bugfixes for vga, audio, vnc

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEoDKM/7k6F6eZAf59TLbY7tPocTgFAmI0j4YACgkQTLbY7tPo
 cTi0ZBAA0+Ed188akXM9h6W1zEkP+7p/oMc5HSj0y0cTlo+I0SKhbPpgGDmFdUk9
 UNmKemiiXzLL0RuVcTfBi0CX3Nl+Ox6K4yutdTXR+qpoLE6VXiWK2eIrQJG/lmEF
 HBHXKCWpE/z3xh7Z1l4SrGFLWL/gHIPEbYIQuZa/dstxRB38cRH2cnjjkC3ITv5A
 wYY7HdLL1Itpi9+Xg0/3q2/u7Fx+SbGD1FyXrfBnm9Gy9o6iAgBqnrhGzIwJ6+45
 CBX5bQx5+eOz1znNowcpieHrJLmfm5sSnz3SKIoKZYncPt1IKOwbl+s6zZClqyDo
 iBluvEAZvR62Q6OQA5acCYFk6IkSZRvWpakKSfo0hNSE6YqSnewmEbv2u2u2Cdvy
 Z/CxkQF7gp35tJhv3tVL/zV2ykqpkQF5sWto9adqJViuHdul4JsrvRZgjQp9niKV
 lZZ2QudliL0IpSpMnkrUFs8aV8QJVoCaCkUsYburJPeR4Pkx5E4dmAMpIHiOIiOw
 c1sUTvFL9HJsZCbRGGIGIM9w80i7EZDbY76FzOJ/npmpaDbw+yO7f0TQin2sP8YR
 7xhGv0cNjLRK+9ndR38TcsfkilFrSHvN+DEKJqhpbv8EBYLXTnx83PDYxbdQ/Ivy
 oh9OLRomjhlxjh/jsA4Mznz3zLJFDnB0GdhDG1X6td/ldMYs6io=
 =zCkU
 -----END PGP SIGNATURE-----

Merge tag 'fixes-20220318-pull-request' of git://git.kraxel.org/qemu into staging

bugfixes for vga, audio, vnc

# gpg: Signature made Fri 18 Mar 2022 13:56:22 GMT
# gpg:                using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* tag 'fixes-20220318-pull-request' of git://git.kraxel.org/qemu:
  hw/display/vga: Report a proper error when adding a 2nd ISA VGA
  hw/display: Allow vga_common_init() to return errors
  hw/display/cirrus_vga: Clean up indentation in pci_cirrus_vga_realize()
  audio/mixeng: Do not declare unused variables
  ui: avoid unnecessary memory operations in vnc_refresh_server_surface()
  ui/gtk: Ignore 2- and 3-button press events

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2022-03-19 11:28:54 +00:00
commit 2058fdbe81
14 changed files with 100 additions and 52 deletions

View File

