Skip to contentSkip to conversation

help needed on how to autoload snd-usb-midi

DISCUSSION karsten wiese 5 participants 10 messages Oct 15, 2002 – Oct 17, 2002

lore
Share & tools
lore
#0 lore raw

Hi,

I am in the process of updating the tascam us-428 patch for alsa-current and need some hints:
formerly the snd-usb-us428 issued "request_module( "snd-usb-midi");"
to load that module. this doesn't work with alsa-current anymore as the snd-usb-audio initialisation, which is triggered, conflicts with the initialisation of snd-usb-us428.
thus I deleted that "request_module( "snd-usb-midi");" from snd_usb_us428.
I remember from some Mail on this list, that snd-usb-midi would be autoloaded if a users process accesses a mididevice, which has been created by "snd_seq_device_new( ...SNDRV_SEQ_DEV_ID_USBMIDI)". this does not happen here now.
what do I miss?
for the tests I use the bristolsynth with "./startBristol -alsa -audiodev hw:1 -mididev hw:1" having issued "modprobe snd-usb-midi" before, everythingg works as expected. otherwise "Could not open the MIDI interface.
Error opening midi device hw:1, exiting midi thread"

TIA, Karsten

__________________________________________________________________

Gesendet von Yahoo! Mail - http://mail.yahoo.de
Möchten Sie mit einem Gruß antworten? http://grusskarten.yahoo.de

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven.
http://thinkgeek.com/sf

#1 lore raw
Quoted 10 lines · karsten wiese

I am in the process of updating the tascam us-428 patch for alsa-current and need some hints:
formerly the snd-usb-us428 issued "request_module( "snd-usb-midi");"
to load that module. this doesn't work with alsa-current anymore as the snd-usb-audio initialisation, which is triggered, conflicts with the initialisation of snd-usb-us428.
thus I deleted that "request_module( "snd-usb-midi");" from snd_usb_us428.

snd-usb-midi isn't anymore an independent driver, it has been integrated into snd-usb-audio (as you've seen), although it's still a separate module. In theory, it may be possible to do the same stuff as snd_usb_create_midi_interface() to make it load correctly.

IMHO the "best" solution would be to add a quirk to usbaudio.c, instead of writing an entirely separate driver with most of the code duplicated. I didn't look at your patch in full length, but it seems to me that the changes needed would be firmware loading (best done in a separate driver or a userspace program) and adding some information about supported audio formats/bitrates. (I'm sure I've missed something. :)

Quoted 5 lines

I remember from some Mail on this list, that snd-usb-midi would be autoloaded if a users process accesses a mididevice, which has been created by "snd_seq_device_new( ...SNDRV_SEQ_DEV_ID_USBMIDI)". this does not happen here now.

Autoloading happens if there is an alias for snd-card-x (x derived from the client number) in modules.conf, and if the card driver calls snd_seq_device_new() for the sequencer driver. (BTW: there was a bug with autoloading sequencer drivers which has been fixed yesterday)

HTH Clemens

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#2 lore raw
Quoted 14 lines · Clemens Ladisch
Quoted 7 lines · karsten wiese

I am in the process of updating the tascam us-428 patch for alsa-current and need some hints:
formerly the snd-usb-us428 issued "request_module( "snd-usb-midi");"
to load that module. this doesn't work with alsa-current anymore as the snd-usb-audio initialisation, which is triggered, conflicts with

the

Quoted 2 lines

initialisation of snd-usb-us428.
thus I deleted that "request_module(

"snd-usb-midi");"

Quoted 1 line

from snd_usb_us428.

Quoted 8 lines

