blob: 3928c2802cc43bd974d3865631e533cc607636cc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Audio Command Interface (ACI) driver (sound/aci.c)
3 *
4 * ACI is a protocol used to communicate with the microcontroller on
5 * some sound cards produced by miro, e.g. the miroSOUND PCM12 and
6 * PCM20. The ACI has been developed for miro by Norberto Pellicci
7 * <pellicci@home.com>. Special thanks to both him and miro for
8 * providing the ACI specification.
9 *
10 * The main function of the ACI is to control the mixer and to get a
11 * product identification. On the PCM20, ACI also controls the radio
12 * tuner on this card, this is supported in the Video for Linux
13 * miropcm20 driver.
14 * -
15 * This is a fullfeatured implementation. Unsupported features
16 * are bugs... (:
17 *
18 * It is not longer necessary to load the mad16 module first. The
19 * user is currently responsible to set the mad16 mixer correctly.
20 *
21 * To toggle the solo mode for full duplex operation just use the OSS
22 * record switch for the pcm ('wave') controller. Robert
23 * -
24 *
25 * Revision history:
26 *
27 * 1995-11-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
28 * First version written.
29 * 1995-12-31 Markus Kuhn
30 * Second revision, general code cleanup.
31 * 1996-05-16 Hannu Savolainen
32 * Integrated with other parts of the driver.
33 * 1996-05-28 Markus Kuhn
34 * Initialize CS4231A mixer, make ACI first mixer,
35 * use new private mixer API for solo mode.
36 * 1998-08-18 Ruurd Reitsma <R.A.Reitsma@wbmt.tudelft.nl>
37 * Small modification to export ACI functions and
38 * complete modularisation.
39 * 2000-06-20 Robert Siemer <Robert.Siemer@gmx.de>
40 * Don't initialize the CS4231A mixer anymore, so the code is
41 * working again, and other small changes to fit in todays
42 * kernels.
43 * 2000-08-26 Robert Siemer
44 * Clean up and rewrite for 2.4.x. Maybe it's SMP safe now... (:
45 * ioctl bugfix, and integration of solo-mode into OSS-API,
46 * added (OSS-limited) equalizer support, return value bugfix,
47 * changed param aci_reset to reset, new params: ide, wss.
48 * 2001-04-20 Robert Siemer
49 * even more cleanups...
50 * 2001-10-08 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
51 * Get rid of check_region, .bss optimizations, use set_current_state
52 */
53
54#include <linux/kernel.h>
55#include <linux/init.h>
56#include <linux/module.h>
57#include <linux/proc_fs.h>
58#include <linux/slab.h>
59#include <asm/semaphore.h>
60#include <asm/io.h>
61#include <asm/uaccess.h>
62#include "sound_config.h"
63
64int aci_port; /* as determined by bit 4 in the OPTi 929 MC4 register */
65static int aci_idcode[2]; /* manufacturer and product ID */
66int aci_version; /* ACI firmware version */
67
68EXPORT_SYMBOL(aci_port);
69EXPORT_SYMBOL(aci_version);
70
71#include "aci.h"
72
73
74static int aci_solo; /* status bit of the card that can't be *
75 * checked with ACI versions prior to 0xb0 */
76static int aci_amp; /* status bit for power-amp/line-out level
77 but I have no docs about what is what... */
78static int aci_micpreamp=3; /* microphone preamp-level that can't be *
79 * checked with ACI versions prior to 0xb0 */
80
81static int mixer_device;
82static struct semaphore aci_sem;
83
84#ifdef MODULE
85static int reset;
86module_param(reset, bool, 0);
87MODULE_PARM_DESC(reset,"When set to 1, reset aci mixer.");
88#else
89static int reset = 1;
90#endif
91
92static int ide=-1;
93module_param(ide, int, 0);
94MODULE_PARM_DESC(ide,"1 enable, 0 disable ide-port - untested"
95 " default: do nothing");
96static int wss=-1;
97module_param(wss, int, 0);
98MODULE_PARM_DESC(wss,"change between ACI/WSS-mixer; use 0 and 1 - untested"
99 " default: do nothing; for PCM1-pro only");
100
101#ifdef DEBUG
102static void print_bits(unsigned char c)
103{
104 int j;
105 printk(KERN_DEBUG "aci: ");
106
107 for (j=7; j>=0; j--) {
108 printk("%d", (c >> j) & 0x1);
109 }
110
111 printk("\n");
112}
113#endif
114
115/*
116 * This busy wait code normally requires less than 15 loops and
117 * practically always less than 100 loops on my i486/DX2 66 MHz.
118 *
119 * Warning: Waiting on the general status flag after reseting the MUTE
120 * function can take a VERY long time, because the PCM12 does some kind
121 * of fade-in effect. For this reason, access to the MUTE function has
122 * not been implemented at all.
123 *
124 * - The OSS interface has no mute option. It takes about 3 seconds to
125 * fade-in on my PCM20. busy_wait() handles it great now... Robert
126 */
127
128static int busy_wait(void)
129{
130 #define MINTIME 500
131 long timeout;
132 unsigned char byte;
133
134 for (timeout = 1; timeout <= MINTIME+30; timeout++) {
135 if (((byte=inb(BUSY_REGISTER)) & 1) == 0) {
136 if (timeout >= MINTIME)
137 printk(KERN_DEBUG "aci: Got READYFLAG in round %ld.\n", timeout-MINTIME);
138 return byte;
139 }
140 if (timeout >= MINTIME) {
141 long out=10*HZ;
142 switch (timeout-MINTIME) {
143 case 0 ... 9:
144 out /= 10;
145 case 10 ... 19:
146 out /= 10;
147 case 20 ... 30:
148 out /= 10;
149 default:
150 set_current_state(TASK_UNINTERRUPTIBLE);
151 schedule_timeout(out);
152 break;
153 }
154 }
155 }
156 printk(KERN_WARNING "aci: busy_wait() time out.\n");
157 return -EBUSY;
158}
159
160/* The four ACI command types are fucked up. [-:
161 * implied is: 1w - special case for INIT
162 * write is: 2w1r
163 * read is: x(1w1r) where x is 1 or 2 (1 CHECK_SIG, 1 CHECK_STER,
164 * 1 VERSION, 2 IDCODE)
165 * the command is only in the first write, rest is protocol overhead
166 *
167 * indexed is technically a write and used for STATUS
168 * and the special case for TUNE is: 3w1r
169 *
170 * Here the new general sheme: TUNE --> aci_rw_cmd(x, y, z)
171 * indexed and write --> aci_rw_cmd(x, y, -1)
172 * implied and read (x=1) --> aci_rw_cmd(x, -1, -1)
173 *
174 * Read (x>=2) is not implemented (only used during initialization).
175 * Use aci_idcode[2] and aci_version... Robert
176 */
177
178/* Some notes for error detection: theoretically it is possible.
179 * But it doubles the I/O-traffic from ww(r) to wwwrw(r) in the normal
180 * case and doesn't seem to be designed for that... Robert
181 */
182
183static inline int aci_rawwrite(unsigned char byte)
184{
185 if (busy_wait() >= 0) {
186#ifdef DEBUG
187 printk(KERN_DEBUG "aci_rawwrite(%d)\n", byte);
188#endif
189 outb(byte, COMMAND_REGISTER);
190 return 0;
191 } else
192 return -EBUSY;
193}
194
195static inline int aci_rawread(void)
196{
197 unsigned char byte;
198
199 if (busy_wait() >= 0) {
200 byte=inb(STATUS_REGISTER);
201#ifdef DEBUG
202 printk(KERN_DEBUG "%d = aci_rawread()\n", byte);
203#endif
204 return byte;
205 } else
206 return -EBUSY;
207}
208
209
210int aci_rw_cmd(int write1, int write2, int write3)
211{
212 int write[] = {write1, write2, write3};
213 int read = -EINTR, i;
214
215 if (down_interruptible(&aci_sem))
216 goto out;
217
218 for (i=0; i<3; i++) {
219 if (write[i]< 0 || write[i] > 255)
220 break;
221 else {
222 read = aci_rawwrite(write[i]);
223 if (read < 0)
224 goto out_up;
225 }
226
227 }
228
229 read = aci_rawread();
230out_up: up(&aci_sem);
231out: return read;
232}
233
234EXPORT_SYMBOL(aci_rw_cmd);
235
236static int setvolume(int __user *arg,
237 unsigned char left_index, unsigned char right_index)
238{
239 int vol, ret, uservol, buf;
240
241 __get_user(uservol, arg);
242
243 /* left channel */
244 vol = uservol & 0xff;
245 if (vol > 100)
246 vol = 100;
247 vol = SCALE(100, 0x20, vol);
248 if ((buf=aci_write_cmd(left_index, 0x20 - vol))<0)
249 return buf;
250 ret = SCALE(0x20, 100, vol);
251
252
253 /* right channel */
254 vol = (uservol >> 8) & 0xff;
255 if (vol > 100)
256 vol = 100;
257 vol = SCALE(100, 0x20, vol);
258 if ((buf=aci_write_cmd(right_index, 0x20 - vol))<0)
259 return buf;
260 ret |= SCALE(0x20, 100, vol) << 8;
261
262 __put_user(ret, arg);
263
264 return 0;
265}
266
267static int getvolume(int __user *arg,
268 unsigned char left_index, unsigned char right_index)
269{
270 int vol;
271 int buf;
272
273 /* left channel */
274 if ((buf=aci_indexed_cmd(ACI_STATUS, left_index))<0)
275 return buf;
276 vol = SCALE(0x20, 100, buf < 0x20 ? 0x20-buf : 0);
277
278 /* right channel */
279 if ((buf=aci_indexed_cmd(ACI_STATUS, right_index))<0)
280 return buf;
281 vol |= SCALE(0x20, 100, buf < 0x20 ? 0x20-buf : 0) << 8;
282
283 __put_user(vol, arg);
284
285 return 0;
286}
287
288
289/* The equalizer is somewhat strange on the ACI. From -12dB to +12dB
290 * write: 0xff..down.to..0x80==0x00..up.to..0x7f
291 */
292
293static inline unsigned int eq_oss2aci(unsigned int vol)
294{
295 int boost=0;
296 unsigned int ret;
297
298 if (vol > 100)
299 vol = 100;
300 if (vol > 50) {
301 vol -= 51;
302 boost=1;
303 }
304 if (boost)
305 ret=SCALE(49, 0x7e, vol)+1;
306 else
307 ret=0xff - SCALE(50, 0x7f, vol);
308 return ret;
309}
310
311static inline unsigned int eq_aci2oss(unsigned int vol)
312{
313 if (vol < 0x80)
314 return SCALE(0x7f, 50, vol) + 50;
315 else
316 return SCALE(0x7f, 50, 0xff-vol);
317}
318
319
320static int setequalizer(int __user *arg,
321 unsigned char left_index, unsigned char right_index)
322{
323 int buf;
324 unsigned int vol;
325
326 __get_user(vol, arg);
327
328 /* left channel */
329 if ((buf=aci_write_cmd(left_index, eq_oss2aci(vol & 0xff)))<0)
330 return buf;
331
332 /* right channel */
333 if ((buf=aci_write_cmd(right_index, eq_oss2aci((vol>>8) & 0xff)))<0)
334 return buf;
335
336 /* the ACI equalizer is more precise */
337 return 0;
338}
339
340static int getequalizer(int __user *arg,
341 unsigned char left_index, unsigned char right_index)
342{
343 int buf;
344 unsigned int vol;
345
346 /* left channel */
347 if ((buf=aci_indexed_cmd(ACI_STATUS, left_index))<0)
348 return buf;
349 vol = eq_aci2oss(buf);
350
351 /* right channel */
352 if ((buf=aci_indexed_cmd(ACI_STATUS, right_index))<0)
353 return buf;
354 vol |= eq_aci2oss(buf) << 8;
355
356 __put_user(vol, arg);
357
358 return 0;
359}
360
361static int aci_mixer_ioctl (int dev, unsigned int cmd, void __user * arg)
362{
363 int vol, buf;
364 int __user *p = arg;
365
366 switch (cmd) {
367 case SOUND_MIXER_WRITE_VOLUME:
368 return setvolume(p, 0x01, 0x00);
369 case SOUND_MIXER_WRITE_CD:
370 return setvolume(p, 0x3c, 0x34);
371 case SOUND_MIXER_WRITE_MIC:
372 return setvolume(p, 0x38, 0x30);
373 case SOUND_MIXER_WRITE_LINE:
374 return setvolume(p, 0x39, 0x31);
375 case SOUND_MIXER_WRITE_SYNTH:
376 return setvolume(p, 0x3b, 0x33);
377 case SOUND_MIXER_WRITE_PCM:
378 return setvolume(p, 0x3a, 0x32);
379 case MIXER_WRITE(SOUND_MIXER_RADIO): /* fall through */
380 case SOUND_MIXER_WRITE_LINE1: /* AUX1 or radio */
381 return setvolume(p, 0x3d, 0x35);
382 case SOUND_MIXER_WRITE_LINE2: /* AUX2 */
383 return setvolume(p, 0x3e, 0x36);
384 case SOUND_MIXER_WRITE_BASS: /* set band one and two */
385 if (aci_idcode[1]=='C') {
386 if ((buf=setequalizer(p, 0x48, 0x40)) ||
387 (buf=setequalizer(p, 0x49, 0x41)));
388 return buf;
389 }
390 break;
391 case SOUND_MIXER_WRITE_TREBLE: /* set band six and seven */
392 if (aci_idcode[1]=='C') {
393 if ((buf=setequalizer(p, 0x4d, 0x45)) ||
394 (buf=setequalizer(p, 0x4e, 0x46)));
395 return buf;
396 }
397 break;
398 case SOUND_MIXER_WRITE_IGAIN: /* MIC pre-amp */
399 if (aci_idcode[1]=='B' || aci_idcode[1]=='C') {
400 __get_user(vol, p);
401 vol = vol & 0xff;
402 if (vol > 100)
403 vol = 100;
404 vol = SCALE(100, 3, vol);
405 if ((buf=aci_write_cmd(ACI_WRITE_IGAIN, vol))<0)
406 return buf;
407 aci_micpreamp = vol;
408 vol = SCALE(3, 100, vol);
409 vol |= (vol << 8);
410 __put_user(vol, p);
411 return 0;
412 }
413 break;
414 case SOUND_MIXER_WRITE_OGAIN: /* Power-amp/line-out level */
415 if (aci_idcode[1]=='A' || aci_idcode[1]=='B') {
416 __get_user(buf, p);
417 buf = buf & 0xff;
418 if (buf > 50)
419 vol = 1;
420 else
421 vol = 0;
422 if ((buf=aci_write_cmd(ACI_SET_POWERAMP, vol))<0)
423 return buf;
424 aci_amp = vol;
425 if (aci_amp)
426 buf = (100 || 100<<8);
427 else
428 buf = 0;
429 __put_user(buf, p);
430 return 0;
431 }
432 break;
433 case SOUND_MIXER_WRITE_RECSRC:
434 /* handle solo mode control */
435 __get_user(buf, p);
436 /* unset solo when RECSRC for PCM is requested */
437 if (aci_idcode[1]=='B' || aci_idcode[1]=='C') {
438 vol = !(buf & SOUND_MASK_PCM);
439 if ((buf=aci_write_cmd(ACI_SET_SOLOMODE, vol))<0)
440 return buf;
441 aci_solo = vol;
442 }
443 buf = (SOUND_MASK_CD| SOUND_MASK_MIC| SOUND_MASK_LINE|
444 SOUND_MASK_SYNTH| SOUND_MASK_LINE2);
445 if (aci_idcode[1] == 'C') /* PCM20 radio */
446 buf |= SOUND_MASK_RADIO;
447 else
448 buf |= SOUND_MASK_LINE1;
449 if (!aci_solo)
450 buf |= SOUND_MASK_PCM;
451 __put_user(buf, p);
452 return 0;
453 case SOUND_MIXER_READ_DEVMASK:
454 buf = (SOUND_MASK_VOLUME | SOUND_MASK_CD |
455 SOUND_MASK_MIC | SOUND_MASK_LINE |
456 SOUND_MASK_SYNTH | SOUND_MASK_PCM |
457 SOUND_MASK_LINE2);
458 switch (aci_idcode[1]) {
459 case 'C': /* PCM20 radio */
460 buf |= (SOUND_MASK_RADIO | SOUND_MASK_IGAIN |
461 SOUND_MASK_BASS | SOUND_MASK_TREBLE);
462 break;
463 case 'B': /* PCM12 */
464 buf |= (SOUND_MASK_LINE1 | SOUND_MASK_IGAIN |
465 SOUND_MASK_OGAIN);
466 break;
467 case 'A': /* PCM1-pro */
468 buf |= (SOUND_MASK_LINE1 | SOUND_MASK_OGAIN);
469 break;
470 default:
471 buf |= SOUND_MASK_LINE1;
472 }
473 __put_user(buf, p);
474 return 0;
475 case SOUND_MIXER_READ_STEREODEVS:
476 buf = (SOUND_MASK_VOLUME | SOUND_MASK_CD |
477 SOUND_MASK_MIC | SOUND_MASK_LINE |
478 SOUND_MASK_SYNTH | SOUND_MASK_PCM |
479 SOUND_MASK_LINE2);
480 switch (aci_idcode[1]) {
481 case 'C': /* PCM20 radio */
482 buf |= (SOUND_MASK_RADIO |
483 SOUND_MASK_BASS | SOUND_MASK_TREBLE);
484 break;
485 default:
486 buf |= SOUND_MASK_LINE1;
487 }
488 __put_user(buf, p);
489 return 0;
490 case SOUND_MIXER_READ_RECMASK:
491 buf = (SOUND_MASK_CD| SOUND_MASK_MIC| SOUND_MASK_LINE|
492 SOUND_MASK_SYNTH| SOUND_MASK_LINE2| SOUND_MASK_PCM);
493 if (aci_idcode[1] == 'C') /* PCM20 radio */
494 buf |= SOUND_MASK_RADIO;
495 else
496 buf |= SOUND_MASK_LINE1;
497
498 __put_user(buf, p);
499 return 0;
500 case SOUND_MIXER_READ_RECSRC:
501 buf = (SOUND_MASK_CD | SOUND_MASK_MIC | SOUND_MASK_LINE |
502 SOUND_MASK_SYNTH | SOUND_MASK_LINE2);
503 /* do we need aci_solo or can I get it from the ACI? */
504 switch (aci_idcode[1]) {
505 case 'B': /* PCM12 */
506 case 'C': /* PCM20 radio */
507 if (aci_version >= 0xb0) {
508 if ((vol=aci_rw_cmd(ACI_STATUS,
509 ACI_S_GENERAL, -1))<0)
510 return vol;
511 if (vol & 0x20)
512 buf |= SOUND_MASK_PCM;
513 }
514 else
515 if (!aci_solo)
516 buf |= SOUND_MASK_PCM;
517 break;
518 default:
519 buf |= SOUND_MASK_PCM;
520 }
521 if (aci_idcode[1] == 'C') /* PCM20 radio */
522 buf |= SOUND_MASK_RADIO;
523 else
524 buf |= SOUND_MASK_LINE1;
525
526 __put_user(buf, p);
527 return 0;
528 case SOUND_MIXER_READ_CAPS:
529 __put_user(0, p);
530 return 0;
531 case SOUND_MIXER_READ_VOLUME:
532 return getvolume(p, 0x04, 0x03);
533 case SOUND_MIXER_READ_CD:
534 return getvolume(p, 0x0a, 0x09);
535 case SOUND_MIXER_READ_MIC:
536 return getvolume(p, 0x06, 0x05);
537 case SOUND_MIXER_READ_LINE:
538 return getvolume(p, 0x08, 0x07);
539 case SOUND_MIXER_READ_SYNTH:
540 return getvolume(p, 0x0c, 0x0b);
541 case SOUND_MIXER_READ_PCM:
542 return getvolume(p, 0x0e, 0x0d);
543 case MIXER_READ(SOUND_MIXER_RADIO): /* fall through */
544 case SOUND_MIXER_READ_LINE1: /* AUX1 */
545 return getvolume(p, 0x11, 0x10);
546 case SOUND_MIXER_READ_LINE2: /* AUX2 */
547 return getvolume(p, 0x13, 0x12);
548 case SOUND_MIXER_READ_BASS: /* get band one */
549 if (aci_idcode[1]=='C') {
550 return getequalizer(p, 0x23, 0x22);
551 }
552 break;
553 case SOUND_MIXER_READ_TREBLE: /* get band seven */
554 if (aci_idcode[1]=='C') {
555 return getequalizer(p, 0x2f, 0x2e);
556 }
557 break;
558 case SOUND_MIXER_READ_IGAIN: /* MIC pre-amp */
559 if (aci_idcode[1]=='B' || aci_idcode[1]=='C') {
560 /* aci_micpreamp or ACI? */
561 if (aci_version >= 0xb0) {
562 if ((buf=aci_indexed_cmd(ACI_STATUS,
563 ACI_S_READ_IGAIN))<0)
564 return buf;
565 }
566 else
567 buf=aci_micpreamp;
568 vol = SCALE(3, 100, buf <= 3 ? buf : 3);
569 vol |= vol << 8;
570 __put_user(vol, p);
571 return 0;
572 }
573 break;
574 case SOUND_MIXER_READ_OGAIN:
575 if (aci_amp)
576 buf = (100 || 100<<8);
577 else
578 buf = 0;
579 __put_user(buf, p);
580 return 0;
581 }
582 return -EINVAL;
583}
584
585static struct mixer_operations aci_mixer_operations =
586{
587 .owner = THIS_MODULE,
588 .id = "ACI",
589 .ioctl = aci_mixer_ioctl
590};
591
592/*
593 * There is also an internal mixer in the codec (CS4231A or AD1845),
594 * that deserves no purpose in an ACI based system which uses an
595 * external ACI controlled stereo mixer. Make sure that this codec
596 * mixer has the AUX1 input selected as the recording source, that the
597 * input gain is set near maximum and that the other channels going
598 * from the inputs to the codec output are muted.
599 */
600
601static int __init attach_aci(void)
602{
603 char *boardname;
604 int i, rc = -EBUSY;
605
606 init_MUTEX(&aci_sem);
607
608 outb(0xE3, 0xf8f); /* Write MAD16 password */
609 aci_port = (inb(0xf90) & 0x10) ?
610 0x344: 0x354; /* Get aci_port from MC4_PORT */
611
612 if (!request_region(aci_port, 3, "sound mixer (ACI)")) {
613 printk(KERN_NOTICE
614 "aci: I/O area 0x%03x-0x%03x already used.\n",
615 aci_port, aci_port+2);
616 goto out;
617 }
618
619 /* force ACI into a known state */
620 rc = -EFAULT;
621 for (i=0; i<3; i++)
622 if (aci_rw_cmd(ACI_ERROR_OP, -1, -1)<0)
623 goto out_release_region;
624
625 /* official this is one aci read call: */
626 rc = -EFAULT;
627 if ((aci_idcode[0]=aci_rw_cmd(ACI_READ_IDCODE, -1, -1))<0 ||
628 (aci_idcode[1]=aci_rw_cmd(ACI_READ_IDCODE, -1, -1))<0) {
629 printk(KERN_ERR "aci: Failed to read idcode on 0x%03x.\n",
630 aci_port);
631 goto out_release_region;
632 }
633
634 if ((aci_version=aci_rw_cmd(ACI_READ_VERSION, -1, -1))<0) {
635 printk(KERN_ERR "aci: Failed to read version on 0x%03x.\n",
636 aci_port);
637 goto out_release_region;
638 }
639
640 if (aci_idcode[0] == 'm') {
641 /* It looks like a miro sound card. */
642 switch (aci_idcode[1]) {
643 case 'A':
644 boardname = "PCM1 pro / early PCM12";
645 break;
646 case 'B':
647 boardname = "PCM12";
648 break;
649 case 'C':
650 boardname = "PCM20 radio";
651 break;
652 default:
653 boardname = "unknown miro";
654 }
655 } else {
656 printk(KERN_WARNING "aci: Warning: unsupported card! - "
657 "no hardware, no specs...\n");
658 boardname = "unknown Cardinal Technologies";
659 }
660
661 printk(KERN_INFO "<ACI 0x%02x, id %02x/%02x \"%c/%c\", (%s)> at 0x%03x\n",
662 aci_version,
663 aci_idcode[0], aci_idcode[1],
664 aci_idcode[0], aci_idcode[1],
665 boardname, aci_port);
666
667 rc = -EBUSY;
668 if (reset) {
669 /* first write()s after reset fail with my PCM20 */
670 if (aci_rw_cmd(ACI_INIT, -1, -1)<0 ||
671 aci_rw_cmd(ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP)<0 ||
672 aci_rw_cmd(ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP)<0)
673 goto out_release_region;
674 }
675
676 /* the PCM20 is muted after reset (and reboot) */
677 if (aci_rw_cmd(ACI_SET_MUTE, 0x00, -1)<0)
678 goto out_release_region;
679
680 if (ide>=0)
681 if (aci_rw_cmd(ACI_SET_IDE, !ide, -1)<0)
682 goto out_release_region;
683
684 if (wss>=0 && aci_idcode[1]=='A')
685 if (aci_rw_cmd(ACI_SET_WSS, !!wss, -1)<0)
686 goto out_release_region;
687
688 mixer_device = sound_install_mixer(MIXER_DRIVER_VERSION, boardname,
689 &aci_mixer_operations,
690 sizeof(aci_mixer_operations), NULL);
691 rc = 0;
692 if (mixer_device < 0) {
693 printk(KERN_ERR "aci: Failed to install mixer.\n");
694 rc = mixer_device;
695 goto out_release_region;
696 } /* else Maybe initialize the CS4231A mixer here... */
697out: return rc;
698out_release_region:
699 release_region(aci_port, 3);
700 goto out;
701}
702
703static void __exit unload_aci(void)
704{
705 sound_unload_mixerdev(mixer_device);
706 release_region(aci_port, 3);
707}
708
709module_init(attach_aci);
710module_exit(unload_aci);
711MODULE_LICENSE("GPL");