Commit 6a36d84e1024ce41860751b449727f4ddca91aa2

Authored by bellard
1 parent 3f9f3aa1

suppressed -enable-audio and simplified -soundhw option handling (malc)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1725 c046a42c-6fe2-441c-8c8c-71466251a162
... ... @@ -574,6 +574,38 @@ static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
574 574 static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
575 575 static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
576 576  
  577 +#ifdef HAS_AUDIO
  578 +static void audio_init (PCIBus *pci_bus)
  579 +{
  580 + struct soundhw *c;
  581 + int audio_enabled = 0;
  582 +
  583 + for (c = soundhw; !audio_enabled && c->name; ++c) {
  584 + audio_enabled = c->enabled;
  585 + }
  586 +
  587 + if (audio_enabled) {
  588 + AudioState *s;
  589 +
  590 + s = AUD_init ();
  591 + if (s) {
  592 + for (c = soundhw; c->name; ++c) {
  593 + if (c->enabled) {
  594 + if (c->isa) {
  595 + c->init.init_isa (s);
  596 + }
  597 + else {
  598 + if (pci_bus) {
  599 + c->init.init_pci (pci_bus, s);
  600 + }
  601 + }
  602 + }
  603 + }
  604 + }
  605 + }
  606 +}
  607 +#endif
  608 +
577 609 /* PC hardware initialisation */
578 610 static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
579 611 DisplayState *ds, const char **fd_filename, int snapshot,
... ... @@ -789,26 +821,9 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
789 821  
790 822 kbd_init();
791 823 DMA_init(0);
792   -
793   - if (audio_enabled) {
794   - AudioState *audio;
795   -
796   - audio = AUD_init();
797   - if (audio) {
798   - if (sb16_enabled)
799   - SB16_init (audio);
800   -#ifdef CONFIG_ADLIB
801   - if (adlib_enabled)
802   - Adlib_init (audio);
803   -#endif
804   -#ifdef CONFIG_GUS
805   - if (gus_enabled)
806   - GUS_init (audio);
  824 +#ifdef HAS_AUDIO
  825 + audio_init(pci_enabled ? pci_bus : NULL);
807 826 #endif
808   - if (pci_enabled && es1370_enabled)
809   - es1370_init (pci_bus, audio);
810   - }
811   - }
812 827  
813 828 floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
814 829  
... ...
qemu-doc.texi
... ... @@ -201,16 +201,12 @@ de en-us fi fr-be hr it lv nl-be pt sl tr
201 201  
202 202 The default is @code{en-us}.
203 203  
204   -@item -enable-audio
205   -
206   -Will enable audio and all the sound hardware QEMU was built with.
207   -
208 204 @item -audio-help
209 205  
210 206 Will show the audio subsystem help: list of drivers, tunable
211 207 parameters.
212 208  
213   -@item -soundhw card1,card2,...
  209 +@item -soundhw card1,card2,... or -soundhw all
214 210  
215 211 Enable audio and selected sound hardware. Use ? to print all
216 212 available sound hardware.
... ... @@ -218,6 +214,7 @@ available sound hardware.
218 214 @example
219 215 qemu -soundhw sb16,adlib hda
220 216 qemu -soundhw es1370 hda
  217 +qemu -soundhw all hda
221 218 qemu -soundhw ?
222 219 @end example
223 220  
... ...
... ... @@ -124,13 +124,6 @@ int nb_nics;
124 124 NICInfo nd_table[MAX_NICS];
125 125 QEMUTimer *gui_timer;
126 126 int vm_running;
127   -#ifdef HAS_AUDIO
128   -int audio_enabled = 0;
129   -int sb16_enabled = 0;
130   -int adlib_enabled = 0;
131   -int gus_enabled = 0;
132   -int es1370_enabled = 0;
133   -#endif
134 127 int rtc_utc = 1;
135 128 int cirrus_vga_enabled = 1;
136 129 #ifdef TARGET_SPARC
... ... @@ -3977,11 +3970,11 @@ void help(void)
3977 3970 "-k language use keyboard layout (for example \"fr\" for French)\n"
3978 3971 #endif
3979 3972 #ifdef HAS_AUDIO
3980   - "-enable-audio enable audio support, and all the sound cards\n"
3981 3973 "-audio-help print list of audio drivers and their options\n"
3982 3974 "-soundhw c1,... enable audio support\n"
3983 3975 " and only specified sound cards (comma separated list)\n"
3984 3976 " use -soundhw ? to get the list of supported cards\n"
  3977 + " use -soundhw all to enable all of them\n"
