ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / sound / pcmcia / vx / vxpocket.c
1 /*
2  * Driver for Digigram VXpocket V2/440 soundcards
3  *
4  * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19  */
20
21 /*
22  please add the following as /etc/pcmcia/vxpocket.conf:
23  
24   device "snd-vxpocket"
25      class "audio" module "snd-vxpocket"
26
27   card "Digigram VX-POCKET"
28     manfid 0x01f1, 0x0100
29     bind "snd-vxpocket"
30
31  */
32
33 #include <sound/driver.h>
34 #include <linux/init.h>
35 #include <sound/core.h>
36 #include <pcmcia/version.h>
37 #include "vxpocket.h"
38 #include <sound/initval.h>
39
40 /*
41  */
42
43 #ifdef COMPILE_VXP440
44 #define CARD_NAME       "VXPocket440"
45 #else
46 #define CARD_NAME       "VXPocket"
47 #endif
48
49 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
50 MODULE_DESCRIPTION("Digigram " CARD_NAME);
51 MODULE_LICENSE("GPL");
52 MODULE_CLASSES("{sound}");
53 MODULE_DEVICES("{{Digigram," CARD_NAME "}}");
54
55 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
56 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
57 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable switches */
58 static unsigned int irq_mask = 0xffff;
59 static int irq_list[4] = { -1 };
60 static int ibl[SNDRV_CARDS];
61
62 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
63 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
64 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
65 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
66 MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
67 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
68 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
69 MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
70 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
71 MODULE_PARM(irq_mask, "i");
72 MODULE_PARM_DESC(irq_mask, "IRQ bitmask for " CARD_NAME " soundcard.");
73 MODULE_PARM(irq_list, "1-4i");
74 MODULE_PARM_DESC(irq_list, "List of Available interrupts for " CARD_NAME " soundcard.");
75 MODULE_PARM(ibl, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
76 MODULE_PARM_DESC(ibl, "Capture IBL size for " CARD_NAME " soundcard.");
77 MODULE_PARM_SYNTAX(ibl, SNDRV_ENABLED);
78  
79
80 /*
81  */
82
83 #ifdef COMPILE_VXP440
84
85 /* 1 DSP, 1 sync UER, 1 sync World Clock (NIY) */
86 /* SMPTE (NIY) */
87 /* 2 stereo analog input (line/micro) */
88 /* 2 stereo analog output */
89 /* Only output levels can be modified */
90 /* UER, but only for the first two inputs and outputs. */
91
92 #define NUM_CODECS      2
93 #define CARD_TYPE       VX_TYPE_VXP440
94 #define DEV_INFO        "snd-vxp440"
95
96 #else
97
98 /* 1 DSP, 1 sync UER */
99 /* 1 programmable clock (NIY) */
100 /* 1 stereo analog input (line/micro) */
101 /* 1 stereo analog output */
102 /* Only output levels can be modified */
103
104 #define NUM_CODECS      1
105 #define CARD_TYPE       VX_TYPE_VXPOCKET
106 #define DEV_INFO        "snd-vxpocket"
107
108 #endif
109
110 static dev_info_t dev_info = DEV_INFO;
111
112 static struct snd_vx_hardware vxp_hw = {
113         .name = CARD_NAME,
114         .type = CARD_TYPE,
115
116         /* hardware specs */
117         .num_codecs = NUM_CODECS,
118         .num_ins = NUM_CODECS,
119         .num_outs = NUM_CODECS,
120         .output_level_max = VX_ANALOG_OUT_LEVEL_MAX,
121 };      
122
123 static struct snd_vxp_entry hw_entry = {
124         .dev_info = &dev_info,
125
126         /* module parameters */
127         .index_table = index,
128         .id_table = id,
129         .enable_table = enable,
130         .irq_mask_p = &irq_mask,
131         .irq_list = irq_list,
132         .ibl = ibl,
133
134         /* h/w config */
135         .hardware = &vxp_hw,
136         .ops = &snd_vxpocket_ops,
137 };
138
139 /*
140  */
141 static dev_link_t *vxp_attach(void)
142 {
143         return snd_vxpocket_attach(&hw_entry);
144 }
145
146 static void vxp_detach(dev_link_t *link)
147 {
148         snd_vxpocket_detach(&hw_entry, link);
149 }
150
151 /*
152  * Module entry points
153  */
154
155 static struct pcmcia_driver vxp_cs_driver = {
156         .owner          = THIS_MODULE,
157         .drv            = {
158                 .name   = DEV_INFO,
159         },
160         .attach         = vxp_attach,
161         .detach         = vxp_detach
162 };
163
164 static int __init init_vxpocket(void)
165 {
166         return pcmcia_register_driver(&vxp_cs_driver);
167 }
168
169 static void __exit exit_vxpocket(void)
170 {
171         pcmcia_unregister_driver(&vxp_cs_driver);
172         snd_vxpocket_detach_all(&hw_entry);
173 }
174
175 module_init(init_vxpocket);
176 module_exit(exit_vxpocket);