Commit 22d83b140e7b2dda555b7e3035050454f8764b7f

Authored by Paul Brook
1 parent 0d9acba8

Push AUD_init down to devices

Now we can safely call AUD_init multiple times we can push it down to
individual audio devices, rather than having to pass it from the board
init.

Signed-off-by: Paul Brook <paul@codesourcery.com>
hw/ac97.c
... ... @@ -1308,8 +1308,9 @@ static void ac97_on_reset (void *opaque)
1308 1308 mixer_reset (s);
1309 1309 }
1310 1310  
1311   -int ac97_init (PCIBus *bus, AudioState *audio)
  1311 +int ac97_init (PCIBus *bus)
1312 1312 {
  1313 + AudioState *audio = AUD_init();
1313 1314 PCIAC97LinkState *d;
1314 1315 AC97LinkState *s;
1315 1316 uint8_t *c;
... ... @@ -1319,11 +1320,6 @@ int ac97_init (PCIBus *bus, AudioState *audio)
1319 1320 return -1;
1320 1321 }
1321 1322  
1322   - if (!audio) {
1323   - AUD_log ("ac97", "No audio state\n");
1324   - return -1;
1325   - }
1326   -
1327 1323 d = (PCIAC97LinkState *) pci_register_device (bus, "AC97",
1328 1324 sizeof (PCIAC97LinkState),
1329 1325 -1, NULL, NULL);
... ...
hw/adlib.c
... ... @@ -277,16 +277,12 @@ static void Adlib_fini (AdlibState *s)
277 277 AUD_remove_card (&s->card);
278 278 }
279 279  
280   -int Adlib_init (AudioState *audio, qemu_irq *pic)
  280 +int Adlib_init (qemu_irq *pic)
281 281 {
  282 + AudioState *audio = AUD_init();
282 283 AdlibState *s = &glob_adlib;
283 284 struct audsettings as;
284 285  
285   - if (!audio) {
286   - dolog ("No audio state\n");
287   - return -1;
288   - }
289   -
290 286 #ifdef HAS_YMF262
291 287 if (YMF262Init (1, 14318180, conf.freq)) {
292 288 dolog ("YMF262Init %d failed\n", conf.freq);
... ...
hw/audiodev.h
1 1 /* es1370.c */
2   -int es1370_init (PCIBus *bus, AudioState *s);
  2 +int es1370_init(PCIBus *bus);
3 3  
4 4 /* sb16.c */
5   -int SB16_init (AudioState *s, qemu_irq *pic);
  5 +int SB16_init(qemu_irq *pic);
6 6  
7 7 /* adlib.c */
8   -int Adlib_init (AudioState *s, qemu_irq *pic);
  8 +int Adlib_init(qemu_irq *pic);
9 9  
10 10 /* gus.c */
11   -int GUS_init (AudioState *s, qemu_irq *pic);
  11 +int GUS_init(qemu_irq *pic);
12 12  
13 13 /* ac97.c */
14   -int ac97_init (PCIBus *buf, AudioState *s);
  14 +int ac97_init(PCIBus *buf);
15 15  
16 16 /* cs4231a.c */
17   -int cs4231a_init (AudioState *s, qemu_irq *pic);
  17 +int cs4231a_init(qemu_irq *pic);
... ...
hw/cs4231a.c
... ... @@ -636,16 +636,12 @@ static int cs_load(QEMUFile *f, void *opaque, int version_id)
636 636 return 0;
637 637 }
638 638  
639   -int cs4231a_init (AudioState *audio, qemu_irq *pic)
  639 +int cs4231a_init (qemu_irq *pic)
640 640 {
  641 + AudioState *audio = AUD_init();
641 642 int i;
642 643 CSState *s;
643 644  
644   - if (!audio) {
645   - lerr ("No audio state\n");
646   - return -1;
647   - }
648   -
649 645 s = qemu_mallocz (sizeof (*s));
650 646  
651 647 s->pic = pic;
... ...
hw/devices.h
... ... @@ -17,9 +17,8 @@ void ads7846_write(void *opaque, uint32_t value);
17 17 ADS7846State *ads7846_init(qemu_irq penirq);
18 18  
19 19 /* tsc210x.c */
20   -uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio);
21   -uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
22   - qemu_irq dav, AudioState *audio);
  20 +uWireSlave *tsc2102_init(qemu_irq pint);
  21 +uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
23 22 I2SCodec *tsc210x_codec(uWireSlave *chip);
24 23 uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
25 24 void tsc210x_set_transform(uWireSlave *chip,
... ...
hw/es1370.c
... ... @@ -1005,8 +1005,9 @@ static void es1370_on_reset (void *opaque)
1005 1005 es1370_reset (s);
1006 1006 }
1007 1007  
1008   -int es1370_init (PCIBus *bus, AudioState *audio)
  1008 +int es1370_init (PCIBus *bus)
