qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Cc: Helge Deller <deller@gmx.de>, qemu-stable@nongnu.org
Subject: [PATCH 5/5] hw/display/artist: Fix framebuffer access for Linux
Date: Wed, 12 Jan 2022 22:07:30 +0100	[thread overview]
Message-ID: <20220112210730.292775-6-deller@gmx.de> (raw)
In-Reply-To: <20220112210730.292775-1-deller@gmx.de>

This patch fixes two problems which prevented Linux to access the
artist graphics framebuffer:

The check if the framebuffer or the color map should be accessed was
incomplete. By using the vram_read/write_bufidx() functions we now check
correctly if ARTIST_BUFFER_CMAP should be accessed.

The second fix is to correctly calculate the X- and Y-coordinates and
check against the graphics resolution.

With this fix in place, the Linux stifb driver now works correctly,
shows the penguins at bootup and uses the stifb as graphics console.
I haven't seen any negative side effects when running HP-UX.

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: qemu-stable@nongnu.org
---
 hw/display/artist.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/display/artist.c b/hw/display/artist.c
index 6384076c60..fbf5525334 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -1186,7 +1186,7 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
     unsigned int offset;
     trace_artist_vram_write(size, addr, val);

-    if (s->cmap_bm_access) {
+    if (vram_write_bufidx(s) == ARTIST_BUFFER_CMAP) {
         buf = &s->vram_buffer[ARTIST_BUFFER_CMAP];
         if (addr + 3 < buf->size) {
             *(uint32_t *)(buf->data + addr) = val;
@@ -1195,14 +1195,14 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
     }

     buf = vram_write_buffer(s);
-    posy = ADDR_TO_Y(addr >> 2);
-    posx = ADDR_TO_X(addr >> 2);
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);

     if (!buf->size) {
         return;
     }

-    if (posy > buf->height || posx > buf->width) {
+    if (posy >= buf->height || posx >= buf->width) {
         return;
     }

@@ -1242,7 +1242,7 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
     uint64_t val;
     unsigned int posy, posx;

-    if (s->cmap_bm_access) {
+    if (vram_read_bufidx(s) == ARTIST_BUFFER_CMAP) {
         buf = &s->vram_buffer[ARTIST_BUFFER_CMAP];
         val = 0;
         if (addr < buf->size && addr + 3 < buf->size) {
@@ -1257,10 +1257,10 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
         return 0;
     }

-    posy = ADDR_TO_Y(addr >> 2);
-    posx = ADDR_TO_X(addr >> 2);
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);

-    if (posy > buf->height || posx > buf->width) {
+    if (posy >= buf->height || posx >= buf->width) {
         return 0;
     }

--
2.31.1



  parent reply	other threads:[~2022-01-12 21:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 21:07 [PATCH 0/5] Fixes and updates for hppa target Helge Deller
2022-01-12 21:07 ` [PATCH 1/5] seabios-hppa: Update SeaBIOS-hppa to VERSION 3 Helge Deller
2022-01-12 21:07 ` [PATCH 2/5] hw/hppa: Allow up to 16 emulated CPUs Helge Deller
2022-01-12 21:07 ` [PATCH 3/5] hppa: Add support for an emulated TOC/NMI button Helge Deller
2022-01-12 21:07 ` [PATCH 4/5] hw/display/artist: Mouse cursor fixes for HP-UX Helge Deller
2022-01-12 21:07 ` Helge Deller [this message]
2022-01-12 21:47   ` [PATCH 5/5] hw/display/artist: Fix framebuffer access for Linux Philippe Mathieu-Daudé
2022-01-15 11:55     ` Sven Schnelle
2022-01-15 18:36       ` Sven Schnelle

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=20220112210730.292775-6-deller@gmx.de \
    --to=deller@gmx.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).