diff options
author | Daniel Mack <daniel@caiaq.de> | 2009-06-02 06:36:39 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-06-02 06:55:59 -0400 |
commit | bafeee5b1f8d32cbf791c322b40a6fa91d8ccf7a (patch) | |
tree | 27bc6bb25d0f7313a4a367a5f784f512bbad16ef /sound/usb/caiaq | |
parent | 17db0486d73a7bc62996569cea63464daacb22a4 (diff) |
ALSA: snd_usb_caiaq: give better shortname
If not passed as module option, provide an own card ID with the newly
introduced snd_set_card_id() call.
This will prevent ALSA from calling choose_default_name() which only
takes the last part of a name containing whitespaces. This for example
caused 'Audio 4 DJ' to be shortened to 'DJ', which was not very
descriptive.
The implementation now takes the short name and removes all whitespaces
from it which is much nicer.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/caiaq')
-rw-r--r-- | sound/usb/caiaq/device.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index 15052e439e30..43bd0dbaea28 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -382,10 +382,10 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) | |||
382 | 382 | ||
383 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) | 383 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) |
384 | { | 384 | { |
385 | char usbpath[32]; | 385 | char *c, usbpath[32]; |
386 | struct usb_device *usb_dev = dev->chip.dev; | 386 | struct usb_device *usb_dev = dev->chip.dev; |
387 | struct snd_card *card = dev->chip.card; | 387 | struct snd_card *card = dev->chip.card; |
388 | int err; | 388 | int err, len; |
389 | 389 | ||
390 | if (usb_set_interface(usb_dev, 0, 1) != 0) { | 390 | if (usb_set_interface(usb_dev, 0, 1) != 0) { |
391 | log("can't set alt interface.\n"); | 391 | log("can't set alt interface.\n"); |
@@ -427,6 +427,23 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev) | |||
427 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); | 427 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); |
428 | strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); | 428 | strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); |
429 | 429 | ||
430 | /* if the id was not passed as module option, fill it with a shortened | ||
431 | * version of the product string which does not contain any | ||
432 | * whitespaces */ | ||
433 | |||
434 | if (*card->id == '\0') { | ||
435 | char id[sizeof(card->id)]; | ||
436 | |||
437 | memset(id, 0, sizeof(id)); | ||
438 | |||
439 | for (c = card->shortname, len = 0; | ||
440 | *c && len < sizeof(card->id); c++) | ||
441 | if (*c != ' ') | ||
442 | id[len++] = *c; | ||
443 | |||
444 | snd_card_set_id(card, id); | ||
445 | } | ||
446 | |||
430 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); | 447 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); |
431 | snprintf(card->longname, sizeof(card->longname), | 448 | snprintf(card->longname, sizeof(card->longname), |
432 | "%s %s (%s)", | 449 | "%s %s (%s)", |