2 * Sample AUXILARY Wine Driver
4 * Copyright 1994 Martin Ayotte
12 #include <sys/ioctl.h>
19 #ifdef HAVE_SYS_SOUNDCARD_H
20 # include <sys/soundcard.h>
22 #ifdef HAVE_MACHINE_SOUNDCARD_H
23 # include <machine/soundcard.h>
26 #define MIXER_DEV "/dev/mixer"
29 #define IOCTL(a,b,c) ioctl(a,b,&c)
31 #define IOCTL(a,b,c) (c = ioctl(a,b,c) )
35 static int NumDev
= 6;
37 /*-----------------------------------------------------------------------*/
40 /**************************************************************************
41 * AUX_GetDevCaps [internal]
43 static DWORD
AUX_GetDevCaps(WORD wDevID
, LPAUXCAPS16 lpCaps
, DWORD dwSize
)
48 TRACE(mmaux
,"(%04X, %p, %lu);\n", wDevID
, lpCaps
, dwSize
);
49 if (lpCaps
== NULL
) return MMSYSERR_NOTENABLED
;
50 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
51 WARN(mmaux
, "mixer device not available !\n");
52 return MMSYSERR_NOTENABLED
;
54 if (ioctl(mixer
, SOUND_MIXER_READ_LINE
, &volume
) == -1) {
56 WARN(mmaux
, "unable read mixer !\n");
57 return MMSYSERR_NOTENABLED
;
61 lpCaps
->wMid
= 0x0002;
62 lpCaps
->vDriverVersion
= 0x0200;
63 lpCaps
->dwSupport
= AUXCAPS_VOLUME
| AUXCAPS_LRVOLUME
;
66 lpCaps
->wPid
= 0x0196;
67 strcpy(lpCaps
->szPname
, "SB16 Aux: Wave");
68 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
71 lpCaps
->wPid
= 0x0197;
72 strcpy(lpCaps
->szPname
, "SB16 Aux: Midi Synth");
73 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
76 lpCaps
->wPid
= 0x0191;
77 strcpy(lpCaps
->szPname
, "SB16 Aux: CD");
78 lpCaps
->wTechnology
= AUXCAPS_CDAUDIO
;
81 lpCaps
->wPid
= 0x0192;
82 strcpy(lpCaps
->szPname
, "SB16 Aux: Line-In");
83 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
86 lpCaps
->wPid
= 0x0193;
87 strcpy(lpCaps
->szPname
, "SB16 Aux: Mic");
88 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
91 lpCaps
->wPid
= 0x0194;
92 strcpy(lpCaps
->szPname
, "SB16 Aux: Master");
93 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
99 lpCaps
->vDriverVersion
= 0x0100;
100 strcpy(lpCaps
->szPname
, "Generic Linux Auxiliary Driver");
101 lpCaps
->wTechnology
= AUXCAPS_CDAUDIO
;
102 lpCaps
->dwSupport
= AUXCAPS_VOLUME
| AUXCAPS_LRVOLUME
;
104 return MMSYSERR_NOERROR
;
106 return MMSYSERR_NOTENABLED
;
111 /**************************************************************************
112 * AUX_GetVolume [internal]
114 static DWORD
AUX_GetVolume(WORD wDevID
, LPDWORD lpdwVol
)
117 int mixer
,volume
,left
,right
,cmd
;
119 TRACE(mmaux
,"(%04X, %p);\n", wDevID
, lpdwVol
);
120 if (lpdwVol
== NULL
) return MMSYSERR_NOTENABLED
;
121 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
122 WARN(mmaux
, "mixer device not available !\n");
123 return MMSYSERR_NOTENABLED
;
127 TRACE(mmaux
,"SOUND_MIXER_READ_PCM !\n");
128 cmd
= SOUND_MIXER_READ_PCM
;
131 TRACE(mmaux
,"SOUND_MIXER_READ_SYNTH !\n");
132 cmd
= SOUND_MIXER_READ_SYNTH
;
135 TRACE(mmaux
,"SOUND_MIXER_READ_CD !\n");
136 cmd
= SOUND_MIXER_READ_CD
;
139 TRACE(mmaux
,"SOUND_MIXER_READ_LINE !\n");
140 cmd
= SOUND_MIXER_READ_LINE
;
143 TRACE(mmaux
,"SOUND_MIXER_READ_MIC !\n");
144 cmd
= SOUND_MIXER_READ_MIC
;
147 TRACE(mmaux
,"SOUND_MIXER_READ_VOLUME !\n");
148 cmd
= SOUND_MIXER_READ_VOLUME
;
151 WARN(mmaux
, "invalid device id=%04X !\n", wDevID
);
152 return MMSYSERR_NOTENABLED
;
154 if (ioctl(mixer
, cmd
, &volume
) == -1) {
155 WARN(mmaux
, "unable read mixer !\n");
156 return MMSYSERR_NOTENABLED
;
159 left
= volume
& 0x7F;
160 right
= (volume
>> 8) & 0x7F;
161 TRACE(mmaux
,"left=%d right=%d !\n", left
, right
);
162 *lpdwVol
= MAKELONG(left
<< 9, right
<< 9);
163 return MMSYSERR_NOERROR
;
165 return MMSYSERR_NOTENABLED
;
169 /**************************************************************************
170 * AUX_SetVolume [internal]
172 static DWORD
AUX_SetVolume(WORD wDevID
, DWORD dwParam
)
178 TRACE(mmaux
,"(%04X, %08lX);\n", wDevID
, dwParam
);
179 volume
= (LOWORD(dwParam
) >> 9 & 0x7F) +
180 ((HIWORD(dwParam
) >> 9 & 0x7F) << 8);
181 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
182 WARN(mmaux
, "mixer device not available !\n");
183 return MMSYSERR_NOTENABLED
;
187 TRACE(mmaux
,"SOUND_MIXER_WRITE_PCM !\n");
188 cmd
= SOUND_MIXER_WRITE_PCM
;
191 TRACE(mmaux
,"SOUND_MIXER_WRITE_SYNTH !\n");
192 cmd
= SOUND_MIXER_WRITE_SYNTH
;
195 TRACE(mmaux
,"SOUND_MIXER_WRITE_CD !\n");
196 cmd
= SOUND_MIXER_WRITE_CD
;
199 TRACE(mmaux
,"SOUND_MIXER_WRITE_LINE !\n");
200 cmd
= SOUND_MIXER_WRITE_LINE
;
203 TRACE(mmaux
,"SOUND_MIXER_WRITE_MIC !\n");
204 cmd
= SOUND_MIXER_WRITE_MIC
;
207 TRACE(mmaux
,"SOUND_MIXER_WRITE_VOLUME !\n");
208 cmd
= SOUND_MIXER_WRITE_VOLUME
;
211 WARN(mmaux
,"invalid device id=%04X !\n", wDevID
);
212 return MMSYSERR_NOTENABLED
;
214 if (ioctl(mixer
, cmd
, &volume
) == -1) {
215 WARN(mmaux
, "unable set mixer !\n");
216 return MMSYSERR_NOTENABLED
;
219 return MMSYSERR_NOERROR
;
221 return MMSYSERR_NOTENABLED
;
226 /**************************************************************************
227 * auxMessage [sample driver]
229 DWORD WINAPI
auxMessage(WORD wDevID
, WORD wMsg
, DWORD dwUser
,
230 DWORD dwParam1
, DWORD dwParam2
)
232 TRACE(mmaux
,"(%04X, %04X, %08lX, %08lX, %08lX);\n",
233 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
235 case AUXDM_GETDEVCAPS
:
236 return AUX_GetDevCaps(wDevID
,(LPAUXCAPS16
)dwParam1
,dwParam2
);
237 case AUXDM_GETNUMDEVS
:
238 TRACE(mmaux
,"return %d;\n", NumDev
);
240 case AUXDM_GETVOLUME
:
241 return AUX_GetVolume(wDevID
,(LPDWORD
)dwParam1
);
242 case AUXDM_SETVOLUME
:
243 return AUX_SetVolume(wDevID
,dwParam1
);
245 WARN(mmaux
, "unknown message !\n");
247 return MMSYSERR_NOTSUPPORTED
;