提交 1dbfa005 编写于 作者: G Gerd Hoffmann

console: rename vga_hw_*, add QemuConsole param

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: NGerd Hoffmann <kraxel@redhat.com>
上级 64840c66
...@@ -720,7 +720,7 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h) ...@@ -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 /* we have to flush all pending changes so that the copy
is generated at the appropriate moment in time */ is generated at the appropriate moment in time */
if (notify) if (notify)
vga_hw_update(); graphic_hw_update(s->vga.con);
(*s->cirrus_rop) (s, s->vga.vram_ptr + (*s->cirrus_rop) (s, s->vga.vram_ptr +
(s->cirrus_blt_dstaddr & s->cirrus_addr_mask), (s->cirrus_blt_dstaddr & s->cirrus_addr_mask),
......
...@@ -1074,7 +1074,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d) ...@@ -1074,7 +1074,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
qemu_spice_create_host_primary(&d->ssd); qemu_spice_create_host_primary(&d->ssd);
d->mode = QXL_MODE_VGA; d->mode = QXL_MODE_VGA;
vga_dirty_log_start(&d->vga); vga_dirty_log_start(&d->vga);
vga_hw_update(); graphic_hw_update(d->vga.con);
} }
static void qxl_exit_vga_mode(PCIQXLDevice *d) static void qxl_exit_vga_mode(PCIQXLDevice *d)
......
...@@ -2452,6 +2452,6 @@ static void vga_screen_dump(void *opaque, const char *filename, bool cswitch, ...@@ -2452,6 +2452,6 @@ static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
if (cswitch) { if (cswitch) {
vga_invalidate_display(s); vga_invalidate_display(s);
} }
vga_hw_update(); graphic_hw_update(s->con);
ppm_save(filename, surface, errp); ppm_save(filename, surface, errp);
} }
...@@ -152,10 +152,10 @@ typedef struct VGACommonState { ...@@ -152,10 +152,10 @@ typedef struct VGACommonState {
uint32_t cursor_offset; uint32_t cursor_offset;
unsigned int (*rgb_to_pixel)(unsigned int r, unsigned int (*rgb_to_pixel)(unsigned int r,
unsigned int g, unsigned b); unsigned int g, unsigned b);
vga_hw_update_ptr update; graphic_hw_update_ptr update;
vga_hw_invalidate_ptr invalidate; graphic_hw_invalidate_ptr invalidate;
vga_hw_screen_dump_ptr screen_dump; graphic_hw_screen_dump_ptr screen_dump;
vga_hw_text_update_ptr text_update; graphic_hw_text_update_ptr text_update;
bool full_update_text; bool full_update_text;
bool full_update_gfx; bool full_update_gfx;
/* hardware mouse cursor support */ /* hardware mouse cursor support */
......
...@@ -278,21 +278,21 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch) ...@@ -278,21 +278,21 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
*dest = ch; *dest = ch;
} }
typedef void (*vga_hw_update_ptr)(void *); typedef void (*graphic_hw_update_ptr)(void *);
typedef void (*vga_hw_invalidate_ptr)(void *); typedef void (*graphic_hw_invalidate_ptr)(void *);
typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch, typedef void (*graphic_hw_screen_dump_ptr)(void *, const char *, bool cswitch,
Error **errp); 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, QemuConsole *graphic_console_init(graphic_hw_update_ptr update,
vga_hw_invalidate_ptr invalidate, graphic_hw_invalidate_ptr invalidate,
vga_hw_screen_dump_ptr screen_dump, graphic_hw_screen_dump_ptr screen_dump,
vga_hw_text_update_ptr text_update, graphic_hw_text_update_ptr text_update,
void *opaque); void *opaque);
void vga_hw_update(void); void graphic_hw_update(QemuConsole *con);
void vga_hw_invalidate(void); void graphic_hw_invalidate(QemuConsole *con);
void vga_hw_text_update(console_ch_t *chardata); void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
int is_graphic_console(void); int is_graphic_console(void);
int is_fixedsize_console(void); int is_fixedsize_console(void);
......
...@@ -118,10 +118,10 @@ struct QemuConsole { ...@@ -118,10 +118,10 @@ struct QemuConsole {
DisplayState *ds; DisplayState *ds;
/* Graphic console state. */ /* Graphic console state. */
vga_hw_update_ptr hw_update; graphic_hw_update_ptr hw_update;
vga_hw_invalidate_ptr hw_invalidate; graphic_hw_invalidate_ptr hw_invalidate;
vga_hw_screen_dump_ptr hw_screen_dump; graphic_hw_screen_dump_ptr hw_screen_dump;
vga_hw_text_update_ptr hw_text_update; graphic_hw_text_update_ptr hw_text_update;
void *hw; void *hw;
int g_width, g_height; int g_width, g_height;
...@@ -165,16 +165,24 @@ static int nb_consoles = 0; ...@@ -165,16 +165,24 @@ static int nb_consoles = 0;
static void text_console_do_init(CharDriverState *chr, DisplayState *ds); 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) if (!con) {
active_console->hw_update(active_console->hw); 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) if (!con) {
active_console->hw_invalidate(active_console->hw); con = active_console;
}
if (con && con->hw_invalidate) {
con->hw_invalidate(con->hw);
}
} }
void qmp_screendump(const char *filename, Error **errp) void qmp_screendump(const char *filename, Error **errp)
...@@ -201,10 +209,13 @@ 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) if (!con) {
active_console->hw_text_update(active_console->hw, chardata); con = active_console;
}
if (con && con->hw_text_update)
con->hw_text_update(con->hw, chardata);
} }
static void vga_fill_rect(QemuConsole *con, static void vga_fill_rect(QemuConsole *con,
...@@ -932,7 +943,7 @@ void console_select(unsigned int index) ...@@ -932,7 +943,7 @@ void console_select(unsigned int index)
qemu_mod_timer(s->cursor_timer, qemu_mod_timer(s->cursor_timer,
qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2); 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) ...@@ -1359,10 +1370,10 @@ DisplayState *init_displaystate(void)
return display_state; return display_state;
} }
QemuConsole *graphic_console_init(vga_hw_update_ptr update, QemuConsole *graphic_console_init(graphic_hw_update_ptr update,
vga_hw_invalidate_ptr invalidate, graphic_hw_invalidate_ptr invalidate,
vga_hw_screen_dump_ptr screen_dump, graphic_hw_screen_dump_ptr screen_dump,
vga_hw_text_update_ptr text_update, graphic_hw_text_update_ptr text_update,
void *opaque) void *opaque)
{ {
int width = 640; int width = 640;
...@@ -1407,7 +1418,7 @@ static void text_console_update_cursor(void *opaque) ...@@ -1407,7 +1418,7 @@ static void text_console_update_cursor(void *opaque)
QemuConsole *s = opaque; QemuConsole *s = opaque;
s->cursor_visible_phase = !s->cursor_visible_phase; s->cursor_visible_phase = !s->cursor_visible_phase;
vga_hw_invalidate(); graphic_hw_invalidate(s);
qemu_mod_timer(s->cursor_timer, qemu_mod_timer(s->cursor_timer,
qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2); qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2);
} }
......
...@@ -166,11 +166,11 @@ static void curses_refresh(DisplayChangeListener *dcl) ...@@ -166,11 +166,11 @@ static void curses_refresh(DisplayChangeListener *dcl)
clear(); clear();
refresh(); refresh();
curses_calc_pad(); curses_calc_pad();
vga_hw_invalidate(); graphic_hw_invalidate(NULL);
invalidate = 0; invalidate = 0;
} }
vga_hw_text_update(screen); graphic_hw_text_update(NULL, screen);
nextchr = ERR; nextchr = ERR;
while (1) { while (1) {
......
...@@ -327,7 +327,7 @@ static void gd_update(DisplayChangeListener *dcl, ...@@ -327,7 +327,7 @@ static void gd_update(DisplayChangeListener *dcl,
static void gd_refresh(DisplayChangeListener *dcl) static void gd_refresh(DisplayChangeListener *dcl)
{ {
vga_hw_update(); graphic_hw_update(NULL);
} }
static void gd_switch(DisplayChangeListener *dcl, static void gd_switch(DisplayChangeListener *dcl,
......
...@@ -492,8 +492,8 @@ static void toggle_full_screen(void) ...@@ -492,8 +492,8 @@ static void toggle_full_screen(void)
sdl_grab_end(); sdl_grab_end();
} }
} }
vga_hw_invalidate(); graphic_hw_invalidate(NULL);
vga_hw_update(); graphic_hw_update(NULL);
} }
static void handle_keydown(SDL_Event *ev) static void handle_keydown(SDL_Event *ev)
...@@ -522,8 +522,8 @@ static void handle_keydown(SDL_Event *ev) ...@@ -522,8 +522,8 @@ static void handle_keydown(SDL_Event *ev)
if (scaling_active) { if (scaling_active) {
scaling_active = 0; scaling_active = 0;
sdl_switch(dcl, NULL); sdl_switch(dcl, NULL);
vga_hw_invalidate(); graphic_hw_invalidate(NULL);
vga_hw_update(); graphic_hw_update(NULL);
} }
gui_keysym = 1; gui_keysym = 1;
break; break;
...@@ -556,8 +556,8 @@ static void handle_keydown(SDL_Event *ev) ...@@ -556,8 +556,8 @@ static void handle_keydown(SDL_Event *ev)
surface_width(surface); surface_width(surface);
sdl_scale(width, height); sdl_scale(width, height);
vga_hw_invalidate(); graphic_hw_invalidate(NULL);
vga_hw_update(); graphic_hw_update(NULL);
gui_keysym = 1; gui_keysym = 1;
} }
default: default:
...@@ -770,7 +770,7 @@ static void sdl_refresh(DisplayChangeListener *dcl) ...@@ -770,7 +770,7 @@ static void sdl_refresh(DisplayChangeListener *dcl)
sdl_update_caption(); sdl_update_caption();
} }
vga_hw_update(); graphic_hw_update(NULL);
SDL_EnableUNICODE(!is_graphic_console()); SDL_EnableUNICODE(!is_graphic_console());
while (SDL_PollEvent(ev)) { while (SDL_PollEvent(ev)) {
...@@ -802,8 +802,8 @@ static void sdl_refresh(DisplayChangeListener *dcl) ...@@ -802,8 +802,8 @@ static void sdl_refresh(DisplayChangeListener *dcl)
break; break;
case SDL_VIDEORESIZE: case SDL_VIDEORESIZE:
sdl_scale(ev->resize.w, ev->resize.h); sdl_scale(ev->resize.w, ev->resize.h);
vga_hw_invalidate(); graphic_hw_invalidate(NULL);
vga_hw_update(); graphic_hw_update(NULL);
break; break;
default: default:
break; break;
......
...@@ -414,7 +414,7 @@ void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd) ...@@ -414,7 +414,7 @@ void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd) void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
{ {
dprint(3, "%s:\n", __func__); dprint(3, "%s:\n", __func__);
vga_hw_update(); graphic_hw_update(ssd->con);
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) { if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) {
......
...@@ -1956,8 +1956,8 @@ static void set_pixel_format(VncState *vs, ...@@ -1956,8 +1956,8 @@ static void set_pixel_format(VncState *vs,
set_pixel_conversion(vs); set_pixel_conversion(vs);
vga_hw_invalidate(); graphic_hw_invalidate(NULL);
vga_hw_update(); graphic_hw_update(NULL);
} }
static void pixel_format_message (VncState *vs) { static void pixel_format_message (VncState *vs) {
...@@ -2653,7 +2653,7 @@ static void vnc_refresh(void *opaque) ...@@ -2653,7 +2653,7 @@ static void vnc_refresh(void *opaque)
VncState *vs, *vn; VncState *vs, *vn;
int has_dirty, rects = 0; int has_dirty, rects = 0;
vga_hw_update(); graphic_hw_update(NULL);
if (vnc_trylock_display(vd)) { if (vnc_trylock_display(vd)) {
vd->timer_interval = VNC_REFRESH_INTERVAL_BASE; vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
...@@ -2692,7 +2692,7 @@ static void vnc_init_timer(VncDisplay *vd) ...@@ -2692,7 +2692,7 @@ static void vnc_init_timer(VncDisplay *vd)
vd->timer_interval = VNC_REFRESH_INTERVAL_BASE; vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) { if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) {
vd->timer = qemu_new_timer_ms(rt_clock, vnc_refresh, vd); vd->timer = qemu_new_timer_ms(rt_clock, vnc_refresh, vd);
vga_hw_update(); graphic_hw_update(NULL);
vnc_refresh(vd); vnc_refresh(vd);
} }
} }
...@@ -2775,7 +2775,7 @@ void vnc_init_state(VncState *vs) ...@@ -2775,7 +2775,7 @@ void vnc_init_state(VncState *vs)
QTAILQ_INSERT_HEAD(&vd->clients, vs, next); QTAILQ_INSERT_HEAD(&vd->clients, vs, next);
vga_hw_update(); graphic_hw_update(NULL);
vnc_write(vs, "RFB 003.008\n", 12); vnc_write(vs, "RFB 003.008\n", 12);
vnc_flush(vs); vnc_flush(vs);
...@@ -2800,7 +2800,7 @@ static void vnc_listen_read(void *opaque, bool websocket) ...@@ -2800,7 +2800,7 @@ static void vnc_listen_read(void *opaque, bool websocket)
int csock; int csock;
/* Catch-up */ /* Catch-up */
vga_hw_update(); graphic_hw_update(NULL);
#ifdef CONFIG_VNC_WS #ifdef CONFIG_VNC_WS
if (websocket) { if (websocket) {
csock = qemu_accept(vs->lwebsock, (struct sockaddr *)&addr, &addrlen); csock = qemu_accept(vs->lwebsock, (struct sockaddr *)&addr, &addrlen);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册