audio: add audiodev properties to frontends
Finally add audiodev= options to audio frontends so users can specify which backend to use when multiple backends exist. Not specifying an audiodev= option currently causes the first audiodev to be used, this is fixed in the next commit. Example usage: -audiodev pa,id=foo -device AC97,audiodev=foo Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: d64db52dda2d0e9d97bc5ab1dd9adf724280fea1.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
f0b9f36d71
commit
88e47b9a45
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "qemu/queue.h"
|
#include "qemu/queue.h"
|
||||||
#include "qapi/qapi-types-audio.h"
|
#include "qapi/qapi-types-audio.h"
|
||||||
|
#include "hw/qdev-properties.h"
|
||||||
|
|
||||||
typedef void (*audio_callback_fn) (void *opaque, int avail);
|
typedef void (*audio_callback_fn) (void *opaque, int avail);
|
||||||
|
|
||||||
@ -181,4 +182,7 @@ void audio_legacy_help(void);
|
|||||||
AudioState *audio_state_by_name(const char *name);
|
AudioState *audio_state_by_name(const char *name);
|
||||||
const char *audio_get_id(QEMUSoundCard *card);
|
const char *audio_get_id(QEMUSoundCard *card);
|
||||||
|
|
||||||
|
#define DEFINE_AUDIO_PROPERTIES(_s, _f) \
|
||||||
|
DEFINE_PROP_AUDIODEV("audiodev", _s, _f)
|
||||||
|
|
||||||
#endif /* QEMU_AUDIO_H */
|
#endif /* QEMU_AUDIO_H */
|
||||||
|
@ -1410,6 +1410,7 @@ static int ac97_init (PCIBus *bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Property ac97_properties[] = {
|
static Property ac97_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(AC97LinkState, card),
|
||||||
DEFINE_PROP_UINT32 ("use_broken_id", AC97LinkState, use_broken_id, 0),
|
DEFINE_PROP_UINT32 ("use_broken_id", AC97LinkState, use_broken_id, 0),
|
||||||
DEFINE_PROP_END_OF_LIST (),
|
DEFINE_PROP_END_OF_LIST (),
|
||||||
};
|
};
|
||||||
|
@ -299,6 +299,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Property adlib_properties[] = {
|
static Property adlib_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(AdlibState, card),
|
||||||
DEFINE_PROP_UINT32 ("iobase", AdlibState, port, 0x220),
|
DEFINE_PROP_UINT32 ("iobase", AdlibState, port, 0x220),
|
||||||
DEFINE_PROP_UINT32 ("freq", AdlibState, freq, 44100),
|
DEFINE_PROP_UINT32 ("freq", AdlibState, freq, 44100),
|
||||||
DEFINE_PROP_END_OF_LIST (),
|
DEFINE_PROP_END_OF_LIST (),
|
||||||
|
@ -690,6 +690,7 @@ static int cs4231a_init (ISABus *bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Property cs4231a_properties[] = {
|
static Property cs4231a_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(CSState, card),
|
||||||
DEFINE_PROP_UINT32 ("iobase", CSState, port, 0x534),
|
DEFINE_PROP_UINT32 ("iobase", CSState, port, 0x534),
|
||||||
DEFINE_PROP_UINT32 ("irq", CSState, irq, 9),
|
DEFINE_PROP_UINT32 ("irq", CSState, irq, 9),
|
||||||
DEFINE_PROP_UINT32 ("dma", CSState, dma, 3),
|
DEFINE_PROP_UINT32 ("dma", CSState, dma, 3),
|
||||||
|
@ -887,6 +887,11 @@ static int es1370_init (PCIBus *bus)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Property es1370_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(ES1370State, card),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
static void es1370_class_init (ObjectClass *klass, void *data)
|
static void es1370_class_init (ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS (klass);
|
DeviceClass *dc = DEVICE_CLASS (klass);
|
||||||
@ -903,6 +908,7 @@ static void es1370_class_init (ObjectClass *klass, void *data)
|
|||||||
dc->desc = "ENSONIQ AudioPCI ES1370";
|
dc->desc = "ENSONIQ AudioPCI ES1370";
|
||||||
dc->vmsd = &vmstate_es1370;
|
dc->vmsd = &vmstate_es1370;
|
||||||
dc->reset = es1370_on_reset;
|
dc->reset = es1370_on_reset;
|
||||||
|
dc->props = es1370_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo es1370_info = {
|
static const TypeInfo es1370_info = {
|
||||||
@ -923,4 +929,3 @@ static void es1370_register_types (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
type_init (es1370_register_types)
|
type_init (es1370_register_types)
|
||||||
|
|
||||||
|
@ -299,6 +299,7 @@ static int GUS_init (ISABus *bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Property gus_properties[] = {
|
static Property gus_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(GUSState, card),
|
||||||
DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100),
|
DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100),
|
||||||
DEFINE_PROP_UINT32 ("iobase", GUSState, port, 0x240),
|
DEFINE_PROP_UINT32 ("iobase", GUSState, port, 0x240),
|
||||||
DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7),
|
DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7),
|
||||||
|
@ -841,6 +841,7 @@ static const VMStateDescription vmstate_hda_audio = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static Property hda_audio_properties[] = {
|
static Property hda_audio_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(HDAAudioState, card),
|
||||||
DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0),
|
DEFINE_PROP_UINT32("debug", HDAAudioState, debug, 0),
|
||||||
DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true),
|
DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer, true),
|
||||||
DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer, true),
|
DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer, true),
|
||||||
|
@ -330,6 +330,11 @@ static const VMStateDescription vmstate_milkymist_ac97 = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Property milkymist_ac97_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(MilkymistAC97State, card),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
static void milkymist_ac97_class_init(ObjectClass *klass, void *data)
|
static void milkymist_ac97_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
@ -337,6 +342,7 @@ static void milkymist_ac97_class_init(ObjectClass *klass, void *data)
|
|||||||
dc->realize = milkymist_ac97_realize;
|
dc->realize = milkymist_ac97_realize;
|
||||||
dc->reset = milkymist_ac97_reset;
|
dc->reset = milkymist_ac97_reset;
|
||||||
dc->vmsd = &vmstate_milkymist_ac97;
|
dc->vmsd = &vmstate_milkymist_ac97;
|
||||||
|
dc->props = milkymist_ac97_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo milkymist_ac97_info = {
|
static const TypeInfo milkymist_ac97_info = {
|
||||||
|
@ -209,6 +209,7 @@ static const VMStateDescription vmstate_spk = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static Property pcspk_properties[] = {
|
static Property pcspk_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(PCSpkState, card),
|
||||||
DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1),
|
DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1),
|
||||||
DEFINE_PROP_BOOL("migrate", PCSpkState, migrate, true),
|
DEFINE_PROP_BOOL("migrate", PCSpkState, migrate, true),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
@ -625,6 +625,7 @@ static const VMStateDescription vmstate_pl041 = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static Property pl041_device_properties[] = {
|
static Property pl041_device_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(PL041State, codec.card),
|
||||||
/* Non-compact FIFO depth property */
|
/* Non-compact FIFO depth property */
|
||||||
DEFINE_PROP_UINT32("nc_fifo_depth", PL041State, fifo_depth,
|
DEFINE_PROP_UINT32("nc_fifo_depth", PL041State, fifo_depth,
|
||||||
DEFAULT_FIFO_DEPTH),
|
DEFAULT_FIFO_DEPTH),
|
||||||
|
@ -1422,6 +1422,7 @@ static int SB16_init (ISABus *bus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Property sb16_properties[] = {
|
static Property sb16_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(SB16State, card),
|
||||||
DEFINE_PROP_UINT32 ("version", SB16State, ver, 0x0405), /* 4.5 */
|
DEFINE_PROP_UINT32 ("version", SB16State, ver, 0x0405), /* 4.5 */
|
||||||
DEFINE_PROP_UINT32 ("iobase", SB16State, port, 0x220),
|
DEFINE_PROP_UINT32 ("iobase", SB16State, port, 0x220),
|
||||||
DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5),
|
DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5),
|
||||||
|
@ -702,6 +702,11 @@ void wm8750_set_bclk_in(void *opaque, int new_hz)
|
|||||||
wm8750_clk_update(s, 1);
|
wm8750_clk_update(s, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Property wm8750_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(WM8750State, card),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
static void wm8750_class_init(ObjectClass *klass, void *data)
|
static void wm8750_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
@ -712,6 +717,7 @@ static void wm8750_class_init(ObjectClass *klass, void *data)
|
|||||||
sc->recv = wm8750_rx;
|
sc->recv = wm8750_rx;
|
||||||
sc->send = wm8750_tx;
|
sc->send = wm8750_tx;
|
||||||
dc->vmsd = &vmstate_wm8750;
|
dc->vmsd = &vmstate_wm8750;
|
||||||
|
dc->props = wm8750_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo wm8750_info = {
|
static const TypeInfo wm8750_info = {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "audio/audio.h"
|
||||||
#include "net/net.h"
|
#include "net/net.h"
|
||||||
#include "hw/qdev-properties.h"
|
#include "hw/qdev-properties.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
@ -353,6 +354,62 @@ const PropertyInfo qdev_prop_netdev = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* --- audiodev --- */
|
||||||
|
static void get_audiodev(Object *obj, Visitor *v, const char* name,
|
||||||
|
void *opaque, Error **errp)
|
||||||
|
{
|
||||||
|
DeviceState *dev = DEVICE(obj);
|
||||||
|
Property *prop = opaque;
|
||||||
|
QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop);
|
||||||
|
char *p = g_strdup(audio_get_id(card));
|
||||||
|
|
||||||
|
visit_type_str(v, name, &p, errp);
|
||||||
|
g_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_audiodev(Object *obj, Visitor *v, const char* name,
|
||||||
|
void *opaque, Error **errp)
|
||||||
|
{
|
||||||
|
DeviceState *dev = DEVICE(obj);
|
||||||
|
Property *prop = opaque;
|
||||||
|
QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop);
|
||||||
|
AudioState *state;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
int err = 0;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
if (dev->realized) {
|
||||||
|
qdev_prop_set_after_realize(dev, name, errp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
visit_type_str(v, name, &str, &local_err);
|
||||||
|
if (local_err) {
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = audio_state_by_name(str);
|
||||||
|
|
||||||
|
if (!state) {
|
||||||
|
err = -ENOENT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
card->state = state;
|
||||||
|
|
||||||
|
out:
|
||||||
|
error_set_from_qdev_prop_error(errp, err, dev, prop, str);
|
||||||
|
g_free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
const PropertyInfo qdev_prop_audiodev = {
|
||||||
|
.name = "str",
|
||||||
|
.description = "ID of an audiodev to use as a backend",
|
||||||
|
/* release done on shutdown */
|
||||||
|
.get = get_audiodev,
|
||||||
|
.set = set_audiodev,
|
||||||
|
};
|
||||||
|
|
||||||
void qdev_prop_set_drive(DeviceState *dev, const char *name,
|
void qdev_prop_set_drive(DeviceState *dev, const char *name,
|
||||||
BlockBackend *value, Error **errp)
|
BlockBackend *value, Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -667,6 +667,7 @@ static const VMStateDescription vmstate_usb_audio = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static Property usb_audio_properties[] = {
|
static Property usb_audio_properties[] = {
|
||||||
|
DEFINE_AUDIO_PROPERTIES(USBAudioState, card),
|
||||||
DEFINE_PROP_UINT32("debug", USBAudioState, debug, 0),
|
DEFINE_PROP_UINT32("debug", USBAudioState, debug, 0),
|
||||||
DEFINE_PROP_UINT32("buffer", USBAudioState, buffer,
|
DEFINE_PROP_UINT32("buffer", USBAudioState, buffer,
|
||||||
32 * USBAUDIO_PACKET_SIZE),
|
32 * USBAUDIO_PACKET_SIZE),
|
||||||
|
@ -33,6 +33,7 @@ extern const PropertyInfo qdev_prop_blocksize;
|
|||||||
extern const PropertyInfo qdev_prop_pci_host_devaddr;
|
extern const PropertyInfo qdev_prop_pci_host_devaddr;
|
||||||
extern const PropertyInfo qdev_prop_uuid;
|
extern const PropertyInfo qdev_prop_uuid;
|
||||||
extern const PropertyInfo qdev_prop_arraylen;
|
extern const PropertyInfo qdev_prop_arraylen;
|
||||||
|
extern const PropertyInfo qdev_prop_audiodev;
|
||||||
extern const PropertyInfo qdev_prop_link;
|
extern const PropertyInfo qdev_prop_link;
|
||||||
extern const PropertyInfo qdev_prop_off_auto_pcibar;
|
extern const PropertyInfo qdev_prop_off_auto_pcibar;
|
||||||
extern const PropertyInfo qdev_prop_pcie_link_speed;
|
extern const PropertyInfo qdev_prop_pcie_link_speed;
|
||||||
@ -234,6 +235,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width;
|
|||||||
+ type_check(QemuUUID, typeof_field(_state, _field)), \
|
+ type_check(QemuUUID, typeof_field(_state, _field)), \
|
||||||
.set_default = true, \
|
.set_default = true, \
|
||||||
}
|
}
|
||||||
|
#define DEFINE_PROP_AUDIODEV(_n, _s, _f) \
|
||||||
|
DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard)
|
||||||
|
|
||||||
#define DEFINE_PROP_END_OF_LIST() \
|
#define DEFINE_PROP_END_OF_LIST() \
|
||||||
{}
|
{}
|
||||||
|
Loading…
Reference in New Issue
Block a user