]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fbcon: Put font-rotation state into separate struct
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 7 Apr 2026 09:23:21 +0000 (11:23 +0200)
committerHelge Deller <deller@gmx.de>
Tue, 7 Apr 2026 15:38:07 +0000 (17:38 +0200)
Move all temporary state of the font-rotation code into the struct
rotated in struct fbcon_par. Protect it with the Kconfig symbol
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION. Avoids mixing it up with fbcon's
regular state.

v2:
- fix typos

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/core/fbcon.c
drivers/video/fbdev/core/fbcon.h
drivers/video/fbdev/core/fbcon_ccw.c
drivers/video/fbdev/core/fbcon_cw.c
drivers/video/fbdev/core/fbcon_rotate.c
drivers/video/fbdev/core/fbcon_ud.c

index ff4c69e971f8cc19d77a0585d7df173da3a35923..b0e3e765360d1e0815f48e99ce38e3754fe1189c 100644 (file)
@@ -787,7 +787,9 @@ static void fbcon_release(struct fb_info *info)
                kfree(par->cursor_state.mask);
                kfree(par->cursor_data);
                kfree(par->cursor_src);
-               kfree(par->fontbuffer);
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
+               kfree(par->rotated.buf);
+#endif
                kfree(info->fbcon_par);
                info->fbcon_par = NULL;
        }
@@ -1040,7 +1042,9 @@ static const char *fbcon_startup(void)
        par = info->fbcon_par;
        par->currcon = -1;
        par->graphics = 1;
-       par->cur_rotate = -1;
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
+       par->rotated.buf_rotate = -1;
+#endif
 
        p->con_rotate = initial_rotation;
        if (p->con_rotate == -1)
index bb0727b706312cd1346c673b6ae256e036b6e49c..321cc7f44baa8af9e57caed411bafee68e343f17 100644 (file)
@@ -80,13 +80,17 @@ struct fbcon_par {
        int    graphics;
        bool   initialized;
        int    rotate;
-       int    cur_rotate;
        char  *cursor_data;
-       u8          *fontbuffer;
-       const u8    *fontdata;
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
+       struct {
+               font_data_t *fontdata;  /* source font */
+               u8 *buf;                /* rotated glyphs */
+               size_t bufsize;
+               int buf_rotate;         /* rotation of buf */
+       } rotated;
+#endif
        u8    *cursor_src;
        u32    cursor_size;
-       size_t fd_size;
 
        const struct fbcon_bitops *bitops;
 };
