mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 05/08] viafb: fix cursor position and size
@ 2026-12-05 22:23 Johann Klammer
  0 siblings, 0 replies; only message in thread
From: Johann Klammer @ 2026-12-05 22:23 UTC (permalink / raw)
  To: FlorianSchandinat, linux-kernel, linux-fbdev

Motivation: get those low-res modes working.
the hardware cursor is ignorant of doublescan.
y coordinate and cursor height has to be doubled, so it displays correctly.

From: [GPT-6]
Signed-off-by: Johann Klammer <klammerj@a1.net>
---
diff '--color=auto' -uprN -x '*.o' -x '*.ko' -x '*.mod*' -x '*.a' -x '*.cmd' -x modules.order -x Module.symvers -x .tmp_versions linux-7.3.0-gentoo.orig/drivers/video/fbdev/via/viafbdev.c linux-7.3.0-gentoo.work/drivers/video/fbdev/via/viafbdev.c
--- linux-7.3.0-gentoo.orig/drivers/video/fbdev/via/viafbdev.c	2026-12-05 21:25:49.332370762 +0100
+++ linux-7.3.0-gentoo.work/drivers/video/fbdev/via/viafbdev.c	2026-12-05 21:29:38.968377017 +0100
@@ -774,7 +774,7 @@ static int viafb_cursor(struct fb_info *
 	void __iomem *engine = viapar->shared->vdev->engine_mmio;
 	u32 temp, xx, yy, bg_color = 0, fg_color = 0,
 		chip_name = viapar->shared->chip_info.gfx_chip_name;
-	int i, j = 0, cur_size = 64;
+	int i, cur_size = 64;
 
 	if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo)
 		return -ENODEV;
@@ -793,6 +793,8 @@ static int viafb_cursor(struct fb_info *
 
 	if (cursor->set & FB_CUR_SETPOS) {
 		yy = cursor->image.dy - info->var.yoffset;
+		if(info->var.vmode & FB_VMODE_DOUBLE)
+			yy *= 2;
 		xx = cursor->image.dx - info->var.xoffset;
 		temp = yy & 0xFFFF;
 		temp |= (xx << 16);
@@ -890,19 +892,46 @@ static int viafb_cursor(struct fb_info *
 			break;
 		}
 
-		if (cur_size == 32) {
-			for (i = 0; i < size; i++) {
-				cr_data->bak[j] = (u32) cr_data->data[i];
-				cr_data->bak[j + 1] = ~cr_data->bak[j];
-				j += 2;
-			}
-		} else {
-			for (i = 0; i < size; i++) {
-				cr_data->bak[j] = (u32) cr_data->data[i];
-				cr_data->bak[j + 1] = 0x0;
-				cr_data->bak[j + 2] = ~cr_data->bak[j];
-				cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
-				j += 4;
+		{
+			int stride = (cursor->image.width + 7) >> 3;
+			int dbl = (info->var.vmode & FB_VMODE_DOUBLE) &&
+				(cursor->image.height <= 32);
+			int row, col, dst = 0;
+
+			if (cur_size == 32) {
+				for (row = 0; row < cursor->image.height; row++) {
+					u32 row_bits = 0;
+					for (col = 0; col < stride; col++)
+						row_bits |= (u32)cr_data->data[row * stride + col] << (col * 8);
+					cr_data->bak[dst] = row_bits;
+					cr_data->bak[dst + 1] = ~row_bits;
+					dst += 2;
+					if (dbl) {
+						cr_data->bak[dst] = row_bits;
+						cr_data->bak[dst + 1] = ~row_bits;
+						dst += 2;
+					}
+				}
+			} else {
+				for (row = 0; row < cursor->image.height; row++) {
+					u32 row_lo = 0, row_hi = 0;
+					for (col = 0; col < stride && col < 4; col++)
+						row_lo |= (u32)cr_data->data[row * stride + col] << (col * 8);
+					for (col = 4; col < stride && col < 8; col++)
+						row_hi |= (u32)cr_data->data[row * stride + col] << ((col - 4) * 8);
+					cr_data->bak[dst] = row_lo;
+					cr_data->bak[dst + 1] = row_hi;
+					cr_data->bak[dst + 2] = ~row_lo;
+					cr_data->bak[dst + 3] = ~row_hi;
+					dst += 4;
+					if (dbl) {
+						cr_data->bak[dst] = row_lo;
+						cr_data->bak[dst + 1] = row_hi;
+						cr_data->bak[dst + 2] = ~row_lo;
+						cr_data->bak[dst + 3] = ~row_hi;
+						dst += 4;
+					}
+				}
 			}
 		}
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-05 22:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-05 22:23 [PATCH 05/08] viafb: fix cursor position and size Johann Klammer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®