summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhuvanchandra DV <bhuvanchandra.dv@toradex.com>2017-06-14 15:51:27 +0530
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2017-06-30 14:04:16 +0200
commit22db6beb45cba5a67cab9e9a55cd60d7471591d9 (patch)
treec73fc7ff5d60cee05efcea405beab9772f1f7f62
parente7d34fe2e7dacbc98447b107db1d500ee46faf30 (diff)
video: fbdev: mxsfb: allow setting display timings via kernel command line
Add support to allow configuring the display timings via kernel command line. e.g.: video=mxsfb:800x480M-16@60,pixclockpol=1,outputen=1 Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r--drivers/video/fbdev/mxsfb.c80
1 files changed, 59 insertions, 21 deletions
diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
index 0538a636651a..3dffddfc4c0c 100644
--- a/drivers/video/fbdev/mxsfb.c
+++ b/drivers/video/fbdev/mxsfb.c
@@ -224,6 +224,7 @@ struct mxsfb_info {
struct mxc_dispdrv_handle *dispdrv;
int id;
struct fb_var_screeninfo var;
+ char *fb_mode_str;
};
#define mxsfb_is_v3(host) (host->devdata->ipversion == 3)
@@ -514,7 +515,6 @@ static void mxsfb_enable_controller(struct fb_info *fb_info)
"dispdrv:%s\n", host->dispdrv->drv->name);
return;
}
- host->sync = fb_info->var.sync;
}
if (host->reg_lcd) {
@@ -1102,6 +1102,41 @@ static int mxsfb_restore_mode(struct mxsfb_info *host)
return 0;
}
+/*
+ * Parse user specified options (`video=')
+ * e.g.:
+ * video=mxsfb:800x480M-16@60,pixclockpol=1,outputen=1
+ */
+static int mxsfb_option_setup(struct mxsfb_info *host, struct fb_info *fb_info)
+{
+ char *options, *opt;
+ struct platform_device *pdev = host->pdev;
+
+ if (fb_get_options(DRIVER_NAME, &options)) {
+ dev_err(&pdev->dev, "Can't get fb option for %s!\n", DRIVER_NAME);
+ return -ENODEV;
+ }
+
+ if (!options || !*options)
+ return 0;
+
+ while ((opt = strsep(&options, ",")) != NULL) {
+ if (!*opt) {
+ continue;
+ } else if (!strncmp(opt, "pixclockpol=", 12)) {
+ if(simple_strtoul(opt + 12, NULL, 0))
+ host->sync |= FB_SYNC_CLK_LAT_FALL;
+ } else if (!strncmp(opt, "outputen=", 9)) {
+ if(simple_strtoul(opt + 9, NULL, 0))
+ host->sync |= FB_SYNC_OE_LOW_ACT;
+ } else {
+ host->fb_mode_str = opt;
+ }
+ }
+
+ return 0;
+}
+
static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host)
{
struct fb_info *fb_info = host->fb_info;
@@ -1110,10 +1145,13 @@ static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host)
struct device_node *np = host->pdev->dev.of_node;
struct device_node *display_np;
struct display_timings *timings = NULL;
+ struct videomode vm;
+ struct fb_videomode fb_vm;
+ struct fb_videomode native_mode;
const char *disp_dev;
u32 width;
int i;
- int ret = 0;
+ int ret = 0, retval = 0;
host->id = of_alias_get_id(np, "lcdif");
@@ -1169,14 +1207,9 @@ static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host)
goto put_display_node;
}
- for (i = 0; i < timings->num_timings; i++) {
- struct videomode vm;
- struct fb_videomode fb_vm;
-
- /* Only consider native mode */
- if (i != timings->native_mode)
- continue;
+ INIT_LIST_HEAD(&fb_info->modelist);
+ for (i = 0; i < timings->num_timings; i++) {
ret = videomode_from_timings(timings, &vm, i);
if (ret < 0)
goto put_display_node;
@@ -1198,9 +1231,22 @@ static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host)
*/
if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
fb_vm.sync |= FB_SYNC_CLK_LAT_FALL;
+
+ if (i == timings->native_mode) {
+ fb_videomode_from_videomode(&vm, &native_mode);
+ fb_videomode_to_var(&fb_info->var, &fb_vm);
+ }
+
fb_add_videomode(&fb_vm, &fb_info->modelist);
}
+ retval = fb_find_mode(&fb_info->var, fb_info, host->fb_mode_str, &fb_vm,
+ timings->num_timings, &native_mode,
+ fb_info->var.bits_per_pixel);
+ if (retval != 1)
+ /* save the sync value getting from dtb */
+ host->sync = fb_info->var.sync;
+
put_display_node:
if (timings)
kfree(timings);
@@ -1212,7 +1258,6 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host)
{
struct fb_info *fb_info = host->fb_info;
struct fb_var_screeninfo *var = &fb_info->var;
- struct fb_modelist *modelist;
int ret;
fb_info->fbops = &mxsfb_ops;
@@ -1223,6 +1268,10 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host)
fb_info->fix.visual = FB_VISUAL_TRUECOLOR,
fb_info->fix.accel = FB_ACCEL_NONE;
+ ret = mxsfb_option_setup(host, fb_info);
+ if (ret)
+ return ret;
+
ret = mxsfb_init_fbinfo_dt(host);
if (ret)
return ret;
@@ -1232,15 +1281,6 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host)
else
sprintf(fb_info->fix.id, "mxs-lcdif%d", host->id);
- if (!list_empty(&fb_info->modelist)) {
- /* first video mode in the modelist as default video mode */
- modelist = list_first_entry(&fb_info->modelist,
- struct fb_modelist, list);
- fb_videomode_to_var(var, &modelist->mode);
- }
- /* save the sync value getting from dtb */
- host->sync = fb_info->var.sync;
-
var->nonstd = 0;
var->activate = FB_ACTIVATE_NOW;
var->accel_flags = 0;
@@ -1469,8 +1509,6 @@ static int mxsfb_probe(struct platform_device *pdev)
goto fb_release;
}
- INIT_LIST_HEAD(&fb_info->modelist);
-
pm_runtime_enable(&host->pdev->dev);
ret = mxsfb_init_fbinfo(host);