Add 16bpp BMP support
PATCH 1/1 Add 16bpp BMP support
This patch adds 16bpp BMP support to the common lcd code.
At the moment it's only been tested on the MIMC200 AVR32 board, but the hooks are in place to extend this to other platforms.
---
common/lcd.c | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 44 insertions(+), 10 deletions(-)
common/lcd.c +44 -10
@@ -84,7 +84,7 @@ extern void lcd_enable (void);static void *lcd_logo (void ); -#if LCD_BPP ==LCD_COLOR8 +#if (LCD_BPP ==LCD_COLOR8 ) || (LCD_BPP ==LCD_COLOR16 )extern void lcd_setcolreg (ushort regno,ushort red,ushort green,ushort blue);#endif
@@ -656,7 +656,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) bpix =NBITS (panel_info.vl_bpix); -if ((bpix !=1 ) && (bpix !=8 )) { +if ((bpix !=1 ) && (bpix !=8 ) && (bpix !=16 )) {printf ("Error: %d bit/pixel mode not supported by U-Boot\n" , bpix);return 1 ;
@@ -738,17 +738,51 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) bmap = (uchar *)bmp +le32_to_cpu (bmp->header.data_offset); fb = (uchar *) (lcd_base + (y + height -1 ) * lcd_line_length + x); -for (i =0 ; i < height; ++i) { -WATCHDOG_RESET (); - for (j = 0; j < width ; j++) + +switch (bpix) { +case 1 :/* pass through */ +case 8 : +for (i =0 ; i < height; ++i) { +WATCHDOG_RESET (); + for (j = 0; j < width ; j++)#if defined(CONFIG_PXA250 ) || defined(CONFIG_ATMEL_LCD ) - *(fb++) = *(bmap++); + *(fb++) = *(bmap++);#elif defined(CONFIG_MPC823 ) || defined(CONFIG_MCC200 ) - *(fb++)=255 -*(bmap++); + *(fb++)=255 -*(bmap++);#endif - bmap += (width - padded_line); - fb -= (width + lcd_line_length); - } + bmap += (width - padded_line); + fb -= (width + lcd_line_length); + } +break ; + +case 16 : +for (i =0 ; i < height; ++i) { +WATCHDOG_RESET (); +for (j =0 ; j < width; j++) { +#if defined(CONFIG_PXA250 ) +#error 16 bpp support not added for PXA250 +#elif defined(CONFIG_ATMEL_LCD ) +#if defined(CONFIG_ATMEL_LCD_BGR555 ) + *(fb++) = ((bmap[0 ] &0x1f ) <<2 ) | (bmap[1 ] &0x03 ); + *(fb++) = (bmap[0 ] &0xe0 ) | ((bmap[1 ] &0x7c ) >>2 ); + bmap +=2 ; +#else + *(fb++) = *(bmap++); + *(fb++) = *(bmap++); +#endif +#elif defined(CONFIG_MPC823 ) +#error 16 bpp support not added for MPC823 +#elif defined(CONFIG_MCC200 ) +#error 16 bpp support not added for MCC200 +#endif + } + bmap += (padded_line - width) *2 ; + fb -= (width *2 + lcd_line_length); + } +break ; +default : +break ; + };return (0 ); }
Wolfgang Denk
NAKPATCH 1/1 Add 16bpp BMP support
Dear Mark Jackson,
Quoted 7 lines · In message <[email protected]> you wrote:
This patch adds 16bpp BMP support to the common lcd code.
At the moment it's only been tested on the MIMC200 AVR32 board, but the hooks are in place to extend this to other platforms.
Signed-off-by Mark Jackson <[email protected]>---
...
common/lcd.c int lcd_display_bitmap(ulong bmp_image, int x, int y) · line 765
Quoted 8 lines
common/lcd.c +8
-0+case 16 : +for (i =0 ; i < height; ++i) { +WATCHDOG_RESET (); +for (j =0 ; j < width; j++) { +#if defined(CONFIG_PXA250 ) +#error 16 bpp support not added for PXA250 +#elif defined(CONFIG_ATMEL_LCD ) +#if defined(CONFIG_ATMEL_LCD_BGR555 )
Oops. Right in the middle of a for loop?
This is probably not exactly a good
place for the placement of such a generic compile time check.
common/lcd.c int lcd_display_bitmap(ulong bmp_image, int x, int y) · line 777
Quoted 12 lines
common/lcd.c +12
-0+ *(fb++) = ((bmap[0 ] &0x1f ) <<2 ) | (bmap[1 ] &0x03 ); + *(fb++) = (bmap[0 ] &0xe0 ) | ((bmap[1 ] &0x7c ) >>2 ); + bmap +=2 ; +#else + *(fb++) = *(bmap++); + *(fb++) = *(bmap++); +#endif +#elif defined(CONFIG_MPC823 ) +#error 16 bpp support not added for MPC823 +#elif defined(CONFIG_MCC200 ) +#error 16 bpp support not added for MCC200 +#endif
Ditto here.
I don't like this approach. The code is too ugly. If you need dfferent versions, thatn factor out the different code into functions, or similar.
NAK.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Even historians fail to learn from history -- they repeat the same mistakes. -- John Gill, "Patterns of Force", stardate 2534.7