audio: deprecate -soundhw

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABCgAGBQJfA3uDAAoJEEy22O7T6HE4sfEQAIF5gEmYirMMZWeh57XxlxJ8
 AftJphRGIY3XaBZOWkTEX6K7SCMqslFbDH6orqHc6ca1O/70azwTmh3EwI3dqKp2
 OuEUx79iqwWi1nfkDzZtEziUyPuMH06CsjOP6CMPIP/gM+oawa0ocaci4r8o6TCQ
 zkifggGFMFvWjY9+ESeiDjH0bDAshh54VcB/b4zy8HQ/Wt52b7JshMiK4FDnG+Ci
 kDcPIzolH4yA5M4HR9IUJ314Yq+Xmx7YF6VzfZkTbX+oyepz1zFkr3CdW2sPn948
 6JfHlkGbsVGzbD0nXZUuE1m9j6iFMqPXOifersLZc9XJVpEfgRIVp3znl6bwki8m
 MOjpsXiLRUyUxd7KswTuABz5QrkrGs4pLsvky04vKBQVJyZIHjApOgPaMfOuVzMC
 0i/mN+37O0aTwU6IQCYMnqhXj3l79Wt3ZhD54nZl0Nt+8tlDEsnMj63zc3eF/qqp
 cYGxetJnG/73CPogdjxlH4z0GRBS4adn/kTjLQnRQCy1tCyKMNHYhy9MXO34JcjL
 4TWVVg45AnqHLJ9nSRS3ErOaoQN36p+sR28VVZ3dqJTvN69ErQx1LWCiA/Z7CeaR
 cKv8HHE+AcrOFZkxLyYhQsltuqZWCILsrWBvLvfwtfWP4BCbQndmwefVUVo295Ak
 +K7H1hAAEVtd8OJeyFek
 =oMK8
 -----END PGP SIGNATURE-----

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

audio: deprecate -soundhw

# gpg: Signature made Mon 06 Jul 2020 20:29:07 BST
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/audio-20200706-pull-request:
  audio: set default value for pcspk.iobase property
  pcspk: update docs/system/target-i386-desc.rst.inc
  audio: add soundhw deprecation notice
  audio: deprecate -soundhw pcspk
  audio: create pcspk device early
  audio: rework pcspk_init()
  softmmu: initialize spice and audio earlier
  pc_basic_device_init: drop no_vmport arg
  pc_basic_device_init: drop has_pit arg
  pc_basic_device_init: pass PCMachineState
  audio: deprecate -soundhw hda
  audio: deprecate -soundhw sb16
  audio: deprecate -soundhw gus
  audio: deprecate -soundhw cs4231a
  audio: deprecate -soundhw adlib
  audio: deprecate -soundhw es1370
  audio: deprecate -soundhw ac97
  audio: add deprecated_register_soundhw
  stubs: add pci_create_simple
  stubs: add isa_create_simple

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-07-08 16:33:59 +01:00
commit 8796c64ecd
24 changed files with 121 additions and 79 deletions

View File

@ -82,6 +82,15 @@ should specify an ``audiodev=`` property. Additionally, when using
vnc, you should specify an ``audiodev=`` propery if you plan to
transmit audio through the VNC protocol.
Creating sound card devices using ``-soundhw`` (since 5.1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sound card devices should be created using ``-device`` instead. The
names are the same for most devices. The exceptions are ``hda`` which
needs two devices (``-device intel-hda -device hda-duplex``) and
``pcspk`` which can be activated using ``-machine
pcspk-audiodev=<name>``.
``-mon ...,control=readline,pretty=on|off`` (since 4.1)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''

View File

@ -31,6 +31,8 @@ The QEMU PC System emulator simulates the following peripherals:
- CS4231A compatible sound card
- PC speaker
- PCI UHCI, OHCI, EHCI or XHCI USB controller and a virtual USB-1.1
hub.
@ -49,7 +51,7 @@ must be told to not have parallel ports to have working GUS.
.. parsed-literal::
|qemu_system_x86| dos.img -soundhw gus -parallel none
|qemu_system_x86| dos.img -device gus -parallel none
Alternatively:
@ -60,3 +62,12 @@ Alternatively:
Or some other unclaimed IRQ.
CS4231A is the chip used in Windows Sound System and GUSMAX products
The PC speaker audio device can be configured using the pcspk-audiodev
machine property, i.e.
.. parsed-literal::
|qemu_system_x86| some.img \
-audiodev <backend>,id=<name> \
-machine pcspk-audiodev=<name>

View File

@ -1393,12 +1393,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 (),
@ -1436,7 +1430,8 @@ 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);
deprecated_register_soundhw("ac97", "Intel 82801AA AC97 Audio",
0, TYPE_AC97);
}
type_init (ac97_register_types)

