diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-06-06 12:47:37 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-06-06 12:47:37 +0100 |
commit | 8625c3ffc883e8b5bcac345fa7ac5e9fec6fb593 (patch) | |
tree | f809b98d8e18a5aa4f59d0e21fb4574f8dc2bd76 | |
parent | b0491a1a17de0a32e2bc6a5ab2d79a657f8cb53e (diff) | |
parent | 07b9098dfca4209ea1fca3cb26297164fcb4ae3c (diff) |
Merge remote-tracking branch 'remotes/kraxel/tags/pull-audio-20160606-1' into staging
audio: pa volume fix, some qomifying.
# gpg: Signature made Mon 06 Jun 2016 08:01:21 BST
# gpg: using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
* remotes/kraxel/tags/pull-audio-20160606-1:
hw/audio: QOM'ify milkymist-ac97.c
hw/audio: QOM'ify intel-hda
hw/audio: QOM cleanup for intel-hda
hw/audio: QOM'ify cs4231.c
audio: pa: Set volume of recording stream instead of recording device
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | audio/paaudio.c | 11 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | hw/audio/cs4231.c | 12 | ||||
-rw-r--r-- | hw/audio/intel-hda.c | 32 | ||||
-rw-r--r-- | hw/audio/milkymist-ac97.c | 26 |
5 files changed, 45 insertions, 40 deletions
diff --git a/audio/paaudio.c b/audio/paaudio.c index 57678e72e1..65beb6f010 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -781,23 +781,22 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...) pa_threaded_mainloop_lock (g->mainloop); - /* FIXME: use the upcoming "set_source_output_{volume,mute}" */ - op = pa_context_set_source_volume_by_index (g->context, - pa_stream_get_device_index (pa->stream), + op = pa_context_set_source_output_volume (g->context, + pa_stream_get_index (pa->stream), &v, NULL, NULL); if (!op) { qpa_logerr (pa_context_errno (g->context), - "set_source_volume() failed\n"); + "set_source_output_volume() failed\n"); } else { pa_operation_unref(op); } - op = pa_context_set_source_mute_by_index (g->context, + op = pa_context_set_source_output_mute (g->context, pa_stream_get_index (pa->stream), sw->vol.mute, NULL, NULL); if (!op) { qpa_logerr (pa_context_errno (g->context), - "set_source_mute() failed\n"); + "set_source_output_mute() failed\n"); } else { pa_operation_unref (op); } @@ -2813,8 +2813,8 @@ for drv in $audio_drv_list; do ;; pa) - audio_drv_probe $drv pulse/mainloop.h "-lpulse" \ - "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;" + audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \ + "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;" libs_softmmu="-lpulse $libs_softmmu" audio_pt_int="yes" ;; diff --git a/hw/audio/cs4231.c b/hw/audio/cs4231.c index caf97c1692..30690f96ae 100644 --- a/hw/audio/cs4231.c +++ b/hw/audio/cs4231.c @@ -145,16 +145,15 @@ static const VMStateDescription vmstate_cs4231 = { } }; -static int cs4231_init1(SysBusDevice *dev) +static void cs4231_init(Object *obj) { - CSState *s = CS4231(dev); + CSState *s = CS4231(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); - memory_region_init_io(&s->iomem, OBJECT(s), &cs_mem_ops, s, "cs4321", + memory_region_init_io(&s->iomem, obj, &cs_mem_ops, s, "cs4321", CS_SIZE); sysbus_init_mmio(dev, &s->iomem); sysbus_init_irq(dev, &s->irq); - - return 0; } static Property cs4231_properties[] = { @@ -164,9 +163,7 @@ static Property cs4231_properties[] = { static void cs4231_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = cs4231_init1; dc->reset = cs_reset; dc->vmsd = &vmstate_cs4231; dc->props = cs4231_properties; @@ -176,6 +173,7 @@ static const TypeInfo cs4231_info = { .name = TYPE_CS4231, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(CSState), + .instance_init = cs4231_init, .class_init = cs4231_class_init, }; diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index d372d4ab98..93d7669fb5 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -26,6 +26,7 @@ #include "intel-hda.h" #include "intel-hda-defs.h" #include "sysemu/dma.h" +#include "qapi/error.h" /* --------------------------------------------------------------------- */ /* hda bus */ @@ -50,25 +51,28 @@ void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size, bus->xfer = xfer; } -static int hda_codec_dev_init(DeviceState *qdev) +static void hda_codec_dev_realize(DeviceState *qdev, Error **errp) { - HDACodecBus *bus = DO_UPCAST(HDACodecBus, qbus, qdev->parent_bus); - HDACodecDevice *dev = DO_UPCAST(HDACodecDevice, qdev, qdev); + HDACodecBus *bus = HDA_BUS(qdev->parent_bus); + HDACodecDevice *dev = HDA_CODEC_DEVICE(qdev); HDACodecDeviceClass *cdc = HDA_CODEC_DEVICE_GET_CLASS(dev); if (dev->cad == -1) { dev->cad = bus->next_cad; } if (dev->cad >= 15) { - return -1; + error_setg(errp, "HDA audio codec address is full"); + return; } bus->next_cad = dev->cad + 1; - return cdc->init(dev); + if (cdc->init(dev) != 0) { + error_setg(errp, "HDA audio init failed"); + } } static int hda_codec_dev_exit(DeviceState *qdev) { - HDACodecDevice *dev = DO_UPCAST(HDACodecDevice, qdev, qdev); + HDACodecDevice *dev = HDA_CODEC_DEVICE(qdev); HDACodecDeviceClass *cdc = HDA_CODEC_DEVICE_GET_CLASS(dev); if (cdc->exit) { @@ -84,7 +88,7 @@ HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad) QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { DeviceState *qdev = kid->child; - cdev = DO_UPCAST(HDACodecDevice, qdev, qdev); + cdev = HDA_CODEC_DEVICE(qdev); if (cdev->cad == cad) { return cdev; } @@ -94,14 +98,14 @@ HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad) void hda_codec_response(HDACodecDevice *dev, bool solicited, uint32_t response) { - HDACodecBus *bus = DO_UPCAST(HDACodecBus, qbus, dev->qdev.parent_bus); + HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus); bus->response(dev, solicited, response); } bool hda_codec_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, uint8_t *buf, uint32_t len) { - HDACodecBus *bus = DO_UPCAST(HDACodecBus, qbus, dev->qdev.parent_bus); + HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus); return bus->xfer(dev, stnr, output, buf, len); } @@ -337,7 +341,7 @@ static void intel_hda_corb_run(IntelHDAState *d) static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t response) { - HDACodecBus *bus = DO_UPCAST(HDACodecBus, qbus, dev->qdev.parent_bus); + HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus); IntelHDAState *d = container_of(bus, IntelHDAState, codecs); hwaddr addr; uint32_t wp, ex; @@ -386,7 +390,7 @@ static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t res static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, uint8_t *buf, uint32_t len) { - HDACodecBus *bus = DO_UPCAST(HDACodecBus, qbus, dev->qdev.parent_bus); + HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus); IntelHDAState *d = container_of(bus, IntelHDAState, codecs); hwaddr addr; uint32_t s, copy, left; @@ -493,7 +497,7 @@ static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool runn DeviceState *qdev = kid->child; HDACodecDeviceClass *cdc; - cdev = DO_UPCAST(HDACodecDevice, qdev, qdev); + cdev = HDA_CODEC_DEVICE(qdev); cdc = HDA_CODEC_DEVICE_GET_CLASS(cdev); if (cdc->stream) { cdc->stream(cdev, stream, running, output); @@ -1120,7 +1124,7 @@ static void intel_hda_reset(DeviceState *dev) /* reset codecs */ QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) { DeviceState *qdev = kid->child; - cdev = DO_UPCAST(HDACodecDevice, qdev, qdev); + cdev = HDA_CODEC_DEVICE(qdev); device_reset(DEVICE(cdev)); d->state_sts |= (1 << cdev->cad); } @@ -1298,7 +1302,7 @@ static const TypeInfo intel_hda_info_ich9 = { static void hda_codec_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); - k->init = hda_codec_dev_init; + k->realize = hda_codec_dev_realize; k->exit = hda_codec_dev_exit; set_bit(DEVICE_CATEGORY_SOUND, k->categories); k->bus_type = TYPE_HDA_BUS; diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index 6a3b53674e..5075c2b148 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -284,16 +284,26 @@ static int ac97_post_load(void *opaque, int version_id) return 0; } -static int milkymist_ac97_init(SysBusDevice *dev) +static void milkymist_ac97_init(Object *obj) { - MilkymistAC97State *s = MILKYMIST_AC97(dev); + MilkymistAC97State *s = MILKYMIST_AC97(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); - struct audsettings as; sysbus_init_irq(dev, &s->crrequest_irq); sysbus_init_irq(dev, &s->crreply_irq); sysbus_init_irq(dev, &s->dmar_irq); sysbus_init_irq(dev, &s->dmaw_irq); + memory_region_init_io(&s->regs_region, obj, &ac97_mmio_ops, s, + "milkymist-ac97", R_MAX * 4); + sysbus_init_mmio(dev, &s->regs_region); +} + +static void milkymist_ac97_realize(DeviceState *dev, Error **errp) +{ + MilkymistAC97State *s = MILKYMIST_AC97(dev); + struct audsettings as; + AUD_register_card("Milkymist AC'97", &s->card); as.freq = 48000; @@ -305,12 +315,6 @@ static int milkymist_ac97_init(SysBusDevice *dev) "mm_ac97.in", s, ac97_in_cb, &as); s->voice_out = AUD_open_out(&s->card, s->voice_out, "mm_ac97.out", s, ac97_out_cb, &as); - - memory_region_init_io(&s->regs_region, OBJECT(s), &ac97_mmio_ops, s, - "milkymist-ac97", R_MAX * 4); - sysbus_init_mmio(dev, &s->regs_region); - - return 0; } static const VMStateDescription vmstate_milkymist_ac97 = { @@ -327,9 +331,8 @@ static const VMStateDescription vmstate_milkymist_ac97 = { static void milkymist_ac97_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = milkymist_ac97_init; + dc->realize = milkymist_ac97_realize; dc->reset = milkymist_ac97_reset; dc->vmsd = &vmstate_milkymist_ac97; } @@ -338,6 +341,7 @@ static const TypeInfo milkymist_ac97_info = { .name = TYPE_MILKYMIST_AC97, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MilkymistAC97State), + .instance_init = milkymist_ac97_init, .class_init = milkymist_ac97_class_init, }; |