All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 10/23] console: rename vga_hw_*, add QemuConsole param
Date: Wed, 20 Mar 2013 10:43:32 +0100	[thread overview]
Message-ID: <1363772625-9182-11-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1363772625-9182-1-git-send-email-kraxel@redhat.com>

Add QemuConsole parameter to vga_hw_*, so the interface allows to update
non-active consoles (the actual code can't handle this yet, see next
patch).  Passing NULL is allowed and updates the active console, like
the functions do today.

While touching all vga_hw_* calls anyway rename that to the functions to
hardware-neutral graphics_hw_*

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/cirrus_vga.c      |    2 +-
 hw/qxl.c             |    2 +-
 hw/vga.c             |    2 +-
 hw/vga_int.h         |    8 ++++----
 include/ui/console.h |   22 +++++++++++-----------
 ui/console.c         |   49 ++++++++++++++++++++++++++++++-------------------
 ui/curses.c          |    4 ++--
 ui/gtk.c             |    2 +-
 ui/sdl.c             |   18 +++++++++---------
 ui/spice-display.c   |    2 +-
 ui/vnc.c             |   12 ++++++------
 11 files changed, 67 insertions(+), 56 deletions(-)

diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 7a4d634..8a0f74f 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -720,7 +720,7 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
     /* we have to flush all pending changes so that the copy
        is generated at the appropriate moment in time */
     if (notify)
-	vga_hw_update();
+        graphic_hw_update(s->vga.con);
 
     (*s->cirrus_rop) (s, s->vga.vram_ptr +
 		      (s->cirrus_blt_dstaddr & s->cirrus_addr_mask),
diff --git a/hw/qxl.c b/hw/qxl.c
index b66b414..1ceee7e 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1074,7 +1074,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
     qemu_spice_create_host_primary(&d->ssd);
     d->mode = QXL_MODE_VGA;
     vga_dirty_log_start(&d->vga);
-    vga_hw_update();
+    graphic_hw_update(d->vga.con);
 }
 
 static void qxl_exit_vga_mode(PCIQXLDevice *d)
diff --git a/hw/vga.c b/hw/vga.c
index 59bfb22..533b60e 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2452,6 +2452,6 @@ static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
     if (cswitch) {
         vga_invalidate_display(s);
     }
-    vga_hw_update();
+    graphic_hw_update(s->con);
     ppm_save(filename, surface, errp);
 }
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 260f7d6..1b8f670 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -152,10 +152,10 @@ typedef struct VGACommonState {
     uint32_t cursor_offset;
     unsigned int (*rgb_to_pixel)(unsigned int r,
                                  unsigned int g, unsigned b);
-    vga_hw_update_ptr update;
-    vga_hw_invalidate_ptr invalidate;
-    vga_hw_screen_dump_ptr screen_dump;
-    vga_hw_text_update_ptr text_update;
+    graphic_hw_update_ptr update;
+    graphic_hw_invalidate_ptr invalidate;
+    graphic_hw_screen_dump_ptr screen_dump;
+    graphic_hw_text_update_ptr text_update;
     bool full_update_text;
     bool full_update_gfx;
     /* hardware mouse cursor support */
diff --git a/include/ui/console.h b/include/ui/console.h
index 3725dae..9c585c0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -278,21 +278,21 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
     *dest = ch;
 }
 
-typedef void (*vga_hw_update_ptr)(void *);
-typedef void (*vga_hw_invalidate_ptr)(void *);
-typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
+typedef void (*graphic_hw_update_ptr)(void *);
+typedef void (*graphic_hw_invalidate_ptr)(void *);
+typedef void (*graphic_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
                                        Error **errp);
-typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
+typedef void (*graphic_hw_text_update_ptr)(void *, console_ch_t *);
 
