1 #include <hardware/vbe.h>
12 /* FIXME: Masks/shifts are preliminary and not tested */
13 static const char ModeTable
[2][8] =
15 {5, 0, 6, 5, 5, 11, 0, 0},
16 {5, 0, 5, 5, 5, 10, 0, 0}
19 static int SetFormat(struct vbe_mode
*info
, unsigned char mode
)
21 if ((mode
> 0) && (mode
< FORMAT_OTHER
))
25 memcpy(&info
->red_mask_size
, ModeTable
[mode
], 8);
26 memcpy(&info
->linear_red_mask_size
, ModeTable
[mode
], 8);
32 DisplayError("Unknown display format %d\n"
33 "Screen size %d x %d, BPP %d, BytesPerLine %d",
34 mode
, info
->x_resolution
, info
->y_resolution
, info
->bits_per_pixel
, info
->bytes_per_scanline
);
40 int GetFBInfo(struct vbe_mode
*info
)
44 RawFrameBufferInfo fb
;
47 D(fprintf(stderr
, "[Video] Getting framebuffer information...\n"));
50 ret
= ExtEscape(hdc
, GETRAWFRAMEBUFFER
, 0, NULL
, sizeof(fb
), (char *)&fb
);
55 D(fprintf(stderr
, "[Video] GETRAWFRAMEBUFFER worked, addr %p, size %d x %d\n",
56 fb
.pFramePointer
, fb
.cxPixels
, fb
.cyPixels
));
57 D(fprintf(stderr
, "[Video] Format %d, BPP %d, BytesPerPixel %d, BytesPerLine %d\n",
58 fb
.wFormat
, fb
.wBPP
, fb
.cxStride
, fb
.cyStride
));
60 info
->bytes_per_scanline
= fb
.cyStride
;
61 info
->x_resolution
= fb
.cxPixels
;
62 info
->y_resolution
= fb
.cyPixels
;
63 info
->bits_per_pixel
= fb
.wBPP
;
64 info
->phys_base
= (unsigned int)fb
.pFramePointer
; /* FIXME: Convert to physical! */
65 info
->linear_bytes_per_scanline
= fb
.cyStride
;
67 return SetFormat(info
, fb
.wFormat
);
71 * HaRET also tries GAPI at this point. However:
72 * 1. Some documentation says that GAPI is deprecated
73 * 2. I don't want to bother with runtime linking, current code works quite fine.
77 ret
= ExtEscape(hdc
, GETGXINFO
, 0, NULL
, sizeof(dev
), (char *)&dev
);
81 D(fprintf(stderr
, "[Video] GETGXINFO worked, addr %p, size %ld x %ld\n",
82 dev
.pvFrameBuffer
, dev
.cxWidth
, dev
.cyHeight
));
83 D(fprintf(stderr
, "[Video] Format %ld, BPP %ld, BytesPerLine %ld\n",
84 dev
.ffFormat
, dev
.cBPP
, dev
.cbStride
));
86 info
->bytes_per_scanline
= dev
.cbStride
;
87 info
->x_resolution
= dev
.cxWidth
;
88 info
->y_resolution
= dev
.cyHeight
;
89 info
->bits_per_pixel
= dev
.cBPP
;
90 info
->phys_base
= (unsigned int)dev
.pvFrameBuffer
; /* FIXME: Convert to physical! */
91 info
->linear_bytes_per_scanline
= dev
.cbStride
;
93 return SetFormat(info
, dev
.ffFormat
);
96 DisplayError("Failed to get framebuffer information");