audio: remove the need for audio card CONFIG_* symbols

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1366303444-24620-3-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Paolo Bonzini 2013-04-18 18:43:58 +02:00 committed by Anthony Liguori
parent 8c444a1978
commit 36cd6f6f20
13 changed files with 62 additions and 144 deletions

View File

@ -899,96 +899,30 @@ struct soundhw {
} init; } init;
}; };
static struct soundhw soundhw[] = { static struct soundhw soundhw[9];
#ifdef HAS_AUDIO_CHOICE static int soundhw_count;
#ifdef CONFIG_PCSPK
{
"pcspk",
"PC speaker",
0,
1,
{ .init_isa = pcspk_audio_init }
},
#endif
#ifdef CONFIG_SB16 void isa_register_soundhw(const char *name, const char *descr,
{ int (*init_isa)(ISABus *bus))
"sb16", {
"Creative Sound Blaster 16", assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
0, soundhw[soundhw_count].name = name;
1, soundhw[soundhw_count].descr = descr;
{ .init_isa = SB16_init } soundhw[soundhw_count].isa = 1;
}, soundhw[soundhw_count].init.init_isa = init_isa;
#endif soundhw_count++;
}
#ifdef CONFIG_CS4231A void pci_register_soundhw(const char *name, const char *descr,
{ int (*init_pci)(PCIBus *bus))
"cs4231a", {
"CS4231A", assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
0, soundhw[soundhw_count].name = name;
1, soundhw[soundhw_count].descr = descr;
{ .init_isa = cs4231a_init } soundhw[soundhw_count].isa = 0;
}, soundhw[soundhw_count].init.init_pci = init_pci;
#endif soundhw_count++;
}
#ifdef CONFIG_ADLIB
{
"adlib",
#ifdef HAS_YMF262
"Yamaha YMF262 (OPL3)",
#else
"Yamaha YM3812 (OPL2)",
#endif
0,
1,
{ .init_isa = Adlib_init }
},
#endif
#ifdef CONFIG_GUS
{
"gus",
"Gravis Ultrasound GF1",
0,
1,
{ .init_isa = GUS_init }
},
#endif
#ifdef CONFIG_AC97
{
"ac97",
"Intel 82801AA AC97 Audio",
0,
0,
{ .init_pci = ac97_init }
},
#endif
#ifdef CONFIG_ES1370
{
"es1370",
"ENSONIQ AudioPCI ES1370",
0,
0,
{ .init_pci = es1370_init }
},
#endif
#ifdef CONFIG_HDA
{
"hda",
"Intel HD Audio",
0,
0,
{ .init_pci = intel_hda_and_codec_init }
},
#endif
#endif /* HAS_AUDIO_CHOICE */
{ NULL, NULL, 0, 0, { NULL } }
};
void select_soundhw(const char *optarg) void select_soundhw(const char *optarg)
{ {
@ -997,16 +931,16 @@ void select_soundhw(const char *optarg)
if (is_help_option(optarg)) { if (is_help_option(optarg)) {
show_valid_cards: show_valid_cards:
#ifdef HAS_AUDIO_CHOICE if (soundhw_count) {
printf("Valid sound card names (comma separated):\n"); printf("Valid sound card names (comma separated):\n");
for (c = soundhw; c->name; ++c) { for (c = soundhw; c->name; ++c) {
printf ("%-11s %s\n", c->name, c->descr); 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");
} }
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");
#endif
exit(!is_help_option(optarg)); exit(!is_help_option(optarg));
} }
else { else {

8
configure vendored
View File

@ -4459,15 +4459,9 @@ esac
if test "$target_softmmu" = "yes" ; then if test "$target_softmmu" = "yes" ; then
case "$TARGET_BASE_ARCH" in case "$TARGET_BASE_ARCH" in
arm) arm|lm32|i386|mips|ppc)
cflags="-DHAS_AUDIO $cflags" cflags="-DHAS_AUDIO $cflags"
;; ;;
lm32)
cflags="-DHAS_AUDIO $cflags"
;;
i386|mips|ppc)
cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
;;
esac esac
fi fi

View File

