Skip to content

Commit

Permalink
AUO-K190x: make color handling more flexible
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heiko Stübner authored and Tomi Valkeinen committed Apr 4, 2013
1 parent 4ea80d3 commit 76de404
Showing 1 changed file with 65 additions and 14 deletions.
79 changes: 65 additions & 14 deletions drivers/video/auo_k190x.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,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(struct auok190xfb_par *par, int size,
u16 *data)
static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size,
u16 *data)
{
struct device *dev = par->info->device;
int i;
Expand Down Expand Up @@ -91,6 +91,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;
Expand Down Expand Up @@ -381,6 +396,35 @@ static int auok190xfb_check_var(struct fb_var_screeninfo *var,
struct panel_info *panel = &panel_table[par->resolution];
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
*/
Expand Down Expand Up @@ -410,6 +454,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,
Expand Down Expand Up @@ -894,18 +956,8 @@ int auok190x_common_probe(struct platform_device *pdev,
/* initialise fix, var, resolution and rotation */

strlcpy(info->fix.id, init->id, 16);
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
info->fix.xpanstep = 0;
info->fix.ypanstep = 0;
info->fix.ywrapstep = 0;
info->fix.accel = FB_ACCEL_NONE;

info->var.bits_per_pixel = 8;
info->var.grayscale = 1;
info->var.red.length = 8;
info->var.green.length = 8;
info->var.blue.length = 8;

panel = &panel_table[board->resolution];

Expand Down Expand Up @@ -933,8 +985,7 @@ int auok190x_common_probe(struct platform_device *pdev,
if (ret)
goto err_defio;

info->fix.line_length = info->var.xres_virtual *
info->var.bits_per_pixel / 8;
auok190xfb_set_fix(info);

/* deferred io init */

Expand Down

0 comments on commit 76de404

Please sign in to comment.