[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternativ
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw |
Date: |
Thu, 22 Jan 2009 20:31:04 +0100 |
From: Markus Armbruster <address@hidden>
This is in preparation of pci=... support for audio devices. -soundhw
doesn't support the common name=value,... syntax.
---
sysemu.h | 1 +
vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 69 insertions(+), 26 deletions(-)
diff --git a/sysemu.h b/sysemu.h
index 79cbdf0..c47318b 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -199,6 +199,7 @@ void pstrcpy_targphys(target_phys_addr_t dest, int buf_size,
struct soundhw {
const char *name;
const char *descr;
+ const char *opts;
int enabled;
int isa;
union {
diff --git a/vl.c b/vl.c
index cf413c2..736c917 100644
--- a/vl.c
+++ b/vl.c
@@ -3866,6 +3866,8 @@ static void help(int exitcode)
#endif
#ifdef HAS_AUDIO
"-audio-help print list of audio drivers and their options\n"
+ "-audio model=type[,name=str]\n"
+ " enable a sound card\n"
"-soundhw c1,... enable audio support\n"
" and only specified sound cards (comma separated
list)\n"
" use -soundhw ? to get the list of supported
cards\n"
@@ -4034,6 +4036,7 @@ enum {
QEMU_OPTION_portrait,
#ifdef HAS_AUDIO
QEMU_OPTION_audio_help,
+ QEMU_OPTION_audio,
QEMU_OPTION_soundhw,
#endif
@@ -4134,6 +4137,7 @@ static const QEMUOption qemu_options[] = {
{ "k", HAS_ARG, QEMU_OPTION_k },
#ifdef HAS_AUDIO
{ "audio-help", 0, QEMU_OPTION_audio_help },
+ { "audio", HAS_ARG, QEMU_OPTION_audio },
{ "soundhw", HAS_ARG, QEMU_OPTION_soundhw },
#endif
@@ -4268,6 +4272,7 @@ struct soundhw soundhw[] = {
{
"pcspk",
"PC speaker",
+ NULL,
0,
1,
{ .init_isa = pcspk_audio_init }
@@ -4278,6 +4283,7 @@ struct soundhw soundhw[] = {
{
"sb16",
"Creative Sound Blaster 16",
+ NULL,
0,
1,
{ .init_isa = SB16_init }
@@ -4288,6 +4294,7 @@ struct soundhw soundhw[] = {
{
"cs4231a",
"CS4231A",
+ NULL,
0,
1,
{ .init_isa = cs4231a_init }
@@ -4302,6 +4309,7 @@ struct soundhw soundhw[] = {
#else
"Yamaha YM3812 (OPL2)",
#endif
+ NULL,
0,
1,
{ .init_isa = Adlib_init }
@@ -4312,6 +4320,7 @@ struct soundhw soundhw[] = {
{
"gus",
"Gravis Ultrasound GF1",
+ NULL,
0,
1,
{ .init_isa = GUS_init }
@@ -4322,6 +4331,7 @@ struct soundhw soundhw[] = {
{
"ac97",
"Intel 82801AA AC97 Audio",
+ NULL,
0,
0,
{ .init_pci = ac97_init }
@@ -4332,6 +4342,7 @@ struct soundhw soundhw[] = {
{
"es1370",
"ENSONIQ AudioPCI ES1370",
+ NULL,
0,
0,
{ .init_pci = es1370_init }
@@ -4340,60 +4351,88 @@ struct soundhw soundhw[] = {
#endif /* HAS_AUDIO_CHOICE */
- { NULL, NULL, 0, 0, { NULL } }
+ { NULL, NULL, NULL, 0, 0, { NULL } }
};
+static struct soundhw *soundhw_by_name(const char *name)
+{
+ struct soundhw *c;
+
+ for (c = soundhw; c->name; c++) {
+ if (!strcmp (c->name, name))
+ return c;
+ }
+ return NULL;
+}
+
+static void audio_show_models(void)
+{
+ struct soundhw *c;
+
+ for (c = soundhw; c->name; c++)
+ printf ("%-11s %s\n", c->name, c->descr);
+}
+
+static void audio_enable(const char *optarg)
+{
+ char model[16];
+ struct soundhw *c;
+
+ if (!get_param_value(model, sizeof(model), "model", optarg)) {
+ fprintf(stderr, "FIXME need model\n");
+ exit(1);
+ }
+
+ if (!strcmp(model, "?")) {
+ audio_show_models();
+ exit(0);
+ }
+
+ c = soundhw_by_name(model);
+ if (!c) {
+ fprintf(stderr, "FIXME unknown model\n");
+ exit(1);
+ }
+ c->enabled = 1;
+ c->opts = optarg;
+}
+
static void select_soundhw (const char *optarg)
{
struct soundhw *c;
+ char buf[32];
if (*optarg == '?') {
show_valid_cards:
printf ("Valid sound card names (comma separated):\n");
- for (c = soundhw; c->name; ++c) {
- printf ("%-11s %s\n", c->name, c->descr);
- }
+ audio_show_models();
printf ("\n-soundhw all will enable all of the above\n");
exit (*optarg != '?');
}
else {
- size_t l;
const char *p;
- char *e;
int bad_card = 0;
if (!strcmp (optarg, "all")) {
for (c = soundhw; c->name; ++c) {
c->enabled = 1;
+ c->opts = NULL;
}
return;
}
p = optarg;
while (*p) {
- e = strchr (p, ',');
- l = !e ? strlen (p) : (size_t) (e - p);
-
- for (c = soundhw; c->name; ++c) {
- if (!strncmp (c->name, p, l)) {
- c->enabled = 1;
- break;
- }
- }
-
- if (!c->name) {
- if (l > 80) {
- fprintf (stderr,
- "Unknown sound card name (too big to show)\n");
- }
- else {
- fprintf (stderr, "Unknown sound card name `%.*s'\n",
- (int) l, p);
- }
+ p = get_opt_value(buf, sizeof(buf), p);
+ c = soundhw_by_name(buf);
+ if (c) {
+ c->enabled = 1;
+ c->opts = NULL;
+ } else {
+ fprintf (stderr, "Unknown sound card name `%s'\n", buf);
bad_card = 1;
}
- p += l + (e != NULL);
}
if (bad_card)
@@ -4839,6 +4878,9 @@ int main(int argc, char **argv, char **envp)
AUD_help ();
exit (0);
break;
+ case QEMU_OPTION_audio:
+ audio_enable(optarg);
+ break;
case QEMU_OPTION_soundhw:
select_soundhw (optarg);
break;
--
1.6.0.6
- [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses, Markus Armbruster, 2009/01/22
- [Qemu-devel] [PATCH 9/9] Support pci=... in option argument of -audio, Markus Armbruster, 2009/01/22
- [Qemu-devel] [PATCH 3/9] Support pci=... in option argument of -vga, Markus Armbruster, 2009/01/22
- [Qemu-devel] [PATCH 2/9] Clean up handling of name=value, ... part of -vga option argument, Markus Armbruster, 2009/01/22
- [Qemu-devel] [PATCH 5/9] Support pci=... in option argument of -net nic, Markus Armbruster, 2009/01/22
- [Qemu-devel] [PATCH 4/9] Convert virtio_init_pci() to pci_register_device_2(), Markus Armbruster, 2009/01/22
- [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw,
Markus Armbruster <=
- Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw, malc, 2009/01/22
- Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw, Markus Armbruster, 2009/01/23
- Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw, Kevin Wolf, 2009/01/23
- Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw, Markus Armbruster, 2009/01/23
- Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw, Kevin Wolf, 2009/01/23
- Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw, Markus Armbruster, 2009/01/23
[Qemu-devel] [PATCH 1/9] PCI device registration helpers, Markus Armbruster, 2009/01/22
[Qemu-devel] [PATCH 7/9] Support pci=... in option argument of -drive if=virtio, Markus Armbruster, 2009/01/22
[Qemu-devel] [PATCH 6/9] Make drives_opt[] accessible from device initialization, Markus Armbruster, 2009/01/22
Re: [Qemu-devel] [RFC PATCH 0/9] Configurable PCI device addresses, Anthony Liguori, 2009/01/22