Commit 98e5b6d0 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Helge Deller
Browse files

fbcon: Put font-rotation state into separate struct



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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent 6903bd69
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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)
+8 −4
Original line number Diff line number Diff line
@@ -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;
};
+4 −4
Original line number Diff line number Diff line
@@ -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) {
+4 −4
Original line number Diff line number Diff line
@@ -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) {
+14 −13
Original line number Diff line number Diff line
@@ -18,34 +18,35 @@
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,
	buf = font_data_rotate(par->rotated.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);
			       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;
}
Loading