1009 1009 {
  1010 + AudioState *audio = AUD_init();
1010 1011 PCIES1370State *d;
1011 1012 ES1370State *s;
1012 1013 uint8_t *c;
... ... @@ -1016,11 +1017,6 @@ int es1370_init (PCIBus *bus, AudioState *audio)
1016 1017 return -1;
1017 1018 }
1018 1019  
1019   - if (!audio) {
1020   - dolog ("No audio state\n");
1021   - return -1;
1022   - }
1023   -
1024 1020 d = (PCIES1370State *) pci_register_device (bus, "ES1370",
1025 1021 sizeof (PCIES1370State),
1026 1022 -1, NULL, NULL);
... ...
hw/gus.c
... ... @@ -250,16 +250,12 @@ static int GUS_load (QEMUFile *f, void *opaque, int version_id)
250 250 return 0;
251 251 }
252 252  
253   -int GUS_init (AudioState *audio, qemu_irq *pic)
  253 +int GUS_init (qemu_irq *pic)
254 254 {
  255 + AudioState *audio = AUD_init();
255 256 GUSState *s;
256 257 struct audsettings as;
257 258  
258   - if (!audio) {
259   - dolog ("No audio state\n");
260   - return -1;
261   - }
262   -
263 259 s = qemu_mallocz (sizeof (*s));
264 260  
265 261 AUD_register_card (audio, "gus", &s->card);
... ...
hw/i2c.h
... ... @@ -60,7 +60,7 @@ qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
60 60 void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
61 61  
62 62 /* wm8750.c */
63   -i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio);
  63 +i2c_slave *wm8750_init(i2c_bus *bus);
64 64 void wm8750_reset(i2c_slave *i2c);
65 65 void wm8750_data_req_set(i2c_slave *i2c,
66 66 void (*data_req)(void *, int, int), void *opaque);
... ...
hw/mips_jazz.c
... ... @@ -104,13 +104,10 @@ static void audio_init(qemu_irq *pic)
104 104 }
105 105  
106 106 if (audio_enabled) {
107   - AudioState *s;
108   -
109   - s = AUD_init();
110 107 for (c = soundhw; c->name; ++c) {
111 108 if (c->enabled) {
112 109 if (c->isa) {
113   - c->init.init_isa(s, pic);
  110 + c->init.init_isa(pic);
114 111 }
115 112 }
116 113 }
... ...
hw/mips_malta.c
... ... @@ -469,12 +469,9 @@ static void audio_init (PCIBus *pci_bus)
469 469 }
470 470  
471 471 if (audio_enabled) {
472   - AudioState *s;
473   -
474   - s = AUD_init ();
475 472 for (c = soundhw; c->name; ++c) {
476 473 if (c->enabled) {
477   - c->init.init_pci (pci_bus, s);
  474 + c->init.init_pci(pci_bus);
478 475 }
479 476 }
480 477 }
... ...
hw/musicpal.c
... ... @@ -422,13 +422,10 @@ static CPUWriteMemoryFunc *musicpal_audio_writefn[] = {
422 422  
423 423 static i2c_interface *musicpal_audio_init(qemu_irq irq)
424 424 {
425   - AudioState *audio;
426 425 musicpal_audio_state *s;
427 426 i2c_interface *i2c;
428 427 int iomemtype;
429 428  
430   - audio = AUD_init();
431   -
432 429 s = qemu_mallocz(sizeof(musicpal_audio_state));
433 430 s->irq = irq;
434 431  
... ... @@ -436,7 +433,7 @@ static i2c_interface *musicpal_audio_init(qemu_irq irq)
436 433 i2c->bus = i2c_init_bus();
437 434 i2c->current_addr = -1;
438 435  
439   - s->wm = wm8750_init(i2c->bus, audio);
  436 + s->wm = wm8750_init(i2c->bus);
440 437 if (!s->wm)
441 438 return NULL;
442 439 i2c_set_slave_address(s->wm, MP_WM_ADDR);
... ...
hw/nseries.c
... ... @@ -252,7 +252,7 @@ static void n800_tsc_kbd_setup(struct n800_s *s)
252 252 qemu_irq kbirq = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_KP_IRQ_GPIO)[0];
253 253 qemu_irq dav = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_TS_GPIO)[0];
254 254  
255   - s->ts.chip = tsc2301_init(penirq, kbirq, dav, 0);
  255 + s->ts.chip = tsc2301_init(penirq, kbirq, dav);