View File

@ -319,16 +319,10 @@ static const TypeInfo adlib_info = {
.class_init = adlib_class_initfn,
};
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);
deprecated_register_soundhw("adlib", ADLIB_DESC, 1, TYPE_ADLIB);
}
type_init (adlib_register_types)

View File

@ -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),
@ -720,7 +714,7 @@ static const TypeInfo cs4231a_info = {
static void cs4231a_register_types (void)
{
type_register_static (&cs4231a_info);
isa_register_soundhw("cs4231a", "CS4231A", cs4231a_init);
deprecated_register_soundhw("cs4231a", "CS4231A", 1, TYPE_CS4231A);
}
type_init (cs4231a_register_types)

View File

@ -884,12 +884,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(),
@ -928,7 +922,8 @@ 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);
deprecated_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370",
0, TYPE_ES1370);
}
type_init (es1370_register_types)

View File

@ -286,12 +286,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),
@ -322,7 +316,7 @@ static const TypeInfo gus_info = {
static void gus_register_types (void)
{
type_register_static (&gus_info);
isa_register_soundhw("gus", "Gravis Ultrasound GF1", GUS_init);
deprecated_register_soundhw("gus", "Gravis Ultrasound GF1", 1, TYPE_GUS);
}
type_init (gus_register_types)

View File

@ -25,6 +25,7 @@
#include "qemu/bitops.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qemu/error-report.h"
#include "hw/audio/soundhw.h"
#include "intel-hda.h"
#include "migration/vmstate.h"
@ -1307,6 +1308,8 @@ static int intel_hda_and_codec_init(PCIBus *bus)
BusState *hdabus;
DeviceState *codec;
warn_report("'-soundhw hda' is deprecated, "
"please use '-device intel-hda -device hda-duplex' instead");
controller = DEVICE(pci_create_simple(bus, -1, "intel-hda"));
hdabus = QLIST_FIRST(&controller->child_bus);
codec = qdev_new("hda-duplex");

View File

@ -28,6 +28,7 @@
#include "audio/audio.h"
#include "qemu/module.h"
#include "qemu/timer.h"
#include "qemu/error-report.h"
#include "hw/timer/i8254.h"
#include "migration/vmstate.h"
#include "hw/audio/pcspk.h"
@ -112,11 +113,15 @@ static void pcspk_callback(void *opaque, int free)
}
}
static int pcspk_audio_init(ISABus *bus)
static int pcspk_audio_init(PCSpkState *s)
{
PCSpkState *s = pcspk_state;
struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUDIO_FORMAT_U8, 0};
if (s->voice) {
/* already initialized */
return 0;
}
AUD_register_card(s_spk, &s->card);
s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
@ -185,6 +190,10 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
isa_register_ioport(isadev, &s->ioport, s->iobase);
if (s->card.state) {
pcspk_audio_init(s);
}
pcspk_state = s;
}
@ -210,7 +219,7 @@ static const VMStateDescription vmstate_spk = {
static Property pcspk_properties[] = {
DEFINE_AUDIO_PROPERTIES(PCSpkState, card),
DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, -1),
DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, 0x61),
DEFINE_PROP_BOOL("migrate", PCSpkState, migrate, true),
DEFINE_PROP_END_OF_LIST(),
};
@ -236,9 +245,18 @@ static const TypeInfo pcspk_info = {
.class_init = pcspk_class_initfn,
};
static int pcspk_audio_init_soundhw(ISABus *bus)
{
PCSpkState *s = pcspk_state;
warn_report("'-soundhw pcspk' is deprecated, "
"please set a backend using '-machine pcspk-audiodev=<name>' instead");
return pcspk_audio_init(s);
}
static void pcspk_register(void)
{
type_register_static(&pcspk_info);
isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init);
isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init_soundhw);
}
type_init(pcspk_register)

