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.
7 drivers/mfd/glamo/glamo-fb.c | 105 +++++++++++++++++++++---------------------
8 include/linux/fb.h | 1 +
9 2 files changed, 54 insertions(+), 52 deletions(-)
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 */
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,
26 "Smedia driver does not [yet?] support 24/32bpp\n");
32 @@ -495,23 +496,19 @@ static int glamofb_setcolreg(unsigned regno,
36 -#ifdef NOT_CURRENTLY_USED
37 +#ifdef CONFIG_MFD_GLAMO_HWACCEL
38 static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
40 struct glamofb_handle *glamo = info->par;
42 + unsigned long flags;
44 if (cursor->image.depth > 2)
47 - reg = reg_read(glamo, GLAMO_REG_LCD_MODE1);
48 + spin_lock_irqsave(&glamo->lock_cmd, flags);
51 - reg_write(glamo, GLAMO_REG_LCD_MODE1,
52 - reg | GLAMO_LCD_MODE1_CURSOR_EN);
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);
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)
64 if (cursor->set & FB_CUR_SETCMAP) {
66 + uint16_t fg = cursor->image.fg_color;
67 + uint16_t bg = cursor->image.bg_color;
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);
74 - if (cursor->set & FB_CUR_SETSIZE ||
75 - cursor->set & (FB_CUR_SETIMAGE | FB_CUR_SETSHAPE)) {
77 + if (cursor->set & FB_CUR_SETHOT)
78 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_PRESET,
79 + (cursor->hot.x << 8) | cursor->hot.y);
81 + if ((cursor->set & FB_CUR_SETSIZE) ||
82 + (cursor->set & (FB_CUR_SETIMAGE | FB_CUR_SETSHAPE))) {
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;
91 + pitch = (cursor->image.width + 3) >> 2;
92 reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_SIZE,
94 reg_write(glamo, GLAMO_REG_LCD_CURSOR_PITCH,
95 - cursor->image.width * 2);
97 reg_write(glamo, GLAMO_REG_LCD_CURSOR_Y_SIZE,
98 cursor->image.height);
100 - for (op = 0; op < (cursor->image.width *
101 - cursor->image.height * 2)/8; op += 4)
102 - writel(0x0, dst + op);
104 for (y = 0; y < cursor->image.height; y++) {
105 for (x = 0; x < cursor->image.width; x++) {
107 @@ -558,14 +562,27 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
110 op = (dcol & 1) ? 1 : 3;
111 - op <<= ((x % 4) * 2);
112 + byte |= op << ((x % 4) * 2);
115 - op |= readb(dst + (x / 4));
116 - writeb(op, dst + (x / 4));
117 + if ((x % 4) == 0) {
118 + writeb(byte, dst + x / 4);
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);
132 + spin_unlock_irqrestore(&glamo->lock_cmd, flags);
138 @@ -576,15 +593,14 @@ static inline int glamofb_cmdq_empty(struct glamofb_handle *gfb)
141 /* call holding gfb->lock_cmd when locking, until you unlock */
143 int glamofb_cmd_mode(struct glamofb_handle *gfb, int on)
145 int timeout = 200000;
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);
150 -/* dev_dbg(gfb->dev, "%s: waiting for cmdq empty: ",
152 + dev_dbg(gfb->dev, "%s: waiting for cmdq empty: ",
154 while ((!glamofb_cmdq_empty(gfb)) && (timeout--))
157 @@ -593,7 +609,7 @@ int glamofb_cmd_mode(struct glamofb_handle *gfb, int on)
161 -/* dev_dbg(gfb->dev, "empty!\n"); */
162 + dev_dbg(gfb->dev, "empty!\n");
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);
169 /* wait until LCD is idle */
170 -/* dev_dbg(gfb->dev, "waiting for LCD idle: "); */
171 + dev_dbg(gfb->dev, "waiting for LCD idle: ");
173 while ((!reg_read(gfb, GLAMO_REG_LCD_STATUS2) & (1 << 12)) &&
175 @@ -612,7 +628,7 @@ int glamofb_cmd_mode(struct glamofb_handle *gfb, int on)
179 -/* dev_dbg(gfb->dev, "idle!\n"); */
180 + dev_dbg(gfb->dev, "idle!\n");
184 @@ -635,8 +651,7 @@ int glamofb_cmd_write(struct glamofb_handle *gfb, u_int16_t val)
186 int timeout = 200000;
188 -/* dev_dbg(gfb->dev, "%s: waiting for cmdq empty\n",
190 + dev_dbg(gfb->dev, "%s: waiting for cmdq empty\n", __FUNCTION__);
191 while ((!glamofb_cmdq_empty(gfb)) && (timeout--))
194 @@ -645,7 +660,7 @@ int glamofb_cmd_write(struct glamofb_handle *gfb, u_int16_t val)
198 -/* dev_dbg(gfb->dev, "idle, writing 0x%04x\n", val); */
199 + dev_dbg(gfb->dev, "idle, writing 0x%04x\n", val);
201 reg_write(gfb, GLAMO_REG_LCD_COMMAND1, val);
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,
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");
218 + glamofb->cursor_addr = fbinfo->screen_base + 0xf0000;
220 platform_set_drvdata(pdev, fbinfo);
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;
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;
237 fbinfo->fbops = &glamofb_ops;
238 @@ -832,26 +850,9 @@ static int glamofb_remove(struct platform_device *pdev)
243 -static int glamofb_suspend(struct platform_device *pdev, pm_message_t state)
248 -static int glamofb_resume(struct platform_device *pdev)
253 -#define glamofb_suspend NULL
254 -#define glamofb_resume NULL
257 static struct platform_driver glamofb_driver = {
258 .probe = glamofb_probe,
259 .remove = glamofb_remove,
260 - .suspend = glamofb_suspend,
261 - .resume = glamofb_resume,
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 */