256 256 s->ts.opaque = s->ts.chip->opaque;
257 257 s->ts.txrx = tsc210x_txrx;
258 258  
... ...
hw/omap2.c
... ... @@ -1973,7 +1973,6 @@ struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,
1973 1973 omap_eac_reset(s);
1974 1974  
1975 1975 #ifdef HAS_AUDIO
1976   - /* TODO: do AUD_init globally for machine */
1977 1976 AUD_register_card(AUD_init(), "OMAP EAC", &s->codec.card);
1978 1977  
1979 1978 iomemtype = cpu_register_io_memory(0, omap_eac_readfn,
... ...
hw/palm.c
... ... @@ -93,14 +93,8 @@ static MouseTransformInfo palmte_pointercal = {
93 93 static void palmte_microwire_setup(struct omap_mpu_state_s *cpu)
94 94 {
95 95 uWireSlave *tsc;
96   - AudioState *audio = 0;
97 96  
98   -#ifdef HAS_AUDIO
99   - audio = AUD_init();
100   -#endif
101   -
102   - tsc = tsc2102_init(omap_gpio_in_get(cpu->gpio)[PALMTE_PINTDAV_GPIO],
103   - audio);
  97 + tsc = tsc2102_init(omap_gpio_in_get(cpu->gpio)[PALMTE_PINTDAV_GPIO]);
104 98  
105 99 omap_uwire_attach(cpu->microwire, tsc, 0);
106 100 omap_mcbsp_i2s_attach(cpu->mcbsp1, tsc210x_codec(tsc));
... ...
... ... @@ -788,17 +788,13 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
788 788 }
789 789  
790 790 if (audio_enabled) {
791   - AudioState *s;
792   -
793   - s = AUD_init ();
794 791 for (c = soundhw; c->name; ++c) {
795 792 if (c->enabled) {
796 793 if (c->isa) {
797   - c->init.init_isa (s, pic);
798   - }
799   - else {
  794 + c->init.init_isa(pic);
  795 + } else {
800 796 if (pci_bus) {
801   - c->init.init_pci (pci_bus, s);
  797 + c->init.init_pci(pci_bus);
802 798 }
803 799 }
804 800 }
... ...
... ... @@ -119,7 +119,7 @@ extern int no_hpet;
119 119  
120 120 /* pcspk.c */
121 121 void pcspk_init(PITState *);
122   -int pcspk_audio_init(AudioState *, qemu_irq *pic);
  122 +int pcspk_audio_init(qemu_irq *pic);
123 123  
124 124 /* piix_pci.c */
125 125 PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic);
... ...
hw/pcspk.c
... ... @@ -96,15 +96,12 @@ static void pcspk_callback(void *opaque, int free)
96 96 }
97 97 }
98 98  
99   -int pcspk_audio_init(AudioState *audio, qemu_irq *pic)
  99 +int pcspk_audio_init(qemu_irq *pic)
100 100 {
  101 + AudioState *audio = AUD_init();
101 102 PCSpkState *s = &pcspk_state;
102 103 struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
103 104  
104   - if (!audio) {
105   - AUD_log(s_spk, "No audio state\n");
106   - return -1;
107   - }
108 105 AUD_register_card(audio, s_spk, &s->card);
109 106  
110 107 s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
... ...
hw/ppc_prep.c
... ... @@ -696,7 +696,6 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
696 696 }
697 697 i8042_init(i8259[1], i8259[12], 0x60);
698 698 DMA_init(1);
699   - // AUD_init();
700 699 // SB16_init();
701 700  
702 701 for(i = 0; i < MAX_FD; i++) {
... ...
hw/sb16.c
... ... @@ -1398,18 +1398,14 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id)
1398 1398 return 0;
1399 1399 }
1400 1400  
1401   -int SB16_init (AudioState *audio, qemu_irq *pic)
  1401 +int SB16_init (qemu_irq *pic)