3985 3978 #endif
3986 3979 "-localtime set the real time clock to local time [default=utc]\n"
3987 3980 "-full-screen start in full screen\n"
... ... @@ -4097,7 +4090,6 @@ enum {
4097 4090 QEMU_OPTION_m,
4098 4091 QEMU_OPTION_nographic,
4099 4092 #ifdef HAS_AUDIO
4100   - QEMU_OPTION_enable_audio,
4101 4093 QEMU_OPTION_audio_help,
4102 4094 QEMU_OPTION_soundhw,
4103 4095 #endif
... ... @@ -4159,7 +4151,6 @@ const QEMUOption qemu_options[] = {
4159 4151 { "nographic", 0, QEMU_OPTION_nographic },
4160 4152 { "k", HAS_ARG, QEMU_OPTION_k },
4161 4153 #ifdef HAS_AUDIO
4162   - { "enable-audio", 0, QEMU_OPTION_enable_audio },
4163 4154 { "audio-help", 0, QEMU_OPTION_audio_help },
4164 4155 { "soundhw", HAS_ARG, QEMU_OPTION_soundhw },
4165 4156 #endif
... ... @@ -4280,58 +4271,90 @@ void register_machines(void)
4280 4271 }
4281 4272  
4282 4273 #ifdef HAS_AUDIO
4283   -static void select_soundhw (const char *optarg)
4284   -{
4285   - if (*optarg == '?') {
4286   - show_valid_cards:
4287   - printf ("Valid sound card names (comma separated):\n");
4288   - printf ("sb16 Creative Sound Blaster 16\n");
  4274 +struct soundhw soundhw[] = {
  4275 + {
  4276 + "sb16",
  4277 + "Creative Sound Blaster 16",
  4278 + 0,
  4279 + 1,
  4280 + { .init_isa = SB16_init }
  4281 + },
  4282 +
4289 4283 #ifdef CONFIG_ADLIB
  4284 + {
  4285 + "adlib",
4290 4286 #ifdef HAS_YMF262
4291   - printf ("adlib Yamaha YMF262 (OPL3)\n");
  4287 + "Yamaha YMF262 (OPL3)",
4292 4288 #else
4293   - printf ("adlib Yamaha YM3812 (OPL2)\n");
  4289 + "Yamaha YM3812 (OPL2)",
4294 4290 #endif
  4291 + 0,
  4292 + 1,
  4293 + { .init_isa = Adlib_init }
  4294 + },
4295 4295 #endif
  4296 +
4296 4297 #ifdef CONFIG_GUS
4297   - printf ("gus Gravis Ultrasound GF1\n");
  4298 + {
  4299 + "gus",
  4300 + "Gravis Ultrasound GF1",
  4301 + 0,
  4302 + 1,
  4303 + { .init_isa = GUS_init }
  4304 + },
4298 4305 #endif
4299   - printf ("es1370 ENSONIQ AudioPCI ES1370\n");
  4306 +
  4307 + {
  4308 + "es1370",
  4309 + "ENSONIQ AudioPCI ES1370",
  4310 + 0,
  4311 + 0,
  4312 + { .init_pci = es1370_init }
  4313 + },
  4314 +
  4315 + { NULL, NULL, 0, 0, { NULL } }
  4316 +};
  4317 +
  4318 +static void select_soundhw (const char *optarg)
  4319 +{
  4320 + struct soundhw *c;
  4321 +
  4322 + if (*optarg == '?') {
  4323 + show_valid_cards:
  4324 +
  4325 + printf ("Valid sound card names (comma separated):\n");
  4326 + for (c = soundhw; c->name; ++c) {
  4327 + printf ("%-11s %s\n", c->name, c->descr);
  4328 + }
  4329 + printf ("\n-soundhw all will enable all of the above\n");
4300 4330 exit (*optarg != '?');
4301 4331 }
4302 4332 else {
4303   - struct {
4304   - char *name;
4305   - int *enabledp;
4306   - } soundhw_tab[] = {
4307   - { "sb16", &sb16_enabled },
4308   -#ifdef CONFIG_ADLIB
4309   - { "adlib", &adlib_enabled },
4310   -#endif
4311   -#ifdef CONFIG_GUS
4312   - { "gus", &gus_enabled },
4313   -#endif
4314   - { "es1370", &es1370_enabled },
4315   - };
4316   - size_t tablen, l, i;
  4333 + size_t l;
4317 4334 const char *p;
4318 4335 char *e;
4319 4336 int bad_card = 0;
4320 4337  
4321   - p = optarg;
4322   - tablen = sizeof (soundhw_tab) / sizeof (soundhw_tab[0]);
  4338 + if (!strcmp (optarg, "all")) {
  4339 + for (c = soundhw; c->name; ++c) {
  4340 + c->enabled = 1;
  4341 + }
  4342 + return;
  4343 + }
4323 4344  
  4345 + p = optarg;
4324 4346 while (*p) {
4325 4347 e = strchr (p, ',');
4326 4348 l = !e ? strlen (p) : (size_t) (e - p);
4327   - for (i = 0; i < tablen; ++i) {
4328   - if (!strncmp (soundhw_tab[i].name, p, l)) {
4329   - audio_enabled = 1;
4330   - *soundhw_tab[i].enabledp = 1;
  4349 +
  4350 + for (c = soundhw; c->name; ++c) {
  4351 + if (!strncmp (c->name, p, l)) {
  4352 + c->enabled = 1;
4331 4353 break;
4332 4354 }
4333 4355 }
4334   - if (i == tablen) {
  4356 +
  4357 + if (!c->name) {
4335 4358 if (l > 80) {
4336 4359 fprintf (stderr,
4337 4360 "Unknown sound card name (too big to show)\n");
... ... @@ -4592,13 +4615,6 @@ int main(int argc, char **argv)
4592 4615 break;
4593 4616 #endif
4594 4617 #ifdef HAS_AUDIO
4595   - case QEMU_OPTION_enable_audio:
4596   - audio_enabled = 1;
4597   - sb16_enabled = 1;
4598   - adlib_enabled = 1;
4599   - gus_enabled = 1;
4600   - es1370_enabled = 1;
4601   - break;
4602 4618 case QEMU_OPTION_audio_help:
4603 4619 AUD_help ();
4604 4620 exit (0);
... ...
... ... @@ -126,11 +126,6 @@ void qemu_system_powerdown(void);
126 126  
127 127 void main_loop_wait(int timeout);
128 128  
129   -extern int audio_enabled;
130   -extern int sb16_enabled;
131   -extern int adlib_enabled;
132   -extern int gus_enabled;
133   -extern int es1370_enabled;
134 129 extern int ram_size;
135 130 extern int bios_size;
136 131 extern int rtc_utc;
... ... @@ -621,6 +616,21 @@ typedef struct HeathrowPICS HeathrowPICS;
621 616 void heathrow_pic_set_irq(void *opaque, int num, int level);
622 617 HeathrowPICS *heathrow_pic_init(int *pmem_index);
623 618  
  619 +#ifdef HAS_AUDIO
  620 +struct soundhw {
  621 + const char *name;
  622 + const char *descr;
  623 + int enabled;
  624 + int isa;
  625 + union {
  626 + int (*init_isa) (AudioState *s);
  627 + int (*init_pci) (PCIBus *bus, AudioState *s);
  628 + } init;
  629 +};
  630 +
  631 +extern struct soundhw soundhw[];
  632 +#endif
  633 +
624 634 /* vga.c */
625 635  
626 636 #define VGA_RAM_SIZE (4096 * 1024)
... ...