Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/kraxel/tags/audio-20200706-pull…
Browse files Browse the repository at this point in the history
…-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>
  • Loading branch information
pm215 committed Jul 8, 2020
2 parents cd95576 + 2336172 commit 8796c64
Show file tree
Hide file tree
Showing 24 changed files with 121 additions and 79 deletions.
9 changes: 9 additions & 0 deletions docs/system/deprecated.rst
Expand Up @@ -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)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''

Expand Down
13 changes: 12 additions & 1 deletion docs/system/target-i386-desc.rst.inc
Expand Up @@ -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.

Expand All @@ -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:

Expand All @@ -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>
9 changes: 2 additions & 7 deletions hw/audio/ac97.c
Expand Up @@ -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 (),
Expand Down Expand Up @@ -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)
8 changes: 1 addition & 7 deletions hw/audio/adlib.c
Expand Up @@ -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)
8 changes: 1 addition & 7 deletions hw/audio/cs4231a.c
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
9 changes: 2 additions & 7 deletions hw/audio/es1370.c
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
8 changes: 1 addition & 7 deletions hw/audio/gus.c
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
3 changes: 3 additions & 0 deletions hw/audio/intel-hda.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down
26 changes: 22 additions & 4 deletions hw/audio/pcspk.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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(),
};
Expand All @@ -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)
9 changes: 2 additions & 7 deletions hw/audio/sb16.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
24 changes: 23 additions & 1 deletion hw/audio/soundhw.c
Expand Up @@ -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"
Expand All @@ -32,6 +33,7 @@
struct soundhw {
const char *name;
const char *descr;
const char *typename;
int enabled;
int isa;
union {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions hw/i386/pc.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions hw/i386/pc_piix.c
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions hw/i386/pc_q35.c
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion hw/isa/i82378.c
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion hw/mips/jazz.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 8796c64

Please sign in to comment.