2 * drivers/sound/waveartist.c
4 * The low level driver for the RWA010 Rockwell Wave Artist
5 * codec chip used in the Corel Computer NetWinder.
7 * Cleaned up and integrated into 2.1 by Russell King (rmk@arm.linux.org.uk)
11 * Copyright (C) by Corel Computer 1998
13 * RWA010 specs received under NDA from Rockwell
15 * Copyright (C) by Hannu Savolainen 1993-1997
17 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
18 * Version 2 (June 1991). See the "COPYING" file distributed with this software
27 #define DEBUG_MIXER 16
28 #define DEBUG_TRIGGER 32
36 #include <linux/module.h>
37 #include <linux/config.h>
38 #include <linux/sched.h>
39 #include <linux/interrupt.h>
40 #include <linux/delay.h>
41 #include <linux/smp.h>
43 #include <asm/dec21285.h>
44 #include <asm/hardware.h>
46 #include "soundmodule.h"
47 #include "sound_config.h"
48 #include "waveartist.h"
51 #define _ISA_DMA(x) (x)
54 #define _ISA_IRQ(x) (x)
57 #define VNC_TIMER_PERIOD (HZ/4) //check slider 4 times/sec
59 #define MIXER_PRIVATE3_RESET 0x53570000
60 #define MIXER_PRIVATE3_READ 0x53570001
61 #define MIXER_PRIVATE3_WRITE 0x53570002
63 #define VNC_INTERNAL_SPKR 0x01 //the sw mute on/off control bit
64 #define VNC_INTERNAL_MIC 0x10 //the hw internal/handset mic bit
66 /* Use RECSRC = speaker to mark the internal microphone
68 * Some cheating involved here: there is no way to relay
69 * to the system, which microphone in in use
70 * (left = handset, or right = internal)
72 * So while I do not flag SPEAKER in the Recording Devices
73 * Mask, when on internal
75 * mike - I set the speaker bit hi. Some mixers can be
79 #define POSSIBLE_RECORDING_DEVICES (SOUND_MASK_LINE |\
81 SOUND_MASK_LINE1) //Line1 = analog phone
83 #define SUPPORTED_MIXER_DEVICES (SOUND_MASK_SYNTH |\
91 static unsigned short levels
[SOUND_MIXER_NRDEVICES
] = {
92 0x5555, /* Master Volume */
95 0x5555, /* Synth (FM) */
97 0x0000, /* PC Speaker */
98 0x0000, /* Ext Line */
101 0x0000, /* Recording monitor */
102 0x0000, /* SB PCM (ALT PCM) */
103 0x0000, /* Recording level */
104 0x0000, /* Input gain */
105 0x0000, /* Output gain */
106 0x0000, /* Line1 (Aux1) */
107 0x0000, /* Line2 (Aux2) */
108 0x0000, /* Line3 (Aux3) */
109 0x0000, /* Digital1 */
110 0x0000, /* Digital2 */
111 0x0000, /* Digital3 */
112 0x0000, /* Phone In */
113 0x0000, /* Phone Out */
120 struct address_info hw
; /* hardware */
131 /* Mixer parameters */
132 unsigned short *levels
;
134 signed int slider_vol
; /* hardware slider volume */
135 int recmask
; /* currently enabled recording device! */
136 int supported_devices
; /* SUPPORTED_MIXER_DEVICES */
137 int rec_devices
; /* POSSIBLE_RECORDING_DEVICES */
138 int handset_mute_sw
:1;/* 1 - handset controlled in sw */
139 int use_slider
:1;/* use slider setting for o/p vol */
143 typedef struct wavnc_port_info
{
150 static int nr_waveartist_devs
;
151 static wavnc_info adev_info
[MAX_AUDIO_DEV
];
153 static int waveartist_mixer_set(wavnc_info
*devc
, int whichDev
, unsigned int level
);
156 * Corel Netwinder specifics...
158 static struct timer_list vnc_timer
;
159 extern spinlock_t gpio_lock
;
162 vnc_mute(wavnc_info
*devc
, int mute
)
166 spin_lock_irqsave(&gpio_lock
, flags
);
167 cpld_modify(CPLD_UNMUTE
, mute
? 0 : CPLD_UNMUTE
);
168 spin_unlock_irqrestore(&gpio_lock
, flags
);
170 devc
->mute_state
= mute
;
174 vnc_volume_slider(wavnc_info
*devc
)
176 static signed int old_slider_volume
;
178 signed int volume
= 255;
180 *CSR_TIMER1_LOAD
= 0x00ffffff;
186 *CSR_TIMER1_CNTL
= TIMER_CNTL_ENABLE
| TIMER_CNTL_DIV1
;
188 while (volume
&& (inb(0x201) & 0x01))
191 *CSR_TIMER1_CNTL
= 0;
193 restore_flags(flags
);
195 volume
= 0x00ffffff - *CSR_TIMER1_VALUE
;
199 volume
= 150 - (volume
>> 5);
201 volume
= (volume
>> 6) - 25;
211 * slider quite often reads +-8, so debounce this random noise
213 if ((volume
- old_slider_volume
) > 7 ||
214 (old_slider_volume
- volume
) > 7) {
215 old_slider_volume
= volume
;
217 DEB(printk("Slider volume: %d.\n", old_slider_volume
));
220 return old_slider_volume
;
224 vnc_slider(wavnc_info
*devc
)
226 signed int slider_volume
;
230 * read the "buttons" state.
231 * Bit 4 = handset present,
234 // the state should be "querable" via a private IOCTL call
235 temp
= inb(0x201) & 0x30;
237 if (!devc
->handset_mute_sw
&&
238 (temp
^ devc
->handset_state
) & VNC_INTERNAL_MIC
) {
239 devc
->handset_state
= temp
;
240 devc
->handset_mute_sw
= 0;
242 vnc_mute(devc
, (temp
& VNC_INTERNAL_MIC
) ? 1 : 0);
245 slider_volume
= vnc_volume_slider(devc
);
248 * If we're using software controlled volume, and
249 * the slider moves by more than 20%, then we
250 * switch back to slider controlled volume.
252 if (devc
->slider_vol
> slider_volume
) {
253 if (devc
->slider_vol
- slider_volume
> 20)
254 devc
->use_slider
= 1;
256 if (slider_volume
- devc
->slider_vol
> 20)
257 devc
->use_slider
= 1;
261 * use only left channel
263 temp
= levels
[SOUND_MIXER_VOLUME
] & 0xFF;
265 if (slider_volume
!= temp
&& devc
->use_slider
) {
266 devc
->slider_vol
= slider_volume
;
268 waveartist_mixer_set(devc
, SOUND_MIXER_VOLUME
,
269 slider_volume
| slider_volume
<< 8);
278 vnc_slider_tick(unsigned long data
)
282 if (vnc_slider(adev_info
+ data
))
283 next_timeout
= 5; // mixer reported change
285 next_timeout
= VNC_TIMER_PERIOD
;
287 mod_timer(&vnc_timer
, jiffies
+ next_timeout
);
291 vnc_private_ioctl(int dev
, unsigned int cmd
, caddr_t arg
)
293 wavnc_info
*devc
= (wavnc_info
*)audio_devs
[dev
]->devc
;
296 if (cmd
== SOUND_MIXER_PRIVATE1
) {
298 * Use this call to override the automatic handset
299 * behaviour - ignore handset.
300 * bit 7 = total control over handset - do not
302 * bit 4 = internal mic
303 * bit 0 = mute internal speaker
305 if (get_user(val
, (int *)arg
))
308 devc
->handset_mute_sw
= val
;
310 temp
= val
& VNC_INTERNAL_SPKR
;
311 if (devc
->mute_state
!= temp
)
312 vnc_mute(devc
, temp
);
314 devc
->handset_state
= val
& VNC_INTERNAL_MIC
;
315 waveartist_mixer_set(devc
, SOUND_MIXER_RECSRC
, SOUND_MASK_MIC
);
319 if (cmd
== SOUND_MIXER_PRIVATE2
) {
320 #define VNC_SOUND_PAUSE 0x53 //to pause the DSP
321 #define VNC_SOUND_RESUME 0x57 //to unpause the DSP
326 printk("MIXER_PRIVATE2: passed parameter = 0x%X.\n",val
);
328 if (val
== VNC_SOUND_PAUSE
) {
329 wa_sendcmd(0x16); //PAUSE the ADC
330 } else if (val
== VNC_SOUND_RESUME
) {
331 wa_sendcmd(0x18); //RESUME the ADC
333 return -EINVAL
; //invalid parameters...
338 if (cmd
== SOUND_MIXER_PRIVATE3
) {
340 int mixer_reg
[15]; //reg 14 is actually a command: read,write,reset
347 if (verify_area(VERIFY_READ
, (void *) val
, sizeof(mixer_reg
) == -EFAULT
))
350 memcpy_fromfs(&mixer_reg
, (void *) val
, sizeof(mixer_reg
));
352 if (mixer_reg
[0x0E] == MIXER_PRIVATE3_RESET
) { //reset command??
353 wavnc_mixer_reset(devc
);
355 } else if (mixer_reg
[0x0E] == MIXER_PRIVATE3_WRITE
) { //write command??
356 // printk("WaveArtist Mixer: Private write command.\n");
358 wa_sendcmd(0x32); //Pair1 - word 1 and 5
359 wa_sendcmd(mixer_reg
[0]);
360 wa_sendcmd(mixer_reg
[4]);
362 wa_sendcmd(0x32); //Pair2 - word 2 and 6
363 wa_sendcmd(mixer_reg
[1]);
364 wa_sendcmd(mixer_reg
[5]);
366 wa_sendcmd(0x32); //Pair3 - word 3 and 7
367 wa_sendcmd(mixer_reg
[2]);
368 wa_sendcmd(mixer_reg
[6]);
370 wa_sendcmd(0x32); //Pair4 - word 4 and 8
371 wa_sendcmd(mixer_reg
[3]);
372 wa_sendcmd(mixer_reg
[7]);
374 wa_sendcmd(0x32); //Pair5 - word 9 and 10
375 wa_sendcmd(mixer_reg
[8]);
376 wa_sendcmd(mixer_reg
[9]);
378 wa_sendcmd(0x0031); //set left and right PCM
379 wa_sendcmd(mixer_reg
[0x0A]);
380 wa_sendcmd(mixer_reg
[0x0B]);
382 wa_sendcmd(0x0131); //set left and right FM
383 wa_sendcmd(mixer_reg
[0x0C]);
384 wa_sendcmd(mixer_reg
[0x0D]);
387 } else if (mixer_reg
[0x0E] == MIXER_PRIVATE3_READ
) { //read command?
388 // printk("WaveArtist Mixer: Private read command.\n");
390 //first read all current values...
394 for (i
= 0; i
< 14; i
++) {
395 wa_sendcmd((i
<< 8) + 0x30); // get ready for command nn30H
397 while (!(inb(STATR
) & CMD_RF
)) {
398 }; //wait for response ready...
400 mixer_reg
[i
] = inw(CMDR
);
402 restore_flags(flags
);
404 if (verify_area(VERIFY_WRITE
, (void *) val
, sizeof(mixer_reg
) == -EFAULT
))
407 memcpy_tofs((void *) val
, &mixer_reg
, sizeof(mixer_reg
));
417 waveartist_set_ctlr(struct address_info
*hw
, unsigned char clear
, unsigned char set
)
419 unsigned int ctlr_port
= hw
->io_base
+ CTLR
;
421 clear
= ~clear
& inb(ctlr_port
);
423 outb(clear
| set
, ctlr_port
);
426 /* Toggle IRQ acknowledge line
429 waveartist_iack(wavnc_info
*devc
)
431 unsigned int ctlr_port
= devc
->hw
.io_base
+ CTLR
;
434 old_ctlr
= inb(ctlr_port
) & ~IRQ_ACK
;
436 outb(old_ctlr
| IRQ_ACK
, ctlr_port
);
437 outb(old_ctlr
, ctlr_port
);
441 waveartist_sleep(int timeout_ms
)
443 unsigned int timeout
= timeout_ms
* 10 * HZ
/ 100;
446 current
->state
= TASK_INTERRUPTIBLE
;
447 timeout
= schedule_timeout(timeout
);
454 waveartist_reset(wavnc_info
*devc
)
456 struct address_info
*hw
= &devc
->hw
;
457 unsigned int timeout
, res
= -1;
459 waveartist_set_ctlr(hw
, -1, RESET
);
461 waveartist_set_ctlr(hw
, RESET
, 0);
467 if (inb(hw
->io_base
+ STATR
) & CMD_RF
) {
468 res
= inw(hw
->io_base
+ CMDR
);
475 printk("WaveArtist: reset timeout ");
476 if (res
!= (unsigned int)-1)
477 printk("(res=%04X)", res
);
485 waveartist_cmd(wavnc_info
*devc
,
486 int nr_cmd
, unsigned int *cmd
,
487 int nr_resp
, unsigned int *resp
)
489 unsigned int io_base
= devc
->hw
.io_base
;
490 unsigned int timed_out
= 0;
493 if (debug_flg
& DEBUG_CMD
) {
494 printk("waveartist_cmd: cmd=");
496 for (i
= 0; i
< nr_cmd
; i
++)
497 printk("%04X ", cmd
[i
]);
502 if (inb(io_base
+ STATR
) & CMD_RF
) {
508 old_data
= inw(io_base
+ CMDR
);
510 if (debug_flg
& DEBUG_CMD
)
511 printk("flushed %04X...", old_data
);
516 for (i
= 0; !timed_out
&& i
< nr_cmd
; i
++) {
519 for (count
= 5000; count
; count
--)
520 if (inb(io_base
+ STATR
) & CMD_WE
)
526 outw(cmd
[i
], io_base
+ CMDR
);
529 for (i
= 0; !timed_out
&& i
< nr_resp
; i
++) {
532 for (count
= 5000; count
; count
--)
533 if (inb(io_base
+ STATR
) & CMD_RF
)
539 resp
[i
] = inw(io_base
+ CMDR
);
542 if (debug_flg
& DEBUG_CMD
) {
544 printk("waveartist_cmd: resp=");
546 for (i
= 0; i
< nr_resp
; i
++)
547 printk("%04X ", resp
[i
]);
551 printk("waveartist_cmd: timed out\n");
554 return timed_out
? 1 : 0;
558 waveartist_cmd2(wavnc_info
*devc
, unsigned int cmd
, unsigned int arg
)
560 unsigned int vals
[2];
565 waveartist_cmd(devc
, 2, vals
, 1, vals
);
571 waveartist_cmd3(wavnc_info
*devc
, unsigned int cmd
,
572 unsigned int arg1
, unsigned int arg2
)
574 unsigned int vals
[3];
580 return waveartist_cmd(devc
, 3, vals
, 0, NULL
);
584 waveartist_sendcmd(struct address_info
*hw
, unsigned int cmd
)
588 if (debug_flg
& DEBUG_CMD
)
589 printk("waveartist_sendcmd: cmd=0x%04X...", cmd
);
593 if (inb(hw
->io_base
+ STATR
) & CMD_RF
) {
597 count
= inw(hw
->io_base
+ CMDR
);
601 if (debug_flg
& DEBUG_CMD
)
602 printk(" flushed %04X...", count
);
606 * preset timeout at 5000 loops
611 if (inb(hw
->io_base
+ STATR
) & CMD_WE
) {
612 /* wait till CMD_WE is high
613 * then output the command
615 outw(cmd
, hw
->io_base
+ CMDR
);
619 /* ready BEFORE timeout?
621 if (debug_flg
& DEBUG_CMD
)
622 printk(" %s\n", count
? "Done OK." : "Error!");
626 return count
? 0 : 1;
630 waveartist_getrev(struct address_info
*hw
, char *rev
)
634 waveartist_sendcmd(hw
, 0);
636 temp
= inw(hw
->io_base
+ CMDR
);
638 inw(hw
->io_base
+ CMDR
); // discard second word == 0
648 waveartist_mute(wavnc_info
*devc
, int mute
)
652 static void waveartist_halt_output(int dev
);
653 static void waveartist_halt_input(int dev
);
654 static void waveartist_halt(int dev
);
655 static void waveartist_trigger(int dev
, int state
);
658 waveartist_open(int dev
, int mode
)
661 wavnc_port_info
*portc
;
664 if (dev
< 0 || dev
>= num_audiodevs
)
667 devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
668 portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
672 if (portc
->open_mode
|| (devc
->open_mode
& mode
)) {
673 restore_flags(flags
);
677 devc
->audio_mode
= 0;
678 devc
->open_mode
|= mode
;
679 portc
->open_mode
= mode
;
680 waveartist_trigger(dev
, 0);
682 if (mode
& OPEN_READ
)
683 devc
->record_dev
= dev
;
684 if (mode
& OPEN_WRITE
)
685 devc
->playback_dev
= dev
;
686 restore_flags(flags
);
689 * Mute output until the playback really starts. This
690 * decreases clicking (hope so).
692 waveartist_mute(devc
, 1);
698 waveartist_close(int dev
)
700 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
701 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
707 waveartist_halt(dev
);
709 devc
->audio_mode
= 0;
710 devc
->open_mode
&= ~portc
->open_mode
;
711 portc
->open_mode
= 0;
713 waveartist_mute(devc
, 1);
715 restore_flags(flags
);
719 waveartist_output_block(int dev
, unsigned long buf
, int __count
, int intrflag
)
721 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
722 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
724 unsigned int count
= __count
;
726 if (debug_flg
& DEBUG_OUT
)
727 printk("waveartist: output block, buf=0x%lx, count=0x%x...\n",
732 if (portc
->audio_format
& (AFMT_S16_LE
| AFMT_S16_BE
))
735 if (portc
->channels
> 1)
740 if (devc
->audio_mode
& PCM_ENABLE_OUTPUT
&&
741 audio_devs
[dev
]->flags
& DMA_AUTOMODE
&&
743 count
== devc
->xfer_count
) {
744 devc
->audio_mode
|= PCM_ENABLE_OUTPUT
;
746 * Auto DMA mode on. No need to react
756 waveartist_cmd2(devc
, 0x0024, count
);
758 devc
->xfer_count
= count
;
759 devc
->audio_mode
|= PCM_ENABLE_OUTPUT
;
761 restore_flags(flags
);
765 waveartist_start_input(int dev
, unsigned long buf
, int __count
, int intrflag
)
767 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
768 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
770 unsigned int count
= __count
;
772 if (debug_flg
& DEBUG_IN
)
773 printk("waveartist: start input, buf=0x%lx, count=0x%x...\n",
776 if (portc
->audio_format
& (AFMT_S16_LE
| AFMT_S16_BE
)) /* 16 bit data */
779 if (portc
->channels
> 1)
784 if (devc
->audio_mode
& PCM_ENABLE_INPUT
&&
785 audio_devs
[dev
]->flags
& DMA_AUTOMODE
&&
787 count
== devc
->xfer_count
) {
788 devc
->audio_mode
|= PCM_ENABLE_INPUT
;
790 * Auto DMA mode on. No need to react
800 waveartist_cmd2(devc
, 0x0014, count
);
801 waveartist_mute(devc
, 0);
803 devc
->xfer_count
= count
;
804 devc
->audio_mode
|= PCM_ENABLE_INPUT
;
806 restore_flags(flags
);
810 waveartist_ioctl(int dev
, unsigned int cmd
, caddr_t arg
)
816 waveartist_get_speed(wavnc_port_info
*portc
)
821 * program the speed, channels, bits
823 if (portc
->speed
== 8000)
825 else if (portc
->speed
== 11025)
827 else if (portc
->speed
== 22050)
829 else if (portc
->speed
== 44100)
833 * non-standard - just calculate
835 speed
= portc
->speed
<< 16;
837 speed
= (speed
/ 44100) & 65535;
844 waveartist_get_bits(wavnc_port_info
*portc
)
848 if (portc
->audio_format
== AFMT_S16_LE
)
850 else if (portc
->audio_format
== AFMT_S8
)
853 bits
= 2; //default AFMT_U8
859 waveartist_prepare_for_input(int dev
, int bsize
, int bcount
)
862 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
863 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
864 unsigned int speed
, bits
;
866 if (devc
->audio_mode
)
869 speed
= waveartist_get_speed(portc
);
870 bits
= waveartist_get_bits(portc
);
875 if (waveartist_cmd2(devc
, WACMD_INPUTFORMAT
, bits
))
876 printk("waveartist: error setting the record format to %d\n",
877 portc
->audio_format
);
879 if (waveartist_cmd2(devc
, WACMD_INPUTCHANNELS
, portc
->channels
))
880 printk("waveartist: error setting record to %d channels\n",
884 * write cmd SetSampleSpeedTimeConstant
886 if (waveartist_cmd2(devc
, WACMD_INPUTSPEED
, speed
))
887 printk("waveartist: error setting the record speed "
888 "to %dHz.\n", portc
->speed
);
890 if (waveartist_cmd2(devc
, WACMD_INPUTDMA
, 1))
891 printk("waveartist: error setting the record data path "
894 if (waveartist_cmd2(devc
, WACMD_INPUTFORMAT
, bits
))
895 printk("waveartist: error setting the record format to %d\n",
896 portc
->audio_format
);
898 devc
->xfer_count
= 0;
899 restore_flags(flags
);
900 waveartist_halt_input(dev
);
902 if (debug_flg
& DEBUG_INTR
) {
903 printk("WA CTLR reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ CTLR
));
904 printk("WA STAT reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ STATR
));
905 printk("WA IRQS reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ IRQSTAT
));
912 waveartist_prepare_for_output(int dev
, int bsize
, int bcount
)
915 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
916 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
917 unsigned int speed
, bits
;
920 * program the speed, channels, bits
922 speed
= waveartist_get_speed(portc
);
923 bits
= waveartist_get_bits(portc
);
928 if (waveartist_cmd2(devc
, WACMD_OUTPUTSPEED
, speed
) &&
929 waveartist_cmd2(devc
, WACMD_OUTPUTSPEED
, speed
))
930 printk("waveartist: error setting the playback speed "
931 "to %dHz.\n", portc
->speed
);
933 if (waveartist_cmd2(devc
, WACMD_OUTPUTCHANNELS
, portc
->channels
))
934 printk("waveartist: error setting the playback to"
935 " %d channels\n", portc
->channels
);
937 if (waveartist_cmd2(devc
, WACMD_OUTPUTDMA
, 0))
938 printk("waveartist: error setting the playback data path "
941 if (waveartist_cmd2(devc
, WACMD_OUTPUTFORMAT
, bits
))
942 printk("waveartist: error setting the playback format to %d\n",
943 portc
->audio_format
);
945 devc
->xfer_count
= 0;
946 restore_flags(flags
);
947 waveartist_halt_output(dev
);
949 if (debug_flg
& DEBUG_INTR
) {
950 printk("WA CTLR reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ CTLR
));
951 printk("WA STAT reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ STATR
));
952 printk("WA IRQS reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ IRQSTAT
));
959 waveartist_halt(int dev
)
961 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
965 if (portc
->open_mode
& OPEN_WRITE
)
966 waveartist_halt_output(dev
);
968 if (portc
->open_mode
& OPEN_READ
)
969 waveartist_halt_input(dev
);
971 devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
972 devc
->audio_mode
= 0;
976 waveartist_halt_input(int dev
)
978 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
984 waveartist_mute(devc
, 1);
986 //RMK disable_dma(audio_devs[dev]->dmap_in->dma);
991 waveartist_sendcmd(&devc
->hw
, 0x17);
993 //RMK enable_dma(audio_devs[dev]->dmap_in->dma);
994 devc
->audio_mode
&= ~PCM_ENABLE_INPUT
;
997 * Clear interrupt by toggling
998 * the IRQ_ACK bit in CTRL
1000 if (inb(devc
->hw
.io_base
+ STATR
) & IRQ_REQ
)
1001 waveartist_iack(devc
);
1003 // devc->audio_mode &= ~PCM_ENABLE_INPUT;
1005 restore_flags(flags
);
1009 waveartist_halt_output(int dev
)
1011 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
1012 unsigned long flags
;
1017 waveartist_mute(devc
, 1);
1019 //RMK disable_dma(audio_devs[dev]->dmap_out->dma);
1021 waveartist_sendcmd(&devc
->hw
, 0x27);
1023 //RMK enable_dma(audio_devs[dev]->dmap_out->dma);
1025 devc
->audio_mode
&= ~PCM_ENABLE_OUTPUT
;
1028 * Clear interrupt by toggling
1029 * the IRQ_ACK bit in CTRL
1031 if (inb(devc
->hw
.io_base
+ STATR
) & IRQ_REQ
)
1032 waveartist_iack(devc
);
1034 // devc->audio_mode &= ~PCM_ENABLE_OUTPUT;
1036 restore_flags(flags
);
1040 waveartist_trigger(int dev
, int state
)
1042 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
1043 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
1044 unsigned long flags
;
1046 if (debug_flg
& DEBUG_TRIGGER
) {
1047 printk("wavnc: audio trigger ");
1048 if (state
& PCM_ENABLE_INPUT
)
1050 if (state
& PCM_ENABLE_OUTPUT
)
1058 state
&= devc
->audio_mode
;
1060 if (portc
->open_mode
& OPEN_READ
&&
1061 state
& PCM_ENABLE_INPUT
)
1063 * enable ADC Data Transfer to PC
1065 waveartist_sendcmd(&devc
->hw
, 0x15);
1067 if (portc
->open_mode
& OPEN_WRITE
&&
1068 state
& PCM_ENABLE_OUTPUT
)
1070 * enable DAC data transfer from PC
1072 waveartist_sendcmd(&devc
->hw
, 0x25);
1074 waveartist_mute(devc
, 0);
1076 restore_flags(flags
);
1080 waveartist_set_speed(int dev
, int arg
)
1082 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
1085 return portc
->speed
;
1093 return portc
->speed
;
1098 waveartist_set_channels(int dev
, short arg
)
1100 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
1102 if (arg
!= 1 && arg
!= 2)
1103 return portc
->channels
;
1105 portc
->channels
= arg
;
1110 waveartist_set_bits(int dev
, unsigned int arg
)
1112 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
1115 return portc
->audio_format
;
1117 if ((arg
!= AFMT_U8
) && (arg
!= AFMT_S16_LE
) && (arg
!= AFMT_S8
))
1120 portc
->audio_format
= arg
;
1125 static struct audio_driver waveartist_audio_driver
= {
1128 waveartist_output_block
,
1129 waveartist_start_input
,
1131 waveartist_prepare_for_input
,
1132 waveartist_prepare_for_output
,
1136 waveartist_halt_input
,
1137 waveartist_halt_output
,
1139 waveartist_set_speed
,
1140 waveartist_set_bits
,
1141 waveartist_set_channels
1146 waveartist_intr(int irq
, void *dev_id
, struct pt_regs
*regs
)
1148 wavnc_info
*devc
= (wavnc_info
*)dev_id
;
1149 int irqstatus
, status
;
1151 irqstatus
= inb(devc
->hw
.io_base
+ IRQSTAT
);
1152 status
= inb(devc
->hw
.io_base
+ STATR
);
1154 if (debug_flg
& DEBUG_INTR
)
1155 printk("waveartist_intr: stat=%02x, irqstat=%02x\n",
1158 if (status
& IRQ_REQ
) /* Clear interrupt */
1159 waveartist_iack(devc
);
1161 printk("waveartist: unexpected interrupt\n");
1164 if (irqstatus
& 0x01) {
1169 if ((status
& DMA0
) && (devc
->audio_mode
& PCM_ENABLE_OUTPUT
)) {
1170 DMAbuf_outputintr(devc
->playback_dev
, 1);
1173 if ((status
& DMA1
) && (devc
->audio_mode
& PCM_ENABLE_INPUT
)) {
1174 DMAbuf_inputintr(devc
->record_dev
);
1177 if (temp
) //default:
1178 printk("WaveArtist: Unknown interrupt\n");
1181 if (irqstatus
& 0x2)
1182 // We do not use SB mode natively...
1183 printk("WaveArtist: Unexpected SB interrupt...\n");
1186 /* -------------------------------------------------------------------------
1190 waveartist_mixer_update(wavnc_info
*devc
, int whichDev
)
1192 unsigned int mask
, reg_l
, reg_r
;
1193 unsigned int lev_left
, lev_right
;
1194 unsigned int vals
[3];
1196 lev_left
= devc
->levels
[whichDev
] & 0xff;
1197 lev_right
= devc
->levels
[whichDev
] >> 8;
1199 #define SCALE(lev,max) ((lev) * (max) / 100)
1202 case SOUND_MIXER_VOLUME
:
1206 lev_left
= SCALE(lev_left
, 7) << 1;
1207 lev_right
= SCALE(lev_right
, 7) << 1;
1210 case SOUND_MIXER_LINE
:
1214 lev_left
= SCALE(lev_left
, 31) << 6;
1215 lev_right
= SCALE(lev_right
, 31) << 6;
1218 case SOUND_MIXER_MIC
:
1222 lev_left
= SCALE(lev_left
, 3) << 4;
1223 lev_right
= SCALE(lev_right
, 3) << 4;
1226 case SOUND_MIXER_RECLEV
:
1230 lev_left
= SCALE(lev_left
, 10);
1231 lev_right
= SCALE(lev_right
, 10);
1234 case SOUND_MIXER_LINE1
:
1238 lev_left
= SCALE(lev_left
, 31) << 1;
1239 lev_right
= SCALE(lev_right
, 31) << 1;
1242 case SOUND_MIXER_PCM
:
1243 waveartist_cmd3(devc
, 0x0031, SCALE(lev_left
, 32767),
1244 SCALE(lev_right
, 32767));
1247 case SOUND_MIXER_SYNTH
:
1248 waveartist_cmd3(devc
, 0x0131, SCALE(lev_left
, 32767),
1249 SCALE(lev_right
, 32767));
1256 /* read left setting */
1257 vals
[0] = reg_l
+ 0x30;
1258 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 1);
1260 /* read right setting */
1261 vals
[0] = reg_r
+ 0x30;
1262 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 2);
1264 vals
[1] = (vals
[1] & ~mask
) | (lev_left
& mask
);
1265 vals
[2] = (vals
[2] & ~mask
) | (lev_right
& mask
);
1267 /* write left,right back */
1269 waveartist_cmd(devc
, 3, vals
, 0, NULL
);
1273 waveartist_select_input(wavnc_info
*devc
, unsigned int input
)
1275 unsigned int vals
[3];
1277 /* New mixer programming - switch recording source
1278 * using R/L_ADC_Mux_Select. We are playing with
1279 * left/right mux bit fields in reg 9.
1281 * We can not switch Mux_Select while recording, so
1282 * for microphones, enable both left and right and
1283 * play with levels only!
1285 * Unfortunately, we need to select the src of mono
1286 * recording (left or right) before starting the
1287 * recording - so can not dynamically switch between
1288 * handset amd internal microphones...
1295 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 1);
1298 * Get reg 10, only so that we can write it back.
1301 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 2);
1303 if (debug_flg
& DEBUG_MIXER
)
1304 printk("RECSRC: old left: 0x%04X, old right: 0x%04X.\n",
1305 vals
[1] & 0x07, (vals
[1] >> 3) & 0x07);
1307 vals
[1] &= ~0x03F; //kill current left/right mux input select
1311 * Handset or internal MIC
1313 case SOUND_MASK_MIC
:
1315 * handset not plugged in?
1317 if (devc
->handset_state
& VNC_INTERNAL_MIC
) {
1319 * set mono recording from right mic
1321 waveartist_sendcmd(&devc
->hw
, 0x0134);
1324 * right=mic, left=none
1330 devc
->rec_devices
|= SOUND_MASK_SPEAKER
;
1334 * set mono rec from left mic
1336 waveartist_sendcmd(&devc
->hw
, 0x0034);
1339 * right=none, left=mic
1345 devc
->rec_devices
&= ~SOUND_MASK_SPEAKER
;
1349 * right=mic, left=mic
1354 case SOUND_MASK_LINE1
:
1356 * set mono rec from left aux1
1358 waveartist_sendcmd(&devc
->hw
, 0x0034);
1360 * right=none, left=Aux1;
1365 case SOUND_MASK_LINE
:
1367 * set mono rec from left (default)
1369 waveartist_sendcmd(&devc
->hw
, 0x0034);
1371 * right=Line, left=Line;
1377 if (debug_flg
& DEBUG_MIXER
)
1378 printk("RECSRC %d: left=0x%04X, right=0x%04X.\n", input
,
1379 vals
[1] & 0x07, (vals
[1] >> 3) & 0x07);
1382 /* This part is good, if input connected to
1383 * a mixer, so can be used for record-only modes...
1390 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 1);
1396 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 2);
1398 if (debug_flg
& DEBUG_MIXER
)
1399 printk("RECSRC: old left: 0x%04X, old right: 0x%04X.\n",
1403 * kill current left/right mux input select
1410 * handset or internal mic
1412 case SOUND_MASK_MIC
:
1414 * handset not plugged in?
1416 if (devc
->handset_state
& VNC_INTERNAL_MIC
) {
1418 * set mono recording from right mic
1420 waveartist_sendcmd(&devc
->hw
, 0x0134);
1422 * left = none, right = mic, RX filter gain
1429 devc
->rec_devices
|= SOUND_MASK_SPEAKER
;
1432 * set mono rec from left mic
1434 waveartist_sendcmd(&devc
->hw
, 0x0034);
1436 * left = mic, RX filter gain, right = none;
1443 devc
->rec_devices
&= ~SOUND_MASK_SPEAKER
;
1447 case SOUND_MASK_LINE1
:
1449 * set mono rec from left aux1
1451 waveartist_sendcmd(&devc
->hw
, 0x0034);
1453 * left = Aux1, right = none
1459 case SOUND_MASK_LINE
:
1461 * left = Line, right = Line
1468 if (debug_flg
& DEBUG_MIXER
)
1469 printk("RECSRC %d: left(4) 0x%04X, right(8) 0x%04X.\n",
1470 level
, vals
[1], vals
[2]);
1473 * and finally - write the reg pair back....
1477 waveartist_cmd(devc
, 3, vals
, 0, NULL
);
1481 waveartist_mixer_set(wavnc_info
*devc
, int whichDev
, unsigned int level
)
1483 unsigned int lev_left
= level
& 0x007f;
1484 unsigned int lev_right
= (level
& 0x7f00) >> 8;
1486 int left
, right
, devmask
, changed
, i
;
1488 left
= level
& 0x7f;
1489 right
= (level
& 0x7f00) >> 8;
1491 if (debug_flg
& DEBUG_MIXER
)
1492 printk("wa_mixer_set(dev=%d, level=%X)\n",
1496 /* Master volume (0-7)
1497 * We have 3 bits on the Left/Right Mixer Gain,
1498 * bits 3,2,1 on 3 and 7
1500 case SOUND_MIXER_VOLUME
:
1501 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1502 waveartist_mixer_update(devc
, whichDev
);
1506 /* External line (0-31)
1507 * use LOUT/ROUT bits 10...6, reg 1 and 5
1509 case SOUND_MIXER_LINE
:
1510 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1511 waveartist_mixer_update(devc
, whichDev
);
1514 /* Mono microphone (0-3) mute,
1517 case SOUND_MIXER_MIC
:
1519 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1521 /* we do not need to mute volume of
1522 * an unused mic - it is simply unused...
1524 if (devc
->handset_state
& VNC_INTERNAL_MIC
)
1525 devc
->levels
[whichDev
] = lev_right
<< 8;
1527 levels
[whichDev
] = lev_left
;
1529 waveartist_mixer_update(devc
, whichDev
);
1532 /* Recording level (0-7)
1534 case SOUND_MIXER_RECLEV
:
1535 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1536 waveartist_mixer_update(devc
, whichDev
);
1539 /* Mono External Aux1 (0-31)
1540 * use LINE1 bits 5...1, reg 1 and 5
1542 case SOUND_MIXER_LINE1
:
1543 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1544 waveartist_mixer_update(devc
, whichDev
);
1547 /* WaveArtist PCM (0-32767)
1549 case SOUND_MIXER_PCM
:
1550 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1551 waveartist_mixer_update(devc
, whichDev
);
1554 /* Internal synthesizer (0-31)
1556 case SOUND_MIXER_SYNTH
:
1557 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1558 waveartist_mixer_update(devc
, whichDev
);
1562 /* Select recording input source
1564 case SOUND_MIXER_RECSRC
:
1565 devmask
= level
& POSSIBLE_RECORDING_DEVICES
;
1567 changed
= devmask
^ devc
->recmask
;
1568 devc
->recmask
= devmask
;
1570 for (i
= 0; i
< SOUND_MIXER_NRDEVICES
; i
++)
1571 if (changed
& (1 << i
))
1572 waveartist_mixer_update(devc
, i
);
1574 waveartist_select_input(devc
, level
);
1576 * do not save in "levels", return current setting
1578 return devc
->recmask
;
1584 return devc
->levels
[whichDev
];
1588 waveartist_mixer_reset(wavnc_info
*devc
)
1592 if (debug_flg
& DEBUG_MIXER
)
1593 printk("%s: mixer_reset\n", devc
->hw
.name
);
1598 waveartist_sendcmd(&devc
->hw
, 0x33);
1601 * set input for ADC to come from
1602 * a mux (left and right) == reg 9,
1605 waveartist_cmd3(devc
, 0x0032, 0x9800, 0xa836);
1608 * set mixer input select to none, RX filter gains 0 db
1610 waveartist_cmd3(devc
, 0x0032, 0x4c00, 0x8c00);
1613 * set bit 0 reg 2 to 1 - unmute MonoOut
1615 waveartist_cmd3(devc
, 0x0032, 0x2801, 0x6800);
1617 for (i
= 0; i
< SOUND_MIXER_NRDEVICES
; i
++)
1618 waveartist_mixer_update(devc
, i
);
1620 /* set default input device = internal mic
1621 * current recording device = none
1625 devc
->handset_state
= VNC_INTERNAL_MIC
;
1626 // waveartist_mixer_set(devc, SOUND_MIXER_RECSRC, SOUND_MASK_MIC);
1629 * start from enabling the hw setting
1631 devc
->handset_mute_sw
= 0;
1632 devc
->supported_devices
= SUPPORTED_MIXER_DEVICES
;
1633 devc
->rec_devices
= POSSIBLE_RECORDING_DEVICES
;
1637 waveartist_mixer_ioctl(int dev
, unsigned int cmd
, caddr_t arg
)
1639 wavnc_info
*devc
= (wavnc_info
*)audio_devs
[dev
]->devc
;
1641 if (cmd
== SOUND_MIXER_PRIVATE1
||
1642 cmd
== SOUND_MIXER_PRIVATE2
||
1643 cmd
== SOUND_MIXER_PRIVATE3
)
1644 return vnc_private_ioctl(dev
, cmd
, arg
);
1646 if (((cmd
>> 8) & 0xff) == 'M') {
1647 if (_SIOC_DIR(cmd
) & _SIOC_WRITE
) {
1650 if (get_user(val
, (int *)arg
))
1654 * special case for master volume: if we
1655 * received this call - switch from hw
1656 * volume control to a software volume
1657 * control, till the hw volume is modified
1658 * to signal that user wants to be back in
1661 if ((cmd
& 0xff) == SOUND_MIXER_VOLUME
)
1662 devc
->use_slider
= 0;
1664 return waveartist_mixer_set(devc
, cmd
& 0xff, val
);
1671 switch (cmd
& 0xff) {
1672 case SOUND_MIXER_RECSRC
:
1673 ret
= devc
->recmask
;
1675 if (devc
->handset_state
& VNC_INTERNAL_MIC
)
1676 ret
|= SOUND_MASK_SPEAKER
;
1679 case SOUND_MIXER_DEVMASK
:
1680 ret
= devc
->supported_devices
;
1683 case SOUND_MIXER_STEREODEVS
:
1684 ret
= devc
->supported_devices
&
1685 ~(SOUND_MASK_SPEAKER
|SOUND_MASK_IMIX
);
1688 case SOUND_MIXER_RECMASK
:
1689 ret
= devc
->rec_devices
;
1692 case SOUND_MIXER_CAPS
:
1693 ret
= SOUND_CAP_EXCL_INPUT
;
1697 if ((cmd
& 0xff) < SOUND_MIXER_NRDEVICES
)
1698 ret
= devc
->levels
[cmd
& 0xff];
1703 return put_user(ret
, (int *)arg
) ? -EINVAL
: 0;
1707 return -ENOIOCTLCMD
;
1710 static struct mixer_operations waveartist_mixer_operations
=
1713 "WaveArtist NetWinder",
1714 waveartist_mixer_ioctl
1718 waveartist_init(wavnc_info
*devc
)
1720 wavnc_port_info
*portc
;
1721 char rev
[3], dev_name
[64];
1724 waveartist_reset(devc
);
1726 sprintf(dev_name
, "%s (%s", devc
->hw
.name
, devc
->chip_name
);
1728 if (waveartist_getrev(&devc
->hw
, rev
)) {
1729 strcat(dev_name
, " rev. ");
1730 strcat(dev_name
, rev
);
1732 strcat(dev_name
, ")");
1734 conf_printf2(dev_name
, devc
->hw
.io_base
, devc
->hw
.irq
,
1735 devc
->hw
.dma
, devc
->hw
.dma2
);
1737 portc
= (wavnc_port_info
*)kmalloc(sizeof(wavnc_port_info
), GFP_KERNEL
);
1741 memset(portc
, 0, sizeof(wavnc_port_info
));
1743 my_dev
= sound_install_audiodrv(AUDIO_DRIVER_VERSION
, dev_name
,
1744 &waveartist_audio_driver
, sizeof(struct audio_driver
),
1745 devc
->audio_flags
, AFMT_U8
| AFMT_S16_LE
| AFMT_S8
,
1746 devc
, devc
->hw
.dma
, devc
->hw
.dma2
);
1751 audio_devs
[my_dev
]->portc
= portc
;
1753 waveartist_mixer_reset(devc
);
1756 * clear any pending interrupt
1758 waveartist_iack(devc
);
1760 if (request_irq(devc
->hw
.irq
, waveartist_intr
, 0, devc
->hw
.name
, devc
) < 0) {
1761 printk("%s: IRQ %d in use\n",
1762 devc
->hw
.name
, devc
->hw
.irq
);
1766 if (sound_alloc_dma(devc
->hw
.dma
, devc
->hw
.name
)) {
1767 printk("%s: Can't allocate DMA%d\n",
1768 devc
->hw
.name
, devc
->hw
.dma
);
1772 if (devc
->hw
.dma
!= devc
->hw
.dma2
&& devc
->hw
.dma2
!= NO_DMA
)
1773 if (sound_alloc_dma(devc
->hw
.dma2
, devc
->hw
.name
)) {
1774 printk("%s: can't allocate DMA%d\n",
1775 devc
->hw
.name
, devc
->hw
.dma2
);
1779 waveartist_set_ctlr(&devc
->hw
, 0, DMA1_IE
| DMA0_IE
);
1781 audio_devs
[my_dev
]->mixer_dev
=
1782 sound_install_mixer(MIXER_DRIVER_VERSION
,
1784 &waveartist_mixer_operations
,
1785 sizeof(struct mixer_operations
),
1791 sound_free_dma(devc
->hw
.dma
);
1794 free_irq(devc
->hw
.irq
, devc
);
1797 sound_unload_audiodev(my_dev
);
1807 probe_waveartist(struct address_info
*hw_config
)
1809 wavnc_info
*devc
= &adev_info
[nr_waveartist_devs
];
1811 if (nr_waveartist_devs
>= MAX_AUDIO_DEV
) {
1812 printk("waveartist: too many audio devices\n");
1816 if (check_region(hw_config
->io_base
, 15)) {
1817 printk("WaveArtist: I/O port conflict\n");
1821 if (hw_config
->irq
> _ISA_IRQ(15) || hw_config
->irq
< _ISA_IRQ(0)) {
1822 printk("WaveArtist: Bad IRQ %d\n", hw_config
->irq
);
1826 if (hw_config
->dma
!= _ISA_DMA(3)) {
1827 printk("WaveArtist: Bad DMA %d\n", hw_config
->dma
);
1831 hw_config
->name
= "WaveArtist";
1832 devc
->hw
= *hw_config
;
1833 devc
->open_mode
= 0;
1834 devc
->chip_name
= "RWA-010";
1840 attach_waveartist(struct address_info
*hw
)
1842 wavnc_info
*devc
= &adev_info
[nr_waveartist_devs
];
1845 * NOTE! If irq < 0, there is another driver which has allocated the
1846 * IRQ so that this driver doesn't need to allocate/deallocate it.
1847 * The actually used IRQ is ABS(irq).
1850 devc
->hw
.irq
= (hw
->irq
> 0) ? hw
->irq
: 0;
1851 devc
->open_mode
= 0;
1852 devc
->playback_dev
= 0;
1853 devc
->record_dev
= 0;
1854 devc
->audio_flags
= DMA_AUTOMODE
;
1855 devc
->levels
= levels
;
1857 if (hw
->dma
!= hw
->dma2
&& hw
->dma2
!= NO_DMA
)
1858 devc
->audio_flags
|= DMA_DUPLEX
;
1860 request_region(hw
->io_base
, 15, devc
->hw
.name
);
1862 devc
->dev_no
= waveartist_init(devc
);
1864 if (devc
->dev_no
< 0)
1865 release_region(hw
->io_base
, 15);
1867 init_timer(&vnc_timer
);
1868 vnc_timer
.function
= vnc_slider_tick
;
1869 vnc_timer
.expires
= jiffies
;
1870 vnc_timer
.data
= nr_waveartist_devs
;
1871 add_timer(&vnc_timer
);
1873 nr_waveartist_devs
+= 1;
1880 unload_waveartist(struct address_info
*hw
)
1882 wavnc_info
*devc
= NULL
;
1885 for (i
= 0; i
< nr_waveartist_devs
; i
++)
1886 if (hw
->io_base
== adev_info
[i
].hw
.io_base
) {
1887 devc
= adev_info
+ i
;
1894 release_region(devc
->hw
.io_base
, 15);
1896 waveartist_set_ctlr(&devc
->hw
, DMA1_IE
|DMA0_IE
, 0);
1898 if (devc
->hw
.irq
>= 0)
1899 free_irq(devc
->hw
.irq
, devc
);
1901 sound_free_dma(devc
->hw
.dma
);
1903 if (devc
->hw
.dma
!= devc
->hw
.dma2
&&
1904 devc
->hw
.dma2
!= NO_DMA
)
1905 sound_free_dma(devc
->hw
.dma2
);
1907 del_timer(&vnc_timer
);
1909 mixer
= audio_devs
[devc
->dev_no
]->mixer_dev
;
1912 sound_unload_mixerdev(mixer
);
1914 if (devc
->dev_no
>= 0)
1915 sound_unload_audiodev(devc
->dev_no
);
1917 nr_waveartist_devs
-= 1;
1919 for (; i
< nr_waveartist_devs
; i
++)
1920 adev_info
[i
] = adev_info
[i
+ 1];
1922 printk("waveartist: can't find device to unload\n");
1927 MODULE_PARM(io
, "i"); /* IO base */
1928 MODULE_PARM(irq
, "i"); /* IRQ */
1929 MODULE_PARM(dma
, "i"); /* DMA */
1930 MODULE_PARM(dma2
, "i"); /* DMA2 */
1932 int io
= CONFIG_WAVEARTIST_BASE
;
1933 int irq
= CONFIG_WAVEARTIST_IRQ
;
1934 int dma
= CONFIG_WAVEARTIST_DMA
;
1935 int dma2
= CONFIG_WAVEARTIST_DMA2
;
1937 static int attached
;
1939 struct address_info hw_config
;
1941 int init_module(void)
1943 hw_config
.io_base
= io
;
1944 hw_config
.irq
= irq
;
1945 hw_config
.dma
= dma
;
1946 hw_config
.dma2
= dma2
;
1948 if (!probe_waveartist(&hw_config
))
1951 attach_waveartist(&hw_config
);
1958 void cleanup_module(void)
1963 unload_waveartist(&hw_config
);