[PATCH 2/4] fbset support

Chia-I Wu olv at openmoko.com
Wed Dec 5 15:18:38 CET 2007


This is a multi-part message in MIME format.
--------------1.5.3.1
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


Move modeline setting to a function of itself.  Call this function on
initialization and set_par.

Signed-off-by: Chia-I Wu <olv at openmoko.com>
---
 drivers/video/glamo/glamo-fb.c |  103 +++++++++++++++++++++++++---------------
 1 files changed, 65 insertions(+), 38 deletions(-)
--------------1.5.3.1
Content-Type: text/x-patch; name="652885a2d7f48fa4675b7c3d7a2a3736a24a50fa.diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="652885a2d7f48fa4675b7c3d7a2a3736a24a50fa.diff"

diff --git a/drivers/video/glamo/glamo-fb.c b/drivers/video/glamo/glamo-fb.c
index 451de75..3a102e4 100644
--- a/drivers/video/glamo/glamo-fb.c
+++ b/drivers/video/glamo/glamo-fb.c
@@ -99,25 +99,12 @@ static struct glamo_script glamo_regs[] = {
 	{ GLAMO_REG_LCD_MODE3, 0x0b40 },
 	  /* src data rgb565, res, 18bit rgb666
 	   * 000 01 011 0100 0000 */
-	{ GLAMO_REG_LCD_WIDTH, 480 },
-	{ GLAMO_REG_LCD_HEIGHT, 640 },
 	{ GLAMO_REG_LCD_POLARITY, 0x440c },
 	  /* DE high active, no cpu/lcd if, cs0 force low, a0 low active,
 	   * np cpu if, 9bit serial data, sclk rising edge latch data
 	   * 01 00 0 100 0 000 01 0 0 */
 	{ GLAMO_REG_LCD_A_BASE1, 0x0000 }, /* display A base address 15:0 */
 	{ GLAMO_REG_LCD_A_BASE2, 0x0000 }, /* display A base address 22:16 */
-	{ GLAMO_REG_LCD_PITCH, 480*2 },
-	{ GLAMO_REG_LCD_HORIZ_TOTAL, 480 + 8 + 8 + 104 }, /* 600 */
-	{ GLAMO_REG_LCD_HORIZ_RETR_START, 0 },
-	{ GLAMO_REG_LCD_HORIZ_RETR_END, 8 },
-	{ GLAMO_REG_LCD_HORIZ_DISP_START, 8 + 104 },
-	{ GLAMO_REG_LCD_HORIZ_DISP_END, 8 + 104 + 480 },
-	{ GLAMO_REG_LCD_VERT_TOTAL, 640 + 2 + 2 + 16 }, /* 660 */
-	{ GLAMO_REG_LCD_VERT_RETR_START, 0 },
-	{ GLAMO_REG_LCD_VERT_RETR_END, 2 },
-	{ GLAMO_REG_LCD_VERT_DISP_START, 2 + 2 },
-	{ GLAMO_REG_LCD_VERT_DISP_END, 2 + 2 + 640 },
 };
 
 static int glamofb_run_script(struct glamofb_handle *glamo,
@@ -207,24 +194,64 @@ static int glamofb_check_var(struct fb_var_screeninfo *var,
 	return 0;
 }
 
+static void glamofb_activate_var(struct glamofb_handle *glamo,
+				struct fb_var_screeninfo *var)
+{
+	int sync, bp, disp, fp, total;
+
+	glamofb_cmd_mode(glamo, 1);
+
+	/* XXX highest bits of the following two regs have other meanings */
+	reg_write(glamo, GLAMO_REG_LCD_WIDTH, var->xres);
+	reg_write(glamo, GLAMO_REG_LCD_HEIGHT, var->yres);
+	reg_write(glamo, GLAMO_REG_LCD_PITCH,
+			(var->xres * var->bits_per_pixel) / 8);
+
+	sync = 0;
+	bp = sync + var->hsync_len;
+	disp = bp + var->left_margin;
+	fp = disp + var->xres;
+	total = fp + var->right_margin;
+
+	reg_write(glamo, GLAMO_REG_LCD_HORIZ_TOTAL, total);
+	reg_write(glamo, GLAMO_REG_LCD_HORIZ_RETR_START, sync);
+	reg_write(glamo, GLAMO_REG_LCD_HORIZ_RETR_END, bp);
+	reg_write(glamo, GLAMO_REG_LCD_HORIZ_DISP_START, disp);
+	reg_write(glamo, GLAMO_REG_LCD_HORIZ_DISP_END, fp);
+
+	sync = 0;
+	bp = sync + var->vsync_len;
+	disp = bp + var->upper_margin;
+	fp = disp + var->yres;
+	total = fp + var->lower_margin;
+
+	reg_write(glamo, GLAMO_REG_LCD_VERT_TOTAL, total);
+	reg_write(glamo, GLAMO_REG_LCD_VERT_RETR_START, sync);
+	reg_write(glamo, GLAMO_REG_LCD_VERT_RETR_END, bp);
+	reg_write(glamo, GLAMO_REG_LCD_VERT_DISP_START, disp);
+	reg_write(glamo, GLAMO_REG_LCD_VERT_DISP_END, fp);
+
+	glamofb_cmd_mode(glamo, 0);
+}
+
 static int glamofb_set_par(struct fb_info *info)
 {
 	struct glamofb_handle *glamo = info->par;
 	struct fb_var_screeninfo *var = &info->var;
 
-	/* FIXME */
-
 	switch (var->bits_per_pixel) {
 	case 16:
-		glamo->fb->fix.visual = FB_VISUAL_TRUECOLOR;
+		info->fix.visual = FB_VISUAL_TRUECOLOR;
 		break;
 	default:
 		printk("Smedia driver doens't support != 16bpp\n");
 		return -EINVAL;
 	}
 
-	glamo->fb->fix.line_length = (var->width * var->bits_per_pixel) / 8;
-	glamo->fb->fix.smem_len = info->fix.line_length * var->yres_virtual;
+	info->fix.line_length = (var->xres * var->bits_per_pixel) / 8;
+	info->fix.smem_len = info->fix.line_length * var->yres_virtual;
+
+	glamofb_activate_var(glamo, var);
 
 	return 0;
 }
@@ -384,7 +411,6 @@ EXPORT_SYMBOL_GPL(glamofb_cmd_mode);
 
 int glamofb_cmd_write(struct glamofb_handle *gfb, u_int16_t val)
 {
-
 	dev_dbg(gfb->dev, "%s: waiting for cmdq empty\n",
 		__FUNCTION__);
 	while (!glamofb_cmdq_empty(gfb))
@@ -409,6 +435,18 @@ static struct fb_ops glamofb_ops = {
 	.fb_imageblit	= cfb_imageblit,
 };
 
+static int glamofb_init_regs(struct glamofb_handle *glamo)
+{
+	struct fb_info *info = glamo->fb;
+	struct fb_var_screeninfo *var = &info->var;
+
+	glamofb_check_var(&info->var, info);
+	glamofb_run_script(glamo, glamo_regs, ARRAY_SIZE(glamo_regs));
+	glamofb_set_par(info);
+
+	return 0;
+}
+
 static int __init glamofb_probe(struct platform_device *pdev)
 {
 	int rc = -EIO;
@@ -504,24 +542,14 @@ static int __init glamofb_probe(struct platform_device *pdev)
 	fbinfo->var.yres_virtual = mach_info->yres.defval;
 	fbinfo->var.bits_per_pixel = mach_info->bpp.defval;
 
-#if 0
-	fbinfo->var.upper_margin =
-	fbinfo->var.lower_margin =
-	fbinfo->var.vsync_len = 2;
-
-	fbinfo->var.left_margin =
-	fbinfo->var.right_margin =
-	fbinfo->var.hsync_len = 8;
-#endif
+	fbinfo->var.pixclock = mach_info->pixclock;
+	fbinfo->var.left_margin = mach_info->left_margin;
+	fbinfo->var.right_margin = mach_info->right_margin;
+	fbinfo->var.upper_margin = mach_info->upper_margin;
+	fbinfo->var.lower_margin = mach_info->lower_margin;
+	fbinfo->var.hsync_len = mach_info->hsync_len;
+	fbinfo->var.vsync_len = mach_info->vsync_len;
 
-	fbinfo->var.red.offset = 11;
-	fbinfo->var.green.offset = 5;
-	fbinfo->var.blue.offset = 0;
-	fbinfo->var.transp.offset = 0;
-	fbinfo->var.red.length = 5;
-	fbinfo->var.green.length = 6;
-	fbinfo->var.blue.length = 5;
-	fbinfo->var.transp.length = 0;
 	fbinfo->fix.smem_len = mach_info->xres.max *
 			       mach_info->yres.max *
 			       mach_info->bpp.max / 8;
@@ -530,8 +558,7 @@ static int __init glamofb_probe(struct platform_device *pdev)
 
 	glamo_engine_enable(mach_info->glamo, GLAMO_ENGINE_LCD);
 	glamo_engine_reset(mach_info->glamo, GLAMO_ENGINE_LCD);
-	glamofb_run_script(glamofb, glamo_regs, ARRAY_SIZE(glamo_regs));
-	glamofb_cmd_mode(glamofb, 0);
+	glamofb_init_regs(glamofb);
 
 	rc = register_framebuffer(fbinfo);
 	if (rc < 0) {

--------------1.5.3.1--






More information about the openmoko-kernel mailing list