diff -Nru psplash_orig/psplash-fb.c psplash/psplash-fb.c --- psplash_orig/psplash-fb.c 2010-04-22 16:17:33.000000000 +0200 +++ psplash/psplash-fb.c 2010-05-16 15:49:40.000000000 +0200 @@ -132,7 +132,8 @@ goto fail; } - if (fb_var.bits_per_pixel < 16) + if (fb_var.bits_per_pixel != 1 && fb_var.bits_per_pixel != 2 + && fb_var.bits_per_pixel < 16) { fprintf(stderr, "Error, no support currently for %i bpp frame buffers\n" @@ -258,7 +259,18 @@ return NULL; } -#define OFFSET(fb,x,y) (((y) * (fb)->stride) + ((x) * ((fb)->bpp >> 3))) +static inline int +psplash_fb_offset(PSplashFB *fb, int x, int y) +{ + switch (fb->bpp) + { + /* pixel offset */ + case 2: return (y * (fb->stride << 2)) + x; + case 1: return (y * (fb->stride << 3)) + x; + /* byte offset */ + default: return (y * fb->stride) + (x * (fb->bpp >> 3)); + } +} inline void psplash_fb_plot_pixel (PSplashFB *fb, @@ -268,7 +280,7 @@ uint8 green, uint8 blue) { - int off; + int off, shift; if (x < 0 || x > fb->width-1 || y < 0 || y > fb->height-1) return; @@ -276,17 +288,17 @@ switch (fb->angle) { case 270: - off = OFFSET (fb, fb->height - y - 1, x); + off = psplash_fb_offset (fb, fb->height - y - 1, x); break; case 180: - off = OFFSET (fb, fb->width - x - 1, fb->height - y - 1); + off = psplash_fb_offset (fb, fb->width - x - 1, fb->height - y - 1); break; case 90: - off = OFFSET (fb, y, fb->width - x - 1); + off = psplash_fb_offset (fb, y, fb->width - x - 1); break; case 0: default: - off = OFFSET (fb, x, y); + off = psplash_fb_offset (fb, x, y); break; } @@ -303,6 +315,18 @@ *(volatile uint16_t *) (fb->data + off) = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3); break; + case 2: + shift = (3 - (off & 3)) << 1; + *(fb->data + (off >> 2)) = (*(fb->data + (off >> 2)) & ~(3 << shift)) + | (((11*red + 16*green + 5*blue) >> 11) << shift); + break; + case 1: + shift = 7 - (off & 7); + if (((11*red + 16*green + 5*blue) >> 5) >= 128) + *(fb->data + (off >> 3)) |= (1 << shift); + else + *(fb->data + (off >> 3)) &= ~(1 << shift); + break; default: /* depth not supported yet */ break;