Skip to contentSkip to conversation

Add support for a USB audio device model

RFC PATCH In review H. Peter Anvin 8 participants 20 messages Sep 10, 2010 – Oct 14, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Add support for a USB audio device model

I discovered that none of the audio device models supported by current Qemu/KVM appear to be supported out of the box on Win7 64 bit (AC97 works fine on 32 bit). The most logical ways to fix that would be to add a long-term supportable audio device model. Intel HD Audio and USB Audio seemed like the most reasonable options, but I opted for USB Audio for a few reasons:

a) as an external plugin device, it is more likely that it will be supported across a large number of guest operating systems for a very long time.
b) as a vendor-independent class device, it is supported by the OS developers directly without any of the potential strange issues involved with relying on a vendor driver.
c) USB Audio is highly parameterizable, which would make it possible to export all kinds of different audio models to the guest. Note that due to the software-scheduled nature of [UOE]HCI, however, surround sound support (more than 4 channels) would require a High Speed device model with EHCI, or the guest OS will reject it as unschedulable (since it will exceed the schedulable bandwidth of a Full Speed USB bus.)

This patch adds support for a USB audio device model. It is based mostly on the "USB Basic Audio Device Specification", which consists of a set of profiles for the much more general "USB Audio Specification". In accordance with the above profile, it supports 48 kHz, 16-bit stereo only.

It does work, "so far, so good". However, it doesn't really provide a fully acceptable audio quality, because it suffers from a fundamental problem -- the rate of data provided by UHCI may not match the consumption rate of the sink. I don't understand the Qemu audio subsystem well enough to know how to deal with that, which is why I would like comments and/or help (I really have spent way more time than I should on this already). The full USB Audio specification has an optional concept of synchronization packets (a reverse channel which carry data rate information to be used for rate matching); this is specified in section 5.12.4.2 of the USB 2.0 specification (or 5.10.4.2 of USB 1.1). However, it isn't very clear to me how to get the relevant information out of the Qemu audio system.

Quoted 1 line

From a device model point of view, a data packet will arrive once per

1 ms of USB time; this can be the time basis. Presumably this needs to be used to compare against the number of samples actually consumed to construct the functional sample rate on the USB clock, as long as that information can be acquired.

---
 Makefile.objs  |    1 +
 arch_init.c    |   24 ++-
 configure      |    6 +-
 create_config  |    4 +-
 hw/audiodev.h  |    4 +
 hw/pc.c        |   14 +-
 hw/pc_piix.c   |    4 +-
 hw/usb-audio.c |  702 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/usb-net.c   |    3 -
 hw/usb.h       |   13 +-
 qemu-common.h  |    5 +
 sysemu.h       |   11 +-
 12 files changed, 764 insertions(+), 27 deletions(-)
 create mode 100644 hw/usb-audio.c
Makefile.objs +1 -0
index dbee210..8b5b908 100644
@@ -245,6 +245,7 @@ sound-obj-$(CONFIG_AC97) += ac97.o
 sound-obj-$(CONFIG_ADLIB) += fmopl.o adlib.o
 sound-obj-$(CONFIG_GUS) += gus.o gusemu_hal.o gusemu_mixer.o
 sound-obj-$(CONFIG_CS4231A) += cs4231a.o
+sound-obj-$(CONFIG_USB_AUDIO) += usb-audio.o
 
 adlib.o fmopl.o: QEMU_CFLAGS += -DBUILD_Y8950=0
 hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
arch_init.c +17 -7
index e468c0c..68e5643 100644
@@ -430,7 +430,7 @@ struct soundhw soundhw[] = {
         "pcspk",
         "PC speaker",
         0,
-        1,
+        BUS_ISA,
         { .init_isa = pcspk_audio_init }
     },
 #endif
@@ -440,7 +440,7 @@ struct soundhw soundhw[] = {
         "sb16",
         "Creative Sound Blaster 16",
         0,
-        1,
+        BUS_ISA,
         { .init_isa = SB16_init }
     },
 #endif
@@ -450,7 +450,7 @@ struct soundhw soundhw[] = {
         "cs4231a",
         "CS4231A",
         0,
-        1,
+        BUS_ISA,
         { .init_isa = cs4231a_init }
     },
 #endif
