All of lore.kernel.org
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: Magnus Damm <magnus.damm@gmail.com>,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH v2 10/14] sm501: Add support for panel layer
Date: Sat, 25 Feb 2017 20:25:11 +0100	[thread overview]
Message-ID: <ae7dc986dd60d4a4baef3d4aef31e10b281e85a7.1488068248.git.balaton@eik.bme.hu> (raw)
In-Reply-To: <cover.1488068248.git.balaton@eik.bme.hu>

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---

v2: Split off renaming a variable to separate clean up patch

 hw/display/sm501.c | 63 +++++++++++++++++++++++++++---------------------------
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 9c5ded3..caa7e5c 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -2,6 +2,7 @@
  * QEMU SM501 Device
  *
  * Copyright (c) 2008 Shin-ichiro KAWASAKI
+ * Copyright (c) 2016 BALATON Zoltan
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -41,8 +42,11 @@
  *   - Minimum implementation for Linux console : mmio regs and CRT layer.
  *   - 2D graphics acceleration partially supported : only fill rectangle.
  *
- * TODO:
+ * Status: 2016/12/04
+ *   - Misc fixes: endianness, hardware cursor
  *   - Panel support
+ *
+ * TODO:
  *   - Touch panel support
  *   - USB support
  *   - UART support
@@ -1300,18 +1304,16 @@ static inline int get_depth_index(DisplaySurface *surface)
     }
 }
 
-static void sm501_draw_crt(SM501State *s)
+static void sm501_update_display(void *opaque)
 {
+    SM501State *s = (SM501State *)opaque;
     DisplaySurface *surface = qemu_console_surface(s->con);
     int y, c_x, c_y;
-    uint8_t *hwc_src, *src = s->local_mem;
-    int width = get_width(s, 1);
-    int height = get_height(s, 1);
-    int src_bpp = get_bpp(s, 1);
+    int crt = (s->dc_crt_control & SM501_DC_CRT_CONTROL_SEL) ? 1 : 0;
+    int width = get_width(s, crt);
+    int height = get_height(s, crt);
+    int src_bpp = get_bpp(s, crt);
     int dst_bpp = surface_bytes_per_pixel(surface);
-    uint32_t *palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE -
-                                                   SM501_DC_PANEL_PALETTE];
-    uint8_t hwc_palette[3 * 3];
     int dst_depth_index = get_depth_index(surface);
     draw_line_func *draw_line = NULL;
     draw_hwc_line_func *draw_hwc_line = NULL;
@@ -1319,7 +1321,19 @@ static void sm501_draw_crt(SM501State *s)
     int y_start = -1;
     ram_addr_t page_min = ~0l;
     ram_addr_t page_max = 0l;
-    ram_addr_t offset = 0;
+    ram_addr_t offset;
+    uint32_t *palette;
+    uint8_t hwc_palette[3 * 3];
+    uint8_t *hwc_src;
+
+    if (!((crt ? s->dc_crt_control : s->dc_panel_control)
+          & SM501_DC_CRT_CONTROL_ENABLE)) {
+        return;
+    }
+
+    palette = (uint32_t *)(crt ? &s->dc_palette[SM501_DC_CRT_PALETTE -
+                                                SM501_DC_PANEL_PALETTE]
+                               : &s->dc_palette[0]);
 
     /* choose draw_line function */
     switch (src_bpp) {
@@ -1333,20 +1347,19 @@ static void sm501_draw_crt(SM501State *s)
         draw_line = draw_line32_funcs[dst_depth_index];
         break;
     default:
-        printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n",
-               s->dc_crt_control);
+        printf("sm501 update display : invalid control register value.\n");
         abort();
         break;
     }
 
     /* set up to draw hardware cursor */
-    if (is_hwc_enabled(s, 1)) {
+    if (is_hwc_enabled(s, crt)) {
         /* choose cursor draw line function */
         draw_hwc_line = draw_hwc_line_funcs[dst_depth_index];
-        hwc_src = get_hwc_address(s, 1);
-        c_x = get_hwc_x(s, 1);
-        c_y = get_hwc_y(s, 1);
-        get_hwc_palette(s, 1, hwc_palette);
+        hwc_src = get_hwc_address(s, crt);
+        c_x = get_hwc_x(s, crt);
+        c_y = get_hwc_y(s, crt);
+        get_hwc_palette(s, crt, hwc_palette);
     }
 
     /* adjust console size */
@@ -1360,7 +1373,7 @@ static void sm501_draw_crt(SM501State *s)
 
     /* draw each line according to conditions */
     memory_region_sync_dirty_bitmap(&s->local_mem_region);
-    for (y = 0; y < height; y++) {
+    for (y = 0, offset = 0; y < height; y++, offset += width * src_bpp) {
         int update, update_hwc;
         ram_addr_t page0 = offset;
         ram_addr_t page1 = offset + width * src_bpp - 1;
@@ -1378,7 +1391,7 @@ static void sm501_draw_crt(SM501State *s)
             d +=  y * width * dst_bpp;
 
             /* draw graphics layer */
-            draw_line(d, src, width, palette);
+            draw_line(d, s->local_mem + offset, width, palette);
 
             /* draw hardware cursor */
             if (update_hwc) {
@@ -1401,9 +1414,6 @@ static void sm501_draw_crt(SM501State *s)
                 y_start = -1;
             }
         }
-
-        src += width * src_bpp;
-        offset += width * src_bpp;
     }
 
     /* complete flush to display */
@@ -1419,15 +1429,6 @@ static void sm501_draw_crt(SM501State *s)
     }
 }
 