@ -342,13 +342,13 @@ f_sample *mixeng_clip_float[2] = {
void audio_sample_to_uint64(const void *samples, int pos,
uint64_t *left, uint64_t *right)
{
const struct st_sample *sample = samples;
sample += pos;
#ifdef FLOAT_MIXENG
error_report(
"Coreaudio and floating point samples are not supported by replay yet");
abort();
#else
const struct st_sample *sample = samples;
sample += pos;
*left = sample->l;
*right = sample->r;
#endif
@ -357,13 +357,13 @@ void audio_sample_to_uint64(const void *samples, int pos,
void audio_sample_from_uint64(void *samples, int pos,
uint64_t left, uint64_t right)
{
struct st_sample *sample = samples;
sample += pos;
#ifdef FLOAT_MIXENG
error_report(
"Coreaudio and floating point samples are not supported by replay yet");
abort();
#else
struct st_sample *sample = samples;
sample += pos;
sample->l = left;
sample->r = right;
#endif

View File

@ -955,7 +955,9 @@ static void ati_vga_realize(PCIDevice *dev, Error **errp)
}
/* init vga bits */
vga_common_init(vga, OBJECT(s));
if (!vga_common_init(vga, OBJECT(s), errp)) {
return;
}
vga_init(vga, OBJECT(s), pci_address_space(dev),
pci_address_space_io(dev), true);
vga->con = graphic_console_init(DEVICE(s), 0, s->vga.hw_ops, &s->vga);

View File

@ -2940,27 +2940,30 @@ void cirrus_init_common(CirrusVGAState *s, Object *owner,
static void pci_cirrus_vga_realize(PCIDevice *dev, Error **errp)
{
PCICirrusVGAState *d = PCI_CIRRUS_VGA(dev);
CirrusVGAState *s = &d->cirrus_vga;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
int16_t device_id = pc->device_id;
PCICirrusVGAState *d = PCI_CIRRUS_VGA(dev);
CirrusVGAState *s = &d->cirrus_vga;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
int16_t device_id = pc->device_id;
/* follow real hardware, cirrus card emulated has 4 MB video memory.
Also accept 8 MB/16 MB for backward compatibility. */
if (s->vga.vram_size_mb != 4 && s->vga.vram_size_mb != 8 &&
s->vga.vram_size_mb != 16) {
error_setg(errp, "Invalid cirrus_vga ram size '%u'",
s->vga.vram_size_mb);
return;
}
/* setup VGA */
vga_common_init(&s->vga, OBJECT(dev));
cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev),
pci_address_space_io(dev));
s->vga.con = graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s->vga);
/* setup PCI */
/*
* Follow real hardware, cirrus card emulated has 4 MB video memory.
* Also accept 8 MB/16 MB for backward compatibility.
*/
if (s->vga.vram_size_mb != 4 && s->vga.vram_size_mb != 8 &&
s->vga.vram_size_mb != 16) {
error_setg(errp, "Invalid cirrus_vga ram size '%u'",
s->vga.vram_size_mb);
return;
}
/* setup VGA */
if (!vga_common_init(&s->vga, OBJECT(dev), errp)) {
return;
}
cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev),
pci_address_space_io(dev));
s->vga.con = graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s->vga);
/* setup PCI */
memory_region_init(&s->pci_bar, OBJECT(dev), "cirrus-pci-bar0", 0x2000000);
/* XXX: add byte swapping apertures */
@ -2968,14 +2971,14 @@ static void pci_cirrus_vga_realize(PCIDevice *dev, Error **errp)
memory_region_add_subregion(&s->pci_bar, 0x1000000,
&s->cirrus_linear_bitblt_io);
/* setup memory space */
/* memory #0 LFB */
/* memory #1 memory-mapped I/O */
/* XXX: s->vga.vram_size must be a power of two */
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->pci_bar);
if (device_id == CIRRUS_ID_CLGD5446) {
pci_register_bar(&d->dev, 1, 0, &s->cirrus_mmio_io);
}
/* setup memory space */
/* memory #0 LFB */
/* memory #1 memory-mapped I/O */
/* XXX: s->vga.vram_size must be a power of two */
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->pci_bar);
if (device_id == CIRRUS_ID_CLGD5446) {
pci_register_bar(&d->dev, 1, 0, &s->cirrus_mmio_io);
}
}
static Property pci_vga_cirrus_properties[] = {

View File

@ -56,7 +56,9 @@ static void isa_cirrus_vga_realizefn(DeviceState *dev, Error **errp)
return;
}
s->global_vmstate = true;
vga_common_init(s, OBJECT(dev));
if (!vga_common_init(s, OBJECT(dev), errp)) {
return;
}
cirrus_init_common(&d->cirrus_vga, OBJECT(dev), CIRRUS_ID_CLGD5430, 0,
isa_address_space(isadev),
isa_address_space_io(isadev));

View File

@ -2215,7 +2215,11 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp)
qxl_init_ramsize(qxl);
vga->vbe_size = qxl->vgamem_size;
vga->vram_size_mb = qxl->vga.vram_size / MiB;
vga_common_init(vga, OBJECT(dev));
vga_common_init(vga, OBJECT(dev), &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
vga_init(vga, OBJECT(dev),
pci_address_space(dev), pci_address_space_io(dev), false);
portio_list_init(&qxl->vga_port_list, OBJECT(dev), qxl_vga_portio_list,

View File

@ -62,7 +62,10 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
const MemoryRegionPortio *vga_ports, *vbe_ports;
s->global_vmstate = true;
vga_common_init(s, OBJECT(dev));
if (!vga_common_init(s, OBJECT(dev), errp)) {
return;
}
s->legacy_address_space = isa_address_space(isadev);
vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports);
isa_register_portio_list(isadev, &d->portio_vga,

View File

@ -102,7 +102,10 @@ static void vga_mmio_realizefn(DeviceState *dev, Error **errp)
s->vga.bank_offset = 0;
s->vga.global_vmstate = true;
vga_common_init(&s->vga, OBJECT(dev));
if (!vga_common_init(&s->vga, OBJECT(dev), errp)) {
return;
}
sysbus_init_mmio(sbd, &s->vga.vram);
s->vga.con = graphic_console_init(dev, 0, s->vga.hw_ops, &s->vga);
}

View File

@ -239,7 +239,9 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
bool edid = false;
/* vga + console init */
vga_common_init(s, OBJECT(dev));
if (!vga_common_init(s, OBJECT(dev), errp)) {
return;
}
vga_init(s, OBJECT(dev), pci_address_space(dev), pci_address_space_io(dev),
true);
@ -275,7 +277,9 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
bool edid = false;
/* vga + console init */
vga_common_init(s, OBJECT(dev));
if (!vga_common_init(s, OBJECT(dev), errp)) {
return;
}
s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s);
/* mmio bar */

