At Sun, 09 Nov 2008 15:59:03 +0100, Jelle de Jong wrote:
Hello everybody,
I am trying to use udev to get fixed device names depending on the location of the device on the usb bus. The udev rules seems to be working fine, however i cant get dmix to work with the udev rules using only hw dies work. If i remove the udev rules the dmixer works fine.
Can somebody look at the attachment, and maybe do some testing, i would highly appreciate it.
Swapping the card numbers with udev might have a problem because the driver itself remembers the card index, and this number isn't swapped -- thus you get inconsistency between the device file and the internal index number.
BTW, if you just would like to keep the fixed device index for a certain usb device path, try my old patch below. It adds devpath option to snd-usb-audio, and you can specify the usb device path string ("usb-$BUSNAME-$DEVPATH").
Takashi
--- diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index bbd70d5..4e6ae0e 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -68,6 +68,7 @@ static int 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 nrpacks = 8; /* max. number of packets per urb */ static int async_unlink = 1; static int device_setup[SNDRV_CARDS]; /* device parameter for this card*/ @@ -83,6 +84,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(nrpacks, int, 0644); MODULE_PARM_DESC(nrpacks, "Max. number of packets per URB."); module_param(async_unlink, bool, 0444); @@ -3543,6 +3546,21 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, }
+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 * @@ -3613,8 +3631,7 @@ static void *snd_usb_audio_probe(struct usb_device *dev, */ 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)) { if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) { goto __error; }