View File

@ -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 */
@ -1453,7 +1447,8 @@ static const TypeInfo sb16_info = {
static void sb16_register_types (void)
{
type_register_static (&sb16_info);
isa_register_soundhw("sb16", "Creative Sound Blaster 16", SB16_init);
deprecated_register_soundhw("sb16", "Creative Sound Blaster 16",
1, TYPE_SB16);
}
type_init (sb16_register_types)

View File

@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
#include "qemu/option.h"
#include "qemu/help_option.h"
#include "qemu/error-report.h"
#include "qom/object.h"
@ -32,6 +33,7 @@
struct soundhw {
const char *name;
const char *descr;
const char *typename;
int enabled;
int isa;
union {
@ -65,6 +67,17 @@ void pci_register_soundhw(const char *name, const char *descr,
soundhw_count++;
}
void deprecated_register_soundhw(const char *name, const char *descr,
int isa, const char *typename)
{
assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
soundhw[soundhw_count].name = name;
soundhw[soundhw_count].descr = descr;
soundhw[soundhw_count].isa = isa;
soundhw[soundhw_count].typename = typename;
soundhw_count++;
}
void select_soundhw(const char *optarg)
{
struct soundhw *c;
@ -136,7 +149,16 @@ void soundhw_init(void)
for (c = soundhw; c->name; ++c) {
if (c->enabled) {
if (c->isa) {
if (c->typename) {
warn_report("'-soundhw %s' is deprecated, "
"please use '-device %s' instead",
c->name, c->typename);
if (c->isa) {
isa_create_simple(isa_bus, c->typename);
} else {
pci_create_simple(pci_bus, -1, c->typename);
}
} else if (c->isa) {
if (!isa_bus) {
error_report("ISA bus not available for %s", c->name);
exit(1);

View File

@ -1156,11 +1156,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
g_free(a20_line);
}
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
void pc_basic_device_init(struct PCMachineState *pcms,
ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
bool create_fdctrl,
bool no_vmport,
bool has_pit,
uint32_t hpet_irqs)
{
int i;
@ -1211,7 +1210,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
qemu_register_boot_set(pc_boot_set, *rtc_state);
if (!xen_enabled() && has_pit) {
if (!xen_enabled() && pcms->pit_enabled) {
if (kvm_pit_in_kernel()) {
pit = kvm_pit_init(isa_bus, 0x40);
} else {
@ -1221,13 +1220,13 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
/* connect PIT to output control line of the HPET */
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
pcspk_init(isa_bus, pit);
pcspk_init(pcms->pcspk, isa_bus, pit);
}
i8257_dma_init(isa_bus, 0);
/* Super I/O */
pc_superio_init(isa_bus, create_fdctrl, no_vmport);
pc_superio_init(isa_bus, create_fdctrl, pcms->vmport != ON_OFF_AUTO_ON);
}
void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
@ -1901,6 +1900,9 @@ static void pc_machine_initfn(Object *obj)
pcms->pit_enabled = true;
pc_system_flash_create(pcms);
pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
OBJECT(pcms->pcspk), "audiodev");
}
static void pc_machine_reset(MachineState *machine)

View File

@ -235,8 +235,7 @@ static void pc_init1(MachineState *machine,
}
/* init basic PC hardware */
pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, true,
(pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, true,
0x4);
pc_nic_init(pcmc, isa_bus, pci_bus);

View File

@ -275,8 +275,7 @@ static void pc_q35_init(MachineState *machine)
}
/* init basic PC hardware */
pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
(pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
0xff0104);
/* connect pm stuff to lpc */

View File

@ -102,7 +102,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
pit = i8254_pit_init(isabus, 0x40, 0, NULL);
/* speaker */
pcspk_init(isabus, pit);
pcspk_init(isa_new(TYPE_PC_SPEAKER), isabus, pit);
/* 2 82C37 (dma) */
isa_create_simple(isabus, "i82374");

View File

@ -250,7 +250,7 @@ static void mips_jazz_init(MachineState *machine,
isa_bus_irqs(isa_bus, i8259);
i8257_dma_init(isa_bus, 0);
pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
pcspk_init(isa_bus, pit);
pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
/* Video card */
switch (jazz_model) {

View File

@ -31,18 +31,10 @@
#define TYPE_PC_SPEAKER "isa-pcspk"
static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
{
DeviceState *dev;
ISADevice *isadev;
isadev = isa_new(TYPE_PC_SPEAKER);
dev = DEVICE(isadev);
qdev_prop_set_uint32(dev, "iobase", 0x61);
object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
object_property_set_link(OBJECT(isadev), OBJECT(pit), "pit", NULL);
isa_realize_and_unref(isadev, bus, &error_fatal);
return isadev;
}
#endif /* HW_PCSPK_H */

View File

@ -6,6 +6,8 @@ void isa_register_soundhw(const char *name, const char *descr,
void pci_register_soundhw(const char *name, const char *descr,
int (*init_pci)(PCIBus *bus));
void deprecated_register_soundhw(const char *name, const char *descr,
int isa, const char *typename);
void soundhw_init(void);
void select_soundhw(const char *optarg);

View File

@ -33,6 +33,7 @@ struct PCMachineState {
PCIBus *bus;
I2CBus *smbus;
PFlashCFI01 *flash[2];
ISADevice *pcspk;
/* Configuration options: */
uint64_t max_ram_below_4g;
@ -160,11 +161,10 @@ void pc_memory_init(PCMachineState *pcms,
MemoryRegion **ram_memory);
uint64_t pc_pci_hole64_start(void);
DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
void pc_basic_device_init(struct PCMachineState *pcms,
ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
bool create_fdctrl,
bool no_vmport,
bool has_pit,
uint32_t hpet_irqs);
void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
void pc_cmos_init(PCMachineState *pcms,

View File

@ -53,7 +53,9 @@ typedef struct QDevAlias
/* Please keep this table sorted by typename. */
static const QDevAlias qdev_alias_table[] = {
{ "AC97", "ac97" }, /* -soundhw name */
{ "e1000", "e1000-82540em" },
{ "ES1370", "es1370" }, /* -soundhw name */
{ "ich9-ahci", "ahci" },
{ "lsi53c895a", "lsi" },
{ "virtio-9p-ccw", "virtio-9p", QEMU_ARCH_S390X },

View File

@ -4121,12 +4121,17 @@ void qemu_init(int argc, char **argv, char **envp)
fsdev_init_func, NULL, &error_fatal);
#endif
/* spice needs the timers to be initialized by this point */
/* spice must initialize before audio as it changes the default auiodev */
qemu_spice_init();
/*
* Note: we need to create block backends before
* Note: we need to create audio and block backends before
* machine_set_property(), so machine properties can refer to
* them.
*/
configure_blockdev(&bdo_queue, machine_class, snapshot);
audio_init_audiodevs();
machine_opts = qemu_get_machine_opts();
qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
@ -4220,9 +4225,6 @@ void qemu_init(int argc, char **argv, char **envp)
semihosting_arg_fallback(kernel_filename, kernel_cmdline);
}
/* spice needs the timers to be initialized by this point */
qemu_spice_init();
cpu_ticks_init();
if (default_net) {
@ -4332,8 +4334,6 @@ void qemu_init(int argc, char **argv, char **envp)
create_default_memdev(current_machine, mem_path);
}
audio_init_audiodevs();
/* from here on runstate is RUN_STATE_PRELAUNCH */
machine_run_board_init(current_machine);

View File

@ -8,10 +8,12 @@ stub-obj-y += fdset.o
stub-obj-y += gdbstub.o
stub-obj-y += iothread-lock.o
stub-obj-y += is-daemonized.o
stub-obj-y += isa-bus.o
stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
stub-obj-y += monitor-core.o
stub-obj-y += notify-event.o
stub-obj-y += pci-bus.o
stub-obj-y += qmp_memory_device.o
stub-obj-y += qtest.o
stub-obj-y += ramfb.o

7
stubs/isa-bus.c Normal file
View File

@ -0,0 +1,7 @@
#include "qemu/osdep.h"
#include "hw/isa/isa.h"
ISADevice *isa_create_simple(ISABus *bus, const char *name)
{
g_assert_not_reached();
}

7
stubs/pci-bus.c Normal file
View File

@ -0,0 +1,7 @@
#include "qemu/osdep.h"
#include "hw/pci/pci.h"
PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
{
g_assert_not_reached();
}