Skip to contentSkip to conversation

Midi name string in mpu401_uart not unique

PATCH Alan Horstmann 3 participants 8 messages Mar 29, 2006 – Mar 31, 2006

lore
Share & tools
lore
#0 lore raw

For a card with ->shortname, snd_mpu401_uart_new creates the same string for all ports on all cards of same type. Muse, eg, is unable to distinguish them, and cannot use the second port. As a result, I thought wavetable midi on DMX6fire was broken, but some patching solved this. :-)

That set me thinking that really the card driver should be able to pass this string to mpu401_uart_new to describe the ports actual use. It also seems to me that however created the string should be unique, and also that the early characters are the most useful in a sequencer window; I don't need the manufacturer at all -just the model will do.

I have patched one solution, adding a parameter to mpu401_uart_new. Then ice1712 (in my case) generates this string either explicitly from snd_ice1712_card_info or from model string, adding card & device numbers. Diff is attached.

What do you think? There must be other ways to achieve this also. This diff is just a starting point; I've included the 'NULL' parameter just in au88x0 as it is my other card.

With these changes Muse shows 'MIDI-Front DMX6fire 0-0' and 'Wavetable DMX6fire 0-1' which (of course) suits me just fine! Wavetable daughter card now runs great!

Regards Alan

alsa-driver-1.0.11rc3/alsa-kernel/drivers/mpu401/mpu401_uart.c renamed from alsa-driver-orig-1.0.11rc3/alsa-kernel/drivers/mpu401/mpu401_uart.c +12 -5
diff -ru ../alsa-driver-orig-1.0.11rc3/alsa-kernel/drivers/mpu401/mpu401_uart.c ../alsa-driver-1.0.11rc3/alsa-kernel/drivers/mpu401/mpu401_uart.c
@@ -451,7 +451,8 @@
 			unsigned short hardware,
 			unsigned long port, int integrated,
 			int irq, int irq_flags,
-			struct snd_rawmidi ** rrawmidi)
+			struct snd_rawmidi ** rrawmidi,
+			char *midiportname)
 {
 	struct snd_mpu401 *mpu;
 	struct snd_rawmidi *rmidi;
@@ -505,10 +506,16 @@
 	}
 	mpu->irq = irq;
 	mpu->irq_flags = irq_flags;
-	if (card->shortname[0])
-		snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI", card->shortname);
-	else
-		sprintf(rmidi->name, "MPU-401 MIDI %d-%d", card->number, device);
+
+	if (midiportname != NULL) {
+		snprintf(rmidi->name, sizeof(rmidi->name), "%s", midiportname);
+	} else {
+		if (card->shortname[0]) {
+			snprintf(rmidi->name, sizeof(rmidi->name), "MIDI %d-%d %s", card->number, device , card->shortname);
+		} else {
+			sprintf(rmidi->name, "MPU-401 MIDI %d-%d", card->number, device);
+		}
+	}
 	snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_mpu401_uart_output);
 	snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_mpu401_uart_input);
 	rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT |
alsa-driver-1.0.11rc3/alsa-kernel/include/mpu401.h renamed from alsa-driver-orig-1.0.11rc3/alsa-kernel/include/mpu401.h +2 -1
diff -ru ../alsa-driver-orig-1.0.11rc3/alsa-kernel/include/mpu401.h ../alsa-driver-1.0.11rc3/alsa-kernel/include/mpu401.h
@@ -108,6 +108,7 @@
 			int integrated,
 			int irq,
 			int irq_flags,
-			struct snd_rawmidi ** rrawmidi);
+			struct snd_rawmidi ** rrawmidi,
+			char *midiportname);
 
 #endif /* __SOUND_MPU401_H */
