1 From a613c5fb94c06db20195b8be4593cf05895205cf Mon Sep 17 00:00:00 2001
2 From: Andrzej Zaborowski <balrog@zabor.org>
3 Date: Fri, 25 Jul 2008 23:06:16 +0100
4 Subject: [PATCH] Subject: [PATCH] glamo: Don't disable hwcursor for blinking and use vsync-wait.
7 drivers/mfd/glamo/glamo-fb.c | 109 +++++++++++++++++++++++++++++-------------
8 1 files changed, 76 insertions(+), 33 deletions(-)
10 diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c
11 index 30cdb38..7e800f5 100644
12 --- a/drivers/mfd/glamo/glamo-fb.c
13 +++ b/drivers/mfd/glamo/glamo-fb.c
14 @@ -72,6 +72,7 @@ struct glamofb_handle {
16 struct glamofb_platform_data *mach_info;
17 char __iomem *cursor_addr;
19 u_int32_t pseudo_pal[16];
22 @@ -499,18 +500,53 @@ static int glamofb_setcolreg(unsigned regno,
25 #ifdef CONFIG_MFD_GLAMO_HWACCEL
26 +static inline void glamofb_vsync_wait(struct glamofb_handle *glamo,
27 + int line, int size, int range)
32 + count[0] = reg_read(glamo, GLAMO_REG_LCD_STATUS2) & 0x3ff;
33 + count[1] = reg_read(glamo, GLAMO_REG_LCD_STATUS2) & 0x3ff;
34 + } while (count[0] != count[1] ||
35 + (line < count[0] + range &&
36 + size > count[0] - range) ||
37 + count[0] < range * 2);
41 + * Enable/disable the hardware cursor mode altogether
42 + * (for blinking and such, use glamofb_cursor()).
44 +static void glamofb_cursor_onoff(struct glamofb_handle *glamo, int on)
48 + if (glamo->cursor_on) {
49 + y = reg_read(glamo, GLAMO_REG_LCD_CURSOR_Y_POS);
50 + size = reg_read(glamo, GLAMO_REG_LCD_CURSOR_Y_SIZE);
52 + glamofb_vsync_wait(glamo, y, size, 30);
55 + reg_set_bit_mask(glamo, GLAMO_REG_LCD_MODE1,
56 + GLAMO_LCD_MODE1_CURSOR_EN,
57 + on ? GLAMO_LCD_MODE1_CURSOR_EN : 0);
58 + glamo->cursor_on = on;
60 + /* Hide the cursor by default */
61 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_SIZE, 0);
64 static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
66 struct glamofb_handle *glamo = info->par;
69 - if (cursor->image.depth > 2)
72 spin_lock_irqsave(&glamo->lock_cmd, flags);
74 - reg_set_bit_mask(glamo, GLAMO_REG_LCD_MODE1,
75 - GLAMO_LCD_MODE1_CURSOR_EN, 0);
76 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_SIZE,
77 + cursor->enable ? cursor->image.width : 0);
79 if (cursor->set & FB_CUR_SETPOS) {
80 reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_POS,
81 @@ -520,12 +556,12 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
84 if (cursor->set & FB_CUR_SETCMAP) {
85 - uint16_t fg = cursor->image.fg_color;
86 - uint16_t bg = cursor->image.bg_color;
87 + uint16_t fg = glamo->pseudo_pal[cursor->image.fg_color];
88 + uint16_t bg = glamo->pseudo_pal[cursor->image.bg_color];
90 reg_write(glamo, GLAMO_REG_LCD_CURSOR_FG_COLOR, fg);
91 reg_write(glamo, GLAMO_REG_LCD_CURSOR_BG_COLOR, bg);
92 - reg_write(glamo, GLAMO_REG_LCD_CURSOR_DST_COLOR, bg);
93 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_DST_COLOR, fg);
96 if (cursor->set & FB_CUR_SETHOT)
97 @@ -534,23 +570,27 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
99 if ((cursor->set & FB_CUR_SETSIZE) ||
100 (cursor->set & (FB_CUR_SETIMAGE | FB_CUR_SETSHAPE))) {
102 - const unsigned char *pcol = cursor->image.data;
103 - const unsigned char *pmsk = cursor->mask;
104 - void __iomem *dst = glamo->cursor_addr;
105 - unsigned char dcol = 0;
106 - unsigned char dmsk = 0;
107 - unsigned char byte = 0;
109 - pitch = (cursor->image.width + 3) >> 2;
110 - reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_SIZE,
111 - cursor->image.width);
112 + int x, y, pitch, op;
113 + const uint8_t *pcol = cursor->image.data;
114 + const uint8_t *pmsk = cursor->mask;
115 + uint8_t __iomem *dst = glamo->cursor_addr;
120 + if (cursor->image.depth > 1) {
121 + spin_unlock_irqrestore(&glamo->lock_cmd, flags);
125 + pitch = ((cursor->image.width + 7) >> 2) & ~1;
126 reg_write(glamo, GLAMO_REG_LCD_CURSOR_PITCH,
129 reg_write(glamo, GLAMO_REG_LCD_CURSOR_Y_SIZE,
130 - cursor->image.height);
131 + cursor->image.height);
133 for (y = 0; y < cursor->image.height; y++) {
135 for (x = 0; x < cursor->image.width; x++) {
138 @@ -560,28 +600,28 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
144 + if (cursor->rop == ROP_COPY)
146 + (dcol & 1) ? 1 : 3 : 0;
148 + op = ((dmsk & 1) << 1) |
150 + byte |= op << ((x & 3) << 1);
152 - op = (dcol & 1) ? 1 : 3;
153 - byte |= op << ((x % 4) * 2);
156 - if ((x % 4) == 0) {
158 writeb(byte, dst + x / 4);
163 + writeb(byte, dst + x / 4);
171 - if (cursor->enable)
172 - reg_set_bit_mask(glamo, GLAMO_REG_LCD_MODE1,
173 - GLAMO_LCD_MODE1_CURSOR_EN,
174 - GLAMO_LCD_MODE1_CURSOR_EN);
176 spin_unlock_irqrestore(&glamo->lock_cmd, flags);
179 @@ -809,6 +849,9 @@ static int __init glamofb_probe(struct platform_device *pdev)
180 printk(KERN_ERR"spin_lock_init\n");
181 spin_lock_init(&glamofb->lock_cmd);
182 glamofb_init_regs(glamofb);
183 +#ifdef CONFIG_MFD_GLAMO_HWACCEL
184 + glamofb_cursor_onoff(glamofb, 1);
187 rc = register_framebuffer(fbinfo);