2 * linux/drivers/sound/waveartist.c
4 * The low level driver for the RWA010 Rockwell Wave Artist
5 * codec chip used in the Rebel.com NetWinder.
7 * Cleaned up and integrated into 2.1 by Russell King (rmk@arm.linux.org.uk)
8 * and Pat Beirne (patb@corel.ca)
11 * Copyright (C) by Rebel.com 1998-1999
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
32 #include <linux/module.h>
33 #include <linux/init.h>
34 #include <linux/config.h>
35 #include <linux/sched.h>
36 #include <linux/interrupt.h>
37 #include <linux/delay.h>
38 #include <linux/smp.h>
39 #include <linux/spinlock.h>
41 #include <asm/dec21285.h>
42 #include <asm/hardware.h>
43 #include <asm/system.h>
45 #include "soundmodule.h"
46 #include "sound_config.h"
47 #include "waveartist.h"
50 #define _ISA_DMA(x) (x)
53 #define _ISA_IRQ(x) (x)
56 #define POSSIBLE_RECORDING_DEVICES (SOUND_MASK_LINE |\
60 #define SUPPORTED_MIXER_DEVICES (SOUND_MASK_SYNTH |\
69 static unsigned short levels
[SOUND_MIXER_NRDEVICES
] = {
70 0x5555, /* Master Volume */
73 0x2323, /* Synth (FM) */
75 0x0000, /* PC Speaker */
76 0x0000, /* Ext Line */
79 0x0000, /* Recording monitor */
80 0x0000, /* SB PCM (ALT PCM) */
81 0x0000, /* Recording level */
82 0x0000, /* Input gain */
83 0x0000, /* Output gain */
84 0x0000, /* Line1 (Aux1) */
85 0x0000, /* Line2 (Aux2) */
86 0x0000, /* Line3 (Aux3) */
87 0x0000, /* Digital1 */
88 0x0000, /* Digital2 */
89 0x0000, /* Digital3 */
90 0x0000, /* Phone In */
91 0x0000, /* Phone Out */
98 struct address_info hw
; /* hardware */
109 /* Mixer parameters */
110 unsigned short *levels
; /* cache of volume settings */
111 int recmask
; /* currently enabled recording device! */
112 int supported_devices
; /* SUPPORTED_MIXER_DEVICES */
113 int rec_devices
; /* POSSIBLE_RECORDING_DEVICES */
115 #ifdef CONFIG_ARCH_NETWINDER
116 signed int slider_vol
; /* hardware slider volume */
117 unsigned int handset_detect
:1;
118 unsigned int telephone_detect
:1;
119 unsigned int no_autoselect
:1;/* handset/telephone autoselects a path */
120 unsigned int spkr_mute_state
:1;/* set by ioctl or autoselect */
121 unsigned int line_mute_state
:1;/* set by ioctl or autoselect */
122 unsigned int use_slider
:1;/* use slider setting for o/p vol */
126 typedef struct wavnc_port_info
{
133 static int nr_waveartist_devs
;
134 static wavnc_info adev_info
[MAX_AUDIO_DEV
];
135 static spinlock_t waveartist_lock
= SPIN_LOCK_UNLOCKED
;
137 #ifndef machine_is_netwinder
138 #define machine_is_netwinder() 0
141 static struct timer_list vnc_timer
;
142 static void vnc_configure_mixer(wavnc_info
*devc
);
143 static int vnc_private_ioctl(int dev
, unsigned int cmd
, caddr_t arg
);
144 static void vnc_slider_tick(unsigned long data
);
147 waveartist_set_ctlr(struct address_info
*hw
, unsigned char clear
, unsigned char set
)
149 unsigned int ctlr_port
= hw
->io_base
+ CTLR
;
151 clear
= ~clear
& inb(ctlr_port
);
153 outb(clear
| set
, ctlr_port
);
156 /* Toggle IRQ acknowledge line
159 waveartist_iack(wavnc_info
*devc
)
161 unsigned int ctlr_port
= devc
->hw
.io_base
+ CTLR
;
164 old_ctlr
= inb(ctlr_port
) & ~IRQ_ACK
;
166 outb(old_ctlr
| IRQ_ACK
, ctlr_port
);
167 outb(old_ctlr
, ctlr_port
);
171 waveartist_sleep(int timeout_ms
)
173 unsigned int timeout
= timeout_ms
* 10 * HZ
/ 100;
176 current
->state
= TASK_INTERRUPTIBLE
;
177 timeout
= schedule_timeout(timeout
);
184 waveartist_reset(wavnc_info
*devc
)
186 struct address_info
*hw
= &devc
->hw
;
187 unsigned int timeout
, res
= -1;
189 waveartist_set_ctlr(hw
, -1, RESET
);
191 waveartist_set_ctlr(hw
, RESET
, 0);
197 if (inb(hw
->io_base
+ STATR
) & CMD_RF
) {
198 res
= inw(hw
->io_base
+ CMDR
);
205 printk(KERN_WARNING
"WaveArtist: reset timeout ");
206 if (res
!= (unsigned int)-1)
207 printk("(res=%04X)", res
);
214 /* Helper function to send and receive words
215 * from WaveArtist. It handles all the handshaking
216 * and can send or receive multiple words.
219 waveartist_cmd(wavnc_info
*devc
,
220 int nr_cmd
, unsigned int *cmd
,
221 int nr_resp
, unsigned int *resp
)
223 unsigned int io_base
= devc
->hw
.io_base
;
224 unsigned int timed_out
= 0;
227 if (debug_flg
& DEBUG_CMD
) {
228 printk("waveartist_cmd: cmd=");
230 for (i
= 0; i
< nr_cmd
; i
++)
231 printk("%04X ", cmd
[i
]);
236 if (inb(io_base
+ STATR
) & CMD_RF
) {
242 old_data
= inw(io_base
+ CMDR
);
244 if (debug_flg
& DEBUG_CMD
)
245 printk("flushed %04X...", old_data
);
250 for (i
= 0; !timed_out
&& i
< nr_cmd
; i
++) {
253 for (count
= 5000; count
; count
--)
254 if (inb(io_base
+ STATR
) & CMD_WE
)
260 outw(cmd
[i
], io_base
+ CMDR
);
263 for (i
= 0; !timed_out
&& i
< nr_resp
; i
++) {
266 for (count
= 5000; count
; count
--)
267 if (inb(io_base
+ STATR
) & CMD_RF
)
273 resp
[i
] = inw(io_base
+ CMDR
);
276 if (debug_flg
& DEBUG_CMD
) {
278 printk("waveartist_cmd: resp=");
280 for (i
= 0; i
< nr_resp
; i
++)
281 printk("%04X ", resp
[i
]);
285 printk("waveartist_cmd: timed out\n");
288 return timed_out
? 1 : 0;
292 * Send one command word
295 waveartist_cmd1(wavnc_info
*devc
, unsigned int cmd
)
297 return waveartist_cmd(devc
, 1, &cmd
, 0, NULL
);
301 * Send one command, receive one word
303 static inline unsigned int
304 waveartist_cmd1_r(wavnc_info
*devc
, unsigned int cmd
)
308 waveartist_cmd(devc
, 1, &cmd
, 1, &ret
);
314 * Send a double command, receive one
315 * word (and throw it away)
318 waveartist_cmd2(wavnc_info
*devc
, unsigned int cmd
, unsigned int arg
)
320 unsigned int vals
[2];
325 return waveartist_cmd(devc
, 2, vals
, 1, vals
);
329 * Send a triple command
332 waveartist_cmd3(wavnc_info
*devc
, unsigned int cmd
,
333 unsigned int arg1
, unsigned int arg2
)
335 unsigned int vals
[3];
341 return waveartist_cmd(devc
, 3, vals
, 0, NULL
);
345 waveartist_getrev(wavnc_info
*devc
, char *rev
)
347 unsigned int temp
[2];
348 unsigned int cmd
= WACMD_GETREV
;
350 waveartist_cmd(devc
, 1, &cmd
, 2, temp
);
352 rev
[0] = temp
[0] >> 8;
353 rev
[1] = temp
[0] & 255;
359 static void waveartist_halt_output(int dev
);
360 static void waveartist_halt_input(int dev
);
361 static void waveartist_halt(int dev
);
362 static void waveartist_trigger(int dev
, int state
);
365 waveartist_open(int dev
, int mode
)
368 wavnc_port_info
*portc
;
371 if (dev
< 0 || dev
>= num_audiodevs
)
374 devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
375 portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
377 spin_lock_irqsave(&waveartist_lock
, flags
);
378 if (portc
->open_mode
|| (devc
->open_mode
& mode
)) {
379 spin_unlock_irqrestore(&waveartist_lock
, flags
);
383 devc
->audio_mode
= 0;
384 devc
->open_mode
|= mode
;
385 portc
->open_mode
= mode
;
386 waveartist_trigger(dev
, 0);
388 if (mode
& OPEN_READ
)
389 devc
->record_dev
= dev
;
390 if (mode
& OPEN_WRITE
)
391 devc
->playback_dev
= dev
;
392 spin_unlock_irqrestore(&waveartist_lock
, flags
);
398 waveartist_close(int dev
)
400 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
401 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
404 spin_lock_irqsave(&waveartist_lock
, flags
);
406 waveartist_halt(dev
);
408 devc
->audio_mode
= 0;
409 devc
->open_mode
&= ~portc
->open_mode
;
410 portc
->open_mode
= 0;
412 spin_unlock_irqrestore(&waveartist_lock
, flags
);
416 waveartist_output_block(int dev
, unsigned long buf
, int __count
, int intrflag
)
418 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
419 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
421 unsigned int count
= __count
;
423 if (debug_flg
& DEBUG_OUT
)
424 printk("waveartist: output block, buf=0x%lx, count=0x%x...\n",
429 if (portc
->audio_format
& (AFMT_S16_LE
| AFMT_S16_BE
))
432 if (portc
->channels
> 1)
437 if (devc
->audio_mode
& PCM_ENABLE_OUTPUT
&&
438 audio_devs
[dev
]->flags
& DMA_AUTOMODE
&&
440 count
== devc
->xfer_count
) {
441 devc
->audio_mode
|= PCM_ENABLE_OUTPUT
;
443 * Auto DMA mode on. No need to react
447 spin_lock_irqsave(&waveartist_lock
, flags
);
452 waveartist_cmd2(devc
, WACMD_OUTPUTSIZE
, count
);
454 devc
->xfer_count
= count
;
455 devc
->audio_mode
|= PCM_ENABLE_OUTPUT
;
457 spin_unlock_irqrestore(&waveartist_lock
, flags
);
461 waveartist_start_input(int dev
, unsigned long buf
, int __count
, int intrflag
)
463 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
464 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
466 unsigned int count
= __count
;
468 if (debug_flg
& DEBUG_IN
)
469 printk("waveartist: start input, buf=0x%lx, count=0x%x...\n",
472 if (portc
->audio_format
& (AFMT_S16_LE
| AFMT_S16_BE
)) /* 16 bit data */
475 if (portc
->channels
> 1)
480 if (devc
->audio_mode
& PCM_ENABLE_INPUT
&&
481 audio_devs
[dev
]->flags
& DMA_AUTOMODE
&&
483 count
== devc
->xfer_count
) {
484 devc
->audio_mode
|= PCM_ENABLE_INPUT
;
486 * Auto DMA mode on. No need to react
490 spin_lock_irqsave(&waveartist_lock
, flags
);
495 waveartist_cmd2(devc
, WACMD_INPUTSIZE
, count
);
497 devc
->xfer_count
= count
;
498 devc
->audio_mode
|= PCM_ENABLE_INPUT
;
500 spin_unlock_irqrestore(&waveartist_lock
, flags
);
504 waveartist_ioctl(int dev
, unsigned int cmd
, caddr_t arg
)
510 waveartist_get_speed(wavnc_port_info
*portc
)
515 * program the speed, channels, bits
517 if (portc
->speed
== 8000)
519 else if (portc
->speed
== 11025)
521 else if (portc
->speed
== 22050)
523 else if (portc
->speed
== 44100)
527 * non-standard - just calculate
529 speed
= portc
->speed
<< 16;
531 speed
= (speed
/ 44100) & 65535;
538 waveartist_get_bits(wavnc_port_info
*portc
)
542 if (portc
->audio_format
== AFMT_S16_LE
)
544 else if (portc
->audio_format
== AFMT_S8
)
547 bits
= 2; //default AFMT_U8
553 waveartist_prepare_for_input(int dev
, int bsize
, int bcount
)
556 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
557 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
558 unsigned int speed
, bits
;
560 if (devc
->audio_mode
)
563 speed
= waveartist_get_speed(portc
);
564 bits
= waveartist_get_bits(portc
);
566 spin_lock_irqsave(&waveartist_lock
, flags
);
568 if (waveartist_cmd2(devc
, WACMD_INPUTFORMAT
, bits
))
569 printk(KERN_WARNING
"waveartist: error setting the "
570 "record format to %d\n", portc
->audio_format
);
572 if (waveartist_cmd2(devc
, WACMD_INPUTCHANNELS
, portc
->channels
))
573 printk(KERN_WARNING
"waveartist: error setting record "
574 "to %d channels\n", portc
->channels
);
577 * write cmd SetSampleSpeedTimeConstant
579 if (waveartist_cmd2(devc
, WACMD_INPUTSPEED
, speed
))
580 printk(KERN_WARNING
"waveartist: error setting the record "
581 "speed to %dHz.\n", portc
->speed
);
583 if (waveartist_cmd2(devc
, WACMD_INPUTDMA
, 1))
584 printk(KERN_WARNING
"waveartist: error setting the record "
585 "data path to 0x%X\n", 1);
587 if (waveartist_cmd2(devc
, WACMD_INPUTFORMAT
, bits
))
588 printk(KERN_WARNING
"waveartist: error setting the record "
589 "format to %d\n", portc
->audio_format
);
591 devc
->xfer_count
= 0;
592 spin_unlock_irqrestore(&waveartist_lock
, flags
);
593 waveartist_halt_input(dev
);
595 if (debug_flg
& DEBUG_INTR
) {
596 printk("WA CTLR reg: 0x%02X.\n",
597 inb(devc
->hw
.io_base
+ CTLR
));
598 printk("WA STAT reg: 0x%02X.\n",
599 inb(devc
->hw
.io_base
+ STATR
));
600 printk("WA IRQS reg: 0x%02X.\n",
601 inb(devc
->hw
.io_base
+ IRQSTAT
));
608 waveartist_prepare_for_output(int dev
, int bsize
, int bcount
)
611 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
612 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
613 unsigned int speed
, bits
;
616 * program the speed, channels, bits
618 speed
= waveartist_get_speed(portc
);
619 bits
= waveartist_get_bits(portc
);
621 spin_lock_irqsave(&waveartist_lock
, flags
);
623 if (waveartist_cmd2(devc
, WACMD_OUTPUTSPEED
, speed
) &&
624 waveartist_cmd2(devc
, WACMD_OUTPUTSPEED
, speed
))
625 printk(KERN_WARNING
"waveartist: error setting the playback "
626 "speed to %dHz.\n", portc
->speed
);
628 if (waveartist_cmd2(devc
, WACMD_OUTPUTCHANNELS
, portc
->channels
))
629 printk(KERN_WARNING
"waveartist: error setting the playback "
630 "to %d channels\n", portc
->channels
);
632 if (waveartist_cmd2(devc
, WACMD_OUTPUTDMA
, 0))
633 printk(KERN_WARNING
"waveartist: error setting the playback "
634 "data path to 0x%X\n", 0);
636 if (waveartist_cmd2(devc
, WACMD_OUTPUTFORMAT
, bits
))
637 printk(KERN_WARNING
"waveartist: error setting the playback "
638 "format to %d\n", portc
->audio_format
);
640 devc
->xfer_count
= 0;
641 spin_unlock_irqrestore(&waveartist_lock
, flags
);
642 waveartist_halt_output(dev
);
644 if (debug_flg
& DEBUG_INTR
) {
645 printk("WA CTLR reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ CTLR
));
646 printk("WA STAT reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ STATR
));
647 printk("WA IRQS reg: 0x%02X.\n",inb(devc
->hw
.io_base
+ IRQSTAT
));
654 waveartist_halt(int dev
)
656 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
659 if (portc
->open_mode
& OPEN_WRITE
)
660 waveartist_halt_output(dev
);
662 if (portc
->open_mode
& OPEN_READ
)
663 waveartist_halt_input(dev
);
665 devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
666 devc
->audio_mode
= 0;
670 waveartist_halt_input(int dev
)
672 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
675 spin_lock_irqsave(&waveartist_lock
, flags
);
680 waveartist_cmd1(devc
, WACMD_INPUTSTOP
);
682 devc
->audio_mode
&= ~PCM_ENABLE_INPUT
;
685 * Clear interrupt by toggling
686 * the IRQ_ACK bit in CTRL
688 if (inb(devc
->hw
.io_base
+ STATR
) & IRQ_REQ
)
689 waveartist_iack(devc
);
691 // devc->audio_mode &= ~PCM_ENABLE_INPUT;
693 spin_unlock_irqrestore(&waveartist_lock
, flags
);
697 waveartist_halt_output(int dev
)
699 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
702 spin_lock_irqsave(&waveartist_lock
, flags
);
704 waveartist_cmd1(devc
, WACMD_OUTPUTSTOP
);
706 devc
->audio_mode
&= ~PCM_ENABLE_OUTPUT
;
709 * Clear interrupt by toggling
710 * the IRQ_ACK bit in CTRL
712 if (inb(devc
->hw
.io_base
+ STATR
) & IRQ_REQ
)
713 waveartist_iack(devc
);
715 // devc->audio_mode &= ~PCM_ENABLE_OUTPUT;
717 spin_unlock_irqrestore(&waveartist_lock
, flags
);
721 waveartist_trigger(int dev
, int state
)
723 wavnc_info
*devc
= (wavnc_info
*) audio_devs
[dev
]->devc
;
724 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
727 if (debug_flg
& DEBUG_TRIGGER
) {
728 printk("wavnc: audio trigger ");
729 if (state
& PCM_ENABLE_INPUT
)
731 if (state
& PCM_ENABLE_OUTPUT
)
736 spin_lock_irqsave(&waveartist_lock
, flags
);
738 state
&= devc
->audio_mode
;
740 if (portc
->open_mode
& OPEN_READ
&&
741 state
& PCM_ENABLE_INPUT
)
743 * enable ADC Data Transfer to PC
745 waveartist_cmd1(devc
, WACMD_INPUTSTART
);
747 if (portc
->open_mode
& OPEN_WRITE
&&
748 state
& PCM_ENABLE_OUTPUT
)
750 * enable DAC data transfer from PC
752 waveartist_cmd1(devc
, WACMD_OUTPUTSTART
);
754 spin_unlock_irqrestore(&waveartist_lock
, flags
);
758 waveartist_set_speed(int dev
, int arg
)
760 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
776 waveartist_set_channels(int dev
, short arg
)
778 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
780 if (arg
!= 1 && arg
!= 2)
781 return portc
->channels
;
783 portc
->channels
= arg
;
788 waveartist_set_bits(int dev
, unsigned int arg
)
790 wavnc_port_info
*portc
= (wavnc_port_info
*) audio_devs
[dev
]->portc
;
793 return portc
->audio_format
;
795 if ((arg
!= AFMT_U8
) && (arg
!= AFMT_S16_LE
) && (arg
!= AFMT_S8
))
798 portc
->audio_format
= arg
;
803 static struct audio_driver waveartist_audio_driver
= {
806 waveartist_output_block
,
807 waveartist_start_input
,
809 waveartist_prepare_for_input
,
810 waveartist_prepare_for_output
,
814 waveartist_halt_input
,
815 waveartist_halt_output
,
817 waveartist_set_speed
,
819 waveartist_set_channels
824 waveartist_intr(int irq
, void *dev_id
, struct pt_regs
*regs
)
826 wavnc_info
*devc
= (wavnc_info
*)dev_id
;
827 int irqstatus
, status
;
829 irqstatus
= inb(devc
->hw
.io_base
+ IRQSTAT
);
830 status
= inb(devc
->hw
.io_base
+ STATR
);
832 if (debug_flg
& DEBUG_INTR
)
833 printk("waveartist_intr: stat=%02x, irqstat=%02x\n",
836 if (status
& IRQ_REQ
) /* Clear interrupt */
837 waveartist_iack(devc
);
839 printk(KERN_WARNING
"waveartist: unexpected interrupt\n");
841 if (irqstatus
& 0x01) {
846 if ((status
& DMA0
) && (devc
->audio_mode
& PCM_ENABLE_OUTPUT
)) {
847 DMAbuf_outputintr(devc
->playback_dev
, 1);
850 if ((status
& DMA1
) && (devc
->audio_mode
& PCM_ENABLE_INPUT
)) {
851 DMAbuf_inputintr(devc
->record_dev
);
855 printk(KERN_WARNING
"waveartist: Unknown interrupt\n");
858 // We do not use SB mode natively...
859 printk(KERN_WARNING
"waveartist: Unexpected SB interrupt...\n");
862 /* -------------------------------------------------------------------------
866 waveartist_mixer_update(wavnc_info
*devc
, int whichDev
)
868 unsigned int mask
, reg_l
, reg_r
;
869 unsigned int lev_left
, lev_right
;
870 unsigned int vals
[3];
872 lev_left
= devc
->levels
[whichDev
] & 0xff;
873 lev_right
= devc
->levels
[whichDev
] >> 8;
875 #define SCALE(lev,max) ((lev) * (max) / 100)
877 if (machine_is_netwinder() && whichDev
== SOUND_MIXER_PHONEOUT
)
878 whichDev
= SOUND_MIXER_VOLUME
;
881 case SOUND_MIXER_VOLUME
:
885 lev_left
= SCALE(lev_left
, 7) << 1;
886 lev_right
= SCALE(lev_right
, 7) << 1;
889 case SOUND_MIXER_LINE
:
890 if ((devc
->recmask
& SOUND_MASK_LINE
) == 0)
895 lev_left
= SCALE(lev_left
, 31) << 6;
896 lev_right
= SCALE(lev_right
, 31) << 6;
899 case SOUND_MIXER_MIC
:
900 if ((devc
->recmask
& SOUND_MASK_MIC
) == 0)
905 lev_left
= SCALE(lev_left
, 3) << 4;
906 lev_right
= SCALE(lev_right
, 3) << 4;
909 case SOUND_MIXER_RECLEV
:
913 lev_left
= SCALE(lev_left
, 10);
914 lev_right
= SCALE(lev_right
, 10);
917 case SOUND_MIXER_LINE1
:
918 if ((devc
->recmask
& SOUND_MASK_LINE1
) == 0)
923 lev_left
= SCALE(lev_left
, 31) << 1;
924 lev_right
= SCALE(lev_right
, 31) << 1;
927 case SOUND_MIXER_PCM
:
928 waveartist_cmd3(devc
, WACMD_SET_LEVEL
,
929 SCALE(lev_left
, 32767),
930 SCALE(lev_right
, 32767));
933 case SOUND_MIXER_SYNTH
:
934 waveartist_cmd3(devc
, 0x0100 | WACMD_SET_LEVEL
,
935 SCALE(lev_left
, 32767),
936 SCALE(lev_right
, 32767));
943 /* read left setting */
944 vals
[0] = reg_l
+ WACMD_GET_LEVEL
;
945 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 1);
947 /* read right setting */
948 vals
[0] = reg_r
+ 0x30;
949 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 2);
951 vals
[1] = (vals
[1] & ~mask
) | (lev_left
& mask
);
952 vals
[2] = (vals
[2] & ~mask
) | (lev_right
& mask
);
954 /* write left,right back */
955 vals
[0] = WACMD_SET_MIXER
;
956 waveartist_cmd(devc
, 3, vals
, 0, NULL
);
960 waveartist_select_input(wavnc_info
*devc
, unsigned int input
)
962 unsigned int vals
[3];
968 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 1);
971 * Get reg 10, only so that we can write it back.
974 waveartist_cmd(devc
, 1, vals
, 1, vals
+ 2);
976 if (debug_flg
& DEBUG_MIXER
)
977 printk("RECSRC: old left: 0x%04X, old right: 0x%04X.\n",
978 vals
[1] & 0x07, (vals
[1] >> 3) & 0x07);
981 * kill current left/right mux input select
988 * right=mic, left=mic
993 case SOUND_MASK_LINE1
:
995 * right=none, left=Aux1;
1000 case SOUND_MASK_LINE
:
1002 * right=Line, left=Line;
1008 if (debug_flg
& DEBUG_MIXER
)
1009 printk("RECSRC %d: left=0x%04X, right=0x%04X.\n", input
,
1010 vals
[1] & 0x07, (vals
[1] >> 3) & 0x07);
1013 * and finally - write the reg pair back....
1015 vals
[0] = WACMD_SET_MIXER
;
1017 waveartist_cmd(devc
, 3, vals
, 0, NULL
);
1021 waveartist_mixer_set(wavnc_info
*devc
, int whichDev
, unsigned int level
)
1023 unsigned int lev_left
= level
& 0x007f;
1024 unsigned int lev_right
= (level
& 0x7f00) >> 8;
1025 int left
, right
, devmask
;
1027 left
= level
& 0x7f;
1028 right
= (level
& 0x7f00) >> 8;
1030 if (debug_flg
& DEBUG_MIXER
)
1031 printk("wa_mixer_set(dev=%d, level=%X)\n",
1035 case SOUND_MIXER_VOLUME
: /* master volume (0-7) */
1036 case SOUND_MIXER_LINE
: /* external line (0-31) */
1037 case SOUND_MIXER_MIC
: /* mono mic (0-3) */
1038 case SOUND_MIXER_RECLEV
: /* recording level (0-7) */
1039 case SOUND_MIXER_LINE1
: /* mono external aux1 (0-31) */
1040 case SOUND_MIXER_PCM
: /* Waveartist PCM (0-32767) */
1041 case SOUND_MIXER_SYNTH
: /* internal synth (0-31) */
1042 case SOUND_MIXER_IMIX
: /* recording feedback */
1043 devc
->levels
[whichDev
] = lev_left
| lev_right
<< 8;
1044 waveartist_mixer_update(devc
, whichDev
);
1047 /* Select recording input source
1049 case SOUND_MIXER_RECSRC
:
1050 devmask
= level
& devc
->rec_devices
;
1052 #ifdef CONFIG_ARCH_NETWINDER
1053 if (machine_is_netwinder())
1054 vnc_configure_mixer(devc
);
1058 waveartist_select_input(devc
, level
);
1061 * if record monitoring is on, make sure the bit is set
1063 if (devc
->levels
[SOUND_MIXER_IMIX
])
1064 waveartist_mixer_update(devc
, SOUND_MIXER_IMIX
);
1068 * do not save in "levels", return current setting
1070 return devc
->recmask
;
1076 return devc
->levels
[whichDev
];
1080 waveartist_mixer_reset(wavnc_info
*devc
)
1084 if (debug_flg
& DEBUG_MIXER
)
1085 printk("%s: mixer_reset\n", devc
->hw
.name
);
1090 waveartist_cmd1(devc
, WACMD_RST_MIXER
);
1093 * set input for ADC to come from 'quiet'
1094 * turn on default modes
1096 waveartist_cmd3(devc
, WACMD_SET_MIXER
, 0x9800, 0xa836);
1099 * set mixer input select to none, RX filter gains 0 db
1101 waveartist_cmd3(devc
, WACMD_SET_MIXER
, 0x4c00, 0x8c00);
1104 * set bit 0 reg 2 to 1 - unmute MonoOut
1106 waveartist_cmd3(devc
, WACMD_SET_MIXER
, 0x2801, 0x6800);
1108 /* set default input device = internal mic
1109 * current recording device = none
1113 for (i
= 0; i
< SOUND_MIXER_NRDEVICES
; i
++)
1114 waveartist_mixer_update(devc
, i
);
1116 devc
->supported_devices
= SUPPORTED_MIXER_DEVICES
;
1117 devc
->rec_devices
= POSSIBLE_RECORDING_DEVICES
;
1119 if (machine_is_netwinder()) {
1120 devc
->supported_devices
|= SOUND_MASK_PHONEIN
| SOUND_MASK_PHONEOUT
;
1121 devc
->rec_devices
|= SOUND_MASK_PHONEIN
;
1126 waveartist_mixer_ioctl(int dev
, unsigned int cmd
, caddr_t arg
)
1128 wavnc_info
*devc
= (wavnc_info
*)audio_devs
[dev
]->devc
;
1131 #ifdef CONFIG_ARCH_NETWINDER
1132 if (machine_is_netwinder()) {
1133 ret
= vnc_private_ioctl(dev
, cmd
, arg
);
1134 if (ret
!= -ENOIOCTLCMD
)
1139 if (((cmd
>> 8) & 0xff) == 'M') {
1140 if (_SIOC_DIR(cmd
) & _SIOC_WRITE
) {
1143 if (get_user(val
, (int *)arg
))
1146 return waveartist_mixer_set(devc
, cmd
& 0xff, val
);
1151 switch (cmd
& 0xff) {
1152 case SOUND_MIXER_RECSRC
:
1153 ret
= devc
->recmask
;
1156 case SOUND_MIXER_DEVMASK
:
1157 ret
= devc
->supported_devices
;
1160 case SOUND_MIXER_STEREODEVS
:
1161 ret
= devc
->supported_devices
&
1162 ~(SOUND_MASK_SPEAKER
|SOUND_MASK_IMIX
);
1165 case SOUND_MIXER_RECMASK
:
1166 ret
= devc
->rec_devices
;
1169 case SOUND_MIXER_CAPS
:
1170 ret
= SOUND_CAP_EXCL_INPUT
;
1174 if ((cmd
& 0xff) < SOUND_MIXER_NRDEVICES
)
1175 ret
= devc
->levels
[cmd
& 0xff];
1180 return put_user(ret
, (int *)arg
) ? -EFAULT
: 0;
1184 return -ENOIOCTLCMD
;
1187 static struct mixer_operations waveartist_mixer_operations
=
1190 "WaveArtist NetWinder",
1191 waveartist_mixer_ioctl
1195 waveartist_init(wavnc_info
*devc
)
1197 wavnc_port_info
*portc
;
1198 char rev
[3], dev_name
[64];
1201 if (waveartist_reset(devc
))
1204 sprintf(dev_name
, "%s (%s", devc
->hw
.name
, devc
->chip_name
);
1206 if (waveartist_getrev(devc
, rev
)) {
1207 strcat(dev_name
, " rev. ");
1208 strcat(dev_name
, rev
);
1210 strcat(dev_name
, ")");
1212 conf_printf2(dev_name
, devc
->hw
.io_base
, devc
->hw
.irq
,
1213 devc
->hw
.dma
, devc
->hw
.dma2
);
1215 portc
= (wavnc_port_info
*)kmalloc(sizeof(wavnc_port_info
), GFP_KERNEL
);
1219 memset(portc
, 0, sizeof(wavnc_port_info
));
1221 my_dev
= sound_install_audiodrv(AUDIO_DRIVER_VERSION
, dev_name
,
1222 &waveartist_audio_driver
, sizeof(struct audio_driver
),
1223 devc
->audio_flags
, AFMT_U8
| AFMT_S16_LE
| AFMT_S8
,
1224 devc
, devc
->hw
.dma
, devc
->hw
.dma2
);
1229 audio_devs
[my_dev
]->portc
= portc
;
1231 waveartist_mixer_reset(devc
);
1234 * clear any pending interrupt
1236 waveartist_iack(devc
);
1238 if (request_irq(devc
->hw
.irq
, waveartist_intr
, 0, devc
->hw
.name
, devc
) < 0) {
1239 printk(KERN_ERR
"%s: IRQ %d in use\n",
1240 devc
->hw
.name
, devc
->hw
.irq
);
1244 if (sound_alloc_dma(devc
->hw
.dma
, devc
->hw
.name
)) {
1245 printk(KERN_ERR
"%s: Can't allocate DMA%d\n",
1246 devc
->hw
.name
, devc
->hw
.dma
);
1250 if (devc
->hw
.dma
!= devc
->hw
.dma2
&& devc
->hw
.dma2
!= NO_DMA
)
1251 if (sound_alloc_dma(devc
->hw
.dma2
, devc
->hw
.name
)) {
1252 printk(KERN_ERR
"%s: can't allocate DMA%d\n",
1253 devc
->hw
.name
, devc
->hw
.dma2
);
1257 waveartist_set_ctlr(&devc
->hw
, 0, DMA1_IE
| DMA0_IE
);
1259 audio_devs
[my_dev
]->mixer_dev
=
1260 sound_install_mixer(MIXER_DRIVER_VERSION
,
1262 &waveartist_mixer_operations
,
1263 sizeof(struct mixer_operations
),
1269 sound_free_dma(devc
->hw
.dma
);
1272 free_irq(devc
->hw
.irq
, devc
);
1275 sound_unload_audiodev(my_dev
);
1284 static int __init
probe_waveartist(struct address_info
*hw_config
)
1286 wavnc_info
*devc
= &adev_info
[nr_waveartist_devs
];
1288 if (nr_waveartist_devs
>= MAX_AUDIO_DEV
) {
1289 printk(KERN_WARNING
"waveartist: too many audio devices\n");
1293 if (check_region(hw_config
->io_base
, 15)) {
1294 printk(KERN_WARNING
"WaveArtist: I/O port conflict\n");
1298 if (hw_config
->irq
> _ISA_IRQ(15) || hw_config
->irq
< _ISA_IRQ(0)) {
1299 printk(KERN_WARNING
"WaveArtist: Bad IRQ %d\n",
1304 if (hw_config
->dma
!= _ISA_DMA(3)) {
1305 printk(KERN_WARNING
"WaveArtist: Bad DMA %d\n",
1310 hw_config
->name
= "WaveArtist";
1311 devc
->hw
= *hw_config
;
1312 devc
->open_mode
= 0;
1313 devc
->chip_name
= "RWA-010";
1318 static void __init
attach_waveartist(struct address_info
*hw
)
1320 wavnc_info
*devc
= &adev_info
[nr_waveartist_devs
];
1323 * NOTE! If irq < 0, there is another driver which has allocated the
1324 * IRQ so that this driver doesn't need to allocate/deallocate it.
1325 * The actually used IRQ is ABS(irq).
1328 devc
->hw
.irq
= (hw
->irq
> 0) ? hw
->irq
: 0;
1329 devc
->open_mode
= 0;
1330 devc
->playback_dev
= 0;
1331 devc
->record_dev
= 0;
1332 devc
->audio_flags
= DMA_AUTOMODE
;
1333 devc
->levels
= levels
;
1335 if (hw
->dma
!= hw
->dma2
&& hw
->dma2
!= NO_DMA
)
1336 devc
->audio_flags
|= DMA_DUPLEX
;
1338 request_region(hw
->io_base
, 15, devc
->hw
.name
);
1340 devc
->dev_no
= waveartist_init(devc
);
1342 if (devc
->dev_no
< 0)
1343 release_region(hw
->io_base
, 15);
1345 #ifdef CONFIG_ARCH_NETWINDER
1346 if (machine_is_netwinder()) {
1347 init_timer(&vnc_timer
);
1348 vnc_timer
.function
= vnc_slider_tick
;
1349 vnc_timer
.expires
= jiffies
;
1350 vnc_timer
.data
= nr_waveartist_devs
;
1351 add_timer(&vnc_timer
);
1353 vnc_configure_mixer(devc
);
1356 nr_waveartist_devs
+= 1;
1360 static void __exit
unload_waveartist(struct address_info
*hw
)
1362 wavnc_info
*devc
= NULL
;
1365 for (i
= 0; i
< nr_waveartist_devs
; i
++)
1366 if (hw
->io_base
== adev_info
[i
].hw
.io_base
) {
1367 devc
= adev_info
+ i
;
1374 #ifdef CONFIG_ARCH_NETWINDER
1375 if (machine_is_netwinder())
1376 del_timer(&vnc_timer
);
1379 release_region(devc
->hw
.io_base
, 15);
1381 waveartist_set_ctlr(&devc
->hw
, DMA1_IE
|DMA0_IE
, 0);
1383 if (devc
->hw
.irq
>= 0)
1384 free_irq(devc
->hw
.irq
, devc
);
1386 sound_free_dma(devc
->hw
.dma
);
1388 if (devc
->hw
.dma
!= devc
->hw
.dma2
&&
1389 devc
->hw
.dma2
!= NO_DMA
)
1390 sound_free_dma(devc
->hw
.dma2
);
1392 mixer
= audio_devs
[devc
->dev_no
]->mixer_dev
;
1395 sound_unload_mixerdev(mixer
);
1397 if (devc
->dev_no
>= 0)
1398 sound_unload_audiodev(devc
->dev_no
);
1400 nr_waveartist_devs
-= 1;
1402 for (; i
< nr_waveartist_devs
; i
++)
1403 adev_info
[i
] = adev_info
[i
+ 1];
1405 printk(KERN_WARNING
"waveartist: can't find device "
1410 * Rebel.com Netwinder specifics...
1413 #define VNC_TIMER_PERIOD (HZ/4) //check slider 4 times/sec
1415 #define MIXER_PRIVATE3_RESET 0x53570000
1416 #define MIXER_PRIVATE3_READ 0x53570001
1417 #define MIXER_PRIVATE3_WRITE 0x53570002
1419 #define VNC_MUTE_INTERNAL_SPKR 0x01 //the sw mute on/off control bit
1420 #define VNC_MUTE_LINE_OUT 0x10
1421 #define VNC_PHONE_DETECT 0x20
1422 #define VNC_HANDSET_DETECT 0x40
1423 #define VNC_DISABLE_AUTOSWITCH 0x80
1425 extern spinlock_t gpio_lock
;
1428 vnc_update_spkr_mute(wavnc_info
*devc
)
1430 unsigned long flags
;
1432 spin_lock_irqsave(&gpio_lock
, flags
);
1433 cpld_modify(CPLD_UNMUTE
, devc
->spkr_mute_state
? 0 : CPLD_UNMUTE
);
1434 spin_unlock_irqrestore(&gpio_lock
, flags
);
1438 vnc_mute_lout(wavnc_info
*devc
, int mute
)
1443 vnc_volume_slider(wavnc_info
*devc
)
1445 static signed int old_slider_volume
;
1446 unsigned long flags
;
1447 signed int volume
= 255;
1449 *CSR_TIMER1_LOAD
= 0x00ffffff;
1455 *CSR_TIMER1_CNTL
= TIMER_CNTL_ENABLE
| TIMER_CNTL_DIV1
;
1457 while (volume
&& (inb(0x201) & 0x01))
1460 *CSR_TIMER1_CNTL
= 0;
1462 restore_flags(flags
);
1464 volume
= 0x00ffffff - *CSR_TIMER1_VALUE
;
1468 volume
= 150 - (volume
>> 5);
1470 volume
= (volume
>> 6) - 25;
1480 * slider quite often reads +-8, so debounce this random noise
1482 if (abs(volume
- old_slider_volume
) > 7) {
1483 old_slider_volume
= volume
;
1485 if (debug_flg
& DEBUG_MIXER
)
1486 printk(KERN_DEBUG
"Slider volume: %d.\n", volume
);
1489 return old_slider_volume
;
1493 vnc_configure_mixer(wavnc_info
*devc
)
1497 if (!devc
->no_autoselect
) {
1498 if (devc
->handset_detect
) {
1499 devc
->recmask
= SOUND_MASK_LINE1
;
1500 devc
->spkr_mute_state
= devc
->line_mute_state
= 1;
1501 } else if (devc
->telephone_detect
) {
1502 devc
->recmask
= SOUND_MASK_PHONEIN
;
1503 devc
->spkr_mute_state
= devc
->line_mute_state
= 1;
1505 /* unless someone has asked for LINE-IN,
1508 if ((devc
->recmask
& SOUND_MASK_LINE
) == 0)
1509 devc
->recmask
= SOUND_MASK_MIC
;
1510 devc
->spkr_mute_state
= devc
->line_mute_state
= 0;
1512 vnc_update_spkr_mute(devc
);
1513 vnc_mute_lout(devc
, devc
->spkr_mute_state
);
1516 /* Ok. At this point, we have done the autoswitch logic, or we
1517 * have had a command from an ioctl. We have a valid devc->recmask.
1518 * Now we have to connect up the hardware to reflect the recmask.
1520 vals
[1] = waveartist_cmd1_r(devc
, WACMD_GET_LEVEL
| 0x800);
1521 vals
[2] = waveartist_cmd1_r(devc
, WACMD_GET_LEVEL
| 0x900);
1525 switch(devc
->recmask
) {
1526 case SOUND_MASK_MIC
: /* builtin mic */
1527 waveartist_cmd1(devc
, WACMD_SET_MONO
| 0x100); /* right */
1531 case SOUND_MASK_LINE1
: /* out handset */
1532 waveartist_cmd1(devc
, WACMD_SET_MONO
); /* left */
1536 case SOUND_MASK_PHONEIN
: /* our telephone mic */
1537 waveartist_cmd1(devc
, WACMD_SET_MONO
); /* left */
1541 case SOUND_MASK_LINE
: /* stereo line in */
1549 vals
[0] = WACMD_SET_MIXER
;
1550 waveartist_cmd(devc
, 3, vals
, 0, NULL
);
1552 waveartist_mixer_update(devc
, SOUND_MIXER_IMIX
);
1556 vnc_slider(wavnc_info
*devc
)
1558 signed int slider_volume
;
1559 unsigned int temp
, old_hs
, old_td
;
1562 * read the "buttons" state.
1563 * Bit 4 = handset present,
1566 temp
= inb(0x201) & 0x30;
1568 old_hs
= devc
->handset_detect
;
1569 old_td
= devc
->telephone_detect
;
1571 devc
->handset_detect
= !(temp
& 0x10);
1572 devc
->telephone_detect
= !!(temp
& 0x20);
1574 if (!devc
->no_autoselect
&&
1575 (old_hs
!= devc
->handset_detect
||
1576 old_td
!= devc
->telephone_detect
))
1577 vnc_configure_mixer(devc
);
1579 slider_volume
= vnc_volume_slider(devc
);
1582 * If we're using software controlled volume, and
1583 * the slider moves by more than 20%, then we
1584 * switch back to slider controlled volume.
1586 if (abs(devc
->slider_vol
- slider_volume
) > 20)
1587 devc
->use_slider
= 1;
1590 * use only left channel
1592 temp
= levels
[SOUND_MIXER_VOLUME
] & 0xFF;
1594 if (slider_volume
!= temp
&& devc
->use_slider
) {
1595 devc
->slider_vol
= slider_volume
;
1597 waveartist_mixer_set(devc
, SOUND_MIXER_VOLUME
,
1598 slider_volume
| slider_volume
<< 8);
1607 vnc_slider_tick(unsigned long data
)
1611 if (vnc_slider(adev_info
+ data
))
1612 next_timeout
= 5; // mixer reported change
1614 next_timeout
= VNC_TIMER_PERIOD
;
1616 mod_timer(&vnc_timer
, jiffies
+ next_timeout
);
1620 vnc_private_ioctl(int dev
, unsigned int cmd
, caddr_t arg
)
1622 wavnc_info
*devc
= (wavnc_info
*)audio_devs
[dev
]->devc
;
1626 case SOUND_MIXER_PRIVATE1
:
1628 u_int prev_spkr_mute
, prev_line_mute
, prev_auto_state
;
1631 get_user_ret(val
, (int *)arg
, -EFAULT
);
1633 /* check if parameter is logical */
1634 if (val
& ~(VNC_MUTE_INTERNAL_SPKR
|
1636 VNC_DISABLE_AUTOSWITCH
))
1639 prev_auto_state
= devc
->no_autoselect
;
1640 prev_spkr_mute
= devc
->spkr_mute_state
;
1641 prev_line_mute
= devc
->line_mute_state
;
1643 devc
->no_autoselect
= (val
& VNC_DISABLE_AUTOSWITCH
) ? 1 : 0;
1644 devc
->spkr_mute_state
= (val
& VNC_MUTE_INTERNAL_SPKR
) ? 1 : 0;
1645 devc
->line_mute_state
= (val
& VNC_MUTE_LINE_OUT
) ? 1 : 0;
1647 if (prev_spkr_mute
!= devc
->spkr_mute_state
)
1648 vnc_update_spkr_mute(devc
);
1650 if (prev_line_mute
!= devc
->line_mute_state
)
1651 vnc_mute_lout(devc
, devc
->line_mute_state
);
1653 if (prev_auto_state
!= devc
->no_autoselect
)
1654 vnc_configure_mixer(devc
);
1659 case SOUND_MIXER_PRIVATE2
:
1660 get_user_ret(val
, (int *)arg
, -EFAULT
);
1663 #define VNC_SOUND_PAUSE 0x53 //to pause the DSP
1664 #define VNC_SOUND_RESUME 0x57 //to unpause the DSP
1665 case VNC_SOUND_PAUSE
:
1666 waveartist_cmd1(devc
, 0x16);
1669 case VNC_SOUND_RESUME
:
1670 waveartist_cmd1(devc
, 0x18);
1678 /* private ioctl to allow bulk access to waveartist */
1679 case SOUND_MIXER_PRIVATE3
:
1681 unsigned long flags
;
1682 int mixer_reg
[15], i
, val
;
1684 get_user_ret(val
, (int *)arg
, -EFAULT
);
1685 copy_from_user_ret(mixer_reg
, (void *)val
, sizeof(mixer_reg
), -EFAULT
);
1687 switch (mixer_reg
[14]) {
1688 case MIXER_PRIVATE3_RESET
:
1689 waveartist_mixer_reset(devc
);
1692 case MIXER_PRIVATE3_WRITE
:
1693 waveartist_cmd3(devc
, WACMD_SET_MIXER
, mixer_reg
[0], mixer_reg
[4]);
1694 waveartist_cmd3(devc
, WACMD_SET_MIXER
, mixer_reg
[1], mixer_reg
[5]);
1695 waveartist_cmd3(devc
, WACMD_SET_MIXER
, mixer_reg
[2], mixer_reg
[6]);
1696 waveartist_cmd3(devc
, WACMD_SET_MIXER
, mixer_reg
[3], mixer_reg
[7]);
1697 waveartist_cmd3(devc
, WACMD_SET_MIXER
, mixer_reg
[8], mixer_reg
[9]);
1699 waveartist_cmd3(devc
, WACMD_SET_LEVEL
, mixer_reg
[10], mixer_reg
[11]);
1700 waveartist_cmd3(devc
, WACMD_SET_LEVEL
, mixer_reg
[12], mixer_reg
[13]);
1703 case MIXER_PRIVATE3_READ
:
1704 spin_lock_irqsave(&waveartist_lock
, flags
);
1706 for (i
= 0x30; i
< 14 << 8; i
+= 1 << 8)
1707 waveartist_cmd(devc
, 1, &i
, 1, mixer_reg
+ (i
>> 8));
1709 spin_unlock_irqrestore(&waveartist_lock
, flags
);
1711 copy_to_user_ret((void *)val
, mixer_reg
, sizeof(mixer_reg
), -EFAULT
);
1720 /* read back the state from PRIVATE1 */
1721 case SOUND_MIXER_PRIVATE4
:
1722 val
= (devc
->spkr_mute_state
? VNC_MUTE_INTERNAL_SPKR
: 0) |
1723 (devc
->line_mute_state
? VNC_MUTE_LINE_OUT
: 0) |
1724 (devc
->handset_detect
? VNC_HANDSET_DETECT
: 0) |
1725 (devc
->telephone_detect
? VNC_PHONE_DETECT
: 0) |
1726 (devc
->no_autoselect
? VNC_DISABLE_AUTOSWITCH
: 0);
1728 return put_user(val
, (int *)arg
) ? -EFAULT
: 0;
1731 if (((cmd
>> 8) & 0xff) == 'M') {
1732 if (_SIOC_DIR(cmd
) & _SIOC_WRITE
) {
1734 * special case for master volume: if we
1735 * received this call - switch from hw
1736 * volume control to a software volume
1737 * control, till the hw volume is modified
1738 * to signal that user wants to be back in
1741 if ((cmd
& 0xff) == SOUND_MIXER_VOLUME
)
1742 devc
->use_slider
= 0;
1743 } else if ((cmd
& 0xff) == SOUND_MIXER_STEREODEVS
) {
1744 val
= devc
->supported_devices
&
1748 SOUND_MASK_PHONEIN
|
1749 SOUND_MASK_PHONEOUT
);
1750 return put_user(val
, (int *)arg
) ? -EFAULT
: 0;
1754 return -ENOIOCTLCMD
;
1757 static struct address_info cfg
;
1759 static int attached
;
1761 static int __initdata io
;
1762 static int __initdata irq
;
1763 static int __initdata dma
;
1764 static int __initdata dma2
;
1767 MODULE_PARM(io
, "i"); /* IO base */
1768 MODULE_PARM(irq
, "i"); /* IRQ */
1769 MODULE_PARM(dma
, "i"); /* DMA */
1770 MODULE_PARM(dma2
, "i"); /* DMA2 */
1772 static int __init
init_waveartist(void)
1774 if (!io
&& machine_is_netwinder()) {
1776 * The NetWinder WaveArtist is at a fixed address.
1777 * If the user does not supply an address, use the
1778 * well-known parameters.
1791 if (!probe_waveartist(&cfg
))
1794 attach_waveartist(&cfg
);
1801 static void __exit
cleanup_waveartist(void)
1805 unload_waveartist(&cfg
);
1809 module_init(init_waveartist
);
1810 module_exit(cleanup_waveartist
);
1813 static int __init
setup_waveartist(char *str
)
1815 /* io, irq, dma, dma2 */
1818 str
= get_options(str
, ARRAY_SIZE(ints
), ints
);
1827 __setup("waveartist=", setup_waveartist
);