alsa-driver-1.0.11rc3/alsa-kernel/pci/au88x0/au88x0_mpu401.c renamed from alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/au88x0/au88x0_mpu401.c +1 -1
diff -ru ../alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/au88x0/au88x0_mpu401.c ../alsa-driver-1.0.11rc3/alsa-kernel/pci/au88x0/au88x0_mpu401.c
@@ -98,7 +98,7 @@
 	port = (unsigned long)(vortex->mmio + VORTEX_MIDI_DATA);
 	if ((temp =
 	     snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_AUREAL, port,
-				 1, 0, 0, &rmidi)) != 0) {
+				 1, 0, 0, &rmidi, NULL)) != 0) {
 		hwwrite(vortex->mmio, VORTEX_CTRL,
 			(hwread(vortex->mmio, VORTEX_CTRL) &
 			 ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN);
alsa-driver-1.0.11rc3/alsa-kernel/pci/ice1712/ews.c renamed from alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/ice1712/ews.c +2 -0
diff -ru ../alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/ice1712/ews.c ../alsa-driver-1.0.11rc3/alsa-kernel/pci/ice1712/ews.c
@@ -1031,6 +1031,8 @@
 		.model = "dmx6fire",
 		.chip_init = snd_ice1712_ews_init,
 		.build_controls = snd_ice1712_ews_add_controls,
+		.mpu401_1_name = "MIDI-Front DMX6fire",
+		.mpu401_2_name = "Wavetable DMX6fire",
 	},
 	{ } /* terminator */
 };
alsa-driver-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.c renamed from alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.c +19 -5
diff -ru ../alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.c ../alsa-driver-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.c
@@ -2643,6 +2660,8 @@
 	struct snd_ice1712 *ice;
 	int pcm_dev = 0, err;
 	struct snd_ice1712_card_info **tbl, *c;
+	char port_name[24];
+	int midevice;
 
 	if (dev >= SNDRV_CARDS)
 		return -ENODEV;
@@ -2718,21 +2738,34 @@
 		}
 
 	if (! c->no_mpu401) {
-		if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712,
+		midevice = 0;
+		if (c->mpu401_1_name != NULL)
+			snprintf(port_name, sizeof(port_name), "%s %d-%d", c->mpu401_1_name, card->number, midevice);
+		else
+			snprintf(port_name, sizeof(port_name), "MIDI 1 %s %d-%d", c->model, card->number, midevice);
+
+		if ((err = snd_mpu401_uart_new(card, midevice, MPU401_HW_ICE1712,
 					       ICEREG(ice, MPU1_CTRL), 1,
 					       ice->irq, 0,
-					       &ice->rmidi[0])) < 0) {
+					       &ice->rmidi[0], port_name)) < 0) {
 			snd_card_free(card);
 			return err;
 		}
 
-		if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401)
-			if ((err = snd_mpu401_uart_new(card, 1, MPU401_HW_ICE1712,
+		if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) {
+			midevice = 1;
+			if (c->mpu401_2_name != NULL)
+				snprintf(port_name, sizeof(port_name), "%s %d-%d", c->mpu401_2_name, card->number, midevice);
+			else
+				snprintf(port_name, sizeof(port_name), "MIDI 2 %s %d-%d", c->model, card->number, midevice);
+			if ((err = snd_mpu401_uart_new(card, midevice, MPU401_HW_ICE1712,
 						       ICEREG(ice, MPU2_CTRL), 1,
 						       ice->irq, 0,
-						       &ice->rmidi[1])) < 0) {
+						       &ice->rmidi[1], port_name)) < 0) {
 				snd_card_free(card);
 				return err;
 			}
+		}
 	}
 
	snd_ice1712_set_input_clock_source(ice, 0);
alsa-driver-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.h renamed from alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.h +2 -0
diff -ru ../alsa-driver-orig-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.h ../alsa-driver-1.0.11rc3/alsa-kernel/pci/ice1712/ice1712.h
@@ -493,6 +494,8 @@
 	int (*chip_init)(struct snd_ice1712 *);
 	int (*build_controls)(struct snd_ice1712 *);
 	unsigned int no_mpu401: 1;