@@ -464,7 +464,7 @@ struct soundhw soundhw[] = {
         "Yamaha YM3812 (OPL2)",
 #endif
         0,
-        1,
+        BUS_ISA,
         { .init_isa = Adlib_init }
     },
 #endif
@@ -474,7 +474,7 @@ struct soundhw soundhw[] = {
         "gus",
         "Gravis Ultrasound GF1",
         0,
-        1,
+        BUS_ISA,
         { .init_isa = GUS_init }
     },
 #endif
@@ -484,7 +484,7 @@ struct soundhw soundhw[] = {
         "ac97",
         "Intel 82801AA AC97 Audio",
         0,
-        0,
+        BUS_PCI,
         { .init_pci = ac97_init }
     },
 #endif
@@ -494,11 +494,21 @@ struct soundhw soundhw[] = {
         "es1370",
         "ENSONIQ AudioPCI ES1370",
         0,
-        0,
+        BUS_PCI,
         { .init_pci = es1370_init }
     },
 #endif
 
+#ifdef CONFIG_USB_AUDIO
+    {
+        "usb",
+        "USB Audio",
+        0,
+        BUS_USB,
+        { .init_usb = usb_audio_soundhw_init }
+    },
+#endif
+
 #endif /* HAS_AUDIO_CHOICE */
 
     { NULL, NULL, 0, 0, { NULL } }
configure +3 -3
index 8228c1c..4fcb829 100755
@@ -71,8 +71,8 @@ sparc_cpu=""
 cross_prefix=""
 cc="gcc"
 audio_drv_list=""
-audio_card_list="ac97 es1370 sb16"
-audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
+audio_card_list="ac97 es1370 sb16 usb-audio"
+audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus usb-audio"
 block_drv_whitelist=""
 host_cc="gcc"
 ar="ar"
@@ -2414,7 +2414,7 @@ if test "$vde" = "yes" ; then
 fi
 for card in $audio_card_list; do
     def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
-    echo "$def=y" >> $config_host_mak
+    echo ${def//-/_}=y >> $config_host_mak
 done
 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
 for drv in $audio_drv_list; do
create_config +3 -1
index 0098e68..1caa25b 100755
@@ -25,7 +25,7 @@ case $line in
  CONFIG_AUDIO_DRIVERS=*)
     drivers=${line#*=}
     echo "#define CONFIG_AUDIO_DRIVERS \\"
-    for drv in $drivers; do
+    for drv in ${drivers//-/_}; do
       echo "    &${drv}_audio_driver,\\"
     done
     echo ""
@@ -39,10 +39,12 @@ case $line in
     ;;
  CONFIG_*=y) # configuration
     name=${line%=*}
+    name=${name//-/_}
     echo "#define $name 1"
     ;;
  CONFIG_*=*) # configuration
     name=${line%=*}
+    name=${name//-/_}
     value=${line#*=}
     echo "#define $name $value"
     ;;
hw/audiodev.h +4 -0
index 39a729b..24daef4 100644
@@ -15,3 +15,7 @@ int ac97_init(PCIBus *buf);
 
 /* cs4231a.c */
 int cs4231a_init(qemu_irq *pic);
+
+/* usb-audio.c */
+int usb_audio_soundhw_init(USBBus *bus);
+
hw/pc.c +11 -3
index 9c08573..c456189 100644
@@ -756,13 +756,21 @@ void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic)
 
     for (c = soundhw; c->name; ++c) {
         if (c->enabled) {
-            if (c->isa) {
+	    switch (c->bus) {
+	    case BUS_ISA:
                 c->init.init_isa(pic);
-            } else {
+		break;
+	    case BUS_PCI:
                 if (pci_bus) {
                     c->init.init_pci(pci_bus);
                 }
-            }
+		break;
+	    case BUS_USB:
+		if (usb_enabled) {
+                    c->init.init_usb(NULL /* FIXME */);
+                }
+		break;
+	    }
         }
     }
 }
hw/pc_piix.c +2 -2
index 3d07ce5..5c98b63 100644
@@ -167,8 +167,6 @@ static void pc_init1(ram_addr_t ram_size,
         }
     }
 
