aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStefan Ringel <stefan.ringel@arcor.de>2010-05-30 08:19:02 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-02 13:05:42 -0400
commitd77057f250104120c149904e6d1c85a7bf718ada (patch)
tree1d49daee7efa660f7f78661ea56e944131516913 /drivers
parent53ff4c7900979433e8af56f59e267d06e6744e93 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/tm6000/tm6000-alsa.c125
-rw-r--r--drivers/staging/tm6000/tm6000.h15
2 files changed, 62 insertions, 78 deletions
diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index 273e26ede650..da221e22e27f 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -36,29 +36,6 @@
36 } while (0) 36 } while (0)
37 37
38/**************************************************************************** 38/****************************************************************************
39 Data type declarations - Can be moded to a header file later
40 ****************************************************************************/
41
42struct snd_tm6000_card {
43 struct snd_card *card;
44
45 spinlock_t reg_lock;
46
47 atomic_t count;
48
49 unsigned int period_size;
50 unsigned int num_periods;
51
52 struct tm6000_core *core;
53 struct tm6000_buffer *buf;
54
55 int bufsize;
56
57 struct snd_pcm_substream *substream;
58};
59
60
61/****************************************************************************
62 Module global static vars 39 Module global static vars
63 ****************************************************************************/ 40 ****************************************************************************/
64 41
@@ -312,21 +289,6 @@ static struct snd_pcm_ops snd_tm6000_pcm_ops = {
312/* 289/*
313 * create a PCM device 290 * create a PCM device
314 */ 291 */
315static int __devinit snd_tm6000_pcm(struct snd_tm6000_card *chip,
316 int device, char *name)
317{
318 int err;
319 struct snd_pcm *pcm;
320
321 err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm);
322 if (err < 0)
323 return err;
324 pcm->private_data = chip;
325 strcpy(pcm->name, name);
326 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_tm6000_pcm_ops);
327
328 return 0;
329}
330 292
331/* FIXME: Control interface - How to control volume/mute? */ 293/* FIXME: Control interface - How to control volume/mute? */
332 294
@@ -337,73 +299,64 @@ static int __devinit snd_tm6000_pcm(struct snd_tm6000_card *chip,
337/* 299/*
338 * Alsa Constructor - Component probe 300 * Alsa Constructor - Component probe
339 */ 301 */
340 302int tm6000_audio_init(struct tm6000_core *dev)
341int tm6000_audio_init(struct tm6000_core *dev, int idx)
342{ 303{
343 struct snd_card *card; 304 struct snd_card *card;
344 struct snd_tm6000_card *chip; 305 struct snd_tm6000_card *chip;
345 int rc, len; 306 int rc;
346 char component[14]; 307 static int devnr;
308 char component[14];
309 struct snd_pcm *pcm;
310
311 if (!dev)
312 return 0;
347 313
348 if (idx >= SNDRV_CARDS) 314 if (devnr >= SNDRV_CARDS)
349 return -ENODEV; 315 return -ENODEV;
350 316
351 if (!enable[idx]) 317 if (!enable[devnr])
352 return -ENOENT; 318 return -ENOENT;
353 319
354 rc = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card); 320 rc = snd_card_create(index[devnr], id[devnr], THIS_MODULE, 0, &card);
355 if (rc < 0) { 321 if (rc < 0) {
356 snd_printk(KERN_ERR "cannot create card instance %d\n", idx); 322 snd_printk(KERN_ERR "cannot create card instance %d\n", devnr);
357 return rc; 323 return rc;
358 } 324 }
359 325
360 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 326 chip = kzalloc(sizeof(struct snd_tm6000_card), GFP_KERNEL);
361 if (!chip) { 327 if (!chip) {
362 rc = -ENOMEM; 328 rc = -ENOMEM;
363 goto error; 329 goto error;
364 } 330 }
365 331
366 chip->core = dev;
367 chip->card = card;
368
369 strcpy(card->driver, "tm6000-alsa");
370 sprintf(component, "USB%04x:%04x", 332 sprintf(component, "USB%04x:%04x",
371 le16_to_cpu(dev->udev->descriptor.idVendor), 333 le16_to_cpu(dev->udev->descriptor.idVendor),
372 le16_to_cpu(dev->udev->descriptor.idProduct)); 334 le16_to_cpu(dev->udev->descriptor.idProduct));
373 snd_component_add(card, component); 335 snd_component_add(card, component);
374 336
375 if (dev->udev->descriptor.iManufacturer) 337 spin_lock_init(&chip->reg_lock);
376 len = usb_string(dev->udev, 338 rc = snd_pcm_new(card, "TM6000 Audio", 0, 0, 1, &pcm);
377 dev->udev->descriptor.iManufacturer,
378 card->longname, sizeof(card->longname));
379 else
380 len = 0;
381
382 if (len > 0)
383 strlcat(card->longname, " ", sizeof(card->longname));
384
385 strlcat(card->longname, card->shortname, sizeof(card->longname));
386
387 len = strlcat(card->longname, " at ", sizeof(card->longname));
388
389 if (len < sizeof(card->longname))
390 usb_make_path(dev->udev, card->longname + len,
391 sizeof(card->longname) - len);
392
393 strlcat(card->longname,
394 dev->udev->speed == USB_SPEED_LOW ? ", low speed" :
395 dev->udev->speed == USB_SPEED_FULL ? ", full speed" :
396 ", high speed",
397 sizeof(card->longname));
398
399 rc = snd_tm6000_pcm(chip, 0, "tm6000 Digital");
400 if (rc < 0) 339 if (rc < 0)
401 goto error; 340 goto error;
402 341
342 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_tm6000_pcm_ops);
343 pcm->info_flags = 0;
344 pcm->private_data = dev;
345 strcpy(pcm->name, "Trident TM5600/60x0");
346 strcpy(card->driver, "tm6000-alsa");
347 strcpy(card->shortname, "TM5600/60x0");
348 sprintf(card->longname, "TM5600/60x0 Audio at bus %d device %d",
349 dev->udev->bus->busnum, dev->udev->devnum);
350
351 snd_card_set_dev(card, &dev->udev->dev);
352
403 rc = snd_card_register(card); 353 rc = snd_card_register(card);
404 if (rc < 0) 354 if (rc < 0)
405 goto error; 355 goto error;
406 356
357 chip->core = dev;
358 chip->card = card;
359 dev->adev = chip;
407 360
408 return 0; 361 return 0;
409 362
@@ -414,6 +367,22 @@ error:
414 367
415static int tm6000_audio_fini(struct tm6000_core *dev) 368static int tm6000_audio_fini(struct tm6000_core *dev)
416{ 369{
370 struct snd_tm6000_card *chip = dev->adev;
371
372 if (!dev)
373 return 0;
374
375 if (!chip)
376 return 0;
377
378 if (!chip->card)
379 return 0;
380
381 snd_card_free(chip->card);
382 chip->card = NULL;
383 kfree(chip);
384 dev->adev = NULL;
385
417 return 0; 386 return 0;
418} 387}
419 388
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 7bbaf26dea14..e2675cac7516 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -132,6 +132,18 @@ struct tm6000_dvb {
132 struct mutex mutex; 132 struct mutex mutex;
133}; 133};
134 134
135struct snd_tm6000_card {
136 struct snd_card *card;
137 spinlock_t reg_lock;
138 atomic_t count;
139 unsigned int period_size;
140 unsigned int num_periods;
141 struct tm6000_core *core;
142 struct tm6000_buffer *buf;
143 int bufsize;
144 struct snd_pcm_substream *substream;
145};
146
135struct tm6000_endpoint { 147struct tm6000_endpoint {
136 struct usb_host_endpoint *endp; 148 struct usb_host_endpoint *endp;
137 __u8 bInterfaceNumber; 149 __u8 bInterfaceNumber;
@@ -190,6 +202,9 @@ struct tm6000_core {
190 /* DVB-T support */ 202 /* DVB-T support */
191 struct tm6000_dvb *dvb; 203 struct tm6000_dvb *dvb;
192 204
205 /* audio support */
206 struct snd_tm6000_card *adev;
207
193 /* locks */ 208 /* locks */
194 struct mutex lock; 209 struct mutex lock;
195 210