+	char *mpu401_1_name;
+	char *mpu401_2_name;
 	unsigned int eeprom_size;
 	unsigned char *eeprom_data;
 };
#1 lore raw

At Wed, 29 Mar 2006 23:20:54 +0100,

Quoted 17 lines · Alan Horstmann

For a card with ->shortname, snd_mpu401_uart_new creates the same string for all ports on all cards of same type. Muse, eg, is unable to distinguish them, and cannot use the second port. As a result, I thought wavetable midi on DMX6fire was broken, but some patching solved this. :-)

That set me thinking that really the card driver should be able to pass this string to mpu401_uart_new to describe the ports actual use. It also seems to me that however created the string should be unique, and also that the early characters are the most useful in a sequencer window; I don't need the manufacturer at all -just the model will do.

I have patched one solution, adding a parameter to mpu401_uart_new. Then ice1712 (in my case) generates this string either explicitly from snd_ice1712_card_info or from model string, adding card & device numbers. Diff is attached.

Quoted 7 lines

What do you think? There must be other ways to achieve this also. This diff is just a starting point; I've included the 'NULL' parameter just in au88x0 as it is my other card.

With these changes Muse shows 'MIDI-Front DMX6fire 0-0' and 'Wavetable DMX6fire 0-1' which (of course) suits me just fine! Wavetable daughter card now runs great!

Instead of adding a new argument to snd_mpu401_uart_new, the caller can overwrite the string after creating the instace.

	snd_mpu401_uart_new(card, device, type, ..., &rmidi);
	snprintf(rmidi->name, sizeof(rmidi->name),
		"MIDI Name As I Like %d", card->number);

Then the change would be less intrusive.

Or am I missing something else?

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#2 lore raw
Quoted 15 lines · you

At Wed, 29 Mar 2006 23:20:54 +0100,

Quoted 8 lines · Alan Horstmann

I have patched one solution, adding a parameter to mpu401_uart_new. Then ice1712 (in my case) generates this string either explicitly from snd_ice1712_card_info or from model string, adding card & device numbers. Diff is attached.

What do you think? There must be other ways to achieve this also. This diff is just a starting point; I've included the 'NULL' parameter just in au88x0 as it is my other card.

Instead of adding a new argument to snd_mpu401_uart_new, the caller can overwrite the string after creating the instace.

Quoted 7 lines
	snd_mpu401_uart_new(card, device, type, ..., &rmidi);
	snprintf(rmidi->name, sizeof(rmidi->name),
		"MIDI Name As I Like %d", card->number);

Then the change would be less intrusive.

Or am I missing something else?

Sounds a lot simpler -just involving the driver only; I will try this later. In the mpu-names.diff midi names were added to snd_ice1712_card_info to be used in the name string. Is that still a reasonable thing to do, or is there a better place, given that the different sub-vendors might have different requirements?

Bearing in mind Clemens' comments, is there any value in improving the name given by mpu401_uart_new when using ->shortname, as in the diff, by adding card and device numbers?

Alan

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#3 lore raw

At Thu, 30 Mar 2006 18:45:23 +0100,

Quoted 23 lines · Alan Horstmann
Quoted 21 lines · you

At Wed, 29 Mar 2006 23:20:54 +0100,

Quoted 8 lines · Alan Horstmann

I have patched one solution, adding a parameter to mpu401_uart_new. Then ice1712 (in my case) generates this string either explicitly from snd_ice1712_card_info or from model string, adding card & device numbers. Diff is attached.

What do you think? There must be other ways to achieve this also. This diff is just a starting point; I've included the 'NULL' parameter just in au88x0 as it is my other card.

Instead of adding a new argument to snd_mpu401_uart_new, the caller can overwrite the string after creating the instace.

	snd_mpu401_uart_new(card, device, type, ..., &rmidi);
	snprintf(rmidi->name, sizeof(rmidi->name),
		"MIDI Name As I Like %d", card->number);

Then the change would be less intrusive.

