Get the correct line_length.

Set the BPP and other fields and write it back, so the line_length comes back correctly.

Change-Id: I85e4e8223c79b9394ae1fb609b3026de62027ab8
This commit is contained in:
Michael Ward 2011-06-23 19:28:53 -07:00
parent fb04b87002
commit 3dbe66b71d

View File

@ -74,13 +74,48 @@ static int get_framebuffer(GGLSurface *fb)
return -1;
}
if (ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) {
if (ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) {
perror("failed to get fb0 info");
close(fd);
return -1;
}
if (ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) {
vi.bits_per_pixel = PIXEL_SIZE * 8;
if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_BGRA_8888) {
vi.red.offset = 8;
vi.red.length = 8;
vi.green.offset = 16;
vi.green.length = 8;
vi.blue.offset = 24;
vi.blue.length = 8;
vi.transp.offset = 0;
vi.transp.length = 8;
} else if (PIXEL_FORMAT == GGL_PIXEL_FORMAT_RGBX_8888) {
vi.red.offset = 24;
vi.red.length = 8;
vi.green.offset = 16;
vi.green.length = 8;
vi.blue.offset = 8;
vi.blue.length = 8;
vi.transp.offset = 0;
vi.transp.length = 8;
} else { /* RGB565*/
vi.red.offset = 11;
vi.red.length = 5;
vi.green.offset = 5;
vi.green.length = 6;
vi.blue.offset = 0;
vi.blue.length = 5;
vi.transp.offset = 0;
vi.transp.length = 0;
}
if (ioctl(fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
perror("failed to put fb0 info");
close(fd);
return -1;
}
if (ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) {
perror("failed to get fb0 info");
close(fd);
return -1;