@@ -53,39 +53,35 @@ enum {
HAL_PIXEL_FORMAT_RGB_888 = 3,
HAL_PIXEL_FORMAT_RGB_565 = 4,
HAL_PIXEL_FORMAT_BGRA_8888 = 5,
- HAL_PIXEL_FORMAT_RGBA_5551 = 6,
- HAL_PIXEL_FORMAT_RGBA_4444 = 7,
};
struct framebuffer_config {
- u8 format;
u8 bytes_per_pixel;
- u8 transp_offset;
- u8 transp_length;
u8 red_offset;
u8 red_length;
u8 green_offset;
u8 green_length;
u8 blue_offset;
u8 blue_length;
+ u8 transp_offset;
+ u8 transp_length;
+};
+
+static const struct framebuffer_config fb_configs[] = {
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Invalid, assume RGB_565 */
+ { 4, 0, 8, 8, 8, 16, 8, 24, 8 }, /* HAL_PIXEL_FORMAT_RGBA_8888 */
+ { 4, 0, 8, 8, 8, 16, 8, 0, 0 }, /* HAL_PIXEL_FORMAT_RGBX_8888 */
+ { 3, 0, 8, 8, 8, 16, 8, 0, 0 }, /* HAL_PIXEL_FORMAT_RGB_888 */
+ { 2, 11, 5, 5, 6, 0, 5, 0, 0 }, /* HAL_PIXEL_FORMAT_RGB_565 */
+ { 4, 16, 8, 8, 8, 0, 8, 24, 8 }, /* HAL_PIXEL_FORMAT_BGRA_8888 */
};
static const struct framebuffer_config *get_fb_config_from_format(int format)
{
- /* Only configurations supported by the emulator. */
- static const struct framebuffer_config fb_configs[] = {
- { HAL_PIXEL_FORMAT_RGB_565, 2, 0, 0, 11, 5, 5, 6, 0, 5 },
- { HAL_PIXEL_FORMAT_RGBX_8888, 4, 0, 0, 16, 8, 8, 8, 0, 8 },
- { HAL_PIXEL_FORMAT_RGBA_8888, 4, 24, 8, 16, 8, 8, 8, 0, 8 },
- };
- const int fb_configs_size = ARRAY_SIZE(fb_configs);
- int n;
-
- for (n = 0; n < fb_configs_size; ++n) {
- if (format == fb_configs[n].format)
- return &fb_configs[n];
- }
- return &fb_configs[0]; /* default to RGB565 */
+ if (format > 0 && format < ARRAY_SIZE(fb_configs))
+ return &fb_configs[format];
+
+ return &fb_configs[HAL_PIXEL_FORMAT_RGB_565]; /* legacy default */
}
struct goldfish_fb {