Patchwork audio: consolidate audio_init()

login
register
mail settings
Submitter Isaku Yamahata
Date Jan. 21, 2011, 10:53 a.m.
Message ID <49202e5aabfe119ae7349399dbf59fcbcd1dff97.1295607113.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/79825/
State New
Headers show

Comments

Isaku Yamahata - Jan. 21, 2011, 10:53 a.m.
consolidate audio_init() and remove references to shoundhw.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 arch_init.c     |   35 ++++++++++++++++++++++++++++++++++-
 arch_init.h     |    1 +
 hw/mips_jazz.c  |   24 ++----------------------
 hw/mips_malta.c |   23 ++---------------------
 hw/pc.c         |   17 -----------------
 hw/pc.h         |    3 ---
 hw/pc_piix.c    |    3 ++-
 sysemu.h        |   15 ---------------
 8 files changed, 41 insertions(+), 80 deletions(-)
Blue Swirl - Jan. 21, 2011, 8:44 p.m.
On Fri, Jan 21, 2011 at 10:53 AM, Isaku Yamahata <yamahata@valinux.co.jp> wrote:
> consolidate audio_init() and remove references to shoundhw.
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

Acked-by: Blue Swirl <blauwirbel@gmail.com>
malc - Jan. 21, 2011, 10:27 p.m.
On Fri, 21 Jan 2011, Blue Swirl wrote:

> On Fri, Jan 21, 2011 at 10:53 AM, Isaku Yamahata <yamahata@valinux.co.jp> wrote:
> > consolidate audio_init() and remove references to shoundhw.
> >
> > Cc: Blue Swirl <blauwirbel@gmail.com>
> > Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

Don't see the point of first hunk. No objections otherwise.

> 
> Acked-by: Blue Swirl <blauwirbel@gmail.com>
>
Andreas Färber - Jan. 23, 2011, 3:50 p.m.
Am 21.01.2011 um 23:27 schrieb malc:

> On Fri, 21 Jan 2011, Blue Swirl wrote:
>
>> On Fri, Jan 21, 2011 at 10:53 AM, Isaku Yamahata <yamahata@valinux.co.jp 
>> > wrote:
>>> consolidate audio_init() and remove references to shoundhw.
>>>
>>> Cc: Blue Swirl <blauwirbel@gmail.com>
>>> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
>
> Don't see the point of first hunk. No objections otherwise.

I guess the point is to limit use of 'soundhw' to arch_init.c rather  
than to anyone including sysemu.h?
The definition of the struct is moved there and the variable is made  
static.

>>
>> Acked-by: Blue Swirl <blauwirbel@gmail.com>
Isaku Yamahata - Jan. 24, 2011, 2:16 a.m.
On Sun, Jan 23, 2011 at 04:50:34PM +0100, Andreas Färber wrote:
> Am 21.01.2011 um 23:27 schrieb malc:
>
>> On Fri, 21 Jan 2011, Blue Swirl wrote:
>>
>>> On Fri, Jan 21, 2011 at 10:53 AM, Isaku Yamahata 
>>> <yamahata@valinux.co.jp> wrote:
>>>> consolidate audio_init() and remove references to shoundhw.
>>>>
>>>> Cc: Blue Swirl <blauwirbel@gmail.com>
>>>> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
>>
>> Don't see the point of first hunk. No objections otherwise.
>
> I guess the point is to limit use of 'soundhw' to arch_init.c rather  
> than to anyone including sysemu.h?
> The definition of the struct is moved there and the variable is made  
> static.

That's right. Thank you for explanation. I didn't see any reason
why the definition of struct soundhw is used anywhere else.

