summaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-openmoko-2.6.32/0025-Almost-make-rotation-work.patch
blob: 84132c76499dc0e63bddff8b2d6d93ebe6e21d16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
From 2f37934f81b3f46ad5c3dac6484a2c3c255066fc Mon Sep 17 00:00:00 2001
From: Thomas White <taw@bitwiz.org.uk>
Date: Wed, 28 Apr 2010 00:09:00 +0200
Subject: [PATCH 27/27] Almost make rotation work

Signed-off-by: Thomas White <taw@bitwiz.org.uk>
---
 drivers/mfd/glamo/glamo-display.c |  171 ++++++++++++++++++++++++++++---------
 1 files changed, 129 insertions(+), 42 deletions(-)

diff --git a/drivers/mfd/glamo/glamo-display.c b/drivers/mfd/glamo/glamo-display.c
index a551968..75ad734 100644
--- a/drivers/mfd/glamo/glamo-display.c
+++ b/drivers/mfd/glamo/glamo-display.c
@@ -298,6 +298,7 @@ static int glamo_crtc_mode_set(struct drm_crtc *crtc,
 	struct glamodrm_handle *gdrm;
 	struct glamo_crtc *gcrtc;
 	int retr_start, retr_end, disp_start, disp_end;
+	int rot;
 
 	/* Dig out our handle */
 	gcrtc = to_glamo_crtc(crtc);
@@ -310,49 +311,135 @@ static int glamo_crtc_mode_set(struct drm_crtc *crtc,
 		msleep(500);
 	}
 
+	/* Rotate? */
+	if ( (mode->hdisplay == 640) && (mode->vdisplay == 480) ) {
+		rot = GLAMO_LCD_ROT_MODE_90;
+	} else if ( (mode->hdisplay == 480) && (mode->vdisplay == 640) ) {
+		rot = GLAMO_LCD_ROT_MODE_0;
+	} else if ( (mode->hdisplay == 320) && (mode->vdisplay == 240) ) {
+		rot = GLAMO_LCD_ROT_MODE_90;
+	} else if ( (mode->hdisplay == 240) && (mode->vdisplay == 320) ) {
+		rot = GLAMO_LCD_ROT_MODE_0;
+	} else {
+		printk(KERN_WARNING "[glamo-drm] Couldn't choose rotation.\n");
+		rot = GLAMO_LCD_ROT_MODE_0;
+	}
+
 	glamo_lcd_cmd_mode(gdrm, 1);
 
-	glamo_engine_reclock(gdrm->glamo_core, GLAMO_ENGINE_LCD, mode->clock);
-	gdrm->saved_clock = mode->clock;
+	/* Set dimensions */
+	if ( rot == GLAMO_LCD_ROT_MODE_0 ) {
+
+		glamo_engine_reclock(gdrm->glamo_core, GLAMO_ENGINE_LCD,
+		                     mode->clock);
+
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_WIDTH,
+			             GLAMO_LCD_WIDTH_MASK, mode->hdisplay);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HEIGHT,
+			             GLAMO_LCD_HEIGHT_MASK, mode->vdisplay);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_PITCH,
+			             GLAMO_LCD_PITCH_MASK, mode->hdisplay*2);
+
+		/* Set rotation */
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_WIDTH,
+				     GLAMO_LCD_ROT_MODE_MASK, rot);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_MODE1,
+				     GLAMO_LCD_MODE1_ROTATE_EN,
+				     (rot != GLAMO_LCD_ROT_MODE_0) ?
+				       GLAMO_LCD_MODE1_ROTATE_EN : 0);
+
+		/* Convert "X modeline timings" into "Glamo timings" */
+		retr_start = 0;
+		retr_end = retr_start + mode->hsync_end - mode->hsync_start;
+		disp_start = mode->htotal - mode->hsync_start;
+		disp_end = disp_start + mode->hdisplay;
+
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_TOTAL,
+				     GLAMO_LCD_HV_TOTAL_MASK, mode->htotal);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_START,
+				     GLAMO_LCD_HV_RETR_START_MASK, retr_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_END,
+				     GLAMO_LCD_HV_RETR_END_MASK, retr_end);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_START,
+				     GLAMO_LCD_HV_RETR_DISP_START_MASK, disp_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_END,
+				     GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
+
+		/* The same in the vertical direction */
+		retr_start = 0;
+		retr_end = retr_start + mode->vsync_end - mode->vsync_start;
+		disp_start = mode->vtotal - mode->vsync_start;
+		disp_end = disp_start + mode->vdisplay;
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_TOTAL,
+				     GLAMO_LCD_HV_TOTAL_MASK, mode->vtotal);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_START,
+				     GLAMO_LCD_HV_RETR_START_MASK, retr_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_END,
+				     GLAMO_LCD_HV_RETR_END_MASK, retr_end);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_START,
+				     GLAMO_LCD_HV_RETR_DISP_START_MASK,
+				     disp_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_END,
+				     GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
+
+	} else {
+
+		glamo_engine_reclock(gdrm->glamo_core, GLAMO_ENGINE_LCD,
+		                     mode->clock/2);
+
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_WIDTH,
+			             GLAMO_LCD_WIDTH_MASK, mode->vdisplay);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HEIGHT,
+			             GLAMO_LCD_HEIGHT_MASK, mode->hdisplay);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_PITCH,
+			             GLAMO_LCD_PITCH_MASK, mode->hdisplay*2);
+
+		/* Set rotation */
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_WIDTH,
+				     GLAMO_LCD_ROT_MODE_MASK, rot);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_MODE1,
+				     GLAMO_LCD_MODE1_ROTATE_EN,
+				     (rot != GLAMO_LCD_ROT_MODE_0) ?
+				       GLAMO_LCD_MODE1_ROTATE_EN : 0);
+
+		/* Apply "vertical" numbers to the horizontal registers */
+		retr_start = 0;
+		retr_end = retr_start + mode->vsync_end - mode->vsync_start;
+		disp_start = mode->vtotal - mode->vsync_start;
+		disp_end = disp_start + mode->vdisplay;
+
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_TOTAL,
+				     GLAMO_LCD_HV_TOTAL_MASK, mode->vtotal);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_START,
+				     GLAMO_LCD_HV_RETR_START_MASK, retr_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_END,
+				     GLAMO_LCD_HV_RETR_END_MASK, retr_end);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_START,
+				     GLAMO_LCD_HV_RETR_DISP_START_MASK,
+				     disp_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_END,
+				     GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
+
+		/* Apply "horizontal" numbers to the vertical registers */
+		retr_start = 0;
+		retr_end = retr_start + mode->hsync_end - mode->hsync_start;
+		disp_start = mode->htotal - mode->hsync_start;
+		disp_end = disp_start + mode->hdisplay;
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_TOTAL,
+				     GLAMO_LCD_HV_TOTAL_MASK, mode->htotal);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_START,
+				     GLAMO_LCD_HV_RETR_START_MASK, retr_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_END,
+				     GLAMO_LCD_HV_RETR_END_MASK, retr_end);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_START,
+				     GLAMO_LCD_HV_RETR_DISP_START_MASK,
+				     disp_start);
+		reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_END,
+				     GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
 
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_WIDTH,
-	                     GLAMO_LCD_WIDTH_MASK, mode->hdisplay);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HEIGHT,
-	                     GLAMO_LCD_HEIGHT_MASK, mode->vdisplay);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_PITCH,
-	                     GLAMO_LCD_PITCH_MASK, mode->hdisplay*2);
-
-	/* Convert "X modeline timings" into "Glamo timings" */
-	retr_start = 0;
-	retr_end = retr_start + mode->hsync_end - mode->hsync_start;
-	disp_start = mode->htotal - mode->hsync_start;
-	disp_end = disp_start + mode->hdisplay;
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_TOTAL,
-	                     GLAMO_LCD_HV_TOTAL_MASK, mode->htotal);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_START,
-	                     GLAMO_LCD_HV_RETR_START_MASK, retr_start);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_END,
-	                     GLAMO_LCD_HV_RETR_END_MASK, retr_end);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_START,
-	                     GLAMO_LCD_HV_RETR_DISP_START_MASK, disp_start);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_END,
-	                     GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
-
-	/* The same in the vertical direction */
-	retr_start = 0;
-	retr_end = retr_start + mode->vsync_end - mode->vsync_start;
-	disp_start = mode->vtotal - mode->vsync_start;
-	disp_end = disp_start + mode->vdisplay;
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_TOTAL,
-	                     GLAMO_LCD_HV_TOTAL_MASK, mode->vtotal);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_START,
-	                     GLAMO_LCD_HV_RETR_START_MASK, retr_start);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_END,
-	                     GLAMO_LCD_HV_RETR_END_MASK, retr_end);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_START,
-	                     GLAMO_LCD_HV_RETR_DISP_START_MASK, disp_start);
-	reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_END,
-	                     GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
+	}
+
+	gdrm->saved_clock = mode->clock;
 
 	glamo_lcd_cmd_mode(gdrm, 0);
 
@@ -747,8 +834,8 @@ int glamo_display_init(struct drm_device *dev)
 	drm_mode_config_init(dev);
 
 	dev->mode_config.min_width = 240;
-	dev->mode_config.min_height = 320;
-	dev->mode_config.max_width = 480;
+	dev->mode_config.min_height = 240;
+	dev->mode_config.max_width = 640;
 	dev->mode_config.max_height = 640;
 
 	dev->mode_config.funcs = (void *)&glamo_mode_funcs;
-- 
1.7.1