Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 10/12] add the sm501fb option to sm501 fb driver
@ 2010-05-04  9:55 yajin
  2010-05-05 12:15 ` Ben Dooks
  0 siblings, 1 reply; 5+ messages in thread
From: yajin @ 2010-05-04  9:55 UTC (permalink / raw)
  To: linux-mips, loongson-dev, wuzhangjin, apatard, vince, ben

Currently the sm501 mode can only be fetched from modedb.c.
Unfortunately the modes in modedb.c are not complete. For example it
lacks the resolution of 1024x600. So the sm501 fb driver should have
the ability to accept the mode option from linux command line.

Signed-off-by: yajin <yajin@vm-kernel.org>
---
 drivers/video/sm501fb.c |   67 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
index b7dc180..f2c69ca 100644
--- a/drivers/video/sm501fb.c
+++ b/drivers/video/sm501fb.c
@@ -43,6 +43,37 @@

 #define NR_PALETTE	256

+static char *mode_option;
+module_param_named(mode, mode_option, charp, 0);
+MODULE_PARM_DESC(mode, "Initial mode");
+
+/*
+ * SM501 Mode
+ *    1024X600 is not defined in default mode(modedb.c).
+ */
+static const struct fb_videomode sm501_modedb[] __initdata = {
+ {
+	/* 1024x600-60 */
+	NULL,  60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
+  FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+ },
+ {
+	 /* 1024x600-70 */
+	 NULL,  70, 1024, 600, 17211, 152,  48, 21, 1, 104, 3,
+  FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+ },
+ {
+	 /* 1024x600-75 */
+	 NULL,  75, 1024, 600, 15822, 160,  56, 23, 1, 104, 3,
+  FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+ },
+ {
+	 /* 1024x600-85 */
+	 NULL,  85, 1024, 600, 13730, 168,  56, 26, 1, 112, 3,
+  FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+ }
+};
+
 enum sm501_controller {
 	HEAD_CRT	= 0,
 	HEAD_PANEL	= 1,
@@ -1729,8 +1760,16 @@ static int sm501fb_init_fb(struct fb_info *fb,
 			fb->var.xres_virtual = fb->var.xres;
 			fb->var.yres_virtual = fb->var.yres;
 		} else {
-			ret = fb_find_mode(&fb->var, fb,
-					   NULL, NULL, 0, NULL, 8);
+			if (mode_option) {
+				dev_info(info->dev, "using user defined mode:"
+						" %s\n", mode_option);
+				ret = fb_find_mode(&fb->var, fb,
+						mode_option, sm501_modedb,
+						ARRAY_SIZE(sm501_modedb),
+						NULL, fb->var.bits_per_pixel);
+			} else
+				ret = fb_find_mode(&fb->var, fb,
+						NULL, NULL, 0, NULL, 8);

 			if (ret == 0 || ret == 4) {
 				dev_err(info->dev,
@@ -2136,8 +2175,32 @@ static struct platform_driver sm501fb_driver = {
 	},
 };

+#ifndef MODULE
+static int  __devinit sm501fb_setup(char *options)
+{
+	char *this_opt;
+
+	if (!options || !*options)
+		return 0;
+
+	while ((this_opt = strsep(&options, ",")) != NULL) {
+		if (!*this_opt)
+			continue;
+		mode_option = this_opt;
+	}
+	return 0;
+}
+#endif
+
 static int __devinit sm501fb_init(void)
 {
+#ifndef MODULE
+	char *option = NULL;
+
+	if (fb_get_options("sm501fb", &option))
+		return -ENODEV;
+	sm501fb_setup(option);
+#endif
 	return platform_driver_register(&sm501fb_driver);
 }

-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-05 13:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04  9:55 [PATCH 10/12] add the sm501fb option to sm501 fb driver yajin
2010-05-05 12:15 ` Ben Dooks
2010-05-05 12:32   ` Arnaud Patard
2010-05-05 13:17     ` yajin
2010-05-05 13:31       ` Arnaud Patard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox