Re: [Alsa-user] Controlling card number assignments

2017-07-07 Thread Takashi Iwai
On Fri, 07 Jul 2017 19:55:10 +0200,
Paul D. DeRocco wrote:
> 
> > From: Clemens Ladisch [mailto:clem...@ladisch.de] 
> > 
> > You could use the vid/pid options of the driver.  See
> >  or
> > .
> 
> The DAC isn't a USB device. It connects to the RPi's I2S interface, and is
> controlled by I2C, and enumerated via a .dto file. It does, however, have
> a consistent name, so I'm alright with that.
> 
> The USB to MIDI converters are a different matter. They're USB, but they
> could be any brand. I have a cheap Chinese converter whose name comes up
> as "Interface", and an E-Mu device called "XMidiX1". It would be really
> nice to have some geographic way to refer to them, based on the USB port
> they're plugged into. But I guess that's something I should ask about on
> the systemd list.

The patch below adds a new module option to USB-audio driver for
specifying the devpath string.  Together with index option, you can
define the card index for the fixed devpath.  Would it work for you?

The patch has been floating around over years, and not merged just
because I haven't heard of the good usage of it.


Takashi

-- 8< --
From: Takashi Iwai 
Subject: [PATCH] ALSA: usb-audio - Add devpath option

Added devpath module option to specify the USB devpath for the
specific device index.

Signed-off-by: Takashi Iwai 
---
 sound/usb/card.c | 21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 6640277a725b..a9af497d19bf 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -79,6 +79,7 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* 
Enable this card *
 /* Vendor/product IDs for this card */
 static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
 static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
+static char *devpath[SNDRV_CARDS];
 static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
 static bool ignore_ctl_error;
 static bool autoclock = true;
@@ -94,6 +95,8 @@ module_param_array(vid, int, NULL, 0444);
 MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
 module_param_array(pid, int, NULL, 0444);
 MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
+module_param_array(devpath, charp, NULL, 0444);
+MODULE_PARM_DESC(devpath, "USB devpath for the specific index.");
 module_param_array(device_setup, int, NULL, 0444);
 MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
 module_param(ignore_ctl_error, bool, 0444);
@@ -506,6 +509,21 @@ get_alias_quirk(struct usb_device *dev, unsigned int id)
return NULL;
 }
 
+static int is_matching_device(int i, u32 id, struct usb_device *dev)
+{
+   if (vid[i] != -1 && vid[i] != USB_ID_VENDOR(id))
+   return 0;
+   if (pid[i] != -1 && pid[i] != USB_ID_PRODUCT(id))
+   return 0;
+   if (devpath[i]) {
+   char tmppath[64];
+   usb_make_path(dev, tmppath, sizeof(tmppath));
+   if (strcmp(devpath[i], tmppath))
+   return 0;
+   }
+   return 1;
+}
+
 /*
  * probe the active usb device
  *
@@ -566,8 +584,7 @@ static int usb_audio_probe(struct usb_interface *intf,
 */
for (i = 0; i < SNDRV_CARDS; i++)
if (enable[i] && ! usb_chip[i] &&
-   (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
-   (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
+   is_matching_device(i, id, dev)) {
err = snd_usb_audio_create(intf, dev, i, quirk,
   id, );
if (err < 0)
-- 
2.13.2


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Controlling card number assignments

2017-07-07 Thread Clemens Ladisch
Paul D. DeRocco wrote:
>> You could use the vid/pid options of the driver.  See
>>  or
>> .
>
> The DAC isn't a USB device.

With different modules, you can simply order them by adding something
like this to a .conf file in /etc/modprobe.d/:

  options snd slots=snd-usb-audio,snd-whatevertheothermoduleisnamed


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Controlling card number assignments

2017-07-07 Thread Paul D. DeRocco
> From: Clemens Ladisch [mailto:clem...@ladisch.de] 
> 
> You could use the vid/pid options of the driver.  See
>  or
> .

The DAC isn't a USB device. It connects to the RPi's I2S interface, and is
controlled by I2C, and enumerated via a .dto file. It does, however, have
a consistent name, so I'm alright with that.

The USB to MIDI converters are a different matter. They're USB, but they
could be any brand. I have a cheap Chinese converter whose name comes up
as "Interface", and an E-Mu device called "XMidiX1". It would be really
nice to have some geographic way to refer to them, based on the USB port
they're plugged into. But I guess that's something I should ask about on
the systemd list.

-- 

Ciao,   Paul D. DeRocco
Paulmailto:pdero...@ix.netcom.com


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Controlling card number assignments

2017-07-07 Thread Paul D. DeRocco
> From: Clemens Ladisch [mailto:clem...@ladisch.de] 
> 
> With different modules, you can simply order them by adding something
> like this to a .conf file in /etc/modprobe.d/:
> 
>   options snd slots=snd-usb-audio,snd-whatevertheothermoduleisnamed

Thanks. The following seems to work for me.

  options snd slots=snd-soc-hifiberry-dacplus,snd-usb-audio

The USB MIDI devices come up in a predictable order if they're present on
boot, but obviously if they're plugged in afterwards they are numbered in
the order they're plugged in. It would still be nice to associate a
consistent name with each USB port, even if it doesn't gracefully handle
cases like external hubs.

-- 

Ciao,   Paul D. DeRocco
Paulmailto:pdero...@ix.netcom.com


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Boss BR-80

2017-07-07 Thread Benjamin via Alsa-user

Hi Clemens,

thanks for your reply!

aplay or arecord doesn't work. (See code below)

Cheers,


Ben




benjamin@microlab:~$ aplay -D hw:CARD=BR80AUDIO,DEV=0 pinknoise.wav
Wiedergabe: WAVE 'pinknoise.wav' : Signed 16 bit Little Endian, Rate: 
44100 Hz, mono

aplay: set_params:1299: Sample-Format nicht unterstützt
Available formats:
- S32_LE
benjamin@microlab:~$ arecord -D hw:CARD=BR80AUDIO,DEV=0 bluenoise.wav
Aufnahme: WAVE 'bluenoise.wav' : Unsigned 8 bit, Rate: 8000 Hz, mono
arecord: set_params:1299: Sample-Format nicht unterstützt
Available formats:
- S32_LE
benjamin@microlab:~$


On 03.07.2017 10:08, Clemens Ladisch wrote:

Benjamin via Alsa-user wrote:

ALSA: poll time out, polled for 34828045 usecs

Apparently, this device is not strictly compatible with the USB Audio
specification and requires some vendor-specific command(s) to work.

Does aplay or arecord alone work?


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user




--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Boss BR-80

2017-07-07 Thread Clemens Ladisch
Benjamin wrote:
> $ aplay -D hw:CARD=BR80AUDIO,DEV=0 pinknoise.wav
> Wiedergabe: WAVE 'pinknoise.wav' : Signed 16 bit Little Endian, Rate: 44100 
> Hz, mono
> aplay: set_params:1299: Sample-Format nicht unterstützt
> Available formats:
> - S32_LE

Try plughw instead of hw.


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Controlling card number assignments

2017-07-07 Thread Clemens Ladisch
Paul D. DeRocco wrote:
> I've got a Raspberry Pi with a HiFiBerry DAC on it, and a USB to MIDI
> converter plugged into it. It's running a GUI-less embedded Linux created
> with Yocto, which uses systemd and udev. The card numbers assigned to
> these two devices is unpredictable. What can I do to fix the card numbers?

You could use the vid/pid options of the driver.  See
 or
.


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user