V4L/DVB: tm6000: rewrite init and fini
rewrite tm6000_audio_init and tm6000_audio_fini Signed-off-by: Stefan Ringel <stefan.ringel@arcor.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
53ff4c7900
commit
d77057f250
2 changed files with 62 additions and 78 deletions
|
@ -35,29 +35,6 @@
|
|||
printk(KERN_INFO "%s/1: " fmt, chip->core->name , ## arg); \
|
||||
} while (0)
|
||||
|
||||
/****************************************************************************
|
||||
Data type declarations - Can be moded to a header file later
|
||||
****************************************************************************/
|
||||
|
||||
struct snd_tm6000_card {
|
||||
struct snd_card *card;
|
||||
|
||||
spinlock_t reg_lock;
|
||||
|
||||
atomic_t count;
|
||||
|
||||
unsigned int period_size;
|
||||
unsigned int num_periods;
|
||||
|
||||
struct tm6000_core *core;
|
||||
struct tm6000_buffer *buf;
|
||||
|
||||
int bufsize;
|
||||
|
||||
struct snd_pcm_substream *substream;
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
Module global static vars
|
||||
****************************************************************************/
|
||||
|
@ -312,21 +289,6 @@ static struct snd_pcm_ops snd_tm6000_pcm_ops = {
|
|||
/*
|
||||
* create a PCM device
|
||||
*/
|
||||
static int __devinit snd_tm6000_pcm(struct snd_tm6000_card *chip,
|
||||
int device, char *name)
|
||||
{
|
||||
int err;
|
||||
struct snd_pcm *pcm;
|
||||
|
||||
err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
pcm->private_data = chip;
|
||||
strcpy(pcm->name, name);
|
||||
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_tm6000_pcm_ops);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: Control interface - How to control volume/mute? */
|
||||
|
||||
|
@ -337,73 +299,64 @@ static int __devinit snd_tm6000_pcm(struct snd_tm6000_card *chip,
|
|||
/*
|
||||
* Alsa Constructor - Component probe
|
||||
*/
|
||||
|
||||
int tm6000_audio_init(struct tm6000_core *dev, int idx)
|
||||
int tm6000_audio_init(struct tm6000_core *dev)
|
||||
{
|
||||
struct snd_card *card;
|
||||
struct snd_tm6000_card *chip;
|
||||
int rc, len;
|
||||
char component[14];
|
||||
struct snd_card *card;
|
||||
struct snd_tm6000_card *chip;
|
||||
int rc;
|
||||
static int devnr;
|
||||
char component[14];
|
||||
struct snd_pcm *pcm;
|
||||
|
||||
if (idx >= SNDRV_CARDS)
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
if (devnr >= SNDRV_CARDS)
|
||||
return -ENODEV;
|
||||
|
||||
if (!enable[idx])
|
||||
if (!enable[devnr])
|
||||
return -ENOENT;
|
||||
|
||||
rc = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card);
|
||||
rc = snd_card_create(index[devnr], id[devnr], THIS_MODULE, 0, &card);
|
||||
if (rc < 0) {
|
||||
snd_printk(KERN_ERR "cannot create card instance %d\n", idx);
|
||||
snd_printk(KERN_ERR "cannot create card instance %d\n", devnr);
|
||||
return rc;
|
||||
}
|
||||
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
chip = kzalloc(sizeof(struct snd_tm6000_card), 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");
|
||||
spin_lock_init(&chip->reg_lock);
|
||||
rc = snd_pcm_new(card, "TM6000 Audio", 0, 0, 1, &pcm);
|
||||
if (rc < 0)
|
||||
goto error;
|
||||
|
||||
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_tm6000_pcm_ops);
|
||||
pcm->info_flags = 0;
|
||||
pcm->private_data = dev;
|
||||
strcpy(pcm->name, "Trident TM5600/60x0");
|
||||
strcpy(card->driver, "tm6000-alsa");
|
||||
strcpy(card->shortname, "TM5600/60x0");
|
||||
sprintf(card->longname, "TM5600/60x0 Audio at bus %d device %d",
|
||||
dev->udev->bus->busnum, dev->udev->devnum);
|
||||
|
||||
snd_card_set_dev(card, &dev->udev->dev);
|
||||
|
||||
rc = snd_card_register(card);
|
||||
if (rc < 0)
|
||||
goto error;
|
||||
|
||||
chip->core = dev;
|
||||
chip->card = card;
|
||||
dev->adev = chip;
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -414,6 +367,22 @@ int tm6000_audio_init(struct tm6000_core *dev, int idx)
|
|||
|
||||
static int tm6000_audio_fini(struct tm6000_core *dev)
|
||||
{
|
||||
struct snd_tm6000_card *chip = dev->adev;
|
||||
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
if (!chip)
|
||||
return 0;
|
||||
|
||||
if (!chip->card)
|
||||
return 0;
|
||||
|
||||
snd_card_free(chip->card);
|
||||
chip->card = NULL;
|
||||
kfree(chip);
|
||||
dev->adev = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,18 @@ struct tm6000_dvb {
|
|||
struct mutex mutex;
|
||||
};
|
||||
|
||||
struct snd_tm6000_card {
|
||||
struct snd_card *card;
|
||||
spinlock_t reg_lock;
|
||||
atomic_t count;
|
||||
unsigned int period_size;
|
||||
unsigned int num_periods;
|
||||
struct tm6000_core *core;
|
||||
struct tm6000_buffer *buf;
|
||||
int bufsize;
|
||||
struct snd_pcm_substream *substream;
|
||||
};
|
||||
|
||||
struct tm6000_endpoint {
|
||||
struct usb_host_endpoint *endp;
|
||||
__u8 bInterfaceNumber;
|
||||
|
@ -190,6 +202,9 @@ struct tm6000_core {
|
|||
/* DVB-T support */
|
||||
struct tm6000_dvb *dvb;
|
||||
|
||||
/* audio support */
|
||||
struct snd_tm6000_card *adev;
|
||||
|
||||
/* locks */
|
||||
struct mutex lock;
|
||||
|
||||
|
|
Loading…
Reference in a new issue