>
>>>
>>> Acked-by: Blue Swirl <blauwirbel@gmail.com>
>
Aurelien Jarno - Jan. 25, 2011, 8:23 a.m.
On Fri, Jan 21, 2011 at 07:53:45PM +0900, Isaku Yamahata wrote:
> consolidate audio_init() and remove references to shoundhw.
> 
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
>  arch_init.c     |   35 ++++++++++++++++++++++++++++++++++-
>  arch_init.h     |    1 +
>  hw/mips_jazz.c  |   24 ++----------------------
>  hw/mips_malta.c |   23 ++---------------------
>  hw/pc.c         |   17 -----------------
>  hw/pc.h         |    3 ---
>  hw/pc_piix.c    |    3 ++-
>  sysemu.h        |   15 ---------------
>  8 files changed, 41 insertions(+), 80 deletions(-)

Thanks, applied.

> diff --git a/arch_init.c b/arch_init.c
> index e32e289..cc56f0f 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -461,7 +461,18 @@ void qemu_service_io(void)
>  }
>  
>  #ifdef HAS_AUDIO
> -struct soundhw soundhw[] = {
> +struct soundhw {
> +    const char *name;
> +    const char *descr;
> +    int enabled;
> +    int isa;
> +    union {
> +        int (*init_isa) (qemu_irq *pic);
> +        int (*init_pci) (PCIBus *bus);
> +    } init;
> +};
> +
> +static struct soundhw soundhw[] = {
>  #ifdef HAS_AUDIO_CHOICE
>  #if defined(TARGET_I386) || defined(TARGET_MIPS)
>      {
> @@ -610,10 +621,32 @@ void select_soundhw(const char *optarg)
>          }
>      }
>  }
> +
> +void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus)
> +{
> +    struct soundhw *c;
> +
> +    for (c = soundhw; c->name; ++c) {
> +        if (c->enabled) {
> +            if (c->isa) {
> +                if (isa_pic) {
> +                    c->init.init_isa(isa_pic);
> +                }
> +            } else {
> +                if (pci_bus) {
> +                    c->init.init_pci(pci_bus);
> +                }
> +            }
> +        }
> +    }
> +}
>  #else
>  void select_soundhw(const char *optarg)
>  {
>  }
> +void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus)
> +{
> +}
>  #endif
>  
>  int qemu_uuid_parse(const char *str, uint8_t *uuid)
> diff --git a/arch_init.h b/arch_init.h
> index 682890c..17c9164 100644
> --- a/arch_init.h
> +++ b/arch_init.h
> @@ -27,6 +27,7 @@ void do_acpitable_option(const char *optarg);
>  void do_smbios_option(const char *optarg);
>  void cpudef_init(void);
>  int audio_available(void);
> +void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus);
>  int kvm_available(void);
>  int xen_available(void);
>  
> diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
> index a7caa3f..85eba5a 100644
> --- a/hw/mips_jazz.c
> +++ b/hw/mips_jazz.c
> @@ -29,7 +29,7 @@
>  #include "isa.h"
>  #include "fdc.h"
>  #include "sysemu.h"
> -#include "audio/audio.h"
> +#include "arch_init.h"
>  #include "boards.h"
>  #include "net.h"
>  #include "esp.h"
> @@ -90,26 +90,6 @@ static CPUWriteMemoryFunc * const dma_dummy_write[3] = {
>      dma_dummy_writeb,
>  };
>  
> -static void audio_init(qemu_irq *pic)
> -{
> -    struct soundhw *c;
> -    int audio_enabled = 0;
> -
> -    for (c = soundhw; !audio_enabled && c->name; ++c) {
> -        audio_enabled = c->enabled;
> -    }
> -
> -    if (audio_enabled) {
> -        for (c = soundhw; c->name; ++c) {
> -            if (c->enabled) {
> -                if (c->isa) {
> -                    c->init.init_isa(pic);
> -                }
> -            }
> -        }
> -    }
> -}
> -
>  #define MAGNUM_BIOS_SIZE_MAX 0x7e000
>  #define MAGNUM_BIOS_SIZE (BIOS_SIZE < MAGNUM_BIOS_SIZE_MAX ? BIOS_SIZE : MAGNUM_BIOS_SIZE_MAX)
>  
> @@ -284,7 +264,7 @@ void mips_jazz_init (ram_addr_t ram_size,
>  
>      /* Sound card */
>      /* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
> -    audio_init(i8259);
> +    audio_init(i8259, NULL);
>  
>      /* NVRAM: Unprotected at 0x9000, Protected at 0xa000, Read only at 0xb000 */
>      ds1225y_init(0x80009000, "nvram");
> diff --git a/hw/mips_malta.c b/hw/mips_malta.c
> index d3ba969..9ae1e1f 100644
> --- a/hw/mips_malta.c
> +++ b/hw/mips_malta.c
> @@ -37,7 +37,7 @@
>  #include "vmware_vga.h"
>  #include "qemu-char.h"
>  #include "sysemu.h"
> -#include "audio/audio.h"
> +#include "arch_init.h"
>  #include "boards.h"
>  #include "qemu-log.h"
>  #include "mips-bios.h"
> @@ -457,25 +457,6 @@ static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, qemu_irq uart_ir
>      return s;
>  }
>  
> -/* Audio support */
> -static void audio_init (PCIBus *pci_bus)
> -{
> -    struct soundhw *c;
> -    int audio_enabled = 0;
> -
> -    for (c = soundhw; !audio_enabled && c->name; ++c) {
> -        audio_enabled = c->enabled;
> -    }
> -
> -    if (audio_enabled) {
> -        for (c = soundhw; c->name; ++c) {
> -            if (c->enabled) {
> -                c->init.init_pci(pci_bus);
> -            }
> -        }
> -    }
> -}
> -
>  /* Network support */
>  static void network_init(void)
>  {
> @@ -967,7 +948,7 @@ void mips_malta_init (ram_addr_t ram_size,
>      fdctrl_init_isa(fd);
>  
>      /* Sound card */
> -    audio_init(pci_bus);
> +    audio_init(NULL, pci_bus);
>  
>      /* Network card */
>      network_init();
> diff --git a/hw/pc.c b/hw/pc.c
> index fface7d..4dfdc0b 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -829,23 +829,6 @@ static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };
>  static const int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
>  static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
>  
> -void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic)
> -{
> -    struct soundhw *c;
> -
> -    for (c = soundhw; c->name; ++c) {
> -        if (c->enabled) {
> -            if (c->isa) {
> -                c->init.init_isa(pic);
> -            } else {
> -                if (pci_bus) {
> -                    c->init.init_pci(pci_bus);
> -                }
> -            }
> -        }
> -    }
> -}
> -
>  void pc_init_ne2k_isa(NICInfo *nd)
>  {
>      static int nb_ne2k = 0;
> diff --git a/hw/pc.h b/hw/pc.h
> index 6852790..a048768 100644
> --- a/hw/pc.h
> +++ b/hw/pc.h
> @@ -100,9 +100,6 @@ void pc_basic_device_init(qemu_irq *isa_irq,
>                            FDCtrl **floppy_controller,
>                            ISADevice **rtc_state);
>  void pc_init_ne2k_isa(NICInfo *nd);
> -#ifdef HAS_AUDIO
> -void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic);
> -#endif
>  void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
>                    const char *boot_device,
>                    BusState *ide0, BusState *ide1,
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index f82508d..7b74473 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -34,6 +34,7 @@
>  #include "kvm.h"
>  #include "sysemu.h"
>  #include "sysbus.h"
> +#include "arch_init.h"
>  #include "blockdev.h"
>  
>  #define MAX_IDE_BUS 2
> @@ -148,7 +149,7 @@ static void pc_init1(ram_addr_t ram_size,
>          }
>      }
>  
> -    pc_audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
> +    audio_init(isa_irq, pci_enabled ? pci_bus : NULL);
>  
>      pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
>                   idebus[0], idebus[1], floppy_controller, rtc_state);
> diff --git a/sysemu.h b/sysemu.h
> index d8fceec..a1d1164 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -177,21 +177,6 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
>  
>  #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
>  
> -#ifdef HAS_AUDIO
> -struct soundhw {
> -    const char *name;
> -    const char *descr;
> -    int enabled;
> -    int isa;
> -    union {
> -        int (*init_isa) (qemu_irq *pic);
> -        int (*init_pci) (PCIBus *bus);
> -    } init;
> -};
> -
> -extern struct soundhw soundhw[];
> -#endif
> -
>  void do_usb_add(Monitor *mon, const QDict *qdict);
>  void do_usb_del(Monitor *mon, const QDict *qdict);
>  void usb_info(Monitor *mon);
> -- 
> 1.7.1.1
> 
> 
>

