hw/audio: Make 'soundhw' command line option a QOM interface
cover hw/audio: Make 'soundhw' command line option a QOM interface
After looking at Gerd's "audio: deprecate -soundhw":
https://www.mail-archive.com/[email protected]/msg698818.html
I updated a patch I started some time ago.
It is unfinished due to problem with hda-intel and pcspk. I have some idea how to fix pcspk, but it invasive. I haven't looked at hda-intel yet.
Looking at Gerd series, fixing these issue might be trivial for him, so I send this patch as it, in case it helps.
Regards,
Phil.
Philippe Mathieu-Daudé (1):
hw/audio: Make 'soundhw' command line option a QOM interface
include/hw/audio/soundhw.h | 20 +++- hw/audio/ac97.c | 10 +- hw/audio/adlib.c | 13 ++- hw/audio/cs4231a.c | 13 ++- hw/audio/es1370.c | 10 +- hw/audio/gus.c | 13 ++- hw/audio/intel-hda.c | 13 ++- hw/audio/pcspk.c | 14 ++- hw/audio/sb16.c | 13 ++- hw/audio/soundhw.c | 203 ++++++++++++++++++++----------------- 10 files changed, 178 insertions(+), 144 deletions(-)
Signature · 1 line
2.21.1
RFC PATCH 1/1 hw/audio: Make 'soundhw' command line option a QOM interface
From: Philippe Mathieu-Daudé <[email protected]>
Introduce the SOUNDHW_CMDLINE_INTERFACE QOM type to replace the deprecated register_soundhw() API.
The conversion of devices calling isa_register_soundhw() / pci_register_soundhw() is easy:
- Add SOUNDHW_CMDLINE_INTERFACE to InterfaceInfo[],
- Set cmdline_name to the soundhw name, the first argument of register_soundhw()to cmdline_name,
- Remove register_soundhw() call.
soundhw.c is rewritten:
- Register the new interface type,
- Use GLib APIs
- Remove register_soundhw() functions.
As the conversion is hardly splitable, it is unfortunately written as a single patch.
---
pcspk and hda-intel are problematic, so the conversion is not finished there, code is marked /* XXX */.
--- include/hw/audio/soundhw.h | 20 +++- hw/audio/ac97.c | 10 +- hw/audio/adlib.c | 13 ++- hw/audio/cs4231a.c | 13 ++- hw/audio/es1370.c | 10 +- hw/audio/gus.c | 13 ++- hw/audio/intel-hda.c | 13 ++- hw/audio/pcspk.c | 14 ++- hw/audio/sb16.c | 13 ++- hw/audio/soundhw.c | 203 ++++++++++++++++++++----------------- 10 files changed, 178 insertions(+), 144 deletions(-)
include/hw/audio/soundhw.h +15 -5
@@ -1,13 +1,23 @@#ifndef HW_SOUNDHW_H #define HW_SOUNDHW_H -void isa_register_soundhw (const char *name,const char *descr, -int (*init_isa)(ISABus *bus)); - -void pci_register_soundhw (const char *name,const char *descr, -int (*init_pci)(PCIBus *bus)); +#include "qom/object.h" void soundhw_init (void );void select_soundhw (const char *optarg); +#define SOUNDHW_CMDLINE_INTERFACE "soundhw-deprecated" + +#define SOUNDHW_CMDLINE_CLASS (class) \ + OBJECT_CLASS_CHECK(SoundHwCmdlineClass, (class), SOUNDHW_CMDLINE_INTERFACE) + +typedef struct SoundHwCmdlineClass { +/*< private >*/ +InterfaceClass parent_class; +/*< public >*/ + +const char *cmdline_name; +bool option_used; +}SoundHwCmdlineClass ; +#endif
hw/audio/ac97.c +3 -7
@@ -1395,12 +1395,6 @@ static void ac97_exit(PCIDevice *dev)AUD_remove_card (&s->card); } -static int ac97_init (PCIBus *bus) -{ -pci_create_simple (bus,-1 ,TYPE_AC97 ); -return 0 ; -} -static Property ac97_properties[] = {DEFINE_AUDIO_PROPERTIES (AC97LinkState, card),DEFINE_PROP_END_OF_LIST (),
@@ -1410,6 +1404,7 @@ static void ac97_class_init (ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +SoundHwCmdlineClass *sk =SOUNDHW_CMDLINE_CLASS (klass); k->realize = ac97_realize; k->exit = ac97_exit;
@@ -1422,6 +1417,7 @@ static void ac97_class_init (ObjectClass *klass, void *data) dc->vmsd = &vmstate_ac97;device_class_set_props (dc, ac97_properties); dc->reset = ac97_on_reset; + sk->cmdline_name ="ac97" ; }static const TypeInfo ac97_info = {
@@ -1431,6 +1427,7 @@ static const TypeInfo ac97_info = { .class_init = ac97_class_init, .interfaces = (InterfaceInfo []) { {INTERFACE_CONVENTIONAL_PCI_DEVICE }, + {SOUNDHW_CMDLINE_INTERFACE }, { }, }, };
@@ -1438,7 +1435,6 @@ static const TypeInfo ac97_info = {static void ac97_register_types (void ) {type_register_static (&ac97_info); -pci_register_soundhw ("ac97" ,"Intel 82801AA AC97 Audio" , ac97_init); }type_init (ac97_register_types)
hw/audio/adlib.c +6 -7
@@ -308,11 +308,13 @@ static Property adlib_properties[] = {static void adlib_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +SoundHwCmdlineClass *sk =SOUNDHW_CMDLINE_CLASS (klass); dc->realize = adlib_realizefn;set_bit (DEVICE_CATEGORY_SOUND , dc->categories); dc->desc =ADLIB_DESC ;device_class_set_props (dc, adlib_properties); + sk->cmdline_name ="adlib" ; }static const TypeInfo adlib_info = {
@@ -320,18 +322,15 @@ static const TypeInfo adlib_info = { .parent = TYPE_ISA_DEVICE, .instance_size = sizeof (AdlibState), .class_init = adlib_class_initfn, + .interfaces = (InterfaceInfo []) { + {SOUNDHW_CMDLINE_INTERFACE }, + { }, + }, }; -static int Adlib_init (ISABus *bus) -{ -isa_create_simple (bus,TYPE_ADLIB ); -return 0 ; -} -static void adlib_register_types (void ) {type_register_static (&adlib_info); -isa_register_soundhw ("adlib" ,ADLIB_DESC , Adlib_init); }type_init (adlib_register_types)
hw/audio/cs4231a.c +6 -7
@@ -683,12 +683,6 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)AUD_register_card ("cs4231a" , &s->card); } -static int cs4231a_init (ISABus *bus) -{ -isa_create_simple (bus,TYPE_CS4231A ); -return 0 ; -} -static Property cs4231a_properties[] = {DEFINE_AUDIO_PROPERTIES (CSState, card),DEFINE_PROP_UINT32 ("iobase" , CSState, port,0x534 ),
@@ -700,6 +694,7 @@ static Property cs4231a_properties[] = {static void cs4231a_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +SoundHwCmdlineClass *sk =SOUNDHW_CMDLINE_CLASS (klass); dc->realize = cs4231a_realizefn; dc->reset = cs4231a_reset;
@@ -707,6 +702,7 @@ static void cs4231a_class_initfn (ObjectClass *klass, void *data) dc->desc ="Crystal Semiconductor CS4231A" ; dc->vmsd = &vmstate_cs4231a;device_class_set_props (dc, cs4231a_properties); + sk->cmdline_name ="cs4231a" ; }static const TypeInfo cs4231a_info = {
@@ -715,12 +711,15 @@ static const TypeInfo cs4231a_info = { .instance_size = sizeof (CSState), .instance_init = cs4231a_initfn, .class_init = cs4231a_class_initfn, + .interfaces = (InterfaceInfo []) { + {SOUNDHW_CMDLINE_INTERFACE }, + { }, + }, };static void cs4231a_register_types (void ) {type_register_static (&cs4231a_info); -isa_register_soundhw ("cs4231a" ,"CS4231A" , cs4231a_init); }type_init (cs4231a_register_types)
hw/audio/es1370.c +3 -7
@@ -881,12 +881,6 @@ static void es1370_exit(PCIDevice *dev)AUD_remove_card (&s->card); } -static int es1370_init (PCIBus *bus) -{ -pci_create_simple (bus,-1 ,TYPE_ES1370 ); -return 0 ; -} -static Property es1370_properties[] = {DEFINE_AUDIO_PROPERTIES (ES1370State, card),DEFINE_PROP_END_OF_LIST (),
@@ -896,6 +890,7 @@ static void es1370_class_init (ObjectClass *klass, void *data) {DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +SoundHwCmdlineClass *sk =SOUNDHW_CMDLINE_CLASS (klass); k->realize = es1370_realize; k->exit = es1370_exit;
@@ -909,6 +904,7 @@ static void es1370_class_init (ObjectClass *klass, void *data) dc->vmsd = &vmstate_es1370; dc->reset = es1370_on_reset;device_class_set_props (dc, es1370_properties); + sk->cmdline_name ="es1370" ; }static const TypeInfo es1370_info = {
@@ -918,6 +914,7 @@ static const TypeInfo es1370_info = { .class_init = es1370_class_init, .interfaces = (InterfaceInfo []) { {INTERFACE_CONVENTIONAL_PCI_DEVICE }, + {SOUNDHW_CMDLINE_INTERFACE }, { }, }, };
@@ -925,7 +922,6 @@ static const TypeInfo es1370_info = {static void es1370_register_types (void ) {type_register_static (&es1370_info); -pci_register_soundhw ("es1370" ,"ENSONIQ AudioPCI ES1370" , es1370_init); }type_init (es1370_register_types)
hw/audio/gus.c +6 -7
@@ -292,12 +292,6 @@ static void gus_realizefn (DeviceState *dev, Error **errp)AUD_set_active_out (s->voice,1 ); } -static int GUS_init (ISABus *bus) -{ -isa_create_simple (bus,TYPE_GUS ); -return 0 ; -} -static Property gus_properties[] = {DEFINE_AUDIO_PROPERTIES (GUSState, card),DEFINE_PROP_UINT32 ("freq" , GUSState, freq,44100 ),
@@ -310,12 +304,14 @@ static Property gus_properties[] = {static void gus_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +SoundHwCmdlineClass *sk =SOUNDHW_CMDLINE_CLASS (klass); dc->realize = gus_realizefn;set_bit (DEVICE_CATEGORY_SOUND , dc->categories); dc->desc ="Gravis Ultrasound GF1" ; dc->vmsd = &vmstate_gus;device_class_set_props (dc, gus_properties); + sk->cmdline_name ="gus" ; }static const TypeInfo gus_info = {
@@ -323,12 +319,15 @@ static const TypeInfo gus_info = { .parent = TYPE_ISA_DEVICE, .instance_size = sizeof (GUSState), .class_init = gus_class_initfn, + .interfaces = (InterfaceInfo []) { + {SOUNDHW_CMDLINE_INTERFACE }, + { }, + }, };static void gus_register_types (void ) {type_register_static (&gus_info); -isa_register_soundhw ("gus" ,"Gravis Ultrasound GF1" , GUS_init); }type_init (gus_register_types)
hw/audio/intel-hda.c +12 -1
@@ -1281,11 +1281,15 @@ static const TypeInfo intel_hda_info_ich9 = {static void hda_codec_device_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass); +SoundHwCmdlineClass *shc =SOUNDHW_CMDLINE_CLASS (klass); + k->realize = hda_codec_dev_realize; k->unrealize = hda_codec_dev_unrealize;set_bit (DEVICE_CATEGORY_SOUND , k->categories); k->bus_type =TYPE_HDA_BUS ;device_class_set_props (k, hda_props); + k->desc ="Intel HD Audio" ; + shc->cmdline_name ="hda" ; }static const TypeInfo hda_codec_device_type_info = {
@@ -1295,6 +1299,10 @@ static const TypeInfo hda_codec_device_type_info = { .abstract = true, .class_size = sizeof(HDACodecDeviceClass), .class_init = hda_codec_device_class_init, + .interfaces = (InterfaceInfo []) { + {SOUNDHW_CMDLINE_INTERFACE }, + { }, + }, };/*
@@ -1321,7 +1329,10 @@ static void intel_hda_register_types(void)type_register_static (&intel_hda_info_ich6);type_register_static (&intel_hda_info_ich9);type_register_static (&hda_codec_device_type_info); -pci_register_soundhw ("hda" ,"Intel HD Audio" , intel_hda_and_codec_init); + +if (0 ) { +intel_hda_and_codec_init (NULL );/* XXX */ + } }type_init (intel_hda_register_types)
hw/audio/pcspk.c +12 -2
@@ -112,7 +112,7 @@ static void pcspk_callback(void *opaque, int free) } } -static int pcspk_audio_init (ISABus *bus) +static int pcspk_audio_init (BusState *bus) {PCSpkState *s = pcspk_state;struct audsettings as = {PCSPK_SAMPLE_RATE ,1 ,AUDIO_FORMAT_U8 ,0 };
@@ -218,14 +218,21 @@ static Property pcspk_properties[] = {static void pcspk_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +SoundHwCmdlineClass *sk =SOUNDHW_CMDLINE_CLASS (klass); dc->realize = pcspk_realizefn;set_bit (DEVICE_CATEGORY_SOUND , dc->categories); + dc->desc ="PC speaker" ; dc->vmsd = &vmstate_spk;device_class_set_props (dc, pcspk_properties);/* Reason: realize sets global pcspk_state */ /* Reason: pit object link */ dc->user_creatable = false; + sk->cmdline_name ="pcspk" ; + +if (0 ) { +pcspk_audio_init (NULL );/* XXX */ + } }static const TypeInfo pcspk_info = {
@@ -234,11 +241,14 @@ static const TypeInfo pcspk_info = { .instance_size = sizeof(PCSpkState), .instance_init = pcspk_initfn, .class_init = pcspk_class_initfn, + .interfaces = (InterfaceInfo []) { + {SOUNDHW_CMDLINE_INTERFACE }, + { }, + }, };static void pcspk_register (void ) {type_register_static (&pcspk_info); -isa_register_soundhw ("pcspk" ,"PC speaker" , pcspk_audio_init); }type_init (pcspk_register)
hw/audio/sb16.c +6 -7
@@ -1415,12 +1415,6 @@ static void sb16_realizefn (DeviceState *dev, Error **errp)AUD_register_card ("sb16" , &s->card); } -static int SB16_init (ISABus *bus) -{ -isa_create_simple (bus,TYPE_SB16 ); -return 0 ; -} -static Property sb16_properties[] = {DEFINE_AUDIO_PROPERTIES (SB16State, card),DEFINE_PROP_UINT32 ("version" , SB16State, ver,0x0405 ),/* 4.5 */
@@ -1434,12 +1428,14 @@ static Property sb16_properties[] = {static void sb16_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +SoundHwCmdlineClass *sk =SOUNDHW_CMDLINE_CLASS (klass); dc->realize = sb16_realizefn;set_bit (DEVICE_CATEGORY_SOUND , dc->categories); dc->desc ="Creative Sound Blaster 16" ; dc->vmsd = &vmstate_sb16;device_class_set_props (dc, sb16_properties); + sk->cmdline_name ="sb16" ; }static const TypeInfo sb16_info = {
@@ -1448,12 +1444,15 @@ static const TypeInfo sb16_info = { .instance_size = sizeof (SB16State), .instance_init = sb16_initfn, .class_init = sb16_class_initfn, + .interfaces = (InterfaceInfo []) { + {SOUNDHW_CMDLINE_INTERFACE }, + { }, + }, };static void sb16_register_types (void ) {type_register_static (&sb16_info); -isa_register_soundhw ("sb16" ,"Creative Sound Blaster 16" , SB16_init); }type_init (sb16_register_types)
hw/audio/soundhw.c +109 -94
234 lines not on this page · raw message
Signature · 1 line
2.21.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
LINK aarch64-softmmu/qemu-system-aarch64../hw/audio/soundhw.o: In function `soundhw_create_entry':/tmp/qemu-test/src/hw/audio/soundhw.c:136: undefined reference to `isa_create_simple'
collect2: error: ld returned 1 exit status
make[1]: *** [qemu-system-aarch64] Error 1
make: *** [aarch64-softmmu/all] Error 2
Traceback (most recent call last):
File "./tests/docker/docker.py", line 664, in <module>
sys.exit(main())
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=5de0a0c769b044a1956d7b5dd71fa689', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-u4j0jrib/src/docker-src.2020-04-29-19.08.08.8026:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=5de0a0c769b044a1956d7b5dd71fa689
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-u4j0jrib/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 2m38.775s
user 0m8.234s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===
LINK aarch64-softmmu/qemu-system-aarch64w.exe../hw/audio/soundhw.o: In function `soundhw_create_entry':/tmp/qemu-test/src/hw/audio/soundhw.c:136: undefined reference to `isa_create_simple'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:208: qemu-system-aarch64w.exe] Error 1
make: *** [Makefile:527: aarch64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
GEN x86_64-softmmu/qemu-system-x86_64.exe
Traceback (most recent call last):
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=3da0c9d83a224670b19a0d47e227af57', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-_fqhuldy/src/docker-src.2020-04-29-19.16.21.27499:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=3da0c9d83a224670b19a0d47e227af57
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-_fqhuldy/src'
make: *** [docker-run-test-mingw@fedora] Error 2
real 2m44.609s
user 0m7.898s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]