Commit fd0858017eb67aa0d41dd4e8499ca6a7bfb63941

Authored by Nicolas Ferre
Committed by Linus Torvalds
1 parent cf19a37e06

atmel_lcdfb: wiring BGR to RGB color mode

Adds different wiring mode for the LCD screen.

The legacy atmel LCDC IP uses a non standard color mode, "BGR-555.1" instead
"RGB-565".  The major part of graphic stacks for embedded systems uses only
"RGB-565".  It is possible to swap LCD IOs instead of doing this bit swapping
by software (See application note AT91SAM9 LCD Controller
http://www.atmel.com/dyn/resources/prod_documents/doc6300.pdf)

This wire swapping is done on the at91sam9rl-ek board (board code
using this patch will come later).

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Andrew Victor <avictor.za@gmail.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 32 additions and 5 deletions Side-by-side Diff

drivers/video/atmel_lcdfb.c
... ... @@ -338,19 +338,35 @@
338 338 break;
339 339 case 15:
340 340 case 16:
341   - var->red.offset = 0;
  341 + if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
  342 + /* RGB:565 mode */
  343 + var->red.offset = 11;
  344 + var->blue.offset = 0;
  345 + var->green.length = 6;
  346 + } else {
  347 + /* BGR:555 mode */
  348 + var->red.offset = 0;
  349 + var->blue.offset = 10;
  350 + var->green.length = 5;
  351 + }
342 352 var->green.offset = 5;
343   - var->blue.offset = 10;
344   - var->red.length = var->green.length = var->blue.length = 5;
  353 + var->red.length = var->blue.length = 5;
345 354 break;
346 355 case 32:
347 356 var->transp.offset = 24;
348 357 var->transp.length = 8;
349 358 /* fall through */
350 359 case 24:
351   - var->red.offset = 0;
  360 + if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
  361 + /* RGB:888 mode */
  362 + var->red.offset = 16;
  363 + var->blue.offset = 0;
  364 + } else {
  365 + /* BGR:888 mode */
  366 + var->red.offset = 0;
  367 + var->blue.offset = 16;
  368 + }
352 369 var->green.offset = 8;
353   - var->blue.offset = 16;
354 370 var->red.length = var->green.length = var->blue.length = 8;
355 371 break;
356 372 default:
... ... @@ -697,6 +713,7 @@
697 713 sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control;
698 714 sinfo->guard_time = pdata_sinfo->guard_time;
699 715 sinfo->lcdcon_is_backlight = pdata_sinfo->lcdcon_is_backlight;
  716 + sinfo->lcd_wiring_mode = pdata_sinfo->lcd_wiring_mode;
700 717 } else {
701 718 dev_err(dev, "cannot get default configuration\n");
702 719 goto free_info;
include/video/atmel_lcdc.h
... ... @@ -22,6 +22,15 @@
22 22 #ifndef __ATMEL_LCDC_H__
23 23 #define __ATMEL_LCDC_H__
24 24  
  25 +
  26 +/* Way LCD wires are connected to the chip:
  27 + * Some Atmel chips use BGR color mode (instead of standard RGB)
  28 + * A swapped wiring onboard can bring to RGB mode.
  29 + */
  30 +#define ATMEL_LCDC_WIRING_BGR 0
  31 +#define ATMEL_LCDC_WIRING_RGB 1
  32 +
  33 +
25 34 /* LCD Controller info data structure, stored in device platform_data */
26 35 struct atmel_lcdfb_info {
27 36 spinlock_t lock;
... ... @@ -42,6 +51,7 @@
42 51 u8 saved_lcdcon;
43 52  
44 53 u8 default_bpp;
  54 + u8 lcd_wiring_mode;
45 55 unsigned int default_lcdcon2;
46 56 unsigned int default_dmacon;
47 57 void (*atmel_lcdfb_power_control)(int on);