diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-01-11 14:51:45 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-01-11 14:51:45 -0200 |
commit | 4f0c3a5b186e34fc3b00d9de553b946f1c917d63 (patch) | |
tree | 8c3daee89a958b9848b0384afea1f33522b26df0 /linux | |
parent | 1eee0178b5f14b0044c51bd9c72856e8a5e1038b (diff) | |
download | mediapointer-dvb-s2-4f0c3a5b186e34fc3b00d9de553b946f1c917d63.tar.gz mediapointer-dvb-s2-4f0c3a5b186e34fc3b00d9de553b946f1c917d63.tar.bz2 |
Add a proper init code for -alsa
From: Mauro Carvalho Chehab <mchehab@redhat.com>
Uses about the same initialization code as defined on usbaudio.c.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/staging/tm6000/tm6000-alsa.c | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/linux/drivers/staging/tm6000/tm6000-alsa.c b/linux/drivers/staging/tm6000/tm6000-alsa.c index 08c73db9e..50fd57cce 100644 --- a/linux/drivers/staging/tm6000/tm6000-alsa.c +++ b/linux/drivers/staging/tm6000/tm6000-alsa.c @@ -14,7 +14,7 @@ #include <linux/init.h> #include <linux/device.h> #include <linux/interrupt.h> -#include <linux/dma-mapping.h> +#include <linux/usb.h> #include <asm/delay.h> #include <sound/driver.h> @@ -67,6 +67,7 @@ struct snd_tm6000_card { ****************************************************************************/ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 1}; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 10) @@ -361,15 +362,81 @@ static void snd_tm6000_dev_free(struct snd_card *card) * Alsa Constructor - Component probe */ - -/* FIXME: initialize -alsa driver */ -static int tm6000_audio_init(void) +static int tm6000_audio_init(struct tm6000_core *dev, int idx) { - printk("tm6000-alsa not ready yet\n"); + struct snd_card *card; + struct snd_tm6000_card *chip; + int rc, len; + char component[14]; + + if (idx >= SNDRV_CARDS) + return -ENODEV; + + if (!enable[idx]) + return -ENOENT; + + card = snd_card_new(index[idx], id[idx], THIS_MODULE, 0); + if (card == NULL) { + snd_printk(KERN_ERR "cannot create card instance %d\n", idx); + return -ENOMEM; + } + + chip = kzalloc(sizeof(*chip), GFP_KERNEL); + if (!chip) { + rc = -ENOMEM; + goto error; + } + + chip->core = dev; + chip->card = card; + + strcpy(card->driver, "tm6000-alsa"); + sprintf(component, "USB%04x:%04x", + le16_to_cpu(dev->udev->descriptor.idVendor), + le16_to_cpu(dev->udev->descriptor.idProduct)); + snd_component_add(card, component); + + if (dev->udev->descriptor.iManufacturer) + len = usb_string(dev->udev, + dev->udev->descriptor.iManufacturer, + card->longname, sizeof(card->longname)); + else + len = 0; + + if (len > 0) + strlcat(card->longname, " ", sizeof(card->longname)); + + strlcat(card->longname, card->shortname, sizeof(card->longname)); + + len = strlcat(card->longname, " at ", sizeof(card->longname)); + + if (len < sizeof(card->longname)) + usb_make_path(dev->udev, card->longname + len, + sizeof(card->longname) - len); + + strlcat(card->longname, + dev->udev->speed == USB_SPEED_LOW ? ", low speed" : + dev->udev->speed == USB_SPEED_FULL ? ", full speed" : + ", high speed", + sizeof(card->longname)); + + rc = snd_tm6000_pcm(chip, 0, "tm6000 Digital"); + if (rc < 0) + goto error; + + rc = snd_card_register(card); + if (rc < 0) + goto error; + return 0; + +error: + snd_card_free(card); + return rc; } +#if 0 /* * module remove */ @@ -379,3 +446,5 @@ static void tm6000_audio_fini(void) module_init(tm6000_audio_init); module_exit(tm6000_audio_fini); + +#endif |