qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH 3/9] hw/display/tc6393xb: Expand out macros in template header
Date: Mon, 15 Feb 2021 10:32:09 +0000	[thread overview]
Message-ID: <20210215103215.4944-4-peter.maydell@linaro.org> (raw)
In-Reply-To: <20210215103215.4944-1-peter.maydell@linaro.org>

Now the template header is included only for BITS==32, expand
out all the macros that depended on the BITS setting.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/display/tc6393xb_template.h | 35 ++++------------------------------
 1 file changed, 4 insertions(+), 31 deletions(-)

diff --git a/hw/display/tc6393xb_template.h b/hw/display/tc6393xb_template.h
index 78629c07f97..7789ffc4399 100644
--- a/hw/display/tc6393xb_template.h
+++ b/hw/display/tc6393xb_template.h
@@ -21,25 +21,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#if BITS == 8
-# define SET_PIXEL(addr, color)  (*(uint8_t *)addr = color)
-#elif BITS == 15 || BITS == 16
-# define SET_PIXEL(addr, color)  (*(uint16_t *)addr = color)
-#elif BITS == 24
-# define SET_PIXEL(addr, color)  \
-    do {                         \
-        addr[0] = color;         \
-        addr[1] = (color) >> 8;  \
-        addr[2] = (color) >> 16; \
-    } while (0)
-#elif BITS == 32
-# define SET_PIXEL(addr, color)  (*(uint32_t *)addr = color)
-#else
-# error unknown bit depth
-#endif
-
-
-static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s)
+static void tc6393xb_draw_graphic32(TC6393xbState *s)
 {
     DisplaySurface *surface = qemu_console_surface(s->con);
     int i;
@@ -49,24 +31,15 @@ static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s)
     data_buffer = s->vram_ptr;
     data_display = surface_data(surface);
     for(i = 0; i < s->scr_height; i++) {
-#if (BITS == 16)
-        memcpy(data_display, data_buffer, s->scr_width * 2);
-        data_buffer += s->scr_width;
-        data_display += surface_stride(surface);
-#else
         int j;
-        for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
+        for (j = 0; j < s->scr_width; j++, data_display += 4, data_buffer++) {
             uint16_t color = *data_buffer;
-            uint32_t dest_color = glue(rgb_to_pixel, BITS)(
+            uint32_t dest_color = rgb_to_pixel32(
                            ((color & 0xf800) * 0x108) >> 11,
                            ((color & 0x7e0) * 0x41) >> 9,
                            ((color & 0x1f) * 0x21) >> 2
                            );
-            SET_PIXEL(data_display, dest_color);
+            *(uint32_t *)data_display = dest_color;
         }
-#endif
     }
 }
-
-#undef BITS
-#undef SET_PIXEL
-- 
2.20.1



  parent reply	other threads:[~2021-02-15 10:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 10:32 [PATCH 0/9] arm: drop dead code for non-32-bit-RGB surfaces Peter Maydell
2021-02-15 10:32 ` [PATCH 1/9] hw/arm/musicpal: Remove " Peter Maydell
2021-02-15 10:32 ` [PATCH 2/9] hw/display/tc6393xb: Remove dead code for handling non-32bpp surfaces Peter Maydell
2021-02-15 10:32 ` Peter Maydell [this message]
2021-02-15 10:32 ` [PATCH 4/9] hw/display/tc6393xb: Inline tc6393xb_draw_graphic32() at its callsite Peter Maydell
2021-02-15 10:56   ` Philippe Mathieu-Daudé
2021-02-15 10:32 ` [PATCH 5/9] hw/display/omap_lcdc: Expand out macros in template header Peter Maydell
2021-02-15 10:32 ` [PATCH 6/9] hw/display/omap_lcdc: Drop broken bigendian ifdef Peter Maydell
2021-02-15 10:58   ` Philippe Mathieu-Daudé
2021-02-15 10:32 ` [PATCH 7/9] hw/display/omap_lcdc: Fix coding style issues in template header Peter Maydell
2021-02-15 10:58   ` Philippe Mathieu-Daudé
2021-02-15 10:32 ` [PATCH 8/9] hw/display/omap_lcdc: Inline template header into C file Peter Maydell
2021-02-15 10:59   ` Philippe Mathieu-Daudé
2021-02-15 10:32 ` [PATCH 9/9] hw/display/omap_lcdc: Delete unnecessary macro Peter Maydell
2021-02-15 10:59   ` Philippe Mathieu-Daudé
2021-02-16  0:45 ` [PATCH 0/9] arm: drop dead code for non-32-bit-RGB surfaces Richard Henderson

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=20210215103215.4944-4-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@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 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).