All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org, groug@kaod.org
Cc: David Gibson <david@gibson.dropbear.id.au>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: [PULL 02/20] hw/display/sm501: Expand out macros in template header
Date: Wed, 10 Mar 2021 15:09:44 +1100	[thread overview]
Message-ID: <20210310041002.333813-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20210310041002.333813-1-david@gibson.dropbear.id.au>

From: Peter Maydell <peter.maydell@linaro.org>

Now that we only include sm501_template.h for the DEPTH==32 case, we
can expand out the uses of the BPP, PIXEL_TYPE and PIXEL_NAME macros
in that header.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20210212180653.27588-3-peter.maydell@linaro.org>
Acked-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/display/sm501_template.h | 60 +++++++++++--------------------------
 1 file changed, 17 insertions(+), 43 deletions(-)

diff --git a/hw/display/sm501_template.h b/hw/display/sm501_template.h
index a60abad019..28537a05d9 100644
--- a/hw/display/sm501_template.h
+++ b/hw/display/sm501_template.h
@@ -22,28 +22,8 @@
  * THE SOFTWARE.
  */
 
-#if DEPTH == 8
-#define BPP 1
-#define PIXEL_TYPE uint8_t
-#elif DEPTH == 15 || DEPTH == 16
-#define BPP 2
-#define PIXEL_TYPE uint16_t
-#elif DEPTH == 32
-#define BPP 4
-#define PIXEL_TYPE uint32_t
-#else
-#error unsupport depth
-#endif
-
-#ifdef BGR_FORMAT
-#define PIXEL_NAME glue(DEPTH, bgr)
-#else
-#define PIXEL_NAME DEPTH
-#endif /* BGR_FORMAT */
-
-
-static void glue(draw_line8_, PIXEL_NAME)(
-                 uint8_t *d, const uint8_t *s, int width, const uint32_t *pal)
+static void draw_line8_32(uint8_t *d, const uint8_t *s, int width,
+                          const uint32_t *pal)
 {
     uint8_t v, r, g, b;
     do {
@@ -51,14 +31,14 @@ static void glue(draw_line8_, PIXEL_NAME)(
         r = (pal[v] >> 16) & 0xff;
         g = (pal[v] >>  8) & 0xff;
         b = (pal[v] >>  0) & 0xff;
-        *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
+        *(uint32_t *)d = rgb_to_pixel32(r, g, b);
         s++;
-        d += BPP;
+        d += 4;
     } while (--width != 0);
 }
 
-static void glue(draw_line16_, PIXEL_NAME)(
-                 uint8_t *d, const uint8_t *s, int width, const uint32_t *pal)
+static void draw_line16_32(uint8_t *d, const uint8_t *s, int width,
+                           const uint32_t *pal)
 {
     uint16_t rgb565;
     uint8_t r, g, b;
@@ -68,14 +48,14 @@ static void glue(draw_line16_, PIXEL_NAME)(
         r = (rgb565 >> 8) & 0xf8;
         g = (rgb565 >> 3) & 0xfc;
         b = (rgb565 << 3) & 0xf8;
-        *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
+        *(uint32_t *)d = rgb_to_pixel32(r, g, b);
         s += 2;
-        d += BPP;
+        d += 4;
     } while (--width != 0);
 }
 
-static void glue(draw_line32_, PIXEL_NAME)(
-                 uint8_t *d, const uint8_t *s, int width, const uint32_t *pal)
+static void draw_line32_32(uint8_t *d, const uint8_t *s, int width,
+                           const uint32_t *pal)
 {
     uint8_t r, g, b;
 
@@ -83,17 +63,17 @@ static void glue(draw_line32_, PIXEL_NAME)(
         r = s[2];
         g = s[1];
         b = s[0];
-        *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
+        *(uint32_t *)d = rgb_to_pixel32(r, g, b);
         s += 4;
-        d += BPP;
+        d += 4;
     } while (--width != 0);
 }
 
 /**
  * Draw hardware cursor image on the given line.
  */
-static void glue(draw_hwc_line_, PIXEL_NAME)(uint8_t *d, const uint8_t *s,
-                 int width, const uint8_t *palette, int c_x, int c_y)
+static void draw_hwc_line_32(uint8_t *d, const uint8_t *s, int width,
+                             const uint8_t *palette, int c_x, int c_y)
 {
     int i;
     uint8_t r, g, b, v, bitset = 0;
@@ -101,7 +81,7 @@ static void glue(draw_hwc_line_, PIXEL_NAME)(uint8_t *d, const uint8_t *s,
     /* get cursor position */
     assert(0 <= c_y && c_y < SM501_HWC_HEIGHT);
     s += SM501_HWC_WIDTH * c_y / 4;  /* 4 pixels per byte */
-    d += c_x * BPP;
+    d += c_x * 4;
 
     for (i = 0; i < SM501_HWC_WIDTH && c_x + i < width; i++) {
         /* get pixel value */
@@ -118,14 +98,8 @@ static void glue(draw_hwc_line_, PIXEL_NAME)(uint8_t *d, const uint8_t *s,
             r = palette[v * 3 + 0];
             g = palette[v * 3 + 1];
             b = palette[v * 3 + 2];
-            *(PIXEL_TYPE *)d = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
+            *(uint32_t *)d = rgb_to_pixel32(r, g, b);
         }
-        d += BPP;
+        d += 4;
     }
 }
-
-#undef DEPTH
-#undef BPP
-#undef PIXEL_TYPE
-#undef PIXEL_NAME
-#undef BGR_FORMAT
-- 
2.29.2



  parent reply	other threads:[~2021-03-10  4:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10  4:09 [PULL 00/20] ppc-for-6.0 queue 20210310 David Gibson
2021-03-10  4:09 ` [PULL 01/20] hw/display/sm501: Remove dead code for non-32-bit RGB surfaces David Gibson
2021-03-10  4:09 ` David Gibson [this message]
2021-03-10  4:09 ` [PULL 03/20] hw/display/sm501: Inline template header into C file David Gibson
2021-03-10  4:09 ` [PULL 04/20] spapr_drc.c: do not call spapr_drc_detach() in drc_isolate_logical() David Gibson
2021-03-10  4:09 ` [PULL 05/20] pseries: Update SLOF firmware image David Gibson
2021-03-10  4:09 ` [PULL 06/20] spapr_drc.c: use spapr_drc_release() in isolate_physical/set_unusable David Gibson
2021-03-10  4:09 ` [PULL 07/20] spapr: rename spapr_drc_detach() to spapr_drc_unplug_request() David Gibson
2021-03-10  4:09 ` [PULL 08/20] docs/system: Extend PPC section David Gibson
2021-03-10  4:09 ` [PULL 09/20] target/ppc: Fix bcdsub. emulation when result overflows David Gibson
2021-03-10  4:09 ` [PULL 10/20] spapr_drc.c: introduce unplug_timeout_timer David Gibson
2021-03-10  4:09 ` [PULL 11/20] spapr_drc.c: add hotunplug timeout for CPUs David Gibson
2021-03-10  4:09 ` [PULL 12/20] spapr_drc.c: use DRC reconfiguration to cleanup DIMM unplug state David Gibson
2021-03-10  4:09 ` [PULL 13/20] hw/net: fsl_etsec: Fix build error when HEX_DUMP is on David Gibson
2021-03-10  4:09 ` [PULL 14/20] hw/ppc: e500: Add missing <ranges> in the eTSEC node David Gibson
2021-03-10  4:09 ` [PULL 15/20] spapr.c: add 'unplug already in progress' message for PHB unplug David Gibson
2021-03-10  4:09 ` [PULL 16/20] spapr_pci.c: add 'unplug already in progress' message for PCI unplug David Gibson
2021-03-10  4:09 ` [PULL 17/20] qemu_timer.c: add timer_deadline_ms() helper David Gibson
2021-03-10  4:10 ` [PULL 18/20] target/ppc: fix icount support on Book-e vms accessing SPRs David Gibson
2021-03-10  4:10 ` [PULL 19/20] spapr.c: remove duplicated assert in spapr_memory_unplug_request() David Gibson
2021-03-10  4:10 ` [PULL 20/20] spapr.c: send QAPI event when memory hotunplug fails David Gibson
2021-03-10  4:43 ` [PULL 00/20] ppc-for-6.0 queue 20210310 Bin Meng
2021-03-10  6:00   ` David Gibson
2021-03-11  1:26     ` Bin Meng
2021-03-10 14:09 ` Ivan Warren
2021-03-11  1:47   ` David Gibson
2021-03-11  3:22     ` Ivan Warren
2021-03-11  4:56       ` David Gibson
2021-03-11 13:31         ` Richard Henderson
2021-03-11 15:54           ` Greg Kurz
2021-03-11 18:02             ` Greg Kurz
2021-03-12 13:53 ` Peter Maydell

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=20210310041002.333813-3-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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.