audio: qom cleanups.

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJb1w0FAAoJEEy22O7T6HE4umAP/3KJVWPdG/92Kle06wX1Zj7q
 6h9a3065KKPpQfxjjKiTvkKAHon4jRjbH3iq9Td/6DNNPTei9dJZuF9+UyoiI3rz
 RfC9LTHiCIZV6PvojDc0WxoQwLTEGtQE1OVo4qLdZgnGC8lwWpS3Tj8oivA4hf5Q
 QR0IMaHWOQJXpwckLj4n/6J2giFXlLcBq24D/lskY67JCi0giXNgw91yaSh5gLRU
 ZVeadi+iClv6iUtnThqDtLJwabHWUeKryKNEdSlRtbZ8oIuJPwbGgdK2y24buE/a
 GB+TfkJzKk8LWXwCoqr1co2S+2fssuP2IphCS7v7W4zcT4ZWFa35czP55MqdqKIC
 LwS56aGmVPsatfZsK978Hp5cPIi1uvM/NBSFJS7zZ6zKXoUqHNr3WickwS6DOeWp
 8Ixcsl1t5dFuEWevNB8UXsk8FXpDkLKBaIlWQHr2nEy3g0qa7w64VZ1Rm0/Ajmou
 m6cYiNRqoGpqvlz25KOvkFJ4Q0vLATFmULF2qVUYH+ocFxarwKou3wt1WRPP5qnr
 4gvEnAy8D2VtLWKP9dVg/RGkd5WeQv9dnzjfUeQOKeXCBkz+dEotQYVZvcauAyMe
 L7TUgwhWlZDaS1nMPZ/Gsy4Kib+Vv3ljH1lOvTO2mkbV5XcgHSd/hECPF0kYIvVN
 OOOMqgXP/4bVM1oKUIgm
 =nOQe
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/audio-20181029-pull-request' into staging

audio: qom cleanups.

# gpg: Signature made Mon 29 Oct 2018 13:37:09 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# 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>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/audio-20181029-pull-request:
  audio: use TYPE_MV88W8618_AUDIO instead of hardcoded string
  audio: use object link instead of qdev property to pass wm8750 reference
  audio: use TYPE_WM8750 instead of a hardcoded string
  hw: AC97: make it more QOMconventional

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-10-29 15:15:14 +00:00
commit db7069133e
4 changed files with 18 additions and 14 deletions

View File

@ -1693,9 +1693,10 @@ static void musicpal_init(MachineState *machine)
}
wm8750_dev = i2c_create_slave(i2c, TYPE_WM8750, MP_WM_ADDR);
dev = qdev_create(NULL, "mv88w8618_audio");
dev = qdev_create(NULL, TYPE_MV88W8618_AUDIO);
s = SYS_BUS_DEVICE(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
object_property_set_link(OBJECT(dev), OBJECT(wm8750_dev),
TYPE_WM8750, NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);

View File

@ -123,6 +123,10 @@ enum {
#define MUTE_SHIFT 15
#define TYPE_AC97 "AC97"
#define AC97(obj) \
OBJECT_CHECK(AC97LinkState, (obj), TYPE_AC97)
#define REC_MASK 7
enum {
REC_MIC = 0,
@ -1340,7 +1344,7 @@ static void ac97_on_reset (DeviceState *dev)
static void ac97_realize(PCIDevice *dev, Error **errp)
{
AC97LinkState *s = DO_UPCAST (AC97LinkState, dev, dev);
AC97LinkState *s = AC97(dev);
uint8_t *c = s->dev.config;
/* TODO: no need to override */
@ -1389,7 +1393,7 @@ static void ac97_realize(PCIDevice *dev, Error **errp)
static void ac97_exit(PCIDevice *dev)
{
AC97LinkState *s = DO_UPCAST(AC97LinkState, dev, dev);
AC97LinkState *s = AC97(dev);
AUD_close_in(&s->card, s->voice_pi);
AUD_close_out(&s->card, s->voice_po);
@ -1399,7 +1403,7 @@ static void ac97_exit(PCIDevice *dev)
static int ac97_init (PCIBus *bus)
{
pci_create_simple (bus, -1, "AC97");
pci_create_simple(bus, -1, TYPE_AC97);
return 0;
}
@ -1427,7 +1431,7 @@ static void ac97_class_init (ObjectClass *klass, void *data)
}
static const TypeInfo ac97_info = {
.name = "AC97",
.name = TYPE_AC97,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof (AC97LinkState),
.class_init = ac97_class_init,

View File

@ -15,6 +15,7 @@
#include "hw/i2c/i2c.h"
#include "hw/audio/wm8750.h"
#include "audio/audio.h"
#include "qapi/error.h"
#define MP_AUDIO_SIZE 0x00001000
@ -38,7 +39,6 @@
#define MP_AUDIO_CLOCK_24MHZ (1 << 9)
#define MP_AUDIO_MONO (1 << 14)
#define TYPE_MV88W8618_AUDIO "mv88w8618_audio"
#define MV88W8618_AUDIO(obj) \
OBJECT_CHECK(mv88w8618_audio_state, (obj), TYPE_MV88W8618_AUDIO)
@ -252,6 +252,11 @@ static void mv88w8618_audio_init(Object *obj)
memory_region_init_io(&s->iomem, obj, &mv88w8618_audio_ops, s,
"audio", MP_AUDIO_SIZE);
sysbus_init_mmio(dev, &s->iomem);
object_property_add_link(OBJECT(dev), "wm8750", TYPE_WM8750,
(Object **) &s->wm,
qdev_prop_allow_set_link_before_realize,
0, &error_abort);
}
static void mv88w8618_audio_realize(DeviceState *dev, Error **errp)
@ -279,11 +284,6 @@ static const VMStateDescription mv88w8618_audio_vmsd = {
}
};
static Property mv88w8618_audio_properties[] = {
DEFINE_PROP_PTR("wm8750", mv88w8618_audio_state, wm),
{/* end of list */},
};
static void mv88w8618_audio_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@ -291,8 +291,6 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data)
dc->realize = mv88w8618_audio_realize;
dc->reset = mv88w8618_audio_reset;
dc->vmsd = &mv88w8618_audio_vmsd;
dc->props = mv88w8618_audio_properties;
/* Reason: pointer property "wm8750" */
dc->user_creatable = false;
}

View File

@ -17,6 +17,7 @@
#include "hw/hw.h"
#define TYPE_WM8750 "wm8750"
#define TYPE_MV88W8618_AUDIO "mv88w8618_audio"
typedef void data_req_cb(void *opaque, int free_out, int free_in);