Files
linux/drivers/video/fbdev/core/fbcon_rotate.c
Thomas Zimmermann cfa72955a0 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>
2026-04-07 17:38:07 +02:00

52 lines
1.2 KiB
C

/*
* linux/drivers/video/console/fbcon_rotate.c -- Software Rotation
*
* Copyright (C) 2005 Antonino Daplas <adaplas @pol.net>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include <linux/errno.h>
#include <linux/fb.h>
#include <linux/font.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;
unsigned char *fontbuffer;
int ret;
if (vc->vc_font.data == par->fontdata &&
par->p->con_rotate == par->cur_rotate)
return 0;
par->fontdata = vc->vc_font.data;
par->cur_rotate = par->p->con_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);
goto err_kfree;
}
par->fontbuffer = fontbuffer;
return 0;
err_kfree:
kfree(par->fontbuffer);
par->fontbuffer = NULL; /* clear here to avoid output */
return ret;
}