2 * Sample AUXILARY Wine Driver
4 * Copyright 1994 Martin Ayotte
13 #include <sys/ioctl.h>
16 #include "multimedia.h"
17 #include "debugtools.h"
19 DEFAULT_DEBUG_CHANNEL(mmaux)
21 #define MIXER_DEV "/dev/mixer"
23 static int NumDev = 6;
25 /*-----------------------------------------------------------------------*/
28 /**************************************************************************
29 * AUX_GetDevCaps [internal]
31 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPS16 lpCaps, DWORD dwSize)
36 TRACE("(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
37 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
38 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
39 WARN("mixer device not available !\n");
40 return MMSYSERR_NOTENABLED;
42 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
44 WARN("unable read mixer !\n");
45 return MMSYSERR_NOTENABLED;
49 lpCaps->wMid = 0x0002;
50 lpCaps->vDriverVersion = 0x0200;
51 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
54 lpCaps->wPid = 0x0196;
55 strcpy(lpCaps->szPname, "SB16 Aux: Wave");
56 lpCaps->wTechnology = AUXCAPS_AUXIN;
59 lpCaps->wPid = 0x0197;
60 strcpy(lpCaps->szPname, "SB16 Aux: Midi Synth");
61 lpCaps->wTechnology = AUXCAPS_AUXIN;
64 lpCaps->wPid = 0x0191;
65 strcpy(lpCaps->szPname, "SB16 Aux: CD");
66 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
69 lpCaps->wPid = 0x0192;
70 strcpy(lpCaps->szPname, "SB16 Aux: Line-In");
71 lpCaps->wTechnology = AUXCAPS_AUXIN;
74 lpCaps->wPid = 0x0193;
75 strcpy(lpCaps->szPname, "SB16 Aux: Mic");
76 lpCaps->wTechnology = AUXCAPS_AUXIN;
79 lpCaps->wPid = 0x0194;
80 strcpy(lpCaps->szPname, "SB16 Aux: Master");
81 lpCaps->wTechnology = AUXCAPS_AUXIN;
87 lpCaps->vDriverVersion = 0x0100;
88 strcpy(lpCaps->szPname, "Generic Linux Auxiliary Driver");
89 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
90 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
92 return MMSYSERR_NOERROR;
94 return MMSYSERR_NOTENABLED;
99 /**************************************************************************
100 * AUX_GetVolume [internal]
102 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
105 int mixer, volume, left, right, cmd;
107 TRACE("(%04X, %p);\n", wDevID, lpdwVol);
108 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
109 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
110 WARN("mixer device not available !\n");
111 return MMSYSERR_NOTENABLED;
115 TRACE("SOUND_MIXER_READ_PCM !\n");
116 cmd = SOUND_MIXER_READ_PCM;
119 TRACE("SOUND_MIXER_READ_SYNTH !\n");
120 cmd = SOUND_MIXER_READ_SYNTH;
123 TRACE("SOUND_MIXER_READ_CD !\n");
124 cmd = SOUND_MIXER_READ_CD;
127 TRACE("SOUND_MIXER_READ_LINE !\n");
128 cmd = SOUND_MIXER_READ_LINE;
131 TRACE("SOUND_MIXER_READ_MIC !\n");
132 cmd = SOUND_MIXER_READ_MIC;
135 TRACE("SOUND_MIXER_READ_VOLUME !\n");
136 cmd = SOUND_MIXER_READ_VOLUME;
139 WARN("invalid device id=%04X !\n", wDevID);
140 return MMSYSERR_NOTENABLED;
142 if (ioctl(mixer, cmd, &volume) == -1) {
143 WARN("unable read mixer !\n");
144 return MMSYSERR_NOTENABLED;
147 left = LOBYTE(LOWORD(volume));
148 right = HIBYTE(LOWORD(volume));
149 TRACE("left=%d right=%d !\n", left, right);
150 *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
151 return MMSYSERR_NOERROR;
153 return MMSYSERR_NOTENABLED;
157 /**************************************************************************
158 * AUX_SetVolume [internal]
160 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
164 int volume, left, right;
167 TRACE("(%04X, %08lX);\n", wDevID, dwParam);
169 left = (LOWORD(dwParam) * 100) >> 16;
170 right = (HIWORD(dwParam) * 100) >> 16;
171 volume = (right << 8) | left;
173 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
174 WARN("mixer device not available !\n");
175 return MMSYSERR_NOTENABLED;
180 TRACE("SOUND_MIXER_WRITE_PCM !\n");
181 cmd = SOUND_MIXER_WRITE_PCM;
184 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
185 cmd = SOUND_MIXER_WRITE_SYNTH;
188 TRACE("SOUND_MIXER_WRITE_CD !\n");
189 cmd = SOUND_MIXER_WRITE_CD;
192 TRACE("SOUND_MIXER_WRITE_LINE !\n");
193 cmd = SOUND_MIXER_WRITE_LINE;
196 TRACE("SOUND_MIXER_WRITE_MIC !\n");
197 cmd = SOUND_MIXER_WRITE_MIC;
200 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
201 cmd = SOUND_MIXER_WRITE_VOLUME;
204 WARN("invalid device id=%04X !\n", wDevID);
205 return MMSYSERR_NOTENABLED;
207 if (ioctl(mixer, cmd, &volume) == -1) {
208 WARN("unable set mixer !\n");
209 return MMSYSERR_NOTENABLED;
212 return MMSYSERR_NOERROR;
214 return MMSYSERR_NOTENABLED;
219 /**************************************************************************
220 * auxMessage [sample driver]
222 DWORD WINAPI auxMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
223 DWORD dwParam1, DWORD dwParam2)
225 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
226 wDevID, wMsg, dwUser, dwParam1, dwParam2);
228 case AUXDM_GETDEVCAPS:
229 return AUX_GetDevCaps(wDevID,(LPAUXCAPS16)dwParam1,dwParam2);
230 case AUXDM_GETNUMDEVS:
231 TRACE("return %d;\n", NumDev);
233 case AUXDM_GETVOLUME:
234 return AUX_GetVolume(wDevID,(LPDWORD)dwParam1);
235 case AUXDM_SETVOLUME:
236 return AUX_SetVolume(wDevID,dwParam1);
238 WARN("unknown message !\n");
240 return MMSYSERR_NOTSUPPORTED;