2 * Sample AUXILARY 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 int AUXDRV_Init(void)
56 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
57 WARN("mixer device not available !\n");
66 /**************************************************************************
67 * AUX_GetDevCaps [internal]
69 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPSW lpCaps, DWORD dwSize)
72 static const WCHAR ini[] = {'O','S','S',' ','A','u','x',0};
74 TRACE("(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
75 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
76 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
77 WARN("mixer device not available !\n");
78 return MMSYSERR_NOTENABLED;
80 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
82 WARN("unable to read mixer !\n");
83 return MMSYSERR_NOTENABLED;
88 lpCaps->vDriverVersion = 0x0100;
89 strcpyW(lpCaps->szPname, ini);
90 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
91 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
93 return MMSYSERR_NOERROR;
97 /**************************************************************************
98 * AUX_GetVolume [internal]
100 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
102 int mixer, volume, left, right, cmd;
104 TRACE("(%04X, %p);\n", wDevID, lpdwVol);
105 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
106 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
107 WARN("mixer device not available !\n");
108 return MMSYSERR_NOTENABLED;
112 TRACE("SOUND_MIXER_READ_PCM !\n");
113 cmd = SOUND_MIXER_READ_PCM;
116 TRACE("SOUND_MIXER_READ_SYNTH !\n");
117 cmd = SOUND_MIXER_READ_SYNTH;
120 TRACE("SOUND_MIXER_READ_CD !\n");
121 cmd = SOUND_MIXER_READ_CD;
124 TRACE("SOUND_MIXER_READ_LINE !\n");
125 cmd = SOUND_MIXER_READ_LINE;
128 TRACE("SOUND_MIXER_READ_MIC !\n");
129 cmd = SOUND_MIXER_READ_MIC;
132 TRACE("SOUND_MIXER_READ_VOLUME !\n");
133 cmd = SOUND_MIXER_READ_VOLUME;
136 WARN("invalid device id=%04X !\n", wDevID);
137 return MMSYSERR_NOTENABLED;
139 if (ioctl(mixer, cmd, &volume) == -1) {
140 WARN("unable to read mixer !\n");
141 return MMSYSERR_NOTENABLED;
144 left = LOBYTE(LOWORD(volume));
145 right = HIBYTE(LOWORD(volume));
146 TRACE("left=%d right=%d !\n", left, right);
147 *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
148 return MMSYSERR_NOERROR;
151 /**************************************************************************
152 * AUX_SetVolume [internal]
154 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
157 int volume, left, right;
160 TRACE("(%04X, %08lX);\n", wDevID, dwParam);
162 left = (LOWORD(dwParam) * 100) >> 16;
163 right = (HIWORD(dwParam) * 100) >> 16;
164 volume = (right << 8) | left;
166 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
167 WARN("mixer device not available !\n");
168 return MMSYSERR_NOTENABLED;
173 TRACE("SOUND_MIXER_WRITE_PCM !\n");
174 cmd = SOUND_MIXER_WRITE_PCM;
177 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
178 cmd = SOUND_MIXER_WRITE_SYNTH;
181 TRACE("SOUND_MIXER_WRITE_CD !\n");
182 cmd = SOUND_MIXER_WRITE_CD;
185 TRACE("SOUND_MIXER_WRITE_LINE !\n");
186 cmd = SOUND_MIXER_WRITE_LINE;
189 TRACE("SOUND_MIXER_WRITE_MIC !\n");
190 cmd = SOUND_MIXER_WRITE_MIC;
193 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
194 cmd = SOUND_MIXER_WRITE_VOLUME;
197 WARN("invalid device id=%04X !\n", wDevID);
198 return MMSYSERR_NOTENABLED;
200 if (ioctl(mixer, cmd, &volume) == -1) {
201 WARN("unable to set mixer !\n");
202 return MMSYSERR_NOTENABLED;
205 return MMSYSERR_NOERROR;
210 /**************************************************************************
211 * auxMessage (WINEOSS.2)
213 DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
214 DWORD dwParam1, DWORD dwParam2)
216 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
217 wDevID, wMsg, dwUser, dwParam1, dwParam2);
227 /* FIXME: Pretend this is supported */
229 case AUXDM_GETDEVCAPS:
230 return AUX_GetDevCaps(wDevID, (LPAUXCAPSW)dwParam1, dwParam2);
231 case AUXDM_GETNUMDEVS:
232 TRACE("return %d;\n", NumDev);
234 case AUXDM_GETVOLUME:
235 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
236 case AUXDM_SETVOLUME:
237 return AUX_SetVolume(wDevID, dwParam1);
239 WARN("unknown message !\n");
241 return MMSYSERR_NOTSUPPORTED;
243 return MMSYSERR_NOTENABLED;