snd-usb-midi isn't anymore an independent driver, it has been integrated
into snd-usb-audio (as you've seen), although it's still a separate
module. In theory, it may be possible to do the same stuff as
snd_usb_create_midi_interface() to make it load correctly.

here is the routine that is used in snd-usb-us428:
static int snd_us428_create_usbmidi( snd_card_t* card )
{
#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)

	static snd_usb_audio_quirk_t quirk = {
		.vendor_name =	"TASCAM",
		.product_name =	"US-428",
		.ifnum = 	0,
		.type = QUIRK_MIDI_FIXED_ENDPOINT,
		.data = & (const snd_usb_midi_endpoint_info_t) {
			.epnum =	6,
			.out_cables =	3,
			.in_cables =	3
			}
	};
	snd_seq_device_t *seq_device;
	snd_usb_midi_t *umidi;
	int err;

	err = snd_seq_device_new( card, us428(
card)->chip.next_seq_device,
				 SNDRV_SEQ_DEV_ID_USBMIDI,
				 sizeof(snd_usb_midi_t), &seq_device);
	if (err < 0)
		return err;
	us428( card)->chip.next_seq_device++;
	strcpy(seq_device->name, card->shortname);
	umidi = (snd_usb_midi_t
*)SNDRV_SEQ_DEVICE_ARGPTR(seq_device);
	umidi->chip = &us428( card)->chip;
	umidi->ifnum = 0;
	umidi->quirk = &quirk;
	umidi->seq_client = -1;
#endif
	return 0;
}

its a copy-change of usb-audio. something wrong here ? cannot be completely wrong: if snd-usb-midi is loaded manually,
everything works ok.

Quoted 13 lines

IMHO the "best" solution would be to add a quirk to usbaudio.c, instead of
writing an entirely separate driver with most of the code duplicated. I
didn't look at your patch in full length, but it seems to me that the
changes needed would be firmware loading (best done in a separate driver
or a userspace program) and adding some information about supported audio
formats/bitrates. (I'm sure I've missed something. :)

the us-428 audio is very nonstandard:
it is necessary to know how many frames are just recorded to be able to playback without unwanted crackles. I found no other way to determine the exact samplerate. furthermore there are the hardware knobs, sliders and lights, the digital in switch....

Quoted 9 lines
Quoted 3 lines

I remember from some Mail on this list, that snd-usb-midi would be autoloaded if a users

process

Quoted 2 lines

accesses a mididevice, which has been created by "snd_seq_device_new(

...SNDRV_SEQ_DEV_ID_USBMIDI)".

Quoted 1 line

this does not happen here now.

Quoted 8 lines

Autoloading happens if there is an alias for snd-card-x (x derived from
the client number) in modules.conf, and if the card driver calls
snd_seq_device_new() for the sequencer driver. (BTW:
there was a bug with
autoloading sequencer drivers which has been fixed yesterday)

mmh, i just checked again my tree: it is current. I put a line
"alias snd-card-1 snd-usb-midi"
(the us-428 is my second card)
into modules.conf. is it this what you suggest? unfortunately the autoload still does not happen. Trying to start the Synth with:
"./startBristol -alsa -audiodev hw:1 -mididev hw:1" snd-usb-midi is still not loaded and the error message is:
"ALSA lib rawmidi_hw.c:227:(snd_rawmidi_hw_open) open /dev/snd/midiC1D0 failed: No such file or directory" Could somebody please explain, how a specific midi module gets loaded on a user processes access of an alsa (raw)midi device ?

Karsten

__________________________________________________________________

Gesendet von Yahoo! Mail - http://mail.yahoo.de
Möchten Sie mit einem Gruß antworten? http://grusskarten.yahoo.de

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven.
http://thinkgeek.com/sf

#3 lore raw
Quoted 3 lines · karsten wiese

here is the routine that is used in snd-usb-us428:
...
its a copy-change of usb-audio. something wrong here ?

No, it's fine. The problem is elsewhere.

Quoted 7 lines
Quoted 3 lines

IMHO the "best" solution would be to add a quirk to usbaudio.c, (...) (I'm sure I've missed something. :)

the us-428 audio is very nonstandard:
it is necessary to know how many frames are just
recorded to be able to playback without unwanted
crackles.

