* [PATCH v3 0/3] virtio-gpu: Respect UI refresh rate for EDID @ 2022-02-26 11:55 ` Akihiko Odaki 0 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: qemu Developers, xen-devel, Gerd Hoffmann, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant, Akihiko Odaki Let virtio-gpu be aware of the refresh rate. The EDID change is delivered with display hotplugging, which should not happen too frequently. Because of that, this moves the refresh rate to QemuUIInfo, whose change delivery is throttled. The delivery throttling also affects xenfb and this change does not maintain a seperate code path to avoid the throttling because the difference is little if it xists. Usually the refresh rate of display does not change frequently and most guests are not prepared for that anyway. v3: Rebased to the latest QEMU. Akihiko Odaki (3): ui/console: Do not return a value with ui_info ui: Deliver refresh rate via QemuUIInfo virtio-gpu: Respect UI refresh rate for EDID hw/display/virtio-gpu-base.c | 7 +++--- hw/display/virtio-gpu.c | 1 + hw/display/virtio-vga.c | 5 ++-- hw/display/xenfb.c | 14 ++++++++--- hw/vfio/display.c | 8 +++--- include/hw/virtio/virtio-gpu.h | 1 + include/ui/console.h | 4 +-- include/ui/gtk.h | 2 +- ui/console.c | 6 ----- ui/gtk-egl.c | 4 +-- ui/gtk-gl-area.c | 3 +-- ui/gtk.c | 45 ++++++++++++++++++++-------------- 12 files changed, 54 insertions(+), 46 deletions(-) -- 2.32.0 (Apple Git-132) ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 0/3] virtio-gpu: Respect UI refresh rate for EDID @ 2022-02-26 11:55 ` Akihiko Odaki 0 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: Stefano Stabellini, Michael S . Tsirkin, Paul Durrant, qemu Developers, Gerd Hoffmann, Akihiko Odaki, Anthony Perard, xen-devel Let virtio-gpu be aware of the refresh rate. The EDID change is delivered with display hotplugging, which should not happen too frequently. Because of that, this moves the refresh rate to QemuUIInfo, whose change delivery is throttled. The delivery throttling also affects xenfb and this change does not maintain a seperate code path to avoid the throttling because the difference is little if it xists. Usually the refresh rate of display does not change frequently and most guests are not prepared for that anyway. v3: Rebased to the latest QEMU. Akihiko Odaki (3): ui/console: Do not return a value with ui_info ui: Deliver refresh rate via QemuUIInfo virtio-gpu: Respect UI refresh rate for EDID hw/display/virtio-gpu-base.c | 7 +++--- hw/display/virtio-gpu.c | 1 + hw/display/virtio-vga.c | 5 ++-- hw/display/xenfb.c | 14 ++++++++--- hw/vfio/display.c | 8 +++--- include/hw/virtio/virtio-gpu.h | 1 + include/ui/console.h | 4 +-- include/ui/gtk.h | 2 +- ui/console.c | 6 ----- ui/gtk-egl.c | 4 +-- ui/gtk-gl-area.c | 3 +-- ui/gtk.c | 45 ++++++++++++++++++++-------------- 12 files changed, 54 insertions(+), 46 deletions(-) -- 2.32.0 (Apple Git-132) ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 1/3] ui/console: Do not return a value with ui_info 2022-02-26 11:55 ` Akihiko Odaki @ 2022-02-26 11:55 ` Akihiko Odaki -1 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: qemu Developers, xen-devel, Gerd Hoffmann, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant, Akihiko Odaki The returned value is not used and misleading. Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> --- hw/display/virtio-gpu-base.c | 6 +++--- hw/display/virtio-vga.c | 5 ++--- hw/vfio/display.c | 8 +++----- include/ui/console.h | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index fff0fb4a828..c73b3aa06b8 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -69,12 +69,12 @@ static void virtio_gpu_notify_event(VirtIOGPUBase *g, uint32_t event_type) virtio_notify_config(&g->parent_obj); } -static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) +static void virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) { VirtIOGPUBase *g = opaque; if (idx >= g->conf.max_outputs) { - return -1; + return; } g->req_state[idx].x = info->xoff; @@ -92,7 +92,7 @@ static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) /* send event to guest */ virtio_gpu_notify_event(g, VIRTIO_GPU_EVENT_DISPLAY); - return 0; + return; } static void diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 5a2f7a45408..84433d3557e 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -47,15 +47,14 @@ static void virtio_vga_base_text_update(void *opaque, console_ch_t *chardata) } } -static int virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) +static void virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) { VirtIOVGABase *vvga = opaque; VirtIOGPUBase *g = vvga->vgpu; if (g->hw_ops->ui_info) { - return g->hw_ops->ui_info(g, idx, info); + g->hw_ops->ui_info(g, idx, info); } - return -1; } static void virtio_vga_base_gl_block(void *opaque, bool block) diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 89bc90508fb..78f4d82c1c3 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -106,14 +106,14 @@ err: return; } -static int vfio_display_edid_ui_info(void *opaque, uint32_t idx, - QemuUIInfo *info) +static void vfio_display_edid_ui_info(void *opaque, uint32_t idx, + QemuUIInfo *info) { VFIOPCIDevice *vdev = opaque; VFIODisplay *dpy = vdev->dpy; if (!dpy->edid_regs) { - return 0; + return; } if (info->width && info->height) { @@ -121,8 +121,6 @@ static int vfio_display_edid_ui_info(void *opaque, uint32_t idx, } else { vfio_display_edid_update(vdev, false, 0, 0); } - - return 0; } static void vfio_display_edid_init(VFIOPCIDevice *vdev) diff --git a/include/ui/console.h b/include/ui/console.h index f590819880b..7f5374380f0 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -427,7 +427,7 @@ typedef struct GraphicHwOps { bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ void (*text_update)(void *opaque, console_ch_t *text); void (*update_interval)(void *opaque, uint64_t interval); - int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); + void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); void (*gl_block)(void *opaque, bool block); } GraphicHwOps; -- 2.32.0 (Apple Git-132) ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 1/3] ui/console: Do not return a value with ui_info @ 2022-02-26 11:55 ` Akihiko Odaki 0 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: Stefano Stabellini, Michael S . Tsirkin, Paul Durrant, qemu Developers, Gerd Hoffmann, Akihiko Odaki, Anthony Perard, xen-devel The returned value is not used and misleading. Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> --- hw/display/virtio-gpu-base.c | 6 +++--- hw/display/virtio-vga.c | 5 ++--- hw/vfio/display.c | 8 +++----- include/ui/console.h | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index fff0fb4a828..c73b3aa06b8 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -69,12 +69,12 @@ static void virtio_gpu_notify_event(VirtIOGPUBase *g, uint32_t event_type) virtio_notify_config(&g->parent_obj); } -static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) +static void virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) { VirtIOGPUBase *g = opaque; if (idx >= g->conf.max_outputs) { - return -1; + return; } g->req_state[idx].x = info->xoff; @@ -92,7 +92,7 @@ static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) /* send event to guest */ virtio_gpu_notify_event(g, VIRTIO_GPU_EVENT_DISPLAY); - return 0; + return; } static void diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 5a2f7a45408..84433d3557e 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -47,15 +47,14 @@ static void virtio_vga_base_text_update(void *opaque, console_ch_t *chardata) } } -static int virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) +static void virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) { VirtIOVGABase *vvga = opaque; VirtIOGPUBase *g = vvga->vgpu; if (g->hw_ops->ui_info) { - return g->hw_ops->ui_info(g, idx, info); + g->hw_ops->ui_info(g, idx, info); } - return -1; } static void virtio_vga_base_gl_block(void *opaque, bool block) diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 89bc90508fb..78f4d82c1c3 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -106,14 +106,14 @@ err: return; } -static int vfio_display_edid_ui_info(void *opaque, uint32_t idx, - QemuUIInfo *info) +static void vfio_display_edid_ui_info(void *opaque, uint32_t idx, + QemuUIInfo *info) { VFIOPCIDevice *vdev = opaque; VFIODisplay *dpy = vdev->dpy; if (!dpy->edid_regs) { - return 0; + return; } if (info->width && info->height) { @@ -121,8 +121,6 @@ static int vfio_display_edid_ui_info(void *opaque, uint32_t idx, } else { vfio_display_edid_update(vdev, false, 0, 0); } - - return 0; } static void vfio_display_edid_init(VFIOPCIDevice *vdev) diff --git a/include/ui/console.h b/include/ui/console.h index f590819880b..7f5374380f0 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -427,7 +427,7 @@ typedef struct GraphicHwOps { bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ void (*text_update)(void *opaque, console_ch_t *text); void (*update_interval)(void *opaque, uint64_t interval); - int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); + void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); void (*gl_block)(void *opaque, bool block); } GraphicHwOps; -- 2.32.0 (Apple Git-132) ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo 2022-02-26 11:55 ` Akihiko Odaki @ 2022-02-26 11:55 ` Akihiko Odaki -1 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: qemu Developers, xen-devel, Gerd Hoffmann, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant, Akihiko Odaki This change adds a new member, refresh_rate to QemuUIInfo in include/ui/console.h. It represents the refresh rate of the physical display backend, and it is more appropriate than GUI update interval as the refresh rate which the emulated device reports: - sdl may set GUI update interval shorter than the refresh rate of the physical display to respond to user-generated events. - sdl and vnc aggressively changes GUI update interval, but a guests is typically not designed to respond to frequent refresh rate changes, or frequent "display mode" changes in general. The frequency of refresh rate changes of the physical display backend matches better to the guest's expectation. QemuUIInfo also has other members representing "display mode", which makes it suitable for refresh rate representation. It has a throttling of update notifications, and prevents frequent changes of the display mode. Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> --- hw/display/xenfb.c | 14 +++++++++++--- include/ui/console.h | 2 +- include/ui/gtk.h | 2 +- ui/console.c | 6 ------ ui/gtk-egl.c | 4 ++-- ui/gtk-gl-area.c | 3 +-- ui/gtk.c | 45 +++++++++++++++++++++++++------------------- 7 files changed, 42 insertions(+), 34 deletions(-) diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 838260b6ad1..a53341ef673 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -777,16 +777,24 @@ static void xenfb_update(void *opaque) xenfb->up_fullscreen = 0; } -static void xenfb_update_interval(void *opaque, uint64_t interval) +static void xenfb_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) { struct XenFB *xenfb = opaque; + uint32_t refresh_rate; if (xenfb->feature_update) { #ifdef XENFB_TYPE_REFRESH_PERIOD if (xenfb_queue_full(xenfb)) { return; } - xenfb_send_refresh_period(xenfb, interval); + + refresh_rate = info->refresh_rate; + if (!refresh_rate) { + refresh_rate = 75; + } + + /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ + xenfb_send_refresh_period(xenfb, 1000 * 1000 / refresh_rate); #endif } } @@ -983,5 +991,5 @@ struct XenDevOps xen_framebuffer_ops = { static const GraphicHwOps xenfb_ops = { .invalidate = xenfb_invalidate, .gfx_update = xenfb_update, - .update_interval = xenfb_update_interval, + .ui_info = xenfb_ui_info, }; diff --git a/include/ui/console.h b/include/ui/console.h index 7f5374380f0..24f1dbec038 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -139,6 +139,7 @@ typedef struct QemuUIInfo { int yoff; uint32_t width; uint32_t height; + uint32_t refresh_rate; } QemuUIInfo; /* cursor data format is 32bit RGBA */ @@ -426,7 +427,6 @@ typedef struct GraphicHwOps { void (*gfx_update)(void *opaque); bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ void (*text_update)(void *opaque, console_ch_t *text); - void (*update_interval)(void *opaque, uint64_t interval); void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); void (*gl_block)(void *opaque, bool block); } GraphicHwOps; diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 101b147d1b9..ae0f53740d1 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -155,7 +155,7 @@ extern bool gtk_use_gl_area; /* ui/gtk.c */ void gd_update_windowsize(VirtualConsole *vc); -int gd_monitor_update_interval(GtkWidget *widget); +void gd_update_monitor_refresh_rate(VirtualConsole *vc, GtkWidget *widget); void gd_hw_gl_flushed(void *vc); /* ui/gtk-egl.c */ diff --git a/ui/console.c b/ui/console.c index 40eebb6d2cc..63c5c207f0c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -155,7 +155,6 @@ static void gui_update(void *opaque) uint64_t dcl_interval; DisplayState *ds = opaque; DisplayChangeListener *dcl; - QemuConsole *con; ds->refreshing = true; dpy_refresh(ds); @@ -170,11 +169,6 @@ static void gui_update(void *opaque) } if (ds->update_interval != interval) { ds->update_interval = interval; - QTAILQ_FOREACH(con, &consoles, next) { - if (con->hw_ops->update_interval) { - con->hw_ops->update_interval(con->hw, interval); - } - } trace_console_refresh(interval); } ds->last_update = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index e3bd4bc2743..b5bffbab252 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -140,8 +140,8 @@ void gd_egl_refresh(DisplayChangeListener *dcl) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); - vc->gfx.dcl.update_interval = gd_monitor_update_interval( - vc->window ? vc->window : vc->gfx.drawing_area); + gd_update_monitor_refresh_rate( + vc, vc->window ? vc->window : vc->gfx.drawing_area); if (!vc->gfx.esurface) { gd_egl_init(vc); diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index fc5a082eb84..0113474ef5f 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -121,8 +121,7 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); - vc->gfx.dcl.update_interval = gd_monitor_update_interval( - vc->window ? vc->window : vc->gfx.drawing_area); + gd_update_monitor_refresh_rate(vc, vc->window ? vc->window : vc->gfx.drawing_area); if (!vc->gfx.gls) { if (!gtk_widget_get_realized(vc->gfx.drawing_area)) { diff --git a/ui/gtk.c b/ui/gtk.c index a8567b9ddc8..7d904141af0 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -696,11 +696,20 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event, return TRUE; } -static void gd_set_ui_info(VirtualConsole *vc, gint width, gint height) +static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate) { QemuUIInfo info; - memset(&info, 0, sizeof(info)); + info = *dpy_get_ui_info(vc->gfx.dcl.con); + info.refresh_rate = refresh_rate; + dpy_set_ui_info(vc->gfx.dcl.con, &info, true); +} + +static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height) +{ + QemuUIInfo info; + + info = *dpy_get_ui_info(vc->gfx.dcl.con); info.width = width; info.height = height; dpy_set_ui_info(vc->gfx.dcl.con, &info, true); @@ -724,33 +733,32 @@ static void gd_resize_event(GtkGLArea *area, { VirtualConsole *vc = (void *)opaque; - gd_set_ui_info(vc, width, height); + gd_set_ui_size(vc, width, height); } #endif -/* - * If available, return the update interval of the monitor in ms, - * else return 0 (the default update interval). - */ -int gd_monitor_update_interval(GtkWidget *widget) +void gd_update_monitor_refresh_rate(VirtualConsole *vc, GtkWidget *widget) { #ifdef GDK_VERSION_3_22 GdkWindow *win = gtk_widget_get_window(widget); + int refresh_rate; if (win) { GdkDisplay *dpy = gtk_widget_get_display(widget); GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win); - int refresh_rate = gdk_monitor_get_refresh_rate(monitor); /* [mHz] */ - - if (refresh_rate) { - /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ - return MIN(1000 * 1000 / refresh_rate, - GUI_REFRESH_INTERVAL_DEFAULT); - } + refresh_rate = gdk_monitor_get_refresh_rate(monitor); /* [mHz] */ + } else { + refresh_rate = 0; } + + gd_set_ui_refresh_rate(vc, refresh_rate); + + /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ + vc->gfx.dcl.update_interval = refresh_rate ? + MIN(1000 * 1000 / refresh_rate, GUI_REFRESH_INTERVAL_DEFAULT) : + GUI_REFRESH_INTERVAL_DEFAULT; #endif - return 0; } static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) @@ -787,8 +795,7 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) return FALSE; } - vc->gfx.dcl.update_interval = - gd_monitor_update_interval(vc->window ? vc->window : s->window); + gd_update_monitor_refresh_rate(vc, vc->window ? vc->window : s->window); fbw = surface_width(vc->gfx.ds); fbh = surface_height(vc->gfx.ds); @@ -1673,7 +1680,7 @@ static gboolean gd_configure(GtkWidget *widget, { VirtualConsole *vc = opaque; - gd_set_ui_info(vc, cfg->width, cfg->height); + gd_set_ui_size(vc, cfg->width, cfg->height); return FALSE; } -- 2.32.0 (Apple Git-132) ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo @ 2022-02-26 11:55 ` Akihiko Odaki 0 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: Stefano Stabellini, Michael S . Tsirkin, Paul Durrant, qemu Developers, Gerd Hoffmann, Akihiko Odaki, Anthony Perard, xen-devel This change adds a new member, refresh_rate to QemuUIInfo in include/ui/console.h. It represents the refresh rate of the physical display backend, and it is more appropriate than GUI update interval as the refresh rate which the emulated device reports: - sdl may set GUI update interval shorter than the refresh rate of the physical display to respond to user-generated events. - sdl and vnc aggressively changes GUI update interval, but a guests is typically not designed to respond to frequent refresh rate changes, or frequent "display mode" changes in general. The frequency of refresh rate changes of the physical display backend matches better to the guest's expectation. QemuUIInfo also has other members representing "display mode", which makes it suitable for refresh rate representation. It has a throttling of update notifications, and prevents frequent changes of the display mode. Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> --- hw/display/xenfb.c | 14 +++++++++++--- include/ui/console.h | 2 +- include/ui/gtk.h | 2 +- ui/console.c | 6 ------ ui/gtk-egl.c | 4 ++-- ui/gtk-gl-area.c | 3 +-- ui/gtk.c | 45 +++++++++++++++++++++++++------------------- 7 files changed, 42 insertions(+), 34 deletions(-) diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 838260b6ad1..a53341ef673 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -777,16 +777,24 @@ static void xenfb_update(void *opaque) xenfb->up_fullscreen = 0; } -static void xenfb_update_interval(void *opaque, uint64_t interval) +static void xenfb_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) { struct XenFB *xenfb = opaque; + uint32_t refresh_rate; if (xenfb->feature_update) { #ifdef XENFB_TYPE_REFRESH_PERIOD if (xenfb_queue_full(xenfb)) { return; } - xenfb_send_refresh_period(xenfb, interval); + + refresh_rate = info->refresh_rate; + if (!refresh_rate) { + refresh_rate = 75; + } + + /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ + xenfb_send_refresh_period(xenfb, 1000 * 1000 / refresh_rate); #endif } } @@ -983,5 +991,5 @@ struct XenDevOps xen_framebuffer_ops = { static const GraphicHwOps xenfb_ops = { .invalidate = xenfb_invalidate, .gfx_update = xenfb_update, - .update_interval = xenfb_update_interval, + .ui_info = xenfb_ui_info, }; diff --git a/include/ui/console.h b/include/ui/console.h index 7f5374380f0..24f1dbec038 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -139,6 +139,7 @@ typedef struct QemuUIInfo { int yoff; uint32_t width; uint32_t height; + uint32_t refresh_rate; } QemuUIInfo; /* cursor data format is 32bit RGBA */ @@ -426,7 +427,6 @@ typedef struct GraphicHwOps { void (*gfx_update)(void *opaque); bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ void (*text_update)(void *opaque, console_ch_t *text); - void (*update_interval)(void *opaque, uint64_t interval); void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); void (*gl_block)(void *opaque, bool block); } GraphicHwOps; diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 101b147d1b9..ae0f53740d1 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -155,7 +155,7 @@ extern bool gtk_use_gl_area; /* ui/gtk.c */ void gd_update_windowsize(VirtualConsole *vc); -int gd_monitor_update_interval(GtkWidget *widget); +void gd_update_monitor_refresh_rate(VirtualConsole *vc, GtkWidget *widget); void gd_hw_gl_flushed(void *vc); /* ui/gtk-egl.c */ diff --git a/ui/console.c b/ui/console.c index 40eebb6d2cc..63c5c207f0c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -155,7 +155,6 @@ static void gui_update(void *opaque) uint64_t dcl_interval; DisplayState *ds = opaque; DisplayChangeListener *dcl; - QemuConsole *con; ds->refreshing = true; dpy_refresh(ds); @@ -170,11 +169,6 @@ static void gui_update(void *opaque) } if (ds->update_interval != interval) { ds->update_interval = interval; - QTAILQ_FOREACH(con, &consoles, next) { - if (con->hw_ops->update_interval) { - con->hw_ops->update_interval(con->hw, interval); - } - } trace_console_refresh(interval); } ds->last_update = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index e3bd4bc2743..b5bffbab252 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -140,8 +140,8 @@ void gd_egl_refresh(DisplayChangeListener *dcl) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); - vc->gfx.dcl.update_interval = gd_monitor_update_interval( - vc->window ? vc->window : vc->gfx.drawing_area); + gd_update_monitor_refresh_rate( + vc, vc->window ? vc->window : vc->gfx.drawing_area); if (!vc->gfx.esurface) { gd_egl_init(vc); diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index fc5a082eb84..0113474ef5f 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -121,8 +121,7 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); - vc->gfx.dcl.update_interval = gd_monitor_update_interval( - vc->window ? vc->window : vc->gfx.drawing_area); + gd_update_monitor_refresh_rate(vc, vc->window ? vc->window : vc->gfx.drawing_area); if (!vc->gfx.gls) { if (!gtk_widget_get_realized(vc->gfx.drawing_area)) { diff --git a/ui/gtk.c b/ui/gtk.c index a8567b9ddc8..7d904141af0 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -696,11 +696,20 @@ static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event, return TRUE; } -static void gd_set_ui_info(VirtualConsole *vc, gint width, gint height) +static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate) { QemuUIInfo info; - memset(&info, 0, sizeof(info)); + info = *dpy_get_ui_info(vc->gfx.dcl.con); + info.refresh_rate = refresh_rate; + dpy_set_ui_info(vc->gfx.dcl.con, &info, true); +} + +static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height) +{ + QemuUIInfo info; + + info = *dpy_get_ui_info(vc->gfx.dcl.con); info.width = width; info.height = height; dpy_set_ui_info(vc->gfx.dcl.con, &info, true); @@ -724,33 +733,32 @@ static void gd_resize_event(GtkGLArea *area, { VirtualConsole *vc = (void *)opaque; - gd_set_ui_info(vc, width, height); + gd_set_ui_size(vc, width, height); } #endif -/* - * If available, return the update interval of the monitor in ms, - * else return 0 (the default update interval). - */ -int gd_monitor_update_interval(GtkWidget *widget) +void gd_update_monitor_refresh_rate(VirtualConsole *vc, GtkWidget *widget) { #ifdef GDK_VERSION_3_22 GdkWindow *win = gtk_widget_get_window(widget); + int refresh_rate; if (win) { GdkDisplay *dpy = gtk_widget_get_display(widget); GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win); - int refresh_rate = gdk_monitor_get_refresh_rate(monitor); /* [mHz] */ - - if (refresh_rate) { - /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ - return MIN(1000 * 1000 / refresh_rate, - GUI_REFRESH_INTERVAL_DEFAULT); - } + refresh_rate = gdk_monitor_get_refresh_rate(monitor); /* [mHz] */ + } else { + refresh_rate = 0; } + + gd_set_ui_refresh_rate(vc, refresh_rate); + + /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ + vc->gfx.dcl.update_interval = refresh_rate ? + MIN(1000 * 1000 / refresh_rate, GUI_REFRESH_INTERVAL_DEFAULT) : + GUI_REFRESH_INTERVAL_DEFAULT; #endif - return 0; } static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) @@ -787,8 +795,7 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) return FALSE; } - vc->gfx.dcl.update_interval = - gd_monitor_update_interval(vc->window ? vc->window : s->window); + gd_update_monitor_refresh_rate(vc, vc->window ? vc->window : s->window); fbw = surface_width(vc->gfx.ds); fbh = surface_height(vc->gfx.ds); @@ -1673,7 +1680,7 @@ static gboolean gd_configure(GtkWidget *widget, { VirtualConsole *vc = opaque; - gd_set_ui_info(vc, cfg->width, cfg->height); + gd_set_ui_size(vc, cfg->width, cfg->height); return FALSE; } -- 2.32.0 (Apple Git-132) ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo 2022-02-26 11:55 ` Akihiko Odaki (?) @ 2022-06-09 10:28 ` Gerd Hoffmann 2022-06-09 11:45 ` Akihiko Odaki -1 siblings, 1 reply; 13+ messages in thread From: Gerd Hoffmann @ 2022-06-09 10:28 UTC (permalink / raw) To: Akihiko Odaki Cc: qemu Developers, xen-devel, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant > --- a/include/ui/console.h > +++ b/include/ui/console.h > @@ -139,6 +139,7 @@ typedef struct QemuUIInfo { > int yoff; > uint32_t width; > uint32_t height; > + uint32_t refresh_rate; > } QemuUIInfo; > > /* cursor data format is 32bit RGBA */ > @@ -426,7 +427,6 @@ typedef struct GraphicHwOps { > void (*gfx_update)(void *opaque); > bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ > void (*text_update)(void *opaque, console_ch_t *text); > - void (*update_interval)(void *opaque, uint64_t interval); > void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); > void (*gl_block)(void *opaque, bool block); > } GraphicHwOps; So you are dropping update_interval, which isn't mentioned in the commit message at all. Also this patch is rather big. I'd suggest: (1) add refresh_rate (2) update users one by one (3) finally drop update_interval when no user is left. thanks, Gerd ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo 2022-06-09 10:28 ` Gerd Hoffmann @ 2022-06-09 11:45 ` Akihiko Odaki 2022-06-09 12:02 ` Gerd Hoffmann 0 siblings, 1 reply; 13+ messages in thread From: Akihiko Odaki @ 2022-06-09 11:45 UTC (permalink / raw) To: Gerd Hoffmann Cc: qemu Developers, xen-devel, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant On 2022/06/09 19:28, Gerd Hoffmann wrote: >> --- a/include/ui/console.h >> +++ b/include/ui/console.h >> @@ -139,6 +139,7 @@ typedef struct QemuUIInfo { >> int yoff; >> uint32_t width; >> uint32_t height; >> + uint32_t refresh_rate; >> } QemuUIInfo; >> >> /* cursor data format is 32bit RGBA */ >> @@ -426,7 +427,6 @@ typedef struct GraphicHwOps { >> void (*gfx_update)(void *opaque); >> bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ >> void (*text_update)(void *opaque, console_ch_t *text); >> - void (*update_interval)(void *opaque, uint64_t interval); >> void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); >> void (*gl_block)(void *opaque, bool block); >> } GraphicHwOps; > > So you are dropping update_interval, which isn't mentioned in the commit > message at all. Also this patch is rather big. I'd suggest: > > (1) add refresh_rate > (2) update users one by one > (3) finally drop update_interval when no user is left. > > thanks, > Gerd > I think 1 and 3 should have to be done once since refresh_rate and update_interval would interfere with each other otherwise. Does that make sense? Regards, Akihiko Odaki ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo 2022-06-09 11:45 ` Akihiko Odaki @ 2022-06-09 12:02 ` Gerd Hoffmann 2022-06-09 12:12 ` Akihiko Odaki 0 siblings, 1 reply; 13+ messages in thread From: Gerd Hoffmann @ 2022-06-09 12:02 UTC (permalink / raw) To: Akihiko Odaki Cc: qemu Developers, xen-devel, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant On Thu, Jun 09, 2022 at 08:45:41PM +0900, Akihiko Odaki wrote: > On 2022/06/09 19:28, Gerd Hoffmann wrote: > > > --- a/include/ui/console.h > > > +++ b/include/ui/console.h > > > @@ -139,6 +139,7 @@ typedef struct QemuUIInfo { > > > int yoff; > > > uint32_t width; > > > uint32_t height; > > > + uint32_t refresh_rate; > > > } QemuUIInfo; > > > /* cursor data format is 32bit RGBA */ > > > @@ -426,7 +427,6 @@ typedef struct GraphicHwOps { > > > void (*gfx_update)(void *opaque); > > > bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ > > > void (*text_update)(void *opaque, console_ch_t *text); > > > - void (*update_interval)(void *opaque, uint64_t interval); > > > void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); > > > void (*gl_block)(void *opaque, bool block); > > > } GraphicHwOps; > > > > So you are dropping update_interval, which isn't mentioned in the commit > > message at all. Also this patch is rather big. I'd suggest: > > > > (1) add refresh_rate > > (2) update users one by one > > (3) finally drop update_interval when no user is left. > > > > thanks, > > Gerd > > > > I think 1 and 3 should have to be done once since refresh_rate and > update_interval would interfere with each other otherwise. Well, between 1 and 3 both old and new API are active. Shouldn't be much of a problem because the GraphicHwOps implementations are using only the one or the other. take care, Gerd ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo 2022-06-09 12:02 ` Gerd Hoffmann @ 2022-06-09 12:12 ` Akihiko Odaki 2022-06-09 13:34 ` Gerd Hoffmann 0 siblings, 1 reply; 13+ messages in thread From: Akihiko Odaki @ 2022-06-09 12:12 UTC (permalink / raw) To: Gerd Hoffmann Cc: qemu Developers, xen-devel, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant On 2022/06/09 21:02, Gerd Hoffmann wrote: > On Thu, Jun 09, 2022 at 08:45:41PM +0900, Akihiko Odaki wrote: >> On 2022/06/09 19:28, Gerd Hoffmann wrote: >>>> --- a/include/ui/console.h >>>> +++ b/include/ui/console.h >>>> @@ -139,6 +139,7 @@ typedef struct QemuUIInfo { >>>> int yoff; >>>> uint32_t width; >>>> uint32_t height; >>>> + uint32_t refresh_rate; >>>> } QemuUIInfo; >>>> /* cursor data format is 32bit RGBA */ >>>> @@ -426,7 +427,6 @@ typedef struct GraphicHwOps { >>>> void (*gfx_update)(void *opaque); >>>> bool gfx_update_async; /* if true, calls graphic_hw_update_done() */ >>>> void (*text_update)(void *opaque, console_ch_t *text); >>>> - void (*update_interval)(void *opaque, uint64_t interval); >>>> void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); >>>> void (*gl_block)(void *opaque, bool block); >>>> } GraphicHwOps; >>> >>> So you are dropping update_interval, which isn't mentioned in the commit >>> message at all. Also this patch is rather big. I'd suggest: >>> >>> (1) add refresh_rate >>> (2) update users one by one >>> (3) finally drop update_interval when no user is left. >>> >>> thanks, >>> Gerd >>> >> >> I think 1 and 3 should have to be done once since refresh_rate and >> update_interval would interfere with each other otherwise. > > Well, between 1 and 3 both old and new API are active. Shouldn't be > much of a problem because the GraphicHwOps implementations are using > only the one or the other. > > take care, > Gerd > The only GraphicHwOps implementation updated with this change is xenfb. xenfb can be switched to use refresh_rate in step 1 or 3. Switching to use refresh_rate in step 1 would break the refresh rate propagation until all host displays are updated to set refresh_rate instead of calling update_interval. Switching to use refresh_rate in step 3 would break the refresh rate propagation when a host display is updated to set refresh_rate instead of calling update_interval but xenfb does not use refresh_rate. Regards, Akihiko Odaki ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo 2022-06-09 12:12 ` Akihiko Odaki @ 2022-06-09 13:34 ` Gerd Hoffmann 0 siblings, 0 replies; 13+ messages in thread From: Gerd Hoffmann @ 2022-06-09 13:34 UTC (permalink / raw) To: Akihiko Odaki Cc: qemu Developers, xen-devel, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant Hi, > > > > (1) add refresh_rate > > > > (2) update users one by one > > > > (3) finally drop update_interval when no user is left. > > > > > > > > thanks, > > > > Gerd > > > > > > > > > > I think 1 and 3 should have to be done once since refresh_rate and > > > update_interval would interfere with each other otherwise. > > > > Well, between 1 and 3 both old and new API are active. Shouldn't be > > much of a problem because the GraphicHwOps implementations are using > > only the one or the other. > > > > take care, > > Gerd > > > > The only GraphicHwOps implementation updated with this change is xenfb. > xenfb can be switched to use refresh_rate in step 1 or 3. > > Switching to use refresh_rate in step 1 would break the refresh rate > propagation until all host displays are updated to set refresh_rate instead > of calling update_interval. Well, host display update would need splitting into two pieces too, first add refresh_rate, then later drop update_interval, to make the update scheme work without temporary breakage. That sounds increasingly like over engineering it though, I guess I just queue up the patches as-is. thanks, Gerd ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 3/3] virtio-gpu: Respect UI refresh rate for EDID 2022-02-26 11:55 ` Akihiko Odaki @ 2022-02-26 11:55 ` Akihiko Odaki -1 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: qemu Developers, xen-devel, Gerd Hoffmann, Michael S . Tsirkin, Stefano Stabellini, Anthony Perard, Paul Durrant, Akihiko Odaki Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> --- hw/display/virtio-gpu-base.c | 1 + hw/display/virtio-gpu.c | 1 + include/hw/virtio/virtio-gpu.h | 1 + 3 files changed, 3 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index c73b3aa06b8..ee2587a8c36 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -79,6 +79,7 @@ static void virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) g->req_state[idx].x = info->xoff; g->req_state[idx].y = info->yoff; + g->req_state[idx].refresh_rate = info->refresh_rate; g->req_state[idx].width = info->width; g->req_state[idx].height = info->height; g->req_state[idx].width_mm = info->width_mm; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index c6dc818988c..04fbbd1f8f3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -217,6 +217,7 @@ virtio_gpu_generate_edid(VirtIOGPU *g, int scanout, .height_mm = b->req_state[scanout].height_mm, .prefx = b->req_state[scanout].width, .prefy = b->req_state[scanout].height, + .refresh_rate = b->req_state[scanout].refresh_rate, }; edid->size = cpu_to_le32(sizeof(edid->edid)); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2179b757037..09a317e1a7a 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -81,6 +81,7 @@ struct virtio_gpu_scanout { struct virtio_gpu_requested_state { uint16_t width_mm, height_mm; uint32_t width, height; + uint32_t refresh_rate; int x, y; }; -- 2.32.0 (Apple Git-132) ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 3/3] virtio-gpu: Respect UI refresh rate for EDID @ 2022-02-26 11:55 ` Akihiko Odaki 0 siblings, 0 replies; 13+ messages in thread From: Akihiko Odaki @ 2022-02-26 11:55 UTC (permalink / raw) Cc: Stefano Stabellini, Michael S . Tsirkin, Paul Durrant, qemu Developers, Gerd Hoffmann, Akihiko Odaki, Anthony Perard, xen-devel Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> --- hw/display/virtio-gpu-base.c | 1 + hw/display/virtio-gpu.c | 1 + include/hw/virtio/virtio-gpu.h | 1 + 3 files changed, 3 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index c73b3aa06b8..ee2587a8c36 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -79,6 +79,7 @@ static void virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info) g->req_state[idx].x = info->xoff; g->req_state[idx].y = info->yoff; + g->req_state[idx].refresh_rate = info->refresh_rate; g->req_state[idx].width = info->width; g->req_state[idx].height = info->height; g->req_state[idx].width_mm = info->width_mm; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index c6dc818988c..04fbbd1f8f3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -217,6 +217,7 @@ virtio_gpu_generate_edid(VirtIOGPU *g, int scanout, .height_mm = b->req_state[scanout].height_mm, .prefx = b->req_state[scanout].width, .prefy = b->req_state[scanout].height, + .refresh_rate = b->req_state[scanout].refresh_rate, }; edid->size = cpu_to_le32(sizeof(edid->edid)); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2179b757037..09a317e1a7a 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -81,6 +81,7 @@ struct virtio_gpu_scanout { struct virtio_gpu_requested_state { uint16_t width_mm, height_mm; uint32_t width, height; + uint32_t refresh_rate; int x, y; }; -- 2.32.0 (Apple Git-132) ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-06-09 14:21 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-02-26 11:55 [PATCH v3 0/3] virtio-gpu: Respect UI refresh rate for EDID Akihiko Odaki 2022-02-26 11:55 ` Akihiko Odaki 2022-02-26 11:55 ` [PATCH v3 1/3] ui/console: Do not return a value with ui_info Akihiko Odaki 2022-02-26 11:55 ` Akihiko Odaki 2022-02-26 11:55 ` [PATCH v3 2/3] ui: Deliver refresh rate via QemuUIInfo Akihiko Odaki 2022-02-26 11:55 ` Akihiko Odaki 2022-06-09 10:28 ` Gerd Hoffmann 2022-06-09 11:45 ` Akihiko Odaki 2022-06-09 12:02 ` Gerd Hoffmann 2022-06-09 12:12 ` Akihiko Odaki 2022-06-09 13:34 ` Gerd Hoffmann 2022-02-26 11:55 ` [PATCH v3 3/3] virtio-gpu: Respect UI refresh rate for EDID Akihiko Odaki 2022-02-26 11:55 ` Akihiko Odaki
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.