diff options
author | Heiko Stübner <heiko@sntech.de> | 2013-03-22 10:16:29 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2013-04-04 06:08:07 -0400 |
commit | 46574c72c701e45da1e0a2e944df885fcd2db668 (patch) | |
tree | 2001dd31ef6d02096319b0b71f68e04bc331a951 /drivers/video/auo_k190x.c | |
parent | 76de404b452305409182748568444994df765d9d (diff) |
AUO-K190x: add a 16bit truecolor mode
Some applications seem to have problems using the 8bit grayscale mode.
Therefore provide a 16bit truecolor mode which also gets converted to
the 4bit grayscale the display uses, when updating a region.
Signed-off-by: Heiko Stübner <heiko@sntech.de>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video/auo_k190x.c')
-rw-r--r-- | drivers/video/auo_k190x.c | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/drivers/video/auo_k190x.c b/drivers/video/auo_k190x.c index f7f00e34323e..c2a945183a5d 100644 --- a/drivers/video/auo_k190x.c +++ b/drivers/video/auo_k190x.c | |||
@@ -60,6 +60,46 @@ static void auok190x_issue_cmd(struct auok190xfb_par *par, u16 data) | |||
60 | par->board->set_ctl(par, AUOK190X_I80_DC, 1); | 60 | par->board->set_ctl(par, AUOK190X_I80_DC, 1); |
61 | } | 61 | } |
62 | 62 | ||
63 | /** | ||
64 | * Conversion of 16bit color to 4bit grayscale | ||
65 | * does roughly (0.3 * R + 0.6 G + 0.1 B) / 2 | ||
66 | */ | ||
67 | static inline int rgb565_to_gray4(u16 data, struct fb_var_screeninfo *var) | ||
68 | { | ||
69 | return ((((data & 0xF800) >> var->red.offset) * 77 + | ||
70 | ((data & 0x07E0) >> (var->green.offset + 1)) * 151 + | ||
71 | ((data & 0x1F) >> var->blue.offset) * 28) >> 8 >> 1); | ||
72 | } | ||
73 | |||
74 | static int auok190x_issue_pixels_rgb565(struct auok190xfb_par *par, int size, | ||
75 | u16 *data) | ||
76 | { | ||
77 | struct fb_var_screeninfo *var = &par->info->var; | ||
78 | struct device *dev = par->info->device; | ||
79 | int i; | ||
80 | u16 tmp; | ||
81 | |||
82 | if (size & 7) { | ||
83 | dev_err(dev, "issue_pixels: size %d must be a multiple of 8\n", | ||
84 | size); | ||
85 | return -EINVAL; | ||
86 | } | ||
87 | |||
88 | for (i = 0; i < (size >> 2); i++) { | ||
89 | par->board->set_ctl(par, AUOK190X_I80_WR, 0); | ||
90 | |||
91 | tmp = (rgb565_to_gray4(data[4*i], var) & 0x000F); | ||
92 | tmp |= (rgb565_to_gray4(data[4*i+1], var) << 4) & 0x00F0; | ||
93 | tmp |= (rgb565_to_gray4(data[4*i+2], var) << 8) & 0x0F00; | ||
94 | tmp |= (rgb565_to_gray4(data[4*i+3], var) << 12) & 0xF000; | ||
95 | |||
96 | par->board->set_hdb(par, tmp); | ||
97 | par->board->set_ctl(par, AUOK190X_I80_WR, 1); | ||
98 | } | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | |||
63 | static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size, | 103 | static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size, |
64 | u16 *data) | 104 | u16 *data) |
65 | { | 105 | { |
@@ -99,6 +139,8 @@ static int auok190x_issue_pixels(struct auok190xfb_par *par, int size, | |||
99 | 139 | ||
100 | if (info->var.bits_per_pixel == 8 && info->var.grayscale) | 140 | if (info->var.bits_per_pixel == 8 && info->var.grayscale) |
101 | auok190x_issue_pixels_gray8(par, size, data); | 141 | auok190x_issue_pixels_gray8(par, size, data); |
142 | else if (info->var.bits_per_pixel == 16) | ||
143 | auok190x_issue_pixels_rgb565(par, size, data); | ||
102 | else | 144 | else |
103 | dev_err(dev, "unsupported color mode (bits: %d, gray: %d)\n", | 145 | dev_err(dev, "unsupported color mode (bits: %d, gray: %d)\n", |
104 | info->var.bits_per_pixel, info->var.grayscale); | 146 | info->var.bits_per_pixel, info->var.grayscale); |
@@ -419,6 +461,22 @@ static int auok190xfb_check_var(struct fb_var_screeninfo *var, | |||
419 | var->transp.length = 0; | 461 | var->transp.length = 0; |
420 | var->transp.offset = 0; | 462 | var->transp.offset = 0; |
421 | var->transp.msb_right = 0; | 463 | var->transp.msb_right = 0; |
464 | } else if (var->bits_per_pixel == 16) { | ||
465 | var->red.length = 5; | ||
466 | var->red.offset = 11; | ||
467 | var->red.msb_right = 0; | ||
468 | |||
469 | var->green.length = 6; | ||
470 | var->green.offset = 5; | ||
471 | var->green.msb_right = 0; | ||
472 | |||
473 | var->blue.length = 5; | ||
474 | var->blue.offset = 0; | ||
475 | var->blue.msb_right = 0; | ||
476 | |||
477 | var->transp.length = 0; | ||
478 | var->transp.offset = 0; | ||
479 | var->transp.msb_right = 0; | ||
422 | } else { | 480 | } else { |
423 | dev_warn(dev, "unsupported color mode (bits: %d, grayscale: %d)\n", | 481 | dev_warn(dev, "unsupported color mode (bits: %d, grayscale: %d)\n", |
424 | info->var.bits_per_pixel, info->var.grayscale); | 482 | info->var.bits_per_pixel, info->var.grayscale); |
@@ -472,6 +530,15 @@ static int auok190xfb_set_fix(struct fb_info *info) | |||
472 | return 0; | 530 | return 0; |
473 | } | 531 | } |
474 | 532 | ||
533 | static int auok190xfb_set_par(struct fb_info *info) | ||
534 | { | ||
535 | struct auok190xfb_par *par = info->par; | ||
536 | |||
537 | auok190xfb_set_fix(info); | ||
538 | |||
539 | return 0; | ||
540 | } | ||
541 | |||
475 | static struct fb_ops auok190xfb_ops = { | 542 | static struct fb_ops auok190xfb_ops = { |
476 | .owner = THIS_MODULE, | 543 | .owner = THIS_MODULE, |
477 | .fb_read = fb_sys_read, | 544 | .fb_read = fb_sys_read, |
@@ -480,6 +547,7 @@ static struct fb_ops auok190xfb_ops = { | |||
480 | .fb_copyarea = auok190xfb_copyarea, | 547 | .fb_copyarea = auok190xfb_copyarea, |
481 | .fb_imageblit = auok190xfb_imageblit, | 548 | .fb_imageblit = auok190xfb_imageblit, |
482 | .fb_check_var = auok190xfb_check_var, | 549 | .fb_check_var = auok190xfb_check_var, |
550 | .fb_set_par = auok190xfb_set_par, | ||
483 | }; | 551 | }; |
484 | 552 | ||
485 | /* | 553 | /* |
@@ -966,8 +1034,7 @@ int auok190x_common_probe(struct platform_device *pdev, | |||
966 | 1034 | ||
967 | /* videomemory handling */ | 1035 | /* videomemory handling */ |
968 | 1036 | ||
969 | videomemorysize = roundup((panel->w * panel->h) * | 1037 | videomemorysize = roundup((panel->w * panel->h) * 2, PAGE_SIZE); |
970 | info->var.bits_per_pixel / 8, PAGE_SIZE); | ||
971 | videomemory = vmalloc(videomemorysize); | 1038 | videomemory = vmalloc(videomemorysize); |
972 | if (!videomemory) { | 1039 | if (!videomemory) { |
973 | ret = -ENOMEM; | 1040 | ret = -ENOMEM; |