Added functionality for E-mu 0404USB/0202USB/TrackerPre
PATCH 1/1 Added functionality for E-mu 0404USB/0202USB/TrackerPre
Added functionality:
1) Extension Units support (all XU settings now available at alsamixer, kmix, etc):
- "AnalogueIn soft limiter" switch;
- "Sample rate" selector (values 0,1,2,3,4,5 corresponds to 44.1 48 ... 192 kHz);
- "DigitalIn CLK source" selector (internal/external) (**);
- "DigitalOut format SPDIF/AC3" switch (**);
(**)E-mu-0404usb only.
2) Automatic device sample rate adjustment depending on substream samplerate for both capture and playback substream.
Patch is based on Mac OS-X driver (http://sourceforge.net/projects/zaudiodrivermac/) and successfully tested by Ubuntu community users for 0404usb and 0202usb.
--- sound/usb/usbaudio.c | 44 ++++++++++++++++++++++++++++++ sound/usb/usbaudio.h | 2 + sound/usb/usbmixer.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 115 insertions(+), 4 deletions(-)
sound/usb/usbaudio.c +44 -0
@@ -1271,6 +1271,42 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, }/* +* For E-Mu 0404USB/0202USB/TrackerPre sample rate should be set for device, +* not for interface. +*/ +static void set_format_emu_quirk (struct snd_usb_substream *subs,struct audioformat *fmt) +{ +unsigned char emu_samplerate_id =0 ; + +/* When capture is active sample rate shouldn't be changed by playback substream*/ +if (subs->direction ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE ].interface !=-1 ) +return ; + } + +switch (fmt->rate_min) { +case 48000 : + emu_samplerate_id =1 ; +break ; +case 88200 : + emu_samplerate_id =2 ; +break ; +case 96000 : + emu_samplerate_id =3 ; +break ; +case 176400 : + emu_samplerate_id =4 ; +break ; +case 192000 : + emu_samplerate_id =5 ; +break ; +default : + emu_samplerate_id =0 ; + } +snd_emuusb_set_samplerate (subs->stream->chip, emu_samplerate_id); +} + +/* * find a matching format and set up the interface */ static int set_format (struct snd_usb_substream *subs,struct audioformat *fmt)
@@ -1383,6 +1419,14 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) subs->cur_audiofmt = fmt; +switch (subs->stream->chip->usb_id) { +case USB_ID (0x041e ,0x3f02 ):/* E-Mu 0202 USB */ +case USB_ID (0x041e ,0x3f04 ):/* E-Mu 0404 USB */ +case USB_ID (0x041e ,0x3f0a ):/* E-Mu Tracker Pre */ +set_format_emu_quirk (subs, fmt); +break ; + } +#if 0 printk(KERN_DEBUG "setting done: format = %d, rate = %d..%d, channels = %d\n",
sound/usb/usbaudio.h +2 -0
@@ -233,6 +233,8 @@ void snd_usbmidi_input_stop(struct list_head* p);void snd_usbmidi_input_start (struct list_head * p);void snd_usbmidi_disconnect (struct list_head *p); +void snd_emuusb_set_samplerate (struct snd_usb_audio *chip,unsigned char samplerate_id); +/* * retrieve usb_interface descriptor from the host interface * (conditional for compatibility with the older API)
sound/usb/usbmixer.c +69 -4
103 lines not on this page · raw message
Signature · 1 line
1.6.5.6
At Mon, 21 Dec 2009 12:39:27 -0800 (PST),
Quoted 9 lines · Zerg Cannibal
Added functionality:
1) Extension Units support (all XU settings now available at alsamixer, kmix, etc):
- "AnalogueIn soft limiter" switch;
- "Sample rate" selector (values 0,1,2,3,4,5 corresponds to 44.1 48 ... 192 kHz);
- "DigitalIn CLK source" selector (internal/external) (**);
- "DigitalOut format SPDIF/AC3" switch (**);
(**)E-mu-0404usb only.
Quoted 5 lines
2) Automatic device sample rate adjustment depending on substream samplerate for both capture and playback substream.
Patch is based on Mac OS-X driver (http://sourceforge.net/projects/zaudiodrivermac/) and successfully tested by Ubuntu community users for 0404usb and 0202usb.
Signed-off-by CannibalZerg <[email protected]>
Thanks for the patch. Through a quick look, it's fine. But, could you fix the following and repost?
- Fix warnings suggested by scripts/checkpatch.pl.
Some 80-chars warnings can be ignored if it makes worse, though.
- Please give the right name and address matching with your from address.
Also, the sample rate control could be an enum at best. But, this needs more another changes, so let's merge this patch first.
thanks,
Takashi
Quoted 3 lines
Thanks for the patch. Through a quick look, it's
fine.
But, could you fix the following and repost?
Summary:
Added functionality for E-mu 0404USB/0202USB/TrackerPre
Added functionality:
1) Extension Units support (all XU settings now available at alsamixer, kmix, etc):
- "AnalogueIn soft limiter" switch;
- "Sample rate" selector (values 0,1,2,3,4,5 corresponds to 44.1 48 ... 192 kHz);
- "DigitalIn CLK source" selector (internal/external) (**);
- "DigitalOut format SPDIF/AC3" switch (**);
(**)E-mu-0404usb only.
2) Automatic device sample rate adjustment depending on substream samplerate for both capture and playback substream.
--- sound/usb/usbaudio.c | 47 +++++++++++++++++++++++++++++++ sound/usb/usbaudio.h | 13 ++++++++ sound/usb/usbmixer.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 131 insertions(+), 4 deletions(-)
sound/usb/usbaudio.c +47 -0
@@ -1271,6 +1271,45 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, }/* +* For E-Mu 0404USB/0202USB/TrackerPre sample rate should be set for device, +* not for interface. +*/ +static void set_format_emu_quirk (struct snd_usb_substream *subs, +struct audioformat *fmt) +{ +unsigned char emu_samplerate_id =0 ; + +/* When capture is active +* sample rate shouldn't be changed +* by playback substream*/ +if (subs->direction ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE ].interface !=-1 ) +return ; + } + +switch (fmt->rate_min) { +case 48000 : + emu_samplerate_id =EMU_QUIRK_SR_48000HZ ; +break ; +case 88200 : + emu_samplerate_id =EMU_QUIRK_SR_88200HZ ; +break ; +case 96000 : + emu_samplerate_id =EMU_QUIRK_SR_96000HZ ; +break ; +case 176400 : + emu_samplerate_id =EMU_QUIRK_SR_176400HZ ; +break ; +case 192000 : + emu_samplerate_id =EMU_QUIRK_SR_96000HZ ; +break ; +default : + emu_samplerate_id =EMU_QUIRK_SR_192000HZ ; + } +snd_emuusb_set_samplerate (subs->stream->chip, emu_samplerate_id); +} + +/* * find a matching format and set up the interface */ static int set_format (struct snd_usb_substream *subs,struct audioformat *fmt)
@@ -1383,6 +1422,14 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) subs->cur_audiofmt = fmt; +switch (subs->stream->chip->usb_id) { +case USB_ID (0x041e ,0x3f02 ):/* E-Mu 0202 USB */ +case USB_ID (0x041e ,0x3f04 ):/* E-Mu 0404 USB */ +case USB_ID (0x041e ,0x3f0a ):/* E-Mu Tracker Pre */ +set_format_emu_quirk (subs, fmt); +break ; + } +#if 0 printk(KERN_DEBUG "setting done: format = %d, rate = %d..%d, channels = %d\n",
sound/usb/usbaudio.h +13 -0
@@ -208,6 +208,16 @@ struct snd_usb_midi_endpoint_info {/* */ +/*E-mu USB samplerate control quirk*/ +enum { +EMU_QUIRK_SR_44100HZ =0 , +EMU_QUIRK_SR_48000HZ , +EMU_QUIRK_SR_88200HZ , +EMU_QUIRK_SR_96000HZ , +EMU_QUIRK_SR_176400HZ , +EMU_QUIRK_SR_192000HZ +}; +#define combine_word (s) ((*(s)) | ((unsigned int)(s)[1] << 8))#define combine_triple (s) (combine_word(s) | ((unsigned int)(s)[2] << 16))#define combine_quad (s) (combine_triple(s) | ((unsigned int)(s)[3] << 24))
@@ -233,6 +243,9 @@ void snd_usbmidi_input_stop(struct list_head* p);void snd_usbmidi_input_start (struct list_head * p);void snd_usbmidi_disconnect (struct list_head *p); +void snd_emuusb_set_samplerate (struct snd_usb_audio *chip, +unsigned char samplerate_id); +/* * retrieve usb_interface descriptor from the host interface * (conditional for compatibility with the older API)
sound/usb/usbmixer.c +71 -4
105 lines not on this page · raw message
Signature · 1 line
1.6.6
!!! Sorry, previous patch is incorrect !!!
Quoted 3 lines
Thanks for the patch. Through a quick look, it's
fine.
But, could you fix the following and repost?
Summary:
Added functionality for E-mu 0404USB/0202USB/TrackerPre
Added functionality:
1) Extension Units support (all XU settings now available at alsamixer, kmix, etc):
- "AnalogueIn soft limiter" switch;
- "Sample rate" selector (values 0,1,2,3,4,5 corresponds to 44.1 48 ... 192 kHz);
- "DigitalIn CLK source" selector (internal/external) (**);
- "DigitalOut format SPDIF/AC3" switch (**);
(**)E-mu-0404usb only.
2) Automatic device sample rate adjustment depending on substream samplerate for both capture and playback substream.
--- sound/usb/usbaudio.c | 47 +++++++++++++++++++++++++++++++ sound/usb/usbaudio.h | 13 ++++++++ sound/usb/usbmixer.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 131 insertions(+), 4 deletions(-)
sound/usb/usbaudio.c +47 -0
@@ -1271,6 +1271,45 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, }/* +* For E-Mu 0404USB/0202USB/TrackerPre sample rate should be set for device, +* not for interface. +*/ +static void set_format_emu_quirk (struct snd_usb_substream *subs, +struct audioformat *fmt) +{ +unsigned char emu_samplerate_id =0 ; + +/* When capture is active +* sample rate shouldn't be changed +* by playback substream*/ +if (subs->direction ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE ].interface !=-1 ) +return ; + } + +switch (fmt->rate_min) { +case 48000 : + emu_samplerate_id =EMU_QUIRK_SR_48000HZ ; +break ; +case 88200 : + emu_samplerate_id =EMU_QUIRK_SR_88200HZ ; +break ; +case 96000 : + emu_samplerate_id =EMU_QUIRK_SR_96000HZ ; +break ; +case 176400 : + emu_samplerate_id =EMU_QUIRK_SR_176400HZ ; +break ; +case 192000 : + emu_samplerate_id =EMU_QUIRK_SR_192000HZ ; +break ; +default : + emu_samplerate_id =EMU_QUIRK_SR_44100HZ ; + } +snd_emuusb_set_samplerate (subs->stream->chip, emu_samplerate_id); +} + +/* * find a matching format and set up the interface */ static int set_format (struct snd_usb_substream *subs,struct audioformat *fmt)
@@ -1383,6 +1422,14 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) subs->cur_audiofmt = fmt; +switch (subs->stream->chip->usb_id) { +case USB_ID (0x041e ,0x3f02 ):/* E-Mu 0202 USB */ +case USB_ID (0x041e ,0x3f04 ):/* E-Mu 0404 USB */ +case USB_ID (0x041e ,0x3f0a ):/* E-Mu Tracker Pre */ +set_format_emu_quirk (subs, fmt); +break ; + } +#if 0 printk(KERN_DEBUG "setting done: format = %d, rate = %d..%d, channels = %d\n",
sound/usb/usbaudio.h +13 -0
@@ -208,6 +208,16 @@ struct snd_usb_midi_endpoint_info {/* */ +/*E-mu USB samplerate control quirk*/ +enum { +EMU_QUIRK_SR_44100HZ =0 , +EMU_QUIRK_SR_48000HZ , +EMU_QUIRK_SR_88200HZ , +EMU_QUIRK_SR_96000HZ , +EMU_QUIRK_SR_176400HZ , +EMU_QUIRK_SR_192000HZ +}; +#define combine_word (s) ((*(s)) | ((unsigned int)(s)[1] << 8))#define combine_triple (s) (combine_word(s) | ((unsigned int)(s)[2] << 16))#define combine_quad (s) (combine_triple(s) | ((unsigned int)(s)[3] << 24))
@@ -233,6 +243,9 @@ void snd_usbmidi_input_stop(struct list_head* p);void snd_usbmidi_input_start (struct list_head * p);void snd_usbmidi_disconnect (struct list_head *p); +void snd_emuusb_set_samplerate (struct snd_usb_audio *chip, +unsigned char samplerate_id); +/* * retrieve usb_interface descriptor from the host interface * (conditional for compatibility with the older API)
sound/usb/usbmixer.c +71 -4
105 lines not on this page · raw message
Signature · 1 line
1.6.6
Takashi Iwai
AppliedAt Sun, 27 Dec 2009 09:13:41 -0800 (PST),
Quoted 18 lines · Sergiy Kovalchuk
!!! Sorry, previous patch is incorrect !!!
Quoted 3 lines
Thanks for the patch. Through a quick look, it's
fine.
But, could you fix the following and repost?Summary:
Added functionality for E-mu 0404USB/0202USB/TrackerPreAdded functionality:
1) Extension Units support (all XU settings now available at alsamixer, kmix, etc):
- "AnalogueIn soft limiter" switch;
- "Sample rate" selector (values 0,1,2,3,4,5 corresponds to 44.1 48 ... 192 kHz);
- "DigitalIn CLK source" selector (internal/external) (**);
- "DigitalOut format SPDIF/AC3" switch (**);
(**)E-mu-0404usb only.
Quoted 4 lines
2) Automatic device sample rate adjustment depending on substream samplerate for both capture and playback substream.
Signed-off-by Sergiy Kovalchuk <[email protected]>
Thanks, applied now with minor coding-style fixes.
Takashi
2009/12/22 Zerg Cannibal <[email protected]>:
Quoted 11 lines
Added functionality:
1) Extension Units support (all XU settings now available at alsamixer, kmix, etc):
- "AnalogueIn soft limiter" switch;
- "Sample rate" selector (values 0,1,2,3,4,5 corresponds to 44.1 48 ... 192 kHz);
- "DigitalIn CLK source" selector (internal/external) (**);
- "DigitalOut format SPDIF/AC3" switch (**);
(**)E-mu-0404usb only.2) Automatic device sample rate adjustment depending on substream samplerate for both capture and playback substream.
Patch is based on Mac OS-X driver (http://sourceforge.net/projects/zaudiodrivermac/) and successfully tested by Ubuntu community users for 0404usb and 0202usb.
Further info for set_format_emu_quirk()
The values of XU_CR_SELECTOR_CONTROL can be:
0 = 44100
1 = 48000
2 = 88200
3 = 96000
4 = 176400
5 = 192000
USB_XU_CLOCK_RATE has a number of controls
00: Does nothing.
01: Does nothing
02: Query supported sample rates: Bitmap
03: XU_CR_SELECTOR_CONTROL: as above.
USB_XU_CLOCK_SOURCE has a number of controls:
00: Does nothing
01: Does nothing
02: USB_XU_CLOCK_SOURCE_SELECTOR_CONTROL: = 1 for External from SPDIF-IN, 0 = Internal.
USB_XU_DIGITAL_IO has a number of controls:
00: Does nothing
01: Does nothing
02: XU_DIGITAL_IO_SAMPLE_RATE_CONTROL: spdif input sample rate. GET only. 32bit value.
03: XU_DIGITAL_IO_SYNC_SOURCE_LOCK_STATUS: "Lock indicator". GET only 1=Locked. 0=no-lock.
04: Does nothing
05: XU_DIGITAL_IO_OUTPUT_FRAME_FORMAT: 0 = undefined, 1 = Consumer, Copyright OFF, 2 = Consumer, Copyright ON, 3 = Professional.
USB_XU_DEVICE_OPTIONS has a number of controls:
00: Does nothing
01: Does nothing
02: Does nothing
03: XU_DO_SOFT_LIMIT_CONTROL: GET/SET: 1 = Soft limit ON, 0 = Soft limit OFF.
I have no info regarding 0xe305 or 0xe306.
I have firmware upgrade details and firmware version querying details and usb speed query details, if one needs them.
The above info might only apply to an older version of the firmware, so the driver might have to behave differently depending on the installed firmware version.
Kind Regards
James
Quoted 3 lines
Further info for
set_format_emu_quirk()
Thank you for valuable information, especially for digital-in/out control/status values.
My first approach is to bring full functionality for analogue playback and capture, and current patch meets this demand, except capturing above 96kHz (I've got nothing, but white noise). I'll appreciate any information that relates to 174.6kHz and 192kHz capture for E-mu products (MacOS-X driver officially doesn't support it).
Also there no way to obtain DigitalIO status without spawning separate thread, which periodically request the status from device and updates mixer info. My alsa-development skill is poor, so I prefer to avoid such dangerous improvements at the moment.
With Best Regards, Sergiy.
2009/12/28 Sergiy Kovalchuk <[email protected]>:
Quoted 4 lines
Quoted 3 lines
Further info for
set_format_emu_quirk()
Quoted 8 lines
Thank you for valuable information, especially for digital-in/out control/status values.
My first approach is to bring full functionality for analogue playback and capture, and current patch meets this demand, except capturing above 96kHz (I've got nothing, but white noise). I'll appreciate any information that relates to 174.6kHz and 192kHz capture for E-mu products (MacOS-X driver officially doesn't support it).Also there no way to obtain DigitalIO status without spawning separate thread, which periodically request the status from device and updates mixer info. My alsa-development skill is poor, so I prefer to avoid such dangerous improvements at the moment.
With Best Regards, Sergiy.
I do not have the hardware with me at the moment, so I cannot test this. The information I have does talk about the stream format changing depending on whether one is in Full-Speed or High-Speed USB mode. The reason given for not following the USB audio standard for HS mode is that some USB controllers are buggy and this gets round the problem.
Regarding the capture problems:
When the device is in HS mode and the 1/2 ms transfer alternative setting is selected. The descriptor says that the samples are of TYPE_I_PCM.
The actual format within the TYPE_I_PCM packet is:
offset 0: size=4, Length of this packet (dwLength)
offset 4: size=dwLength - 4, packet of interleaved audio data. So, you will have to get the first 4 bytes of each packet dropped in order for the stream to lock like real TYPE_I_PCM.
This is a work-around for an issue seen with some EHCI hosts which for every other packet incorrectly report the received packet length as zero bytes to the audio driver.
Also, the first two packets of any recording should be dropped as they contain unwanted data.
When the clock rate it changed, the alsa driver will have to also switch to the correct USB endpoint alternate setting to match it.
Use this vendor specific command to determine which mode the EMU is in. Input values:
bmRequestType: 0xc0 (Get)
bRequest: 0x2a: (GET_CONNECTION_SPEED)
wValue: Not used.
wIndex: Not used.
wLength: 1
Returns:
at offset 0: Size 1, Type: Number, 0 = Full-Speed, 1 = High-Speed.
Another useful one could be:
Input values:
bmRequestType: 0xc0 (Get)
bRequest: 0x01: (GET_DEVICE_INFO)
wValue: Not used.
wIndex: Not used.
wLength: 32
Returns:
Offset 0: size=4, not used, set to 0
Offset 4: size=4, FirmwareVersion,
D31-24: Major version number
D23-16: Minor version number
D15-09: Build Year
D08-05: Build Month
D04-00: Build dayOffset 8: size=4, Hardware version
D31-09: Set to 0
D08-00: Hardware version
Offset 12: size=4, not used, set to 0.
Regarding the Digital IO status, the emu 0202/0404 has an interrupt endpoint the function as per USB Audio 1.0 specification, section 3.7.1.2.
The problem being, only the 0404 uses it.
I hope this info helps.
Kind Regards
James