View File

@ -2168,9 +2168,10 @@ static inline uint32_t uint_clamp(uint32_t val, uint32_t vmin, uint32_t vmax)
return val;
}
void vga_common_init(VGACommonState *s, Object *obj)
bool vga_common_init(VGACommonState *s, Object *obj, Error **errp)
{
int i, j, v, b;
Error *local_err = NULL;
for(i = 0;i < 256; i++) {
v = 0;
@ -2205,8 +2206,18 @@ void vga_common_init(VGACommonState *s, Object *obj)
s->vbe_size_mask = s->vbe_size - 1;
s->is_vbe_vmstate = 1;
if (s->global_vmstate && qemu_ram_block_by_name("vga.vram")) {
error_setg(errp, "Only one global VGA device can be used at a time");
return false;
}
memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_size,
&error_fatal);
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return false;
}
vmstate_register_ram(&s->vram, s->global_vmstate ? NULL : DEVICE(obj));
xen_register_framebuffer(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
@ -2237,6 +2248,8 @@ void vga_common_init(VGACommonState *s, Object *obj)
s->default_endian_fb = false;
#endif
vga_dirty_log_start(s);
return true;
}
static const MemoryRegionPortio vga_portio_list[] = {

View File

@ -156,7 +156,7 @@ static inline int c6_to_8(int v)
return (v << 2) | (b << 1) | b;
}
void vga_common_init(VGACommonState *s, Object *obj);
bool vga_common_init(VGACommonState *s, Object *obj, Error **errp);
void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
MemoryRegion *address_space_io, bool init_vga_ports);
MemoryRegion *vga_init_io(VGACommonState *s, Object *obj,

View File

@ -108,7 +108,9 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
/* init vga compat bits */
vga->vram_size_mb = 8;
vga_common_init(vga, OBJECT(vpci_dev));
if (!vga_common_init(vga, OBJECT(vpci_dev), errp)) {
return;
}
vga_init(vga, OBJECT(vpci_dev), pci_address_space(&vpci_dev->pci_dev),
pci_address_space_io(&vpci_dev->pci_dev), true);
pci_register_bar(&vpci_dev->pci_dev, 0,

View File

@ -1254,7 +1254,7 @@ static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s,
&error_fatal);
s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram);
vga_common_init(&s->vga, OBJECT(dev));
vga_common_init(&s->vga, OBJECT(dev), &error_fatal);
vga_init(&s->vga, OBJECT(dev), address_space, io, true);
vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
s->new_depth = 32;

View File

@ -972,6 +972,10 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button,
return TRUE;
}
if (button->type == GDK_2BUTTON_PRESS || button->type == GDK_3BUTTON_PRESS) {
return TRUE;
}
qemu_input_queue_btn(vc->gfx.dcl.con, btn,
button->type == GDK_BUTTON_PRESS);
qemu_input_event_sync();

View File

@ -3098,6 +3098,9 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
VncState *vs;
int has_dirty = 0;
pixman_image_t *tmpbuf = NULL;
unsigned long offset;
int x;
uint8_t *guest_ptr, *server_ptr;
struct timeval tv = { 0, 0 };
@ -3106,6 +3109,13 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
has_dirty = vnc_update_stats(vd, &tv);
}
offset = find_next_bit((unsigned long *) &vd->guest.dirty,
height * VNC_DIRTY_BPL(&vd->guest), 0);
if (offset == height * VNC_DIRTY_BPL(&vd->guest)) {
/* no dirty bits in guest surface */
return has_dirty;
}
/*
* Walk through the guest dirty map.
* Check and copy modified bits from guest to server surface.
@ -3130,15 +3140,6 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
line_bytes = MIN(server_stride, guest_ll);
for (;;) {
int x;
uint8_t *guest_ptr, *server_ptr;
unsigned long offset = find_next_bit((unsigned long *) &vd->guest.dirty,
height * VNC_DIRTY_BPL(&vd->guest),
y * VNC_DIRTY_BPL(&vd->guest));
if (offset == height * VNC_DIRTY_BPL(&vd->guest)) {
/* no more dirty bits */
break;
}
y = offset / VNC_DIRTY_BPL(&vd->guest);
x = offset % VNC_DIRTY_BPL(&vd->guest);
@ -3177,6 +3178,13 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
}
y++;
offset = find_next_bit((unsigned long *) &vd->guest.dirty,
height * VNC_DIRTY_BPL(&vd->guest),
y * VNC_DIRTY_BPL(&vd->guest));
if (offset == height * VNC_DIRTY_BPL(&vd->guest)) {
/* no more dirty bits */
break;
}
}
qemu_pixman_image_unref(tmpbuf);
return has_dirty;