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
);
146 return MMSYSERR_NOTENABLED
;
148 if (ioctl(mixer
, cmd
, &volume
) == -1) {
149 WARN("unable to read mixer !\n");
150 return MMSYSERR_NOTENABLED
;
153 left
= LOBYTE(LOWORD(volume
));
154 right
= HIBYTE(LOWORD(volume
));
155 TRACE("left=%d right=%d !\n", left
, right
);
156 *lpdwVol
= MAKELONG((left
* 0xFFFFL
) / 100, (right
* 0xFFFFL
) / 100);
157 return MMSYSERR_NOERROR
;
160 /**************************************************************************
161 * AUX_SetVolume [internal]
163 static DWORD
AUX_SetVolume(WORD wDevID
, DWORD dwParam
)
166 int volume
, left
, right
;
169 TRACE("(%04X, %08X);\n", wDevID
, dwParam
);
171 left
= (LOWORD(dwParam
) * 100) >> 16;
172 right
= (HIWORD(dwParam
) * 100) >> 16;
173 volume
= (right
<< 8) | left
;
175 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
176 WARN("mixer device not available !\n");
177 return MMSYSERR_NOTENABLED
;
182 TRACE("SOUND_MIXER_WRITE_PCM !\n");
183 cmd
= SOUND_MIXER_WRITE_PCM
;
186 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
187 cmd
= SOUND_MIXER_WRITE_SYNTH
;
190 TRACE("SOUND_MIXER_WRITE_CD !\n");
191 cmd
= SOUND_MIXER_WRITE_CD
;
194 TRACE("SOUND_MIXER_WRITE_LINE !\n");
195 cmd
= SOUND_MIXER_WRITE_LINE
;
198 TRACE("SOUND_MIXER_WRITE_MIC !\n");
199 cmd
= SOUND_MIXER_WRITE_MIC
;
202 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
203 cmd
= SOUND_MIXER_WRITE_VOLUME
;
206 WARN("invalid device id=%04X !\n", wDevID
);
207 return MMSYSERR_NOTENABLED
;
209 if (ioctl(mixer
, cmd
, &volume
) == -1) {
210 WARN("unable to set mixer !\n");
211 return MMSYSERR_NOTENABLED
;
214 return MMSYSERR_NOERROR
;
219 /**************************************************************************
220 * auxMessage (WINEOSS.2)
222 DWORD WINAPI
OSS_auxMessage(UINT wDevID
, UINT wMsg
, DWORD dwUser
,
223 DWORD dwParam1
, DWORD dwParam2
)
225 TRACE("(%04X, %04X, %08X, %08X, %08X);\n",
226 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
234 /* FIXME: Pretend this is supported */
236 case AUXDM_GETDEVCAPS
:
237 return AUX_GetDevCaps(wDevID
, (LPAUXCAPSW
)dwParam1
, dwParam2
);
238 case AUXDM_GETNUMDEVS
:
239 TRACE("return %d;\n", NumDev
);
241 case AUXDM_GETVOLUME
:
242 return AUX_GetVolume(wDevID
, (LPDWORD
)dwParam1
);
243 case AUXDM_SETVOLUME
:
244 return AUX_SetVolume(wDevID
, dwParam1
);
246 WARN("unknown message !\n");
248 return MMSYSERR_NOTSUPPORTED
;
250 return MMSYSERR_NOTENABLED
;