framebuffer: fix 16- and 24-bit color. 8-bit still doesn't work.
This commit is contained in:
parent
29404c4199
commit
332b86f520
@ -1,22 +1,22 @@
|
|||||||
#include <framebuffer.h>
|
#include <framebuffer.h>
|
||||||
|
|
||||||
int fb_write_pixel_8bit(struct fb *f, unsigned int x, unsigned int y, unsigned int r, unsigned int g, unsigned int b) {
|
int fb_write_pixel_8bit(struct fb *f, unsigned int x, unsigned int y, unsigned int r, unsigned int g, unsigned int b) {
|
||||||
unsigned char pixel = (((r >> 6) << 4) & 0x30) | (((b >> 6) << 2) & 0xC) | ((g >> 6) & 0x3);
|
unsigned char pixel = (((b >> 6) << 6) & 0xC0) | (((g >> 5) << 3) & 0x38) | ((r >> 5) & 0x7);
|
||||||
((char*) (f->device->fbaddr))[y*f->device->pixelwidth + x] = pixel;
|
((char*)f->device->fbaddr)[y*f->device->pixelwidth + x] = pixel;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fb_write_pixel_16bit(struct fb *f, unsigned int x, unsigned int y, unsigned int r, unsigned int g, unsigned int b) {
|
int fb_write_pixel_16bit(struct fb *f, unsigned int x, unsigned int y, unsigned int r, unsigned int g, unsigned int b) {
|
||||||
unsigned int pixel = (((r >> 3) << 10) & 0x7BF6) | (((b >> 3) << 5) & 0x3E0) | ((g >> 3) & 0x1F);
|
unsigned int pixel = (((b >> 3) << 11) & 0xF800) | (((g >> 2) << 6) & 0x7E0) | ((r >> 3) & 0x1F);
|
||||||
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x) << 1] = (char)pixel;
|
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x) << 1] = (char)pixel;
|
||||||
((char*)f->device->fbaddr)[((y*f->device->pixelwidth + x) << 1) + 1] = (char)(pixel >> 8);
|
((char*)f->device->fbaddr)[((y*f->device->pixelwidth + x) << 1) + 1] = (char)(pixel >> 8);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fb_write_pixel_24bit(struct fb *f, unsigned int x, unsigned int y, unsigned int r, unsigned int g, unsigned int b) {
|
int fb_write_pixel_24bit(struct fb *f, unsigned int x, unsigned int y, unsigned int r, unsigned int g, unsigned int b) {
|
||||||
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x)*3] = (char)r;
|
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x)*4] = (char)r;
|
||||||
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x)*3 + 1] = (char)b;
|
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x)*4 + 1] = (char)g;
|
||||||
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x)*3 + 2] = (char)g;
|
((char*)f->device->fbaddr)[(y*f->device->pixelwidth + x)*4 + 2] = (char)b;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,10 +11,9 @@ void video(void)
|
|||||||
unsigned int x, y;
|
unsigned int x, y;
|
||||||
pl110_init(&myfb, 16);
|
pl110_init(&myfb, 16);
|
||||||
x = 0, y = 0;
|
x = 0, y = 0;
|
||||||
for (x=0; x<640; x++)
|
|
||||||
for (y=0; y<480; y++)
|
for (y=0; y<480; y++)
|
||||||
fb_write_pixel(&myfb, x, y, 0x1f, 0x1f, 0x0);
|
for (x=0; x<640; x++)
|
||||||
|
fb_write_pixel(&myfb, x, y, 0xff, 0x00, 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user