diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/audio/Makefile.objs | 2 | ||||
-rw-r--r-- | hw/audio/ac97.c | 2 | ||||
-rw-r--r-- | hw/audio/adlib.c | 2 | ||||
-rw-r--r-- | hw/audio/cs4231a.c | 2 | ||||
-rw-r--r-- | hw/audio/es1370.c | 2 | ||||
-rw-r--r-- | hw/audio/gus.c | 2 | ||||
-rw-r--r-- | hw/audio/intel-hda.c | 2 | ||||
-rw-r--r-- | hw/audio/pcspk.c | 2 | ||||
-rw-r--r-- | hw/audio/sb16.c | 2 | ||||
-rw-r--r-- | hw/audio/soundhw.c | 156 | ||||
-rw-r--r-- | hw/i386/pc_q35.c | 1 | ||||
-rw-r--r-- | hw/ppc/prep.c | 3 | ||||
-rw-r--r-- | hw/virtio/vhost-user.c | 1 | ||||
-rw-r--r-- | hw/virtio/vhost-vsock.c | 1 | ||||
-rw-r--r-- | hw/virtio/virtio.c | 1 |
15 files changed, 168 insertions, 13 deletions
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs index bb6f07a91e..63db383709 100644 --- a/hw/audio/Makefile.objs +++ b/hw/audio/Makefile.objs @@ -14,3 +14,5 @@ common-obj-$(CONFIG_PL041) += pl041.o lm4549.o common-obj-$(CONFIG_CS4231) += cs4231.o common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o + +common-obj-y += soundhw.o diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index c30657501c..959c786261 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -19,7 +19,7 @@ #include "qemu/osdep.h" #include "hw/hw.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" #include "hw/pci/pci.h" #include "sysemu/dma.h" diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index 09b8248cda..c6e0f10c16 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/hw.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" #include "hw/isa/isa.h" diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 3ecd0582bf..096e8e98d7 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -23,7 +23,7 @@ */ #include "qemu/osdep.h" #include "hw/hw.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" #include "hw/isa/isa.h" #include "hw/qdev.h" diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index fe64c1ac37..dd7c23d185 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -28,7 +28,7 @@ #include "qemu/osdep.h" #include "hw/hw.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" #include "hw/pci/pci.h" #include "sysemu/dma.h" diff --git a/hw/audio/gus.c b/hw/audio/gus.c index ec103a4db9..3e864cd36d 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -24,7 +24,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/hw.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" #include "hw/isa/isa.h" #include "gusemu.h" diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 2c497eb174..06acc98f7b 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -22,7 +22,7 @@ #include "hw/pci/pci.h" #include "hw/pci/msi.h" #include "qemu/timer.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "intel-hda.h" #include "intel-hda-defs.h" #include "sysemu/dma.h" diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 9b99358d87..f643b122bb 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -26,7 +26,7 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" #include "qemu/timer.h" #include "hw/timer/i8254.h" diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 6b4427f242..6ab2f6f89a 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -23,7 +23,7 @@ */ #include "qemu/osdep.h" #include "hw/hw.h" -#include "hw/audio/audio.h" +#include "hw/audio/soundhw.h" #include "audio/audio.h" #include "hw/isa/isa.h" #include "hw/qdev.h" diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c new file mode 100644 index 0000000000..e698909d34 --- /dev/null +++ b/hw/audio/soundhw.c @@ -0,0 +1,156 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/help_option.h" +#include "qemu/error-report.h" +#include "qom/object.h" +#include "hw/isa/isa.h" +#include "hw/pci/pci.h" +#include "hw/audio/soundhw.h" + +struct soundhw { + const char *name; + const char *descr; + int enabled; + int isa; + union { + int (*init_isa) (ISABus *bus); + int (*init_pci) (PCIBus *bus); + } init; +}; + +static struct soundhw soundhw[9]; +static int soundhw_count; + +void isa_register_soundhw(const char *name, const char *descr, + int (*init_isa)(ISABus *bus)) +{ + assert(soundhw_count < ARRAY_SIZE(soundhw) - 1); + soundhw[soundhw_count].name = name; + soundhw[soundhw_count].descr = descr; + soundhw[soundhw_count].isa = 1; + soundhw[soundhw_count].init.init_isa = init_isa; + soundhw_count++; +} + +void pci_register_soundhw(const char *name, const char *descr, + int (*init_pci)(PCIBus *bus)) +{ + assert(soundhw_count < ARRAY_SIZE(soundhw) - 1); + soundhw[soundhw_count].name = name; + soundhw[soundhw_count].descr = descr; + soundhw[soundhw_count].isa = 0; + soundhw[soundhw_count].init.init_pci = init_pci; + soundhw_count++; +} + +void select_soundhw(const char *optarg) +{ + struct soundhw *c; + + if (is_help_option(optarg)) { + show_valid_cards: + + if (soundhw_count) { + printf("Valid sound card names (comma separated):\n"); + for (c = soundhw; c->name; ++c) { + printf ("%-11s %s\n", c->name, c->descr); + } + printf("\n-soundhw all will enable all of the above\n"); + } else { + printf("Machine has no user-selectable audio hardware " + "(it may or may not have always-present audio hardware).\n"); + } + exit(!is_help_option(optarg)); + } + else { + size_t l; + const char *p; + char *e; + int bad_card = 0; + + if (!strcmp(optarg, "all")) { + for (c = soundhw; c->name; ++c) { + c->enabled = 1; + } + return; + } + + p = optarg; + while (*p) { + e = strchr(p, ','); + l = !e ? strlen(p) : (size_t) (e - p); + + for (c = soundhw; c->name; ++c) { + if (!strncmp(c->name, p, l) && !c->name[l]) { + c->enabled = 1; + break; + } + } + + if (!c->name) { + if (l > 80) { + error_report("Unknown sound card name (too big to show)"); + } + else { + error_report("Unknown sound card name `%.*s'", + (int) l, p); + } + bad_card = 1; + } + p += l + (e != NULL); + } + + if (bad_card) { + goto show_valid_cards; + } + } +} + +void soundhw_init(void) +{ + struct soundhw *c; + ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL); + PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, NULL); + + for (c = soundhw; c->name; ++c) { + if (c->enabled) { + if (c->isa) { + if (!isa_bus) { + error_report("ISA bus not available for %s", c->name); + exit(1); + } + c->init.init_isa(isa_bus); + } else { + if (!pci_bus) { + error_report("PCI bus not available for %s", c->name); + exit(1); + } + c->init.init_pci(pci_bus); + } + } + } +} + diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index f243203844..1523ef39e1 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -46,7 +46,6 @@ #include "hw/ide/ahci.h" #include "hw/usb.h" #include "qemu/error-report.h" -#include "migration/migration.h" #include "sysemu/numa.h" /* ICH9 AHCI has 6 ports */ diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 961230c569..d16646c95d 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -36,6 +36,7 @@ #include "hw/pci/pci_host.h" #include "hw/ppc/ppc.h" #include "hw/boards.h" +#include "hw/audio/soundhw.h" #include "qemu/error-report.h" #include "qemu/log.h" #include "hw/ide.h" @@ -782,7 +783,7 @@ static void ibm_40p_init(MachineState *machine) &cmos_checksum); /* initialize audio subsystem */ - audio_init(); + soundhw_init(); /* add some more devices */ if (defaults_enabled()) { diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 32a95a8c69..b87a176770 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -17,7 +17,6 @@ #include "sysemu/kvm.h" #include "qemu/error-report.h" #include "qemu/sockets.h" -#include "migration/migration.h" #include <sys/ioctl.h> #include <sys/socket.h> diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index b4815629e1..49e0022533 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -17,7 +17,6 @@ #include "qapi/error.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" -#include "migration/migration.h" #include "qemu/error-report.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 890b4d7eb7..f99d99fd78 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -21,7 +21,6 @@ #include "hw/virtio/virtio.h" #include "qemu/atomic.h" #include "hw/virtio/virtio-bus.h" -#include "migration/migration.h" #include "hw/virtio/virtio-access.h" #include "sysemu/dma.h" |