Patch

diff --git a/arch_init.c b/arch_init.c
index e32e289..cc56f0f 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -461,7 +461,18 @@  void qemu_service_io(void)
 }
 
 #ifdef HAS_AUDIO
-struct soundhw soundhw[] = {
+struct soundhw {
+    const char *name;
+    const char *descr;
+    int enabled;
+    int isa;
+    union {
+        int (*init_isa) (qemu_irq *pic);
+        int (*init_pci) (PCIBus *bus);
+    } init;
+};
+
+static struct soundhw soundhw[] = {
 #ifdef HAS_AUDIO_CHOICE
 #if defined(TARGET_I386) || defined(TARGET_MIPS)
     {
@@ -610,10 +621,32 @@  void select_soundhw(const char *optarg)
         }
     }
 }
+
+void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus)
+{
+    struct soundhw *c;
+
+    for (c = soundhw; c->name; ++c) {
+        if (c->enabled) {
+            if (c->isa) {
+                if (isa_pic) {
+                    c->init.init_isa(isa_pic);
+                }
+            } else {
+                if (pci_bus) {
+                    c->init.init_pci(pci_bus);
+                }
+            }
+        }
+    }
+}
 #else
 void select_soundhw(const char *optarg)
 {
 }
+void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus)
+{
+}
 #endif
 
 int qemu_uuid_parse(const char *str, uint8_t *uuid)