index 723d9a33067f315ec547460fecf10e5697b60c49..33f02d579e0244a8e48e2e5f0846cc5180f50f5c 100644 (file)
@@ -106,7 +106,7 @@ static inline void ccw_putcs_aligned(struct vc_data *vc, struct fb_info *info,
        u8 *src;
 
        while (cnt--) {
-               src = par->fontbuffer + (scr_readw(s--) & charmask) * cellsize;
+               src = par->rotated.buf + (scr_readw(s--) & charmask) * cellsize;
 
                if (attr) {
                        ccw_update_attr(buf, src, attr, vc);
@@ -142,7 +142,7 @@ static void ccw_putcs(struct vc_data *vc, struct fb_info *info,
        u8 *dst, *buf = NULL;
        u32 vyres = GETVYRES(par->p, info);
 
-       if (!par->fontbuffer)
+       if (!par->rotated.buf)
                return;
 
        image.fg_color = fg;
@@ -232,14 +232,14 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
        char *src;
        u32 vyres = GETVYRES(par->p, info);
 
-       if (!par->fontbuffer)
+       if (!par->rotated.buf)
                return;
 
        cursor.set = 0;
 
        c = scr_readw((u16 *) vc->vc_pos);
        attribute = get_attribute(info, c);
-       src = par->fontbuffer + ((c & charmask) * (w * vc->vc_font.width));
+       src = par->rotated.buf + ((c & charmask) * (w * vc->vc_font.width));
 
        if (par->cursor_state.image.data != src ||
            par->cursor_reset) {
index 732d093d462fa39509389db596121df549680e02..bde820967eb9ad9a9d138242e6da87bd4cf1e8ff 100644 (file)
@@ -91,7 +91,7 @@ static inline void cw_putcs_aligned(struct vc_data *vc, struct fb_info *info,
        u8 *src;
 
        while (cnt--) {
-               src = par->fontbuffer + (scr_readw(s++) & charmask) * cellsize;
+               src = par->rotated.buf + (scr_readw(s++) & charmask) * cellsize;
 
                if (attr) {
                        cw_update_attr(buf, src, attr, vc);
@@ -127,7 +127,7 @@ static void cw_putcs(struct vc_data *vc, struct fb_info *info,
        u8 *dst, *buf = NULL;
        u32 vxres = GETVXRES(par->p, info);
 
-       if (!par->fontbuffer)
+       if (!par->rotated.buf)
                return;
 
        image.fg_color = fg;
@@ -215,14 +215,14 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
        char *src;
        u32 vxres = GETVXRES(par->p, info);
 
-       if (!par->fontbuffer)
+       if (!par->rotated.buf)
                return;
 
        cursor.set = 0;
 
        c = scr_readw((u16 *) vc->vc_pos);
        attribute = get_attribute(info, c);
-       src = par->fontbuffer + ((c & charmask) * (w * vc->vc_font.width));
+       src = par->rotated.buf + ((c & charmask) * (w * vc->vc_font.width));
 
        if (par->cursor_state.image.data != src ||
            par->cursor_reset) {
index 74206f5a6e984146da999b335f330a9b67b87a4a..6cdbc96eeca6f5036553f5703d048263253af962 100644 (file)
 int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
 {
        struct fbcon_par *par = info->fbcon_par;
-       unsigned char *fontbuffer;
+       unsigned char *buf;
        int ret;
 
-       if (vc->vc_font.data == par->fontdata &&
-           par->p->con_rotate == par->cur_rotate)
+       if (par->p->fontdata == par->rotated.fontdata && par->rotate == par->rotated.buf_rotate)
                return 0;
 
-       par->fontdata = vc->vc_font.data;
-       par->cur_rotate = par->p->con_rotate;
+       par->rotated.fontdata = par->p->fontdata;
+       par->rotated.buf_rotate = par->rotate;
 
        if (info->fbops->fb_sync)
                info->fbops->fb_sync(info);
 
-       fontbuffer = font_data_rotate(par->p->fontdata, vc->vc_font.width,
-                                     vc->vc_font.height, vc->vc_font.charcount,
-                                     par->rotate, par->fontbuffer, &par->fd_size);
-       if (IS_ERR(fontbuffer)) {
-               ret = PTR_ERR(fontbuffer);
+       buf = font_data_rotate(par->rotated.fontdata, vc->vc_font.width,
+                              vc->vc_font.height, vc->vc_font.charcount,
+                              par->rotated.buf_rotate, par->rotated.buf,
+                              &par->rotated.bufsize);
+       if (IS_ERR(buf)) {
+               ret = PTR_ERR(buf);
                goto err_kfree;
        }
 
-       par->fontbuffer = fontbuffer;
+       par->rotated.buf = buf;
 
        return 0;
 
 err_kfree:
-       kfree(par->fontbuffer);
-       par->fontbuffer = NULL; /* clear here to avoid output */
+       kfree(par->rotated.buf);
+       par->rotated.buf = NULL; /* clear here to avoid output */
+       par->rotated.bufsize = 0;
 
        return ret;
 }
index a1981fa4701a26cc8f4919935b5e8f24854439da..eaf08999e24927343551ec4ec9fd5588f522e50b 100644 (file)
@@ -92,7 +92,7 @@ static inline void ud_putcs_aligned(struct vc_data *vc, struct fb_info *info,
        u8 *src;
 
        while (cnt--) {
-               src = par->fontbuffer + (scr_readw(s--) & charmask) * cellsize;
+               src = par->rotated.buf + (scr_readw(s--) & charmask) * cellsize;
 
                if (attr) {
                        ud_update_attr(buf, src, attr, vc);
@@ -127,7 +127,7 @@ static inline void ud_putcs_unaligned(struct vc_data *vc,
        u8 *src;
 
        while (cnt--) {
-               src = par->fontbuffer + (scr_readw(s--) & charmask) * cellsize;
+               src = par->rotated.buf + (scr_readw(s--) & charmask) * cellsize;
 
                if (attr) {
                        ud_update_attr(buf, src, attr, vc);
@@ -164,7 +164,7 @@ static void ud_putcs(struct vc_data *vc, struct fb_info *info,
        u32 vyres = GETVYRES(par->p, info);
        u32 vxres = GETVXRES(par->p, info);
 
-       if (!par->fontbuffer)
+       if (!par->rotated.buf)
                return;
 
        image.fg_color = fg;
@@ -262,14 +262,14 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
        u32 vyres = GETVYRES(par->p, info);
        u32 vxres = GETVXRES(par->p, info);
 
-       if (!par->fontbuffer)
+       if (!par->rotated.buf)
                return;
 
        cursor.set = 0;
 
        c = scr_readw((u16 *) vc->vc_pos);
        attribute = get_attribute(info, c);
-       src = par->fontbuffer + ((c & charmask) * (w * vc->vc_font.height));
+       src = par->rotated.buf + ((c & charmask) * (w * vc->vc_font.height));
 
        if (par->cursor_state.image.data != src ||
            par->cursor_reset) {