-QemuConsole *graphic_console_init(vga_hw_update_ptr update,
-                                  vga_hw_invalidate_ptr invalidate,
-                                  vga_hw_screen_dump_ptr screen_dump,
-                                  vga_hw_text_update_ptr text_update,
+QemuConsole *graphic_console_init(graphic_hw_update_ptr update,
+                                  graphic_hw_invalidate_ptr invalidate,
+                                  graphic_hw_screen_dump_ptr screen_dump,
+                                  graphic_hw_text_update_ptr text_update,
                                   void *opaque);
 
-void vga_hw_update(void);
-void vga_hw_invalidate(void);
-void vga_hw_text_update(console_ch_t *chardata);
+void graphic_hw_update(QemuConsole *con);
+void graphic_hw_invalidate(QemuConsole *con);
+void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
 
 int is_graphic_console(void);
 int is_fixedsize_console(void);
diff --git a/ui/console.c b/ui/console.c
index 2c8fd91..23eed6f 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -118,10 +118,10 @@ struct QemuConsole {
     DisplayState *ds;
 
     /* Graphic console state.  */
-    vga_hw_update_ptr hw_update;
-    vga_hw_invalidate_ptr hw_invalidate;
-    vga_hw_screen_dump_ptr hw_screen_dump;
-    vga_hw_text_update_ptr hw_text_update;
+    graphic_hw_update_ptr hw_update;
+    graphic_hw_invalidate_ptr hw_invalidate;
+    graphic_hw_screen_dump_ptr hw_screen_dump;
+    graphic_hw_text_update_ptr hw_text_update;
     void *hw;
     int g_width, g_height;
 
@@ -165,16 +165,24 @@ static int nb_consoles = 0;
 
 static void text_console_do_init(CharDriverState *chr, DisplayState *ds);
 
-void vga_hw_update(void)
+void graphic_hw_update(QemuConsole *con)
 {
-    if (active_console && active_console->hw_update)
-        active_console->hw_update(active_console->hw);
+    if (!con) {
+        con = active_console;
+    }
+    if (con && con->hw_update) {
+        con->hw_update(con->hw);
+    }
 }
 
-void vga_hw_invalidate(void)
+void graphic_hw_invalidate(QemuConsole *con)
 {
-    if (active_console && active_console->hw_invalidate)
-        active_console->hw_invalidate(active_console->hw);
+    if (!con) {
+        con = active_console;
+    }
+    if (con && con->hw_invalidate) {
+        con->hw_invalidate(con->hw);
+    }
 }
 
 void qmp_screendump(const char *filename, Error **errp)
@@ -201,10 +209,13 @@ void qmp_screendump(const char *filename, Error **errp)
     }
 }
 
-void vga_hw_text_update(console_ch_t *chardata)
+void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
 {
-    if (active_console && active_console->hw_text_update)
-        active_console->hw_text_update(active_console->hw, chardata);
+    if (!con) {
+        con = active_console;
+    }
+    if (con && con->hw_text_update)
+        con->hw_text_update(con->hw, chardata);
 }
 
 static void vga_fill_rect(QemuConsole *con,
@@ -932,7 +943,7 @@ void console_select(unsigned int index)
             qemu_mod_timer(s->cursor_timer,
                    qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2);
         }
-        vga_hw_invalidate();
+        graphic_hw_invalidate(s);
     }
 }
 
@@ -1359,10 +1370,10 @@ DisplayState *init_displaystate(void)
     return display_state;
 }
 
-QemuConsole *graphic_console_init(vga_hw_update_ptr update,
-                                  vga_hw_invalidate_ptr invalidate,
-                                  vga_hw_screen_dump_ptr screen_dump,
-                                  vga_hw_text_update_ptr text_update,
+QemuConsole *graphic_console_init(graphic_hw_update_ptr update,
+                                  graphic_hw_invalidate_ptr invalidate,
+                                  graphic_hw_screen_dump_ptr screen_dump,
+                                  graphic_hw_text_update_ptr text_update,
                                   void *opaque)
 {
     int width = 640;
@@ -1407,7 +1418,7 @@ static void text_console_update_cursor(void *opaque)
     QemuConsole *s = opaque;
 
     s->cursor_visible_phase = !s->cursor_visible_phase;
-    vga_hw_invalidate();
+    graphic_hw_invalidate(s);
     qemu_mod_timer(s->cursor_timer,
                    qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2);
 }
diff --git a/ui/curses.c b/ui/curses.c
index ff82307..ed9e65c 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -166,11 +166,11 @@ static void curses_refresh(DisplayChangeListener *dcl)
         clear();
         refresh();
         curses_calc_pad();
-        vga_hw_invalidate();
+        graphic_hw_invalidate(NULL);
         invalidate = 0;
     }
 