I.e. an asynchronous endpoint without frequency feedback? :-( There isn't a second endpoint in the playback interface?

Quoted 2 lines

furthermore there are the hardware knobs, sliders and lights, the digital in switch....

... and I guess those aren't in any way compatible with USB audio mixer controls.

Quoted 8 lines
Quoted 3 lines

Autoloading happens if there is an alias for snd-card-x (x derived from
the client number) in modules.conf, ...

I put a line
"alias snd-card-1 snd-usb-midi"
(the us-428 is my second card)
into modules.conf. is it this what you suggest?

No, the alias should be for the card driver:
alias snd-card-1 snd-usb-us428

Quoted 1 line

unfortunately the autoload still does not happen.

Autoloading works for sequencer ports and for "real" rawmidi devices, but not for rawmidi devices emulated on top of a sequencer port.

Takashi, would it be possible/desirable to change snd_rawmidi_hw_open() to load sequencer drivers if the card driver is loaded but the rawmidi device doesn't exist?
Something like:

	if ((fd = open(filename, fmode)) < 0) {

- snd_card_load(card);
+ card_loaded = snd_card_load(card) == 0; // 0 or 1?
- if ((fd = open(filename, fmode)) < 0) {
+ fd = open(filename, fmode);
+ if (card_loaded && fd < 0) {
+ load_seq_dev(...); // hw_open, get_client_info ?
+ fd = open(filename, fmode);
+ }

+		if (fd < 0) {
			snd_ctl_close(ctl);
			SYSERR("open %s failed", filename);
			return -errno;
		}
	}

Regards
Clemens

-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm

#4 lore raw
Quoted 56 lines · Clemens Ladisch
Quoted 3 lines · karsten wiese

here is the routine that is used in snd-usb-us428:
...
its a copy-change of usb-audio. something wrong here ?

No, it's fine. The problem is elsewhere.

Quoted 7 lines
Quoted 3 lines

IMHO the "best" solution would be to add a quirk to usbaudio.c, (...) (I'm sure I've missed something. :)

the us-428 audio is very nonstandard:
it is necessary to know how many frames are just
recorded to be able to playback without unwanted
crackles.

I.e. an asynchronous endpoint without frequency feedback? :-( There isn't a second endpoint in the playback interface?

Quoted 2 lines

furthermore there are the hardware knobs, sliders and lights, the digital in switch....

... and I guess those aren't in any way compatible with USB audio mixer controls.

Quoted 8 lines
Quoted 3 lines

Autoloading happens if there is an alias for snd-card-x (x derived from
the client number) in modules.conf, ...

I put a line
"alias snd-card-1 snd-usb-midi"
(the us-428 is my second card)
into modules.conf. is it this what you suggest?

No, the alias should be for the card driver:
alias snd-card-1 snd-usb-us428

Quoted 1 line

unfortunately the autoload still does not happen.

Autoloading works for sequencer ports and for "real" rawmidi devices, but not for rawmidi devices emulated on top of a sequencer port.

Takashi, would it be possible/desirable to change snd_rawmidi_hw_open() to load sequencer drivers if the card driver is loaded but the rawmidi device doesn't exist?
Something like:

	if ((fd = open(filename, fmode)) < 0) {
(quoted diff) +7 -2
-		snd_card_load(card);
+		card_loaded = snd_card_load(card) == 0; // 0 or 1?
-		if ((fd = open(filename, fmode)) < 0) {
+		fd = open(filename, fmode);
+		if (card_loaded && fd < 0) {
+			load_seq_dev(...); // hw_open, get_client_info ?
+			fd = open(filename, fmode);
+		}
+		if (fd < 0) {
Quoted 5 lines
			snd_ctl_close(ctl);
			SYSERR("open %s failed", filename);
			return -errno;
		}
	}

It looks ugly. Wouldn't be better to create a direct rawmidi USB driver? Could you remind me reason, why you parse sequencer events? There's something special for USB?

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project http://www.alsa-project.org
SuSE Linux http://www.suse.com

-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm

#5 lore raw
Quoted 8 lines · Jaroslav Kysela
Quoted 5 lines · Clemens Ladisch

Takashi, would it be possible/desirable to change snd_rawmidi_hw_open() to load sequencer drivers if the card driver is loaded but the rawmidi device doesn't exist?
Something like:
(...)

It looks ugly.

Yes.

Quoted 3 lines

Wouldn't be better to create a direct rawmidi USB driver? Could you remind me reason, why you parse sequencer events? There's something special for USB?

USB MIDI is not the same as rawmidi as each MIDI command must be sent as a 32-bit packet, so the driver must parse the stream somehow. (There is a USB MIDI code to send a raw MIDI byte, but there are devices not supporting this. (The USB MIDI specification and said device are, of course, from the same company.))

Well, the real reason why I wrote a sequencer driver was that I wanted to decide between a rawmidi and a sequencer driver, but there wasn't any sequencer driver supporting input, so I had to write one to find out about it. ;-)

It turns out there isn't any real advantage over a rawmidi driver, so I think I'll change the driver to use rawmidi in the next few days.

Regards
Clemens

-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm

#6 lore raw

On Wednesday 16 Oct 2002 12:19, Clemens Ladisch wrote:
[snip]

Quoted 5 lines

Well, the real reason why I wrote a sequencer driver was that I wanted to decide between a rawmidi and a sequencer driver, but there wasn't any sequencer driver supporting input, so I had to write one to find out about it. ;-)

That's a _good_ reason in my book... ;-)

Quoted 3 lines

It turns out there isn't any real advantage over a rawmidi driver, so I think I'll change the driver to use rawmidi in the next few days.

Will this affect the code used when I'm playing (with) my USB MIDI keyboard? (i.e. do I need to test it? ;-) )

Quoted 7 lines

Regards
Clemens

Quoted 6 lines

-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm
_______________________________________________

Oh dear, we're selling stuff for sf.net :-))

-- Peter

-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm

#7 lore raw

us428 patch 0.0.4

hi, this is the logentry:

Quoted 1 line
Quoted 1 line
Quoted 1 line

compiles again with alsa-current. USB_ISO_ASAP not used anymore (most of the time), instead
urb->start_frame is calculated here now, some calls inside usb-driver don't need to happen anymore.

To get the best out of this:
Disable APM-support in the kernel as APM-BIOS calls (once each second) hard disable interrupt for many precious milliseconds.
This helped me much on my slowish PII 400 & PIII 500. ACPI yet untested but might cause the same bad behaviour.
Use a kernel with lowlatency and preemptiv patches applied.
To autoload snd-usb-midi append a line
post-install snd-usb-us428 modprobe snd-usb-midi
to /etc/modules.conf.

known problems:
(1) interrupts > 1000 every 1 s.
(2)sliders, knobs, lights not yet handled except MASTER Volume slider.
(3)"pcm -c 2" doesn't work. "pcm -c 2 -m direct_interleaved" does.
(4)KDE3.03: "Enable full duplex operation" deadlocks. <<<

tascams (still unauthorized) firmware is not included but can be optained off
http://hal9000.drehmoment.org/tascam/

thanks for your support !
aaand does anybody have some clue(s) about the known
problem (3)?

best regards,
karsten

__________________________________________________________________

Gesendet von Yahoo! Mail - http://mail.yahoo.de
Möchten Sie mit einem Gruß antworten? http://grusskarten.yahoo.de

#8 lore raw
In reply to Peter L Jones
Quoted 6 lines · Peter L Jones
Quoted 2 lines · Clemens Ladisch

It turns out there isn't any real advantage over a rawmidi driver, so I think I'll change the driver to use rawmidi in the next few days.

Will this affect the code used when I'm playing (with) my USB MIDI keyboard? (i.e. do I need to test it? ;-) )

In theory, no.
(In theory, there is no difference between theory and practice. :-)

Regards
Clemens

-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm

#9 lore raw
In reply to karsten wiese

At Tue, 15 Oct 2002 16:40:56 +0200 (CEST),

Quoted 17 lines · karsten wiese

Hi,

I am in the process of updating the tascam us-428 patch for alsa-current and need some hints:
formerly the snd-usb-us428 issued "request_module( "snd-usb-midi");"
to load that module. this doesn't work with alsa-current anymore as the snd-usb-audio initialisation, which is triggered, conflicts with the initialisation of snd-usb-us428.
thus I deleted that "request_module( "snd-usb-midi");" from snd_usb_us428.
I remember from some Mail on this list, that snd-usb-midi would be autoloaded if a users process accesses a mididevice, which has been created by "snd_seq_device_new( ...SNDRV_SEQ_DEV_ID_USBMIDI)".

Quoted 8 lines

this does not happen here now.
what do I miss?
for the tests I use the bristolsynth with "./startBristol -alsa -audiodev hw:1 -mididev hw:1" having issued "modprobe snd-usb-midi" before, everythingg works as expected. otherwise "Could not open the MIDI interface.
Error opening midi device hw:1, exiting midi thread"

does support bristrol ALSA sequencer?
if it accesses only the midi device, then snd-usb-midi module won't be loaded automatically, because the midi device itself is not the sequencer stuff.
the auto-load mechanism works only when the sequencer stuff is requested.

i think that an easy way is to force to load snd-usb-midi after snd-usb-audio, such as above command in /etc/modules.conf.

Takashi

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf