diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-04-27 12:27:46 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-05-14 12:33:44 +0200 |
commit | 039a68373c4544ff94871f945a733928b6dcfe93 (patch) | |
tree | 9a4d966054f19e7c967a5d9c046d9ab184ab0fc3 /hw/audio/soundhw.c | |
parent | 67aaa96ae451913ffd25766dc59341fe6b63619d (diff) | |
download | qemu-039a68373c4544ff94871f945a733928b6dcfe93.zip qemu-039a68373c4544ff94871f945a733928b6dcfe93.tar.gz qemu-039a68373c4544ff94871f945a733928b6dcfe93.tar.bz2 |
introduce -audio as a replacement for -soundhw
-audio is used like "-audio pa,model=sb16". It is almost as simple as
-soundhw, but it reuses the -audiodev parsing machinery and attaches an
audiodev to the newly-created device. The main 'feature' is that
it knows about adding the codec device for model=intel-hda, and adding
the audiodev to the codec device.
In the future, it could be extended to support default models or
builtin devices, just like -nic, or even a default backend. For now,
keep it simple.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/audio/soundhw.c')
-rw-r--r-- | hw/audio/soundhw.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c index ebbd095..94d9463 100644 --- a/hw/audio/soundhw.c +++ b/hw/audio/soundhw.c @@ -27,6 +27,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qom/object.h" +#include "hw/qdev-properties.h" #include "hw/isa/isa.h" #include "hw/pci/pci.h" #include "hw/audio/soundhw.h" @@ -36,14 +37,14 @@ struct soundhw { const char *descr; const char *typename; int isa; - int (*init_pci) (PCIBus *bus); + int (*init_pci) (PCIBus *bus, const char *audiodev); }; static struct soundhw soundhw[9]; static int soundhw_count; void pci_register_soundhw(const char *name, const char *descr, - int (*init_pci)(PCIBus *bus)) + int (*init_pci)(PCIBus *bus, const char *audiodev)) { assert(soundhw_count < ARRAY_SIZE(soundhw) - 1); soundhw[soundhw_count].name = name; @@ -80,8 +81,9 @@ void show_valid_soundhw(void) } static struct soundhw *selected = NULL; +static const char *audiodev_id; -void select_soundhw(const char *optarg) +void select_soundhw(const char *optarg, const char *audiodev) { struct soundhw *c; @@ -92,6 +94,7 @@ void select_soundhw(const char *optarg) for (c = soundhw; c->name; ++c) { if (g_str_equal(c->name, optarg)) { selected = c; + audiodev_id = audiodev; break; } } @@ -129,10 +132,11 @@ void soundhw_init(void) if (c->typename) { DeviceState *dev = qdev_new(c->typename); + qdev_prop_set_string(dev, "audiodev", audiodev_id); qdev_realize_and_unref(dev, bus, &error_fatal); } else { assert(!c->isa); - c->init_pci(pci_bus); + c->init_pci(pci_bus, audiodev_id); } } |