[PATCH 05/08] viafb: fix cursor position and size
From: Johann Klammer
Date: Sat Dec 05 2026 - 17:24:01 EST
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@xxxxxx>
---
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;
+ }
+ }
}
}