Skip to content

Commit b5c634f

Browse files
yishai1999kartben
authored andcommitted
cfb: fix get_glyph_byte for vtiled displays
V-Tiled displays need different treatment when getting the glyph byte. Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
1 parent 276d447 commit b5c634f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

subsys/fb/cfb.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@ static inline uint8_t *get_glyph_ptr(const struct cfb_font *fptr, uint8_t c)
7575
}
7676

7777
static inline uint8_t get_glyph_byte(uint8_t *glyph_ptr, const struct cfb_font *fptr,
78-
uint8_t x, uint8_t y)
78+
uint8_t x, uint8_t y, bool vtiled)
7979
{
8080
if (fptr->caps & CFB_FONT_MONO_VPACKED) {
81-
return glyph_ptr[(x * fptr->height + y) / 8];
81+
if (vtiled) {
82+
return glyph_ptr[x * (fptr->height / 8U) + y];
83+
} else {
84+
return glyph_ptr[(x * fptr->height + y) / 8];
85+
}
8286
} else if (fptr->caps & CFB_FONT_MONO_HPACKED) {
8387
return glyph_ptr[y * (fptr->width) + x];
8488
}
@@ -140,10 +144,11 @@ static uint8_t draw_char_vtmono(const struct char_framebuffer *fb,
140144
* So, we process assume that nothing is drawn above.
141145
*/
142146
byte = 0;
143-
next_byte = get_glyph_byte(glyph_ptr, fptr, g_x, g_y / 8);
147+
next_byte = get_glyph_byte(glyph_ptr, fptr, g_x, g_y / 8, true);
144148
} else {
145-
byte = get_glyph_byte(glyph_ptr, fptr, g_x, g_y / 8);
146-
next_byte = get_glyph_byte(glyph_ptr, fptr, g_x, (g_y + 8) / 8);
149+
byte = get_glyph_byte(glyph_ptr, fptr, g_x, g_y / 8, true);
150+
next_byte =
151+
get_glyph_byte(glyph_ptr, fptr, g_x, (g_y + 8) / 8, true);
147152
}
148153

149154
if (font_is_msbfirst) {
@@ -246,7 +251,7 @@ static uint8_t draw_char_htmono(const struct char_framebuffer *fb,
246251
continue;
247252
}
248253

249-
byte = get_glyph_byte(glyph_ptr, fptr, g_x, g_y);
254+
byte = get_glyph_byte(glyph_ptr, fptr, g_x, g_y, false);
250255
if (font_is_msbfirst) {
251256
byte = byte_reverse(byte);
252257
}

0 commit comments

Comments
 (0)