-static void sm501_update_display(void *opaque)
-{
-    SM501State *s = (SM501State *)opaque;
-
-    if (s->dc_crt_control & SM501_DC_CRT_CONTROL_ENABLE) {
-        sm501_draw_crt(s);
-    }
-}
-
 static const GraphicHwOps sm501_ops = {
     .gfx_update  = sm501_update_display,
 };
-- 
2.7.4

  parent reply	other threads:[~2017-02-26  0:31 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-26  0:17 [Qemu-devel] [PATCH v2 00/14] Improvements for SM501 display controller emulation BALATON Zoltan
2017-02-25 18:23 ` [Qemu-devel] [PATCH v2 04/14] sm501: Get rid of base address in draw_hwc_line BALATON Zoltan
2017-03-02 19:14   ` Peter Maydell
2017-03-02 20:06     ` BALATON Zoltan
2017-02-25 18:31 ` [Qemu-devel] [PATCH v2 05/14] sm501: Add emulation of chip connected via PCI BALATON Zoltan
2017-03-02 19:22   ` Peter Maydell
2017-03-02 20:13     ` BALATON Zoltan
2017-03-02 20:43       ` Peter Maydell
2017-03-03  1:53         ` BALATON Zoltan
2017-02-25 18:46 ` [Qemu-devel] [PATCH v2 07/14] sm501: Fix device endianness BALATON Zoltan
2017-03-02 21:04   ` Peter Maydell
2017-03-03  2:15     ` BALATON Zoltan
2017-03-03 18:49       ` Peter Maydell
2017-03-03 20:11         ` BALATON Zoltan
2017-03-04 12:40           ` Peter Maydell
2017-03-04 22:58             ` BALATON Zoltan
2017-03-06 10:32               ` Peter Maydell
2017-03-06 18:46                 ` BALATON Zoltan
2017-02-25 19:19 ` [Qemu-devel] [PATCH v2 09/14] sm501: Misc clean ups BALATON Zoltan
2017-03-02 19:35   ` Peter Maydell
2017-02-25 19:25 ` BALATON Zoltan [this message]
2017-03-02 19:44   ` [Qemu-devel] [PATCH v2 10/14] sm501: Add support for panel layer Peter Maydell
2017-03-02 20:15     ` BALATON Zoltan
2017-03-02 20:46       ` Peter Maydell
2017-02-25 21:47 ` [Qemu-devel] [PATCH v2 12/14] sm501: Implement reading 2D engine registers BALATON Zoltan
2017-03-02 20:00   ` Peter Maydell
2017-03-02 20:22     ` BALATON Zoltan
2017-03-02 20:50       ` Peter Maydell
2017-02-25 23:53 ` [Qemu-devel] [PATCH v2 13/14] sm501: Add reset function and vmstate descriptor BALATON Zoltan
2017-03-02 19:51   ` Peter Maydell
2017-03-02 20:18     ` BALATON Zoltan
2017-03-02 20:49       ` Peter Maydell
2017-03-02 20:55         ` BALATON Zoltan
2017-03-02 21:05           ` BALATON Zoltan
2017-03-02 21:06           ` Peter Maydell
2017-02-26  0:31 ` [Qemu-devel] [PATCH v2 02/14] sm501: Use defines instead of constants where available BALATON Zoltan
2017-03-02 18:53   ` Peter Maydell
2017-03-02 19:03     ` Peter Maydell
2017-03-02 19:58       ` BALATON Zoltan
2017-02-26  0:31 ` [Qemu-devel] [PATCH v2 14/14] ppc: Add SM501 device in config for ppc and ppcemb targets BALATON Zoltan
2017-02-26  0:31 ` [Qemu-devel] [PATCH v2 06/14] sm501: Add missing arbitration control register BALATON Zoltan
2017-03-02 20:08   ` Peter Maydell
2017-03-02 20:09     ` Peter Maydell
2017-02-26  0:31 ` [Qemu-devel] [PATCH v2 11/14] sm501: Add some more missing registers BALATON Zoltan
2017-03-02 19:59   ` Peter Maydell
2017-03-02 20:21     ` BALATON Zoltan
2017-02-26  0:31 ` [Qemu-devel] [PATCH v2 03/14] sm501: QOMify BALATON Zoltan
2017-03-02 19:55   ` Peter Maydell
2017-02-26  0:31 ` [Qemu-devel] [PATCH v2 08/14] sm501: Fix hardware cursor BALATON Zoltan
2017-03-02 19:35   ` Peter Maydell
2017-02-26  0:31 ` [Qemu-devel] [PATCH v2 01/14] sm501: Fixed code style and a few typos in comments BALATON Zoltan
2017-02-27 18:11 ` [Qemu-devel] [PATCH v2 00/14] Improvements for SM501 display controller emulation Michael Tokarev
2017-02-27 19:03   ` 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=ae7dc986dd60d4a4baef3d4aef31e10b281e85a7.1488068248.git.balaton@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=aurelien@aurel32.net \
    --cc=magnus.damm@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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.