@ -1396,7 +1396,7 @@ static void ac97_exitfn (PCIDevice *dev)
memory_region_destroy (&s->io_nabm); memory_region_destroy (&s->io_nabm);
} }
int ac97_init (PCIBus *bus) static int ac97_init (PCIBus *bus)
{ {
pci_create_simple (bus, -1, "AC97"); pci_create_simple (bus, -1, "AC97");
return 0; return 0;
@ -1433,6 +1433,7 @@ static const TypeInfo ac97_info = {
static void ac97_register_types (void) static void ac97_register_types (void)
{ {
type_register_static (&ac97_info); type_register_static (&ac97_info);
pci_register_soundhw("ac97", "Intel 82801AA AC97 Audio", ac97_init);
} }
type_init (ac97_register_types) type_init (ac97_register_types)

View File

@ -372,7 +372,7 @@ static const TypeInfo adlib_info = {
.class_init = adlib_class_initfn, .class_init = adlib_class_initfn,
}; };
int Adlib_init (ISABus *bus) static int Adlib_init (ISABus *bus)
{ {
isa_create_simple (bus, TYPE_ADLIB); isa_create_simple (bus, TYPE_ADLIB);
return 0; return 0;
@ -381,6 +381,7 @@ int Adlib_init (ISABus *bus)
static void adlib_register_types (void) static void adlib_register_types (void)
{ {
type_register_static (&adlib_info); type_register_static (&adlib_info);
isa_register_soundhw("adlib", ADLIB_DESC, Adlib_init);
} }
type_init (adlib_register_types) type_init (adlib_register_types)

View File

@ -659,7 +659,7 @@ static int cs4231a_initfn (ISADevice *dev)
return 0; return 0;
} }
int cs4231a_init (ISABus *bus) static int cs4231a_init (ISABus *bus)
{ {
isa_create_simple (bus, "cs4231a"); isa_create_simple (bus, "cs4231a");
return 0; return 0;
@ -692,6 +692,7 @@ static const TypeInfo cs4231a_info = {
static void cs4231a_register_types (void) static void cs4231a_register_types (void)
{ {
type_register_static (&cs4231a_info); type_register_static (&cs4231a_info);
isa_register_soundhw("cs4231a", "CS4231A", cs4231a_init);
} }
type_init (cs4231a_register_types) type_init (cs4231a_register_types)

View File

@ -1051,7 +1051,7 @@ static void es1370_exitfn (PCIDevice *dev)
memory_region_destroy (&s->io); memory_region_destroy (&s->io);
} }
int es1370_init (PCIBus *bus) static int es1370_init (PCIBus *bus)
{ {
pci_create_simple (bus, -1, "ES1370"); pci_create_simple (bus, -1, "ES1370");
return 0; return 0;
@ -1083,6 +1083,7 @@ static const TypeInfo es1370_info = {
static void es1370_register_types (void) static void es1370_register_types (void)
{ {
type_register_static (&es1370_info); type_register_static (&es1370_info);
pci_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370", es1370_init);
} }
type_init (es1370_register_types) type_init (es1370_register_types)

View File

@ -293,7 +293,7 @@ static int gus_initfn (ISADevice *dev)
return 0; return 0;
} }
int GUS_init (ISABus *bus) static int GUS_init (ISABus *bus)
{ {
isa_create_simple (bus, "gus"); isa_create_simple (bus, "gus");
return 0; return 0;
@ -327,6 +327,7 @@ static const TypeInfo gus_info = {
static void gus_register_types (void) static void gus_register_types (void)
{ {
type_register_static (&gus_info); type_register_static (&gus_info);
isa_register_soundhw("gus", "Gravis Ultrasound GF1", GUS_init);
} }
type_init (gus_register_types) type_init (gus_register_types)

View File

@ -1300,21 +1300,11 @@ static const TypeInfo hda_codec_device_type_info = {
.class_init = hda_codec_device_class_init, .class_init = hda_codec_device_class_init,
}; };
static void intel_hda_register_types(void)
{
type_register_static(&hda_codec_bus_info);
type_register_static(&intel_hda_info_ich6);
type_register_static(&intel_hda_info_ich9);
type_register_static(&hda_codec_device_type_info);
}
type_init(intel_hda_register_types)
/* /*
* create intel hda controller with codec attached to it, * create intel hda controller with codec attached to it,
* so '-soundhw hda' works. * so '-soundhw hda' works.
*/ */
int intel_hda_and_codec_init(PCIBus *bus) static int intel_hda_and_codec_init(PCIBus *bus)
{ {
PCIDevice *controller; PCIDevice *controller;
BusState *hdabus; BusState *hdabus;
@ -1327,3 +1317,13 @@ int intel_hda_and_codec_init(PCIBus *bus)
return 0; return 0;
} }
static void intel_hda_register_types(void)
{
type_register_static(&hda_codec_bus_info);
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);
}
type_init(intel_hda_register_types)

View File

@ -25,6 +25,7 @@
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/i386/pc.h" #include "hw/i386/pc.h"
#include "hw/isa/isa.h" #include "hw/isa/isa.h"
#include "hw/audio/audio.h"
#include "audio/audio.h" #include "audio/audio.h"
#include "qemu/timer.h" #include "qemu/timer.h"
#include "hw/timer/i8254.h" #include "hw/timer/i8254.h"
@ -108,7 +109,7 @@ static void pcspk_callback(void *opaque, int free)
} }
} }
int pcspk_audio_init(ISABus *bus) static int pcspk_audio_init(ISABus *bus)
{ {
PCSpkState *s = pcspk_state; PCSpkState *s = pcspk_state;
struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0}; struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
@ -200,5 +201,6 @@ static const TypeInfo pcspk_info = {
static void pcspk_register(void) static void pcspk_register(void)
{ {
type_register_static(&pcspk_info); type_register_static(&pcspk_info);
isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init);
} }
type_init(pcspk_register) type_init(pcspk_register)

View File

@ -1386,7 +1386,7 @@ static int sb16_initfn (ISADevice *dev)
return 0; return 0;
} }
int SB16_init (ISABus *bus) static int SB16_init (ISABus *bus)
{ {
isa_create_simple (bus, TYPE_SB16); isa_create_simple (bus, TYPE_SB16);
return 0; return 0;
@ -1421,6 +1421,7 @@ static const TypeInfo sb16_info = {
static void sb16_register_types (void) static void sb16_register_types (void)
{ {
type_register_static (&sb16_info); type_register_static (&sb16_info);
isa_register_soundhw("sb16", "Creative Sound Blaster 16", SB16_init);
} }
type_init (sb16_register_types) type_init (sb16_register_types)

View File

@ -33,7 +33,6 @@
#include "hw/usb.h" #include "hw/usb.h"
#include "hw/usb/desc.h" #include "hw/usb/desc.h"
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/audio/audio.h"
#include "audio/audio.h" #include "audio/audio.h"
#define USBAUDIO_VENDOR_NUM 0x46f4 /* CRC16() of "QEMU" */ #define USBAUDIO_VENDOR_NUM 0x46f4 /* CRC16() of "QEMU" */

View File

@ -1,25 +1,10 @@
#ifndef HW_AUDIODEV_H #ifndef HW_AUDIODEV_H
#define HW_AUDIODEV_H 1 #define HW_AUDIODEV_H 1
/* es1370.c */ void isa_register_soundhw(const char *name, const char *descr,
int es1370_init(PCIBus *bus); int (*init_isa)(ISABus *bus));
/* sb16.c */ void pci_register_soundhw(const char *name, const char *descr,
int SB16_init(ISABus *bus); int (*init_pci)(PCIBus *bus));
/* adlib.c */
int Adlib_init(ISABus *bus);
/* gus.c */
int GUS_init(ISABus *bus);
/* ac97.c */
int ac97_init(PCIBus *bus);
/* cs4231a.c */
int cs4231a_init(ISABus *bus);
/* intel-hda.c + hda-audio.c */
int intel_hda_and_codec_init(PCIBus *bus);
#endif #endif

View File

@ -42,6 +42,4 @@ static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
return dev; return dev;
} }
int pcspk_audio_init(ISABus *bus);
#endif /* !HW_PCSPK_H */ #endif /* !HW_PCSPK_H */