Quoted 7 lines
Quoted 1 line

Or am I missing something else?

Sounds a lot simpler -just involving the driver only; I will try this later. In the mpu-names.diff midi names were added to snd_ice1712_card_info to be used in the name string. Is that still a reasonable thing to do, or is there a better place, given that the different sub-vendors might have different requirements?

That addition looks OK to me. What I don't want is to change the existing API if there is a simple solution.

Quoted 3 lines

Bearing in mind Clemens' comments, is there any value in improving the name given by mpu401_uart_new when using ->shortname, as in the diff, by adding card and device numbers?

Maybe the order of "CARD DEVICE" like "DMX6fire WaveTable" is better? Just a matter of taste, though...

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#4 lore raw
Quoted 25 lines · you

At Thu, 30 Mar 2006 18:45:23 +0100,

Quoted 11 lines · Alan Horstmann
Quoted 10 lines · you

Instead of adding a new argument to snd_mpu401_uart_new, the caller can overwrite the string after creating the instace.

	snd_mpu401_uart_new(card, device, type, ..., &rmidi);
	snprintf(rmidi->name, sizeof(rmidi->name),
		"MIDI Name As I Like %d", card->number);

Then the change would be less intrusive.

Quoted 7 lines
Quoted 1 line

Or am I missing something else?

Sounds a lot simpler -just involving the driver only; I will try this later. In the mpu-names.diff midi names were added to snd_ice1712_card_info to be used in the name string. Is that still a reasonable thing to do, or is there a better place, given that the different sub-vendors might have different requirements?

That addition looks OK to me. What I don't want is to change the existing API if there is a simple solution.

Quoted 6 lines
Quoted 3 lines

Bearing in mind Clemens' comments, is there any value in improving the name given by mpu401_uart_new when using ->shortname, as in the diff, by adding card and device numbers?

Maybe the order of "CARD DEVICE" like "DMX6fire WaveTable" is better? Just a matter of taste, though...

Would it be acceptable to add card, device to ->shortname in mpu401_uart as attached:

mpu401_uart.c-add-to-shortname.patch

Add card and device numbers to portnames generated from ->shortnames by snd_mpu401_uart_new.

mpu401_uart.c renamed from mpu401_uart-orig.c +1 -1
@@ -506,7 +506,7 @@
 	mpu->irq = irq;
 	mpu->irq_flags = irq_flags;
 	if (card->shortname[0])
-		snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI", card->shortname);
+		snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI %d-%d", card->shortname, card->number, device);
 	else
 		sprintf(rmidi->name, "MPU-401 MIDI %d-%d", card->number, device);
 	snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_mpu401_uart_output);
#5 lore raw

At Fri, 31 Mar 2006 11:02:37 +0100,

Quoted 38 lines · Alan Horstmann

[1 <text/plain; iso-8859-1 (7bit)>]

Quoted 25 lines · you

At Thu, 30 Mar 2006 18:45:23 +0100,

Quoted 11 lines · Alan Horstmann
Quoted 10 lines · you

Instead of adding a new argument to snd_mpu401_uart_new, the caller can overwrite the string after creating the instace.

	snd_mpu401_uart_new(card, device, type, ..., &rmidi);
	snprintf(rmidi->name, sizeof(rmidi->name),
		"MIDI Name As I Like %d", card->number);

Then the change would be less intrusive.

Quoted 7 lines
Quoted 1 line

Or am I missing something else?

Sounds a lot simpler -just involving the driver only; I will try this later. In the mpu-names.diff midi names were added to snd_ice1712_card_info to be used in the name string. Is that still a reasonable thing to do, or is there a better place, given that the different sub-vendors might have different requirements?

That addition looks OK to me. What I don't want is to change the existing API if there is a simple solution.

Quoted 6 lines
Quoted 3 lines

Bearing in mind Clemens' comments, is there any value in improving the name given by mpu401_uart_new when using ->shortname, as in the diff, by adding card and device numbers?