-    vga_hw_text_update(screen);
+    graphic_hw_text_update(NULL, screen);
 
     nextchr = ERR;
     while (1) {
diff --git a/ui/gtk.c b/ui/gtk.c
index 305940d..bccab90 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -300,7 +300,7 @@ static void gd_update(DisplayChangeListener *dcl,
 
 static void gd_refresh(DisplayChangeListener *dcl)
 {
-    vga_hw_update();
+    graphic_hw_update(NULL);
 }
 
 static void gd_switch(DisplayChangeListener *dcl,
diff --git a/ui/sdl.c b/ui/sdl.c
index 8da0534..ede31dc 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -492,8 +492,8 @@ static void toggle_full_screen(void)
             sdl_grab_end();
         }
     }
-    vga_hw_invalidate();
-    vga_hw_update();
+    graphic_hw_invalidate(NULL);
+    graphic_hw_update(NULL);
 }
 
 static void handle_keydown(SDL_Event *ev)
@@ -522,8 +522,8 @@ static void handle_keydown(SDL_Event *ev)
             if (scaling_active) {
                 scaling_active = 0;
                 sdl_switch(dcl, NULL);
-                vga_hw_invalidate();
-                vga_hw_update();
+                graphic_hw_invalidate(NULL);
+                graphic_hw_update(NULL);
             }
             gui_keysym = 1;
             break;
@@ -556,8 +556,8 @@ static void handle_keydown(SDL_Event *ev)
                     surface_width(surface);
 
                 sdl_scale(width, height);
-                vga_hw_invalidate();
-                vga_hw_update();
+                graphic_hw_invalidate(NULL);
+                graphic_hw_update(NULL);
                 gui_keysym = 1;
             }
         default:
@@ -770,7 +770,7 @@ static void sdl_refresh(DisplayChangeListener *dcl)
         sdl_update_caption();
     }
 
