Skip to content

Commit 1e109da

Browse files
jhovoldgregkh
authored andcommitted
atmel_lcdfb: fix 16-bpp modes on older SOCs
commit a79eac7 upstream. Fix regression introduced by commit 787f9fd ("atmel_lcdfb: support 16bit BGR:565 mode, remove unsupported 15bit modes") which broke 16-bpp modes for older SOCs which use IBGR:555 (msb is intensity) rather than BGR:565. Use SOC-type to determine the pixel layout. Tested on at91sam9263 and at91sam9g45. Acked-by: Peter Korsgaard <jacmet@sunsite.dk> Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c442763 commit 1e109da

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

‎drivers/video/atmel_lcdfb.c‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,22 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
422422
= var->bits_per_pixel;
423423
break;
424424
case 16:
425+
/* Older SOCs use IBGR:555 rather than BGR:565. */
426+
if (sinfo->have_intensity_bit)
427+
var->green.length = 5;
428+
else
429+
var->green.length = 6;
430+
425431
if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
426-
/* RGB:565 mode */
427-
var->red.offset = 11;
432+
/* RGB:5X5 mode */
433+
var->red.offset = var->green.length + 5;
428434
var->blue.offset = 0;
429435
} else {
430-
/* BGR:565 mode */
436+
/* BGR:5X5 mode */
431437
var->red.offset = 0;
432-
var->blue.offset = 11;
438+
var->blue.offset = var->green.length + 5;
433439
}
434440
var->green.offset = 5;
435-
var->green.length = 6;
436441
var->red.length = var->blue.length = 5;
437442
break;
438443
case 32:
@@ -679,8 +684,7 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
679684

680685
case FB_VISUAL_PSEUDOCOLOR:
681686
if (regno < 256) {
682-
if (cpu_is_at91sam9261() || cpu_is_at91sam9263()
683-
|| cpu_is_at91sam9rl()) {
687+
if (sinfo->have_intensity_bit) {
684688
/* old style I+BGR:555 */
685689
val = ((red >> 11) & 0x001f);
686690
val |= ((green >> 6) & 0x03e0);
@@ -870,6 +874,10 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
870874
}
871875
sinfo->info = info;
872876
sinfo->pdev = pdev;
877+
if (cpu_is_at91sam9261() || cpu_is_at91sam9263() ||
878+
cpu_is_at91sam9rl()) {
879+
sinfo->have_intensity_bit = true;
880+
}
873881

874882
strcpy(info->fix.id, sinfo->pdev->name);
875883
info->flags = ATMEL_LCDFB_FBINFO_DEFAULT;

‎include/video/atmel_lcdc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct atmel_lcdfb_info {
6262
void (*atmel_lcdfb_power_control)(int on);
6363
struct fb_monspecs *default_monspecs;
6464
u32 pseudo_palette[16];
65+
bool have_intensity_bit;
6566
};
6667

6768
#define ATMEL_LCDC_DMABADDR1 0x00

0 commit comments

Comments
 (0)