All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sm501: Fix hardware cursor color conversion
@ 2018-06-18 21:38 Sebastian Bauer
  2018-06-18 23:56 ` David Gibson
  2018-06-19  5:26 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Bauer @ 2018-06-18 21:38 UTC (permalink / raw)
  To: mail; +Cc: qemu-devel, david, balaton

According to the sm501 specs the hardware cursor colors are to be given in
the rgb565 format, but the code currently interprets them as bgr565.

Therefore, the colors of the hardware cursors are wrong in the QEMU
display, e.g., the standard mouse pointer of AmigaOS appears blue instead
of red. This change fixes this issue by replacing the existing naive
bgr565 => rgb888 conversion with a standard rgb565 => rgb888 one that also
scales the color component values properly.

Signed-off-by: Sebastian Bauer <mail@sebastianbauer.info>
---
 hw/display/sm501.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 0488ab69d3..6c7f8483f3 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -668,9 +668,9 @@ static inline void get_hwc_palette(SM501State *state, int crt, uint8_t *palette)
         } else {
             rgb565 = color_reg & 0xFFFF;
         }
-        palette[i * 3 + 0] = (rgb565 << 3) & 0xf8; /* red */
-        palette[i * 3 + 1] = (rgb565 >> 3) & 0xfc; /* green */
-        palette[i * 3 + 2] = (rgb565 >> 8) & 0xf8; /* blue */
+        palette[i * 3 + 0] = ((rgb565 >> 11) * 527 + 23) >> 6; /* r */
+        palette[i * 3 + 1] = (((rgb565 >> 5) & 0x3f) * 259 + 33) >> 6; /* g */
+        palette[i * 3 + 2] = ((rgb565 & 0x1f) * 527 + 23) >> 6; /* b */
     }
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] sm501: Fix hardware cursor color conversion
  2018-06-18 21:38 [Qemu-devel] [PATCH] sm501: Fix hardware cursor color conversion Sebastian Bauer
@ 2018-06-18 23:56 ` David Gibson
  2018-06-19  5:26 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2018-06-18 23:56 UTC (permalink / raw)
  To: Sebastian Bauer; +Cc: qemu-devel, balaton

[-- Attachment #1: Type: text/plain, Size: 1759 bytes --]

On Mon, Jun 18, 2018 at 11:38:16PM +0200, Sebastian Bauer wrote:
> According to the sm501 specs the hardware cursor colors are to be given in
> the rgb565 format, but the code currently interprets them as bgr565.

Can those specs be found online somewhere?

> 
> Therefore, the colors of the hardware cursors are wrong in the QEMU
> display, e.g., the standard mouse pointer of AmigaOS appears blue instead
> of red. This change fixes this issue by replacing the existing naive
> bgr565 => rgb888 conversion with a standard rgb565 => rgb888 one that also
> scales the color component values properly.
> 
> Signed-off-by: Sebastian Bauer <mail@sebastianbauer.info>
> ---
>  hw/display/sm501.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 0488ab69d3..6c7f8483f3 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -668,9 +668,9 @@ static inline void get_hwc_palette(SM501State *state, int crt, uint8_t *palette)
>          } else {
>              rgb565 = color_reg & 0xFFFF;
>          }
> -        palette[i * 3 + 0] = (rgb565 << 3) & 0xf8; /* red */
> -        palette[i * 3 + 1] = (rgb565 >> 3) & 0xfc; /* green */
> -        palette[i * 3 + 2] = (rgb565 >> 8) & 0xf8; /* blue */
> +        palette[i * 3 + 0] = ((rgb565 >> 11) * 527 + 23) >> 6; /* r */
> +        palette[i * 3 + 1] = (((rgb565 >> 5) & 0x3f) * 259 + 33) >> 6; /* g */
> +        palette[i * 3 + 2] = ((rgb565 & 0x1f) * 527 + 23) >> 6; /* b */
>      }
>  }
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] sm501: Fix hardware cursor color conversion
  2018-06-18 21:38 [Qemu-devel] [PATCH] sm501: Fix hardware cursor color conversion Sebastian Bauer
  2018-06-18 23:56 ` David Gibson
@ 2018-06-19  5:26 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2018-06-19  5:26 UTC (permalink / raw)
  To: Sebastian Bauer; +Cc: qemu-devel, balaton

[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]

On Mon, Jun 18, 2018 at 11:38:16PM +0200, Sebastian Bauer wrote:
> According to the sm501 specs the hardware cursor colors are to be given in
> the rgb565 format, but the code currently interprets them as bgr565.
> 
> Therefore, the colors of the hardware cursors are wrong in the QEMU
> display, e.g., the standard mouse pointer of AmigaOS appears blue instead
> of red. This change fixes this issue by replacing the existing naive
> bgr565 => rgb888 conversion with a standard rgb565 => rgb888 one that also
> scales the color component values properly.
> 
> Signed-off-by: Sebastian Bauer <mail@sebastianbauer.info>

Applied to ppc-for-3.0, thanks.

> ---
>  hw/display/sm501.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 0488ab69d3..6c7f8483f3 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -668,9 +668,9 @@ static inline void get_hwc_palette(SM501State *state, int crt, uint8_t *palette)
>          } else {
>              rgb565 = color_reg & 0xFFFF;
>          }
> -        palette[i * 3 + 0] = (rgb565 << 3) & 0xf8; /* red */
> -        palette[i * 3 + 1] = (rgb565 >> 3) & 0xfc; /* green */
> -        palette[i * 3 + 2] = (rgb565 >> 8) & 0xf8; /* blue */
> +        palette[i * 3 + 0] = ((rgb565 >> 11) * 527 + 23) >> 6; /* r */
> +        palette[i * 3 + 1] = (((rgb565 >> 5) & 0x3f) * 259 + 33) >> 6; /* g */
> +        palette[i * 3 + 2] = ((rgb565 & 0x1f) * 527 + 23) >> 6; /* b */
>      }
>  }
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-19  5:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 21:38 [Qemu-devel] [PATCH] sm501: Fix hardware cursor color conversion Sebastian Bauer
2018-06-18 23:56 ` David Gibson
2018-06-19  5:26 ` David Gibson

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.