From patchwork Thu Apr 18 16:43:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 237686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 189782C007B for ; Fri, 19 Apr 2013 02:48:12 +1000 (EST) Received: from localhost ([::1]:36519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USs0I-00039c-CE for incoming@patchwork.ozlabs.org; Thu, 18 Apr 2013 12:48:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USrwb-0006fB-1J for qemu-devel@nongnu.org; Thu, 18 Apr 2013 12:44:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USrwU-0006MG-HP for qemu-devel@nongnu.org; Thu, 18 Apr 2013 12:44:20 -0400 Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]:34368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USrwU-0006M1-7P for qemu-devel@nongnu.org; Thu, 18 Apr 2013 12:44:14 -0400 Received: by mail-ea0-f174.google.com with SMTP id m14so1339754eaj.5 for ; Thu, 18 Apr 2013 09:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=mUjsLpGfuuOeuaWzUVgIpEgM5oHQViKrhhoj/6WgP+k=; b=Y4CsUT157p2u1nGX9OD7FrzfxrMfhYiHu84MD4br9PIfa67IJjZ+KwAWWOAEzQ5kZL SqoKxmHbPTGrFwQaeeZm7X5rUv1ilsU6u/zPwdx+hTu7ufjLd4y8L+TlERga5IUobBnN OTbVbyKCY73zgHTzz7burk+MLSr45BsKYVBAMbQ1UnOAppJLRREtBTYNdn0n966myXeb vzvhZrEVEmwyJa6EozjWCV1i845sYGlvIR9OKuZpw/VWtCF94RDcxKYvMsl46KVN7Tuq yLruurt+72HqOVRAzSsWesHqLR3K/IJXWNgBMAE527+epworJnR8RojD7su9uB/RvtQI JY6g== X-Received: by 10.15.36.135 with SMTP id i7mr31960948eev.34.1366303453327; Thu, 18 Apr 2013 09:44:13 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id f9sm1873198eeu.11.2013.04.18.09.44.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 18 Apr 2013 09:44:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2013 18:43:58 +0200 Message-Id: <1366303444-24620-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1366303444-24620-1-git-send-email-pbonzini@redhat.com> References: <1366303444-24620-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22e Cc: av1474@comtv.ru Subject: [Qemu-devel] [PATCH 2/8] audio: remove the need for audio card CONFIG_* symbols X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- RFC->v1: do not touch audio_available() here arch_init.c | 130 ++++++++++++----------------------------------- configure | 8 +-- hw/audio/ac97.c | 3 +- hw/audio/adlib.c | 3 +- hw/audio/cs4231a.c | 3 +- hw/audio/es1370.c | 3 +- hw/audio/gus.c | 3 +- hw/audio/intel-hda.c | 22 ++++---- hw/audio/pcspk.c | 4 +- hw/audio/sb16.c | 3 +- hw/usb/dev-audio.c | 1 - include/hw/audio/audio.h | 23 ++------- include/hw/audio/pcspk.h | 2 - 13 files changed, 63 insertions(+), 145 deletions(-) diff --git a/arch_init.c b/arch_init.c index 92de1bd..8d26993 100644 --- a/arch_init.c +++ b/arch_init.c @@ -899,97 +899,31 @@ struct soundhw { } init; }; -static struct soundhw soundhw[] = { -#ifdef HAS_AUDIO_CHOICE -#ifdef CONFIG_PCSPK - { - "pcspk", - "PC speaker", - 0, - 1, - { .init_isa = pcspk_audio_init } - }, -#endif - -#ifdef CONFIG_SB16 - { - "sb16", - "Creative Sound Blaster 16", - 0, - 1, - { .init_isa = SB16_init } - }, -#endif - -#ifdef CONFIG_CS4231A - { - "cs4231a", - "CS4231A", - 0, - 1, - { .init_isa = cs4231a_init } - }, -#endif - -#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 +static struct soundhw soundhw[9]; +static int soundhw_count; -#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 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; @@ -997,16 +931,16 @@ void select_soundhw(const char *optarg) if (is_help_option(optarg)) { show_valid_cards: -#ifdef HAS_AUDIO_CHOICE - printf("Valid sound card names (comma separated):\n"); - for (c = soundhw; c->name; ++c) { - printf ("%-11s %s\n", c->name, c->descr); + 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"); } - 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)); } else { diff --git a/configure b/configure index ed49f91..7db1edb 100755 --- a/configure +++ b/configure @@ -4455,15 +4455,9 @@ esac if test "$target_softmmu" = "yes" ; then case "$TARGET_BASE_ARCH" in - arm) + arm|lm32|i386|mips|ppc) cflags="-DHAS_AUDIO $cflags" ;; - lm32) - cflags="-DHAS_AUDIO $cflags" - ;; - i386|mips|ppc) - cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags" - ;; esac fi diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index ab68ec6..baf138b 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -1396,7 +1396,7 @@ static void ac97_exitfn (PCIDevice *dev) memory_region_destroy (&s->io_nabm); } -int ac97_init (PCIBus *bus) +static int ac97_init (PCIBus *bus) { pci_create_simple (bus, -1, "AC97"); return 0; @@ -1433,6 +1433,7 @@ 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) diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index fb41f9d..fc20857 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -372,7 +372,7 @@ static const TypeInfo adlib_info = { .class_init = adlib_class_initfn, }; -int Adlib_init (ISABus *bus) +static int Adlib_init (ISABus *bus) { isa_create_simple (bus, TYPE_ADLIB); return 0; @@ -381,6 +381,7 @@ int Adlib_init (ISABus *bus) static void adlib_register_types (void) { type_register_static (&adlib_info); + isa_register_soundhw("adlib", ADLIB_DESC, Adlib_init); } type_init (adlib_register_types) diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 5711b62..cc605e5 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -659,7 +659,7 @@ static int cs4231a_initfn (ISADevice *dev) return 0; } -int cs4231a_init (ISABus *bus) +static int cs4231a_init (ISABus *bus) { isa_create_simple (bus, "cs4231a"); return 0; @@ -692,6 +692,7 @@ static const TypeInfo cs4231a_info = { static void cs4231a_register_types (void) { type_register_static (&cs4231a_info); + isa_register_soundhw("cs4231a", "CS4231A", cs4231a_init); } type_init (cs4231a_register_types) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 9fe5708..c1cd169 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -1051,7 +1051,7 @@ static void es1370_exitfn (PCIDevice *dev) memory_region_destroy (&s->io); } -int es1370_init (PCIBus *bus) +static int es1370_init (PCIBus *bus) { pci_create_simple (bus, -1, "ES1370"); return 0; @@ -1083,6 +1083,7 @@ 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) diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 0604d6e..a91921c 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -293,7 +293,7 @@ static int gus_initfn (ISADevice *dev) return 0; } -int GUS_init (ISABus *bus) +static int GUS_init (ISABus *bus) { isa_create_simple (bus, "gus"); return 0; @@ -327,6 +327,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); } type_init (gus_register_types) diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 3d8077a..1016af0 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -1300,21 +1300,11 @@ static const TypeInfo hda_codec_device_type_info = { .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, * so '-soundhw hda' works. */ -int intel_hda_and_codec_init(PCIBus *bus) +static int intel_hda_and_codec_init(PCIBus *bus) { PCIDevice *controller; BusState *hdabus; @@ -1327,3 +1317,13 @@ int intel_hda_and_codec_init(PCIBus *bus) 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) diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 34e0df7..bed1c86 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -25,6 +25,7 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" +#include "hw/audio/audio.h" #include "audio/audio.h" #include "qemu/timer.h" #include "hw/timer/i8254.h" @@ -105,7 +106,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; struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0}; @@ -197,5 +198,6 @@ static const TypeInfo pcspk_info = { static void pcspk_register(void) { type_register_static(&pcspk_info); + isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init); } type_init(pcspk_register) diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 783b6b4..30bedf9 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1384,7 +1384,7 @@ static int sb16_initfn (ISADevice *dev) return 0; } -int SB16_init (ISABus *bus) +static int SB16_init (ISABus *bus) { isa_create_simple (bus, "sb16"); return 0; @@ -1419,6 +1419,7 @@ 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); } type_init (sb16_register_types) diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 44fc43f..04933a9 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -33,7 +33,6 @@ #include "hw/usb.h" #include "hw/usb/desc.h" #include "hw/hw.h" -#include "hw/audio/audio.h" #include "audio/audio.h" #define USBAUDIO_VENDOR_NUM 0x46f4 /* CRC16() of "QEMU" */ diff --git a/include/hw/audio/audio.h b/include/hw/audio/audio.h index 428274f..b28abdd 100644 --- a/include/hw/audio/audio.h +++ b/include/hw/audio/audio.h @@ -1,25 +1,10 @@ #ifndef HW_AUDIODEV_H #define HW_AUDIODEV_H 1 -/* es1370.c */ -int es1370_init(PCIBus *bus); +void isa_register_soundhw(const char *name, const char *descr, + int (*init_isa)(ISABus *bus)); -/* sb16.c */ -int SB16_init(ISABus *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); +void pci_register_soundhw(const char *name, const char *descr, + int (*init_pci)(PCIBus *bus)); #endif diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h index ce8ef4f..aa6a9d3 100644 --- a/include/hw/audio/pcspk.h +++ b/include/hw/audio/pcspk.h @@ -40,6 +40,4 @@ static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit) return dev; } -int pcspk_audio_init(ISABus *bus); - #endif /* !HW_PCSPK_H */