2 * Sample AUXILIARY Wine Driver
4 * Copyright 1994 Martin Ayotte
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
31 #ifdef HAVE_SYS_IOCTL_H
32 # include <sys/ioctl.h>
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(mmaux
);
46 #define MIXER_DEV "/dev/mixer"
48 static int NumDev
= 6;
50 /*-----------------------------------------------------------------------*/
52 static LRESULT
OSS_AuxInit(void)
57 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
58 WARN("mixer device not available !\n");
67 /*-----------------------------------------------------------------------*/
69 static LRESULT
OSS_AuxExit(void)
75 /**************************************************************************
76 * AUX_GetDevCaps [internal]
78 static DWORD
AUX_GetDevCaps(WORD wDevID
, LPAUXCAPSW lpCaps
, DWORD dwSize
)
81 static const WCHAR ini
[] = {'O','S','S',' ','A','u','x',' ','#','0',0};
83 TRACE("(%04X, %p, %u);\n", wDevID
, lpCaps
, dwSize
);
84 if (lpCaps
== NULL
) return MMSYSERR_NOTENABLED
;
85 if (wDevID
>= NumDev
) return MMSYSERR_BADDEVICEID
;
86 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
87 WARN("mixer device not available !\n");
88 return MMSYSERR_NOTENABLED
;
90 if (ioctl(mixer
, SOUND_MIXER_READ_LINE
, &volume
) == -1) {
92 WARN("unable to read mixer !\n");
93 return MMSYSERR_NOTENABLED
;
97 lpCaps
->wPid
= 0x55 + wDevID
;
98 lpCaps
->vDriverVersion
= 0x0100;
99 strcpyW(lpCaps
->szPname
, ini
);
100 lpCaps
->szPname
[9] = '0' + wDevID
; /* 6 at max */
101 lpCaps
->wTechnology
= wDevID
== 2 ? AUXCAPS_CDAUDIO
: AUXCAPS_AUXIN
;
102 lpCaps
->dwSupport
= AUXCAPS_VOLUME
| AUXCAPS_LRVOLUME
;
104 return MMSYSERR_NOERROR
;
108 /**************************************************************************
109 * AUX_GetVolume [internal]
111 static DWORD
AUX_GetVolume(WORD wDevID
, LPDWORD lpdwVol
)
113 int mixer
, volume
, left
, right
, cmd
;
115 TRACE("(%04X, %p);\n", wDevID
, lpdwVol
);
116 if (lpdwVol
== NULL
) return MMSYSERR_NOTENABLED
;
117 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
118 WARN("mixer device not available !\n");
119 return MMSYSERR_NOTENABLED
;
123 TRACE("SOUND_MIXER_READ_PCM !\n");
124 cmd
= SOUND_MIXER_READ_PCM
;
127 TRACE("SOUND_MIXER_READ_SYNTH !\n");
128 cmd
= SOUND_MIXER_READ_SYNTH
;
131 TRACE("SOUND_MIXER_READ_CD !\n");
132 cmd
= SOUND_MIXER_READ_CD
;
135 TRACE("SOUND_MIXER_READ_LINE !\n");
136 cmd
= SOUND_MIXER_READ_LINE
;
139 TRACE("SOUND_MIXER_READ_MIC !\n");
140 cmd
= SOUND_MIXER_READ_MIC
;
143 TRACE("SOUND_MIXER_READ_VOLUME !\n");
144 cmd
= SOUND_MIXER_READ_VOLUME
;
147 WARN("invalid device id=%04X !\n", wDevID
);
149 return MMSYSERR_NOTENABLED
;
151 if (ioctl(mixer
, cmd
, &volume
) == -1) {
152 WARN("unable to read mixer !\n");
154 return MMSYSERR_NOTENABLED
;
157 left
= LOBYTE(LOWORD(volume
));
158 right
= HIBYTE(LOWORD(volume
));
159 TRACE("left=%d right=%d !\n", left
, right
);
160 *lpdwVol
= MAKELONG((left
* 0xFFFFL
) / 100, (right
* 0xFFFFL
) / 100);
161 return MMSYSERR_NOERROR
;
164 /**************************************************************************
165 * AUX_SetVolume [internal]
167 static DWORD
AUX_SetVolume(WORD wDevID
, DWORD dwParam
)
170 int volume
, left
, right
;
173 TRACE("(%04X, %08X);\n", wDevID
, dwParam
);
175 left
= (LOWORD(dwParam
) * 100) >> 16;
176 right
= (HIWORD(dwParam
) * 100) >> 16;
177 volume
= (right
<< 8) | left
;
179 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
180 WARN("mixer device not available !\n");
181 return MMSYSERR_NOTENABLED
;
186 TRACE("SOUND_MIXER_WRITE_PCM !\n");
187 cmd
= SOUND_MIXER_WRITE_PCM
;
190 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
191 cmd
= SOUND_MIXER_WRITE_SYNTH
;
194 TRACE("SOUND_MIXER_WRITE_CD !\n");
195 cmd
= SOUND_MIXER_WRITE_CD
;
198 TRACE("SOUND_MIXER_WRITE_LINE !\n");
199 cmd
= SOUND_MIXER_WRITE_LINE
;
202 TRACE("SOUND_MIXER_WRITE_MIC !\n");
203 cmd
= SOUND_MIXER_WRITE_MIC
;
206 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
207 cmd
= SOUND_MIXER_WRITE_VOLUME
;
210 WARN("invalid device id=%04X !\n", wDevID
);
212 return MMSYSERR_NOTENABLED
;
214 if (ioctl(mixer
, cmd
, &volume
) == -1) {
215 WARN("unable to set mixer !\n");
217 return MMSYSERR_NOTENABLED
;
220 return MMSYSERR_NOERROR
;
225 /**************************************************************************
226 * auxMessage (WINEOSS.2)
228 DWORD WINAPI
OSS_auxMessage(UINT wDevID
, UINT wMsg
, DWORD_PTR dwUser
,
229 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
231 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
232 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
237 return OSS_AuxInit();
239 return OSS_AuxExit();
242 /* FIXME: Pretend this is supported */
244 case AUXDM_GETDEVCAPS
:
245 return AUX_GetDevCaps(wDevID
, (LPAUXCAPSW
)dwParam1
, dwParam2
);
246 case AUXDM_GETNUMDEVS
:
247 TRACE("return %d;\n", NumDev
);
249 case AUXDM_GETVOLUME
:
250 return AUX_GetVolume(wDevID
, (LPDWORD
)dwParam1
);
251 case AUXDM_SETVOLUME
:
252 return AUX_SetVolume(wDevID
, dwParam1
);
254 WARN("unknown message !\n");
256 return MMSYSERR_NOTSUPPORTED
;
258 return MMSYSERR_NOTENABLED
;