aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/auo_k190x.c
diff options
context:
space:
mode:
authorHeiko Stübner <heiko@sntech.de>2013-03-22 10:15:55 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2013-04-04 06:08:07 -0400
commit76de404b452305409182748568444994df765d9d (patch)
tree841692bcf7c145e71bcc9c52110559e27ca001be /drivers/video/auo_k190x.c
parent4ea80d35b4e0cdb23c42d2664fb745f0afe397d1 (diff)
AUO-K190x: make color handling more flexible
Don't hardcode the 8bit mode in all parts. This creates the possibility to add another colormode easily later on. 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.c79
1 files changed, 65 insertions, 14 deletions
diff --git a/drivers/video/auo_k190x.c b/drivers/video/auo_k190x.c
index a77513b0e18c..f7f00e34323e 100644
--- a/drivers/video/auo_k190x.c
+++ b/drivers/video/auo_k190x.c
@@ -60,8 +60,8 @@ 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
63static int auok190x_issue_pixels(struct auok190xfb_par *par, int size, 63static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size,
64 u16 *data) 64 u16 *data)
65{ 65{
66 struct device *dev = par->info->device; 66 struct device *dev = par->info->device;
67 int i; 67 int i;
@@ -91,6 +91,21 @@ static int auok190x_issue_pixels(struct auok190xfb_par *par, int size,
91 return 0; 91 return 0;
92} 92}
93 93
94static int auok190x_issue_pixels(struct auok190xfb_par *par, int size,
95 u16 *data)
96{
97 struct fb_info *info = par->info;
98 struct device *dev = par->info->device;
99
100 if (info->var.bits_per_pixel == 8 && info->var.grayscale)
101 auok190x_issue_pixels_gray8(par, size, data);
102 else
103 dev_err(dev, "unsupported color mode (bits: %d, gray: %d)\n",
104 info->var.bits_per_pixel, info->var.grayscale);
105
106 return 0;
107}
108
94static u16 auok190x_read_data(struct auok190xfb_par *par) 109static u16 auok190x_read_data(struct auok190xfb_par *par)
95{ 110{
96 u16 data; 111 u16 data;
@@ -382,6 +397,35 @@ static int auok190xfb_check_var(struct fb_var_screeninfo *var,
382 int size; 397 int size;
383 398
384 /* 399 /*
400 * Color depth
401 */
402
403 if (var->bits_per_pixel == 8 && var->grayscale == 1) {
404 /*
405 * For 8-bit grayscale, R, G, and B offset are equal.
406 */
407 var->red.length = 8;
408 var->red.offset = 0;
409 var->red.msb_right = 0;
410
411 var->green.length = 8;
412 var->green.offset = 0;
413 var->green.msb_right = 0;
414
415 var->blue.length = 8;
416 var->blue.offset = 0;
417 var->blue.msb_right = 0;
418
419 var->transp.length = 0;
420 var->transp.offset = 0;
421 var->transp.msb_right = 0;
422 } else {
423 dev_warn(dev, "unsupported color mode (bits: %d, grayscale: %d)\n",
424 info->var.bits_per_pixel, info->var.grayscale);
425 return -EINVAL;
426 }
427
428 /*
385 * Dimensions 429 * Dimensions
386 */ 430 */
387 431
@@ -410,6 +454,24 @@ static int auok190xfb_check_var(struct fb_var_screeninfo *var,
410 return 0; 454 return 0;
411} 455}
412 456
457static int auok190xfb_set_fix(struct fb_info *info)
458{
459 struct fb_fix_screeninfo *fix = &info->fix;
460 struct fb_var_screeninfo *var = &info->var;
461
462 fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
463
464 fix->type = FB_TYPE_PACKED_PIXELS;
465 fix->accel = FB_ACCEL_NONE;
466 fix->visual = (var->grayscale) ? FB_VISUAL_STATIC_PSEUDOCOLOR
467 : FB_VISUAL_TRUECOLOR;
468 fix->xpanstep = 0;
469 fix->ypanstep = 0;
470 fix->ywrapstep = 0;
471
472 return 0;
473}
474
413static struct fb_ops auok190xfb_ops = { 475static struct fb_ops auok190xfb_ops = {
414 .owner = THIS_MODULE, 476 .owner = THIS_MODULE,
415 .fb_read = fb_sys_read, 477 .fb_read = fb_sys_read,
@@ -894,18 +956,8 @@ int auok190x_common_probe(struct platform_device *pdev,
894 /* initialise fix, var, resolution and rotation */ 956 /* initialise fix, var, resolution and rotation */
895 957
896 strlcpy(info->fix.id, init->id, 16); 958 strlcpy(info->fix.id, init->id, 16);
897 info->fix.type = FB_TYPE_PACKED_PIXELS;
898 info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
899 info->fix.xpanstep = 0;
900 info->fix.ypanstep = 0;
901 info->fix.ywrapstep = 0;
902 info->fix.accel = FB_ACCEL_NONE;
903
904 info->var.bits_per_pixel = 8; 959 info->var.bits_per_pixel = 8;
905 info->var.grayscale = 1; 960 info->var.grayscale = 1;
906 info->var.red.length = 8;
907 info->var.green.length = 8;
908 info->var.blue.length = 8;
909 961
910 panel = &panel_table[board->resolution]; 962 panel = &panel_table[board->resolution];
911 963
@@ -933,8 +985,7 @@ int auok190x_common_probe(struct platform_device *pdev,
933 if (ret) 985 if (ret)
934 goto err_defio; 986 goto err_defio;
935 987
936 info->fix.line_length = info->var.xres_virtual * 988 auok190xfb_set_fix(info);
937 info->var.bits_per_pixel / 8;
938 989
939 /* deferred io init */ 990 /* deferred io init */
940 991