aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2010-03-27 14:14:52 -0400
committerJonathan Corbet <corbet@lwn.net>2010-04-20 16:23:19 -0400
commit9ca43cf41d014e12f4b25d4538f362d7513448dd (patch)
tree9c564608e9fac98c2babbd9db290364b107a0e67 /drivers/video
parent1b1f8cd299d3c5a90c2ec1c24c271a0b536e5891 (diff)
viafb: Retain GEMODE reserved bits
Commit c3e25673843153ea75fda79a47cf12f10a25ca37 (viafb: 2D engine rewrite) changed the setting of the GEMODE register so that the reserved bits are no longer preserved. Fix that; at the same time, move this code to its own function and restore the use of symbolic constants. Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: ScottFang@viatech.com.cn Cc: JosephChan@via.com.tw Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/via/accel.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c
index d5077dfa9e00..a52147cf7f09 100644
--- a/drivers/video/via/accel.c
+++ b/drivers/video/via/accel.c
@@ -165,12 +165,42 @@ static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height,
165 return 0; 165 return 0;
166} 166}
167 167
168/*
169 * Figure out an appropriate bytes-per-pixel setting.
170 */
171static int viafb_set_bpp(void __iomem *engine, u8 bpp)
172{
173 u32 gemode;
174
175 /* Preserve the reserved bits */
176 /* Lowest 2 bits to zero gives us no rotation */
177 gemode = readl(engine + VIA_REG_GEMODE) & 0xfffffcfc;
178 switch (bpp) {
179 case 8:
180 gemode |= VIA_GEM_8bpp;
181 break;
182 case 16:
183 gemode |= VIA_GEM_16bpp;
184 break;
185 case 32:
186 gemode |= VIA_GEM_32bpp;
187 break;
188 default:
189 printk(KERN_WARNING "hw_bitblt_2: Unsupported bpp %d\n", bpp);
190 return -EINVAL;
191 }
192 writel(gemode, engine + VIA_REG_GEMODE);
193 return 0;
194}
195
196
168static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height, 197static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,
169 u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, 198 u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y,
170 u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, 199 u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,
171 u32 fg_color, u32 bg_color, u8 fill_rop) 200 u32 fg_color, u32 bg_color, u8 fill_rop)
172{ 201{
173 u32 ge_cmd = 0, tmp, i; 202 u32 ge_cmd = 0, tmp, i;
203 int ret;
174 204
175 if (!op || op > 3) { 205 if (!op || op > 3) {
176 printk(KERN_WARNING "hw_bitblt_2: Invalid operation: %d\n", op); 206 printk(KERN_WARNING "hw_bitblt_2: Invalid operation: %d\n", op);
@@ -204,22 +234,9 @@ static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,
204 } 234 }
205 } 235 }
206 236
207 switch (dst_bpp) { 237 ret = viafb_set_bpp(engine, dst_bpp);
208 case 8: 238 if (ret)
209 tmp = 0x00000000; 239 return ret;
210 break;
211 case 16:
212 tmp = 0x00000100;
213 break;
214 case 32:
215 tmp = 0x00000300;
216 break;
217 default:
218 printk(KERN_WARNING "hw_bitblt_2: Unsupported bpp %d\n",
219 dst_bpp);
220 return -EINVAL;
221 }
222 writel(tmp, engine + 0x04);
223 240
224 if (op == VIA_BITBLT_FILL) 241 if (op == VIA_BITBLT_FILL)
225 tmp = 0; 242 tmp = 0;