summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2026-04-07 11:23:19 +0200
committerHelge Deller <deller@gmx.de>2026-04-07 17:38:07 +0200
commitcfa72955a029cd79433694cac6b5630788609cd4 (patch)
tree92e0af2b946b9f427bbac94a0352d1df4fbddc37 /drivers/video/fbdev
parenta30e9e6b018f40941a626ff77e0bf35c015038fa (diff)
downloadlwn-cfa72955a029cd79433694cac6b5630788609cd4.tar.gz
lwn-cfa72955a029cd79433694cac6b5630788609cd4.zip
lib/fonts: Implement font rotation
Move the core of fbcon's font-rotation code to the font library as the new helper font_data_rotate(). The code can rotate in steps of 90°. For completeness, it also copies the glyph data for multiples of 360°. Bring back the memset optimization. A memset to 0 again clears the whole glyph output buffer. Then use the internal rotation helpers on the cleared output. Fbcon's original implementation worked like this, but lost it during refactoring. Replace fbcon's font-rotation code with the new implementations. All that's left to do for fbcon is to maintain its internal fbcon state. v2: - fix typos Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'drivers/video/fbdev')
-rw-r--r--drivers/video/fbdev/core/fbcon.h2
-rw-r--r--drivers/video/fbdev/core/fbcon_rotate.c78
2 files changed, 20 insertions, 60 deletions
diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h
index 1e3c1ef84762..1793f34a6c84 100644
--- a/drivers/video/fbdev/core/fbcon.h
+++ b/drivers/video/fbdev/core/fbcon.h
@@ -86,7 +86,7 @@ struct fbcon_par {
const u8 *fontdata;
u8 *cursor_src;
u32 cursor_size;
- u32 fd_size;
+ size_t fd_size;
const struct fbcon_bitops *bitops;
};
diff --git a/drivers/video/fbdev/core/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c
index 588dc9d6758a..74206f5a6e98 100644
--- a/drivers/video/fbdev/core/fbcon_rotate.c
+++ b/drivers/video/fbdev/core/fbcon_rotate.c
@@ -8,84 +8,44 @@
* more details.
*/
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/string.h>
+#include <linux/errno.h>
#include <linux/fb.h>
#include <linux/font.h>
-#include <linux/vt_kern.h>
-#include <linux/console.h>
-#include <asm/types.h>
+
#include "fbcon.h"
#include "fbcon_rotate.h"
int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
{
struct fbcon_par *par = info->fbcon_par;
- int len, err = 0;
- int s_cellsize, d_cellsize, i;
- const u8 *src;
- u8 *dst;
+ unsigned char *fontbuffer;
+ int ret;
if (vc->vc_font.data == par->fontdata &&
par->p->con_rotate == par->cur_rotate)
- goto finished;
+ return 0;
- src = par->fontdata = vc->vc_font.data;
+ par->fontdata = vc->vc_font.data;
par->cur_rotate = par->p->con_rotate;
- len = vc->vc_font.charcount;
- s_cellsize = font_glyph_size(vc->vc_font.width, vc->vc_font.height);
- d_cellsize = s_cellsize;
-
- if (par->rotate == FB_ROTATE_CW ||
- par->rotate == FB_ROTATE_CCW)
- d_cellsize = font_glyph_size(vc->vc_font.height, vc->vc_font.width);
if (info->fbops->fb_sync)
info->fbops->fb_sync(info);
- if (par->fd_size < d_cellsize * len) {
- kfree(par->fontbuffer);
- par->fontbuffer = NULL;
- par->fd_size = 0;
-
- dst = kmalloc_array(len, d_cellsize, GFP_KERNEL);
-
- if (dst == NULL) {
- err = -ENOMEM;
- goto finished;
- }
-
- par->fd_size = d_cellsize * len;
- par->fontbuffer = dst;
+ 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);
+ goto err_kfree;
}
- dst = par->fontbuffer;
+ par->fontbuffer = fontbuffer;
- switch (par->rotate) {
- case FB_ROTATE_UD:
- for (i = len; i--; ) {
- font_glyph_rotate_180(src, vc->vc_font.width, vc->vc_font.height, dst);
- src += s_cellsize;
- dst += d_cellsize;
- }
- break;
- case FB_ROTATE_CW:
- for (i = len; i--; ) {
- font_glyph_rotate_90(src, vc->vc_font.width, vc->vc_font.height, dst);
- src += s_cellsize;
- dst += d_cellsize;
- }
- break;
- case FB_ROTATE_CCW:
- for (i = len; i--; ) {
- font_glyph_rotate_270(src, vc->vc_font.width, vc->vc_font.height, dst);
- src += s_cellsize;
- dst += d_cellsize;
- }
- break;
- }
+ return 0;
+
+err_kfree:
+ kfree(par->fontbuffer);
+ par->fontbuffer = NULL; /* clear here to avoid output */
-finished:
- return err;
+ return ret;
}