source: cmedia/trunk/Vsd/AudioIF/vsdconn.c@ 354

Last change on this file since 354 was 354, checked in by stevenhl, 17 years ago

Import untested baseline cmedia sources, work products and binaries
Binaries and work products should be deleted from repository.
once new builds are verified to work.

File size: 14.0 KB
Line 
1/************************* START OF SPECIinCATIONS ***
2*
3* SOURCE FILE NAME: VSDCONN.C
4*
5* DESCRIPTIVE NAME: VSD connector manipulator
6*
7* COPYRIGHT: IBM Confidential
8* Copyright (c) IBM Corporation 1991
9* All Rights Reserved
10*
11* STATUS: OS/2 Release 2.0
12*
13* FUNCTION: The file contains routines to enable/disable and query the
14* the status of connectors.
15*
16* Change History:
17* DATE DEVELOPER CHANGE DESCRIPTION
18* 07/22/93 Linden deCarmo File created
19*
20************************** END OF SPECIFICATIONS **************************/
21
22#define INCL_NOPMAPI
23#define INCL_DOS
24#define INCL_ERRORS
25#define INCL_AUDIO_VSD
26
27
28#include <os2.h>
29#include <os2me.h>
30#include <mcd.h>
31#include <audio.h>
32#include <stdio.h>
33#include <string.h>
34#include <hhpheap.h>
35
36
37#include <vsdcmds.h>
38#include <vsdaud.h>
39
40// INTEL VSD--need to allocate memory
41#ifndef INCL_MM_WPOS
42
43LONG Set_IO_Ports( LPMCI_AUDIO_CHANGE prAudioChange,
44 PMCI_AMP_INSTANCE prInstance,
45 LONG ulFlags )
46{
47
48 ULONG i;
49 ULONG ulNumPorts;
50
51
52 prAudioChange->lInput = INPUTS_LISTED;
53 prAudioChange->lOutput = OUTPUTS_LISTED;
54
55
56 for ( ulNumPorts = 0; ulNumPorts <= prInstance->ulNumInputs; ulNumPorts++ )
57 {
58 // if we are in record mode--DO NOT enable an input
59 // not sure why this code is here.
60
61// if ( prInstance->ulOperation == OPERATION_PLAY )
62// {
63// prAudioChange->rInputList[ ulNumPorts ].ulDevType = NULL_INPUT;
64// prAudioChange->rInputList[ ulNumPorts ].ulDevNum = NULL_INPUT;
65//
66// }
67// else
68// {
69
70// if ( ulFlags & VSD_SET_CONN )
71// {
72 prAudioChange->rInputList[ ulNumPorts ].ulDevType =
73 prInstance->rInputList[ ulNumPorts ].ulDevType;
74// }
75
76// else
77// {
78// prAudioChange->rInputList[ ulNumPorts ].ulDevType = AUDIO_IGNORE;
79// }
80// }
81
82 prAudioChange->rInputList[ ulNumPorts ].ulDevNum = DEVICE_1;
83 }
84
85 for ( ulNumPorts = 0; ulNumPorts <= prInstance->ulNumOutputs; ulNumPorts++ )
86 {
87// if ( ulFlags & VSD_SET_CONN )
88// {
89 prAudioChange->rOutputList[ ulNumPorts ].ulDevType =
90 prInstance->rOutputList[ ulNumPorts ].ulDevType;
91// }
92// else
93// {
94// prAudioChange->rOutputList[ ulNumPorts ].ulDevType = AUDIO_IGNORE;
95// }
96
97 prAudioChange->rOutputList[ ulNumPorts ].ulDevNum = DEVICE_1;
98 }
99
100 if ( prInstance->ulNumInputs < LIST_LEN )
101 {
102 for ( i = prInstance->ulNumInputs + 1; i < LIST_LEN; i++)
103 {
104 prAudioChange->rInputList[ i ].ulDevType = NULL_INPUT;
105 prAudioChange->rInputList[ i ].ulDevNum = NULL_INPUT;
106 }
107 }
108
109 if ( prInstance->ulNumOutputs + 1 < LIST_LEN )
110 {
111 for ( i = prInstance->ulNumOutputs + 1; i < LIST_LEN; i++)
112 {
113 prAudioChange->rOutputList[ i ].ulDevType = NULL_OUTPUT;
114 prAudioChange->rOutputList[ i ].ulDevNum = NULL_OUTPUT;
115 }
116 }
117 return(0L);
118
119} /* Set IO Ports */
120
121
122
123
124
125
126/************************** START OF SPECIFICATIONS ************************
127* *
128* SUBROUTINE NAME: AddPort *
129* *
130* DESCRIPTIVE NAME: Add a port *
131* *
132* FUNCTION: Adds a port to the list of active ports and ensures that *
133* exists for the application and if it has the right access. *
134* *
135* NOTES: This routine contains OS/2 system specific functions. *
136* DosQueryMem *
137* *
138* INPUT: PortArray - Array which contains the list of ports *
139* ulPort - *
140* removed because ACPA does not support lists *
141* *
142* OUTPUT: VSDERR_SUCCESS *
143* VSDERR_CANNOT_MODIFY_CONNECTOR -- if too many ports *
144* *
145* SIDE EFFECTS: *
146* *
147*************************** END OF SPECIFICATIONS *************************/
148
149ULONG AddIOPort( ULONG ulPort,
150 PVSD_INSTANCE pInstance,
151 ULONG ulDirection )
152
153{
154 if ( ulDirection == OUTPUT_PORT )
155 {
156 if ( pInstance->ulNumOutputs > LIST_LEN )
157 {
158 return VSDERR_HARDWARE;
159 }
160
161 // if this port is not already on the list of active ports,
162 // activate it
163
164 if ( !StatusIOPort( ulPort, pInstance, ulDirection ) )
165 {
166 pInstance->rOutputList[ pInstance->ulNumOutputs ].ulDevType = ulPort;
167 pInstance->rOutputList[ pInstance->ulNumOutputs++ ].ulDevNum = DEVICE_1;
168 }
169 }
170 else if ( ulDirection == INPUT_PORT )
171 {
172 if ( pInstance->ulNumInputs > LIST_LEN )
173 {
174 return VSDERR_HARDWARE;
175 }
176 pInstance->rInputList[ pInstance->ulNumInputs ].ulDevType = ulPort;
177 pInstance->rInputList[ pInstance->ulNumInputs ].ulDevNum = DEVICE_1;
178 }
179
180 return VSDERR_SUCCESS;
181
182
183
184} /* AddPort */
185
186/************************* START OF SPECIFICATIONS *************************
187* *
188* SUBROUTINE NAME: RemovePort *
189* *
190* DESCRIPTIVE NAME: Remove a Port *
191* *
192* FUNCTION: Removes a port from the list of active ports and ensures that *
193* the if all ports are turned off, the ACPA will still have the *
194* mike on *
195* *
196* NOTES: This routine contains OS/2 system specific functions. *
197* DosQueryMem *
198* *
199* INPUT: PortArray - Array which contains the list of ports *
200* ulPort - *
201* *
202* OUTPUT: VSDERR_SUCCESS *
203* VSDERR_CANNOT_MODIFY_CONNECTOR -- if too many ports *
204* *
205* SIDE EFFECTS: *
206* *
207*************************** END OF SPECIFICATIONS *************************/
208
209ULONG RemoveIOPort( ULONG ulPort,
210 PVSD_INSTANCE pInstance,
211 ULONG ulDirection )
212
213{
214ULONG ulSearchCounter = 0;
215ULONG ulFoundPort;
216
217 if ( ulDirection == OUTPUT_PORT )
218 {
219 if ( pInstance->ulNumOutputs > LIST_LEN )
220 {
221 return VSDERR_HARDWARE;
222 }
223 // acpa specific code-- no way to turn off the mike if it is the
224 // last connector
225
226 while ( ulSearchCounter <= pInstance->ulNumOutputs )
227 {
228 if ( pInstance->rOutputList[ ulSearchCounter ].ulDevType == ulPort )
229 {
230 ulFoundPort = MCI_TRUE;
231 break;
232 }
233 ulSearchCounter++;
234 }
235
236 if ( ulFoundPort )
237 {
238 // move the remainder of the list forward
239
240
241 memmove( &pInstance->rOutputList[ ulSearchCounter ],
242 &pInstance->rOutputList[ ulSearchCounter + 1 ],
243 ( ( LIST_LEN - 1) - ulSearchCounter + 1 ) * sizeof ( MCI_PORT_LIST ) );
244 pInstance->ulNumOutputs--;
245 }
246
247 }
248 else if ( ulDirection == INPUT_PORT )
249 {
250 if ( pInstance->ulNumInputs > LIST_LEN )
251 {
252 return VSDERR_HARDWARE;
253 }
254 pInstance->rInputList[ pInstance->ulNumInputs ].ulDevType = 0;
255 pInstance->rInputList[ pInstance->ulNumInputs ].ulDevNum = 0;
256 }
257 return VSDERR_SUCCESS;
258
259
260
261} /* RemoveIOPort */
262
263
264/************************* START OF SPECIFICATIONS *************************
265* *
266* SUBROUTINE NAME: StatusPort *
267* *
268* DESCRIPTIVE NAME: Status for a port *
269* *
270* FUNCTION: Returns if a particular port is currently active. *
271* *
272* NOTES: This routine contains OS/2 system specific functions. *
273* DosQueryMem *
274* *
275* INPUT: ulPort *
276* *
277* OUTPUT: MCI_TRUE *
278* MCI_FALSE *
279* *
280* SIDE EFFECTS: *
281* *
282*************************** END OF SPECIFICATIONS **************************/
283
284ULONG StatusIOPort( ULONG ulPort,
285 PVSD_INSTANCE pInstance,
286 ULONG ulDirection )
287
288{
289 ULONG ulSearchCounter = 0;
290 ULONG ulFoundPort = MCI_FALSE;
291
292 if ( ulDirection == OUTPUT_PORT )
293 {
294
295 if ( pInstance->ulNumOutputs > LIST_LEN )
296 {
297 return VSDERR_HARDWARE;
298 }
299
300 // loop through the list of inputs till we hit the end or we
301 // find the port
302
303 while ( ulSearchCounter <= pInstance->ulNumOutputs )
304 {
305 if ( pInstance->rOutputList[ ulSearchCounter ].ulDevType == ulPort )
306 {
307 ulFoundPort = MCI_TRUE;
308 break;
309 }
310 ulSearchCounter++;
311 }
312
313 }
314 else if ( ulDirection == INPUT_PORT )
315 {
316
317 if ( pInstance->ulNumInputs > LIST_LEN )
318 {
319 return VSDERR_HARDWARE;
320 }
321 // loop through the list of inputs till we hit the end or we
322 // find the port
323
324 while ( ulSearchCounter <= pInstance->ulNumInputs )
325 {
326 if ( pInstance->rInputList[ ulSearchCounter ].ulDevType == ulPort )
327 {
328 ulFoundPort = MCI_TRUE;
329 break;
330 }
331 ulSearchCounter++;
332 }
333 }
334 return ulFoundPort;
335
336} /* AddPort */
337
338// INTEL VSD--need to allocate memory
339#endif
340
341/************************* START OF SPECIFICATIONS *************************
342* *
343* SUBROUTINE NAME: ValidateIndex *
344* *
345* DESCRIPTIVE NAME: Reports if a connector index is valid. *
346* *
347* FUNCTION: Returns if a particular port is currently active. *
348* *
349* NOTES: This routine reports if the mixer device supports a particular *
350* connector index. More than one Connectors (i.e. the speakers) *
351* can be attached to the VSD. Individual connectors are *
352* distinguished by the index. *
353* *
354* INPUT: ulPort *
355* *
356* OUTPUT: MCI_TRUE *
357* MCI_FALSE *
358* *
359* SIDE EFFECTS: *
360* *
361*************************** END OF SPECIFICATIONS **************************/
362
363
364
365ULONG ValidateIndex( ULONG ulType, ULONG ulIndex )
366
367{
368 /*---------------------------------------------------------------------*
369 * Ensure only that valid index's are used
370 *---------------------------------------------------------------------*/
371
372 if ( ulType == MCI_SPEAKERS_CONNECTOR )
373 {
374 if ( ulIndex > 2 )
375 {
376 return VSDERR_INVALID_CONNECTOR_INDEX;
377 }
378 }
379 else if ( ulIndex != 1 )
380 {
381 return VSDERR_INVALID_CONNECTOR_INDEX;
382 } /* If the index is not one */
383
384 return ( VSDERR_SUCCESS );
385} /* ValidateIndex */
Note: See TracBrowser for help on using the repository browser.