1
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3
File: oct6100_playout_buf.c
5
Copyright (c) 2001-2007 Octasic Inc.
9
This file contains functions used to manage buffer playout.
11
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is
12
free software; you can redistribute it and/or modify it under the terms of
13
the GNU General Public License as published by the Free Software Foundation;
14
either version 2 of the License, or (at your option) any later version.
16
The OCT6100 GPL API is distributed in the hope that it will be useful, but
17
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
You should have received a copy of the GNU General Public License
22
along with the OCT6100 GPL API; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
$Octasic_Release: OCT612xAPI-01.00-PR49 $
27
$Octasic_Revision: 109 $
29
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
32
/***************************** INCLUDE FILES *******************************/
36
#include "oct6100api/oct6100_defines.h"
37
#include "oct6100api/oct6100_errors.h"
38
#include "oct6100api/oct6100_apiud.h"
40
#include "apilib/octapi_llman.h"
42
#include "oct6100api/oct6100_tlv_inst.h"
43
#include "oct6100api/oct6100_chip_open_inst.h"
44
#include "oct6100api/oct6100_chip_stats_inst.h"
45
#include "oct6100api/oct6100_interrupts_inst.h"
46
#include "oct6100api/oct6100_remote_debug_inst.h"
47
#include "oct6100api/oct6100_debug_inst.h"
48
#include "oct6100api/oct6100_api_inst.h"
49
#include "oct6100api/oct6100_channel_inst.h"
50
#include "oct6100api/oct6100_playout_buf_inst.h"
52
#include "oct6100api/oct6100_interrupts_pub.h"
53
#include "oct6100api/oct6100_chip_open_pub.h"
54
#include "oct6100api/oct6100_channel_pub.h"
55
#include "oct6100api/oct6100_events_pub.h"
56
#include "oct6100api/oct6100_playout_buf_pub.h"
58
#include "oct6100_chip_open_priv.h"
59
#include "oct6100_miscellaneous_priv.h"
60
#include "oct6100_memory_priv.h"
61
#include "oct6100_channel_priv.h"
62
#include "oct6100_events_priv.h"
63
#include "oct6100_playout_buf_priv.h"
65
/**************************** PUBLIC FUNCTIONS *****************************/
67
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
69
Function: Oct6100BufferPlayoutLoad
71
Description: This function loads a playout buffer into external memory.
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.
79
f_pBufferLoad Pointer to buffer playout load structure.
81
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
82
#if !SKIP_Oct6100BufferPlayoutLoadDef
83
UINT32 Oct6100BufferPlayoutLoadDef(
84
tPOCT6100_BUFFER_LOAD f_pBufferLoad )
86
f_pBufferLoad->pbyBufferPattern = NULL;
87
f_pBufferLoad->ulBufferSize = 128;
88
f_pBufferLoad->ulBufferPcmLaw = cOCT6100_PCM_U_LAW;
90
f_pBufferLoad->pulBufferIndex = NULL;
91
f_pBufferLoad->pulPlayoutFreeMemSize = NULL;
93
return cOCT6100_ERR_OK;
97
#if !SKIP_Oct6100BufferPlayoutLoad
98
UINT32 Oct6100BufferPlayoutLoad(
99
tPOCT6100_INSTANCE_API f_pApiInstance,
100
tPOCT6100_BUFFER_LOAD f_pBufferLoad )
102
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
103
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
104
UINT32 ulSerRes = cOCT6100_ERR_OK;
105
UINT32 ulFncRes = cOCT6100_ERR_OK;
107
/* Set the process context of the serialize structure. */
108
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
109
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
111
/* Seize all list semaphores needed by this function. */
112
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
113
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
114
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
115
if ( ulSerRes == cOCT6100_ERR_OK )
117
/* Call the serialized function. */
118
ulFncRes = Oct6100BufferLoadSer( f_pApiInstance, f_pBufferLoad, TRUE, cOCT6100_INVALID_INDEX );
125
/* Release the seized semaphores. */
126
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
127
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
129
/* If an error occured then return the error code. */
130
if ( ulSerRes != cOCT6100_ERR_OK )
132
if ( ulFncRes != cOCT6100_ERR_OK )
135
return cOCT6100_ERR_OK;
139
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
141
Function: Oct6100BufferPlayoutLoadBlockInit
143
Description: This function allows the user to initialize loading a buffer
144
into external memory using blocks.
146
-------------------------------------------------------------------------------
147
| Argument | Description
148
-------------------------------------------------------------------------------
149
f_pApiInstance Pointer to API instance. This memory is used to keep
150
the present state of the chip and all its resources.
152
f_pBufferLoadBlockInit Pointer to buffer playout load block init structure.
154
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
155
#if !SKIP_Oct6100BufferPlayoutLoadBlockInitDef
156
UINT32 Oct6100BufferPlayoutLoadBlockInitDef(
157
tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit )
159
f_pBufferLoadBlockInit->ulBufferSize = 128;
160
f_pBufferLoadBlockInit->ulBufferPcmLaw = cOCT6100_PCM_U_LAW;
162
f_pBufferLoadBlockInit->pulBufferIndex = NULL;
163
f_pBufferLoadBlockInit->pulPlayoutFreeMemSize = NULL;
165
return cOCT6100_ERR_OK;
169
#if !SKIP_Oct6100BufferPlayoutLoadBlockInit
170
UINT32 Oct6100BufferPlayoutLoadBlockInit(
171
tPOCT6100_INSTANCE_API f_pApiInstance,
172
tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit )
174
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
175
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
176
UINT32 ulSerRes = cOCT6100_ERR_OK;
177
UINT32 ulFncRes = cOCT6100_ERR_OK;
179
/* Set the process context of the serialize structure.*/
180
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
181
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
189
/* Call the serialized function. */
190
ulFncRes = Oct6100BufferLoadBlockInitSer( f_pApiInstance, f_pBufferLoadBlockInit );
197
/* Release the seized semaphores. */
198
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
199
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
201
/* If an error occured then return the error code. */
202
if ( ulSerRes != cOCT6100_ERR_OK )
204
if ( ulFncRes != cOCT6100_ERR_OK )
207
return cOCT6100_ERR_OK;
212
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
214
Function: Oct6100BufferPlayoutLoadBlock
216
Description: This function allows the user to load a buffer block into
219
-------------------------------------------------------------------------------
220
| Argument | Description
221
-------------------------------------------------------------------------------
222
f_pApiInstance Pointer to API instance. This memory is used to keep
223
the present state of the chip and all its resources.
225
f_pBufferLoadBlock Pointer to buffer playout load block structure.
227
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
228
#if !SKIP_Oct6100BufferPlayoutLoadBlockDef
229
UINT32 Oct6100BufferPlayoutLoadBlockDef(
230
tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock )
232
f_pBufferLoadBlock->ulBufferIndex = cOCT6100_INVALID_VALUE;
233
f_pBufferLoadBlock->ulBlockLength = cOCT6100_INVALID_VALUE;
234
f_pBufferLoadBlock->ulBlockOffset = cOCT6100_INVALID_VALUE;
236
f_pBufferLoadBlock->pbyBufferPattern = NULL;
238
return cOCT6100_ERR_OK;
242
#if !SKIP_Oct6100BufferPlayoutLoadBlock
243
UINT32 Oct6100BufferPlayoutLoadBlock(
244
tPOCT6100_INSTANCE_API f_pApiInstance,
245
tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock )
247
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
248
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
249
UINT32 ulSerRes = cOCT6100_ERR_OK;
250
UINT32 ulFncRes = cOCT6100_ERR_OK;
252
/* Set the process context of the serialize structure. */
253
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
254
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
256
/* Seize all list semaphores needed by this function. */
257
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
258
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
259
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
260
if ( ulSerRes == cOCT6100_ERR_OK )
262
/* Call the serialized function. */
263
ulFncRes = Oct6100BufferLoadBlockSer( f_pApiInstance, f_pBufferLoadBlock );
270
/* Release the seized semaphores. */
271
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
272
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
274
/* If an error occured then return the error code. */
275
if ( ulSerRes != cOCT6100_ERR_OK )
277
if ( ulFncRes != cOCT6100_ERR_OK )
280
return cOCT6100_ERR_OK;
285
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
287
Function: Oct6100BufferPlayoutUnload
289
Description: This function unloads a playout buffer from external memory.
291
-------------------------------------------------------------------------------
292
| Argument | Description
293
-------------------------------------------------------------------------------
294
f_pApiInstance Pointer to API instance. This memory is used to keep the
295
present state of the chip and all its resources.
297
f_pBufferUnload Pointer to buffer playout unload structure.
299
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
300
#if !SKIP_Oct6100BufferPlayoutUnloadDef
301
UINT32 Oct6100BufferPlayoutUnloadDef(
302
tPOCT6100_BUFFER_UNLOAD f_pBufferUnload )
304
f_pBufferUnload->ulBufferIndex = cOCT6100_INVALID_VALUE;
306
return cOCT6100_ERR_OK;
310
#if !SKIP_Oct6100BufferPlayoutUnload
311
UINT32 Oct6100BufferPlayoutUnload(
312
tPOCT6100_INSTANCE_API f_pApiInstance,
313
tPOCT6100_BUFFER_UNLOAD f_pBufferUnload )
315
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
316
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
317
UINT32 ulSerRes = cOCT6100_ERR_OK;
318
UINT32 ulFncRes = cOCT6100_ERR_OK;
320
/* Set the process context of the serialize structure. */
321
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
322
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
324
/* Seize all list semaphores needed by this function. */
325
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
326
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
327
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
328
if ( ulSerRes == cOCT6100_ERR_OK )
330
/* Call the serialized function. */
331
ulFncRes = Oct6100BufferUnloadSer( f_pApiInstance, f_pBufferUnload, TRUE );
338
/* Release the seized semaphores. */
339
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
340
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
342
/* If an error occured then return the error code. */
343
if ( ulSerRes != cOCT6100_ERR_OK )
345
if ( ulFncRes != cOCT6100_ERR_OK )
348
return cOCT6100_ERR_OK;
353
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
355
Function: Oct6100BufferPlayoutAdd
357
Description: This function adds a buffer to a port's playout list on the
360
-------------------------------------------------------------------------------
361
| Argument | Description
362
-------------------------------------------------------------------------------
363
f_pApiInstance Pointer to API instance. This memory is used to keep the
364
present state of the chip and all its resources.
366
f_pBufferPlayoutAdd Pointer to buffer playout add structure.
368
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
369
#if !SKIP_Oct6100BufferPlayoutAddDef
370
UINT32 Oct6100BufferPlayoutAddDef(
371
tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd )
373
f_pBufferPlayoutAdd->ulChannelHndl = cOCT6100_INVALID_HANDLE;
374
f_pBufferPlayoutAdd->ulBufferIndex = cOCT6100_INVALID_VALUE;
376
f_pBufferPlayoutAdd->ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
377
f_pBufferPlayoutAdd->ulMixingMode = cOCT6100_MIXING_MINUS_6_DB;
378
f_pBufferPlayoutAdd->lGainDb = 0;
380
f_pBufferPlayoutAdd->fRepeat = FALSE;
381
f_pBufferPlayoutAdd->ulRepeatCount = cOCT6100_REPEAT_INFINITELY;
383
f_pBufferPlayoutAdd->ulDuration = cOCT6100_INVALID_VALUE;
385
f_pBufferPlayoutAdd->ulBufferLength = cOCT6100_AUTO_SELECT;
387
return cOCT6100_ERR_OK;
391
#if !SKIP_Oct6100BufferPlayoutAdd
392
UINT32 Oct6100BufferPlayoutAdd(
393
tPOCT6100_INSTANCE_API f_pApiInstance,
394
tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd )
396
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
397
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
398
UINT32 ulSerRes = cOCT6100_ERR_OK;
399
UINT32 ulFncRes = cOCT6100_ERR_OK;
401
/* Set the process context of the serialize structure. */
402
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
403
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
405
/* Seize all list semaphores needed by this function. */
406
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
407
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
408
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
409
if ( ulSerRes == cOCT6100_ERR_OK )
411
/* Call the serialized function. */
412
ulFncRes = Oct6100BufferPlayoutAddSer( f_pApiInstance, f_pBufferPlayoutAdd );
419
/* Release the seized semaphores. */
420
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
421
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
423
/* If an error occured then return the error code. */
424
if ( ulSerRes != cOCT6100_ERR_OK )
426
if ( ulFncRes != cOCT6100_ERR_OK )
429
return cOCT6100_ERR_OK;
434
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
436
Function: Oct6100BufferPlayoutStart
438
Description: This function enables playout of the specified buffer on the
441
-------------------------------------------------------------------------------
442
| Argument | Description
443
-------------------------------------------------------------------------------
444
f_pApiInstance Pointer to API instance. This memory is used to keep the
445
present state of the chip and all its resources.
447
f_pBufferPlayoutStart Pointer to buffer playout start structure.
449
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
450
#if !SKIP_Oct6100BufferPlayoutStartDef
451
UINT32 Oct6100BufferPlayoutStartDef(
452
tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart )
454
f_pBufferPlayoutStart->ulChannelHndl = cOCT6100_INVALID_HANDLE;
455
f_pBufferPlayoutStart->ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
456
f_pBufferPlayoutStart->fNotifyOnPlayoutStop = FALSE;
457
f_pBufferPlayoutStart->ulUserEventId = cOCT6100_INVALID_VALUE;
458
f_pBufferPlayoutStart->fAllowStartWhileActive = FALSE;
460
return cOCT6100_ERR_OK;
464
#if !SKIP_Oct6100BufferPlayoutStart
465
UINT32 Oct6100BufferPlayoutStart(
466
tPOCT6100_INSTANCE_API f_pApiInstance,
467
tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart )
469
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
470
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
471
UINT32 ulSerRes = cOCT6100_ERR_OK;
472
UINT32 ulFncRes = cOCT6100_ERR_OK;
474
/* Set the process context of the serialize structure. */
475
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
476
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
478
/* Seize all list semaphores needed by this function. */
479
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
480
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
481
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
482
if ( ulSerRes == cOCT6100_ERR_OK )
484
/* Call the serialized function. */
485
ulFncRes = Oct6100BufferPlayoutStartSer( f_pApiInstance, f_pBufferPlayoutStart, cOCT6100_BUFFER_PLAYOUT_EVENT_STOP );
492
/* Release the seized semaphores. */
493
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
494
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
496
/* If an error occured then return the error code. */
497
if ( ulSerRes != cOCT6100_ERR_OK )
499
if ( ulFncRes != cOCT6100_ERR_OK )
502
return cOCT6100_ERR_OK;
507
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
509
Function: Oct6100BufferPlayoutStop
511
Description: This function disables playout of a buffer on the specified
514
-------------------------------------------------------------------------------
515
| Argument | Description
516
-------------------------------------------------------------------------------
517
f_pApiInstance Pointer to API instance. This memory is used to keep the
518
present state of the chip and all its resources.
520
f_pBufferPlayoutStop Pointer to buffer playout stop structure.
522
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
523
#if !SKIP_Oct6100BufferPlayoutStopDef
524
UINT32 Oct6100BufferPlayoutStopDef(
525
tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop )
527
f_pBufferPlayoutStop->ulChannelHndl = cOCT6100_INVALID_HANDLE;
528
f_pBufferPlayoutStop->ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
529
f_pBufferPlayoutStop->fStopCleanly = TRUE;
530
f_pBufferPlayoutStop->pfAlreadyStopped = NULL;
531
f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = NULL;
533
return cOCT6100_ERR_OK;
537
#if !SKIP_Oct6100BufferPlayoutStop
538
UINT32 Oct6100BufferPlayoutStop(
539
tPOCT6100_INSTANCE_API f_pApiInstance,
540
tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop )
542
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
543
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
544
UINT32 ulSerRes = cOCT6100_ERR_OK;
545
UINT32 ulFncRes = cOCT6100_ERR_OK;
547
/* Set the process context of the serialize structure. */
548
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
549
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
551
/* Seize all list semaphores needed by this function. */
552
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
553
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
554
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
555
if ( ulSerRes == cOCT6100_ERR_OK )
557
/* Call the serialized function. */
558
ulFncRes = Oct6100BufferPlayoutStopSer( f_pApiInstance, f_pBufferPlayoutStop );
565
/* Release the seized semaphores. */
566
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
567
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
569
/* If an error occured then return the error code. */
570
if ( ulSerRes != cOCT6100_ERR_OK )
572
if ( ulFncRes != cOCT6100_ERR_OK )
575
return cOCT6100_ERR_OK;
580
/**************************** PRIVATE FUNCTIONS ****************************/
582
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
584
Function: Oct6100ApiGetPlayoutBufferSwSizes
586
Description: Gets the sizes of all portions of the API instance pertinent
587
to the management of playout buffers.
589
-------------------------------------------------------------------------------
590
| Argument | Description
591
-------------------------------------------------------------------------------
592
f_pOpenChip Pointer to chip configuration struct.
593
f_pInstSizes Pointer to struct containing instance sizes.
595
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
596
#if !SKIP_Oct6100ApiGetPlayoutBufferSwSizes
597
UINT32 Oct6100ApiGetPlayoutBufferSwSizes(
598
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
599
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
604
/* Calculate memory needed for playout buffer list. */
605
f_pInstSizes->ulPlayoutBufList = f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER );
607
f_pInstSizes->ulPlayoutBufMemoryNodeList = 0;
609
/* Calculate memory needed for playout buffer allocation software. */
610
if ( f_pOpenChip->ulMaxPlayoutBuffers > 0 )
612
ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxPlayoutBuffers, &f_pInstSizes->ulPlayoutBufAlloc );
613
if ( ulResult != cOCT6100_ERR_OK )
614
return cOCT6100_ERR_FATAL_3C;
616
f_pInstSizes->ulPlayoutBufMemoryNodeList = 2 * f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE );
620
f_pInstSizes->ulPlayoutBufAlloc = 0;
623
/* Calculate memory needed for list and allocation software serialization. */
624
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufList, ulTempVar )
625
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufAlloc, ulTempVar )
626
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufMemoryNodeList, ulTempVar )
628
return cOCT6100_ERR_OK;
633
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
635
Function: Oct6100ApiPlayoutBufferSwInit
637
Description: Initializes all elements of the instance structure associated
640
-------------------------------------------------------------------------------
641
| Argument | Description
642
-------------------------------------------------------------------------------
643
f_pApiInstance Pointer to API instance. This memory is used to keep
644
the present state of the chip and all its resources.
646
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
647
#if !SKIP_Oct6100ApiPlayoutBufferSwInit
648
UINT32 Oct6100ApiPlayoutBufferSwInit(
649
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
651
tPOCT6100_SHARED_INFO pSharedInfo;
652
tPOCT6100_API_BUFFER pBufferList;
653
PVOID pBufferPlayoutAlloc;
654
UINT32 ulMaxBufferPlayout;
657
/* Get local pointer to shared portion of instance. */
658
pSharedInfo = f_pApiInstance->pSharedInfo;
660
/* Get the maximum number of buffer playout. */
661
ulMaxBufferPlayout = pSharedInfo->ChipConfig.usMaxPlayoutBuffers;
663
/* Set all entries in the buffer playout list to unused. */
664
mOCT6100_GET_BUFFER_LIST_PNT( pSharedInfo, pBufferList )
666
for ( i = 0; i < ulMaxBufferPlayout; i++ )
668
pBufferList[ i ].fReserved = FALSE;
669
pBufferList[ i ].ulBufferSize = 0;
670
pBufferList[ i ].ulBufferBase = cOCT6100_INVALID_VALUE;
671
pBufferList[ i ].usDependencyCnt = 0;
672
pBufferList[ i ].byBufferPcmLaw = cOCT6100_PCM_U_LAW;
676
/* Initialize the buffer playout allocation software to "all free". */
677
if ( ulMaxBufferPlayout > 0 )
679
mOCT6100_GET_BUFFER_ALLOC_PNT( pSharedInfo, pBufferPlayoutAlloc )
681
ulResult = OctapiLlmAllocInit( &pBufferPlayoutAlloc, ulMaxBufferPlayout );
682
if ( ulResult != cOCT6100_ERR_OK )
683
return cOCT6100_ERR_FATAL_3D;
686
/* Initialize the amount of free memory used by playout. */
687
f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed = 0;
689
return cOCT6100_ERR_OK;
694
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
696
Function: Oct6100BufferLoadSer
698
Description: Loads a buffer in external memory.
700
-------------------------------------------------------------------------------
701
| Argument | Description
702
-------------------------------------------------------------------------------
703
f_pApiInstance Pointer to API instance. This memory is used to keep the
704
present state of the chip and all its resources.
706
f_pBufferLoad Pointer to buffer configuration structure. The handle
707
identifying the buffer in all future function calls is
708
returned in this structure.
710
f_fReserveListStruct Flag indicating if a list structure should be reserved
711
or if the structure has been reserved before. If this
712
is set, the f_ulBufIndex variable must also be set.
714
f_ulBufIndex If the f_fReserveListStruct flag is set, this index
715
will identify the buffer playout list structure
716
that must be used to load the specified buffer.
718
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
719
#if !SKIP_Oct6100BufferLoadSer
720
UINT32 Oct6100BufferLoadSer(
721
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
722
IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad,
723
IN BOOL f_fReserveListStruct,
724
IN UINT32 f_ulBufIndex )
726
UINT32 ulBufferIndex;
730
/* Check the user's configuration of the buffer for errors. */
731
ulResult = Oct6100ApiCheckBufferParams( f_pApiInstance, f_pBufferLoad, TRUE );
732
if ( ulResult != cOCT6100_ERR_OK )
735
/* Reserve all resources needed by the buffer. */
736
ulResult = Oct6100ApiReserveBufferResources( f_pApiInstance, f_pBufferLoad, f_fReserveListStruct, f_ulBufIndex, &ulBufferIndex, &ulBufferBase );
737
if ( ulResult != cOCT6100_ERR_OK )
740
/* Write the buffer in external memory. */
741
ulResult = Oct6100ApiWriteBufferInMemory( f_pApiInstance, ulBufferBase, f_pBufferLoad->ulBufferSize, f_pBufferLoad->pbyBufferPattern );
742
if ( ulResult != cOCT6100_ERR_OK )
745
/* Update the new buffer's entry in the buffer list. */
746
ulResult = Oct6100ApiUpdateBufferEntry( f_pApiInstance, f_pBufferLoad, ulBufferIndex, ulBufferBase );
747
if ( ulResult != cOCT6100_ERR_OK )
750
return cOCT6100_ERR_OK;
755
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
757
Function: Oct6100BufferLoadBlockInitSer
759
Description: Reserve resources for loading a buffer into external memory.
761
-------------------------------------------------------------------------------
762
| Argument | Description
763
-------------------------------------------------------------------------------
764
f_pApiInstance Pointer to API instance. This memory is used to keep
765
the present state of the chip and all its resources.
767
f_pBufferLoadBlockInit Pointer to buffer configuration structure. The
768
handle identifying the buffer in all future
769
function calls is returned in this structure.
771
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
772
#if !SKIP_Oct6100BufferLoadBlockInitSer
773
UINT32 Oct6100BufferLoadBlockInitSer(
774
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
775
IN OUT tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit )
777
UINT32 ulBufferIndex;
780
tOCT6100_BUFFER_LOAD BufferLoad;
782
Oct6100BufferPlayoutLoadDef( &BufferLoad );
784
/* Not to replicate the code, we use the BufferLoad functions directly. */
785
BufferLoad.pulBufferIndex = f_pBufferLoadBlockInit->pulBufferIndex;
786
BufferLoad.pulPlayoutFreeMemSize = f_pBufferLoadBlockInit->pulPlayoutFreeMemSize;
787
BufferLoad.ulBufferPcmLaw = f_pBufferLoadBlockInit->ulBufferPcmLaw;
788
BufferLoad.ulBufferSize = f_pBufferLoadBlockInit->ulBufferSize;
789
BufferLoad.pbyBufferPattern = NULL; /* Must not check this for now */
791
/* Check the user's configuration of the buffer for errors, but do */
792
/* not check if the buffer pointer is NULL. It is NULL for sure! */
793
ulResult = Oct6100ApiCheckBufferParams( f_pApiInstance, &BufferLoad, FALSE );
794
if ( ulResult != cOCT6100_ERR_OK )
797
/* Reserve all resources needed by the buffer. */
798
ulResult = Oct6100ApiReserveBufferResources( f_pApiInstance, &BufferLoad, TRUE, cOCT6100_INVALID_INDEX, &ulBufferIndex, &ulBufferBase );
799
if ( ulResult != cOCT6100_ERR_OK )
802
/* Update the new buffer's entry in the buffer list. */
803
ulResult = Oct6100ApiUpdateBufferEntry( f_pApiInstance, &BufferLoad, ulBufferIndex, ulBufferBase );
804
if ( ulResult != cOCT6100_ERR_OK )
807
return cOCT6100_ERR_OK;
812
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
814
Function: Oct6100BufferLoadBlockSer
816
Description: Loads a buffer in external memory using blocks.
818
-------------------------------------------------------------------------------
819
| Argument | Description
820
-------------------------------------------------------------------------------
821
f_pApiInstance Pointer to API instance. This memory is used to keep
822
the present state of the chip and all its resources.
824
f_pBufferLoadBlock Pointer to buffer block to be loaded into external
827
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
828
#if !SKIP_Oct6100BufferLoadBlockSer
829
UINT32 Oct6100BufferLoadBlockSer(
830
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
831
IN OUT tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock )
836
/* Check the user's configuration for errors. */
837
ulResult = Oct6100ApiCheckBufferLoadBlockParams( f_pApiInstance, f_pBufferLoadBlock, &ulBufferBase );
838
if ( ulResult != cOCT6100_ERR_OK )
841
/* Write the buffer in external memory at the appropriate offset - must do some pointer arithmetic. */
842
ulResult = Oct6100ApiWriteBufferInMemory( f_pApiInstance, ulBufferBase + f_pBufferLoadBlock->ulBlockOffset,
843
f_pBufferLoadBlock->ulBlockLength, f_pBufferLoadBlock->pbyBufferPattern + f_pBufferLoadBlock->ulBlockOffset );
844
if ( ulResult != cOCT6100_ERR_OK )
847
return cOCT6100_ERR_OK;
852
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
854
Function: Oct6100ApiCheckBufferParams
856
Description: Checks the user's buffer playout load configuration for errors.
858
-------------------------------------------------------------------------------
859
| Argument | Description
860
-------------------------------------------------------------------------------
861
f_pApiInstance Pointer to API instance. This memory is used to keep the
862
present state of the chip and all its resources.
864
f_pBufferLoad Pointer to buffer configuration structure.
865
f_fCheckBufferPtr Check if the buffer pointer is NULL or not.
867
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
868
#if !SKIP_Oct6100ApiCheckBufferParams
869
UINT32 Oct6100ApiCheckBufferParams(
870
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
871
IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad,
872
IN BOOL f_fCheckBufferPtr )
874
/* Check for errors. */
875
if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
876
return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
878
if ( f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayout == FALSE )
879
return cOCT6100_ERR_NOT_SUPPORTED_BUFFER_PLAYOUT;
881
if ( f_pBufferLoad->pulBufferIndex == NULL )
882
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
884
if( f_fCheckBufferPtr )
886
if ( f_pBufferLoad->pbyBufferPattern == NULL )
887
return cOCT6100_ERR_BUFFER_PLAYOUT_PATTERN;
890
if ( f_pBufferLoad->ulBufferSize < cOCT6100_MINIMUM_BUFFER_SIZE )
891
return cOCT6100_ERR_BUFFER_PLAYOUT_TOO_SMALL;
893
if ( ( f_pBufferLoad->ulBufferSize % cOCT6100_BUFFER_SIZE_GRANULARITY ) != 0 )
894
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
896
if ( f_pBufferLoad->ulBufferPcmLaw != cOCT6100_PCM_U_LAW &&
897
f_pBufferLoad->ulBufferPcmLaw != cOCT6100_PCM_A_LAW )
898
return cOCT6100_ERR_BUFFER_PLAYOUT_PCM_LAW;
900
return cOCT6100_ERR_OK;
905
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
907
Function: Oct6100ApiCheckBufferLoadBlockParams
909
Description: Checks the user's buffer playout load block configuration for
912
-------------------------------------------------------------------------------
913
| Argument | Description
914
-------------------------------------------------------------------------------
915
f_pApiInstance Pointer to API instance. This memory is used to keep the
916
present state of the chip and all its resources.
918
f_pBufferLoadBlock Pointer to buffer block descriptor.
919
f_pulBufferBase Pointer to the base address of the buffer in external
922
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
923
#if !SKIP_Oct6100ApiCheckBufferLoadBlockParams
924
UINT32 Oct6100ApiCheckBufferLoadBlockParams(
925
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
926
IN tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock,
927
OUT PUINT32 f_pulBufferBase )
929
/* Check for errors. */
930
tPOCT6100_API_BUFFER pBufEntry;
932
if ( f_pBufferLoadBlock->ulBufferIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers )
933
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
935
mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, f_pBufferLoadBlock->ulBufferIndex )
937
if ( pBufEntry->fReserved != TRUE )
938
return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_OPEN;
940
if ( ( f_pBufferLoadBlock->ulBlockLength % 2 ) != 0 )
941
return cOCT6100_ERR_BUFFER_PLAYOUT_BLOCK_LENGTH_INVALID;
943
if ( ( f_pBufferLoadBlock->ulBlockOffset % 2 ) != 0 )
944
return cOCT6100_ERR_BUFFER_PLAYOUT_BLOCK_OFFSET_INVALID;
946
if ( f_pBufferLoadBlock->pbyBufferPattern == NULL )
947
return cOCT6100_ERR_BUFFER_PLAYOUT_PATTERN;
949
/* Check boundaries */
950
if ( ( f_pBufferLoadBlock->ulBlockLength + f_pBufferLoadBlock->ulBlockOffset ) > pBufEntry->ulBufferSize )
951
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
953
*f_pulBufferBase = pBufEntry->ulBufferBase;
955
return cOCT6100_ERR_OK;
960
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
962
Function: Oct6100ApiReserveBufferResources
964
Description: Reserves all resources needed for the new buffer.
966
-------------------------------------------------------------------------------
967
| Argument | Description
968
-------------------------------------------------------------------------------
969
f_pApiInstance Pointer to API instance. This memory is used to keep the
970
present state of the chip and all its resources.
972
f_pBufferLoad Pointer to buffer configuration structure.
974
f_fReserveListStruct Flag indicating if a list structure should be reserved
975
or if the structure has been reserved before.
977
f_ulBufIndex If the f_fReserveListStruct flag is set, this index
978
will identifying the buffer playout list structure
979
that must be used to load the specified buffer.
981
f_pulBufferIndex Allocated entry in buffer playout list.
983
f_pulBufferBase Allocated external memory block for the buffer.
985
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
986
#if !SKIP_Oct6100ApiReserveBufferResources
987
UINT32 Oct6100ApiReserveBufferResources(
988
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
989
IN tPOCT6100_BUFFER_LOAD f_pBufferLoad,
990
IN BOOL f_fReserveListStruct,
991
IN UINT32 f_ulBufIndex,
992
OUT PUINT32 f_pulBufferIndex,
993
OUT PUINT32 f_pulBufferBase )
995
tPOCT6100_SHARED_INFO pSharedInfo;
996
UINT32 ulResult = cOCT6100_ERR_OK;
999
/* Obtain local pointer to shared portion of instance. */
1000
pSharedInfo = f_pApiInstance->pSharedInfo;
1002
/* Reserve an entry in the buffer list. */
1003
if ( f_fReserveListStruct == TRUE )
1005
ulResult = Oct6100ApiReserveBufPlayoutListEntry( f_pApiInstance, f_pulBufferIndex );
1009
*f_pulBufferIndex = f_ulBufIndex;
1011
if ( ulResult == cOCT6100_ERR_OK )
1013
/* Find a free block to store the buffer. */
1014
ulResult = Oct6100ApiReserveBufferPlayoutMemory( f_pApiInstance, f_pBufferLoad->ulBufferSize, f_pulBufferBase );
1015
if ( ulResult != cOCT6100_ERR_OK )
1017
/* Release the list entry. */
1018
if ( f_fReserveListStruct == TRUE )
1020
ulTempVar = Oct6100ApiReleaseBufPlayoutListEntry( f_pApiInstance, *f_pulBufferIndex );
1021
if ( ulTempVar != cOCT6100_ERR_OK )
1032
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1034
Function: Oct6100ApiWriteBufferInMemory
1036
Description: Writes the buffer in external memory.
1038
-------------------------------------------------------------------------------
1039
| Argument | Description
1040
-------------------------------------------------------------------------------
1041
f_pApiInstance Pointer to API instance. This memory is used to keep
1042
the present state of the chip and all its resources.
1044
f_ulBufferBase Allocated external memory address for the buffer.
1046
f_ulBufferLength Length in bytes of the buffer to be copied in memory.
1048
f_pbyBuffer Address where the buffer should be copied from.
1050
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1051
#if !SKIP_Oct6100ApiWriteBufferInMemory
1052
UINT32 Oct6100ApiWriteBufferInMemory(
1053
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1054
IN UINT32 f_ulBufferBase,
1055
IN UINT32 f_ulBufferLength,
1056
IN PUINT8 f_pbyBuffer )
1058
tPOCT6100_SHARED_INFO pSharedInfo;
1059
tOCT6100_WRITE_BURST_PARAMS BurstParams;
1060
tOCT6100_WRITE_PARAMS WriteParams;
1063
PUINT16 pusSuperArray;
1064
PUINT8 pbyPlayoutBuffer;
1065
UINT32 ulByteCount = 0;
1068
/* Get local pointer to shared portion of instance. */
1069
pSharedInfo = f_pApiInstance->pSharedInfo;
1071
/* Set the process context and user chip ID parameters once and for all. */
1072
BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
1074
BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1076
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1078
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1080
/* Write the buffer in external memory. */
1081
ulNumWrites = f_ulBufferLength / 2;
1083
BurstParams.ulWriteAddress = f_ulBufferBase;
1084
BurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
1086
pusSuperArray = pSharedInfo->MiscVars.ausSuperArray;
1087
pbyPlayoutBuffer = f_pbyBuffer;
1089
/* Check if we can maximize the bandwidth through the CPU port. */
1090
if ( f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels == 0 )
1092
WriteParams.ulWriteAddress = 0x234;
1093
WriteParams.usWriteData = 0x08ff;
1094
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
1095
if ( ulResult != cOCT6100_ERR_OK )
1099
while ( ulNumWrites != 0 )
1101
if ( ulNumWrites >= pSharedInfo->ChipConfig.usMaxRwAccesses )
1102
BurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
1104
BurstParams.ulWriteLength = ulNumWrites;
1106
for ( i = 0; i < BurstParams.ulWriteLength; i++ )
1108
pusSuperArray[ i ] = ( UINT16 )(( pbyPlayoutBuffer [ ulByteCount++ ]) << 8);
1109
pusSuperArray[ i ] |= ( UINT16 )pbyPlayoutBuffer [ ulByteCount++ ];
1112
mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )
1113
if ( ulResult != cOCT6100_ERR_OK )
1116
BurstParams.ulWriteAddress += 2 * BurstParams.ulWriteLength;
1117
ulNumWrites -= BurstParams.ulWriteLength;
1121
/* Make sure we revert back the changes made to the CPU bandwidth register. */
1122
if ( f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels == 0 )
1124
WriteParams.ulWriteAddress = 0x234;
1125
WriteParams.usWriteData = 0x0804;
1126
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
1127
if ( ulResult != cOCT6100_ERR_OK )
1131
return cOCT6100_ERR_OK;
1136
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1138
Function: Oct6100ApiUpdateBufferEntry
1140
Description: Updates the new buffer's entry in the buffer playout list.
1142
-------------------------------------------------------------------------------
1143
| Argument | Description
1144
-------------------------------------------------------------------------------
1145
f_pApiInstance Pointer to API instance. This memory is used to keep
1146
the present state of the chip and all its resources.
1148
f_pBufferLoad Pointer to buffer configuration structure.
1149
f_ulBufferIndex Allocated entry in buffer playout list.
1150
f_ulBufferBase Allocated external memory block for the buffer.
1152
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1153
#if !SKIP_Oct6100ApiUpdateBufferEntry
1154
UINT32 Oct6100ApiUpdateBufferEntry(
1155
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1156
IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad,
1157
IN UINT32 f_ulBufferIndex,
1158
IN UINT32 f_ulBufferBase )
1160
tPOCT6100_API_BUFFER pBufEntry;
1161
UINT32 ulBufferSize = f_pBufferLoad->ulBufferSize;
1163
/* Obtain a pointer to the new buffer's list entry. */
1164
mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, f_ulBufferIndex )
1166
/* Copy the buffer's configuration and allocated resources. */
1167
pBufEntry->ulBufferSize = f_pBufferLoad->ulBufferSize;
1168
pBufEntry->byBufferPcmLaw = (UINT8)( f_pBufferLoad->ulBufferPcmLaw & 0xFF );
1169
pBufEntry->ulBufferBase = f_ulBufferBase;
1171
/* Update the entries flags. */
1172
pBufEntry->usDependencyCnt = 0;
1174
/* Mark the buffer as opened. */
1175
pBufEntry->fReserved = TRUE;
1177
/* Increment the number of buffer loaded into the chip.*/
1178
f_pApiInstance->pSharedInfo->ChipStats.usNumberPlayoutBuffers++;
1180
/* Refresh the amount of memory used by buffer playout. */
1182
/* Reserved size is divisible by 64. */
1183
if ( ulBufferSize % 64 )
1184
ulBufferSize = ulBufferSize + ( 64 - ( ulBufferSize % 64 ) );
1185
f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed += ulBufferSize;
1187
/* Return the buffer index to the user. */
1188
*f_pBufferLoad->pulBufferIndex = f_ulBufferIndex;
1190
/* Return the amount of free memory left in the chip. */
1191
/* Note that this value does not give the "fragmentation" state of the available memory. */
1192
/* This value only gives the amount of free memory */
1193
if( f_pBufferLoad->pulPlayoutFreeMemSize )
1194
*f_pBufferLoad->pulPlayoutFreeMemSize = ( f_pApiInstance->pSharedInfo->MiscVars.ulTotalMemSize - ( f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress - cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) ) - ( f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed );
1196
return cOCT6100_ERR_OK;
1201
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1203
Function: Oct6100BufferUnloadSer
1205
Description: Unloads a buffer from external memory.
1207
-------------------------------------------------------------------------------
1208
| Argument | Description
1209
-------------------------------------------------------------------------------
1210
f_pApiInstance Pointer to API instance. This memory is used to keep the
1211
present state of the chip and all its resources.
1213
f_pBufferUnload Pointer to buffer unload structure.
1214
f_fReleaseListStruct Whether to release the buffer playout list structure
1217
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1218
#if !SKIP_Oct6100BufferUnloadSer
1219
UINT32 Oct6100BufferUnloadSer(
1220
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1221
IN OUT tPOCT6100_BUFFER_UNLOAD f_pBufferUnload,
1222
IN BOOL f_fReleaseListStruct )
1224
UINT32 ulBufferIndex;
1225
UINT32 ulBufferBase;
1228
/* Verify that all the parameters given match the state of the API. */
1229
ulResult = Oct6100ApiAssertBufferParams( f_pApiInstance, f_pBufferUnload, &ulBufferIndex, &ulBufferBase );
1230
if ( ulResult != cOCT6100_ERR_OK )
1233
/* Release all resources associated to the unloaded buffer. */
1234
ulResult = Oct6100ApiReleaseBufferResources( f_pApiInstance, ulBufferIndex, ulBufferBase, f_fReleaseListStruct );
1235
if ( ulResult != cOCT6100_ERR_OK )
1238
return cOCT6100_ERR_OK;
1243
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1245
Function: Oct6100ApiAssertBufferParams
1247
Description: Checks the buffer playout unload configuration for errors.
1249
-------------------------------------------------------------------------------
1250
| Argument | Description
1251
-------------------------------------------------------------------------------
1252
f_pApiInstance Pointer to API instance. This memory is used to keep the
1253
present state of the chip and all its resources.
1255
f_pBufferUnload Pointer to buffer unload structure.
1256
f_pulBufferIndex Pointer to the index of the buffer in the API's buffers list.
1257
f_pulBufferBase Pointer to the base address of the buffer in external memory.
1259
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1260
#if !SKIP_Oct6100ApiAssertBufferParams
1261
UINT32 Oct6100ApiAssertBufferParams(
1262
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1263
IN tPOCT6100_BUFFER_UNLOAD f_pBufferUnload,
1264
OUT PUINT32 f_pulBufferIndex,
1265
OUT PUINT32 f_pulBufferBase )
1267
tPOCT6100_API_BUFFER pBufEntry;
1269
*f_pulBufferIndex = f_pBufferUnload->ulBufferIndex;
1271
if ( *f_pulBufferIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers )
1272
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
1274
mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, *f_pulBufferIndex )
1276
/* Check for errors. */
1277
if ( pBufEntry->fReserved != TRUE )
1278
return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_OPEN;
1279
if ( pBufEntry->usDependencyCnt != 0 )
1280
return cOCT6100_ERR_BUFFER_PLAYOUT_ACTIVE_DEPENDENCIES;
1282
/* Return all info needed to invalidate buffer. */
1283
*f_pulBufferBase = pBufEntry->ulBufferBase;
1285
return cOCT6100_ERR_OK;
1290
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1292
Function: Oct6100ApiReleaseBufferResources
1294
Description: Release resources needed by the buffer.
1296
-------------------------------------------------------------------------------
1297
| Argument | Description
1298
-------------------------------------------------------------------------------
1299
f_pApiInstance Pointer to API instance. This memory is used to keep the
1300
present state of the chip and all its resources.
1302
f_ulBufferIndex Allocated entry in buffer playout list.
1303
f_ulBufferBase Allocated external memory block for the buffer.
1304
f_fReleaseListStruct Free the list structure.
1306
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1307
#if !SKIP_Oct6100ApiReleaseBufferResources
1308
UINT32 Oct6100ApiReleaseBufferResources(
1309
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1310
IN UINT32 f_ulBufferIndex,
1311
IN UINT32 f_ulBufferBase,
1312
IN BOOL f_fReleaseListStruct )
1314
tPOCT6100_SHARED_INFO pSharedInfo;
1315
tPOCT6100_API_BUFFER pBufEntry;
1317
UINT32 ulBufferSize;
1319
/* Obtain local pointer to shared portion of instance. */
1320
pSharedInfo = f_pApiInstance->pSharedInfo;
1322
/* Free the external memory reserved for the buffer. */
1323
ulResult = Oct6100ApiReleaseBufferPlayoutMemory( f_pApiInstance, f_ulBufferBase );
1324
if ( ulResult != cOCT6100_ERR_OK )
1325
return cOCT6100_ERR_FATAL_3E;
1327
/* Release the entry from the buffer list. */
1328
if ( f_fReleaseListStruct == TRUE )
1329
ulResult = Oct6100ApiReleaseBufPlayoutListEntry( f_pApiInstance, f_ulBufferIndex );
1330
if ( ulResult != cOCT6100_ERR_OK )
1333
mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, f_ulBufferIndex );
1335
/* Save buffer size before releasing that entry, will be needed to calculate the amount of */
1336
/* free memory left for the user. */
1337
ulBufferSize = pBufEntry->ulBufferSize;
1339
/* Flag the buffer entry as free. */
1340
pBufEntry->fReserved = FALSE;
1342
/* Decrement the number of buffer loaded into the chip. */
1343
f_pApiInstance->pSharedInfo->ChipStats.usNumberPlayoutBuffers--;
1345
/* Refresh the amount of memory used by buffer playout. */
1346
/* Reserved size is divisible by 64. */
1347
if ( ulBufferSize % 64 )
1348
ulBufferSize = ulBufferSize + ( 64 - ( ulBufferSize % 64 ) );
1349
f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed -= ulBufferSize;
1351
return cOCT6100_ERR_OK;
1356
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1358
Function: Oct6100BufferPlayoutAddSer
1360
Description: This function adds a buffer to a channel buffer list.
1362
-------------------------------------------------------------------------------
1363
| Argument | Description
1364
-------------------------------------------------------------------------------
1365
f_pApiInstance Pointer to API instance. This memory is used to keep the
1366
present state of the chip and all its resources.
1368
f_pBufferPlayoutAdd Pointer to buffer playout add structure.
1370
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1371
#if !SKIP_Oct6100BufferPlayoutAddSer
1372
UINT32 Oct6100BufferPlayoutAddSer(
1373
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1374
IN OUT tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd )
1376
UINT32 ulBufferIndex;
1377
UINT32 ulChannelIndex;
1380
/* Check the user's configuration of the buffer for errors. */
1381
ulResult = Oct6100ApiCheckPlayoutAddParams( f_pApiInstance, f_pBufferPlayoutAdd, &ulChannelIndex, &ulBufferIndex );
1382
if ( ulResult != cOCT6100_ERR_OK )
1385
/* Write to all resources needed to activate buffer playout. */
1386
ulResult = Oct6100ApiWriteBufferAddStructs( f_pApiInstance, f_pBufferPlayoutAdd, ulChannelIndex, ulBufferIndex );
1387
if ( ulResult != cOCT6100_ERR_OK )
1390
return cOCT6100_ERR_OK;
1395
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1397
Function: Oct6100ApiCheckPlayoutAddParams
1399
Description: Check the validity of the channel and buffer requested.
1401
-------------------------------------------------------------------------------
1402
| Argument | Description
1403
-------------------------------------------------------------------------------
1404
f_pApiInstance Pointer to API instance. This memory is used to keep the
1405
present state of the chip and all its resources.
1407
f_pBufferPlayoutAdd Pointer to buffer playout add structure.
1408
f_pulChannelIndex Pointer to the channel index of the selected channel.
1409
f_pulBufferIndex Pointer to the buffer index within the API's buffer list.
1411
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1412
#if !SKIP_Oct6100ApiCheckPlayoutAddParams
1413
UINT32 Oct6100ApiCheckPlayoutAddParams(
1414
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1415
IN tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd,
1416
OUT PUINT32 f_pulChannelIndex,
1417
OUT PUINT32 f_pulBufferIndex )
1419
tPOCT6100_API_BUFFER pBufferEntry;
1420
tPOCT6100_API_CHANNEL pEchoChannel;
1421
UINT32 ulEntryOpenCnt;
1423
/* Check for errors. */
1424
if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
1425
return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
1427
if ( f_pBufferPlayoutAdd->ulChannelHndl == cOCT6100_INVALID_HANDLE )
1428
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
1430
if ( f_pBufferPlayoutAdd->ulPlayoutPort != cOCT6100_CHANNEL_PORT_ROUT &&
1431
f_pBufferPlayoutAdd->ulPlayoutPort != cOCT6100_CHANNEL_PORT_SOUT )
1432
return cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT;
1434
if ( f_pBufferPlayoutAdd->fRepeat != TRUE && f_pBufferPlayoutAdd->fRepeat != FALSE )
1435
return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_REPEAT;
1437
if ( f_pBufferPlayoutAdd->fRepeat == TRUE )
1439
if ( f_pBufferPlayoutAdd->ulRepeatCount != cOCT6100_REPEAT_INFINITELY )
1441
if ( f_pBufferPlayoutAdd->ulRepeatCount == 0x0
1442
|| f_pBufferPlayoutAdd->ulRepeatCount > cOCT6100_REPEAT_MAX)
1444
return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_REPEAT_COUNT;
1449
if ( f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_0_DB &&
1450
f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_MINUS_6_DB &&
1451
f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_MINUS_12_DB &&
1452
f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_MUTE )
1453
return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_MIXING;
1455
if ( ( f_pBufferPlayoutAdd->lGainDb < -24 )
1456
|| ( f_pBufferPlayoutAdd->lGainDb > 24 ) )
1457
return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_GAIN_DB;
1459
/*=====================================================================*/
1460
/* Check the channel handle. */
1462
if ( (f_pBufferPlayoutAdd->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
1463
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
1465
*f_pulChannelIndex = f_pBufferPlayoutAdd->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK;
1466
if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
1467
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
1469
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
1471
/* Extract the entry open count from the provided handle. */
1472
ulEntryOpenCnt = (f_pBufferPlayoutAdd->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
1474
/* Check for errors. */
1475
if ( pEchoChannel->fReserved != TRUE )
1476
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_NOT_OPEN;
1477
if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt )
1478
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
1480
/* Check if repeat flag has been used for this port. */
1481
if ( ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) && ( pEchoChannel->fRinBufPlayoutRepeatUsed == TRUE ) )
1482
|| ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pEchoChannel->fSoutBufPlayoutRepeatUsed == TRUE ) ) )
1483
return cOCT6100_ERR_BUFFER_PLAYOUT_REPEAT_USED;
1485
/*=====================================================================*/
1487
/*=====================================================================*/
1488
/* Check the buffer information. */
1490
*f_pulBufferIndex = f_pBufferPlayoutAdd->ulBufferIndex;
1491
if ( *f_pulBufferIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers )
1492
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
1494
mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufferEntry, *f_pulBufferIndex )
1496
if ( pBufferEntry->fReserved != TRUE )
1497
return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_OPEN;
1499
/* Check if the play length is not larger then the currently uploaded buffer. */
1500
if ( ( f_pBufferPlayoutAdd->ulBufferLength > pBufferEntry->ulBufferSize ) &&
1501
( f_pBufferPlayoutAdd->ulBufferLength != cOCT6100_AUTO_SELECT ) )
1502
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
1504
if( f_pBufferPlayoutAdd->ulBufferLength != cOCT6100_AUTO_SELECT )
1506
if ( f_pBufferPlayoutAdd->ulBufferLength < cOCT6100_MINIMUM_BUFFER_SIZE )
1507
return cOCT6100_ERR_BUFFER_PLAYOUT_TOO_SMALL;
1509
if ( ( f_pBufferPlayoutAdd->ulBufferLength % cOCT6100_BUFFER_SIZE_GRANULARITY ) != 0 )
1510
return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
1513
/*=====================================================================*/
1515
return cOCT6100_ERR_OK;
1520
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1522
Function: Oct6100ApiWriteBufferAddStructs
1524
Description: Write the buffer playout event in the channel's port playout
1527
-------------------------------------------------------------------------------
1528
| Argument | Description
1529
-------------------------------------------------------------------------------
1530
f_pApiInstance Pointer to API instance. This memory is used to keep the
1531
present state of the chip and all its resources.
1533
f_pBufferPlayoutAdd Pointer to buffer playout add structure.
1534
f_ulChannelIndex Index of the channel on which the buffer is to be added.
1535
f_ulBufferIndex Index of the buffer structure within the API's buffer list.
1537
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1538
#if !SKIP_Oct6100ApiWriteBufferAddStructs
1539
UINT32 Oct6100ApiWriteBufferAddStructs(
1540
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1541
IN tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd,
1542
IN UINT32 f_ulChannelIndex,
1543
IN UINT32 f_ulBufferIndex )
1545
tPOCT6100_API_BUFFER pBufferEntry;
1546
tPOCT6100_API_CHANNEL pEchoChannel;
1547
tPOCT6100_SHARED_INFO pSharedInfo;
1548
tOCT6100_READ_PARAMS ReadParams;
1551
UINT32 ulEventBuffer;
1553
UINT32 ulReadPtrBytesOfst;
1554
UINT32 ulReadPtrBitOfst;
1555
UINT32 ulReadPtrFieldSize;
1557
UINT32 ulWritePtrBytesOfst;
1558
UINT32 ulWritePtrBitOfst;
1559
UINT32 ulWritePtrFieldSize;
1564
UINT32 ulPlayoutBaseAddress;
1566
UINT32 ulEventIndex;
1569
UINT32 ulRepeatCount = 0;
1570
BOOL fRepeatCountSet = FALSE;
1571
UINT32 ulDurationModulo = 0;
1572
UINT32 ulEventsToCreate = 1;
1573
UINT32 ulBufferDurationMs;
1575
UINT32 ulBufferLength;
1576
UINT16 usTempData = 0;
1579
UINT32 ulChipWritePtr;
1581
UINT32 ulLoopCnt = 0;
1582
BOOL fStillPlaying = TRUE;
1583
BOOL fCheckHardStop = FALSE;
1584
BOOL fOldBufferPlayoutVersion = FALSE;
1586
UINT32 aulWaitTime[ 2 ];
1588
/* Obtain local pointer to shared portion of instance. */
1589
pSharedInfo = f_pApiInstance->pSharedInfo;
1591
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
1592
mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufferEntry, f_ulBufferIndex );
1594
/* Select the buffer of interest. */
1595
if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
1597
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
1598
ulWritePtr = pEchoChannel->ulRinBufWritePtr;
1600
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
1601
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
1602
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
1604
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
1605
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
1606
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
1608
else /* f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
1610
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
1611
ulWritePtr = pEchoChannel->ulSoutBufWritePtr;
1613
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
1614
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
1615
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
1617
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
1618
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
1619
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
1622
/*=======================================================================*/
1623
/* Calculate the repeat count. */
1625
/* The buffer length is either the total buffer size or the value specified by the user */
1626
if ( f_pBufferPlayoutAdd->ulBufferLength == cOCT6100_AUTO_SELECT )
1628
ulBufferLength = pBufferEntry->ulBufferSize;
1632
ulBufferLength = f_pBufferPlayoutAdd->ulBufferLength;
1635
if ( f_pBufferPlayoutAdd->ulDuration != cOCT6100_INVALID_VALUE )
1637
/* With duration and buffer length, we can find the number of times we must repeat playing this buffer. */
1638
ulBufferDurationMs = ulBufferLength / cOCT6100_SAMPLES_PER_MS;
1639
ulRepeatCount = f_pBufferPlayoutAdd->ulDuration / ulBufferDurationMs;
1640
fRepeatCountSet = TRUE;
1642
/* Check if buffer is larger then asked duration. */
1643
if ( ulRepeatCount != 0x0 )
1645
/* We might have to create more then 1 event to accomodate for the repeat-max limit. */
1646
ulEventsToCreate = ( ulRepeatCount / cOCT6100_REPEAT_MAX ) + 1;
1650
/* No repeat event. Maybe only the duration modulo! */
1651
ulEventsToCreate = 0x0;
1654
/* Check if must create a second event for a buffer that cannot be played completely. */
1655
ulDurationModulo = f_pBufferPlayoutAdd->ulDuration % ulBufferDurationMs;
1656
if ( ulDurationModulo != 0x0 )
1658
ulDurationModulo *= cOCT6100_SAMPLES_PER_MS;
1659
if ( ulDurationModulo / cOCT6100_BUFFER_SIZE_GRANULARITY )
1661
/* Round the modulo to be on a buffer size granularity. */
1662
/* This will round down. */
1663
ulDurationModulo = ( ulDurationModulo / cOCT6100_BUFFER_SIZE_GRANULARITY ) * cOCT6100_BUFFER_SIZE_GRANULARITY;
1665
/* If the event about to be created is smaller then the minimum buffer size, */
1666
/* round up to the minimum required by the hardware. */
1667
if ( ulDurationModulo < cOCT6100_MINIMUM_BUFFER_SIZE )
1668
ulDurationModulo = cOCT6100_MINIMUM_BUFFER_SIZE;
1673
/* The modulo is too small to be played. Skip. */
1674
ulDurationModulo = 0;
1678
else if ( f_pBufferPlayoutAdd->fRepeat == TRUE
1679
&& f_pBufferPlayoutAdd->ulRepeatCount != cOCT6100_REPEAT_INFINITELY )
1681
/* The repeat count is set directly from the user. */
1682
ulRepeatCount = f_pBufferPlayoutAdd->ulRepeatCount;
1683
fRepeatCountSet = TRUE;
1686
/*=======================================================================*/
1688
/* Set the playout feature base address. */
1689
ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_ulChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
1691
/* Read the read pointer. */
1692
ulAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
1694
/* Must read in memory directly since this value is changed by hardware. */
1695
ulResult = Oct6100ApiReadDword( f_pApiInstance, ulAddress, &ulTempData );
1696
if ( ulResult != cOCT6100_ERR_OK )
1699
mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
1701
/* Store the read pointer. */
1702
ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
1704
/* Compare the pointers... Are they different? If so, there is something already in the list. */
1705
if ( ulReadPtr != ulWritePtr )
1707
/* Check if there is enough room for the playout events. */
1708
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
1709
&& ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
1711
/* 127 or 31 events image. */
1712
if ( (UINT8)( ( ulWritePtr - ulReadPtr ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 ) ) >= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - (UINT8)ulEventsToCreate ) )
1713
fCheckHardStop = TRUE;
1717
/* Old 31 events image. */
1718
if ( ( ( ulWritePtr - ulReadPtr ) & 0x1F ) >= ( 0x20 - ulEventsToCreate ) )
1719
fCheckHardStop = TRUE;
1721
fOldBufferPlayoutVersion = TRUE;
1724
if ( fCheckHardStop == TRUE )
1726
/* Ok. From what was read, the list is full. But we might still have a chance if the hard-stop */
1727
/* version was used. In this case, some of the buffers in the list might */
1728
/* become free in a couple of milliseconds, so try to wait for this. */
1730
if ( ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) && ( pEchoChannel->fRinHardStop == TRUE ) )
1731
|| ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pEchoChannel->fSoutHardStop == TRUE ) ) )
1733
/* Read the 'chip' write pointer in the hardware. */
1734
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1736
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1737
ReadParams.pusReadData = &usReadData;
1738
ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
1740
/* Get the write pointer in the chip. */
1741
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
1743
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulReadData, ulResult );
1744
if ( ulResult != cOCT6100_ERR_OK )
1747
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
1749
/* Store the write pointer. */
1750
ulChipWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst;
1752
/* Optimize this access by only reading the word we are interested in. */
1753
if ( ulReadPtrBitOfst < 16 )
1754
ReadParams.ulReadAddress += 2;
1756
while( fStillPlaying == TRUE )
1758
/* Read the read pointer until equals to the write pointer. */
1759
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1760
if ( ulResult != cOCT6100_ERR_OK )
1763
/* Move data at correct position according to what was read. */
1764
if ( ulReadPtrBitOfst < 16 )
1765
ulTempData = usReadData;
1767
ulTempData = usReadData << 16;
1769
mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
1771
/* Store the read pointer.*/
1772
ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
1774
/* Playout has finished when the read pointer reaches the write pointer. */
1775
if ( ulReadPtr == ulChipWritePtr )
1779
if ( ulLoopCnt > cOCT6100_MAX_LOOP )
1781
return cOCT6100_ERR_FATAL_E7;
1784
aulWaitTime[ 0 ] = 100;
1785
aulWaitTime[ 1 ] = 0;
1786
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
1787
if ( ulResult != cOCT6100_ERR_OK )
1791
/* Clear hard-stop flag. */
1792
if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
1794
/* No hard stop for now. */
1795
pEchoChannel->fRinHardStop = FALSE;
1797
else /* if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
1799
/* No hard stop for now. */
1800
pEchoChannel->fSoutHardStop = FALSE;
1803
/* Now check again if the event can be added... */
1804
if ( fOldBufferPlayoutVersion == FALSE )
1806
if ( (UINT8)( ( ulWritePtr - ulReadPtr ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 ) ) >= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - (UINT8)ulEventsToCreate ) )
1807
return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL;
1809
else /* if ( fOldBufferPlayoutVersion == TRUE ) */
1811
/* Old 31 events image. */
1812
if ( ( ( ulWritePtr - ulReadPtr ) & 0x1F ) >= ( 0x20 - ulEventsToCreate ) )
1813
return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL;
1816
/* Good, at least another buffer can be added! Add the buffer to the list. */
1820
/* Well the list is full! */
1821
return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL;
1826
/*=======================================================================*/
1827
/* Write the events. */
1829
for ( ulEventIndex = 0; ulEventIndex < ulEventsToCreate; ulEventIndex ++ )
1831
/* Set the playout event base address. */
1832
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
1833
&& ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
1835
/* 127 or 31 events image. */
1836
ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + (f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * (ulWritePtr & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 )));
1840
/* Old 31 events image. */
1841
ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + (f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * (ulWritePtr & 0x1F));
1844
/* EVENT BASE + 0 */
1845
/* Make sure the xIS and xHS bits are cleared. */
1848
/* Set the repeat count. */
1849
if ( fRepeatCountSet == TRUE )
1851
if ( ( ulRepeatCount != 0x0 ) && ( ulRepeatCount <= cOCT6100_REPEAT_MAX ) )
1853
/* Use repeat count directly. */
1854
ulTempData |= ulRepeatCount;
1856
/* Will be used later when creating the duration modulo event. */
1859
else if ( ulRepeatCount != 0x0 )
1861
/* Get ready for next event. */
1862
ulRepeatCount -= cOCT6100_REPEAT_MAX;
1864
/* Set maximum for this event. */
1865
ulTempData |= cOCT6100_REPEAT_MAX;
1869
/* Duration modulo case. Nothing to set here. */
1872
else /* if ( fRepeatCountSet != TRUE ) */
1874
/* Repeat only once. */
1878
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
1879
if ( ulResult != cOCT6100_ERR_OK )
1882
/* EVENT BASE + 4 */
1883
/* Set the buffer base address and playout configuration. */
1885
ulTempData = pBufferEntry->ulBufferBase & 0x07FFFFFF;
1887
/* Set play indefinitely or loop N times. */
1888
if ( ( fRepeatCountSet == FALSE ) && ( f_pBufferPlayoutAdd->fRepeat == TRUE ) )
1890
/* Repeat indefinitely. */
1891
ulTempData |= 0x1 << cOCT6100_PLAYOUT_EVENT_REPEAT_OFFSET;
1893
if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
1894
pEchoChannel->fRinBufPlayoutRepeatUsed = TRUE;
1895
else /* if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
1896
pEchoChannel->fSoutBufPlayoutRepeatUsed = TRUE;
1899
/* Use loop N times feature. */
1900
ulTempData |= 0x1 << cOCT6100_PLAYOUT_EVENT_LOOP_TIMES_OFFSET;
1903
ulTempData |= ( pBufferEntry->byBufferPcmLaw << cOCT6100_PLAYOUT_EVENT_LAW_OFFSET );
1905
/* Set the mixing configuration.*/
1906
ulTempData |= f_pBufferPlayoutAdd->ulMixingMode << cOCT6100_PLAYOUT_EVENT_MIX_OFFSET;
1908
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
1909
if ( ulResult != cOCT6100_ERR_OK )
1913
/* EVENT BASE + 8 */
1914
/* Set the buffer size and playout gain. */
1917
/* Check if we are setting the duration modulo. This would be the last event and this */
1918
/* event is of a very specific size. */
1919
if ( ( fRepeatCountSet == TRUE )
1920
&& ( ulEventIndex == ( ulEventsToCreate - 1 ) )
1921
&& ( ulDurationModulo != 0x0 ) )
1923
/* The duration modulo variable contains all that is needed here. */
1924
ulBufferLength = ulDurationModulo;
1926
ulTempData = ulBufferLength;
1928
/* Adjust playout gain. */
1929
if ( f_pBufferPlayoutAdd->lGainDb != 0 )
1931
/* Convert the dB value into OctFloat format. */
1932
usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pBufferPlayoutAdd->lGainDb );
1933
ulTempData |= ( usTempData & 0xFF00 ) << 16;
1937
ulTempData |= cOCT6100_PLAYOUT_GAIN;
1940
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
1941
if ( ulResult != cOCT6100_ERR_OK )
1944
/* EVENT BASE + 0xC */
1946
ulTempData = ( ulBufferLength - 1 ) & 0xFFFFFFC0; /* Must be multiple of 64 bytes */
1948
/* Adjust playout gain. */
1949
if ( f_pBufferPlayoutAdd->lGainDb != 0 )
1951
ulTempData |= ( usTempData & 0xFF ) << 24;
1954
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
1955
if ( ulResult != cOCT6100_ERR_OK )
1962
/*=======================================================================*/
1965
/*=======================================================================*/
1966
/* Increment the write pointer to make it point to the next empty entry. */
1968
if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
1970
pEchoChannel->ulRinBufWritePtr = ( pEchoChannel->ulRinBufWritePtr + ulEventsToCreate ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 );
1971
/* Remember that a buffer was added on the rin port. */
1972
pEchoChannel->fRinBufAdded = TRUE;
1974
else /* f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
1976
pEchoChannel->ulSoutBufWritePtr = ( pEchoChannel->ulSoutBufWritePtr + ulEventsToCreate ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 );
1977
/* Remember that a buffer was added on the sout port. */
1978
pEchoChannel->fSoutBufAdded = TRUE;
1981
/*=======================================================================*/
1983
return cOCT6100_ERR_OK;
1988
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1990
Function: Oct6100BufferPlayoutStartSer
1992
Description: Starts buffer playout on a channel.
1994
-------------------------------------------------------------------------------
1995
| Argument | Description
1996
-------------------------------------------------------------------------------
1997
f_pApiInstance Pointer to API instance. This memory is used to keep the
1998
present state of the chip and all its resources.
2000
f_pBufferPlayoutStart Pointer to buffer playout start structure.
2002
f_ulPlayoutStopEventType Playout stop event type to be generated if required.
2004
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2005
#if !SKIP_Oct6100BufferPlayoutStartSer
2006
UINT32 Oct6100BufferPlayoutStartSer(
2007
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
2008
IN OUT tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart,
2009
IN UINT32 f_ulPlayoutStopEventType )
2011
UINT32 ulBufferIndex = 0;
2012
UINT32 ulChannelIndex;
2013
BOOL fNotifyOnPlayoutStop;
2014
UINT32 ulUserEventId;
2015
BOOL fAddToCurrentlyPlayingList;
2018
/* Check the user's configuration of the buffer for errors. */
2019
ulResult = Oct6100ApiCheckPlayoutStartParams( f_pApiInstance, f_pBufferPlayoutStart, &ulChannelIndex, &ulBufferIndex, &fNotifyOnPlayoutStop, &ulUserEventId, &fAddToCurrentlyPlayingList );
2020
if ( ulResult != cOCT6100_ERR_OK )
2023
/* Write to all resources needed to activate buffer playout. */
2024
ulResult = Oct6100ApiWriteChanPlayoutStructs( f_pApiInstance, f_pBufferPlayoutStart, ulChannelIndex, ulBufferIndex, fNotifyOnPlayoutStop, ulUserEventId, fAddToCurrentlyPlayingList, f_ulPlayoutStopEventType );
2025
if ( ulResult != cOCT6100_ERR_OK )
2028
return cOCT6100_ERR_OK;
2033
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2035
Function: Oct6100ApiCheckPlayoutStartParams
2037
Description: Check the validity of the channel and buffer requested.
2038
Check the validity of the flags requested.
2040
-------------------------------------------------------------------------------
2041
| Argument | Description
2042
-------------------------------------------------------------------------------
2043
f_pApiInstance Pointer to API instance. This memory is used to keep the
2044
present state of the chip and all its resources.
2046
f_pBufferPlayoutStart Pointer to buffer playout start structure.
2047
f_pulChannelIndex Pointer to the channel index of the selected channel.
2048
f_pulBufferIndex Pointer to the buffer index within the API's buffer list.
2049
f_pfNotifyOnPlayoutStop Pointer to the notify on playout stop flag.
2050
f_pulUserEventId Pointer to the user event id specified.
2051
f_pfAllowStartIfActive Pointer to the add to currently playing list flag.
2053
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2054
#if !SKIP_Oct6100ApiCheckPlayoutStartParams
2055
UINT32 Oct6100ApiCheckPlayoutStartParams(
2056
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
2057
IN OUT tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart,
2058
OUT PUINT32 f_pulChannelIndex,
2059
OUT PUINT32 f_pulBufferIndex,
2060
OUT PBOOL f_pfNotifyOnPlayoutStop,
2061
OUT PUINT32 f_pulUserEventId,
2062
OUT PBOOL f_pfAllowStartIfActive )
2064
tPOCT6100_API_CHANNEL pEchoChannel;
2065
UINT32 ulEntryOpenCnt;
2067
/* Check for errors. */
2068
if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
2069
return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
2071
if ( f_pBufferPlayoutStart->ulChannelHndl == cOCT6100_INVALID_HANDLE )
2072
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2074
if ( f_pBufferPlayoutStart->ulPlayoutPort != cOCT6100_CHANNEL_PORT_ROUT &&
2075
f_pBufferPlayoutStart->ulPlayoutPort != cOCT6100_CHANNEL_PORT_SOUT )
2076
return cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT;
2078
if ( f_pBufferPlayoutStart->fNotifyOnPlayoutStop != FALSE
2079
&& f_pBufferPlayoutStart->fNotifyOnPlayoutStop != TRUE )
2080
return cOCT6100_ERR_BUFFER_PLAYOUT_NOTIFY_ON_STOP;
2082
if ( f_pBufferPlayoutStart->fAllowStartWhileActive != FALSE
2083
&& f_pBufferPlayoutStart->fAllowStartWhileActive != TRUE )
2084
return cOCT6100_ERR_BUFFER_PLAYOUT_ALLOW_ACTIVE;
2086
/*=====================================================================*/
2087
/* Check the channel handle. */
2089
if ( (f_pBufferPlayoutStart->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
2090
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2092
*f_pulChannelIndex = f_pBufferPlayoutStart->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK;
2093
if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
2094
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2096
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
2098
/* Extract the entry open count from the provided handle. */
2099
ulEntryOpenCnt = (f_pBufferPlayoutStart->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
2101
/* Check for errors. */
2102
if ( pEchoChannel->fReserved != TRUE )
2103
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_NOT_OPEN;
2104
if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt )
2105
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2107
/* The channel cannot be in POWER_DOWN or HT_FREEZE to start the playout. */
2108
if ( ( pEchoChannel->byEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN )
2109
|| ( pEchoChannel->byEchoOperationMode == cOCT6100_ECHO_OP_MODE_HT_FREEZE ) )
2110
return cOCT6100_ERR_BUFFER_PLAYOUT_ECHO_OP_MODE;
2112
/* The channel's NLP must be enabled for playout to occur. */
2113
if ( pEchoChannel->VqeConfig.fEnableNlp == FALSE )
2114
return cOCT6100_ERR_BUFFER_PLAYOUT_NLP_DISABLED;
2116
/*=====================================================================*/
2118
/*=====================================================================*/
2119
/* Check if the user activated the buffer playout events. */
2121
if ( f_pBufferPlayoutStart->fNotifyOnPlayoutStop == TRUE
2122
&& f_pApiInstance->pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize == 0 )
2123
return cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_DISABLED;
2125
/*=====================================================================*/
2127
/*=====================================================================*/
2128
/* Check if there is actually a buffer added in the list. */
2130
if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
2132
if ( pEchoChannel->fRinBufAdded == FALSE )
2133
return cOCT6100_ERR_BUFFER_PLAYOUT_LIST_EMPTY;
2135
else /* if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
2137
if ( pEchoChannel->fSoutBufAdded == FALSE )
2138
return cOCT6100_ERR_BUFFER_PLAYOUT_LIST_EMPTY;
2141
/*=====================================================================*/
2143
/* Return the requested information. */
2144
*f_pfNotifyOnPlayoutStop = f_pBufferPlayoutStart->fNotifyOnPlayoutStop;
2145
*f_pulUserEventId = f_pBufferPlayoutStart->ulUserEventId;
2146
*f_pfAllowStartIfActive = f_pBufferPlayoutStart->fAllowStartWhileActive;
2148
return cOCT6100_ERR_OK;
2153
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2155
Function: Oct6100ApiWriteChanPlayoutStructs
2157
Description: Write the buffer playout event in the channel main structure.
2159
-------------------------------------------------------------------------------
2160
| Argument | Description
2161
-------------------------------------------------------------------------------
2162
f_pApiInstance Pointer to API instance. This memory is used to keep the
2163
present state of the chip and all its resources.
2165
f_pBufferPlayoutStart Pointer to buffer playout start structure.
2166
f_ulChannelIndex Index of the channel within the API's channel list.
2167
f_ulBufferIndex Index of the buffer within the API's buffer list.
2168
f_fNotifyOnPlayoutStop Flag for the notify on playout stop.
2169
f_ulUserEventId User event id passed to the user when a playout event is generated.
2170
f_fAllowStartIfActive Add to currently playing list flag.
2171
f_ulPlayoutStopEventType Playout stop event type to be generated if required.
2173
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2174
#if !SKIP_Oct6100ApiWriteChanPlayoutStructs
2175
UINT32 Oct6100ApiWriteChanPlayoutStructs(
2176
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
2177
IN tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart,
2178
IN UINT32 f_ulChannelIndex,
2179
IN UINT32 f_ulBufferIndex,
2180
IN BOOL f_fNotifyOnPlayoutStop,
2181
IN UINT32 f_ulUserEventId,
2182
IN BOOL f_fAllowStartIfActive,
2183
IN UINT32 f_ulPlayoutStopEventType )
2185
tPOCT6100_API_BUFFER pBufferEntry;
2186
tPOCT6100_API_CHANNEL pEchoChannel;
2187
tPOCT6100_SHARED_INFO pSharedInfo;
2188
tOCT6100_READ_PARAMS ReadParams;
2193
UINT32 ulChipWritePtr;
2195
UINT32 ulWritePtrBytesOfst;
2196
UINT32 ulSkipPtrBytesOfst;
2197
UINT32 ulWritePtrBitOfst;
2198
UINT32 ulSkipPtrBitOfst;
2199
UINT32 ulWritePtrFieldSize;
2200
UINT32 ulSkipPtrFieldSize;
2202
UINT32 ulIgnoreBytesOfst;
2203
UINT32 ulIgnoreBitOfst;
2204
UINT32 ulIgnoreFieldSize;
2206
UINT32 ulHardSkipBytesOfst;
2207
UINT32 ulHardSkipBitOfst;
2208
UINT32 ulHardSkipFieldSize;
2210
UINT32 ulReadPtrBytesOfst;
2211
UINT32 ulReadPtrBitOfst;
2212
UINT32 ulReadPtrFieldSize;
2214
UINT32 ulPlayoutBaseAddress;
2220
UINT32 ulLoopCnt = 0;
2224
BOOL fBufferPlayoutStopDetected;
2225
BOOL fWriteSkipPtr = FALSE;
2226
BOOL fStillPlaying = TRUE;
2228
UINT32 aulWaitTime[ 2 ];
2230
/* Obtain local pointer to shared portion of instance. */
2231
pSharedInfo = f_pApiInstance->pSharedInfo;
2233
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
2234
mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufferEntry, f_ulBufferIndex );
2236
/* First off, check for buffer playout events, if requested for this channel/port. */
2237
/* At the same time, if requested, check that the playout has stopped for this channel/port. */
2238
if ( ( ( pEchoChannel->fRinBufPlaying == TRUE )
2239
&& ( ( pEchoChannel->fRinBufPlayoutNotifyOnStop == TRUE ) || ( f_fAllowStartIfActive == FALSE ) )
2240
&& ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) )
2241
|| ( ( ( pEchoChannel->fSoutBufPlaying == TRUE ) || ( f_fAllowStartIfActive == FALSE ) )
2242
&& ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == TRUE )
2243
&& ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) ) )
2245
/* Buffer playout might still be going on for this channel/port. */
2246
ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance,
2248
f_pBufferPlayoutStart->ulPlayoutPort,
2249
pEchoChannel->fRinBufPlayoutNotifyOnStop,
2250
&fBufferPlayoutStopDetected );
2251
if ( ulResult != cOCT6100_ERR_OK )
2254
/* Check if the user requested to only start if playout is over. Return an error if */
2255
/* buffer playout is still going on on this channel/port. */
2256
if ( ( f_fAllowStartIfActive == FALSE ) && ( fBufferPlayoutStopDetected == FALSE ) )
2258
/* No go! User should wait for the current list to stop, or call the */
2259
/* Oct6100BufferPlayoutStop function. */
2260
return cOCT6100_ERR_BUFFER_PLAYOUT_STILL_ACTIVE;
2264
/* Select the buffer of interest. */
2265
if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
2267
ulWritePtr = pEchoChannel->ulRinBufWritePtr;
2268
pulSkipPtr = &pEchoChannel->ulRinBufSkipPtr;
2270
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
2271
ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.usDwordOffset * 4;
2272
ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.usDwordOffset * 4;
2273
ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.usDwordOffset * 4;
2274
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
2276
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
2277
ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byBitOffset;
2278
ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byBitOffset;
2279
ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byBitOffset;
2280
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
2282
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
2283
ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byFieldSize;
2284
ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byFieldSize;
2285
ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byFieldSize;
2286
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
2288
else /* f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
2290
ulWritePtr = pEchoChannel->ulSoutBufWritePtr;
2291
pulSkipPtr = &pEchoChannel->ulSoutBufSkipPtr;
2293
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
2294
ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.usDwordOffset * 4;
2295
ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.usDwordOffset * 4;
2296
ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.usDwordOffset * 4;
2297
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
2299
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
2300
ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byBitOffset;
2301
ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byBitOffset;
2302
ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byBitOffset;
2303
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
2305
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
2306
ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byFieldSize;
2307
ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byFieldSize;
2308
ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byFieldSize;
2309
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
2314
/* Set the playout feature base address. */
2315
ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_ulChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
2317
/* Check if we must wait for stop to complete before starting a new list. */
2318
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
2320
if ( ( ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) && ( pEchoChannel->fRinHardStop == TRUE ) )
2321
|| ( ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pEchoChannel->fSoutHardStop == TRUE ) ) )
2323
/* Read the read pointer. */
2324
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
2326
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2327
ReadParams.pusReadData = &usReadData;
2328
ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
2330
/* Get the write pointer in the chip. */
2331
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
2333
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulReadData, ulResult );
2334
if ( ulResult != cOCT6100_ERR_OK )
2337
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
2339
/* Store the write pointer. */
2340
ulChipWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst;
2342
/* Optimize this access by only reading the word we are interested in. */
2343
if ( ulReadPtrBitOfst < 16 )
2344
ReadParams.ulReadAddress += 2;
2346
while( fStillPlaying == TRUE )
2348
/* Read the read pointer until equals to the write pointer. */
2349
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
2350
if ( ulResult != cOCT6100_ERR_OK )
2353
/* Move data at correct position according to what was read. */
2354
if ( ulReadPtrBitOfst < 16 )
2355
ulTempData = usReadData;
2357
ulTempData = usReadData << 16;
2359
mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
2361
/* Store the read pointer. */
2362
ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
2364
/* Playout has finished when the read pointer reaches the write pointer. */
2365
if ( ulReadPtr == ulChipWritePtr )
2369
if( ulLoopCnt > cOCT6100_MAX_LOOP )
2371
return cOCT6100_ERR_FATAL_E6;
2374
aulWaitTime[ 0 ] = 100;
2375
aulWaitTime[ 1 ] = 0;
2376
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
2377
if ( ulResult != cOCT6100_ERR_OK )
2383
/* Check if must clear the skip bit. */
2384
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
2386
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
2387
&& ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
2389
/* Make sure the skip bit is cleared to start playout! */
2390
ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
2392
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulTempData, ulResult );
2393
if ( ulResult != cOCT6100_ERR_OK )
2396
mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask );
2399
ulTempData &= ( ~ulMask );
2401
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
2405
if ( ulResult != cOCT6100_ERR_OK )
2408
/* Make sure the hard skip bit is cleared to start playout! */
2409
ulAddress = ulPlayoutBaseAddress + ulHardSkipBytesOfst;
2411
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
2416
if ( ulResult != cOCT6100_ERR_OK )
2419
mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulHardSkipBitOfst, &ulMask );
2422
ulTempData &= ( ~ulMask );
2424
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
2428
if ( ulResult != cOCT6100_ERR_OK )
2433
/* Write the skip and write pointer to activate buffer playout. */
2435
/* Update the skip pointer. */
2436
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == FALSE )
2437
|| ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == FALSE ) )
2439
/* Old 31 events image. */
2440
if ( ( ( ulWritePtr - *pulSkipPtr ) & 0x7F ) > 63 )
2442
*pulSkipPtr = ( ulWritePtr - 63 ) & 0x7F;
2443
fWriteSkipPtr = TRUE;
2448
/* No need to update the skip pointer, a bit needs to be set when skipping. */
2449
/* fWriteSkipPtr set to FALSE from variable declaration. */
2452
if ( fWriteSkipPtr == TRUE )
2454
/*=======================================================================*/
2455
/* Fetch and modify the skip pointer. */
2457
ulAddress = ulPlayoutBaseAddress + ulSkipPtrBytesOfst;
2459
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
2464
if ( ulResult != cOCT6100_ERR_OK )
2467
mOCT6100_CREATE_FEATURE_MASK( ulSkipPtrFieldSize, ulSkipPtrBitOfst, &ulMask );
2469
ulTempData &= ( ~ulMask );
2470
ulTempData |= *pulSkipPtr << ulSkipPtrBitOfst;
2472
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
2476
if ( ulResult != cOCT6100_ERR_OK )
2479
/*=======================================================================*/
2483
/*=======================================================================*/
2484
/* Fetch and modify the write pointer. */
2486
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
2488
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
2493
if ( ulResult != cOCT6100_ERR_OK )
2496
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
2498
ulTempData &= ( ~ulMask );
2499
ulTempData |= ulWritePtr << ulWritePtrBitOfst;
2501
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
2505
if ( ulResult != cOCT6100_ERR_OK )
2508
/*=======================================================================*/
2511
/*=======================================================================*/
2512
/* Now update the state of the channel stating that the buffer playout is activated. */
2514
/* Select the buffer of interest.*/
2515
if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
2517
/* Check if the global ports active stat must be incremented. */
2518
if ( pEchoChannel->fRinBufPlaying == FALSE )
2520
/* Increment the number of active buffer playout ports. */
2521
pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts++;
2524
pEchoChannel->fRinBufPlaying = TRUE;
2525
/* Keep the new notify on event flag. */
2526
pEchoChannel->fRinBufPlayoutNotifyOnStop = (UINT8)( f_fNotifyOnPlayoutStop & 0xFF );
2527
/* Keep the specified user event id. */
2528
pEchoChannel->ulRinUserBufPlayoutEventId = f_ulUserEventId;
2529
/* Keep type of event to be generated. */
2530
pEchoChannel->byRinPlayoutStopEventType = (UINT8)( f_ulPlayoutStopEventType & 0xFF );
2531
/* No hard stop for now. */
2532
pEchoChannel->fRinHardStop = FALSE;
2533
/* No buffer added in the rin list for now. */
2534
pEchoChannel->fRinBufAdded = FALSE;
2535
/* Buffer playout is active on this channel. */
2536
pEchoChannel->fBufPlayoutActive = TRUE;
2538
else /* f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
2540
/* Check if the global ports active stat must be incremented. */
2541
if ( pEchoChannel->fSoutBufPlaying == FALSE )
2543
/* Increment the number of active buffer playout ports. */
2544
pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts++;
2547
pEchoChannel->fSoutBufPlaying = TRUE;
2548
/* Keep the new notify on event flag. */
2549
pEchoChannel->fSoutBufPlayoutNotifyOnStop = (UINT8)( f_fNotifyOnPlayoutStop & 0xFF );
2550
/* Keep the specified user event id. */
2551
pEchoChannel->ulSoutUserBufPlayoutEventId = f_ulUserEventId;
2552
/* Keep type of event to be generated. */
2553
pEchoChannel->bySoutPlayoutStopEventType = (UINT8)( f_ulPlayoutStopEventType & 0xFF );
2554
/* No hard stop for now. */
2555
pEchoChannel->fSoutHardStop = FALSE;
2556
/* No buffer added in the sout list for now. */
2557
pEchoChannel->fSoutBufAdded = FALSE;
2558
/* Buffer playout is active on this channel. */
2559
pEchoChannel->fBufPlayoutActive = TRUE;
2562
return cOCT6100_ERR_OK;
2567
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2569
Function: Oct6100BufferPlayoutStopSer
2571
Description: Stops buffer playout on a channel.
2573
-------------------------------------------------------------------------------
2574
| Argument | Description
2575
-------------------------------------------------------------------------------
2576
f_pApiInstance Pointer to API instance. This memory is used to keep the
2577
present state of the chip and all its resources.
2579
f_pBufferPlayoutStop Pointer to buffer playout stop structure.
2581
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2582
#if !SKIP_Oct6100BufferPlayoutStopSer
2583
UINT32 Oct6100BufferPlayoutStopSer(
2584
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
2585
IN OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop )
2587
UINT32 ulChannelIndex;
2588
UINT16 usEchoMemIndex;
2591
/* Check the user's configuration of the buffer for errors. */
2592
ulResult = Oct6100ApiAssertPlayoutStopParams(
2594
f_pBufferPlayoutStop,
2597
if ( ulResult != cOCT6100_ERR_OK )
2600
/* Write to all resources needed to deactivate buffer playout. */
2601
ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
2603
f_pBufferPlayoutStop,
2608
if ( ulResult != cOCT6100_ERR_OK )
2611
return cOCT6100_ERR_OK;
2616
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2618
Function: Oct6100ApiAssertPlayoutStopParams
2620
Description: Check the validity of the channel and buffer requested.
2622
-------------------------------------------------------------------------------
2623
| Argument | Description
2624
-------------------------------------------------------------------------------
2625
f_pApiInstance Pointer to API instance. This memory is used to keep the
2626
present state of the chip and all its resources.
2628
f_pBufferPlayoutStop Pointer to buffer playout stop structure.
2629
f_pulChannelIndex Pointer to the channel index on which playout is to be stopped.
2630
f_pusEchoMemIndex Pointer to the echo mem index on which playout is to be stopped.
2632
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2633
#if !SKIP_Oct6100ApiAssertPlayoutStopParams
2634
UINT32 Oct6100ApiAssertPlayoutStopParams(
2635
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
2636
IN tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop,
2637
OUT PUINT32 f_pulChannelIndex,
2638
OUT PUINT16 f_pusEchoMemIndex )
2640
tPOCT6100_API_CHANNEL pEchoChannel;
2641
UINT32 ulEntryOpenCnt;
2643
/* Check for errors. */
2644
if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
2645
return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
2647
if ( f_pBufferPlayoutStop->ulChannelHndl == cOCT6100_INVALID_HANDLE )
2648
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2650
if ( f_pBufferPlayoutStop->ulPlayoutPort != cOCT6100_CHANNEL_PORT_ROUT &&
2651
f_pBufferPlayoutStop->ulPlayoutPort != cOCT6100_CHANNEL_PORT_SOUT )
2652
return cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT;
2654
if ( f_pBufferPlayoutStop->fStopCleanly != TRUE && f_pBufferPlayoutStop->fStopCleanly != FALSE )
2655
return cOCT6100_ERR_BUFFER_PLAYOUT_STOP_CLEANLY;
2657
/*=====================================================================*/
2658
/* Check the channel handle. */
2660
if ( (f_pBufferPlayoutStop->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
2661
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2663
*f_pulChannelIndex = f_pBufferPlayoutStop->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK;
2664
if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
2665
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2667
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
2669
/* Extract the entry open count from the provided handle. */
2670
ulEntryOpenCnt = (f_pBufferPlayoutStop->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
2672
/* Check for errors. */
2673
if ( pEchoChannel->fReserved != TRUE )
2674
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_NOT_OPEN;
2675
if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt )
2676
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
2678
/* Return echo memory index. */
2679
*f_pusEchoMemIndex = pEchoChannel->usEchoMemIndex;
2681
/* Check if buffer playout is active for the selected port. */
2682
if ( ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
2683
&& ( pEchoChannel->fRinBufPlaying == FALSE )
2684
&& ( pEchoChannel->fRinBufAdded == FALSE ) )
2685
return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_STARTED;
2687
if ( ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT )
2688
&& ( pEchoChannel->fSoutBufPlaying == FALSE )
2689
&& ( pEchoChannel->fSoutBufAdded == FALSE ) )
2690
return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_STARTED;
2692
/*=====================================================================*/
2694
return cOCT6100_ERR_OK;
2699
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2701
Function: Oct6100ApiInvalidateChanPlayoutStructs
2703
Description: Write the buffer playout event in the channel main structure.
2705
-------------------------------------------------------------------------------
2706
| Argument | Description
2707
-------------------------------------------------------------------------------
2708
f_pApiInstance Pointer to API instance. This memory is used to keep the
2709
present state of the chip and all its resources.
2711
f_pBufferPlayoutStop Pointer to buffer playout stop structure.
2712
f_ulChannelIndex Index of the channel within the API's channel list.
2713
f_usEchoMemIndex Index of the echo channel in hardware memory.
2715
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2716
#if !SKIP_Oct6100ApiInvalidateChanPlayoutStructs
2717
UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
2718
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
2719
IN tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop,
2720
IN UINT32 f_ulChannelIndex,
2721
IN UINT16 f_usEchoMemIndex
2725
tPOCT6100_API_CHANNEL pEchoChannel;
2726
tPOCT6100_SHARED_INFO pSharedInfo;
2727
tOCT6100_READ_PARAMS ReadParams;
2728
tOCT6100_WRITE_PARAMS WriteParams;
2732
UINT32 ulWritePtrBytesOfst;
2733
UINT32 ulWritePtrBitOfst;
2734
UINT32 ulWritePtrFieldSize;
2735
UINT32 ulSkipPtrBytesOfst;
2736
UINT32 ulSkipPtrBitOfst;
2737
UINT32 ulSkipPtrFieldSize;
2738
UINT32 ulIgnoreBytesOfst;
2739
UINT32 ulIgnoreBitOfst;
2740
UINT32 ulIgnoreFieldSize;
2741
UINT32 ulHardSkipBytesOfst;
2742
UINT32 ulHardSkipBitOfst;
2743
UINT32 ulHardSkipFieldSize;
2744
UINT32 ulReadPtrBytesOfst;
2745
UINT32 ulReadPtrBitOfst;
2746
UINT32 ulReadPtrFieldSize;
2750
UINT32 ulReadPtr = 0;
2751
UINT32 ulCurrentPtr;
2753
UINT32 ulPlayoutBaseAddress;
2760
BOOL fCheckStop = FALSE;
2762
UINT32 ulEventBuffer;
2764
/* Obtain local pointer to shared portion of instance. */
2765
pSharedInfo = f_pApiInstance->pSharedInfo;
2767
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2769
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
2771
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
2773
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2774
ReadParams.pusReadData = &usReadData;
2776
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
2778
/* Select the port of interest. */
2779
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
2781
ulWritePtr = pEchoChannel->ulRinBufWritePtr;
2782
ulSkipPtr = ulWritePtr;
2784
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
2785
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
2786
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
2788
ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.usDwordOffset * 4;
2789
ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byBitOffset;
2790
ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byFieldSize;
2792
ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.usDwordOffset * 4;
2793
ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byBitOffset;
2794
ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byFieldSize;
2796
ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.usDwordOffset * 4;
2797
ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byBitOffset;
2798
ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byFieldSize;
2800
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
2801
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
2802
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
2804
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
2806
ulWritePtr = pEchoChannel->ulSoutBufWritePtr;
2807
ulSkipPtr = ulWritePtr;
2809
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
2810
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
2811
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
2813
ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.usDwordOffset * 4;
2814
ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byBitOffset;
2815
ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byFieldSize;
2817
ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.usDwordOffset * 4;
2818
ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byBitOffset;
2819
ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byFieldSize;
2821
ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.usDwordOffset * 4;
2822
ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byBitOffset;
2823
ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byFieldSize;
2825
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
2826
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
2827
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
2830
/* Set the playout feature base address. */
2831
ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
2833
/* Check if something is currently playing. */
2834
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
2836
if ( pEchoChannel->fRinBufPlaying == TRUE )
2838
/* Check if we are stopping it or if it stopped by itself. */
2844
if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
2845
*f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
2848
else /* if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
2850
if ( pEchoChannel->fSoutBufPlaying == TRUE )
2852
/* Check if we are stopping it or if it stopped by itself. */
2858
if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
2859
*f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
2863
if ( ( fCheckStop == TRUE ) || ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) )
2865
/* Read the read pointer. */
2866
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
2868
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2869
ReadParams.pusReadData = &usReadData;
2870
ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
2872
/* Optimize this access by only reading the word we are interested in. */
2873
if ( ulReadPtrBitOfst < 16 )
2874
ReadParams.ulReadAddress += 2;
2876
/* Must read in memory directly since this value is changed by hardware */
2877
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
2878
if ( ulResult != cOCT6100_ERR_OK )
2881
/* Move data at correct position according to what was read. */
2882
if ( ulReadPtrBitOfst < 16 )
2883
ulTempData = usReadData;
2885
ulTempData = usReadData << 16;
2887
mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
2889
/* Store the read pointer. */
2890
ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
2892
/* Playout has finished when the read pointer reaches the write pointer. */
2893
if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
2895
if ( ulReadPtr != ulWritePtr )
2896
*f_pBufferPlayoutStop->pfAlreadyStopped = FALSE;
2897
else /* if ( ulReadPtr == ulWritePtr ) */
2898
*f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
2902
/* If the skip bits are located in the event itself, the playout is stopped by setting the */
2903
/* skip pointer to the hardware chip write pointer. Read it directly from the NLP configuration. */
2904
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
2906
if ( ulReadPtr != ulWritePtr )
2908
/* Get the write pointer in the chip. */
2909
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
2911
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance, pEchoChannel, ulAddress, &ulReadData);
2912
if ( ulResult != cOCT6100_ERR_OK )
2915
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
2917
/* Store the write pointer. */
2918
ulWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst;
2919
ulSkipPtr = ulWritePtr;
2923
/* Check if must clear repeat bit. */
2924
if ( ( ( pEchoChannel->fRinBufPlayoutRepeatUsed == TRUE ) && ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) )
2925
|| ( ( pEchoChannel->fSoutBufPlayoutRepeatUsed == TRUE ) && ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) ) )
2927
if ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
2928
|| ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
2929
&& ( ulWritePtr != ulReadPtr ) ) )
2931
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
2933
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
2935
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
2937
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
2940
/* Set the playout event base address. */
2941
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
2942
&& ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
2944
/* 127 or 31 events image. */
2945
ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ( ( ulWritePtr - 1 ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 )));
2949
/* Old 31 events image. */
2950
ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ( ( ulWritePtr - 1 ) & 0x1F));
2953
/* EVENT BASE + 4 */
2954
/* Playout configuration. */
2957
ReadParams.ulReadAddress = ulAddress;
2958
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
2959
if ( ulResult != cOCT6100_ERR_OK )
2962
/* Read-clear-write the new repeat bit. */
2963
usReadData &= 0x7FFF;
2965
WriteParams.ulWriteAddress = ulAddress;
2966
WriteParams.usWriteData = usReadData;
2967
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2968
if ( ulResult != cOCT6100_ERR_OK )
2973
/* Write the skip to the value of the write pointer to stop buffer playout. */
2975
/*=======================================================================*/
2976
/* First set the ignore skip clean bit if required. */
2978
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == FALSE )
2979
|| ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == FALSE ) )
2981
ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
2983
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
2987
if ( ulResult != cOCT6100_ERR_OK )
2990
mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask );
2992
ulTempData &= ( ~ulMask );
2994
/* Check if the skip need to be clean or not. */
2995
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
2996
ulTempData |= 0x1 << ulIgnoreBitOfst;
2998
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
3002
if ( ulResult != cOCT6100_ERR_OK )
3006
/*=======================================================================*/
3009
/*=======================================================================*/
3010
/* Fetch and modify the write pointer. */
3012
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
3014
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance, pEchoChannel, ulAddress, &ulTempData);
3015
if ( ulResult != cOCT6100_ERR_OK )
3018
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
3020
ulTempData &= ( ~ulMask );
3021
ulTempData |= ulWritePtr << ulWritePtrBitOfst;
3023
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
3027
if ( ulResult != cOCT6100_ERR_OK )
3030
/*=======================================================================*/
3033
/*=======================================================================*/
3034
/* Fetch and modify the skip pointer. */
3036
ulAddress = ulPlayoutBaseAddress + ulSkipPtrBytesOfst;
3038
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
3042
if ( ulResult != cOCT6100_ERR_OK )
3045
mOCT6100_CREATE_FEATURE_MASK( ulSkipPtrFieldSize, ulSkipPtrBitOfst, &ulMask );
3047
ulTempData &= ( ~ulMask );
3048
ulTempData |= ulSkipPtr << ulSkipPtrBitOfst;
3050
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
3054
if ( ulResult != cOCT6100_ERR_OK )
3057
/*=======================================================================*/
3060
/*=======================================================================*/
3061
/* If in the new buffer playout case, things are in a different order. */
3063
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
3065
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
3066
&& ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
3068
ulAddress = ulPlayoutBaseAddress + ulHardSkipBytesOfst;
3070
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
3074
if ( ulResult != cOCT6100_ERR_OK )
3077
mOCT6100_CREATE_FEATURE_MASK( ulHardSkipFieldSize, ulHardSkipBitOfst, &ulMask );
3079
ulTempData &= ( ~ulMask );
3081
/* Check if the skip need to be clean or not. */
3082
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
3083
ulTempData |= 0x1 << ulHardSkipBitOfst;
3085
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
3089
if ( ulResult != cOCT6100_ERR_OK )
3092
/* Now is the appropriate time to skip! */
3093
ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
3095
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
3099
if ( ulResult != cOCT6100_ERR_OK )
3102
mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask );
3104
ulTempData &= ( ~ulMask );
3106
/* Set the skip bit. */
3107
ulTempData |= 0x1 << ulIgnoreBitOfst;
3109
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
3113
if ( ulResult != cOCT6100_ERR_OK )
3118
/*=======================================================================*/
3121
/*=======================================================================*/
3122
/* The API must set the skip bit in all the events that are queued. */
3124
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
3126
if ( fCheckStop == TRUE )
3128
if ( ulReadPtr != ulWritePtr )
3130
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
3132
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
3134
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
3136
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
3139
for ( ulCurrentPtr = ulReadPtr; ulCurrentPtr != ulWritePtr; )
3141
/* Set the playout event base address. */
3143
/* 127 or 31 events image. */
3144
ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + ( cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ulCurrentPtr );
3146
ulCurrentPtr &= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 );
3148
/* EVENT BASE + 0 playout configuration. */
3149
WriteParams.ulWriteAddress = ulAddress;
3151
/* Set skip bit + hard-skip bit. */
3152
WriteParams.usWriteData = 0x8000;
3153
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
3154
WriteParams.usWriteData |= 0x4000;
3155
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3156
if ( ulResult != cOCT6100_ERR_OK )
3163
/*=======================================================================*/
3164
/* If stop immediatly, wait the stop before leaving the function. */
3166
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
3168
/* Remember that an "hard stop" was used for the next start. */
3169
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
3170
pEchoChannel->fRinHardStop = TRUE;
3171
else /* if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
3172
pEchoChannel->fSoutHardStop = TRUE;
3175
/*=======================================================================*/
3176
/* Update the channel entry to set the playing flag to FALSE. */
3178
/* Select the port of interest. */
3179
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
3181
/* Check if the global ports active stat must be decremented. */
3182
if ( pEchoChannel->fRinBufPlaying == TRUE )
3184
/* Decrement the number of active buffer playout ports. */
3185
pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
3188
pEchoChannel->fRinBufPlaying = FALSE;
3190
/* Return user information. */
3191
if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL )
3192
*f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fRinBufPlayoutNotifyOnStop;
3194
/* Make sure no new event is recorded for this channel/port. */
3195
pEchoChannel->fRinBufPlayoutNotifyOnStop = FALSE;
3196
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
3198
pEchoChannel->ulRinBufSkipPtr = ulSkipPtr;
3199
pEchoChannel->ulRinBufWritePtr = ulWritePtr;
3201
else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */
3202
pEchoChannel->ulRinBufSkipPtr = pEchoChannel->ulRinBufWritePtr;
3204
/* The repeat flag can now be used. */
3205
pEchoChannel->fRinBufPlayoutRepeatUsed = FALSE;
3207
/* For sure, all buffers have now been cleared on the Rin port. */
3208
pEchoChannel->fRinBufAdded = FALSE;
3210
/* Clear optimization flag if possible. */
3211
if ( ( pEchoChannel->fSoutBufPlaying == FALSE )
3212
&& ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == FALSE ) )
3214
/* Buffer playout is no more active on this channel. */
3215
pEchoChannel->fBufPlayoutActive = FALSE;
3218
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
3220
/* Check if the global ports active stat must be decremented. */
3221
if ( pEchoChannel->fSoutBufPlaying == TRUE )
3223
/* Decrement the number of active buffer playout ports. */
3224
pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
3227
pEchoChannel->fSoutBufPlaying = FALSE;
3229
/* Return user information. */
3230
if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL )
3231
*f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fSoutBufPlayoutNotifyOnStop;
3233
/* Make sure no new event is recorded for this channel/port. */
3234
pEchoChannel->fSoutBufPlayoutNotifyOnStop = FALSE;
3235
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
3237
pEchoChannel->ulSoutBufSkipPtr = ulSkipPtr;
3238
pEchoChannel->ulSoutBufWritePtr = ulWritePtr;
3240
else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */
3241
pEchoChannel->ulSoutBufSkipPtr = pEchoChannel->ulSoutBufWritePtr;
3243
/* The repeat flag can now be used. */
3244
pEchoChannel->fSoutBufPlayoutRepeatUsed = FALSE;
3246
/* For sure, all buffers have now been cleared on the Sout port. */
3247
pEchoChannel->fSoutBufAdded = FALSE;
3249
/* Clear optimization flag if possible. */
3250
if ( ( pEchoChannel->fRinBufPlaying == FALSE )
3251
&& ( pEchoChannel->fRinBufPlayoutNotifyOnStop == FALSE ) )
3253
/* Buffer playout is no more active on this channel. */
3254
pEchoChannel->fBufPlayoutActive = FALSE;
3258
/*=======================================================================*/
3262
return cOCT6100_ERR_OK;
3267
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3269
Function: Oct6100ApiReserveBufPlayoutListEntry
3271
Description: Reserves a free entry in the Buffer playout list.
3273
-------------------------------------------------------------------------------
3274
| Argument | Description
3275
-------------------------------------------------------------------------------
3276
f_pApiInstance Pointer to API instance. This memory is used to keep the
3277
present state of the chip and all its resources.
3279
f_pulBufferIndex List entry reserved.
3281
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3282
#if !SKIP_Oct6100ApiReserveBufPlayoutListEntry
3283
UINT32 Oct6100ApiReserveBufPlayoutListEntry(
3284
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
3285
OUT PUINT32 f_pulBufferIndex )
3287
PVOID pBufPlayoutAlloc;
3290
mOCT6100_GET_BUFFER_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBufPlayoutAlloc )
3292
ulResult = OctapiLlmAllocAlloc( pBufPlayoutAlloc, f_pulBufferIndex );
3293
if ( ulResult != cOCT6100_ERR_OK )
3295
if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
3296
return cOCT6100_ERR_BUFFER_PLAYOUT_ALL_BUFFERS_OPEN;
3298
return cOCT6100_ERR_FATAL_40;
3301
return cOCT6100_ERR_OK;
3306
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3308
Function: Oct6100ApiReleaseBufPlayoutListEntry
3310
Description: Release an entry from the Buffer playout list.
3312
-------------------------------------------------------------------------------
3313
| Argument | Description
3314
-------------------------------------------------------------------------------
3315
f_pApiInstance Pointer to API instance. This memory is used to keep the
3316
present state of the chip and all its resources.
3318
f_ulBufferIndex List entry to be freed.
3320
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3321
#if !SKIP_Oct6100ApiReleaseBufPlayoutListEntry
3322
UINT32 Oct6100ApiReleaseBufPlayoutListEntry(
3323
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
3324
IN UINT32 f_ulBufferIndex )
3326
PVOID pBufPlayoutAlloc;
3329
mOCT6100_GET_BUFFER_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBufPlayoutAlloc )
3331
ulResult = OctapiLlmAllocDealloc( pBufPlayoutAlloc, f_ulBufferIndex );
3332
if ( ulResult != cOCT6100_ERR_OK )
3333
return cOCT6100_ERR_FATAL_41;
3335
return cOCT6100_ERR_OK;