Commit | Line | Data |
---|---|---|
705ececd | 1 | /* |
e1a164d7 | 2 | * Line6 Linux USB driver - 0.9.1beta |
705ececd | 3 | * |
1027f476 | 4 | * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) |
705ececd MG |
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 | ||
705ececd MG |
12 | #include <sound/core.h> |
13 | #include <sound/initval.h> | |
8e336a72 | 14 | #include <linux/export.h> |
705ececd | 15 | |
1027f476 MG |
16 | #include "driver.h" |
17 | #include "audio.h" | |
18 | ||
705ececd MG |
19 | static int line6_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
20 | static char *line6_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | |
21 | ||
705ececd MG |
22 | /* |
23 | Initialize the Line6 USB audio system. | |
24 | */ | |
25 | int line6_init_audio(struct usb_line6 *line6) | |
26 | { | |
dfc70567 | 27 | static int dev; |
705ececd | 28 | struct snd_card *card; |
a405f43e | 29 | int err; |
705ececd | 30 | |
a405f43e AB |
31 | err = snd_card_create(line6_index[dev], line6_id[dev], THIS_MODULE, 0, |
32 | &card); | |
33 | if (err < 0) | |
34 | return err; | |
705ececd MG |
35 | |
36 | line6->card = card; | |
37 | ||
1027f476 | 38 | strcpy(card->id, line6->properties->id); |
705ececd | 39 | strcpy(card->driver, DRIVER_NAME); |
1027f476 | 40 | strcpy(card->shortname, line6->properties->name); |
027360c5 GKH |
41 | /* longname is 80 chars - see asound.h */ |
42 | sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name, | |
43 | dev_name(line6->ifcdev)); | |
705ececd MG |
44 | return 0; |
45 | } | |
46 | ||
47 | /* | |
48 | Register the Line6 USB audio system. | |
49 | */ | |
50 | int line6_register_audio(struct usb_line6 *line6) | |
51 | { | |
52 | int err; | |
53 | ||
dfc70567 GKH |
54 | err = snd_card_register(line6->card); |
55 | if (err < 0) | |
705ececd MG |
56 | return err; |
57 | ||
58 | return 0; | |
59 | } | |
60 | ||
61 | /* | |
62 | Cleanup the Line6 USB audio system. | |
63 | */ | |
64 | void line6_cleanup_audio(struct usb_line6 *line6) | |
65 | { | |
66 | struct snd_card *card = line6->card; | |
67 | ||
536165d8 | 68 | if (card == NULL) |
705ececd MG |
69 | return; |
70 | ||
71 | snd_card_disconnect(card); | |
72 | snd_card_free(card); | |
536165d8 | 73 | line6->card = NULL; |
705ececd | 74 | } |