2 * Sample AUXILARY Wine Driver
4 * Copyright 1994 Martin Ayotte
12 #include <sys/ioctl.h>
16 #include "multimedia.h"
19 #define MIXER_DEV "/dev/mixer"
21 static int NumDev = 6;
23 /*-----------------------------------------------------------------------*/
26 /**************************************************************************
27 * AUX_GetDevCaps [internal]
29 static DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPS16 lpCaps, DWORD dwSize)
34 TRACE(mmaux,"(%04X, %p, %lu);\n", wDevID, lpCaps, dwSize);
35 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
36 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
37 WARN(mmaux, "mixer device not available !\n");
38 return MMSYSERR_NOTENABLED;
40 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
42 WARN(mmaux, "unable read mixer !\n");
43 return MMSYSERR_NOTENABLED;
47 lpCaps->wMid = 0x0002;
48 lpCaps->vDriverVersion = 0x0200;
49 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
52 lpCaps->wPid = 0x0196;
53 strcpy(lpCaps->szPname, "SB16 Aux: Wave");
54 lpCaps->wTechnology = AUXCAPS_AUXIN;
57 lpCaps->wPid = 0x0197;
58 strcpy(lpCaps->szPname, "SB16 Aux: Midi Synth");
59 lpCaps->wTechnology = AUXCAPS_AUXIN;
62 lpCaps->wPid = 0x0191;
63 strcpy(lpCaps->szPname, "SB16 Aux: CD");
64 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
67 lpCaps->wPid = 0x0192;
68 strcpy(lpCaps->szPname, "SB16 Aux: Line-In");
69 lpCaps->wTechnology = AUXCAPS_AUXIN;
72 lpCaps->wPid = 0x0193;
73 strcpy(lpCaps->szPname, "SB16 Aux: Mic");
74 lpCaps->wTechnology = AUXCAPS_AUXIN;
77 lpCaps->wPid = 0x0194;
78 strcpy(lpCaps->szPname, "SB16 Aux: Master");
79 lpCaps->wTechnology = AUXCAPS_AUXIN;
85 lpCaps->vDriverVersion = 0x0100;
86 strcpy(lpCaps->szPname, "Generic Linux Auxiliary Driver");
87 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
88 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
90 return MMSYSERR_NOERROR;
92 return MMSYSERR_NOTENABLED;
97 /**************************************************************************
98 * AUX_GetVolume [internal]
100 static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
103 int mixer,volume,left,right,cmd;
105 TRACE(mmaux,"(%04X, %p);\n", wDevID, lpdwVol);
106 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
107 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
108 WARN(mmaux, "mixer device not available !\n");
109 return MMSYSERR_NOTENABLED;
113 TRACE(mmaux,"SOUND_MIXER_READ_PCM !\n");
114 cmd = SOUND_MIXER_READ_PCM;
117 TRACE(mmaux,"SOUND_MIXER_READ_SYNTH !\n");
118 cmd = SOUND_MIXER_READ_SYNTH;
121 TRACE(mmaux,"SOUND_MIXER_READ_CD !\n");
122 cmd = SOUND_MIXER_READ_CD;
125 TRACE(mmaux,"SOUND_MIXER_READ_LINE !\n");
126 cmd = SOUND_MIXER_READ_LINE;
129 TRACE(mmaux,"SOUND_MIXER_READ_MIC !\n");
130 cmd = SOUND_MIXER_READ_MIC;
133 TRACE(mmaux,"SOUND_MIXER_READ_VOLUME !\n");
134 cmd = SOUND_MIXER_READ_VOLUME;
137 WARN(mmaux, "invalid device id=%04X !\n", wDevID);
138 return MMSYSERR_NOTENABLED;
140 if (ioctl(mixer, cmd, &volume) == -1) {
141 WARN(mmaux, "unable read mixer !\n");
142 return MMSYSERR_NOTENABLED;
145 left = volume & 0x7F;
146 right = (volume >> 8) & 0x7F;
147 TRACE(mmaux,"left=%d right=%d !\n", left, right);
148 *lpdwVol = MAKELONG(left << 9, right << 9);
149 return MMSYSERR_NOERROR;
151 return MMSYSERR_NOTENABLED;
155 /**************************************************************************
156 * AUX_SetVolume [internal]
158 static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
164 TRACE(mmaux,"(%04X, %08lX);\n", wDevID, dwParam);
165 volume = (LOWORD(dwParam) >> 9 & 0x7F) +
166 ((HIWORD(dwParam) >> 9 & 0x7F) << 8);
167 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
168 WARN(mmaux, "mixer device not available !\n");
169 return MMSYSERR_NOTENABLED;
173 TRACE(mmaux,"SOUND_MIXER_WRITE_PCM !\n");
174 cmd = SOUND_MIXER_WRITE_PCM;
177 TRACE(mmaux,"SOUND_MIXER_WRITE_SYNTH !\n");
178 cmd = SOUND_MIXER_WRITE_SYNTH;
181 TRACE(mmaux,"SOUND_MIXER_WRITE_CD !\n");
182 cmd = SOUND_MIXER_WRITE_CD;
185 TRACE(mmaux,"SOUND_MIXER_WRITE_LINE !\n");
186 cmd = SOUND_MIXER_WRITE_LINE;
189 TRACE(mmaux,"SOUND_MIXER_WRITE_MIC !\n");
190 cmd = SOUND_MIXER_WRITE_MIC;
193 TRACE(mmaux,"SOUND_MIXER_WRITE_VOLUME !\n");
194 cmd = SOUND_MIXER_WRITE_VOLUME;
197 WARN(mmaux,"invalid device id=%04X !\n", wDevID);
198 return MMSYSERR_NOTENABLED;
200 if (ioctl(mixer, cmd, &volume) == -1) {
201 WARN(mmaux, "unable set mixer !\n");
202 return MMSYSERR_NOTENABLED;
205 return MMSYSERR_NOERROR;
207 return MMSYSERR_NOTENABLED;
212 /**************************************************************************
213 * auxMessage [sample driver]
215 DWORD WINAPI auxMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
216 DWORD dwParam1, DWORD dwParam2)
218 TRACE(mmaux,"(%04X, %04X, %08lX, %08lX, %08lX);\n",
219 wDevID, wMsg, dwUser, dwParam1, dwParam2);
221 case AUXDM_GETDEVCAPS:
222 return AUX_GetDevCaps(wDevID,(LPAUXCAPS16)dwParam1,dwParam2);
223 case AUXDM_GETNUMDEVS:
224 TRACE(mmaux,"return %d;\n", NumDev);
226 case AUXDM_GETVOLUME:
227 return AUX_GetVolume(wDevID,(LPDWORD)dwParam1);
228 case AUXDM_SETVOLUME:
229 return AUX_SetVolume(wDevID,dwParam1);
231 WARN(mmaux, "unknown message !\n");
233 return MMSYSERR_NOTSUPPORTED;