All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	qemu-devel@nongnu.org, "Sven Schnelle" <svens@stackframe.org>
Subject: Re: [PATCH 0/6] hppa: Artist graphics driver fixes for HP-UX
Date: Thu, 12 May 2022 14:05:33 +0200	[thread overview]
Message-ID: <Ynz4DeilqP6YYhEX@p100> (raw)
In-Reply-To: <3574c102-ba23-07b9-e6df-818c53718de7@gmx.de>

Please review below patch as well. I'd like to include it
in the series when I send a v2 version of the series.

Thanks,
Helge


From: Helge Deller <deller@gmx.de>
Date: Thu, 12 May 2022 13:40:39 +0200
Subject: [PATCH] artist: Fix X cursor position calculation in X11

The X cursor postion can be calculated based on the backporch and
interleave values.  In the emulation we ignore the HP-UX settings for
backporch and use instead twice the size of the emulated cursor.  With
those changes the X-position of the graphics cursor is now finally
working correctly on HP-UX 10 and HP-UX 11.

Based on coding in Xorg X11R6.6

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/hw/display/artist.c b/hw/display/artist.c
index 49dad2b824..8bf3bed79a 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -1,7 +1,8 @@
 /*
  * QEMU HP Artist Emulation
  *
- * Copyright (c) 2019 Sven Schnelle <svens@stackframe.org>
+ * Copyright (c) 2019-2022 Sven Schnelle <svens@stackframe.org>
+ * Copyright (c) 2022 Helge Deller <deller@gmx.de>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  */
@@ -313,19 +314,15 @@ static void artist_rop8(ARTISTState *s, struct vram_buffer *buf,
 static void artist_get_cursor_pos(ARTISTState *s, int *x, int *y)
 {
     /*
-     * Don't know whether these magic offset values are configurable via
-     * some register. They seem to be the same for all resolutions.
-     * The cursor values provided in the registers are:
-     * X-value: -295 (for HP-UX 11) and 338 (for HP-UX 10.20) up to 2265
-     * Y-value: 1146 down to 0
      * The emulated Artist graphic is like a CRX graphic, and as such
      * it's usually fixed at 1280x1024 pixels.
-     * Because of the maximum Y-value of 1146 you can not choose a higher
-     * vertical resolution on HP-UX (unless you disable the mouse).
+     * Other resolutions may work, but no guarantee.
      */

-    static int offset = 338;
-    int lx;
+    unsigned int hbp_times_vi, horizBackPorch;
+    int16_t xHi, xLo;
+    const int videoInterleave = 4;
+    const int pipelineDelay = 4;

     /* ignore if uninitialized */
     if (s->cursor_pos == 0) {
@@ -333,16 +330,22 @@ static void artist_get_cursor_pos(ARTISTState *s, int *x, int *y)
         return;
     }

-    lx = artist_get_x(s->cursor_pos);
-    if (lx < offset) {
-        offset = lx;
-    }
-    *x = (lx - offset) / 2;
+    /* Calculate X position based on backporch and interleave values.
+       Based on code from Xorg X11R6.6
+     */
+    horizBackPorch = ((s->horiz_backporch & 0xff0000) >> 16) +
+                     ((s->horiz_backporch & 0xff00) >> 8) + 2;
+    hbp_times_vi = horizBackPorch * videoInterleave;
+    xHi = s->cursor_pos >> 19;
+    *x = ((xHi + pipelineDelay) * videoInterleave) - hbp_times_vi;
+
+    xLo = (s->cursor_pos >> 16) & 0x07;
+    *x += ((xLo - hbp_times_vi) & (videoInterleave - 1)) + 8 - 1;

     /* subtract cursor offset from cursor control register */
     *x -= (s->cursor_cntrl & 0xf0) >> 4;

-    /* height minus nOffscreenScanlines is stored in cursor control register */
+    /* Calculate Y position */
     *y = s->height - artist_get_y(s->cursor_pos);
     *y -= (s->cursor_cntrl & 0x0f);

@@ -1056,6 +1059,8 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
         break;

     case HORIZ_BACKPORCH:
+        /* overwrite HP-UX settings to fix X cursor position. */
+        val = (NGLE_MAX_SPRITE_SIZE << 16) + (NGLE_MAX_SPRITE_SIZE << 8);
         combine_write_reg(addr, val, size, &s->horiz_backporch);
         break;



  parent reply	other threads:[~2022-05-12 12:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11 23:50 [PATCH 0/6] hppa: Artist graphics driver fixes for HP-UX Helge Deller
2022-05-11 23:50 ` [PATCH 1/6] seabios-hppa: Update SeaBIOS-hppa to VERSION 4 Helge Deller
2022-05-11 23:50 ` [PATCH 2/6] artist: Introduce constant for max cursor size Helge Deller
2022-05-11 23:50 ` [PATCH 3/6] artist: Use human-readable variable names instead of reg_xxx Helge Deller
2022-05-11 23:50 ` [PATCH 4/6] artist: Fix vertical X11 cursor position in HP-UX Helge Deller
2022-05-11 23:50 ` [PATCH 5/6] artist: Allow to turn cursor on or off Helge Deller
2022-05-11 23:50 ` [PATCH 6/6] artist: Emulate screen blanking Helge Deller
     [not found] ` <3574c102-ba23-07b9-e6df-818c53718de7@gmx.de>
2022-05-12 12:05   ` Helge Deller [this message]
2022-05-16  7:19 ` [PATCH 0/6] hppa: Artist graphics driver fixes for HP-UX Mark Cave-Ayland
2022-05-16 14:43   ` Helge Deller
2022-05-16 16:52     ` Mark Cave-Ayland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ynz4DeilqP6YYhEX@p100 \
    --to=deller@gmx.de \
    --cc=f4bug@amsat.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=svens@stackframe.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.