1.1 --- a/stage2/lcd.c Sun Apr 24 01:29:39 2016 +0200
1.2 +++ b/stage2/lcd.c Sun Apr 24 16:19:49 2016 +0200
1.3 @@ -58,7 +58,7 @@
1.4 return (scale * num) / denom;
1.5 }
1.6
1.7 -static unsigned long pixel(u8 r, u8 g, u8 b, u8 rmax, u8 gmax, u8 bmax, u8 rshift, u8 gshift, u8 bshift)
1.8 +static u32 pixel(u8 r, u8 g, u8 b, u8 rmax, u8 gmax, u8 bmax, u8 rshift, u8 gshift, u8 bshift)
1.9 {
1.10 return (div(r, 255, rmax) << rshift) | (div(g, 255, gmax) << gshift) | (div(b, 255, bmax) << bshift);
1.11 }
1.12 @@ -73,41 +73,83 @@
1.13 rgb[(pixel_type + 1) % 3] = (rgb[0] + rgb[1]) / 2;
1.14 }
1.15
1.16 +static void set_pixel32(unsigned short h, unsigned short v, u32 value)
1.17 +{
1.18 + u32 *pix = get_pixel32(h, v);
1.19 + *pix = value;
1.20 +}
1.21 +
1.22 +static void set_pixel16_565(unsigned short h, unsigned short v, u32 value)
1.23 +{
1.24 + u16 *pix = get_pixel16(h, v);
1.25 + *pix = (u16) value;
1.26 +}
1.27 +
1.28 +static void set_pixel8(unsigned short h, unsigned short v, u32 value)
1.29 +{
1.30 + u8 *pix = get_pixel8(h, v);
1.31 + *pix = (u8) value;
1.32 +}
1.33 +
1.34 +static void set_pixel4(unsigned short h, unsigned short v, u32 value)
1.35 +{
1.36 + u8 *pix = get_pixel4(h, v);
1.37 + u8 mask = h & 1 ? 0xf0 : 0x0f;
1.38 + *pix = (*pix & mask) | ((u8) value);
1.39 +}
1.40 +
1.41 +void set_pixel(unsigned short h, unsigned short v, u32 value)
1.42 +{
1.43 + switch (panel_info.vl_bpix)
1.44 + {
1.45 + case LCD_COLOR32:
1.46 + set_pixel32(h, v, value);
1.47 + break;
1.48 +
1.49 + case LCD_COLOR8:
1.50 + set_pixel8(h, v, value);
1.51 + break;
1.52 +
1.53 + case LCD_COLOR4:
1.54 + set_pixel4(h, v, value);
1.55 + break;
1.56 +
1.57 + case LCD_COLOR16:
1.58 + default:
1.59 + set_pixel16_565(h, v, value);
1.60 + break;
1.61 + }
1.62 +}
1.63 static void test_pixel32(unsigned short h, unsigned short v, unsigned short pixel_type)
1.64 {
1.65 - u32 *pix = get_pixel32(h, v);
1.66 u8 rgb[3];
1.67
1.68 get_colour(h, v, rgb, pixel_type);
1.69 - *pix = (u32) pixel(rgb[0], rgb[1], rgb[2], 255, 255, 255, 16, 8, 0);
1.70 + set_pixel32(h, v, pixel(rgb[0], rgb[1], rgb[2], 255, 255, 255, 16, 8, 0));
1.71 }
1.72
1.73 static void test_pixel16_565(unsigned short h, unsigned short v, unsigned short pixel_type)
1.74 {
1.75 - u16 *pix = get_pixel16(h, v);
1.76 u8 rgb[3];
1.77
1.78 get_colour(h, v, rgb, pixel_type);
1.79 - *pix = (u16) pixel(rgb[0], rgb[1], rgb[2], 31, 63, 31, 11, 5, 0);
1.80 + set_pixel16_565(h, v, pixel(rgb[0], rgb[1], rgb[2], 31, 63, 31, 11, 5, 0));
1.81 }
1.82
1.83 static void test_pixel8(unsigned short h, unsigned short v, unsigned short pixel_type)
1.84 {
1.85 - u8 *pix = get_pixel8(h, v);
1.86 u8 rgb[3];
1.87
1.88 get_colour(h, v, rgb, pixel_type);
1.89 - *pix = (u8) pixel(rgb[0], rgb[1], rgb[2], 7, 7, 3, 5, 2, 0);
1.90 + set_pixel8(h, v, pixel(rgb[0], rgb[1], rgb[2], 7, 7, 3, 5, 2, 0));
1.91 }
1.92
1.93 static void test_pixel4(unsigned short h, unsigned short v, unsigned short pixel_type)
1.94 {
1.95 - u8 *pix = get_pixel4(h, v);
1.96 - u8 mask = h & 1 ? 0xf0 : 0x0f;
1.97 u8 rgb[3];
1.98
1.99 get_colour(h, v, rgb, pixel_type);
1.100 - *pix = (*pix & mask) | ((u8) pixel(rgb[0], rgb[1], rgb[2], 1, 2, 1, 3, 1, 0) << (h & 1 ? 0 : 4));
1.101 + set_pixel4(h, v, pixel(rgb[0], rgb[1], rgb[2], 1, 2, 1, 3, 1, 0));
1.102 }
1.103
1.104 void test_pixel(unsigned short h, unsigned short v, unsigned short pixel_type)