Release 941122
[wine/multimedia.git] / multimedia / mmaux.c
blobef69eed2f77d29d7dc4ea75ed477a507c58f9faa
1 /*
2 * Sample AUXILARY Wine Driver for Linux
4 * Copyright 1994 Martin Ayotte
5 */
6 static char Copyright[] = "Copyright Martin Ayotte, 1994";
8 #ifndef WINELIB
9 #define BUILTIN_MMSYSTEM
10 #endif
12 #ifdef BUILTIN_MMSYSTEM
14 #define EMULATE_SB16
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19 #include <fcntl.h>
20 #include <sys/ioctl.h>
21 #include "win.h"
22 #include "user.h"
23 #include "driver.h"
24 #include "mmsystem.h"
26 #ifdef linux
27 #include <linux/soundcard.h>
28 #endif
30 #define SOUND_DEV "/dev/dsp"
31 #define MIXER_DEV "/dev/mixer"
33 #ifdef SOUND_VERSION
34 #define IOCTL(a,b,c) ioctl(a,b,&c)
35 #else
36 #define IOCTL(a,b,c) (c = ioctl(a,b,c) )
37 #endif
40 /*-----------------------------------------------------------------------*/
43 /**************************************************************************
44 * AUX_GetDevCaps [internal]
46 DWORD AUX_GetDevCaps(WORD wDevID, LPAUXCAPS lpCaps, DWORD dwSize)
48 #ifdef linux
49 int mixer;
50 int volume;
51 printf("AUX_GetDevCaps(%u, %08X, %u);\n", wDevID, lpCaps, dwSize);
52 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
53 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
54 printf("AUX_GetDevCaps // mixer device not available !\n");
55 return MMSYSERR_NOTENABLED;
57 if (ioctl(mixer, SOUND_MIXER_READ_LINE, &volume) == -1) {
58 close(mixer);
59 printf("AUX_GetDevCaps // unable read mixer !\n");
60 return MMSYSERR_NOTENABLED;
62 close(mixer);
63 #ifdef EMULATE_SB16
64 lpCaps->wMid = 0x0002;
65 lpCaps->vDriverVersion = 0x0200;
66 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
67 switch (wDevID) {
68 case 0:
69 lpCaps->wPid = 0x0196;
70 strcpy(lpCaps->szPname, "SB16 Aux: Wave");
71 lpCaps->wTechnology = AUXCAPS_AUXIN;
72 break;
73 case 1:
74 lpCaps->wPid = 0x0197;
75 strcpy(lpCaps->szPname, "SB16 Aux: Midi Synth");
76 lpCaps->wTechnology = AUXCAPS_AUXIN;
77 break;
78 case 2:
79 lpCaps->wPid = 0x0191;
80 strcpy(lpCaps->szPname, "SB16 Aux: CD");
81 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
82 break;
83 case 3:
84 lpCaps->wPid = 0x0192;
85 strcpy(lpCaps->szPname, "SB16 Aux: Line-In");
86 lpCaps->wTechnology = AUXCAPS_AUXIN;
87 break;
88 case 4:
89 lpCaps->wPid = 0x0193;
90 strcpy(lpCaps->szPname, "SB16 Aux: Mic");
91 lpCaps->wTechnology = AUXCAPS_AUXIN;
92 break;
93 case 5:
94 lpCaps->wPid = 0x0194;
95 strcpy(lpCaps->szPname, "SB16 Aux: Master");
96 lpCaps->wTechnology = AUXCAPS_AUXIN;
97 break;
99 #else
100 lpCaps->wMid = 0xAA;
101 lpCaps->wPid = 0x55;
102 lpCaps->vDriverVersion = 0x0100;
103 strcpy(lpCaps->szPname, "Generic Linux Auxiliary Driver");
104 lpCaps->wTechnology = AUXCAPS_CDAUDIO;
105 lpCaps->dwSupport = AUXCAPS_VOLUME | AUXCAPS_LRVOLUME;
106 #endif
107 return MMSYSERR_NOERROR;
108 #else
109 return MMSYSERR_NOTENABLED;
110 #endif
114 /**************************************************************************
115 * AUX_GetVolume [internal]
117 DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
119 #ifdef linux
120 int mixer;
121 int volume;
122 int cmd;
123 printf("AUX_GetVolume(%u, %08X);\n", wDevID, lpdwVol);
124 if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
125 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
126 printf("Linux 'AUX_GetVolume' // mixer device not available !\n");
127 return MMSYSERR_NOTENABLED;
129 switch(wDevID) {
130 case 0:
131 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_PCM !\n");
132 cmd = SOUND_MIXER_READ_PCM;
133 break;
134 case 1:
135 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_SYNTH !\n");
136 cmd = SOUND_MIXER_READ_SYNTH;
137 break;
138 case 2:
139 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_CD !\n");
140 cmd = SOUND_MIXER_READ_CD;
141 break;
142 case 3:
143 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_LINE !\n");
144 cmd = SOUND_MIXER_READ_LINE;
145 break;
146 case 4:
147 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_MIC !\n");
148 cmd = SOUND_MIXER_READ_MIC;
149 break;
150 case 5:
151 default:
152 printf("Linux 'AUX_GetVolume' // SOUND_MIXER_READ_VOLUME !\n");
153 cmd = SOUND_MIXER_READ_VOLUME;
154 break;
156 if (ioctl(mixer, cmd, &volume) == -1) {
157 printf("Linux 'AUX_GetVolume' // unable read mixer !\n");
158 return MMSYSERR_NOTENABLED;
160 close(mixer);
161 *lpdwVol = MAKELONG(volume, volume);
162 return MMSYSERR_NOERROR;
163 #else
164 return MMSYSERR_NOTENABLED;
165 #endif
168 /**************************************************************************
169 * AUX_SetVolume [internal]
171 DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
173 #ifdef linux
174 int mixer;
175 int volume;
176 int cmd;
177 printf("AUX_SetVolume(%u, %08X);\n", wDevID, dwParam);
178 volume = LOWORD(dwParam);
179 if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
180 printf("Linux 'AUX_SetVolume' // mixer device not available !\n");
181 return MMSYSERR_NOTENABLED;
183 switch(wDevID) {
184 case 0:
185 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_PCM !\n");
186 cmd = SOUND_MIXER_WRITE_PCM;
187 break;
188 case 1:
189 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_SYNTH !\n");
190 cmd = SOUND_MIXER_WRITE_SYNTH;
191 break;
192 case 2:
193 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_CD !\n");
194 cmd = SOUND_MIXER_WRITE_CD;
195 break;
196 case 3:
197 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_LINE !\n");
198 cmd = SOUND_MIXER_WRITE_LINE;
199 break;
200 case 4:
201 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_MIC !\n");
202 cmd = SOUND_MIXER_WRITE_MIC;
203 break;
204 case 5:
205 default:
206 printf("Linux 'AUX_SetVolume' // SOUND_MIXER_WRITE_VOLUME !\n");
207 cmd = SOUND_MIXER_WRITE_VOLUME;
208 break;
210 if (ioctl(mixer, cmd, &volume) == -1) {
211 printf("Linux 'AUX_SetVolume' // unable set mixer !\n");
212 return MMSYSERR_NOTENABLED;
214 close(mixer);
215 return MMSYSERR_NOERROR;
216 #else
217 return MMSYSERR_NOTENABLED;
218 #endif
222 /**************************************************************************
223 * auxMessage [sample driver]
225 DWORD auxMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
226 DWORD dwParam1, DWORD dwParam2)
228 printf("auxMessage(%u, %04X, %08X, %08X, %08X);\n",
229 wDevID, wMsg, dwUser, dwParam1, dwParam2);
230 switch(wMsg) {
231 case AUXDM_GETDEVCAPS:
232 return AUX_GetDevCaps(wDevID, (LPAUXCAPS)dwParam1, dwParam2);
233 case AUXDM_GETNUMDEVS:
234 printf("AUX_GetNumDevs();\n");
235 return 1L;
236 case AUXDM_GETVOLUME:
237 return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
238 case AUXDM_SETVOLUME:
239 return AUX_SetVolume(wDevID, dwParam1);
241 return MMSYSERR_NOTSUPPORTED;
245 #endif /* #ifdef BUILTIN_MMSYSTEM */