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