-    pc_audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
-
     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
                  idebus[0], idebus[1], floppy_controller, rtc_state);
 
@@ -176,6 +174,8 @@ static void pc_init1(ram_addr_t ram_size,
         usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
     }
 
+    pc_audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
+
     if (pci_enabled && acpi_enabled) {
         uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
         i2c_bus *smbus;
hw/usb-audio.c new file +702 -0

702 lines not on this page · raw message

hw/usb-net.c +0 -3
index 70f9263..61469f3 100644
@@ -68,9 +68,6 @@ enum usbstring_idx {
 #define USB_CDC_UNION_TYPE		0x06	/* union_desc */
 #define USB_CDC_ETHERNET_TYPE		0x0f	/* ether_desc */
 
-#define USB_DT_CS_INTERFACE		0x24
-#define USB_DT_CS_ENDPOINT		0x25
-
 #define USB_CDC_SEND_ENCAPSULATED_COMMAND	0x00
 #define USB_CDC_GET_ENCAPSULATED_RESPONSE	0x01
 #define USB_CDC_REQ_SET_LINE_CODING		0x20
hw/usb.h +7 -6
index 00d2802..40fd9bd 100644
@@ -67,6 +67,11 @@
 #define USB_CLASS_APP_SPEC		0xfe
 #define USB_CLASS_VENDOR_SPEC		0xff
 
+#define USB_SUBCLASS_UNDEFINED		0
+#define USB_SUBCLASS_AUDIO_CONTROL	1
+#define USB_SUBCLASS_AUDIO_STREAMING	2
+#define USB_SUBCLASS_AUDIO_MIDISTREAMING 3
+
 #define USB_DIR_OUT			0
 #define USB_DIR_IN			0x80
 
@@ -116,18 +121,14 @@
 #define USB_DT_STRING			0x03
 #define USB_DT_INTERFACE		0x04
 #define USB_DT_ENDPOINT			0x05
+#define USB_DT_CS_INTERFACE		0x24
+#define USB_DT_CS_ENDPOINT		0x25
 
 #define USB_ENDPOINT_XFER_CONTROL	0
 #define USB_ENDPOINT_XFER_ISOC		1
 #define USB_ENDPOINT_XFER_BULK		2
 #define USB_ENDPOINT_XFER_INT		3
 
-typedef struct USBBus USBBus;
-typedef struct USBPort USBPort;
-typedef struct USBDevice USBDevice;
-typedef struct USBDeviceInfo USBDeviceInfo;
-typedef struct USBPacket USBPacket;
-
 /* definition of a USB device */
 struct USBDevice {
     DeviceState qdev;
qemu-common.h +5 -0
index dfd3dc0..650ab17 100644
@@ -229,6 +229,11 @@ typedef struct I2SCodec I2SCodec;
 typedef struct SSIBus SSIBus;
 typedef struct EventNotifier EventNotifier;
 typedef struct VirtIODevice VirtIODevice;
+typedef struct USBBus USBBus;
+typedef struct USBPort USBPort;
+typedef struct USBDevice USBDevice;
+typedef struct USBDeviceInfo USBDeviceInfo;
+typedef struct USBPacket USBPacket;
 
 typedef uint64_t pcibus_t;
 
sysemu.h +9 -2
index 98bd47d..4bf8a20 100644
@@ -172,14 +172,21 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
 #ifdef HAS_AUDIO
+enum bus_type {
+    BUS_PCI,
+    BUS_ISA,
+    BUS_USB,
+};
+
 struct soundhw {
     const char *name;
     const char *descr;
     int enabled;
-    int isa;
+    enum bus_type bus;
     union {
-        int (*init_isa) (qemu_irq *pic);
         int (*init_pci) (PCIBus *bus);
+        int (*init_isa) (qemu_irq *pic);
+        int (*init_usb) (USBBus *bus);
     } init;
 };
 
Signature · 1 line
1.7.2.1
#1 lore raw
Quoted 6 lines · H. Peter Anvin

I discovered that none of the audio device models supported by current Qemu/KVM appear to be supported out of the box on Win7 64 bit (AC97 works fine on 32 bit). The most logical ways to fix that would be to add a long-term supportable audio device model. Intel HD Audio and USB Audio seemed like the most reasonable options, but I opted for USB Audio for a few reasons:

I'll look at it tomorow, in the meantime it would be great to know how to test it (i.e. how to build the kernel which includes the driver for this thing)

Oh and is the audio output bad when using linux guest too? (I don't have any windows guests to test this part of the equation)

P.S. The patches have lot's of tabs in them btw.

P.P.S. There's an extension to your Intel HDA Audio option:
to get the HDA code from VirtualBox and "port" it to QEMU.

[..snip..]

Signature · 1 line
mailto:[email protected]
#2 lore raw
Quoted 9 lines · malc
Quoted 6 lines · H. Peter Anvin

I discovered that none of the audio device models supported by current Qemu/KVM appear to be supported out of the box on Win7 64 bit (AC97 works fine on 32 bit). The most logical ways to fix that would be to add a long-term supportable audio device model. Intel HD Audio and USB Audio seemed like the most reasonable options, but I opted for USB Audio for a few reasons:

Quoted 3 lines

I'll look at it tomorow, in the meantime it would be great to know how to test it (i.e. how to build the kernel which includes the driver for this thing)

Any remotely recent stock distro should have support for it. I say "should", because I haven't actually tested it with a Linux guest yet.

I'll try to do that later; I have to leave now.

Quoted 2 lines

Oh and is the audio output bad when using linux guest too? (I don't have any windows guests to test this part of the equation)

Yes; I also have an stderr message in the patch

Quoted 1 line

P.S. The patches have lot's of tabs in them btw.

*Sigh* my tools are tuned to Linux kernel development, I'm afraid.

Quoted 2 lines

P.P.S. There's an extension to your Intel HDA Audio option:
to get the HDA code from VirtualBox and "port" it to QEMU.

I know. Someone else is welcome to do that... since it would require knowing both the VirtualBox and the Qemu sound subsystem interfaces and in what ways they are similar or different.

-hpa

#3 lore raw
Quoted 6 lines · H. Peter Anvin

Any remotely recent stock distro should have support for it. I say "should", because I haven't actually tested it with a Linux guest yet.

I'll try to do that later; I have to leave now.

Just tested it on a stock Fedora 13 64 bit VM; it behaves exactly the same way as under Win7.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#4 lore raw
Quoted 10 lines · H. Peter Anvin
Quoted 6 lines · H. Peter Anvin

Any remotely recent stock distro should have support for it. I say "should", because I haven't actually tested it with a Linux guest yet.

I'll try to do that later; I have to leave now.

Just tested it on a stock Fedora 13 64 bit VM; it behaves exactly the same way as under Win7.

Just for the sake of completeness, the Qemu command line was:

~/qemu/git-kvm/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 2 -m 1024 -usb -soundhw usb -hda qemu-fc13-64.img -serial stdio

... and this was with the usb-audio patch applied against top of the the qemu-kvm git tree (the patch applies against the top of the main qemu tree too, but because KVM isn't very stable there it was faster to use the KVM tree.)

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#9 lore raw
In reply to H. Peter Anvin

hw/usb-audio.c line 5

Quoted 11 lines · H. Peter Anvin
hw/usb-audio.c new file +5 -0
new file mode 100644
index 0000000..d4cf488
@@ -0,0 +1,702 @@
+/*
+ * QEMU USB Net devices
+ *
+ * Copyright (c) 2006 Thomas Sailer
+ * Copyright (c) 2008 Andrzej Zaborowski

Want to update this for usb-audio?

Stefan

#7 lore raw
In reply to H. Peter Anvin

On 11.09.2010, at 03:08, H. Peter Anvin wrote:

[snip]

Quoted 3 lines

I know. Someone else is welcome to do that... since it would require knowing both the VirtualBox and the Qemu sound subsystem interfaces and in what ways they are similar or different.

They should be reasonably close. About 80% of the VBox device model consists of qemu, mangled through an OS2'ifier.

Alex

#5 lore raw
In reply to H. Peter Anvin
Quoted 12 lines · H. Peter Anvin
Quoted 10 lines · H. Peter Anvin
Quoted 6 lines · H. Peter Anvin

Any remotely recent stock distro should have support for it. I say "should", because I haven't actually tested it with a Linux guest yet.

I'll try to do that later; I have to leave now.

Just tested it on a stock Fedora 13 64 bit VM; it behaves exactly the same way as under Win7.

Sorry but I have no idea what "stock Fedora 13 64 bit VM" is.

Quoted 9 lines

Just for the sake of completeness, the Qemu command line was:

~/qemu/git-kvm/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 2 -m 1024 -usb -soundhw usb -hda qemu-fc13-64.img -serial stdio

... and this was with the usb-audio patch applied against top of the the qemu-kvm git tree (the patch applies against the top of the main qemu tree too, but because KVM isn't very stable there it was faster to use the KVM tree.)

^^^ this doesn't parse, somewhere QEMU was replaced by KVM i think

Anywho, i tried it with linux-test and custom/minimal compiled 2.6.32 [1]

x86_64-softmmu/qemu-system-x86_64 -kernel \
~/x/bld/linux-2.6.32/arch/x86_64/boot/bzImage -append "root=/dev/hda" \
-vnc :0 -soundhw usb ~/x/img/linux-0.2.img -usb [-enable-kvm]
^^^ this has no consequence [2]

Inside the guest `$ madplay 20thfull.mp2' and things sounded fine with OSS, with ALSA the story is somewhat different, it stuttered for a while but then settled and things went back to smooth playback.

So i need a reproduction scenario

[1] .config available on request
[2] Well actually it has - on the speed `-enable-kvm' makes boot sluggish for whatever reason

Signature · 1 line
mailto:[email protected]
#6 lore raw

I meant just take the Fedora 13 DVD and install it onto a virtual hard disk. More later when I'm at a real computer.

Quoted 48 lines · malc
Quoted 12 lines · H. Peter Anvin
Quoted 10 lines · H. Peter Anvin
Quoted 6 lines · H. Peter Anvin

Any remotely recent stock distro should have support for it. I say "should", because I haven't actually tested it with a Linux guest yet.

I'll try to do that later; I have to leave now.

Just tested it on a stock Fedora 13 64 bit VM; it behaves exactly the same way as under Win7.

Sorry but I have no idea what "stock Fedora 13 64 bit VM" is.

Quoted 9 lines

Just for the sake of completeness, the Qemu command line was:

~/qemu/git-kvm/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 2 -m 1024 -usb -soundhw usb -hda qemu-fc13-64.img -serial stdio

... and this was with the usb-audio patch applied against top of the the qemu-kvm git tree (the patch applies against the top of the main qemu tree too, but because KVM isn't very stable there it was faster to use the KVM tree.)

^^^ this doesn't parse, somewhere QEMU was replaced by KVM i think

Anywho, i tried it with linux-test and custom/minimal compiled 2.6.32 [1]

x86_64-softmmu/qemu-system-x86_64 -kernel \
~/x/bld/linux-2.6.32/arch/x86_64/boot/bzImage -append "root=/dev/hda" \
-vnc :0 -soundhw usb ~/x/img/linux-0.2.img -usb [-enable-kvm]
^^^ this has no consequence [2]

Inside the guest `$ madplay 20thfull.mp2' and things sounded fine with OSS, with ALSA the story is somewhat different, it stuttered for a while but then settled and things went back to smooth playback.

So i need a reproduction scenario

[1] .config available on request
[2] Well actually it has - on the speed `-enable-kvm' makes boot sluggish for whatever reason

Signature · 1 line
mailto:[email protected]
Signature · 1 line
Sent from my mobile phone.  Please pardon any lack of formatting.
#8 lore raw
In reply to Alexander Graf

It would certainly be a worthwhile project.

Quoted 14 lines · Alexander Graf

On 11.09.2010, at 03:08, H. Peter Anvin wrote:

[snip]

Quoted 3 lines

I know. Someone else is welcome to do that... since it would require knowing both the VirtualBox and the Qemu sound subsystem interfaces and in what ways they are similar or different.

They should be reasonably close. About 80% of the VBox device model consists of qemu, mangled through an OS2'ifier.

Alex

Signature · 1 line
Sent from my mobile phone.  Please pardon any lack of formatting.
#10 lore raw
In reply to Stefan Hajnoczi
Quoted 15 lines · Stefan Hajnoczi

hw/usb-audio.c line 5

Quoted 11 lines · H. Peter Anvin
hw/usb-audio.c new file +5 -0
new file mode 100644
index 0000000..d4cf488
@@ -0,0 +1,702 @@
+/*
+ * QEMU USB Net devices
+ *
+ * Copyright (c) 2006 Thomas Sailer
+ * Copyright (c) 2008 Andrzej Zaborowski

Want to update this for usb-audio?

Quoted 1 line

Stefan

Yeah, obviously...

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#11 lore raw
In reply to H. Peter Anvin
Quoted 6 lines · H. Peter Anvin

I discovered that none of the audio device models supported by current Qemu/KVM appear to be supported out of the box on Win7 64 bit (AC97 works fine on 32 bit). The most logical ways to fix that would be to add a long-term supportable audio device model. Intel HD Audio and USB Audio seemed like the most reasonable options, but I opted for USB Audio for a few reasons:

...

Quoted 16 lines
configure +2 -2
index 8228c1c..4fcb829 100755
@@ -71,8 +71,8 @@ sparc_cpu=""
 cross_prefix=""
 cc="gcc"
 audio_drv_list=""
-audio_card_list="ac97 es1370 sb16"
-audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
+audio_card_list="ac97 es1370 sb16 usb-audio"
+audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus usb-audio"
 block_drv_whitelist=""
 host_cc="gcc"
 ar="ar"

configure if test "$vde" = "yes" ; then · line 2420

Quoted 8 lines
configure +1 -1
@@ -2414,7 +2414,7 @@ if test "$vde" = "yes" ; then
 fi
 for card in $audio_card_list; do
     def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
-    echo "$def=y" >> $config_host_mak
+    echo ${def//-/_}=y >> $config_host_mak
 done
 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
 for drv in $audio_drv_list; do
# patch -p1 < /tmp/usb-audio.patch
# ./configure
...
...
preadv support    yes
fdatasync         yes
uuid support      no
vhost-net support no
Trace backend     nop
Trace output file trace-<pid>
./configure: 2276: Bad substitution
Quoted 26 lines
create_config +3 -1
index 0098e68..1caa25b 100755
@@ -25,7 +25,7 @@ case $line in
  CONFIG_AUDIO_DRIVERS=*)
     drivers=${line#*=}
     echo "#define CONFIG_AUDIO_DRIVERS \\"
-    for drv in $drivers; do
+    for drv in ${drivers//-/_}; do
       echo "    &${drv}_audio_driver,\\"
     done
     echo ""
@@ -39,10 +39,12 @@ case $line in
     ;;
  CONFIG_*=y) # configuration
     name=${line%=*}
+    name=${name//-/_}
     echo "#define $name 1"
     ;;
  CONFIG_*=*) # configuration
     name=${line%=*}
+    name=${name//-/_}
     value=${line#*=}
     echo "#define $name $value"
     ;;

...

#12 lore raw
Quoted 13 lines · Amos Kong
# patch -p1 < /tmp/usb-audio.patch
# ./configure
...
...
preadv support    yes
fdatasync         yes
uuid support      no
vhost-net support no
Trace backend     nop
Trace output file trace-<pid>
./configure: 2276: Bad substitution

What shell is your /bin/sh?

-hpa

#19 lore raw
In reply to Amos Kong
Quoted 32 lines · Amos Kong
# patch -p1 < /tmp/usb-audio.patch
# ./configure
...
...
preadv support    yes
fdatasync         yes
uuid support      no
vhost-net support no
Trace backend     nop
Trace output file trace-<pid>
./configure: 2276: Bad substitution
Quoted 18 lines
create_config +2 -1
index 0098e68..1caa25b 100755
@@ -25,7 +25,7 @@ case $line in
  CONFIG_AUDIO_DRIVERS=*)
     drivers=${line#*=}
     echo "#define CONFIG_AUDIO_DRIVERS \\"
-    for drv in $drivers; do
+    for drv in ${drivers//-/_}; do
       echo "    &${drv}_audio_driver,\\"
     done
     echo ""
@@ -39,10 +39,12 @@ case $line in
     ;;
  CONFIG_*=y) # configuration
     name=${line%=*}
+    name=${name//-/_}
Quoted 8 lines

create_config case $line in · line 50

Quoted 8 lines
create_config +1 -0
     echo "#define $name 1"
     ;;
  CONFIG_*=*) # configuration
     name=${line%=*}
+    name=${name//-/_}
     value=${line#*=}
     echo "#define $name $value"
     ;;

Looks like ${.../...} is a bashism.

One can replace it with:

name=echo "$name" | tr '-' '_'

and

for drv in echo "$drivers" | tr '-' '_'; do

-hpa

#13 lore raw
In reply to H. Peter Anvin
Quoted 14 lines · H. Peter Anvin
Quoted 13 lines · Amos Kong
# patch -p1 < /tmp/usb-audio.patch
# ./configure
...
...
preadv support    yes
fdatasync         yes
uuid support      no
vhost-net support no
Trace backend     nop
Trace output file trace-<pid>
./configure: 2276: Bad substitution

Hello Peter,

Quoted 1 line

What shell is your /bin/sh?

dash,
It's fine when using bash, I suggest to use a common way.

I've heard wonderful music (guest:win7), but mixed with a litte noise, not so fluent. The following debug msg is normal?

# ./x86_64-softmmu/qemu-system-x86_64 ~/win7-32.qcow2 -m 1024 -vnc :0 -usbdevice tablet -cpu qemu64  -enable-kvm -bios pc-bios/bios.bin -net nic,netdev=idkQlbc8,macaddr=02:BB:3A:D3:b8:29 -netdev tap,id=idkQlbc8,ifname=virtio_0_8000,script=/etc/qemu-ifup-vbr0,downscript=no,vhost=on -snapshot -usb -soundhw usb 
usb_create: no bus specified, using "usb.0" for "usb-audio"
usb-audio: reset
usb-audio: control transaction: request 0x0005 value 0x0001 index 0x0000 length 0x0000
usb-audio: control transaction: request 0x8006 value 0x0100 index 0x0000 length 0x0008
usb-audio: control transaction: request 0x8006 value 0x0200 index 0x0000 length 0x0009
usb-audio: control transaction: request 0x8006 value 0x0200 index 0x0000 length 0x0071
usb-audio: reset
usb-audio: reset
usb-audio: control transaction: request 0x8006 value 0x0100 index 0x0000 length 0x0040
usb-audio: reset
usb-audio: control transaction: request 0x0005 value 0x0001 index 0x0000 length 0x0000
usb-audio: control transaction: request 0x8006 value 0x0100 index 0x0000 length 0x0012
usb-audio: control transaction: request 0x8006 value 0x0200 index 0x0000 length 0x00ff
usb-audio: control transaction: request 0x8006 value 0x03ee index 0x0000 length 0x0012
usb-audio: control transaction: request 0x8006 value 0x0303 index 0x0409 length 0x00ff
usb-audio: control transaction: request 0x8006 value 0x0300 index 0x0000 length 0x00ff
usb-audio: control transaction: request 0x8006 value 0x0302 index 0x0409 length 0x00ff
usb-audio: control transaction: request 0x8006 value 0x0600 index 0x0000 length 0x000a
usb-audio: failed control transaction: request 0x8006 value 0x0600 index 0x0000 length 0x000a
usb-audio: control transaction: request 0x8006 value 0x0100 index 0x0000 length 0x0012
usb-audio: control transaction: request 0x8006 value 0x0200 index 0x0000 length 0x0009
usb-audio: control transaction: request 0x8006 value 0x0200 index 0x0000 length 0x0071
usb-audio: control transaction: request 0x0009 value 0x0001 index 0x0000 length 0x0000
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: control transaction: request 0x8006 value 0x0305 index 0x0409 length 0x0004
usb-audio: control transaction: request 0x8006 value 0x0305 index 0x0409 length 0x002c
usb-audio: control transaction: request 0x8006 value 0x0307 index 0x0409 length 0x004a
usb-audio: control transaction: request 0x8006 value 0x0308 index 0x0409 length 0x0004
usb-audio: control transaction: request 0x8006 value 0x0308 index 0x0409 length 0x003e
usb-audio: control transaction: request 0xa181 value 0x0100 index 0x0200 length 0x0001
usb-audio: control transaction: request 0xa181 value 0x0201 index 0x0200 length 0x0002
usb-audio: control transaction: request 0xa182 value 0x0201 index 0x0200 length 0x0002
usb-audio: control transaction: request 0xa183 value 0x0201 index 0x0200 length 0x0002
usb-audio: control transaction: request 0xa184 value 0x0201 index 0x0200 length 0x0002
usb-audio: control transaction: request 0xa181 value 0x0202 index 0x0200 length 0x0002
usb-audio: control transaction: request 0xa182 value 0x0202 index 0x0200 length 0x0002
usb-audio: control transaction: request 0xa183 value 0x0202 index 0x0200 length 0x0002
usb-audio: control transaction: request 0xa184 value 0x0202 index 0x0200 length 0x0002
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: control transaction: request 0x010b value 0x0001 index 0x0001 length 0x0000
usb-audio: set interface 1
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: set interface 0
usb-audio: control transaction: request 0x010b value 0x0001 index 0x0001 length 0x0000
usb-audio: set interface 1
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: set interface 0
usb-audio: control transaction: request 0x010b value 0x0001 index 0x0001 length 0x0000
usb-audio: set interface 1
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: set interface 0
usb-audio: control transaction: request 0x010b value 0x0001 index 0x0001 length 0x0000
usb-audio: set interface 1
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: set interface 0
usb-audio: control transaction: request 0x010b value 0x0001 index 0x0001 length 0x0000
usb-audio: set interface 1
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: set interface 0
usb-audio: control transaction: request 0x010b value 0x0001 index 0x0001 length 0x0000
usb-audio: set interface 1
usb-audio: control transaction: request 0x010b value 0x0000 index 0x0001 length 0x0000
usb-audio: set interface 0
usb-audio: control transaction: request 0x010b value 0x0001 index 0x0001 length 0x0000
usb-audio: set interface 1
#14 lore raw
Quoted 8 lines · Amos Kong

Hello Peter,

Quoted 1 line

What shell is your /bin/sh?

dash,
It's fine when using bash, I suggest to use a common way.

Yes, I'll fix it.

Quoted 2 lines

I've heard wonderful music (guest:win7), but mixed with a litte noise, not so fluent. The following debug msg is normal?

Yes, all of that is normal. I talked to malc earlier today, and I think I have a pretty good idea for how to deal with the rate-matching issues; I'm going to try to write it up tomorrow.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#15 lore raw
Quoted 7 lines · H. Peter Anvin
Quoted 2 lines · Amos Kong

I've heard wonderful music (guest:win7), but mixed with a litte noise, not so fluent. The following debug msg is normal?

Yes, all of that is normal.  I talked to malc earlier today, and I think I have a pretty good idea for how to deal with the rate-matching issues; I'm going to try to write it up tomorrow.

Hi,

Was just wondering if you've been able to put some time to the rate-matching issues?

Has this usb-audio patch evolved and I'm just missing it?

Thanks for doing this work!
Mike

#16 lore raw
Quoted 9 lines · Mike Snitzer

Was just wondering if you've been able to put some time to the rate-matching issues?

Has this usb-audio patch evolved and I'm just missing it?

Thanks for doing this work!
Mike

The sad result really is: it doesn't work, and it probably will never work.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#17 lore raw
Quoted 5 lines · ----- "H. Peter Anvin
Quoted 4 lines · Mike Snitzer

Was just wondering if you've been able to put some time to the rate-matching issues?

Quoted 9 lines
Quoted 5 lines

Has this usb-audio patch evolved and I'm just missing it?

Thanks for doing this work!
Mike

The sad result really is: it doesn't work, and it probably will never work.

Can you elaborate?

Quoted 5 lines

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#18 lore raw
Quoted 3 lines · Alon Levy

Can you elaborate?

The quality of rate information is too low, and the delays in the system are too large to enable consistent convergence.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.