diff --git a/arch_init.h b/arch_init.h
index 682890c..17c9164 100644
--- a/arch_init.h
+++ b/arch_init.h
@@ -27,6 +27,7 @@  void do_acpitable_option(const char *optarg);
 void do_smbios_option(const char *optarg);
 void cpudef_init(void);
 int audio_available(void);
+void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus);
 int kvm_available(void);
 int xen_available(void);
 
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index a7caa3f..85eba5a 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -29,7 +29,7 @@ 
 #include "isa.h"
 #include "fdc.h"
 #include "sysemu.h"
-#include "audio/audio.h"
+#include "arch_init.h"
 #include "boards.h"
 #include "net.h"
 #include "esp.h"
@@ -90,26 +90,6 @@  static CPUWriteMemoryFunc * const dma_dummy_write[3] = {
     dma_dummy_writeb,
 };
 
-static void audio_init(qemu_irq *pic)
-{
-    struct soundhw *c;
-    int audio_enabled = 0;
-
-    for (c = soundhw; !audio_enabled && c->name; ++c) {
-        audio_enabled = c->enabled;
-    }
-
-    if (audio_enabled) {
-        for (c = soundhw; c->name; ++c) {
-            if (c->enabled) {
-                if (c->isa) {
-                    c->init.init_isa(pic);
-                }
-            }
-        }
-    }
-}
-
 #define MAGNUM_BIOS_SIZE_MAX 0x7e000
 #define MAGNUM_BIOS_SIZE (BIOS_SIZE < MAGNUM_BIOS_SIZE_MAX ? BIOS_SIZE : MAGNUM_BIOS_SIZE_MAX)
 