1402 1402 {
  1403 + AudioState *audio = AUD_init();
1403 1404 SB16State *s;
1404 1405 int i;
1405 1406 static const uint8_t dsp_write_ports[] = {0x6, 0xc};
1406 1407 static const uint8_t dsp_read_ports[] = {0x6, 0xa, 0xc, 0xd, 0xe, 0xf};
1407 1408  
1408   - if (!audio) {
1409   - dolog ("No audio state\n");
1410   - return -1;
1411   - }
1412   -
1413 1409 s = qemu_mallocz (sizeof (*s));
1414 1410  
1415 1411 s->cmd = -1;
... ...
hw/spitz.c
... ... @@ -740,12 +740,10 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
740 740 i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
741 741  
742 742 #ifdef HAS_AUDIO
743   - AudioState *audio;
744 743 i2c_slave *wm;
745 744  
746   - audio = AUD_init();
747 745 /* Attach a WM8750 to the bus */
748   - wm = wm8750_init(bus, audio);
  746 + wm = wm8750_init(bus);
749 747  
750 748 spitz_wm8750_addr(wm, 0, 0);
751 749 pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM,
... ...
hw/tsc210x.c
... ... @@ -684,8 +684,7 @@ static void tsc2102_audio_register_write(
684 684 "wrong value written into Audio 1\n");
685 685 #endif
686 686 tsc2102_audio_rate_update(s);
687   - if (s->audio)
688   - tsc2102_audio_output_update(s);
  687 + tsc2102_audio_output_update(s);
689 688 return;
690 689  
691 690 case 0x01:
... ... @@ -729,8 +728,7 @@ static void tsc2102_audio_register_write(
729 728 "wrong value written into Power\n");
730 729 #endif
731 730 tsc2102_audio_rate_update(s);
732   - if (s->audio)
733   - tsc2102_audio_output_update(s);
  731 + tsc2102_audio_output_update(s);
734 732 return;
735 733  
736 734 case 0x06: /* Audio Control 3 */
... ... @@ -741,8 +739,7 @@ static void tsc2102_audio_register_write(
741 739 fprintf(stderr, "tsc2102_audio_register_write: "
742 740 "wrong value written into Audio 3\n");
743 741 #endif
744   - if (s->audio)
745   - tsc2102_audio_output_update(s);
  742 + tsc2102_audio_output_update(s);
746 743 return;
747 744  
748 745 case 0x07: /* LCH_BASS_BOOST_N0 */
... ... @@ -1105,7 +1102,7 @@ static int tsc210x_load(QEMUFile *f, void *opaque, int version_id)
1105 1102 return 0;
1106 1103 }
1107 1104  
1108   -uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
  1105 +uWireSlave *tsc2102_init(qemu_irq pint)
1109 1106 {
1110 1107 TSC210xState *s;
1111 1108  
... ... @@ -1120,7 +1117,7 @@ uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
1120 1117 s->pint = pint;
1121 1118 s->model = 0x2102;
1122 1119 s->name = "tsc2102";
1123   - s->audio = audio;
  1120 + s->audio = AUD_init();;
1124 1121  
1125 1122 s->tr[0] = 0;
1126 1123 s->tr[1] = 1;
... ... @@ -1146,8 +1143,7 @@ uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
1146 1143 qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
1147 1144 "QEMU TSC2102-driven Touchscreen");
1148 1145  
1149   - if (s->audio)
1150   - AUD_register_card(s->audio, s->name, &s->card);
  1146 + AUD_register_card(s->audio, s->name, &s->card);
1151 1147  
1152 1148 qemu_register_reset((void *) tsc210x_reset, s);
1153 1149 register_savevm(s->name, -1, 0,
... ... @@ -1156,8 +1152,7 @@ uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
1156 1152 return &s->chip;
1157 1153 }
1158 1154  
1159   -uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
1160   - qemu_irq dav, AudioState *audio)
  1155 +uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)
1161 1156 {
1162 1157 TSC210xState *s;
1163 1158  
... ... @@ -1174,7 +1169,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
1174 1169 s->davint = dav;
1175 1170 s->model = 0x2301;
1176 1171 s->name = "tsc2301";
1177   - s->audio = audio;
  1172 + s->audio = AUD_init();
1178 1173  
1179 1174 s->tr[0] = 0;
1180 1175 s->tr[1] = 1;
... ... @@ -1200,8 +1195,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
1200 1195 qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
1201 1196 "QEMU TSC2301-driven Touchscreen");
1202 1197  
1203   - if (s->audio)
1204   - AUD_register_card(s->audio, s->name, &s->card);
  1198 + AUD_register_card(s->audio, s->name, &s->card);
1205 1199  
1206 1200 qemu_register_reset((void *) tsc210x_reset, s);
1207 1201 register_savevm(s->name, -1, 0, tsc210x_save, tsc210x_load, s);
... ...
hw/wm8750.c
... ... @@ -645,8 +645,9 @@ static int wm8750_load(QEMUFile *f, void *opaque, int version_id)
645 645 return 0;
646 646 }
647 647  
648   -i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio)
  648 +i2c_slave *wm8750_init(i2c_bus *bus)
649 649 {
  650 + AudioState *audio = AUD_init();
650 651 WM8750State *s = (WM8750State *)
651 652 i2c_slave_init(bus, 0, sizeof(WM8750State));
652 653 s->i2c.event = wm8750_event;
... ...
sysemu.h
... ... @@ -241,8 +241,8 @@ struct soundhw {
241 241 int enabled;
242 242 int isa;
243 243 union {
244   - int (*init_isa) (AudioState *s, qemu_irq *pic);
245   - int (*init_pci) (PCIBus *bus, AudioState *s);
  244 + int (*init_isa) (qemu_irq *pic);
  245 + int (*init_pci) (PCIBus *bus);
246 246 } init;
247 247 };
248 248  
... ...