Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 201931
b: refs/heads/master
c: d77057f
h: refs/heads/master
i:
  201929: 1e3761b
  201927: 59d26b3
v: v3
  • Loading branch information
Stefan Ringel authored and Mauro Carvalho Chehab committed Aug 2, 2010
1 parent cad0c07 commit 14c1425
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 79 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53ff4c7900979433e8af56f59e267d06e6744e93
refs/heads/master: d77057f250104120c149904e6d1c85a7bf718ada
125 changes: 47 additions & 78 deletions trunk/drivers/staging/tm6000/tm6000-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down Expand Up @@ -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? */

Expand All @@ -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 (!dev)
return 0;

if (idx >= SNDRV_CARDS)
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;

Expand All @@ -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;
}

Expand Down
15 changes: 15 additions & 0 deletions trunk/drivers/staging/tm6000/tm6000.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 14c1425

Please sign in to comment.