@@ -284,7 +264,7 @@  void mips_jazz_init (ram_addr_t ram_size,
 
     /* Sound card */
     /* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
-    audio_init(i8259);
+    audio_init(i8259, NULL);
 
     /* NVRAM: Unprotected at 0x9000, Protected at 0xa000, Read only at 0xb000 */
     ds1225y_init(0x80009000, "nvram");
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index d3ba969..9ae1e1f 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -37,7 +37,7 @@ 
 #include "vmware_vga.h"
 #include "qemu-char.h"
 #include "sysemu.h"
-#include "audio/audio.h"
+#include "arch_init.h"
 #include "boards.h"
 #include "qemu-log.h"
 #include "mips-bios.h"
@@ -457,25 +457,6 @@  static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, qemu_irq uart_ir
     return s;
 }
 
-/* Audio support */
-static void audio_init (PCIBus *pci_bus)
-{
-    struct soundhw *c;
-    int audio_enabled = 0;
-
-    for (c = soundhw; !audio_enabled && c->name; ++c) {
-        audio_enabled = c->enabled;
-    }
-
-    if (audio_enabled) {
-        for (c = soundhw; c->name; ++c) {
-            if (c->enabled) {
-                c->init.init_pci(pci_bus);
-            }
-        }
-    }
-}
-
 /* Network support */
 static void network_init(void)
 {
@@ -967,7 +948,7 @@  void mips_malta_init (ram_addr_t ram_size,
     fdctrl_init_isa(fd);
 
     /* Sound card */
-    audio_init(pci_bus);
+    audio_init(NULL, pci_bus);
 
     /* Network card */
     network_init();
diff --git a/hw/pc.c b/hw/pc.c
index fface7d..4dfdc0b 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -829,23 +829,6 @@  static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };
 static const int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
 static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
 
-void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic)
-{
-    struct soundhw *c;
-
-    for (c = soundhw; c->name; ++c) {
-        if (c->enabled) {
-            if (c->isa) {
-                c->init.init_isa(pic);
-            } else {
-                if (pci_bus) {
-                    c->init.init_pci(pci_bus);
-                }
-            }
-        }
-    }
-}
-
 void pc_init_ne2k_isa(NICInfo *nd)
 {
     static int nb_ne2k = 0;
diff --git a/hw/pc.h b/hw/pc.h
index 6852790..a048768 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -100,9 +100,6 @@  void pc_basic_device_init(qemu_irq *isa_irq,
                           FDCtrl **floppy_controller,
                           ISADevice **rtc_state);
 void pc_init_ne2k_isa(NICInfo *nd);
-#ifdef HAS_AUDIO
-void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic);
-#endif
 void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
                   const char *boot_device,
                   BusState *ide0, BusState *ide1,
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index f82508d..7b74473 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -34,6 +34,7 @@ 
 #include "kvm.h"
 #include "sysemu.h"
 #include "sysbus.h"
+#include "arch_init.h"
 #include "blockdev.h"
 
 #define MAX_IDE_BUS 2
@@ -148,7 +149,7 @@  static void pc_init1(ram_addr_t ram_size,
         }
     }
 
-    pc_audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
+    audio_init(isa_irq, pci_enabled ? pci_bus : NULL);
 
     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
                  idebus[0], idebus[1], floppy_controller, rtc_state);
diff --git a/sysemu.h b/sysemu.h
index d8fceec..a1d1164 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -177,21 +177,6 @@  extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
-#ifdef HAS_AUDIO
-struct soundhw {
-    const char *name;
-    const char *descr;
-    int enabled;
-    int isa;
-    union {
-        int (*init_isa) (qemu_irq *pic);
-        int (*init_pci) (PCIBus *bus);
-    } init;
-};
-
-extern struct soundhw soundhw[];
-#endif
-
 void do_usb_add(Monitor *mon, const QDict *qdict);
 void do_usb_del(Monitor *mon, const QDict *qdict);
 void usb_info(Monitor *mon);