1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 * Sample AUXILARY Wine Driver
5 * Copyright 1994 Martin Ayotte
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #ifdef HAVE_SYS_IOCTL_H
33 # include <sys/ioctl.h>
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(mmaux);
45 #define MIXER_DEV "/dev/mixer"
47 static int NumDev = 6;
49 /*-----------------------------------------------------------------------*/
51 static int AUXDRV_Init(void)
55 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
56 WARN("mixer device not available !\n");
65 /**************************************************************************
66 * AUX_GetDevCaps [internal]
68 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPSA lpCaps, DWORD dwSize)
72 TRACE("(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
73 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
74 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
75 WARN("mixer device not available !\n");
76 return MMSYSERR_NOTENABLED;
78 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
80 WARN("unable to read mixer !\n");
81 return MMSYSERR_NOTENABLED;
85 lpCaps->wMid = 0x0002;
86 lpCaps->vDriverVersion = 0x0200;
87 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
90 lpCaps->wPid = 0x0196;
91 strcpy(lpCaps->szPname, "SB16 Aux: Wave");
92 lpCaps->wTechnology = AUXCAPS_AUXIN;
95 lpCaps->wPid = 0x0197;
96 strcpy(lpCaps->szPname, "SB16 Aux: Midi Synth");
97 lpCaps->wTechnology = AUXCAPS_AUXIN;
100 lpCaps->wPid = 0x0191;
101 strcpy(lpCaps->szPname, "SB16 Aux: CD");
102 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
105 lpCaps->wPid = 0x0192;
106 strcpy(lpCaps->szPname, "SB16 Aux: Line-In");
107 lpCaps->wTechnology = AUXCAPS_AUXIN;
110 lpCaps->wPid = 0x0193;
111 strcpy(lpCaps->szPname, "SB16 Aux: Mic");
112 lpCaps->wTechnology = AUXCAPS_AUXIN;
115 lpCaps->wPid = 0x0194;
116 strcpy(lpCaps->szPname, "SB16 Aux: Master");
117 lpCaps->wTechnology = AUXCAPS_AUXIN;
123 lpCaps->vDriverVersion = 0x0100;
124 strcpy(lpCaps->szPname, "Generic Linux Auxiliary Driver");
125 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
126 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
128 return MMSYSERR_NOERROR;
132 /**************************************************************************
133 * AUX_GetVolume [internal]
135 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
137 int mixer, volume, left, right, cmd;
139 TRACE("(%04X, %p);\n", wDevID, lpdwVol);
140 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
141 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
142 WARN("mixer device not available !\n");
143 return MMSYSERR_NOTENABLED;
147 TRACE("SOUND_MIXER_READ_PCM !\n");
148 cmd = SOUND_MIXER_READ_PCM;
151 TRACE("SOUND_MIXER_READ_SYNTH !\n");
152 cmd = SOUND_MIXER_READ_SYNTH;
155 TRACE("SOUND_MIXER_READ_CD !\n");
156 cmd = SOUND_MIXER_READ_CD;
159 TRACE("SOUND_MIXER_READ_LINE !\n");
160 cmd = SOUND_MIXER_READ_LINE;
163 TRACE("SOUND_MIXER_READ_MIC !\n");
164 cmd = SOUND_MIXER_READ_MIC;
167 TRACE("SOUND_MIXER_READ_VOLUME !\n");
168 cmd = SOUND_MIXER_READ_VOLUME;
171 WARN("invalid device id=%04X !\n", wDevID);
172 return MMSYSERR_NOTENABLED;
174 if (ioctl(mixer, cmd, &volume) == -1) {
175 WARN("unable to read mixer !\n");
176 return MMSYSERR_NOTENABLED;
179 left = LOBYTE(LOWORD(volume));
180 right = HIBYTE(LOWORD(volume));
181 TRACE("left=%d right=%d !\n", left, right);
182 *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
183 return MMSYSERR_NOERROR;
186 /**************************************************************************
187 * AUX_SetVolume [internal]
189 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
192 int volume, left, right;
195 TRACE("(%04X, %08lX);\n", wDevID, dwParam);
197 left = (LOWORD(dwParam) * 100) >> 16;
198 right = (HIWORD(dwParam) * 100) >> 16;
199 volume = (right << 8) | left;
201 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
202 WARN("mixer device not available !\n");
203 return MMSYSERR_NOTENABLED;
208 TRACE("SOUND_MIXER_WRITE_PCM !\n");
209 cmd = SOUND_MIXER_WRITE_PCM;
212 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
213 cmd = SOUND_MIXER_WRITE_SYNTH;
216 TRACE("SOUND_MIXER_WRITE_CD !\n");
217 cmd = SOUND_MIXER_WRITE_CD;
220 TRACE("SOUND_MIXER_WRITE_LINE !\n");
221 cmd = SOUND_MIXER_WRITE_LINE;
224 TRACE("SOUND_MIXER_WRITE_MIC !\n");
225 cmd = SOUND_MIXER_WRITE_MIC;
228 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
229 cmd = SOUND_MIXER_WRITE_VOLUME;
232 WARN("invalid device id=%04X !\n", wDevID);
233 return MMSYSERR_NOTENABLED;
235 if (ioctl(mixer, cmd, &volume) == -1) {
236 WARN("unable to set mixer !\n");
237 return MMSYSERR_NOTENABLED;
240 return MMSYSERR_NOERROR;
245 /**************************************************************************
246 * auxMessage (WINEOSS.2)
248 DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
249 DWORD dwParam1, DWORD dwParam2)
251 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
252 wDevID, wMsg, dwUser, dwParam1, dwParam2);
262 /* FIXME: Pretend this is supported */
264 case AUXDM_GETDEVCAPS:
265 return AUX_GetDevCaps(wDevID, (LPAUXCAPSA)dwParam1,dwParam2);
266 case AUXDM_GETNUMDEVS:
267 TRACE("return %d;\n", NumDev);
269 case AUXDM_GETVOLUME:
270 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
271 case AUXDM_SETVOLUME:
272 return AUX_SetVolume(wDevID, dwParam1);
274 WARN("unknown message !\n");
276 return MMSYSERR_NOTSUPPORTED;
278 return MMSYSERR_NOTENABLED;