Skip to content

Commit

Permalink
atmel_lcdfb: fix 16-bpp modes on older SOCs
Browse files Browse the repository at this point in the history
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.

Cc: <[email protected]>
Acked-by: Peter Korsgaard <[email protected]>
Signed-off-by: Johan Hovold <[email protected]>
Signed-off-by: Nicolas Ferre <[email protected]>
  • Loading branch information
jhovold authored and Nicolas Ferre committed Mar 13, 2013
1 parent f6161aa commit a79eac7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
22 changes: 15 additions & 7 deletions drivers/video/atmel_lcdfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,17 +422,22 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
= var->bits_per_pixel;
break;
case 16:
/* Older SOCs use IBGR:555 rather than BGR:565. */
if (sinfo->have_intensity_bit)
var->green.length = 5;
else
var->green.length = 6;

if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
/* RGB:565 mode */
var->red.offset = 11;
/* RGB:5X5 mode */
var->red.offset = var->green.length + 5;
var->blue.offset = 0;
} else {
/* BGR:565 mode */
/* BGR:5X5 mode */
var->red.offset = 0;
var->blue.offset = 11;
var->blue.offset = var->green.length + 5;
}
var->green.offset = 5;
var->green.length = 6;
var->red.length = var->blue.length = 5;
break;
case 32:
Expand Down Expand Up @@ -679,8 +684,7 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,

case FB_VISUAL_PSEUDOCOLOR:
if (regno < 256) {
if (cpu_is_at91sam9261() || cpu_is_at91sam9263()
|| cpu_is_at91sam9rl()) {
if (sinfo->have_intensity_bit) {
/* old style I+BGR:555 */
val = ((red >> 11) & 0x001f);
val |= ((green >> 6) & 0x03e0);
Expand Down Expand Up @@ -870,6 +874,10 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
}
sinfo->info = info;
sinfo->pdev = pdev;
if (cpu_is_at91sam9261() || cpu_is_at91sam9263() ||
cpu_is_at91sam9rl()) {
sinfo->have_intensity_bit = true;
}

strcpy(info->fix.id, sinfo->pdev->name);
info->flags = ATMEL_LCDFB_FBINFO_DEFAULT;
Expand Down
1 change: 1 addition & 0 deletions include/video/atmel_lcdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct atmel_lcdfb_info {
void (*atmel_lcdfb_power_control)(int on);
struct fb_monspecs *default_monspecs;
u32 pseudo_palette[16];
bool have_intensity_bit;
};

#define ATMEL_LCDC_DMABADDR1 0x00
Expand Down

0 comments on commit a79eac7

Please sign in to comment.