aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pcmcia
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-07-30 01:55:32 -0400
committerLen Brown <len.brown@intel.com>2005-07-30 01:55:32 -0400
commitadbedd34244e2b054557002817f979a9b004a405 (patch)
tree78e4a524e84f8b3e23ae8b49ac689048584e4668 /sound/pcmcia
parentd6ac1a7910d22626bc77e73db091e00b810715f4 (diff)
parentb0825488a642cadcf39709961dde61440cb0731c (diff)
merge 2.6.13-rc4 with ACPI's to-linus tree
Diffstat (limited to 'sound/pcmcia')
-rw-r--r--sound/pcmcia/Kconfig15
-rw-r--r--sound/pcmcia/vx/Makefile7
-rw-r--r--sound/pcmcia/vx/vx_entry.c375
-rw-r--r--sound/pcmcia/vx/vxp440.c14
-rw-r--r--sound/pcmcia/vx/vxpocket.c427
-rw-r--r--sound/pcmcia/vx/vxpocket.h27
6 files changed, 378 insertions, 487 deletions
diff --git a/sound/pcmcia/Kconfig b/sound/pcmcia/Kconfig
index 3611e298834f..5d1b0b762efa 100644
--- a/sound/pcmcia/Kconfig
+++ b/sound/pcmcia/Kconfig
@@ -8,23 +8,12 @@ config SND_VXPOCKET
8 depends on SND && PCMCIA && ISA 8 depends on SND && PCMCIA && ISA
9 select SND_VX_LIB 9 select SND_VX_LIB
10 help 10 help
11 Say Y here to include support for Digigram VXpocket 11 Say Y here to include support for Digigram VXpocket and
12 soundcards. 12 VXpocket 440 soundcards.
13 13
14 To compile this driver as a module, choose M here: the module 14 To compile this driver as a module, choose M here: the module
15 will be called snd-vxpocket. 15 will be called snd-vxpocket.
16 16
17config SND_VXP440
18 tristate "Digigram VXpocket 440"
19 depends on SND && PCMCIA && ISA
20 select SND_VX_LIB
21 help
22 Say Y here to include support for Digigram VXpocket 440
23 soundcards.
24
25 To compile this driver as a module, choose M here: the module
26 will be called snd-vxp440.
27
28config SND_PDAUDIOCF 17config SND_PDAUDIOCF
29 tristate "Sound Core PDAudioCF" 18 tristate "Sound Core PDAudioCF"
30 depends on SND && PCMCIA && ISA 19 depends on SND && PCMCIA && ISA
diff --git a/sound/pcmcia/vx/Makefile b/sound/pcmcia/vx/Makefile
index f35dfa1af094..54971f01e968 100644
--- a/sound/pcmcia/vx/Makefile
+++ b/sound/pcmcia/vx/Makefile
@@ -3,9 +3,6 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
4# 4#
5 5
6snd-vx-cs-objs := vx_entry.o vxp_ops.o vxp_mixer.o 6snd-vxpocket-objs := vxpocket.o vxp_ops.o vxp_mixer.o
7snd-vxpocket-objs := vxpocket.o
8snd-vxp440-objs := vxp440.o
9 7
10obj-$(CONFIG_SND_VXPOCKET) += snd-vxpocket.o snd-vx-cs.o 8obj-$(CONFIG_SND_VXPOCKET) += snd-vxpocket.o
11obj-$(CONFIG_SND_VXP440) += snd-vxp440.o snd-vx-cs.o
diff --git a/sound/pcmcia/vx/vx_entry.c b/sound/pcmcia/vx/vx_entry.c
deleted file mode 100644
index df7a39ba9680..000000000000
--- a/sound/pcmcia/vx/vx_entry.c
+++ /dev/null
@@ -1,375 +0,0 @@
1/*
2 * Driver for Digigram VXpocket soundcards
3 *
4 * PCMCIA entry part
5 *
6 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <sound/driver.h>
24#include <sound/core.h>
25#include "vxpocket.h"
26#include <pcmcia/ciscode.h>
27#include <pcmcia/cisreg.h>
28
29
30MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
31MODULE_DESCRIPTION("Common routines for Digigram PCMCIA VX drivers");
32MODULE_LICENSE("GPL");
33
34/*
35 * prototypes
36 */
37static void vxpocket_config(dev_link_t *link);
38
39
40static void vxpocket_release(dev_link_t *link)
41{
42 if (link->state & DEV_CONFIG) {
43 /* release cs resources */
44 pcmcia_release_configuration(link->handle);
45 pcmcia_release_io(link->handle, &link->io);
46 pcmcia_release_irq(link->handle, &link->irq);
47 link->state &= ~DEV_CONFIG;
48 }
49}
50
51/*
52 * destructor
53 */
54static int snd_vxpocket_free(vx_core_t *chip)
55{
56 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
57 struct snd_vxp_entry *hw;
58 dev_link_t *link = &vxp->link;
59
60 vxpocket_release(link);
61
62 /* Break the link with Card Services */
63 if (link->handle)
64 pcmcia_deregister_client(link->handle);
65
66 hw = vxp->hw_entry;
67 if (hw)
68 hw->card_list[vxp->index] = NULL;
69 chip->card = NULL;
70 kfree(chip->dev);
71
72 snd_vx_free_firmware(chip);
73 kfree(chip);
74 return 0;
75}
76
77static int snd_vxpocket_dev_free(snd_device_t *device)
78{
79 vx_core_t *chip = device->device_data;
80 return snd_vxpocket_free(chip);
81}
82
83/*
84 * snd_vxpocket_attach - attach callback for cs
85 * @hw: the hardware information
86 */
87dev_link_t *snd_vxpocket_attach(struct snd_vxp_entry *hw)
88{
89 client_reg_t client_reg; /* Register with cardmgr */
90 dev_link_t *link; /* Info for cardmgr */
91 int i, ret;
92 vx_core_t *chip;
93 struct snd_vxpocket *vxp;
94 snd_card_t *card;
95 static snd_device_ops_t ops = {
96 .dev_free = snd_vxpocket_dev_free,
97 };
98
99 snd_printdd(KERN_DEBUG "vxpocket_attach called\n");
100 /* find an empty slot from the card list */
101 for (i = 0; i < SNDRV_CARDS; i++) {
102 if (! hw->card_list[i])
103 break;
104 }
105 if (i >= SNDRV_CARDS) {
106 snd_printk(KERN_ERR "vxpocket: too many cards found\n");
107 return NULL;
108 }
109 if (! hw->enable_table[i])
110 return NULL; /* disabled explicitly */
111
112 /* ok, create a card instance */
113 card = snd_card_new(hw->index_table[i], hw->id_table[i], THIS_MODULE, 0);
114 if (card == NULL) {
115 snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n");
116 return NULL;
117 }
118
119 chip = snd_vx_create(card, hw->hardware, hw->ops,
120 sizeof(struct snd_vxpocket) - sizeof(vx_core_t));
121 if (! chip)
122 return NULL;
123
124#ifdef SND_VX_FW_LOADER
125 /* fake a device here since pcmcia doesn't give a valid device... */
126 chip->dev = kcalloc(1, sizeof(*chip->dev), GFP_KERNEL);
127 if (! chip->dev) {
128 snd_printk(KERN_ERR "vxp: can't malloc chip->dev\n");
129 kfree(chip);
130 snd_card_free(card);
131 return NULL;
132 }
133 device_initialize(chip->dev);
134 sprintf(chip->dev->bus_id, "vxpocket%d", i);
135#endif
136
137 if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops) < 0) {
138 kfree(chip);
139 snd_card_free(card);
140 return NULL;
141 }
142
143 vxp = (struct snd_vxpocket *)chip;
144 vxp->index = i;
145 vxp->hw_entry = hw;
146 chip->ibl.size = hw->ibl[i];
147 hw->card_list[i] = chip;
148
149 link = &vxp->link;
150 link->priv = chip;
151
152 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
153 link->io.NumPorts1 = 16;
154
155 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
156 // link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
157
158 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
159 link->irq.Handler = &snd_vx_irq_handler;
160 link->irq.Instance = chip;
161
162 link->conf.Attributes = CONF_ENABLE_IRQ;
163 link->conf.Vcc = 50;
164 link->conf.IntType = INT_MEMORY_AND_IO;
165 link->conf.ConfigIndex = 1;
166 link->conf.Present = PRESENT_OPTION;
167
168 /* Register with Card Services */
169 memset(&client_reg, 0, sizeof(client_reg));
170 client_reg.dev_info = hw->dev_info;
171 client_reg.Version = 0x0210;
172 client_reg.event_callback_args.client_data = link;
173
174 ret = pcmcia_register_client(&link->handle, &client_reg);
175 if (ret != CS_SUCCESS) {
176 cs_error(link->handle, RegisterClient, ret);
177 snd_card_free(card);
178 return NULL;
179 }
180
181 /* Chain drivers */
182 link->next = hw->dev_list;
183 hw->dev_list = link;
184
185 /* snd_card_set_pm_callback(card, snd_vxpocket_suspend, snd_vxpocket_resume, chip); */
186
187 return link;
188}
189
190
191/**
192 * snd_vxpocket_assign_resources - initialize the hardware and card instance.
193 * @port: i/o port for the card
194 * @irq: irq number for the card
195 *
196 * this function assigns the specified port and irq, boot the card,
197 * create pcm and control instances, and initialize the rest hardware.
198 *
199 * returns 0 if successful, or a negative error code.
200 */
201static int snd_vxpocket_assign_resources(vx_core_t *chip, int port, int irq)
202{
203 int err;
204 snd_card_t *card = chip->card;
205 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
206
207 snd_printdd(KERN_DEBUG "vxpocket assign resources: port = 0x%x, irq = %d\n", port, irq);
208 vxp->port = port;
209
210 sprintf(card->shortname, "Digigram %s", card->driver);
211 sprintf(card->longname, "%s at 0x%x, irq %i",
212 card->shortname, port, irq);
213
214 chip->irq = irq;
215
216 if ((err = snd_vx_setup_firmware(chip)) < 0)
217 return err;
218
219 return 0;
220}
221
222
223/*
224 * snd_vxpocket_detach - detach callback for cs
225 * @hw: the hardware information
226 */
227void snd_vxpocket_detach(struct snd_vxp_entry *hw, dev_link_t *link)
228{
229 vx_core_t *chip;
230
231 if (! link)
232 return;
233
234 chip = link->priv;
235
236 snd_printdd(KERN_DEBUG "vxpocket_detach called\n");
237 /* Remove the interface data from the linked list */
238 if (hw) {
239 dev_link_t **linkp;
240 /* Locate device structure */
241 for (linkp = &hw->dev_list; *linkp; linkp = &(*linkp)->next)
242 if (*linkp == link) {
243 *linkp = link->next;
244 break;
245 }
246 }
247 chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */
248 snd_card_disconnect(chip->card);
249 snd_card_free_in_thread(chip->card);
250}
251
252/*
253 * configuration callback
254 */
255
256#define CS_CHECK(fn, ret) \
257do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
258
259static void vxpocket_config(dev_link_t *link)
260{
261 client_handle_t handle = link->handle;
262 vx_core_t *chip = link->priv;
263 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
264 tuple_t tuple;
265 cisparse_t *parse = NULL;
266 u_short buf[32];
267 int last_fn, last_ret;
268
269 snd_printdd(KERN_DEBUG "vxpocket_config called\n");
270 parse = kmalloc(sizeof(*parse), GFP_KERNEL);
271 if (! parse) {
272 snd_printk(KERN_ERR "vx: cannot allocate\n");
273 return;
274 }
275 tuple.Attributes = 0;
276 tuple.TupleData = (cisdata_t *)buf;
277 tuple.TupleDataMax = sizeof(buf);
278 tuple.TupleOffset = 0;
279 tuple.DesiredTuple = CISTPL_CONFIG;
280 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
281 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
282 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse));
283 link->conf.ConfigBase = parse->config.base;
284 link->conf.Present = parse->config.rmask[0];
285
286 /* Configure card */
287 link->state |= DEV_CONFIG;
288
289 CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
290 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
291 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
292
293 if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
294 goto failed;
295
296 link->dev = &vxp->node;
297 link->state &= ~DEV_CONFIG_PENDING;
298 kfree(parse);
299 return;
300
301cs_failed:
302 cs_error(link->handle, last_fn, last_ret);
303failed:
304 pcmcia_release_configuration(link->handle);
305 pcmcia_release_io(link->handle, &link->io);
306 pcmcia_release_irq(link->handle, &link->irq);
307 link->state &= ~DEV_CONFIG;
308 kfree(parse);
309}
310
311
312/*
313 * event callback
314 */
315int vxpocket_event(event_t event, int priority, event_callback_args_t *args)
316{
317 dev_link_t *link = args->client_data;
318 vx_core_t *chip = link->priv;
319
320 switch (event) {
321 case CS_EVENT_CARD_REMOVAL:
322 snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n");
323 link->state &= ~DEV_PRESENT;
324 if (link->state & DEV_CONFIG) {
325 chip->chip_status |= VX_STAT_IS_STALE;
326 }
327 break;
328 case CS_EVENT_CARD_INSERTION:
329 snd_printdd(KERN_DEBUG "CARD_INSERTION..\n");
330 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
331 vxpocket_config(link);
332 break;
333#ifdef CONFIG_PM
334 case CS_EVENT_PM_SUSPEND:
335 snd_printdd(KERN_DEBUG "SUSPEND\n");
336 link->state |= DEV_SUSPEND;
337 if (chip && chip->card->pm_suspend) {
338 snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n");
339 chip->card->pm_suspend(chip->card, PMSG_SUSPEND);
340 }
341 /* Fall through... */
342 case CS_EVENT_RESET_PHYSICAL:
343 snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n");
344 if (link->state & DEV_CONFIG)
345 pcmcia_release_configuration(link->handle);
346 break;
347 case CS_EVENT_PM_RESUME:
348 snd_printdd(KERN_DEBUG "RESUME\n");
349 link->state &= ~DEV_SUSPEND;
350 /* Fall through... */
351 case CS_EVENT_CARD_RESET:
352 snd_printdd(KERN_DEBUG "CARD_RESET\n");
353 if (DEV_OK(link)) {
354 //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
355 snd_printdd(KERN_DEBUG "requestconfig...\n");
356 pcmcia_request_configuration(link->handle, &link->conf);
357 if (chip && chip->card->pm_resume) {
358 snd_printdd(KERN_DEBUG "calling snd_vx_resume\n");
359 chip->card->pm_resume(chip->card);
360 }
361 }
362 snd_printdd(KERN_DEBUG "resume done!\n");
363 break;
364#endif
365 }
366 return 0;
367}
368
369/*
370 * exported stuffs
371 */
372EXPORT_SYMBOL(snd_vxpocket_ops);
373EXPORT_SYMBOL(snd_vxpocket_attach);
374EXPORT_SYMBOL(vxpocket_event);
375EXPORT_SYMBOL(snd_vxpocket_detach);
diff --git a/sound/pcmcia/vx/vxp440.c b/sound/pcmcia/vx/vxp440.c
deleted file mode 100644
index 59190a833001..000000000000
--- a/sound/pcmcia/vx/vxp440.c
+++ /dev/null
@@ -1,14 +0,0 @@
1#define COMPILE_VXP440
2
3/*
4 add the following as /etc/pcmcia/vxp440.conf:
5
6 device "snd-vxp440"
7 class "audio" module "snd-vxp440"
8
9 card "Digigram VX-POCKET440"
10 manfid 0x01f1, 0x0100
11 bind "snd-vxp440"
12*/
13
14#include "vxpocket.c"
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 62d6fa128148..3a82161d3b24 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -24,21 +24,17 @@
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <sound/core.h> 25#include <sound/core.h>
26#include "vxpocket.h" 26#include "vxpocket.h"
27#include <pcmcia/ciscode.h>
28#include <pcmcia/cisreg.h>
27#include <sound/initval.h> 29#include <sound/initval.h>
28 30
29/* 31/*
30 */ 32 */
31 33
32#ifdef COMPILE_VXP440
33#define CARD_NAME "VXPocket440"
34#else
35#define CARD_NAME "VXPocket"
36#endif
37
38MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); 34MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
39MODULE_DESCRIPTION("Digigram " CARD_NAME); 35MODULE_DESCRIPTION("Digigram VXPocket");
40MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
41MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}"); 37MODULE_SUPPORTED_DEVICE("{{Digigram,VXPocket},{Digigram,VXPocket440}}");
42 38
43static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 39static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 40static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -46,82 +42,405 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
46static int ibl[SNDRV_CARDS]; 42static int ibl[SNDRV_CARDS];
47 43
48module_param_array(index, int, NULL, 0444); 44module_param_array(index, int, NULL, 0444);
49MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 45MODULE_PARM_DESC(index, "Index value for VXPocket soundcard.");
50module_param_array(id, charp, NULL, 0444); 46module_param_array(id, charp, NULL, 0444);
51MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); 47MODULE_PARM_DESC(id, "ID string for VXPocket soundcard.");
52module_param_array(enable, bool, NULL, 0444); 48module_param_array(enable, bool, NULL, 0444);
53MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); 49MODULE_PARM_DESC(enable, "Enable VXPocket soundcard.");
54module_param_array(ibl, int, NULL, 0444); 50module_param_array(ibl, int, NULL, 0444);
55MODULE_PARM_DESC(ibl, "Capture IBL size for " CARD_NAME " soundcard."); 51MODULE_PARM_DESC(ibl, "Capture IBL size for VXPocket soundcard.");
56 52
57 53
58/* 54/*
59 */ 55 */
60 56
61#ifdef COMPILE_VXP440 57static unsigned int card_alloc;
58static dev_link_t *dev_list; /* Linked list of devices */
59static dev_info_t dev_info = "snd-vxpocket";
62 60
63/* 1 DSP, 1 sync UER, 1 sync World Clock (NIY) */
64/* SMPTE (NIY) */
65/* 2 stereo analog input (line/micro) */
66/* 2 stereo analog output */
67/* Only output levels can be modified */
68/* UER, but only for the first two inputs and outputs. */
69 61
70#define NUM_CODECS 2 62static int vxpocket_event(event_t event, int priority, event_callback_args_t *args);
71#define CARD_TYPE VX_TYPE_VXP440
72#define DEV_INFO "snd-vxp440"
73 63
74#else
75 64
76/* 1 DSP, 1 sync UER */ 65/*
77/* 1 programmable clock (NIY) */ 66 */
78/* 1 stereo analog input (line/micro) */ 67static void vxpocket_release(dev_link_t *link)
79/* 1 stereo analog output */ 68{
80/* Only output levels can be modified */ 69 if (link->state & DEV_CONFIG) {
70 /* release cs resources */
71 pcmcia_release_configuration(link->handle);
72 pcmcia_release_io(link->handle, &link->io);
73 pcmcia_release_irq(link->handle, &link->irq);
74 link->state &= ~DEV_CONFIG;
75 }
76 if (link->handle) {
77 /* Break the link with Card Services */
78 pcmcia_deregister_client(link->handle);
79 link->handle = NULL;
80 }
81}
81 82
82#define NUM_CODECS 1 83/*
83#define CARD_TYPE VX_TYPE_VXPOCKET 84 * destructor, called from snd_card_free_in_thread()
84#define DEV_INFO "snd-vxpocket" 85 */
86static int snd_vxpocket_dev_free(snd_device_t *device)
87{
88 vx_core_t *chip = device->device_data;
85 89
86#endif 90 snd_vx_free_firmware(chip);
91 kfree(chip);
92 return 0;
93}
87 94
88static dev_info_t dev_info = DEV_INFO;
89 95
90static struct snd_vx_hardware vxp_hw = { 96/*
91 .name = CARD_NAME, 97 * Hardware information
92 .type = CARD_TYPE, 98 */
99
100/* VX-pocket V2
101 *
102 * 1 DSP, 1 sync UER
103 * 1 programmable clock (NIY)
104 * 1 stereo analog input (line/micro)
105 * 1 stereo analog output
106 * Only output levels can be modified
107 */
108
109static struct snd_vx_hardware vxpocket_hw = {
110 .name = "VXPocket",
111 .type = VX_TYPE_VXPOCKET,
93 112
94 /* hardware specs */ 113 /* hardware specs */
95 .num_codecs = NUM_CODECS, 114 .num_codecs = 1,
96 .num_ins = NUM_CODECS, 115 .num_ins = 1,
97 .num_outs = NUM_CODECS, 116 .num_outs = 1,
98 .output_level_max = VX_ANALOG_OUT_LEVEL_MAX, 117 .output_level_max = VX_ANALOG_OUT_LEVEL_MAX,
99}; 118};
100 119
101static struct snd_vxp_entry hw_entry = { 120/* VX-pocket 440
102 .dev_info = &dev_info, 121 *
122 * 1 DSP, 1 sync UER, 1 sync World Clock (NIY)
123 * SMPTE (NIY)
124 * 2 stereo analog input (line/micro)
125 * 2 stereo analog output
126 * Only output levels can be modified
127 * UER, but only for the first two inputs and outputs.
128 */
103 129
104 /* module parameters */ 130static struct snd_vx_hardware vxp440_hw = {
105 .index_table = index, 131 .name = "VXPocket440",
106 .id_table = id, 132 .type = VX_TYPE_VXP440,
107 .enable_table = enable, 133
108 .ibl = ibl, 134 /* hardware specs */
135 .num_codecs = 2,
136 .num_ins = 2,
137 .num_outs = 2,
138 .output_level_max = VX_ANALOG_OUT_LEVEL_MAX,
139};
140
141
142/*
143 * create vxpocket instance
144 */
145static struct snd_vxpocket *snd_vxpocket_new(snd_card_t *card, int ibl)
146{
147 client_reg_t client_reg; /* Register with cardmgr */
148 dev_link_t *link; /* Info for cardmgr */
149 vx_core_t *chip;
150 struct snd_vxpocket *vxp;
151 int ret;
152 static snd_device_ops_t ops = {
153 .dev_free = snd_vxpocket_dev_free,
154 };
155
156 chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops,
157 sizeof(struct snd_vxpocket) - sizeof(vx_core_t));
158 if (! chip)
159 return NULL;
160
161 if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops) < 0) {
162 kfree(chip);
163 return NULL;
164 }
165 chip->ibl.size = ibl;
166
167 vxp = (struct snd_vxpocket *)chip;
168
169 link = &vxp->link;
170 link->priv = chip;
171
172 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
173 link->io.NumPorts1 = 16;
174
175 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
176
177 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
178 link->irq.Handler = &snd_vx_irq_handler;
179 link->irq.Instance = chip;
180
181 link->conf.Attributes = CONF_ENABLE_IRQ;
182 link->conf.Vcc = 50;
183 link->conf.IntType = INT_MEMORY_AND_IO;
184 link->conf.ConfigIndex = 1;
185 link->conf.Present = PRESENT_OPTION;
186
187 /* Register with Card Services */
188 memset(&client_reg, 0, sizeof(client_reg));
189 client_reg.dev_info = &dev_info;
190 client_reg.EventMask =
191 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL
192#ifdef CONFIG_PM
193 | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET
194 | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME
195#endif
196 ;
197 client_reg.event_handler = &vxpocket_event;
198 client_reg.Version = 0x0210;
199 client_reg.event_callback_args.client_data = link;
200
201 ret = pcmcia_register_client(&link->handle, &client_reg);
202 if (ret != CS_SUCCESS) {
203 cs_error(link->handle, RegisterClient, ret);
204 return NULL;
205 }
206
207 return vxp;
208}
209
210
211/**
212 * snd_vxpocket_assign_resources - initialize the hardware and card instance.
213 * @port: i/o port for the card
214 * @irq: irq number for the card
215 *
216 * this function assigns the specified port and irq, boot the card,
217 * create pcm and control instances, and initialize the rest hardware.
218 *
219 * returns 0 if successful, or a negative error code.
220 */
221static int snd_vxpocket_assign_resources(vx_core_t *chip, int port, int irq)
222{
223 int err;
224 snd_card_t *card = chip->card;
225 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
226
227 snd_printdd(KERN_DEBUG "vxpocket assign resources: port = 0x%x, irq = %d\n", port, irq);
228 vxp->port = port;
229
230 sprintf(card->shortname, "Digigram %s", card->driver);
231 sprintf(card->longname, "%s at 0x%x, irq %i",
232 card->shortname, port, irq);
233
234 chip->irq = irq;
235
236 if ((err = snd_vx_setup_firmware(chip)) < 0)
237 return err;
238
239 return 0;
240}
241
242
243/*
244 * configuration callback
245 */
246
247#define CS_CHECK(fn, ret) \
248do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
249
250static void vxpocket_config(dev_link_t *link)
251{
252 client_handle_t handle = link->handle;
253 vx_core_t *chip = link->priv;
254 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
255 tuple_t tuple;
256 cisparse_t *parse;
257 u_short buf[32];
258 int last_fn, last_ret;
259
260 snd_printdd(KERN_DEBUG "vxpocket_config called\n");
261 parse = kmalloc(sizeof(*parse), GFP_KERNEL);
262 if (! parse) {
263 snd_printk(KERN_ERR "vx: cannot allocate\n");
264 return;
265 }
266 tuple.Attributes = 0;
267 tuple.TupleData = (cisdata_t *)buf;
268 tuple.TupleDataMax = sizeof(buf);
269 tuple.TupleOffset = 0;
270 tuple.DesiredTuple = CISTPL_CONFIG;
271 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
272 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
273 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse));
274 link->conf.ConfigBase = parse->config.base;
275 link->conf.Present = parse->config.rmask[0];
276
277 /* redefine hardware record according to the VERSION1 string */
278 tuple.DesiredTuple = CISTPL_VERS_1;
279 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
280 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
281 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse));
282 if (! strcmp(parse->version_1.str + parse->version_1.ofs[1], "VX-POCKET")) {
283 snd_printdd("VX-pocket is detected\n");
284 } else {
285 snd_printdd("VX-pocket 440 is detected\n");
286 /* overwrite the hardware information */
287 chip->hw = &vxp440_hw;
288 chip->type = vxp440_hw.type;
289 strcpy(chip->card->driver, vxp440_hw.name);
290 }
291
292 /* Configure card */
293 link->state |= DEV_CONFIG;
294
295 CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
296 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
297 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
298
299 chip->dev = &handle_to_dev(link->handle);
300
301 if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
302 goto failed;
303
304 link->dev = &vxp->node;
305 link->state &= ~DEV_CONFIG_PENDING;
306 kfree(parse);
307 return;
308
309cs_failed:
310 cs_error(link->handle, last_fn, last_ret);
311failed:
312 pcmcia_release_configuration(link->handle);
313 pcmcia_release_io(link->handle, &link->io);
314 pcmcia_release_irq(link->handle, &link->irq);
315 link->state &= ~DEV_CONFIG;
316 kfree(parse);
317}
318
319
320/*
321 * event callback
322 */
323static int vxpocket_event(event_t event, int priority, event_callback_args_t *args)
324{
325 dev_link_t *link = args->client_data;
326 vx_core_t *chip = link->priv;
327
328 switch (event) {
329 case CS_EVENT_CARD_REMOVAL:
330 snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n");
331 link->state &= ~DEV_PRESENT;
332 if (link->state & DEV_CONFIG)
333 chip->chip_status |= VX_STAT_IS_STALE;
334 break;
335 case CS_EVENT_CARD_INSERTION:
336 snd_printdd(KERN_DEBUG "CARD_INSERTION..\n");
337 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
338 vxpocket_config(link);
339 break;
340#ifdef CONFIG_PM
341 case CS_EVENT_PM_SUSPEND:
342 snd_printdd(KERN_DEBUG "SUSPEND\n");
343 link->state |= DEV_SUSPEND;
344 if (chip && chip->card->pm_suspend) {
345 snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n");
346 chip->card->pm_suspend(chip->card, PMSG_SUSPEND);
347 }
348 /* Fall through... */
349 case CS_EVENT_RESET_PHYSICAL:
350 snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n");
351 if (link->state & DEV_CONFIG)
352 pcmcia_release_configuration(link->handle);
353 break;
354 case CS_EVENT_PM_RESUME:
355 snd_printdd(KERN_DEBUG "RESUME\n");
356 link->state &= ~DEV_SUSPEND;
357 /* Fall through... */
358 case CS_EVENT_CARD_RESET:
359 snd_printdd(KERN_DEBUG "CARD_RESET\n");
360 if (DEV_OK(link)) {
361 //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
362 snd_printdd(KERN_DEBUG "requestconfig...\n");
363 pcmcia_request_configuration(link->handle, &link->conf);
364 if (chip && chip->card->pm_resume) {
365 snd_printdd(KERN_DEBUG "calling snd_vx_resume\n");
366 chip->card->pm_resume(chip->card);
367 }
368 }
369 snd_printdd(KERN_DEBUG "resume done!\n");
370 break;
371#endif
372 }
373 return 0;
374}
109 375
110 /* h/w config */
111 .hardware = &vxp_hw,
112 .ops = &snd_vxpocket_ops,
113};
114 376
115/* 377/*
116 */ 378 */
117static dev_link_t *vxp_attach(void) 379static dev_link_t *vxp_attach(void)
118{ 380{
119 return snd_vxpocket_attach(&hw_entry); 381 snd_card_t *card;
382 struct snd_vxpocket *vxp;
383 int i;
384
385 /* find an empty slot from the card list */
386 for (i = 0; i < SNDRV_CARDS; i++) {
387 if (! card_alloc & (1 << i))
388 break;
389 }
390 if (i >= SNDRV_CARDS) {
391 snd_printk(KERN_ERR "vxpocket: too many cards found\n");
392 return NULL;
393 }
394 if (! enable[i])
395 return NULL; /* disabled explicitly */
396
397 /* ok, create a card instance */
398 card = snd_card_new(index[i], id[i], THIS_MODULE, 0);
399 if (card == NULL) {
400 snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n");
401 return NULL;
402 }
403
404 vxp = snd_vxpocket_new(card, ibl[i]);
405 if (! vxp) {
406 snd_card_free(card);
407 return NULL;
408 }
409
410 vxp->index = index[i];
411 card_alloc |= 1 << i;
412
413 /* Chain drivers */
414 vxp->link.next = dev_list;
415 dev_list = &vxp->link;
416
417 return &vxp->link;
120} 418}
121 419
122static void vxp_detach(dev_link_t *link) 420static void vxp_detach(dev_link_t *link)
123{ 421{
124 snd_vxpocket_detach(&hw_entry, link); 422 struct snd_vxpocket *vxp;
423 vx_core_t *chip;
424 dev_link_t **linkp;
425
426 if (! link)
427 return;
428
429 vxp = link->priv;
430 chip = (vx_core_t *)vxp;
431 card_alloc &= ~(1 << vxp->index);
432
433 /* Remove the interface data from the linked list */
434 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
435 if (*linkp == link) {
436 *linkp = link->next;
437 break;
438 }
439
440 chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */
441 snd_card_disconnect(chip->card);
442 vxpocket_release(link);
443 snd_card_free_in_thread(chip->card);
125} 444}
126 445
127/* 446/*
@@ -137,7 +456,7 @@ MODULE_DEVICE_TABLE(pcmcia, vxp_ids);
137static struct pcmcia_driver vxp_cs_driver = { 456static struct pcmcia_driver vxp_cs_driver = {
138 .owner = THIS_MODULE, 457 .owner = THIS_MODULE,
139 .drv = { 458 .drv = {
140 .name = DEV_INFO, 459 .name = "snd-vxpocket",
141 }, 460 },
142 .attach = vxp_attach, 461 .attach = vxp_attach,
143 .detach = vxp_detach, 462 .detach = vxp_detach,
@@ -152,7 +471,7 @@ static int __init init_vxpocket(void)
152static void __exit exit_vxpocket(void) 471static void __exit exit_vxpocket(void)
153{ 472{
154 pcmcia_unregister_driver(&vxp_cs_driver); 473 pcmcia_unregister_driver(&vxp_cs_driver);
155 BUG_ON(hw_entry.dev_list != NULL); 474 BUG_ON(dev_list != NULL);
156} 475}
157 476
158module_init(init_vxpocket); 477module_init(init_vxpocket);
diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h
index 4462c04a4e8f..70754aa3dd11 100644
--- a/sound/pcmcia/vx/vxpocket.h
+++ b/sound/pcmcia/vx/vxpocket.h
@@ -28,24 +28,6 @@
28#include <pcmcia/cistpl.h> 28#include <pcmcia/cistpl.h>
29#include <pcmcia/ds.h> 29#include <pcmcia/ds.h>
30 30
31struct snd_vxp_entry {
32 dev_info_t *dev_info;
33
34 /* module parameters */
35 int *index_table;
36 char **id_table;
37 int *enable_table;
38 int *ibl;
39
40 /* h/w config */
41 struct snd_vx_hardware *hardware;
42 struct snd_vx_ops *ops;
43
44 /* slots */
45 vx_core_t *card_list[SNDRV_CARDS];
46 dev_link_t *dev_list; /* Linked list of devices */
47};
48
49struct snd_vxpocket { 31struct snd_vxpocket {
50 32
51 vx_core_t core; 33 vx_core_t core;
@@ -57,8 +39,7 @@ struct snd_vxpocket {
57 unsigned int regCDSP; /* current CDSP register */ 39 unsigned int regCDSP; /* current CDSP register */
58 unsigned int regDIALOG; /* current DIALOG register */ 40 unsigned int regDIALOG; /* current DIALOG register */
59 41
60 int index; 42 int index; /* card index */
61 struct snd_vxp_entry *hw_entry;
62 43
63 /* pcmcia stuff */ 44 /* pcmcia stuff */
64 dev_link_t link; 45 dev_link_t link;
@@ -70,12 +51,6 @@ extern struct snd_vx_ops snd_vxpocket_ops;
70void vx_set_mic_boost(vx_core_t *chip, int boost); 51void vx_set_mic_boost(vx_core_t *chip, int boost);
71void vx_set_mic_level(vx_core_t *chip, int level); 52void vx_set_mic_level(vx_core_t *chip, int level);
72 53
73/*
74 * pcmcia stuff
75 */
76dev_link_t *snd_vxpocket_attach(struct snd_vxp_entry *hw);
77void snd_vxpocket_detach(struct snd_vxp_entry *hw, dev_link_t *link);
78
79int vxp_add_mic_controls(vx_core_t *chip); 54int vxp_add_mic_controls(vx_core_t *chip);
80 55
81/* Constants used to access the CDSP register (0x08). */ 56/* Constants used to access the CDSP register (0x08). */