2 * Sample AUXILARY Wine Driver for Linux
4 * Copyright 1994 Martin Ayotte
8 #define BUILTIN_MMSYSTEM
11 #ifdef BUILTIN_MMSYSTEM
19 #include <sys/ioctl.h>
26 #include <linux/soundcard.h>
29 #define SOUND_DEV "/dev/dsp"
30 #define MIXER_DEV "/dev/mixer"
33 #define IOCTL(a,b,c) ioctl(a,b,&c)
35 #define IOCTL(a,b,c) (c = ioctl(a,b,c) )
39 static int NumDev
= 6;
41 /*-----------------------------------------------------------------------*/
44 /**************************************************************************
45 * AUX_GetDevCaps [internal]
47 static DWORD
AUX_GetDevCaps(WORD wDevID
, LPAUXCAPS lpCaps
, DWORD dwSize
)
52 printf("AUX_GetDevCaps(%u, %p, %lu);\n", wDevID
, lpCaps
, dwSize
);
53 if (lpCaps
== NULL
) return MMSYSERR_NOTENABLED
;
54 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
55 printf("AUX_GetDevCaps // mixer device not available !\n");
56 return MMSYSERR_NOTENABLED
;
58 if (ioctl(mixer
, SOUND_MIXER_READ_LINE
, &volume
) == -1) {
60 printf("AUX_GetDevCaps // unable read mixer !\n");
61 return MMSYSERR_NOTENABLED
;
65 lpCaps
->wMid
= 0x0002;
66 lpCaps
->vDriverVersion
= 0x0200;
67 lpCaps
->dwSupport
= AUXCAPS_VOLUME
| AUXCAPS_LRVOLUME
;
70 lpCaps
->wPid
= 0x0196;
71 strcpy(lpCaps
->szPname
, "SB16 Aux: Wave");
72 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
75 lpCaps
->wPid
= 0x0197;
76 strcpy(lpCaps
->szPname
, "SB16 Aux: Midi Synth");
77 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
80 lpCaps
->wPid
= 0x0191;
81 strcpy(lpCaps
->szPname
, "SB16 Aux: CD");
82 lpCaps
->wTechnology
= AUXCAPS_CDAUDIO
;
85 lpCaps
->wPid
= 0x0192;
86 strcpy(lpCaps
->szPname
, "SB16 Aux: Line-In");
87 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
90 lpCaps
->wPid
= 0x0193;
91 strcpy(lpCaps
->szPname
, "SB16 Aux: Mic");
92 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
95 lpCaps
->wPid
= 0x0194;
96 strcpy(lpCaps
->szPname
, "SB16 Aux: Master");
97 lpCaps
->wTechnology
= AUXCAPS_AUXIN
;
103 lpCaps
->vDriverVersion
= 0x0100;
104 strcpy(lpCaps
->szPname
, "Generic Linux Auxiliary Driver");
105 lpCaps
->wTechnology
= AUXCAPS_CDAUDIO
;
106 lpCaps
->dwSupport
= AUXCAPS_VOLUME
| AUXCAPS_LRVOLUME
;
108 return MMSYSERR_NOERROR
;
110 return MMSYSERR_NOTENABLED
;
115 /**************************************************************************
116 * AUX_GetVolume [internal]
118 static DWORD
AUX_GetVolume(WORD wDevID
, LPDWORD lpdwVol
)
122 int volume
, left
, right
;
124 printf("AUX_GetVolume(%u, %p);\n", wDevID
, lpdwVol
);
125 if (lpdwVol
== NULL
) return MMSYSERR_NOTENABLED
;
126 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
127 printf("Linux 'AUX_GetVolume' // mixer device not available !\n");
128 return MMSYSERR_NOTENABLED
;
132 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_PCM !\n");
133 cmd
= SOUND_MIXER_READ_PCM
;
136 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_SYNTH !\n");
137 cmd
= SOUND_MIXER_READ_SYNTH
;
140 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_CD !\n");
141 cmd
= SOUND_MIXER_READ_CD
;
144 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_LINE !\n");
145 cmd
= SOUND_MIXER_READ_LINE
;
148 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_MIC !\n");
149 cmd
= SOUND_MIXER_READ_MIC
;
152 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_VOLUME !\n");
153 cmd
= SOUND_MIXER_READ_VOLUME
;
156 fprintf(stderr
, "Linux 'AUX_GetVolume' // invalid device id=%d !\n", wDevID
);
157 return MMSYSERR_NOTENABLED
;
159 if (ioctl(mixer
, cmd
, &volume
) == -1) {
160 printf("Linux 'AUX_GetVolume' // unable read mixer !\n");
161 return MMSYSERR_NOTENABLED
;
164 left
= volume
& 0x7F;
165 right
= (volume
>> 8) & 0x7F;
166 printf("Linux 'AUX_GetVolume' // left=%d right=%d !\n", left
, right
);
167 *lpdwVol
= MAKELONG(left
<< 9, right
<< 9);
168 return MMSYSERR_NOERROR
;
170 return MMSYSERR_NOTENABLED
;
174 /**************************************************************************
175 * AUX_SetVolume [internal]
177 static DWORD
AUX_SetVolume(WORD wDevID
, DWORD dwParam
)
183 printf("AUX_SetVolume(%u (%04X), %08lX);\n", wDevID
, wDevID
, dwParam
);
184 volume
= (LOWORD(dwParam
) >> 9 & 0x7F) +
185 ((HIWORD(dwParam
) >> 9 & 0x7F) << 8);
186 if ((mixer
= open(MIXER_DEV
, O_RDWR
)) < 0) {
187 printf("Linux 'AUX_SetVolume' // mixer device not available !\n");
188 return MMSYSERR_NOTENABLED
;
192 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_PCM !\n");
193 cmd
= SOUND_MIXER_WRITE_PCM
;
196 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_SYNTH !\n");
197 cmd
= SOUND_MIXER_WRITE_SYNTH
;
200 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_CD !\n");
201 cmd
= SOUND_MIXER_WRITE_CD
;
204 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_LINE !\n");
205 cmd
= SOUND_MIXER_WRITE_LINE
;
208 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_MIC !\n");
209 cmd
= SOUND_MIXER_WRITE_MIC
;
212 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_VOLUME !\n");
213 cmd
= SOUND_MIXER_WRITE_VOLUME
;
216 fprintf(stderr
, "Linux 'AUX_SetVolume' // invalid device id=%d !\n", wDevID
);
217 return MMSYSERR_NOTENABLED
;
219 if (ioctl(mixer
, cmd
, &volume
) == -1) {
220 printf("Linux 'AUX_SetVolume' // unable set mixer !\n");
221 return MMSYSERR_NOTENABLED
;
224 return MMSYSERR_NOERROR
;
226 return MMSYSERR_NOTENABLED
;
231 /**************************************************************************
232 * auxMessage [sample driver]
234 DWORD
auxMessage(WORD wDevID
, WORD wMsg
, DWORD dwUser
,
235 DWORD dwParam1
, DWORD dwParam2
)
237 printf("auxMessage(%u, %04X, %08lX, %08lX, %08lX);\n",
238 wDevID
, wMsg
, dwUser
, dwParam1
, dwParam2
);
240 case AUXDM_GETDEVCAPS
:
241 return AUX_GetDevCaps(wDevID
,
242 (LPAUXCAPS
)PTR_SEG_TO_LIN(dwParam1
), dwParam2
);
243 case AUXDM_GETNUMDEVS
:
244 printf("AUX_GetNumDevs() return %d;\n", NumDev
);
246 case AUXDM_GETVOLUME
:
247 return AUX_GetVolume(wDevID
, (LPDWORD
)PTR_SEG_TO_LIN(dwParam1
));
248 case AUXDM_SETVOLUME
:
249 return AUX_SetVolume(wDevID
, dwParam1
);
251 fprintf(stderr
,"auxMessage // unknown message !\n");
253 return MMSYSERR_NOTSUPPORTED
;
257 #endif /* #ifdef BUILTIN_MMSYSTEM */