aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-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;