1 /*
2 * Line6 Linux USB driver - 0.9.1beta
3 *
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 */
11
12 #include <sound/core.h>
13 #include <sound/initval.h>
14
15 #include "driver.h"
16 #include "audio.h"
17
18 static int line6_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
19 static char *line6_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
20
21 /*
22 Initialize the Line6 USB audio system.
23 */
line6_init_audio(struct usb_line6 * line6)24 int line6_init_audio(struct usb_line6 *line6)
25 {
26 static int dev;
27 struct snd_card *card;
28 int err;
29
30 err = snd_card_create(line6_index[dev], line6_id[dev], THIS_MODULE, 0,
31 &card);
32 if (err < 0)
33 return err;
34
35 line6->card = card;
36
37 strcpy(card->id, line6->properties->id);
38 strcpy(card->driver, DRIVER_NAME);
39 strcpy(card->shortname, line6->properties->name);
40 /* longname is 80 chars - see asound.h */
41 sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
42 dev_name(line6->ifcdev));
43 return 0;
44 }
45
46 /*
47 Register the Line6 USB audio system.
48 */
line6_register_audio(struct usb_line6 * line6)49 int line6_register_audio(struct usb_line6 *line6)
50 {
51 int err;
52
53 err = snd_card_register(line6->card);
54 if (err < 0)
55 return err;
56
57 return 0;
58 }
59
60 /*
61 Cleanup the Line6 USB audio system.
62 */
line6_cleanup_audio(struct usb_line6 * line6)63 void line6_cleanup_audio(struct usb_line6 *line6)
64 {
65 struct snd_card *card = line6->card;
66
67 if (card == NULL)
68 return;
69
70 snd_card_disconnect(card);
71 snd_card_free(card);
72 line6->card = NULL;
73 }
74