[PATCH 1/3] tty/vt: 8th bit location in vc_uniscr routines

Zsolt Kajtar posted 3 patches 1 month ago
There is a newer version of this series
[PATCH 1/3] tty/vt: 8th bit location in vc_uniscr routines
Posted by Zsolt Kajtar 1 month ago
Both vc_uniscr_check and vc_uniscr_copy_line assume that the 8th bit of
glyph is also the 8th bit in the screen buffer. However this is only the
case for fbcon at the moment. Vgacon has it on the 11th and so the
conversion won't work correctly in that case. The patch corrects this
oversight.

Signed-off-by: Zsolt Kajtar <soci@c64.rulez.org>
---
 drivers/tty/vt/vt.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 869261141..c6c931047 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -493,7 +493,7 @@ int vc_uniscr_check(struct vc_data *vc)
 {
 	u32 **uni_lines;
 	unsigned short *p;
-	int x, y, mask;
+	int x, y;
 
 	WARN_CONSOLE_UNLOCKED();
 
@@ -514,11 +514,14 @@ int vc_uniscr_check(struct vc_data *vc)
 	 * unicode content will be available after a complete screen refresh.
 	 */
 	p = (unsigned short *)vc->vc_origin;
-	mask = vc->vc_hi_font_mask | 0xff;
 	for (y = 0; y < vc->vc_rows; y++) {
 		u32 *line = uni_lines[y];
 		for (x = 0; x < vc->vc_cols; x++) {
-			u16 glyph = scr_readw(p++) & mask;
+			u16 w = scr_readw(p++);
+			u16 glyph = w & 0xff;
+
+			if (w & vc->vc_hi_font_mask)
+				glyph |= 0x100;
 			line[x] = inverse_translate(vc, glyph, true);
 		}
 	}
@@ -561,10 +564,13 @@ void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed,
 		 * buffer of its own.
 		 */
 		u16 *p = (u16 *)pos;
-		int mask = vc->vc_hi_font_mask | 0xff;
 		u32 *uni_buf = dest;
 		while (nr--) {
-			u16 glyph = scr_readw(p++) & mask;
+			u16 w = scr_readw(p++);
+			u16 glyph = w & 0xff;
+
+			if (w & vc->vc_hi_font_mask)
+				glyph |= 0x100;
 			*uni_buf++ = inverse_translate(vc, glyph, true);
 		}
 	}
-- 
2.30.2
Re: [PATCH 1/3] tty/vt: 8th bit location in vc_uniscr routines
Posted by Jiri Slaby 1 month ago
On 29. 08. 25, 21:49, Zsolt Kajtar wrote:
> Both vc_uniscr_check and vc_uniscr_copy_line assume that the 8th bit of
> glyph is also the 8th bit in the screen buffer. However this is only the
> case for fbcon at the moment. Vgacon has it on the 11th and so the
> conversion won't work correctly in that case. The patch corrects this
> oversight.
> 
> Signed-off-by: Zsolt Kajtar <soci@c64.rulez.org>
> ---
>   drivers/tty/vt/vt.c | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 869261141..c6c931047 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -493,7 +493,7 @@ int vc_uniscr_check(struct vc_data *vc)
>   {
>   	u32 **uni_lines;
>   	unsigned short *p;
> -	int x, y, mask;
> +	int x, y;
>   
>   	WARN_CONSOLE_UNLOCKED();
>   
> @@ -514,11 +514,14 @@ int vc_uniscr_check(struct vc_data *vc)
>   	 * unicode content will be available after a complete screen refresh.
>   	 */
>   	p = (unsigned short *)vc->vc_origin;
> -	mask = vc->vc_hi_font_mask | 0xff;
>   	for (y = 0; y < vc->vc_rows; y++) {
>   		u32 *line = uni_lines[y];
>   		for (x = 0; x < vc->vc_cols; x++) {
> -			u16 glyph = scr_readw(p++) & mask;
> +			u16 w = scr_readw(p++);
> +			u16 glyph = w & 0xff;
> +
> +			if (w & vc->vc_hi_font_mask)
> +				glyph |= 0x100;

This makes sense, but introduce a helper, please.

>   			line[x] = inverse_translate(vc, glyph, true);
>   		}
>   	}
> @@ -561,10 +564,13 @@ void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed,
>   		 * buffer of its own.
>   		 */
>   		u16 *p = (u16 *)pos;
> -		int mask = vc->vc_hi_font_mask | 0xff;
>   		u32 *uni_buf = dest;
>   		while (nr--) {
> -			u16 glyph = scr_readw(p++) & mask;
> +			u16 w = scr_readw(p++);
> +			u16 glyph = w & 0xff;
> +
> +			if (w & vc->vc_hi_font_mask)
> +				glyph |= 0x100;

And use here as well.

>   			*uni_buf++ = inverse_translate(vc, glyph, true);
>   		}
>   	}


-- 
js
suse labs