[ar71xx] remove duplicated includes
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1207-Subject-PATCH-glamo-Don-t-disable-hwcursor-for-b.patch
1 From 57df1041409b50f2cc3137a820254fa982c49c45 Mon Sep 17 00:00:00 2001
2 From: Andrzej Zaborowski <balrog@zabor.org>
3 Date: Wed, 2 Jul 2008 22:43:11 +0100
4 Subject: [PATCH] Subject: [PATCH] glamo: Don't disable hwcursor for blinking and use vsync-wait.
5
6 ---
7 drivers/mfd/glamo/glamo-fb.c | 109 +++++++++++++++++++++++++++++-------------
8 1 files changed, 76 insertions(+), 33 deletions(-)
9
10 diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c
11 index 16e9d2e..7feef32 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 {
15 char __iomem *base;
16 struct glamofb_platform_data *mach_info;
17 char __iomem *cursor_addr;
18 + int cursor_on;
19 u_int32_t pseudo_pal[16];
20 spinlock_t lock_cmd;
21 };
22 @@ -497,18 +498,53 @@ static int glamofb_setcolreg(unsigned regno,
23 }
24
25 #ifdef CONFIG_MFD_GLAMO_HWACCEL
26 +static inline void glamofb_vsync_wait(struct glamofb_handle *glamo,
27 + int line, int size, int range)
28 +{
29 + int count[2];
30 +
31 + do {
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);
38 +}
39 +
40 +/*
41 + * Enable/disable the hardware cursor mode altogether
42 + * (for blinking and such, use glamofb_cursor()).
43 + */
44 +static void glamofb_cursor_onoff(struct glamofb_handle *glamo, int on)
45 +{
46 + int y, size;
47 +
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);
51 +
52 + glamofb_vsync_wait(glamo, y, size, 30);
53 + }
54 +
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;
59 +
60 + /* Hide the cursor by default */
61 + reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_SIZE, 0);
62 +}
63 +
64 static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
65 {
66 struct glamofb_handle *glamo = info->par;
67 unsigned long flags;
68
69 - if (cursor->image.depth > 2)
70 - return -EINVAL;
71 -
72 spin_lock_irqsave(&glamo->lock_cmd, flags);
73
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);
78
79 if (cursor->set & FB_CUR_SETPOS) {
80 reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_POS,
81 @@ -518,12 +554,12 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
82 }
83
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];
89
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);
94 }
95
96 if (cursor->set & FB_CUR_SETHOT)
97 @@ -532,23 +568,27 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
98
99 if ((cursor->set & FB_CUR_SETSIZE) ||
100 (cursor->set & (FB_CUR_SETIMAGE | FB_CUR_SETSHAPE))) {
101 - int x, y, pitch;
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;
108 -
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;
116 + uint8_t dcol = 0;
117 + uint8_t dmsk = 0;
118 + uint8_t byte = 0;
119 +
120 + if (cursor->image.depth > 1) {
121 + spin_unlock_irqrestore(&glamo->lock_cmd, flags);
122 + return -EINVAL;
123 + }
124 +
125 + pitch = ((cursor->image.width + 7) >> 2) & ~1;
126 reg_write(glamo, GLAMO_REG_LCD_CURSOR_PITCH,
127 - pitch);
128 + pitch);
129 reg_write(glamo, GLAMO_REG_LCD_CURSOR_Y_SIZE,
130 - cursor->image.height);
131 + cursor->image.height);
132
133 for (y = 0; y < cursor->image.height; y++) {
134 + byte = 0;
135 for (x = 0; x < cursor->image.width; x++) {
136 if ((x % 8) == 0) {
137 dcol = *pcol++;
138 @@ -558,28 +598,28 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
139 dmsk >>= 1;
140 }
141
142 - if (dmsk & 1) {
143 - unsigned int op;
144 + if (cursor->rop == ROP_COPY)
145 + op = (dmsk & 1) ?
146 + (dcol & 1) ? 1 : 3 : 0;
147 + else
148 + op = ((dmsk & 1) << 1) |
149 + ((dcol & 1) << 0);
150 + byte |= op << ((x & 3) << 1);
151
152 - op = (dcol & 1) ? 1 : 3;
153 - byte |= op << ((x % 4) * 2);
154 - }
155 -
156 - if ((x % 4) == 0) {
157 + if (x % 4 == 3) {
158 writeb(byte, dst + x / 4);
159 byte = 0;
160 }
161 }
162 + if (x % 4) {
163 + writeb(byte, dst + x / 4);
164 + byte = 0;
165 + }
166
167 dst += pitch;
168 }
169 }
170
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);
175 -
176 spin_unlock_irqrestore(&glamo->lock_cmd, flags);
177
178 return 0;
179 @@ -806,6 +846,9 @@ static int __init glamofb_probe(struct platform_device *pdev)
180
181 spin_lock_init(&glamofb->lock_cmd);
182 glamofb_init_regs(glamofb);
183 +#ifdef CONFIG_MFD_GLAMO_HWACCEL
184 + glamofb_cursor_onoff(glamofb, 1);
185 +#endif
186
187 rc = register_framebuffer(fbinfo);
188 if (rc < 0) {
189 --
190 1.5.6.5
191
This page took 0.050815 seconds and 5 git commands to generate.