[ar71xx] fix GPIO function select bit definitions (based on a patch by Jonas <jmajau...
[openwrt.git] / target / linux / s3c24xx / patches-2.6.26 / 1151-Subject-PATCH-Hardware-glamo-fb-cursor-some-clea.patch
1 From 824fc22a0aaacf942eb3b3dfa6aad32c7285669f Mon Sep 17 00:00:00 2001
2 From: Andrzej Zaborowski <balrog@zabor.org>
3 Date: Fri, 25 Jul 2008 23:06:11 +0100
4 Subject: [PATCH] Subject: [PATCH] Hardware glamo-fb cursor, some clean-up.
5
6 ---
7 drivers/mfd/glamo/glamo-fb.c | 105 +++++++++++++++++++++--------------------
8 include/linux/fb.h | 1 +
9 2 files changed, 55 insertions(+), 51 deletions(-)
10
11 diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c
12 index edc6d9c..30cdb38 100644
13 --- a/drivers/mfd/glamo/glamo-fb.c
14 +++ b/drivers/mfd/glamo/glamo-fb.c
15 @@ -117,6 +117,8 @@ static struct glamo_script glamo_regs[] = {
16 * 01 00 0 100 0 000 01 0 0 */
17 { GLAMO_REG_LCD_A_BASE1, 0x0000 }, /* display A base address 15:0 */
18 { GLAMO_REG_LCD_A_BASE2, 0x0000 }, /* display A base address 22:16 */
19 + { GLAMO_REG_LCD_CURSOR_BASE1, 0x0000 }, /* cursor base address 15:0 */
20 + { GLAMO_REG_LCD_CURSOR_BASE2, 0x000f }, /* cursor base address 22:16 */
21 };
22
23 static int glamofb_run_script(struct glamofb_handle *glamo,
24 @@ -200,7 +202,6 @@ static int glamofb_check_var(struct fb_var_screeninfo *var,
25 printk(KERN_ERR
26 "Smedia driver does not [yet?] support 24/32bpp\n");
27 return -EINVAL;
28 - break;
29 }
30
31 return 0;
32 @@ -497,22 +498,19 @@ static int glamofb_setcolreg(unsigned regno,
33 return 0;
34 }
35
36 +#ifdef CONFIG_MFD_GLAMO_HWACCEL
37 static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
38 {
39 struct glamofb_handle *glamo = info->par;
40 - u_int16_t reg;
41 + unsigned long flags;
42
43 if (cursor->image.depth > 2)
44 return -EINVAL;
45
46 - reg = reg_read(glamo, GLAMO_REG_LCD_MODE1);
47 + spin_lock_irqsave(&glamo->lock_cmd, flags);
48
49 - if (cursor->enable)
50 - reg_write(glamo, GLAMO_REG_LCD_MODE1,
51 - reg | GLAMO_LCD_MODE1_CURSOR_EN);
52 - else
53 - reg_write(glamo, GLAMO_REG_LCD_MODE1,
54 - reg & ~GLAMO_LCD_MODE1_CURSOR_EN);
55 + reg_set_bit_mask(glamo, GLAMO_REG_LCD_MODE1,
56 + GLAMO_LCD_MODE1_CURSOR_EN, 0);
57
58 if (cursor->set & FB_CUR_SETPOS) {
59 reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_POS,
60 @@ -522,29 +520,36 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
61 }
62
63 if (cursor->set & FB_CUR_SETCMAP) {
64 - /* FIXME */
65 + uint16_t fg = cursor->image.fg_color;
66 + uint16_t bg = cursor->image.bg_color;
67 +
68 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_FG_COLOR, fg);
69 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_BG_COLOR, bg);
70 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_DST_COLOR, bg);
71 }
72
73 - if (cursor->set & FB_CUR_SETSIZE ||
74 - cursor->set & (FB_CUR_SETIMAGE | FB_CUR_SETSHAPE)) {
75 - int x, y, op;
76 + if (cursor->set & FB_CUR_SETHOT)
77 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_PRESET,
78 + (cursor->hot.x << 8) | cursor->hot.y);
79 +
80 + if ((cursor->set & FB_CUR_SETSIZE) ||
81 + (cursor->set & (FB_CUR_SETIMAGE | FB_CUR_SETSHAPE))) {
82 + int x, y, pitch;
83 const unsigned char *pcol = cursor->image.data;
84 const unsigned char *pmsk = cursor->mask;
85 void __iomem *dst = glamo->cursor_addr;
86 unsigned char dcol = 0;
87 unsigned char dmsk = 0;
88 + unsigned char byte = 0;
89
90 + pitch = (cursor->image.width + 3) >> 2;
91 reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_SIZE,
92 cursor->image.width);
93 reg_write(glamo, GLAMO_REG_LCD_CURSOR_PITCH,
94 - cursor->image.width * 2);
95 + pitch);
96 reg_write(glamo, GLAMO_REG_LCD_CURSOR_Y_SIZE,
97 cursor->image.height);
98
99 - for (op = 0; op < (cursor->image.width *
100 - cursor->image.height * 2)/8; op += 4)
101 - writel(0x0, dst + op);
102 -
103 for (y = 0; y < cursor->image.height; y++) {
104 for (x = 0; x < cursor->image.width; x++) {
105 if ((x % 8) == 0) {
106 @@ -559,15 +564,29 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
107 unsigned int op;
108
109 op = (dcol & 1) ? 1 : 3;
110 - op <<= ((x % 4) * 2);
111 + byte |= op << ((x % 4) * 2);
112 + }
113
114 - op |= readb(dst + (x / 4));
115 - writeb(op, dst + (x / 4));
116 + if ((x % 4) == 0) {
117 + writeb(byte, dst + x / 4);
118 + byte = 0;
119 }
120 }
121 +
122 + dst += pitch;
123 }
124 }
125 +
126 + if (cursor->enable)
127 + reg_set_bit_mask(glamo, GLAMO_REG_LCD_MODE1,
128 + GLAMO_LCD_MODE1_CURSOR_EN,
129 + GLAMO_LCD_MODE1_CURSOR_EN);
130 +
131 + spin_unlock_irqrestore(&glamo->lock_cmd, flags);
132 +
133 + return 0;
134 }
135 +#endif
136
137 static inline int glamofb_cmdq_empty(struct glamofb_handle *gfb)
138 {
139 @@ -576,15 +595,14 @@ static inline int glamofb_cmdq_empty(struct glamofb_handle *gfb)
140 }
141
142 /* call holding gfb->lock_cmd when locking, until you unlock */
143 -
144 int glamofb_cmd_mode(struct glamofb_handle *gfb, int on)
145 {
146 int timeout = 200000;
147
148 -/* dev_dbg(gfb->dev, "glamofb_cmd_mode(gfb=%p, on=%d)\n", gfb, on); */
149 + dev_dbg(gfb->dev, "glamofb_cmd_mode(gfb=%p, on=%d)\n", gfb, on);
150 if (on) {
151 -/* dev_dbg(gfb->dev, "%s: waiting for cmdq empty: ",
152 - __FUNCTION__); */
153 + dev_dbg(gfb->dev, "%s: waiting for cmdq empty: ",
154 + __FUNCTION__);
155 while ((!glamofb_cmdq_empty(gfb)) && (timeout--))
156 yield();
157 if (timeout < 0) {
158 @@ -593,7 +611,7 @@ int glamofb_cmd_mode(struct glamofb_handle *gfb, int on)
159 "*************\n");
160 return -EIO;
161 }
162 -/* dev_dbg(gfb->dev, "empty!\n"); */
163 + dev_dbg(gfb->dev, "empty!\n");
164
165 /* display the entire frame then switch to command */
166 reg_write(gfb, GLAMO_REG_LCD_COMMAND1,
167 @@ -601,7 +619,7 @@ int glamofb_cmd_mode(struct glamofb_handle *gfb, int on)
168 GLAMO_LCD_CMD_DATA_FIRE_VSYNC);
169
170 /* wait until LCD is idle */
171 -/* dev_dbg(gfb->dev, "waiting for LCD idle: "); */
172 + dev_dbg(gfb->dev, "waiting for LCD idle: ");
173 timeout = 200000;
174 while ((!reg_read(gfb, GLAMO_REG_LCD_STATUS2) & (1 << 12)) &&
175 (timeout--))
176 @@ -612,7 +630,7 @@ int glamofb_cmd_mode(struct glamofb_handle *gfb, int on)
177 "*************\n");
178 return -EIO;
179 }
180 -/* dev_dbg(gfb->dev, "idle!\n"); */
181 + dev_dbg(gfb->dev, "idle!\n");
182
183 mdelay(100);
184 } else {
185 @@ -635,8 +653,7 @@ int glamofb_cmd_write(struct glamofb_handle *gfb, u_int16_t val)
186 {
187 int timeout = 200000;
188
189 -/* dev_dbg(gfb->dev, "%s: waiting for cmdq empty\n",
190 - __FUNCTION__); */
191 + dev_dbg(gfb->dev, "%s: waiting for cmdq empty\n", __FUNCTION__);
192 while ((!glamofb_cmdq_empty(gfb)) && (timeout--))
193 yield();
194 if (timeout < 0) {
195 @@ -645,7 +662,7 @@ int glamofb_cmd_write(struct glamofb_handle *gfb, u_int16_t val)
196 "*************\n");
197 return 1;
198 }
199 -/* dev_dbg(gfb->dev, "idle, writing 0x%04x\n", val); */
200 + dev_dbg(gfb->dev, "idle, writing 0x%04x\n", val);
201
202 reg_write(gfb, GLAMO_REG_LCD_COMMAND1, val);
203
204 @@ -659,7 +676,9 @@ static struct fb_ops glamofb_ops = {
205 .fb_set_par = glamofb_set_par,
206 .fb_blank = glamofb_blank,
207 .fb_setcolreg = glamofb_setcolreg,
208 - //.fb_cursor = glamofb_cursor,
209 +#ifdef CONFIG_MFD_GLAMO_HWACCEL
210 + .fb_cursor = glamofb_cursor,
211 +#endif
212 .fb_fillrect = cfb_fillrect,
213 .fb_copyarea = cfb_copyarea,
214 .fb_imageblit = cfb_imageblit,
215 @@ -743,6 +762,7 @@ static int __init glamofb_probe(struct platform_device *pdev)
216 dev_err(&pdev->dev, "failed to ioremap() vram memory\n");
217 goto out_release_fb;
218 }
219 + glamofb->cursor_addr = fbinfo->screen_base + 0xf0000;
220
221 platform_set_drvdata(pdev, fbinfo);
222
223 @@ -754,13 +774,13 @@ static int __init glamofb_probe(struct platform_device *pdev)
224 fbinfo->fix.xpanstep = 0;
225 fbinfo->fix.ypanstep = 0;
226 fbinfo->fix.ywrapstep = 0;
227 - fbinfo->fix.accel = FB_ACCEL_NONE; /* FIXME */
228 + fbinfo->fix.accel = FB_ACCEL_GLAMO;
229
230 fbinfo->var.nonstd = 0;
231 fbinfo->var.activate = FB_ACTIVATE_NOW;
232 fbinfo->var.height = mach_info->height;
233 fbinfo->var.width = mach_info->width;
234 - fbinfo->var.accel_flags = 0;
235 + fbinfo->var.accel_flags = 0; /* FIXME */
236 fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
237
238 fbinfo->fbops = &glamofb_ops;
239 @@ -833,26 +853,9 @@ static int glamofb_remove(struct platform_device *pdev)
240 return 0;
241 }
242
243 -#ifdef CONFIG_PM
244 -static int glamofb_suspend(struct platform_device *pdev, pm_message_t state)
245 -{
246 - return 0;
247 -}
248 -
249 -static int glamofb_resume(struct platform_device *pdev)
250 -{
251 - return 0;
252 -}
253 -#else
254 -#define glamofb_suspend NULL
255 -#define glamofb_resume NULL
256 -#endif
257 -
258 static struct platform_driver glamofb_driver = {
259 .probe = glamofb_probe,
260 .remove = glamofb_remove,
261 - .suspend = glamofb_suspend,
262 - .resume = glamofb_resume,
263 .driver = {
264 .name = "glamo-fb",
265 .owner = THIS_MODULE,
266 diff --git a/include/linux/fb.h b/include/linux/fb.h
267 index 72295b0..1df1225 100644
268 --- a/include/linux/fb.h
269 +++ b/include/linux/fb.h
270 @@ -120,6 +120,7 @@ struct dentry;
271 #define FB_ACCEL_XGI_VOLARI_V 47 /* XGI Volari V3XT, V5, V8 */
272 #define FB_ACCEL_XGI_VOLARI_Z 48 /* XGI Volari Z7 */
273 #define FB_ACCEL_OMAP1610 49 /* TI OMAP16xx */
274 +#define FB_ACCEL_GLAMO 50 /* SMedia Glamo */
275 #define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */
276 #define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */
277 #define FB_ACCEL_NEOMAGIC_NM2093 92 /* NeoMagic NM2093 */
278 --
279 1.5.6.3
280
This page took 0.057803 seconds and 5 git commands to generate.