AUO-K190x: make color handling more flexible
From: Heiko Stuebner <heiko@...> Date: Sun, 12 Aug 2012 15:49:54 +0200
Commit-Message
Patch-Comment
drivers/video/auo_k190x.c | 79 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 65 insertions(+), 14 deletions(-)
Statistics
- 65 lines added
- 14 lines removed
Changes
-------------------------- drivers/video/auo_k190x.c ---------------------------
index 7f4c4ef..848cfe9 100644
@@ -59,8 +59,8 @@ static void auok190x_issue_cmd(struct auok190xfb_par *par, u16 data)
par->board->set_ctl(par, AUOK190X_I80_DC, 1);
}
+static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size,
+ u16 *data)
{
struct device *dev = par->info->device;
int i;
@@ -90,6 +90,21 @@ static int auok190x_issue_pixels(struct auok190xfb_par *par, int size,
return 0;
}
+static int auok190x_issue_pixels(struct auok190xfb_par *par, int size,
+ u16 *data)
+{
+ struct fb_info *info = par->info;
+ struct device *dev = par->info->device;
+
+ if (info->var.bits_per_pixel == 8 && info->var.grayscale)
+ auok190x_issue_pixels_gray8(par, size, data);
+ else
+ dev_err(dev, "unsupported color mode (bits: %d, gray: %d)\n",
+ info->var.bits_per_pixel, info->var.grayscale);
+
+ return 0;
+}
+
static u16 auok190x_read_data(struct auok190xfb_par *par)
{
u16 data;
@@ -381,6 +396,35 @@ static int auok190xfb_check_var(struct fb_var_screeninfo *var,
int size;
/*
+ * Color depth
+ */
+
+ if (var->bits_per_pixel == 8 && var->grayscale == 1) {
+ /*
+ * For 8-bit grayscale, R, G, and B offset are equal.
+ */
+ var->red.length = 8;
+ var->red.offset = 0;
+ var->red.msb_right = 0;
+
+ var->green.length = 8;
+ var->green.offset = 0;
+ var->green.msb_right = 0;
+
+ var->blue.length = 8;
+ var->blue.offset = 0;
+ var->blue.msb_right = 0;
+
+ var->transp.length = 0;
+ var->transp.offset = 0;
+ var->transp.msb_right = 0;
+ } else {
+ dev_warn(dev, "unsupported color mode (bits: %d, grayscale: %d)\n",
+ info->var.bits_per_pixel, info->var.grayscale);
+ return -EINVAL;
+ }
+
+ /*
* Dimensions
*/
@@ -409,6 +453,24 @@ static int auok190xfb_check_var(struct fb_var_screeninfo *var,
return 0;
}
+static int auok190xfb_set_fix(struct fb_info *info)
+{
+ struct fb_fix_screeninfo *fix = &info->fix;
+ struct fb_var_screeninfo *var = &info->var;
+
+ fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
+
+ fix->type = FB_TYPE_PACKED_PIXELS;
+ fix->accel = FB_ACCEL_NONE;
+ fix->visual = (var->grayscale) ? FB_VISUAL_STATIC_PSEUDOCOLOR
+ : FB_VISUAL_TRUECOLOR;
+ fix->xpanstep = 0;
+ fix->ypanstep = 0;
+ fix->ywrapstep = 0;
+
+ return 0;
+}
+
static struct fb_ops auok190xfb_ops = {
.owner = THIS_MODULE,
.fb_read = fb_sys_read,
@@ -893,18 +955,8 @@ int __devinit auok190x_common_probe(struct platform_device *pdev,
/* initialise fix, var, resolution and rotation */
strlcpy(info->fix.id, init->id, 16);
info->var.bits_per_pixel = 8;
info->var.grayscale = 1;
panel = &panel_table[board->resolution];
@@ -932,8 +984,7 @@ int __devinit auok190x_common_probe(struct platform_device *pdev,
if (ret)
goto err_defio;
+ auok190xfb_set_fix(info);
/* deferred io init */