Skip to content

Commit 411b5be

Browse files
committed
Support 16/32 bit color depth
Mado currently supports 32-bit color depth for desktop and laptop display devices. To enhance its compatibility across diverse Linux framebuffer environments, I have made the following changes to support both 16-bit and 32-bit color depths: - Distinguish the color format and perform color format conversion. - Examine the correctness of the framebuffer format based on the color format. These updates improve Mado's compatibility, enabling it to be used on devices with low memory overhead, such as the Raspberry Pi, in addition to desktop display devices.
1 parent efe7d49 commit 411b5be

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

backend/fbdev.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,30 @@ static bool twin_fbdev_work(void *closure)
8888
return true;
8989
}
9090

91+
<<<<<<< HEAD
92+
=======
93+
static inline bool twin_fbdev_is_rgb565(twin_fbdev_t *tx)
94+
{
95+
return tx->fb_var.red.offset == 11 && tx->fb_var.red.length == 5 &&
96+
tx->fb_var.green.offset == 5 && tx->fb_var.green.length == 6 &&
97+
tx->fb_var.blue.offset == 0 && tx->fb_var.blue.length == 5;
98+
}
99+
100+
static inline bool twin_fbdev_is_rgb888(twin_fbdev_t *tx)
101+
{
102+
return tx->fb_var.red.offset == 16 && tx->fb_var.red.length == 8 &&
103+
tx->fb_var.green.offset == 8 && tx->fb_var.green.length == 8 &&
104+
tx->fb_var.blue.offset == 0 && tx->fb_var.blue.length == 8;
105+
}
106+
107+
static inline bool twin_fbdev_is_argb32(twin_fbdev_t *tx)
108+
{
109+
return tx->fb_var.red.offset == 16 && tx->fb_var.red.length == 8 &&
110+
tx->fb_var.green.offset == 8 && tx->fb_var.green.length == 8 &&
111+
tx->fb_var.blue.offset == 0 && tx->fb_var.blue.length == 8;
112+
}
113+
114+
>>>>>>> b70c59c (Support 16/32 bit color depth)
91115
static bool twin_fbdev_apply_config(twin_fbdev_t *tx)
92116
{
93117
/* Read changable information of the framebuffer */
@@ -111,10 +135,36 @@ static bool twin_fbdev_apply_config(twin_fbdev_t *tx)
111135
return false;
112136
}
113137

138+
<<<<<<< HEAD
114139
/* Check bits per pixel */
115140
if (tx->fb_var.bits_per_pixel != 32) {
116141
log_error("Failed to set framebuffer bpp to 32");
117142
return false;
143+
=======
144+
/* Examine the framebuffer format */
145+
switch (tx->fb_var.bits_per_pixel) {
146+
case 16: /* RGB565 */
147+
if (!twin_fbdev_is_rgb565(tx)) {
148+
log_error("Invalid framebuffer format for 16 bpp");
149+
return false;
150+
}
151+
break;
152+
case 24: /* RGB888 */
153+
if (!twin_fbdev_is_rgb888(tx)) {
154+
log_error("Invalid framebuffer format for 24 bpp");
155+
return false;
156+
}
157+
break;
158+
case 32: /* ARGB32 */
159+
if (!twin_fbdev_is_argb32(tx)) {
160+
log_error("Invalid framebuffer format for 32 bpp");
161+
return false;
162+
}
163+
break;
164+
default:
165+
log_error("Unsupported bits per pixel: %d", tx->fb_var.bits_per_pixel);
166+
break;
167+
>>>>>>> b70c59c (Support 16/32 bit color depth)
118168
}
119169

120170
/* Read unchangable information of the framebuffer */

0 commit comments

Comments
 (0)