Maybe the order of "CARD DEVICE" like "DMX6fire WaveTable" is better? Just a matter of taste, though...

Would it be acceptable to add card, device to ->shortname in mpu401_uart as attached:

Quoted 6 lines

mpu401_uart.c-add-to-shortname.patch

Add card and device numbers to portnames generated from ->shortnames by snd_mpu401_uart_new.

Thanks for the patch. But I don't want to change that part at all. It may break other stuff what you've not tested.

Just change the ice1712 stuff, instead.

Takashi

mpu401_uart.c line 512

Quoted 12 lines

[2 mpu401_uart.c-add-to-shortname.patch <text/x-diff; iso-8859-1 (7bit)>]

mpu401_uart.c renamed from mpu401_uart-orig.c +1 -1
@@ -506,7 +506,7 @@
 	mpu->irq = irq;
 	mpu->irq_flags = irq_flags;
 	if (card->shortname[0])
-		snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI", card->shortname);
+		snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI %d-%d", card->shortname, card->number, device);
 	else
 		sprintf(rmidi->name, "MPU-401 MIDI %d-%d", card->number, device);
 	snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_mpu401_uart_output);

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#6 lore raw
Quoted 45 lines · you

At Fri, 31 Mar 2006 11:02:37 +0100,

Quoted 42 lines · Alan Horstmann

[1 <text/plain; iso-8859-1 (7bit)>]

Quoted 24 lines · you

At Thu, 30 Mar 2006 18:45:23 +0100,

Quoted 10 lines · Alan Horstmann
Quoted 9 lines · you

Instead of adding a new argument to snd_mpu401_uart_new, the caller can overwrite the string after creating the instace.

	snd_mpu401_uart_new(card, device, type, ..., &rmidi);
	snprintf(rmidi->name, sizeof(rmidi->name),
		"MIDI Name As I Like %d", card->number);

Then the change would be less intrusive.

Quoted 7 lines
Quoted 1 line

Or am I missing something else?

Sounds a lot simpler -just involving the driver only; I will try this later. In the mpu-names.diff midi names were added to snd_ice1712_card_info to be used in the name string. Is that still a reasonable thing to do, or is there a better place, given that the different sub-vendors might have different requirements?

That addition looks OK to me. What I don't want is to change the existing API if there is a simple solution.

Quoted 6 lines
Quoted 3 lines

Bearing in mind Clemens' comments, is there any value in improving the name given by mpu401_uart_new when using ->shortname, as in the diff, by adding card and device numbers?

Maybe the order of "CARD DEVICE" like "DMX6fire WaveTable" is better? Just a matter of taste, though...

Would it be acceptable to add card, device to ->shortname in mpu401_uart as attached:

mpu401_uart.c-add-to-shortname.patch

Add card and device numbers to portnames generated from ->shortnames by snd_mpu401_uart_new.

Quoted 6 lines
Quoted 1 line

Thanks for the patch. But I don't want to change that part at all. It may break other stuff what you've not tested.

Just change the ice1712 stuff, instead.

O.K. That is fine. I understand you have to think of the 'larger picture'.

The question of the order of the parts of the name is similar to date formats -yy-mm-dd or dd-mm-yy or other. I would think that convention in driver names goes for CARD DEVICE suggesting DMX6fire WaveTable as you mentioned, but usability is improved if the detail comes first, where it is less likely to be truncated. If I offer a patch for ice1712, which would you prefer?

Regards Alan

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#7 lore raw
In reply to Alan Horstmann
Quoted 2 lines · Alan Horstmann

For a card with ->shortname, snd_mpu401_uart_new creates the same string for all ports on all cards of same type.

These names should be overridden by the card driver, but it's perfectly valid behaviour. ALSA sequencer port names are not guaranteed to be unique.

Quoted 1 line

Muse, eg, is unable to distinguish them, and cannot use the second port.

This is a bug in Muse.

Regards,
Clemens

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642