1 From 3192193f8a1a799783963aaf10119b39c3e8df24 Mon Sep 17 00:00:00 2001
2 From: Balaji Rao <balajirrao@openmoko.org>
3 Date: Thu, 29 Jan 2009 18:25:32 +0000
4 Subject: [PATCH 7/8] Subject: glamo_fix_improper_xrandr_geometry_setting.patch
6 glamo_fix_improper_xrandr_geometry_setting.patch
8 Switching to xrandr -o 3 from xrandr -o 1 caused the screen to look crazy
9 because of the way lcd geometry is set in glamo. This patch fixes it.
11 Signed-off-by: Balaji Rao <balajirrao@openmoko.org>
13 drivers/mfd/glamo/glamo-fb.c | 109 ++++++++++++++++++-----------------------
14 1 files changed, 48 insertions(+), 61 deletions(-)
16 diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c
17 index 91cf75b..16531fa 100644
18 --- a/drivers/mfd/glamo/glamo-fb.c
19 +++ b/drivers/mfd/glamo/glamo-fb.c
20 @@ -75,6 +75,7 @@ struct glamofb_handle {
22 u_int32_t pseudo_pal[16];
24 + int angle; /* Current rotation angle */
27 /* 'sibling' spi device for lcm init */
28 @@ -255,11 +256,6 @@ static void reg_set_bit_mask(struct glamofb_handle *glamo,
29 #define GLAMO_LCD_HV_RETR_DISP_START_MASK 0x03FF
30 #define GLAMO_LCD_HV_RETR_DISP_END_MASK 0x03FF
33 - ORIENTATION_PORTRAIT,
34 - ORIENTATION_LANDSCAPE
38 /* the caller has to enxure lock_cmd is held and we are in cmd mode */
39 static void __rotate_lcd(struct glamofb_handle *glamo, __u32 rotation)
40 @@ -275,17 +271,22 @@ static void __rotate_lcd(struct glamofb_handle *glamo, __u32 rotation)
43 glamo_rot = GLAMO_LCD_ROT_MODE_0;
47 glamo_rot = GLAMO_LCD_ROT_MODE_90;
51 glamo_rot = GLAMO_LCD_ROT_MODE_180;
55 glamo_rot = GLAMO_LCD_ROT_MODE_270;
60 glamo_rot = GLAMO_LCD_ROT_MODE_0;
63 @@ -301,38 +302,12 @@ static void __rotate_lcd(struct glamofb_handle *glamo, __u32 rotation)
64 GLAMO_LCD_MODE1_ROTATE_EN : 0);
67 -static enum orientation get_orientation(struct fb_var_screeninfo *var)
69 - if (var->xres <= var->yres)
70 - return ORIENTATION_PORTRAIT;
72 - return ORIENTATION_LANDSCAPE;
75 -static int will_orientation_change(struct fb_var_screeninfo *var)
77 - enum orientation orient = get_orientation(var);
80 - case ORIENTATION_LANDSCAPE:
81 - if (var->rotate == FB_ROTATE_UR ||
82 - var->rotate == FB_ROTATE_UD)
85 - case ORIENTATION_PORTRAIT:
86 - if (var->rotate == FB_ROTATE_CW ||
87 - var->rotate == FB_ROTATE_CCW)
94 static void glamofb_update_lcd_controller(struct glamofb_handle *glamo,
95 struct fb_var_screeninfo *var)
97 - int sync, bp, disp, fp, total, xres, yres, pitch, orientation_changing;
98 + int sync, bp, disp, fp, total, pitch;
104 @@ -355,31 +330,52 @@ static void glamofb_update_lcd_controller(struct glamofb_handle *glamo,
110 + if (glamo->angle == 90 || glamo->angle == 270) {
112 + * But if we are going back to portrait mode from here,
113 + * we get inverted values from Xglamo
115 + if (!(var->rotate == FB_ROTATE_UR ||
116 + var->rotate == FB_ROTATE_UD)) {
118 + height = var->xres;
121 + height = var->yres;
124 - /* figure out if orientation is going to change */
125 - orientation_changing = will_orientation_change(var);
128 + height = var->yres;
131 - /* adjust the pitch according to new orientation to come */
133 + if (var->rotate == FB_ROTATE_UR || var->rotate == FB_ROTATE_UD) {
134 + /* We don't need to set xres and yres in this particular case
135 + * because Xglamo does it for us */
136 + if (!(glamo->angle == 90 || glamo->angle == 270)) {
137 + var->xres = width;var->yres = height;
140 - if (orientation_changing) {
141 - pitch = var->yres * var->bits_per_pixel / 8;
143 - pitch = var->xres * var->bits_per_pixel / 8;
145 + var->xres_virtual = width * 2;
146 + var->yres_virtual = height;
147 + pitch = width * var->bits_per_pixel / 8;
149 + var->xres = height;
151 + var->xres_virtual = height;
152 + var->yres_virtual = width * 2;
153 + pitch = height * var->bits_per_pixel / 8;
157 - * set the desired LCD geometry
159 reg_set_bit_mask(glamo,
161 GLAMO_LCD_WIDTH_MASK,
164 reg_set_bit_mask(glamo,
165 GLAMO_REG_LCD_HEIGHT,
166 GLAMO_LCD_HEIGHT_MASK,
169 reg_set_bit_mask(glamo,
171 GLAMO_LCD_PITCH_MASK,
172 @@ -388,22 +384,11 @@ static void glamofb_update_lcd_controller(struct glamofb_handle *glamo,
173 /* honour the rotation request */
174 __rotate_lcd(glamo, var->rotate);
176 - /* update the reported geometry of the framebuffer. */
177 - if (orientation_changing) {
178 - var->xres_virtual = var->xres = yres;
179 - var->xres_virtual *= 2;
180 - var->yres_virtual = var->yres = xres;
182 - var->xres_virtual = var->xres = xres;
183 - var->yres_virtual = var->yres = yres;
184 - var->yres_virtual *= 2;
187 /* update scannout timings */
189 bp = sync + var->hsync_len;
190 disp = bp + var->left_margin;
193 total = fp + var->right_margin;
195 reg_set_bit_mask(glamo, GLAMO_REG_LCD_HORIZ_TOTAL,
196 @@ -420,7 +405,7 @@ static void glamofb_update_lcd_controller(struct glamofb_handle *glamo,
198 bp = sync + var->vsync_len;
199 disp = bp + var->upper_margin;
201 + fp = disp + height;
202 total = fp + var->lower_margin;
204 reg_set_bit_mask(glamo, GLAMO_REG_LCD_VERT_TOTAL,
205 @@ -836,6 +821,8 @@ static int __init glamofb_probe(struct platform_device *pdev)
206 glamofb->fb = fbinfo;
207 glamofb->dev = &pdev->dev;
209 + glamofb->angle = 0;
211 strcpy(fbinfo->fix.id, "SMedia Glamo");
213 glamofb->reg = platform_get_resource_byname(pdev, IORESOURCE_MEM,