aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2006-02-24 16:04:20 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-24 17:31:39 -0500
commitee713059d4922e4ee17700496d9eb3b95b1ab836 (patch)
treefe56c8f04342938813edce2bb0c92a984b125457 /drivers/video
parentcacfc8cf4ed6e05a0d9a8bd17ab85536abd0f6c5 (diff)
[PATCH] Fix pseudo_palette setup in asiliantfb_setcolreg()
The setcolreg function will attempt to write 24 color entries to the pseudo_pallette. However, the pseudo_palette has only space for 16 entries. Thanks to Atsushi Nemoto for reporting this bug. Signed-off-by: Antonino Daplas <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/asiliantfb.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/video/asiliantfb.c b/drivers/video/asiliantfb.c
index 69f75547865d..c924d81f7978 100644
--- a/drivers/video/asiliantfb.c
+++ b/drivers/video/asiliantfb.c
@@ -322,32 +322,29 @@ static int asiliantfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
322 writeb(green, mmio_base + 0x791); 322 writeb(green, mmio_base + 0x791);
323 writeb(blue, mmio_base + 0x791); 323 writeb(blue, mmio_base + 0x791);
324 324
325 switch(p->var.bits_per_pixel) { 325 if (regno < 16) {
326 case 15: 326 switch(p->var.red.offset) {
327 if (regno < 16) { 327 case 10: /* RGB 555 */
328 ((u32 *)(p->pseudo_palette))[regno] = 328 ((u32 *)(p->pseudo_palette))[regno] =
329 ((red & 0xf8) << 7) | 329 ((red & 0xf8) << 7) |
330 ((green & 0xf8) << 2) | 330 ((green & 0xf8) << 2) |
331 ((blue & 0xf8) >> 3); 331 ((blue & 0xf8) >> 3);
332 } 332 break;
333 break; 333 case 11: /* RGB 565 */
334 case 16:
335 if (regno < 16) {
336 ((u32 *)(p->pseudo_palette))[regno] = 334 ((u32 *)(p->pseudo_palette))[regno] =
337 ((red & 0xf8) << 8) | 335 ((red & 0xf8) << 8) |
338 ((green & 0xfc) << 3) | 336 ((green & 0xfc) << 3) |
339 ((blue & 0xf8) >> 3); 337 ((blue & 0xf8) >> 3);
340 } 338 break;
341 break; 339 case 16: /* RGB 888 */
342 case 24:
343 if (regno < 24) {
344 ((u32 *)(p->pseudo_palette))[regno] = 340 ((u32 *)(p->pseudo_palette))[regno] =
345 (red << 16) | 341 (red << 16) |
346 (green << 8) | 342 (green << 8) |
347 (blue); 343 (blue);
344 break;
348 } 345 }
349 break;
350 } 346 }
347
351 return 0; 348 return 0;
352} 349}
353 350