-    vga_hw_update();
+    graphic_hw_update(NULL);
     SDL_EnableUNICODE(!is_graphic_console());
 
     while (SDL_PollEvent(ev)) {
@@ -802,8 +802,8 @@ static void sdl_refresh(DisplayChangeListener *dcl)
             break;
         case SDL_VIDEORESIZE:
             sdl_scale(ev->resize.w, ev->resize.h);
-            vga_hw_invalidate();
-            vga_hw_update();
+            graphic_hw_invalidate(NULL);
+            graphic_hw_update(NULL);
             break;
         default:
             break;
diff --git a/ui/spice-display.c b/ui/spice-display.c
index eaab19d..2c01674 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -414,7 +414,7 @@ void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
 void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
 {
     dprint(3, "%s:\n", __func__);
-    vga_hw_update();
+    graphic_hw_update(ssd->con);
 
     qemu_mutex_lock(&ssd->lock);
     if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) {
diff --git a/ui/vnc.c b/ui/vnc.c
index bbe1e0f..4c32af5 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1956,8 +1956,8 @@ static void set_pixel_format(VncState *vs,
 
     set_pixel_conversion(vs);
 
-    vga_hw_invalidate();
-    vga_hw_update();
+    graphic_hw_invalidate(NULL);
+    graphic_hw_update(NULL);
 }
 
 static void pixel_format_message (VncState *vs) {
@@ -2653,7 +2653,7 @@ static void vnc_refresh(void *opaque)
     VncState *vs, *vn;
     int has_dirty, rects = 0;
 
-    vga_hw_update();
+    graphic_hw_update(NULL);
 
     if (vnc_trylock_display(vd)) {
         vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
@@ -2692,7 +2692,7 @@ static void vnc_init_timer(VncDisplay *vd)
     vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
     if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) {
         vd->timer = qemu_new_timer_ms(rt_clock, vnc_refresh, vd);
-        vga_hw_update();
+        graphic_hw_update(NULL);
         vnc_refresh(vd);
     }
 }
@@ -2775,7 +2775,7 @@ void vnc_init_state(VncState *vs)
 
     QTAILQ_INSERT_HEAD(&vd->clients, vs, next);
 
-    vga_hw_update();
+    graphic_hw_update(NULL);
 
     vnc_write(vs, "RFB 003.008\n", 12);
     vnc_flush(vs);
@@ -2800,7 +2800,7 @@ static void vnc_listen_read(void *opaque, bool websocket)
     int csock;
 
     /* Catch-up */
-    vga_hw_update();
+    graphic_hw_update(NULL);
 #ifdef CONFIG_VNC_WS
     if (websocket) {
         csock = qemu_accept(vs->lwebsock, (struct sockaddr *)&addr, &addrlen);
-- 
1.7.9.7

  parent reply	other threads:[~2013-03-20  9:44 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20  9:43 [Qemu-devel] [PATCH v2 00/23] console: overhaul continued Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 01/23] exynos4210_fimd.c: fix display resize bug introduced after console revamp Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 02/23] hw/vmware_vga.c: fix screen " Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 03/23] pixman: add qemu_pixman_color() Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 04/23] pixman: render vgafont glyphs into pixman images Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 05/23] console: use pixman for fill+blit Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 06/23] console: use pixman for font rendering Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 07/23] console: switch color_table_rgb to pixman_color_t Gerd Hoffmann
     [not found]   ` <514A01CD.1020106@gmail.com>
2013-03-20 19:25     ` Igor Mitsyanko
2013-03-21  4:49   ` Søren Sandmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 08/23] console: add trace events Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 09/23] console: displaystate init revamp Gerd Hoffmann
     [not found]   ` <514A0478.3090908@gmail.com>
2013-03-20 19:27     ` Igor Mitsyanko
2013-03-21  7:42       ` Gerd Hoffmann
2013-03-20  9:43 ` Gerd Hoffmann [this message]
2013-03-20  9:43 ` [Qemu-devel] [PATCH 11/23] console: give each QemuConsole its own DisplaySurface Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 12/23] console: simplify screendump Gerd Hoffmann
2013-03-20  9:43   ` Gerd Hoffmann
     [not found]   ` <514A08C4.9040103@gmail.com>
2013-03-20 19:28     ` [Qemu-devel] " Igor Mitsyanko
2013-03-20  9:43 ` [Qemu-devel] [PATCH 13/23] console: zap g_width + g_height Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 14/23] console: move gui_update+gui_setup_refresh from vl.c into console.c Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 15/23] console: make DisplayState private to console.c Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 16/23] console: add GraphicHwOps Gerd Hoffmann
2013-03-20  9:43   ` Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 17/23] console: gui timer fixes Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 18/23] xen: re-enable refresh interval reporting for xenfb Gerd Hoffmann
2013-03-20  9:43   ` Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 19/23] console: add qemu_console_is_* Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 20/23] console: allow pinning displaychangelisteners to consoles Gerd Hoffmann
2013-03-20  9:43 ` [Qemu-devel] [PATCH 21/23] gtk: custom cursor support Gerd Hoffmann
2013-03-20 12:59   ` Anthony Liguori
2013-03-20 15:15     ` Gerd Hoffmann
2013-03-20 17:13       ` Anthony Liguori
2013-03-20  9:43 ` [Qemu-devel] [PATCH 22/23] gtk: show a window for each graphical QemuConsole Gerd Hoffmann
2013-03-20 13:04   ` Anthony Liguori
2013-03-20 15:22     ` Gerd Hoffmann
     [not found]   ` <514A0C75.4070802@gmail.com>
2013-03-20 19:29     ` Igor Mitsyanko
2013-03-20 20:06   ` Peter Maydell
2013-03-21  7:52     ` Gerd Hoffmann
2013-03-21  8:51       ` Gerd Hoffmann
2013-03-21 10:55         ` Peter Maydell
2013-03-21 14:43           ` Gerd Hoffmann
2013-03-21 18:25             ` Anthony Liguori
2013-03-22 11:19               ` Peter Maydell
2013-03-20  9:43 ` [Qemu-devel] [PATCH 23/23] qxl: register QemuConsole for secondary cards Gerd Hoffmann

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=1363772625-9182-11-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@us.ibm.com \
    --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 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.