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 LRESULT OSS_AuxInit(void)
57 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
58 WARN("mixer device not available !\n");
67 /*-----------------------------------------------------------------------*/
69 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};
83 TRACE("(%04X, %p, %u);\n", wDevID, lpCaps, dwSize);
84 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
85 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
86 WARN("mixer device not available !\n");
87 return MMSYSERR_NOTENABLED;
89 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
91 WARN("unable to read mixer !\n");
92 return MMSYSERR_NOTENABLED;
97 lpCaps->vDriverVersion = 0x0100;
98 strcpyW(lpCaps->szPname, ini);
99 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
100 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
102 return MMSYSERR_NOERROR;
106 /**************************************************************************
107 * AUX_GetVolume [internal]
109 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
111 int mixer, volume, left, right, cmd;
113 TRACE("(%04X, %p);\n", wDevID, lpdwVol);
114 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
115 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
116 WARN("mixer device not available !\n");
117 return MMSYSERR_NOTENABLED;
121 TRACE("SOUND_MIXER_READ_PCM !\n");
122 cmd = SOUND_MIXER_READ_PCM;
125 TRACE("SOUND_MIXER_READ_SYNTH !\n");
126 cmd = SOUND_MIXER_READ_SYNTH;
129 TRACE("SOUND_MIXER_READ_CD !\n");
130 cmd = SOUND_MIXER_READ_CD;
133 TRACE("SOUND_MIXER_READ_LINE !\n");
134 cmd = SOUND_MIXER_READ_LINE;
137 TRACE("SOUND_MIXER_READ_MIC !\n");
138 cmd = SOUND_MIXER_READ_MIC;
141 TRACE("SOUND_MIXER_READ_VOLUME !\n");
142 cmd = SOUND_MIXER_READ_VOLUME;
145 WARN("invalid device id=%04X !\n", wDevID);
147 return MMSYSERR_NOTENABLED;
149 if (ioctl(mixer, cmd, &volume) == -1) {
150 WARN("unable to read mixer !\n");
152 return MMSYSERR_NOTENABLED;
155 left = LOBYTE(LOWORD(volume));
156 right = HIBYTE(LOWORD(volume));
157 TRACE("left=%d right=%d !\n", left, right);
158 *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
159 return MMSYSERR_NOERROR;
162 /**************************************************************************
163 * AUX_SetVolume [internal]
165 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
168 int volume, left, right;
171 TRACE("(%04X, %08X);\n", wDevID, dwParam);
173 left = (LOWORD(dwParam) * 100) >> 16;
174 right = (HIWORD(dwParam) * 100) >> 16;
175 volume = (right << 8) | left;
177 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
178 WARN("mixer device not available !\n");
179 return MMSYSERR_NOTENABLED;
184 TRACE("SOUND_MIXER_WRITE_PCM !\n");
185 cmd = SOUND_MIXER_WRITE_PCM;
188 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
189 cmd = SOUND_MIXER_WRITE_SYNTH;
192 TRACE("SOUND_MIXER_WRITE_CD !\n");
193 cmd = SOUND_MIXER_WRITE_CD;
196 TRACE("SOUND_MIXER_WRITE_LINE !\n");
197 cmd = SOUND_MIXER_WRITE_LINE;
200 TRACE("SOUND_MIXER_WRITE_MIC !\n");
201 cmd = SOUND_MIXER_WRITE_MIC;
204 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
205 cmd = SOUND_MIXER_WRITE_VOLUME;
208 WARN("invalid device id=%04X !\n", wDevID);
210 return MMSYSERR_NOTENABLED;
212 if (ioctl(mixer, cmd, &volume) == -1) {
213 WARN("unable to set mixer !\n");
215 return MMSYSERR_NOTENABLED;
218 return MMSYSERR_NOERROR;
223 /**************************************************************************
224 * auxMessage (WINEOSS.2)
226 DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
227 DWORD_PTR dwParam1, DWORD_PTR dwParam2)
229 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
230 wDevID, wMsg, dwUser, dwParam1, dwParam2);
238 /* FIXME: Pretend this is supported */
240 case AUXDM_GETDEVCAPS:
241 return AUX_GetDevCaps(wDevID, (LPAUXCAPSW)dwParam1, dwParam2);
242 case AUXDM_GETNUMDEVS:
243 TRACE("return %d;\n", NumDev);
245 case AUXDM_GETVOLUME:
246 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
247 case AUXDM_SETVOLUME:
248 return AUX_SetVolume(wDevID, dwParam1);
250 WARN("unknown message !\n");
252 return MMSYSERR_NOTSUPPORTED;
254 return MMSYSERR_NOTENABLED;