1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 * Sample AUXILARY Wine Driver
5 * Copyright 1994 Martin Ayotte
16 #include <sys/ioctl.h>
21 #include "debugtools.h"
23 DEFAULT_DEBUG_CHANNEL(mmaux)
27 #define MIXER_DEV "/dev/mixer"
29 static int NumDev = 6;
31 /*-----------------------------------------------------------------------*/
33 static int AUXDRV_Init(void)
37 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
38 WARN("mixer device not available !\n");
47 /**************************************************************************
48 * AUX_GetDevCaps [internal]
50 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPSA lpCaps, DWORD dwSize)
54 TRACE("(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
55 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
56 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
57 WARN("mixer device not available !\n");
58 return MMSYSERR_NOTENABLED;
60 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
62 WARN("unable to read mixer !\n");
63 return MMSYSERR_NOTENABLED;
67 lpCaps->wMid = 0x0002;
68 lpCaps->vDriverVersion = 0x0200;
69 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
72 lpCaps->wPid = 0x0196;
73 strcpy(lpCaps->szPname, "SB16 Aux: Wave");
74 lpCaps->wTechnology = AUXCAPS_AUXIN;
77 lpCaps->wPid = 0x0197;
78 strcpy(lpCaps->szPname, "SB16 Aux: Midi Synth");
79 lpCaps->wTechnology = AUXCAPS_AUXIN;
82 lpCaps->wPid = 0x0191;
83 strcpy(lpCaps->szPname, "SB16 Aux: CD");
84 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
87 lpCaps->wPid = 0x0192;
88 strcpy(lpCaps->szPname, "SB16 Aux: Line-In");
89 lpCaps->wTechnology = AUXCAPS_AUXIN;
92 lpCaps->wPid = 0x0193;
93 strcpy(lpCaps->szPname, "SB16 Aux: Mic");
94 lpCaps->wTechnology = AUXCAPS_AUXIN;
97 lpCaps->wPid = 0x0194;
98 strcpy(lpCaps->szPname, "SB16 Aux: Master");
99 lpCaps->wTechnology = AUXCAPS_AUXIN;
105 lpCaps->vDriverVersion = 0x0100;
106 strcpy(lpCaps->szPname, "Generic Linux Auxiliary Driver");
107 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
108 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
110 return MMSYSERR_NOERROR;
114 /**************************************************************************
115 * AUX_GetVolume [internal]
117 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
119 int mixer, volume, left, right, cmd;
121 TRACE("(%04X, %p);\n", wDevID, lpdwVol);
122 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
123 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
124 WARN("mixer device not available !\n");
125 return MMSYSERR_NOTENABLED;
129 TRACE("SOUND_MIXER_READ_PCM !\n");
130 cmd = SOUND_MIXER_READ_PCM;
133 TRACE("SOUND_MIXER_READ_SYNTH !\n");
134 cmd = SOUND_MIXER_READ_SYNTH;
137 TRACE("SOUND_MIXER_READ_CD !\n");
138 cmd = SOUND_MIXER_READ_CD;
141 TRACE("SOUND_MIXER_READ_LINE !\n");
142 cmd = SOUND_MIXER_READ_LINE;
145 TRACE("SOUND_MIXER_READ_MIC !\n");
146 cmd = SOUND_MIXER_READ_MIC;
149 TRACE("SOUND_MIXER_READ_VOLUME !\n");
150 cmd = SOUND_MIXER_READ_VOLUME;
153 WARN("invalid device id=%04X !\n", wDevID);
154 return MMSYSERR_NOTENABLED;
156 if (ioctl(mixer, cmd, &volume) == -1) {
157 WARN("unable to read mixer !\n");
158 return MMSYSERR_NOTENABLED;
161 left = LOBYTE(LOWORD(volume));
162 right = HIBYTE(LOWORD(volume));
163 TRACE("left=%d right=%d !\n", left, right);
164 *lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
165 return MMSYSERR_NOERROR;
168 /**************************************************************************
169 * AUX_SetVolume [internal]
171 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
174 int volume, left, right;
177 TRACE("(%04X, %08lX);\n", wDevID, dwParam);
179 left = (LOWORD(dwParam) * 100) >> 16;
180 right = (HIWORD(dwParam) * 100) >> 16;
181 volume = (right << 8) | left;
183 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
184 WARN("mixer device not available !\n");
185 return MMSYSERR_NOTENABLED;
190 TRACE("SOUND_MIXER_WRITE_PCM !\n");
191 cmd = SOUND_MIXER_WRITE_PCM;
194 TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
195 cmd = SOUND_MIXER_WRITE_SYNTH;
198 TRACE("SOUND_MIXER_WRITE_CD !\n");
199 cmd = SOUND_MIXER_WRITE_CD;
202 TRACE("SOUND_MIXER_WRITE_LINE !\n");
203 cmd = SOUND_MIXER_WRITE_LINE;
206 TRACE("SOUND_MIXER_WRITE_MIC !\n");
207 cmd = SOUND_MIXER_WRITE_MIC;
210 TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
211 cmd = SOUND_MIXER_WRITE_VOLUME;
214 WARN("invalid device id=%04X !\n", wDevID);
215 return MMSYSERR_NOTENABLED;
217 if (ioctl(mixer, cmd, &volume) == -1) {
218 WARN("unable to set mixer !\n");
219 return MMSYSERR_NOTENABLED;
222 return MMSYSERR_NOERROR;
227 /**************************************************************************
228 * OSS_auxMessage [sample driver]
230 DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
231 DWORD dwParam1, DWORD dwParam2)
233 TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
234 wDevID, wMsg, dwUser, dwParam1, dwParam2);
244 /* FIXME: Pretend this is supported */
246 case AUXDM_GETDEVCAPS:
247 return AUX_GetDevCaps(wDevID, (LPAUXCAPSA)dwParam1,dwParam2);
248 case AUXDM_GETNUMDEVS:
249 TRACE("return %d;\n", NumDev);
251 case AUXDM_GETVOLUME:
252 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
253 case AUXDM_SETVOLUME:
254 return AUX_SetVolume(wDevID, dwParam1);
256 WARN("unknown message !\n");
258 return MMSYSERR_NOTSUPPORTED;
260 return MMSYSERR_NOTENABLED;