Debian Codegraph @

xpp/oct612x/octdeviceapi/oct6100api/oct6100_api/oct6100_mixer.c

raw
1 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2
3 File: oct6100_mixer.c
4
5 Copyright (c) 2001-2007 Octasic Inc.
6
7 Description:
8
9 This file contains the functions used to manage the allocation of mixer
10 blocks in memories.
11
12 This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is
13 free software; you can redistribute it and/or modify it under the terms of
14 the GNU General Public License as published by the Free Software Foundation;
15 either version 2 of the License, or (at your option) any later version.
16
17 The OCT6100 GPL API is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with the OCT6100 GPL API; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
26 $Octasic_Release: OCT612xAPI-01.00-PR49 $
27
28 $Octasic_Revision: 42 $
29
30 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
31
32
33 /***************************** INCLUDE FILES *******************************/
34
35 #include "octdef.h"
36
37 #include "oct6100api/oct6100_defines.h"
38 #include "oct6100api/oct6100_errors.h"
39
40 #include "apilib/octapi_llman.h"
41
42 #include "oct6100api/oct6100_apiud.h"
43 #include "oct6100api/oct6100_tlv_inst.h"
44 #include "oct6100api/oct6100_chip_open_inst.h"
45 #include "oct6100api/oct6100_chip_stats_inst.h"
46 #include "oct6100api/oct6100_interrupts_inst.h"
47 #include "oct6100api/oct6100_remote_debug_inst.h"
48 #include "oct6100api/oct6100_debug_inst.h"
49 #include "oct6100api/oct6100_api_inst.h"
50 #include "oct6100api/oct6100_channel_inst.h"
51 #include "oct6100api/oct6100_mixer_inst.h"
52
53 #include "oct6100api/oct6100_interrupts_pub.h"
54 #include "oct6100api/oct6100_chip_open_pub.h"
55 #include "oct6100api/oct6100_channel_pub.h"
56 #include "oct6100api/oct6100_mixer_pub.h"
57
58 #include "oct6100_chip_open_priv.h"
59 #include "oct6100_miscellaneous_priv.h"
60 #include "oct6100_channel_priv.h"
61 #include "oct6100_mixer_priv.h"
62
63 /**************************** PUBLIC FUNCTIONS ****************************/
64
65
66 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
67
68 Function: Oct6100MixerCopyEventCreate
69
70 Description: This function creates a mixer copy event used to copy
71 information from one channel port to another channel port.
72
73 -------------------------------------------------------------------------------
74 | Argument | Description
75 -------------------------------------------------------------------------------
76 f_pApiInstance Pointer to API instance. This memory is used to keep the
77 present state of the chip and all its resources.
78
79 f_pCopyEventCreate Pointer to a mixer copy event structure.
80
81 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
82 #if !SKIP_Oct6100MixerCopyEventCreateDef
83 UINT32 Oct6100MixerCopyEventCreateDef(
84 tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate )
85 {
86 f_pCopyEventCreate->pulCopyEventHndl = NULL;
87
88 f_pCopyEventCreate->ulSourceChanHndl = cOCT6100_INVALID_HANDLE;
89 f_pCopyEventCreate->ulSourcePort = cOCT6100_INVALID_PORT;
90
91 f_pCopyEventCreate->ulDestinationChanHndl = cOCT6100_INVALID_HANDLE;
92 f_pCopyEventCreate->ulDestinationPort = cOCT6100_INVALID_PORT;
93
94 return cOCT6100_ERR_OK;
95 }
96 #endif
97
98
99 #if !SKIP_Oct6100MixerCopyEventCreate
100 UINT32 Oct6100MixerCopyEventCreate(
101 tPOCT6100_INSTANCE_API f_pApiInstance,
102 tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate )
103 {
104 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
105 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
106 UINT32 ulSerRes = cOCT6100_ERR_OK;
107 UINT32 ulFncRes = cOCT6100_ERR_OK;
108
109 /* Set the process context of the serialize structure. */
110 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
111 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
112
113 /* Seize all list semaphores needed by this function. */
114 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
115 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
116 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
117 if ( ulSerRes == cOCT6100_ERR_OK )
118 {
119 /* Call the serialized function. */
120 ulFncRes = Oct6100MixerCopyEventCreateSer( f_pApiInstance, f_pCopyEventCreate );
121 }
122 else
123 {
124 return ulSerRes;
125 }
126
127 /* Release the seized semaphores. */
128 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
129 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
130
131 /* If an error occured then return the error code. */
132 if ( ulSerRes != cOCT6100_ERR_OK )
133 return ulSerRes;
134 if ( ulFncRes != cOCT6100_ERR_OK )
135 return ulFncRes;
136
137 return cOCT6100_ERR_OK;
138 }
139 #endif
140
141
142 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
143
144 Function: Oct6100MixerCopyEventDestroy
145
146 Description: This function destroys a mixer copy event used to copy
147 information from one channel port to another.
148
149 -------------------------------------------------------------------------------
150 | Argument | Description
151 -------------------------------------------------------------------------------
152 f_pApiInstance Pointer to API instance. This memory is used to keep the
153 present state of the chip and all its resources.
154
155 f_pCopyEventDestroy Pointer to a destroy copy event structure.
156
157 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
158 #if !SKIP_Oct6100MixerCopyEventDestroyDef
159 UINT32 Oct6100MixerCopyEventDestroyDef(
160 tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy )
161 {
162 f_pCopyEventDestroy->ulCopyEventHndl = cOCT6100_INVALID_HANDLE;
163
164 return cOCT6100_ERR_OK;
165 }
166 #endif
167
168
169 #if !SKIP_Oct6100MixerCopyEventDestroy
170 UINT32 Oct6100MixerCopyEventDestroy(
171 tPOCT6100_INSTANCE_API f_pApiInstance,
172 tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy )
173 {
174 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
175 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
176 UINT32 ulSerRes = cOCT6100_ERR_OK;
177 UINT32 ulFncRes = cOCT6100_ERR_OK;
178
179 /* Set the process context of the serialize structure. */
180 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
181 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
182
183 /* Seize all list semaphores needed by this function. */
184 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
185 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
186 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
187 if ( ulSerRes == cOCT6100_ERR_OK )
188 {
189 /* Call the serialized function. */
190 ulFncRes = Oct6100MixerCopyEventDestroySer( f_pApiInstance, f_pCopyEventDestroy );
191 }
192 else
193 {
194 return ulSerRes;
195 }
196
197 /* Release the seized semaphores. */
198 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
199 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
200
201 /* If an error occured then return the error code. */
202 if ( ulSerRes != cOCT6100_ERR_OK )
203 return ulSerRes;
204 if ( ulFncRes != cOCT6100_ERR_OK )
205 return ulFncRes;
206
207 return cOCT6100_ERR_OK;
208 }
209 #endif
210
211
212 /**************************** PRIVATE FUNCTIONS ****************************/
213
214
215 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
216
217 Function: Oct6100ApiGetMixerSwSizes
218
219 Description: Gets the sizes of all portions of the API instance pertinent
220 to the management of mixer events.
221
222 -------------------------------------------------------------------------------
223 | Argument | Description
224 -------------------------------------------------------------------------------
225
226 f_pOpenChip User chip configuration.
227 f_pInstSizes Pointer to struct containing instance sizes.
228
229 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
230 #if !SKIP_Oct6100ApiGetMixerSwSizes
231 UINT32 Oct6100ApiGetMixerSwSizes(
232 IN tPOCT6100_CHIP_OPEN f_pOpenChip,
233 OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
234 {
235 UINT32 ulTempVar;
236 UINT32 ulResult;
237
238 /* Calculate the API memory required for the resource entry lists. */
239 f_pInstSizes->ulMixerEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT );
240
241 /* Calculate memory needed for mixers entry allocation. */
242 ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_MIXER_EVENTS, &f_pInstSizes->ulMixerEventAlloc );
243 if ( ulResult != cOCT6100_ERR_OK )
244 return cOCT6100_ERR_FATAL_1D;
245
246 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventList, ulTempVar )
247 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventAlloc, ulTempVar )
248
249
250 f_pInstSizes->ulCopyEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_COPY_EVENT );
251
252 ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_MIXER_EVENTS, &f_pInstSizes->ulCopyEventAlloc );
253 if ( ulResult != cOCT6100_ERR_OK )
254 return cOCT6100_ERR_FATAL_1D;
255
256 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventList, ulTempVar )
257 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventAlloc, ulTempVar )
258
259
260 return cOCT6100_ERR_OK;
261 }
262 #endif
263
264
265 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
266
267 Function: Oct6100ApiMixerSwInit
268
269 Description: Initializes all elements of the instance structure associated
270 to the mixer events.
271
272 -------------------------------------------------------------------------------
273 | Argument | Description
274 -------------------------------------------------------------------------------
275 f_pApiInstance Pointer to API instance. This mixer is used to keep
276 the present state of the chip and all its resources.
277
278 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
279 #if !SKIP_Oct6100ApiMixerSwInit
280 UINT32 Oct6100ApiMixerSwInit(
281 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
282 {
283 tPOCT6100_SHARED_INFO pSharedInfo;
284 tPOCT6100_API_MIXER_EVENT pMixerEventList;
285 PVOID pMixerEventAlloc;
286 PVOID pCopyEventAlloc;
287 UINT32 ulTempVar;
288 UINT32 ulResult;
289
290 /* Get local pointer(s). */
291 pSharedInfo = f_pApiInstance->pSharedInfo;
292
293 /*===================================================================*/
294 /* Initialize the mixer event list. */
295 mOCT6100_GET_MIXER_EVENT_LIST_PNT( pSharedInfo, pMixerEventList );
296
297 /* Initialize the mixer event allocation software to "all free". */
298 Oct6100UserMemSet( pMixerEventList, 0x00, cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT ));
299
300 mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( pSharedInfo, pMixerEventAlloc )
301
302 ulResult = OctapiLlmAllocInit( &pMixerEventAlloc, cOCT6100_MAX_MIXER_EVENTS );
303 if ( ulResult != cOCT6100_ERR_OK )
304 return cOCT6100_ERR_FATAL_1F;
305
306 /* Now reserve the first entry as the first node. */
307 ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar );
308 if ( ulResult != cOCT6100_ERR_OK )
309 {
310 return cOCT6100_ERR_FATAL_20;
311 }
312
313 /* Check that we obtain the first event. */
314 if ( ulTempVar != 0 )
315 return cOCT6100_ERR_FATAL_21;
316
317 /* Now reserve the tail entry. */
318 ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar );
319 if ( ulResult != cOCT6100_ERR_OK )
320 {
321 return cOCT6100_ERR_FATAL_AA;
322 }
323 /* Check that we obtain the first event. */
324 if ( ulTempVar != 1 )
325 return cOCT6100_ERR_FATAL_AB;
326
327 /* Program the head node. */
328 pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].fReserved = TRUE;
329 pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usNextEventPtr = cOCT6100_MIXER_TAIL_NODE;
330 pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
331
332 /* Program the tail node. */
333 pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].fReserved = TRUE;
334 pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].usNextEventPtr = cOCT6100_INVALID_INDEX;
335 pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
336
337 /* Now reserve the entry used for channel recording if the feature is enabled. */
338 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
339 {
340 UINT32 ulAllocIndex;
341
342 /* Reserve an entry to copy the desire SOUT signal to the SIN signal of the recording channel. */
343 ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulAllocIndex );
344 if ( ulResult != cOCT6100_ERR_OK )
345 {
346 return cOCT6100_ERR_FATAL_90;
347 }
348
349 pSharedInfo->MixerInfo.usRecordCopyEventIndex = (UINT16)( ulAllocIndex & 0xFFFF );
350
351 /* Reserve an entry to copy the saved SIN signal of the debugged channel into it's original location. */
352 ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulAllocIndex );
353 if ( ulResult != cOCT6100_ERR_OK )
354 {
355 return cOCT6100_ERR_FATAL_90;
356 }
357
358 pSharedInfo->MixerInfo.usRecordSinEventIndex = (UINT16)( ulAllocIndex & 0xFFFF );
359
360 /* Configure the SIN event. */
361 pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].fReserved = TRUE;
362 pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].usNextEventPtr = cOCT6100_MIXER_TAIL_NODE;
363 pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
364
365 /* Configure the SOUT copy event. */
366 pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].fReserved = TRUE;
367 pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].usNextEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
368 pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
369
370 /* Program the head node. */
371 pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usNextEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
372 }
373
374 /* Initialize the copy event list. */
375 mOCT6100_GET_COPY_EVENT_ALLOC_PNT( pSharedInfo, pCopyEventAlloc )
376
377 ulResult = OctapiLlmAllocInit( &pCopyEventAlloc, cOCT6100_MAX_MIXER_EVENTS );
378 if ( ulResult != cOCT6100_ERR_OK )
379 return cOCT6100_ERR_FATAL_B4;
380
381 return cOCT6100_ERR_OK;
382 }
383 #endif
384
385
386 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
387
388 Function: Oct6100ApiMixerEventAdd
389
390 Description: This function adds a mixer event event to the list of events
391 based on the event type passed to the function.
392
393 -------------------------------------------------------------------------------
394 | Argument | Description
395 -------------------------------------------------------------------------------
396 f_pApiInstance Pointer to API instance. This memory is used to keep
397 the present state of the chip and all its resources.
398 f_usEventIndex Index of the event within the API's mixer event list.
399 f_usEventType Type of mixer event.
400 f_usDestinationChanIndex Index of the destination channel within the API's
401 channel list.
402
403 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
404 #if !SKIP_Oct6100ApiMixerEventAdd
405 UINT32 Oct6100ApiMixerEventAdd(
406 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
407 IN UINT16 f_usEventIndex,
408 IN UINT16 f_usEventType,
409 IN UINT16 f_usDestinationChanIndex )
410 {
411 tPOCT6100_SHARED_INFO pSharedInfo;
412 tPOCT6100_API_MIXER_EVENT pCurrentEventEntry;
413 tPOCT6100_API_MIXER_EVENT pTempEventEntry;
414 tPOCT6100_API_CHANNEL pDestinationEntry;
415 tOCT6100_WRITE_PARAMS WriteParams;
416 UINT32 ulResult;
417 UINT16 usTempEventIndex;
418
419 /* Obtain local pointer to shared portion of instance. */
420 pSharedInfo = f_pApiInstance->pSharedInfo;
421
422 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
423
424 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
425
426 /* Get a pointer to the event entry. */
427 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex );
428
429 /* Get a pointer to the destination channel entry. */
430 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, f_usDestinationChanIndex );
431
432 /* Now proceed according to the event type. */
433 switch ( f_usEventType )
434 {
435 case cOCT6100_EVENT_TYPE_SOUT_COPY:
436
437 /* Now insert the Sin copy event */
438 if ( pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
439 {
440 /* The only node in the list before the point where the node needs to */
441 /* be inserted is the head node. */
442 usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
443
444 /* This node will be the first one in the Sout copy section. */
445 pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = f_usEventIndex;
446 pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = f_usEventIndex;
447 }
448 else /* pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr != cOCT6100_INVALID_INDEX */
449 {
450 usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
451 pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = f_usEventIndex;
452 }
453
454 break;
455
456 case cOCT6100_EVENT_TYPE_SIN_COPY:
457
458 /* Now insert the Sin copy event. */
459 if ( pSharedInfo->MixerInfo.usFirstSinCopyEventPtr == cOCT6100_INVALID_INDEX )
460 {
461 /* This is the first Sin copy event. We must find the event that comes before */
462 /* the event we want to add. First let's check for a bridge event. */
463 if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == cOCT6100_INVALID_INDEX )
464 {
465 /* No event in the bridge section, now let's check in the Sout copy section. */
466 if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
467 {
468 /* The only node in the list then is the head node. */
469 usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
470 }
471 else
472 {
473 usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
474 }
475 }
476 else
477 {
478 usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr;
479 }
480
481 /* This node will be the first one in the Sin copy section. */
482 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = f_usEventIndex;
483 pSharedInfo->MixerInfo.usLastSinCopyEventPtr = f_usEventIndex;
484 }
485 else /* pSharedInfo->MixerInfo.usFirstSinCopyEventPtr != cOCT6100_INVALID_INDEX */
486 {
487 usTempEventIndex = pSharedInfo->MixerInfo.usLastSinCopyEventPtr;
488 pSharedInfo->MixerInfo.usLastSinCopyEventPtr = f_usEventIndex;
489 }
490
491 break;
492
493 default:
494 return cOCT6100_ERR_FATAL_AF;
495
496 }
497
498 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
499
500 /*=======================================================================*/
501 /* Program the Copy event. */
502
503 /* Set the Copy event first. */
504 pCurrentEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_COPY;
505 pCurrentEventEntry->usNextEventPtr = pTempEventEntry->usNextEventPtr;
506
507 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
508 WriteParams.ulWriteAddress += 4;
509 WriteParams.usWriteData = pCurrentEventEntry->usNextEventPtr;
510
511 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
512 if ( ulResult != cOCT6100_ERR_OK )
513 return ulResult;
514
515 /*=======================================================================*/
516
517 /*=======================================================================*/
518 /* Modify the previous node. */
519
520 /* Set the last Sub-store entry. */
521 pTempEventEntry->usNextEventPtr = f_usEventIndex;
522
523 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
524 WriteParams.ulWriteAddress += 4;
525 WriteParams.usWriteData = f_usEventIndex;
526
527 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
528 if ( ulResult != cOCT6100_ERR_OK )
529 return ulResult;
530
531 /*=======================================================================*/
532
533 /* Save the destination channel index, needed when removing the event from the mixer. */
534 pCurrentEventEntry->usDestinationChanIndex = f_usDestinationChanIndex;
535
536 /* Mark the entry as reserved. */
537 pCurrentEventEntry->fReserved = TRUE;
538
539 /* Increment the event count on that particular destination channel */
540 pDestinationEntry->usMixerEventCnt++;
541
542 return cOCT6100_ERR_OK;
543 }
544 #endif
545
546
547 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
548
549 Function: Oct6100ApiMixerEventRemove
550
551 Description: This function removes a mixer event event from the list of events based
552 on the event type passed to the function.
553
554 -------------------------------------------------------------------------------
555 | Argument | Description
556 -------------------------------------------------------------------------------
557 f_pApiInstance Pointer to API instance. This memory is used to keep the
558 present state of the chip and all its resources.
559
560 f_usEventIndex Index of event within the API's mixer event list.
561 f_usEventType Type of mixer event.
562
563 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
564 #if !SKIP_Oct6100ApiMixerEventRemove
565 UINT32 Oct6100ApiMixerEventRemove(
566 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
567 IN UINT16 f_usEventIndex,
568 IN UINT16 f_usEventType )
569 {
570 tPOCT6100_SHARED_INFO pSharedInfo;
571 tPOCT6100_API_MIXER_EVENT pCurrentEventEntry;
572 tPOCT6100_API_MIXER_EVENT pTempEventEntry;
573 tPOCT6100_API_CHANNEL pDestinationEntry;
574 tOCT6100_WRITE_BURST_PARAMS BurstWriteParams;
575 tOCT6100_WRITE_PARAMS WriteParams;
576 BOOL fFirstSinCopyEvent = FALSE;
577 UINT32 ulResult;
578 UINT16 usTempEventIndex;
579 UINT32 ulLoopCount = 0;
580 UINT16 ausWriteData[ 4 ] = { 0 };
581
582 /* Obtain local pointer to shared portion of instance. */
583 pSharedInfo = f_pApiInstance->pSharedInfo;
584
585 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
586
587 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
588
589 BurstWriteParams.pProcessContext = f_pApiInstance->pProcessContext;
590
591 BurstWriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
592 BurstWriteParams.pusWriteData = ausWriteData;
593 BurstWriteParams.ulWriteLength = 4;
594
595 /* Get a pointer to the event entry. */
596 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex );
597
598 /* Get the pointer to the channel entry. */
599 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, pCurrentEventEntry->usDestinationChanIndex );
600
601 /* Now proceed according to the event type. */
602 switch ( f_usEventType )
603 {
604 case cOCT6100_EVENT_TYPE_SOUT_COPY:
605
606 if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr )
607 {
608 usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
609 }
610 else
611 {
612 /* Now insert the Sin copy event. */
613 usTempEventIndex = pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr;
614 }
615
616 /* Find the copy entry before the entry to remove. */
617 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
618
619 while( pTempEventEntry->usNextEventPtr != f_usEventIndex )
620 {
621 usTempEventIndex = pTempEventEntry->usNextEventPtr;
622
623 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
624
625 ulLoopCount++;
626 if ( ulLoopCount == cOCT6100_MAX_LOOP )
627 return cOCT6100_ERR_FATAL_B2;
628 }
629
630 /*=======================================================================*/
631 /* Update the global mixer pointers. */
632 if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr )
633 {
634 if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
635 {
636 /* This event was the only of the list.*/
637 pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = cOCT6100_INVALID_INDEX;
638 pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = cOCT6100_INVALID_INDEX;
639 }
640 else
641 {
642 pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = pCurrentEventEntry->usNextEventPtr;
643 }
644 }
645 else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
646 {
647 pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = usTempEventIndex;
648 }
649 /*=======================================================================*/
650
651 break;
652
653
654 case cOCT6100_EVENT_TYPE_SIN_COPY:
655
656 if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr )
657 {
658 fFirstSinCopyEvent = TRUE;
659
660 if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr != cOCT6100_INVALID_INDEX )
661 {
662 usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr;
663 }
664 else if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr != cOCT6100_INVALID_INDEX )
665 {
666 usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
667 }
668 else
669 {
670 usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
671 }
672 }
673 else
674 {
675 /* Now insert the Sin copy event. */
676 usTempEventIndex = pSharedInfo->MixerInfo.usFirstSinCopyEventPtr;
677 }
678
679 /* Find the copy entry before the entry to remove. */
680 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
681
682 /* If we are not the first event of the Sin copy list. */
683 if ( fFirstSinCopyEvent == FALSE )
684 {
685 while( pTempEventEntry->usNextEventPtr != f_usEventIndex )
686 {
687 usTempEventIndex = pTempEventEntry->usNextEventPtr;
688 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
689
690 ulLoopCount++;
691 if ( ulLoopCount == cOCT6100_MAX_LOOP )
692 return cOCT6100_ERR_FATAL_B1;
693 }
694 }
695
696 /*=======================================================================*/
697 /* Update the global mixer pointers. */
698 if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr )
699 {
700 if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr )
701 {
702 /* This event was the only of the list. */
703 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = cOCT6100_INVALID_INDEX;
704 pSharedInfo->MixerInfo.usLastSinCopyEventPtr = cOCT6100_INVALID_INDEX;
705 }
706 else
707 {
708 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pCurrentEventEntry->usNextEventPtr;
709 }
710 }
711 else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr )
712 {
713 pSharedInfo->MixerInfo.usLastSinCopyEventPtr = usTempEventIndex;
714 }
715 /*=======================================================================*/
716
717 break;
718
719 default:
720 return cOCT6100_ERR_FATAL_B0;
721
722 }
723
724 /*=======================================================================*/
725 /* Modify the previous event. */
726
727 pTempEventEntry->usNextEventPtr = pCurrentEventEntry->usNextEventPtr;
728
729 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
730 WriteParams.ulWriteAddress += 4;
731 WriteParams.usWriteData = pTempEventEntry->usNextEventPtr;
732
733 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
734 if ( ulResult != cOCT6100_ERR_OK )
735 return ulResult;
736
737 /*=======================================================================*/
738
739
740 /*=======================================================================*/
741 /* Clear the current event. */
742
743 BurstWriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
744
745 mOCT6100_DRIVER_WRITE_BURST_API( BurstWriteParams, ulResult );
746 if ( ulResult != cOCT6100_ERR_OK )
747 return ulResult;
748
749 /*=======================================================================*/
750
751
752 /*=======================================================================*/
753 /* Decrement the mixer event count active on that channel. */
754 pDestinationEntry->usMixerEventCnt--;
755
756 /*=======================================================================*/
757
758
759 /*=======================================================================*/
760
761 /* This index of this channel is not valid anymore! */
762 pCurrentEventEntry->usDestinationChanIndex = cOCT6100_INVALID_INDEX;
763
764 /* Mark this entry as free. */
765 pCurrentEventEntry->fReserved = FALSE;
766
767 return cOCT6100_ERR_OK;
768 }
769 #endif
770
771
772 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
773
774 Function: Oct6100MixerCopyEventCreateSer
775
776 -------------------------------------------------------------------------------
777 | Argument | Description
778 -------------------------------------------------------------------------------
779 f_pApiInstance Pointer to API instance. This memory is used to keep the
780 present state of the chip and all its resources.
781
782 f_pCopyEventCreate Pointer to a create copy event structure.
783
784 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
785 #if !SKIP_Oct6100MixerCopyEventCreateSer
786 UINT32 Oct6100MixerCopyEventCreateSer(
787 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
788 IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate )
789 {
790 UINT16 usCopyEventIndex = 0;
791 UINT16 usMixerEventIndex = 0;
792 UINT16 usSourceChanIndex;
793 UINT16 usDestinationChanIndex;
794 UINT32 ulResult;
795
796 /* Check the user's configuration of the copy event for errors. */
797 ulResult = Oct6100ApiCheckCopyEventCreateParams( f_pApiInstance,
798 f_pCopyEventCreate,
799 &usSourceChanIndex,
800 &usDestinationChanIndex );
801 if ( ulResult != cOCT6100_ERR_OK )
802 return ulResult;
803
804 /* Reserve all resources needed by the copy event. */
805 ulResult = Oct6100ApiReserveCopyEventCreateResources( f_pApiInstance,
806 &usCopyEventIndex,
807 &usMixerEventIndex );
808 if ( ulResult != cOCT6100_ERR_OK )
809 return ulResult;
810
811 /* Write all necessary structures to activate the echo cancellation channel. */
812 ulResult = Oct6100ApiWriteCopyEventCreateStructs( f_pApiInstance,
813 f_pCopyEventCreate,
814 usMixerEventIndex,
815 usSourceChanIndex,
816 usDestinationChanIndex );
817 if ( ulResult != cOCT6100_ERR_OK )
818 return ulResult;
819
820 /* Update the new echo cancellation channels's entry in the ECHO channel list. */
821 ulResult = Oct6100ApiUpdateCopyEventCreateEntry( f_pApiInstance,
822 f_pCopyEventCreate,
823 usCopyEventIndex,
824 usMixerEventIndex,
825 usSourceChanIndex,
826 usDestinationChanIndex );
827 if ( ulResult != cOCT6100_ERR_OK )
828 return ulResult;
829
830 return cOCT6100_ERR_OK;
831 }
832 #endif
833
834
835 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
836
837 Function: Oct6100ApiCheckCopyEventCreateParams
838
839 Description: Checks the user's parameter passed to the create
840 copy event function.
841
842 -------------------------------------------------------------------------------
843 | Argument | Description
844 -------------------------------------------------------------------------------
845 f_pApiInstance Pointer to API instance. This memory is used to keep the
846 present state of the chip and all its resources.
847
848 f_pCopyEventCreate Pointer to a create copy event structure.
849 f_pusSourceChanIndex Pointer to the index of the input channel.
850 f_pusDestinationChanIndex Pointer to the index of the output channel.
851
852 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
853 #if !SKIP_Oct6100ApiCheckCopyEventCreateParams
854 UINT32 Oct6100ApiCheckCopyEventCreateParams(
855 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
856 IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate,
857 OUT PUINT16 f_pusSourceChanIndex,
858 OUT PUINT16 f_pusDestinationChanIndex )
859 {
860 tPOCT6100_SHARED_INFO pSharedInfo;
861 tPOCT6100_API_CHANNEL pSourceEntry;
862 tPOCT6100_API_CHANNEL pDestinationEntry;
863 UINT32 ulEntryOpenCnt;
864
865 /* Obtain shared resources pointer. */
866 pSharedInfo = f_pApiInstance->pSharedInfo;
867
868 if ( f_pCopyEventCreate->pulCopyEventHndl == NULL )
869 return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
870
871 if ( f_pCopyEventCreate->ulSourceChanHndl == cOCT6100_INVALID_HANDLE )
872 return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
873 if ( f_pCopyEventCreate->ulDestinationChanHndl == cOCT6100_INVALID_HANDLE )
874 return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
875
876 if ( f_pCopyEventCreate->ulSourcePort != cOCT6100_CHANNEL_PORT_RIN &&
877 f_pCopyEventCreate->ulSourcePort != cOCT6100_CHANNEL_PORT_SIN )
878 return cOCT6100_ERR_MIXER_SOURCE_PORT;
879
880 if ( f_pCopyEventCreate->ulDestinationPort != cOCT6100_CHANNEL_PORT_RIN &&
881 f_pCopyEventCreate->ulDestinationPort != cOCT6100_CHANNEL_PORT_SIN )
882 return cOCT6100_ERR_MIXER_DESTINATION_PORT;
883
884 /*=======================================================================*/
885 /* Verify the first channel handle. */
886
887 if ( (f_pCopyEventCreate->ulSourceChanHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
888 return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
889
890 *f_pusSourceChanIndex = (UINT16)( f_pCopyEventCreate->ulSourceChanHndl & cOCT6100_HNDL_INDEX_MASK );
891 if ( *f_pusSourceChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
892 return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
893
894 /* Get a pointer to the channel's list entry. */
895 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSourceEntry, *f_pusSourceChanIndex )
896
897 /* Extract the entry open count from the provided handle. */
898 ulEntryOpenCnt = ( f_pCopyEventCreate->ulSourceChanHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
899
900 /* Check for errors. */
901 if ( pSourceEntry->fReserved != TRUE )
902 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
903 if ( ulEntryOpenCnt != pSourceEntry->byEntryOpenCnt )
904 return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
905 if ( pSourceEntry->CodecConfig.byDecoderPort == f_pCopyEventCreate->ulSourcePort )
906 return cOCT6100_ERR_MIXER_SOURCE_ADPCM_RESOURCES_ACTIVATED;
907
908 /*=======================================================================*/
909
910 /*=======================================================================*/
911 /* Verify the second channel handle. */
912
913 if ( (f_pCopyEventCreate->ulDestinationChanHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
914 return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
915
916 *f_pusDestinationChanIndex = (UINT16)( f_pCopyEventCreate->ulDestinationChanHndl & cOCT6100_HNDL_INDEX_MASK );
917 if ( *f_pusDestinationChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
918 return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
919
920 /* Get a pointer to the channel's list entry. */
921 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, *f_pusDestinationChanIndex )
922
923 /* Extract the entry open count from the provided handle. */
924 ulEntryOpenCnt = ( f_pCopyEventCreate->ulDestinationChanHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
925
926 /* Check for errors. */
927 if ( pDestinationEntry->fReserved != TRUE )
928 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
929 if ( ulEntryOpenCnt != pDestinationEntry->byEntryOpenCnt )
930 return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
931 if ( pDestinationEntry->CodecConfig.byDecoderPort == f_pCopyEventCreate->ulDestinationPort )
932 return cOCT6100_ERR_MIXER_DEST_ADPCM_RESOURCES_ACTIVATED;
933
934 /*=======================================================================*/
935
936 return cOCT6100_ERR_OK;
937 }
938 #endif
939
940
941 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
942
943 Function: Oct6100ApiReserveCopyEventCreateResources
944
945 -------------------------------------------------------------------------------
946 | Argument | Description
947 -------------------------------------------------------------------------------
948 f_pApiInstance Pointer to API instance. This memory is used to keep the
949 present state of the chip and all its resources.
950
951 f_pusCopyEntryIndex Pointer to the index of the copy entry within the API's list.
952 f_pusCopyEventIndex Pointer to the index of the mixer copy event.
953 .
954 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
955 #if !SKIP_Oct6100ApiReserveCopyEventCreateResources
956 UINT32 Oct6100ApiReserveCopyEventCreateResources(
957 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
958 OUT PUINT16 f_pusCopyEntryIndex,
959 IN OUT PUINT16 f_pusCopyEventIndex )
960 {
961 tPOCT6100_SHARED_INFO pSharedInfo;
962 UINT32 ulResult = cOCT6100_ERR_OK;
963 UINT32 ulTempVar;
964
965 /* Obtain local pointer to shared portion of instance. */
966 pSharedInfo = f_pApiInstance->pSharedInfo;
967
968 /*===============================================================================*/
969 /* Verify and reserve the resources that might already be allocated. */
970
971 ulResult = Oct6100ApiReserveCopyEventEntry( f_pApiInstance,
972 f_pusCopyEntryIndex );
973 if ( ulResult == cOCT6100_ERR_OK )
974 {
975 /* Reserve the source copy event for the first channel. */
976 ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
977 f_pusCopyEventIndex );
978 if ( ulResult != cOCT6100_ERR_OK )
979 {
980 /* Reserve the Sin copy event for the first channel. */
981 ulTempVar = Oct6100ApiReleaseCopyEventEntry ( f_pApiInstance,
982 *f_pusCopyEntryIndex );
983 if ( ulTempVar != cOCT6100_ERR_OK )
984 return ulTempVar;
985 }
986 }
987
988 return cOCT6100_ERR_OK;
989 }
990 #endif
991
992
993 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
994
995 Function: Oct6100ApiWriteCopyEventCreateStructs
996
997 Description: Performs all the required structure writes to configure the
998 new copy event
999
1000 -------------------------------------------------------------------------------
1001 | Argument | Description
1002 -------------------------------------------------------------------------------
1003 f_pApiInstance Pointer to API instance. This memory is used to keep the
1004 present state of the chip and all its resources.
1005
1006 f_pCopyEventCreate Pointer to a create copy event structure.
1007 f_usMixerEventIndex Index of the copy event within the mixer memory.
1008 f_usSourceChanIndex Index of the source channel within the API's channel list.
1009 f_usDestinationChanIndex Index of the destination channel within the API's channel list.
1010
1011 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1012 #if !SKIP_Oct6100ApiWriteCopyEventCreateStructs
1013 UINT32 Oct6100ApiWriteCopyEventCreateStructs(
1014 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1015 IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate,
1016 IN UINT16 f_usMixerEventIndex,
1017 IN UINT16 f_usSourceChanIndex,
1018 IN UINT16 f_usDestinationChanIndex )
1019 {
1020 tPOCT6100_SHARED_INFO pSharedInfo;
1021 tPOCT6100_API_CHANNEL pSourceEntry;
1022 tPOCT6100_API_CHANNEL pDestinationEntry;
1023 tOCT6100_WRITE_PARAMS WriteParams;
1024 UINT32 ulResult;
1025
1026 /* Obtain local pointer to shared portion of instance. */
1027 pSharedInfo = f_pApiInstance->pSharedInfo;
1028
1029 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1030
1031 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1032
1033 /*==============================================================================*/
1034 /* Get a pointer to the two channel entry. */
1035
1036 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSourceEntry, f_usSourceChanIndex );
1037 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, f_usDestinationChanIndex );
1038
1039 /*==============================================================================*/
1040 /* Configure the TSST control memory and add the Sin copy event if necessary. */
1041
1042 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usMixerEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
1043
1044 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
1045
1046 if ( f_pCopyEventCreate->ulSourcePort == cOCT6100_CHANNEL_PORT_RIN )
1047 {
1048 WriteParams.usWriteData |= pSourceEntry->usRinRoutTsiMemIndex;
1049 WriteParams.usWriteData |= pSourceEntry->TdmConfig.byRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
1050 }
1051 else /* f_pCopyEventCreate->ulSourcePort == cOCT6100_CHANNEL_PORT_SIN */
1052 {
1053 if ( pSourceEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
1054 {
1055 WriteParams.usWriteData |= pSourceEntry->usExtraSinTsiMemIndex;
1056 }
1057 else
1058 {
1059 WriteParams.usWriteData |= pSourceEntry->usSinSoutTsiMemIndex;
1060 }
1061
1062 WriteParams.usWriteData |= pSourceEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
1063 }
1064
1065 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
1066 if ( ulResult != cOCT6100_ERR_OK )
1067 return ulResult;
1068
1069 WriteParams.ulWriteAddress += 2;
1070
1071 if ( f_pCopyEventCreate->ulDestinationPort == cOCT6100_CHANNEL_PORT_RIN )
1072 {
1073 WriteParams.usWriteData = (UINT16)( pDestinationEntry->usRinRoutTsiMemIndex );
1074 }
1075 else /* f_pCopyEventCreate->ulDestinationPort == cOCT6100_CHANNEL_PORT_SIN */
1076 {
1077 WriteParams.usWriteData = (UINT16)( pDestinationEntry->usSinSoutTsiMemIndex );
1078 }
1079
1080 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
1081 if ( ulResult != cOCT6100_ERR_OK )
1082 return ulResult;
1083
1084 /*=======================================================================*/
1085
1086 /* Now insert the event into the event list. */
1087 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
1088 f_usMixerEventIndex,
1089 cOCT6100_EVENT_TYPE_SIN_COPY,
1090 f_usDestinationChanIndex );
1091 if ( ulResult != cOCT6100_ERR_OK )
1092 return ulResult;
1093
1094 /* Increment the copy event count on this channel. */
1095 pDestinationEntry->usCopyEventCnt++;
1096
1097 /*==============================================================================*/
1098
1099 return cOCT6100_ERR_OK;
1100 }
1101 #endif
1102
1103
1104 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1105
1106 Function: Oct6100ApiUpdateCopyEventCreateEntry
1107
1108 -------------------------------------------------------------------------------
1109 | Argument | Description
1110 -------------------------------------------------------------------------------
1111 f_pApiInstance Pointer to API instance. This memory is used to keep
1112 the present state of the chip and all its resources.
1113 f_pCopyEventCreate Pointer to a create copy event structure.
1114 f_usCopyEventIndex Index of the copy event within the API's event list.
1115 f_usMixerEventIndex Index of the copy event within the mixer memory.
1116 f_usSourceChanIndex Index of the source channel within the API's channel list.
1117 f_usDestinationChanIndex Index of the destination channel within the API's channel list.
1118
1119 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1120 #if !SKIP_Oct6100ApiUpdateCopyEventCreateEntry
1121 UINT32 Oct6100ApiUpdateCopyEventCreateEntry(
1122 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1123 IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate,
1124 IN UINT16 f_usCopyEventIndex,
1125 IN UINT16 f_usMixerEventIndex,
1126 IN UINT16 f_usSourceChanIndex,
1127 IN UINT16 f_usDestinationChanIndex )
1128 {
1129 tPOCT6100_SHARED_INFO pSharedInfo;
1130 tPOCT6100_API_COPY_EVENT pCopyEventEntry;
1131
1132 /* Obtain local pointer to shared portion of instance. */
1133 pSharedInfo = f_pApiInstance->pSharedInfo;
1134
1135 /* Obtain a pointer to the new buffer's list entry. */
1136 mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, f_usCopyEventIndex );
1137
1138 /*=======================================================================*/
1139 /* Copy the channel's configuration and allocated resources. */
1140
1141 /* Save the channel info in the copy event. */
1142 pCopyEventEntry->usSourceChanIndex = f_usSourceChanIndex;
1143 pCopyEventEntry->bySourcePort = (UINT8)( f_pCopyEventCreate->ulSourcePort & 0xFF );
1144
1145 pCopyEventEntry->usDestinationChanIndex = f_usDestinationChanIndex;
1146 pCopyEventEntry->byDestinationPort = (UINT8)( f_pCopyEventCreate->ulDestinationPort & 0xFF );
1147
1148 pCopyEventEntry->usMixerEventIndex = f_usMixerEventIndex;
1149
1150 /*=======================================================================*/
1151
1152 /* Form handle returned to user. */
1153 *f_pCopyEventCreate->pulCopyEventHndl = cOCT6100_HNDL_TAG_COPY_EVENT | (pCopyEventEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usCopyEventIndex;
1154
1155 /* Finally, mark the event as used. */
1156 pCopyEventEntry->fReserved = TRUE;
1157
1158 return cOCT6100_ERR_OK;
1159 }
1160 #endif
1161
1162
1163 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1164
1165 Function: Oct6100MixerCopyEventDestroySer
1166
1167 -------------------------------------------------------------------------------
1168 | Argument | Description
1169 -------------------------------------------------------------------------------
1170 f_pApiInstance Pointer to API instance. This memory is used to keep the
1171 present state of the chip and all its resources.
1172
1173 f_pCopyEventDestroy Pointer to a destroy copy event structure.
1174
1175 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1176 #if !SKIP_Oct6100MixerCopyEventDestroySer
1177 UINT32 Oct6100MixerCopyEventDestroySer(
1178 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1179 IN tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy )
1180 {
1181 UINT16 usCopyEventIndex;
1182 UINT16 usMixerEventIndex;
1183 UINT32 ulResult;
1184
1185 /* Verify that all the parameters given match the state of the API. */
1186 ulResult = Oct6100ApiAssertCopyEventDestroyParams( f_pApiInstance,
1187 f_pCopyEventDestroy,
1188 &usCopyEventIndex,
1189 &usMixerEventIndex );
1190 if ( ulResult != cOCT6100_ERR_OK )
1191 return ulResult;
1192
1193 /* Release all resources associated to the echo cancellation channel. */
1194 ulResult = Oct6100ApiInvalidateCopyEventStructs( f_pApiInstance,
1195 usCopyEventIndex,
1196 usMixerEventIndex );
1197 if ( ulResult != cOCT6100_ERR_OK )
1198 return ulResult;
1199
1200 /* Release all resources associated to the echo cancellation channel. */
1201 ulResult = Oct6100ApiReleaseCopyEventResources( f_pApiInstance,
1202 usCopyEventIndex,
1203 usMixerEventIndex );
1204 if ( ulResult != cOCT6100_ERR_OK )
1205 return ulResult;
1206
1207 /* Invalidate the handle. */
1208 f_pCopyEventDestroy->ulCopyEventHndl = cOCT6100_INVALID_HANDLE;
1209
1210 return cOCT6100_ERR_OK;
1211 }
1212 #endif
1213
1214
1215 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1216
1217 Function: Oct6100ApiAssertCopyEventDestroyParams
1218
1219 Description:
1220
1221 -------------------------------------------------------------------------------
1222 | Argument | Description
1223 -------------------------------------------------------------------------------
1224 f_pApiInstance Pointer to API instance. This memory is used to keep the
1225 present state of the chip and all its resources.
1226
1227 f_pCopyEventDestroy Pointer to a destroy copy event structure.
1228 f_pusCopyEventIndex Pointer to the index of the copy event in the API.
1229 f_pusMixerEventIndex Pointer to the index of the copy event in the mixer memory.
1230
1231 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1232 #if !SKIP_Oct6100ApiAssertCopyEventDestroyParams
1233 UINT32 Oct6100ApiAssertCopyEventDestroyParams(
1234 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1235 IN tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy,
1236 IN OUT PUINT16 f_pusCopyEventIndex,
1237 IN OUT PUINT16 f_pusMixerEventIndex )
1238 {
1239 tPOCT6100_SHARED_INFO pSharedInfo;
1240 tPOCT6100_API_COPY_EVENT pCopyEventEntry;
1241 UINT32 ulEntryOpenCnt;
1242
1243 /* Get local pointer(s). */
1244 pSharedInfo = f_pApiInstance->pSharedInfo;
1245
1246 /* Check the provided handle. */
1247 if ( (f_pCopyEventDestroy->ulCopyEventHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_COPY_EVENT )
1248 return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
1249
1250 *f_pusCopyEventIndex = (UINT16)( f_pCopyEventDestroy->ulCopyEventHndl & cOCT6100_HNDL_INDEX_MASK );
1251 if ( *f_pusCopyEventIndex >= cOCT6100_MAX_MIXER_EVENTS )
1252 return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
1253
1254 /*=======================================================================*/
1255
1256 mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, *f_pusCopyEventIndex )
1257
1258 /* Extract the entry open count from the provided handle. */
1259 ulEntryOpenCnt = ( f_pCopyEventDestroy->ulCopyEventHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
1260
1261 /* Check for errors. */
1262 if ( pCopyEventEntry->fReserved != TRUE )
1263 return cOCT6100_ERR_MIXER_EVENT_NOT_OPEN;
1264 if ( ulEntryOpenCnt != pCopyEventEntry->byEntryOpenCnt )
1265 return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
1266
1267 /*=======================================================================*/
1268
1269 /* Return the index of the associated event. */
1270 *f_pusMixerEventIndex = pCopyEventEntry->usMixerEventIndex;
1271
1272 return cOCT6100_ERR_OK;
1273 }
1274 #endif
1275
1276
1277 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1278
1279 Function: Oct6100ApiInvalidateCopyEventStructs
1280
1281 Description: Destroy the link between the two channels.
1282
1283 -------------------------------------------------------------------------------
1284 | Argument | Description
1285 -------------------------------------------------------------------------------
1286 f_pApiInstance Pointer to API instance. This memory is used to keep the
1287 present state of the chip and all its resources.
1288
1289 f_usCopyEventIndex Index of the copy event in the API.
1290 f_usMixerEventIndex Index of the copy event in the mixer memory.
1291
1292 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1293 #if !SKIP_Oct6100ApiInvalidateCopyEventStructs
1294 UINT32 Oct6100ApiInvalidateCopyEventStructs(
1295 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1296 IN UINT16 f_usCopyEventIndex,
1297 IN UINT16 f_usMixerEventIndex )
1298 {
1299 tPOCT6100_SHARED_INFO pSharedInfo;
1300 tOCT6100_WRITE_PARAMS WriteParams;
1301 UINT32 ulResult;
1302
1303 /* Obtain local pointer to shared portion of instance. */
1304 pSharedInfo = f_pApiInstance->pSharedInfo;
1305
1306 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1307
1308 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1309
1310 /*=======================================================================*/
1311 /* Clear the Copy event. */
1312 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usMixerEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
1313 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
1314
1315 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
1316 if ( ulResult != cOCT6100_ERR_OK )
1317 return ulResult;
1318
1319 /*=======================================================================*/
1320
1321 /* Remove the event from the list. */
1322 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
1323 f_usMixerEventIndex,
1324 cOCT6100_EVENT_TYPE_SIN_COPY );
1325 if ( ulResult != cOCT6100_ERR_OK )
1326 return ulResult;
1327
1328 return cOCT6100_ERR_OK;
1329 }
1330 #endif
1331
1332
1333 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1334
1335 Function: Oct6100ApiReleaseCopyEventResources
1336
1337 -------------------------------------------------------------------------------
1338 | Argument | Description
1339 -------------------------------------------------------------------------------
1340 f_pApiInstance Pointer to API instance. This memory is used to keep the
1341 present state of the chip and all its resources.
1342
1343 f_usCopyEventIndex Index of the copy event in the API.
1344 f_usMixerEventIndex Index of the copy event in the mixer memory.
1345
1346 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1347 #if !SKIP_Oct6100ApiReleaseCopyEventResources
1348 UINT32 Oct6100ApiReleaseCopyEventResources(
1349 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1350 IN UINT16 f_usCopyEventIndex,
1351 IN UINT16 f_usMixerEventIndex )
1352 {
1353 tPOCT6100_SHARED_INFO pSharedInfo;
1354 tPOCT6100_API_CHANNEL pDestinationEntry;
1355 tPOCT6100_API_COPY_EVENT pCopyEventEntry;
1356 tPOCT6100_API_MIXER_EVENT pTempEventEntry;
1357 UINT32 ulResult;
1358
1359 /* Obtain local pointer to shared portion of instance. */
1360 pSharedInfo = f_pApiInstance->pSharedInfo;
1361
1362 mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, f_usCopyEventIndex );
1363
1364 ulResult = Oct6100ApiReleaseCopyEventEntry( f_pApiInstance, f_usCopyEventIndex );
1365 if ( ulResult != cOCT6100_ERR_OK )
1366 return cOCT6100_ERR_FATAL_AC;
1367
1368 /* Relese the SIN copy event. */
1369 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usMixerEventIndex );
1370 if ( ulResult != cOCT6100_ERR_OK )
1371 return cOCT6100_ERR_FATAL_B3;
1372
1373 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, f_usMixerEventIndex );
1374
1375 /* Invalidate the entry. */
1376 pTempEventEntry->fReserved = FALSE;
1377 pTempEventEntry->usEventType = cOCT6100_INVALID_INDEX;
1378 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
1379
1380 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, pCopyEventEntry->usDestinationChanIndex );
1381
1382 /* Decrement the copy event count on this channel. */
1383 pDestinationEntry->usCopyEventCnt--;
1384
1385 /*=======================================================================*/
1386
1387 /* Mark the event entry as unused. */
1388 pCopyEventEntry->fReserved = FALSE;
1389 pCopyEventEntry->byEntryOpenCnt++;
1390
1391 /*=======================================================================*/
1392
1393 return cOCT6100_ERR_OK;
1394 }
1395 #endif
1396
1397
1398 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1399
1400 Function: Oct6100ApiReserveMixerEventEntry
1401
1402 Description: Reserves a free entry in the mixer event list.
1403
1404 -------------------------------------------------------------------------------
1405 | Argument | Description
1406 -------------------------------------------------------------------------------
1407 f_pApiInstance Pointer to API instance. This memory is used to keep the
1408 present state of the chip and all its resources.
1409
1410 f_pusEventIndex List entry reserved.
1411
1412 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1413 #if !SKIP_Oct6100ApiReserveMixerEventEntry
1414 UINT32 Oct6100ApiReserveMixerEventEntry(
1415 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1416 OUT PUINT16 f_pusEventIndex )
1417 {
1418 PVOID pMixerEventAlloc;
1419 UINT32 ulResult;
1420 UINT32 ulEventIndex;
1421
1422 mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
1423
1424 ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulEventIndex );
1425 if ( ulResult != cOCT6100_ERR_OK )
1426 {
1427 if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
1428 return cOCT6100_ERR_MIXER_ALL_MIXER_EVENT_ENTRY_OPENED;
1429 else
1430 return cOCT6100_ERR_FATAL_2B;
1431 }
1432
1433 *f_pusEventIndex = (UINT16)( ulEventIndex & 0xFFFF );
1434
1435 return cOCT6100_ERR_OK;
1436 }
1437 #endif
1438
1439
1440 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1441
1442 Function: Oct6100ApiReleaseMixerEventEntry
1443
1444 Description: Release an entry from the mixer event list.
1445
1446 -------------------------------------------------------------------------------
1447 | Argument | Description
1448 -------------------------------------------------------------------------------
1449 f_pApiInstance Pointer to API instance. This memory is used to keep the
1450 present state of the chip and all its resources.
1451
1452 f_usEventIndex List entry reserved.
1453
1454 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1455 #if !SKIP_Oct6100ApiReleaseMixerEventEntry
1456 UINT32 Oct6100ApiReleaseMixerEventEntry(
1457 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1458 IN UINT16 f_usEventIndex )
1459 {
1460 PVOID pMixerEventAlloc;
1461 UINT32 ulResult;
1462
1463 mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
1464
1465 ulResult = OctapiLlmAllocDealloc( pMixerEventAlloc, f_usEventIndex );
1466 if ( ulResult != cOCT6100_ERR_OK )
1467 return cOCT6100_ERR_FATAL_2C;
1468
1469 return cOCT6100_ERR_OK;
1470 }
1471 #endif
1472
1473
1474 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1475
1476 Function: Oct6100ApiGetFreeMixerEventCnt
1477
1478 Description: Retrieve the number of events left in the list.
1479
1480 -------------------------------------------------------------------------------
1481 | Argument | Description
1482 -------------------------------------------------------------------------------
1483 f_pApiInstance Pointer to API instance. This memory is used to keep the
1484 present state of the chip and all its resources.
1485
1486 f_pulFreeEventCnt How many events left.
1487
1488 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1489 #if !SKIP_Oct6100ApiGetFreeMixerEventCnt
1490 UINT32 Oct6100ApiGetFreeMixerEventCnt(
1491 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1492 OUT PUINT32 f_pulFreeEventCnt )
1493 {
1494 PVOID pMixerEventAlloc;
1495 UINT32 ulResult;
1496 UINT32 ulAllocatedEvents;
1497 UINT32 ulAvailableEvents;
1498
1499 mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
1500
1501 ulResult = OctapiLlmAllocInfo( pMixerEventAlloc, &ulAllocatedEvents, &ulAvailableEvents );
1502 if ( ulResult != cOCT6100_ERR_OK )
1503 return cOCT6100_ERR_FATAL_E8;
1504
1505 /* Return number of free events. */
1506 *f_pulFreeEventCnt = ulAvailableEvents;
1507
1508 return cOCT6100_ERR_OK;
1509 }
1510 #endif
1511
1512
1513 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1514
1515 Function: Oct6100ApiReserveCopyEventEntry
1516
1517 Description: Reserves a free entry in the copy event list.
1518
1519 -------------------------------------------------------------------------------
1520 | Argument | Description
1521 -------------------------------------------------------------------------------
1522 f_pApiInstance Pointer to API instance. This memory is used to keep the
1523 present state of the chip and all its resources.
1524
1525 f_pusEventIndex List entry reserved.
1526
1527 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1528 #if !SKIP_Oct6100ApiReserveCopyEventEntry
1529 UINT32 Oct6100ApiReserveCopyEventEntry(
1530 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1531 OUT PUINT16 f_pusEventIndex )
1532 {
1533 PVOID pCopyEventAlloc;
1534 UINT32 ulResult;
1535 UINT32 ulEventIndex;
1536
1537 mOCT6100_GET_COPY_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pCopyEventAlloc )
1538
1539 ulResult = OctapiLlmAllocAlloc( pCopyEventAlloc, &ulEventIndex );
1540 if ( ulResult != cOCT6100_ERR_OK )
1541 {
1542 if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
1543 return cOCT6100_ERR_MIXER_ALL_COPY_EVENT_ENTRY_OPENED;
1544 else
1545 return cOCT6100_ERR_FATAL_AD;
1546 }
1547
1548 *f_pusEventIndex = (UINT16)( ulEventIndex & 0xFFFF );
1549
1550 return cOCT6100_ERR_OK;
1551 }
1552 #endif
1553
1554
1555 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1556
1557 Function: Oct6100ApiReleaseCopyEventEntry
1558
1559 Description: Release an entry from the copy event list.
1560
1561 -------------------------------------------------------------------------------
1562 | Argument | Description
1563 -------------------------------------------------------------------------------
1564 f_pApiInstance Pointer to API instance. This memory is used to keep the
1565 present state of the chip and all its resources.
1566
1567 f_usEventIndex List entry reserved.
1568
1569 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1570 #if !SKIP_Oct6100ApiReleaseCopyEventEntry
1571 UINT32 Oct6100ApiReleaseCopyEventEntry(
1572 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1573 IN UINT16 f_usEventIndex )
1574 {
1575 PVOID pCopyEventAlloc;
1576 UINT32 ulResult;
1577
1578 mOCT6100_GET_COPY_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pCopyEventAlloc )
1579
1580 ulResult = OctapiLlmAllocDealloc( pCopyEventAlloc, f_usEventIndex );
1581 if ( ulResult != cOCT6100_ERR_OK )
1582 return cOCT6100_ERR_FATAL_AE;
1583
1584 return cOCT6100_ERR_OK;
1585 }
1586 #endif