diff options
author | russell <russell@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-07-07 18:03:59 +0000 |
---|---|---|
committer | russell <russell@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-07-07 18:03:59 +0000 |
commit | 4e4b79bf56f6477b65973c869e5a8936aea27864 (patch) | |
tree | 67c314bba567ff7de6df9e7e0324275524a0c3a7 | |
parent | 72f0ecd534701b0a490f48189ce57ce78c58282e (diff) |
merge vpm450m support
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@1206 5390a7c7-147a-4af0-8ec9-7488f05a26cb
75 files changed, 41529 insertions, 48 deletions
@@ -5,9 +5,11 @@ # # -PWD:=$(shell pwd) HOSTCC=gcc +ifeq ($(PWD),) +PWD:=$(shell pwd) +endif # If you want to build for a kernel other than the current kernel, set KVERS ifndef KVERS KVERS:=$(shell uname -r) @@ -22,7 +24,7 @@ ifndef KSRC endif KINCLUDES:=$(KSRC)/include -CFLAGS+=-I. -O4 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER +CFLAGS+=-I. -Iinclude -O4 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER CFLAGS_PPC:=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi) CFLAGS_X86-64:=$(shell if uname -m | grep -q x86_64; then echo "-m64"; fi) CFLAGS+=$(CFLAGS_PPC) $(CFLAGS_X86-64) @@ -45,7 +47,6 @@ KFLAGS+=-DSTANDALONE_ZAPATA CFLAGS+=-DSTANDALONE_ZAPATA KMAKE:= $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) KMAKE_INST:= $(KMAKE) INSTALL_MOD_PATH=$(INSTALL_PREFIX) INSTALL_MOD_DIR=misc modules_install -EXTRA_CFLAGS:=-I$(src) ROOT_PREFIX= INSTALL_PREFIX:=$(DESTDIR) @@ -110,7 +111,9 @@ MODULESKO:=$(MODULES:%=%.ko) MOD_DESTDIR:=zaptel +EXTRA_CFLAGS:=-I$(PWD)/include -I$(PWD)/include/oct6100api obj-m:=$(MODULESO) +wct4xxp-objs:=wct4xxp_base.o vpm450m.o # Also build xpp in the subdirectory xpp/ . But only for >=2.6.10 and only # for i386. On other archs the module will probably build but panic. @@ -128,9 +131,9 @@ BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune all: $(BUILDVER) $(LIBTONEZONE_SO) -linux24: prereq $(MODULESO) $(BINS) +linux24: prereq vpm450m_fw.h $(MODULESO) $(BINS) -linux26: prereq $(BINS) +linux26: prereq vpm450m_fw.h $(BINS) @echo $(KSRC) @if [ -z "$(KSRC)" -o ! -d "$(KSRC)" ]; then echo "You do not appear to have the sources for the $(KVERS) kernel installed."; exit 1 ; fi $(KMAKE) modules @@ -170,8 +173,14 @@ pciradio.o: radfw.h ztdummy.o: ztdummy.h -$(MODULESO): %.o: %.c zaptel.h - $(HOSTCC) $(KFLAGS) -o $@ -c $< +$(filter-out wct4xxp.o,$(MODULESO)) wct4xxp_base.o: %.o: %.c zaptel.h + $(CC) $(KFLAGS) -o $@ -c $< + +vpm450m.o: vpm450m.c zaptel.h + $(CC) $(KFLAGS) -I$(PWD)/include -I$(PWD)/include/oct6100api -o $@ -c $< + +wct4xxp.o: wct4xxp_base.o vpm450m.o + $(LD) -r -o $@ wct4xxp_base.o vpm450m.o tor2ee.o: tor2-hw.h @@ -199,6 +208,11 @@ radfw.h: makefw pciradio.rbt gendigits: gendigits.o $(CC) -o $@ $^ -lm +fw2h: CFLAGS= + +vpm450m_fw.h: OCT6114-128D.ima fw2h + ./fw2h $< $@ + zaptel.c: tones.h prereq: tones.h tor2fw.h radfw.h version.h @@ -372,15 +386,6 @@ update: grep ^C update.out | cut -b4- ; \ fi ; \ rm -f update.out; \ - elif [ -d CVS ]; then \ - echo "Updating from CVS..." ; \ - cvs -q -z3 update -Pd | tee update.out; \ - rm -f .version; \ - if [ `grep -c ^C update.out` -gt 0 ]; then \ - echo ; echo "The following files have conflicts:" ; \ - grep ^C update.out | cut -d' ' -f2- ; \ - fi ; \ - rm -f update.out; \ else \ echo "Not under version control"; \ fi @@ -400,5 +405,6 @@ endif rm -f fxotune rm -f core rm -f ztcfg-shared fxstest + rm -f fw2h vpm450m_fw.h FORCE: diff --git a/OCT6114-128D.ima b/OCT6114-128D.ima Binary files differnew file mode 100644 index 0000000..2644bc5 --- /dev/null +++ b/OCT6114-128D.ima @@ -0,0 +1,47 @@ +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +int main(int argc, char *argv[]) +{ + char *c; + int fd; + FILE *f; + int res; + int x; + unsigned char buf[1024]; + if (argc != 3) { + fprintf(stderr, "Usage: fw2h <infile> <outfile>"); + exit(1); + } + fd = open(argv[1], O_RDONLY); + if (fd < 0) { + fprintf(stderr, "Unable to open '%s': %s\n", argv[1], strerror(errno)); + exit(1); + } + f = fopen(argv[2], "w+"); + if (!f) { + fprintf(stderr, "Unable to open '%s' for writing: %s\n", argv[2], strerror(errno)); + exit(1); + } + c = strrchr(argv[2], '.'); + if (c) *c = '\0'; + fprintf(f, "static unsigned char %s[] = {\t", argv[2]); + while ((res = read(fd, buf, sizeof(buf))) > 0) { + for (x = 0; x < res; x++) { + if (!(x % 16)) + fprintf(f, "\n\t"); + fprintf(f, "0x%02x, ", buf[x]); + } + } + fprintf(f, "\n};\n"); + if (res < 0) { + fprintf(stderr, "Error reading file: %s\n", strerror(errno)); + exit(1); + } + fclose(f); + close(fd); + exit(0); +} diff --git a/include/apilib/octapi_bt0.h b/include/apilib/octapi_bt0.h new file mode 100644 index 0000000..a7dd534 --- /dev/null +++ b/include/apilib/octapi_bt0.h @@ -0,0 +1,70 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_bt0.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 10 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#ifndef __OCTAPI_BT0_H__ +#define __OCTAPI_BT0_H__ + + +#include "octdef.h" + + +#define OCTAPI_BT0_BASE 0xFFFF0000 +#define OCTAPI_BT0_KEY_SIZE_NOT_MUTLIPLE_OF_UINT32 OCTAPI_BT0_BASE+0x0001 +#define OCTAPI_BT0_DATA_SIZE_NOT_MUTLIPLE_OF_UINT32 OCTAPI_BT0_BASE+0x0002 +#define OCTAPI_BT0_MALLOC_FAILED OCTAPI_BT0_BASE+0x0003 +#define OCTAPI_BT0_NO_NODES_AVAILABLE OCTAPI_BT0_BASE+0x0004 +#define OCTAPI_BT0_KEY_ALREADY_IN_TREE OCTAPI_BT0_BASE+0x0005 +#define OCTAPI_BT0_KEY_NOT_IN_TREE OCTAPI_BT0_BASE+0x0006 + +/* Possible result for Find Or Add function.*/ +#define OCTAPI0_BT0_NODE_FOUND 0 +#define OCTAPI0_BT0_NODE_ADDDED 1 + +#define OCTAPI_BT0_NO_SMALLER_KEY 0xAAAAAAAA + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus*/ + +#define octapi_bt0_get_size( number_of_items, key_size, data_size, b_size ) OctApiBt0GetSize( (UINT32) number_of_items,(UINT32) key_size, (UINT32) data_size, (PUINT32) b_size ) +#define octapi_bt0_init(b, number_of_items, key_size, data_size) OctApiBt0Init( (void **) b,(UINT32) number_of_items,(UINT32) key_size, (UINT32) data_size ) +#define octapi_bt0_add_node( b, key, data ) OctApiBt0AddNode( (void *) b,(void *) key,(void **) data ) +#define octapi_bt0_remove_node( b, key ) OctApiBt0RemoveNode( (void *) b,(void *) key ) +#define octapi_bt0_query_node( b, key, data ) OctApiBt0QueryNode( (void *) b,(void *) key,(void **) data ) +#define octapi_bt0_get_first_node( b,key, data ) OctApiBt0GetFirstNode( (void *) b,(void **) key, (void **) data ) + + +static UINT32 OctApiBt0GetSize( UINT32 number_of_items,UINT32 key_size, UINT32 data_size, UINT32 * b_size ); +static UINT32 OctApiBt0Init( void ** b,UINT32 number_of_items,UINT32 key_size, UINT32 data_size ); +UINT32 OctApiBt0AddNode( void * b,void * key,void ** data ); +UINT32 OctApiBt0RemoveNode( void * b,void * key ); +UINT32 OctApiBt0QueryNode( void * b,void * key,void ** data ); +UINT32 OctApiBt0GetFirstNode( void * b,void ** key, void ** data ); +UINT32 OctApiBt0FindOrAddNode(void * b,void * key,void ** data, UINT32 *fnct_result); + +UINT32 OctApiBt0AddNodeReportPrevNodeData(void * b,void * key,void ** data, void ** prev_data, UINT32 *fnct_result ); + +#ifdef __cplusplus +} +#endif /* __cplusplus*/ + + + +#endif /*__OCTAPI_BT0_H__*/ diff --git a/include/apilib/octapi_largmath.h b/include/apilib/octapi_largmath.h new file mode 100644 index 0000000..dae120a --- /dev/null +++ b/include/apilib/octapi_largmath.h @@ -0,0 +1,62 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_largmath.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 5 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#ifndef __OCTAPI_LARGMATH_H__ +#define __OCTAPI_LARGMATH_H__ + + + +#include "octdef.h" + + + +#define OCTAPI_LM_DIVISION_BY_ZERO 0xFFFF +#define OCTAPI_LM_OVERFLOW 0xFFFE +#define OCTAPI_LM_ARRAY_SIZE_MISMATCH 0xFFFD + +#define OCTAPI_LM_MAX_OPTIMIZE_MUL 10 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus*/ + +#define octapi_lm_add( a, alen, b, blen, z, zlen) OctApiLmAdd( (PUINT32) a, (USHORT) alen, (PUINT32) b, (USHORT) blen, (PUINT32) z, (USHORT) zlen ) +#define octapi_lm_subtract( a, alen, bneg, blen, z, zlen, neg) OctApiLmSubtract( (PUINT32) a, (USHORT) alen, (PUINT32) bneg, (USHORT) blen, (PUINT32) z, (USHORT) zlen, (USHORT*) neg ) +#define octapi_lm_compare( a, alen, bneg, blen, neg) OctApiLmCompare( (PUINT32) a, (USHORT) alen, (PUINT32) bneg, (USHORT) blen, (USHORT*) neg ) +#define octapi_lm_multiply( a, b, ablen, z) OctApiLmMultiply( (PUINT32) a, (PUINT32) b, (USHORT) ablen, (PUINT32) z ) +#define octapi_lm_divide( n, d, q, r, ndqrlen) OctApiLmDivide( (PUINT32) n, (PUINT32) d, (PUINT32) q, (PUINT32) r, (USHORT) ndqrlen ) +#define octapi_lm_shiftright1( a, alen) OctApiLmShiftRight1( (PUINT32) a, (USHORT) alen ) +#define octapi_lm_shiftn( a, alen, shiftleft, shiftn) OctApiLmShiftn( (PUINT32) a, (USHORT) alen, (USHORT) shiftleft, (USHORT) shiftn ) +#define octapi_lm_getmsb( a, alen, msb_pos) OctApiLmGetMsb( (PUINT32) a, (USHORT) alen, (USHORT*) msb_pos ) + + +static UINT32 OctApiLmAdd( PUINT32 a, USHORT alen, PUINT32 b, USHORT blen, PUINT32 z, USHORT zlen ); +static UINT32 OctApiLmSubtract( PUINT32 a, USHORT alen, PUINT32 bneg, USHORT blen, PUINT32 z, USHORT zlen, PUSHORT neg ); +UINT32 OctApiLmCompare( PUINT32 a, USHORT alen, PUINT32 bneg, USHORT blen, PUSHORT neg ); +UINT32 OctApiLmMultiply( PUINT32 a, PUINT32 b, USHORT ablen, PUINT32 z ); +UINT32 OctApiLmDivide( PUINT32 n, PUINT32 d, PUINT32 q, PUINT32 r, USHORT ndqrlen ); +UINT32 OctApiLmShiftRight1( PUINT32 a, USHORT alen ); +UINT32 OctApiLmShiftn( PUINT32 a, USHORT alen, USHORT shiftleft, USHORT shiftn ); +UINT32 OctApiLmGetMsb( PUINT32 a, USHORT alen, PUSHORT msb_pos ); + +#ifdef __cplusplus +} +#endif /* __cplusplus*/ + +#endif /*__OCTAPI_LARGMATH_H__*/ diff --git a/include/apilib/octapi_llman.h b/include/apilib/octapi_llman.h new file mode 100644 index 0000000..467ed9c --- /dev/null +++ b/include/apilib/octapi_llman.h @@ -0,0 +1,127 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_llman.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 7 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#include "octdef.h" + +/* Error defines*/ +#define OCTAPI_LLM_MEMORY_NOT_ALLOCATED 0xFFFFFFFF +#define OCTAPI_LLM_NO_STRUCTURES_LEFT 0xFFFFFFFE +#define OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE 0xFFFFFFFD +#define OCTAPI_LLM_ELEMENT_ALREADY_ASSIGNED 0xFFFFFFFC +#define OCTAPI_LLM_ELEMENT_NOT_FOUND 0xFFFFFFFB +#define OCTAPI_LLM_LIST_EMPTY 0xFFFFFFFA +#define OCTAPI_LLM_INVALID_LIST_HANDLE 0xFFFFFFF9 +#define OCTAPI_LLM_TREE_NODE_ABSENT 0xFFFFFFF8 +#define OCTAPI_LLM_INTERNAL_ERROR0 0xFFFFFFF7 +#define OCTAPI_LLM_INTERNAL_ERROR1 0xFFFFFFF6 +#define OCTAPI_LLM_INVALID_PARAMETER 0xFFFFFFF5 + +#define OCTAPI_LLM2_MEMORY_NOT_ALLOCATED 0xFEFFFFFF +#define OCTAPI_LLM2_NO_STRUCTURES_LEFT 0xFEFFFFFE +#define OCTAPI_LLM2_BLOCKNUM_OUT_OF_RANGE 0xFEFFFFFD +#define OCTAPI_LLM2_ELEMENT_ALREADY_ASSIGNED 0xFEFFFFFC +#define OCTAPI_LLM2_ELEMENT_NOT_FOUND 0xFEFFFFFB +#define OCTAPI_LLM2_LIST_EMPTY 0xFEFFFFFA +#define OCTAPI_LLM2_INVALID_LIST_HANDLE 0xFEFFFFF9 +#define OCTAPI_LLM2_TREE_NODE_ABSENT 0xFEFFFFF8 +#define OCTAPI_LLM2_INTERNAL_ERROR0 0xFEFFFFF7 +#define OCTAPI_LLM2_INTERNAL_ERROR1 0xFEFFFFF6 +#define OCTAPI_LLM2_INVALID_PARAMETER 0xFEFFFFF5 + +/* Other defines*/ +#define OCTAPI_LLM_LIST_APPEND 0xFFFFFFFF +#define OCTAPI_LLM2_INSERT_ERROR 0xFFFFFFFF +#define OCTAPI_LLM2_INSERT_FIRST_NODE 0xFFFF0000 +#define OCTAPI_LLM2_INSERT_LIST_NODE 0xFFFF0001 +#define OCTAPI_LLM2_INSERT_LAST_NODE 0xFFFF0002 +#define OCTAPI_LLM2_INSERT_BEFORE_LAST_NODE 0xFFFF0003 +#define OCTAPI_LLM2_REMOVE_ERROR 0xFFFFFFFF +#define OCTAPI_LLM2_REMOVE_FIRST_NODE 0xFFFF0004 +#define OCTAPI_LLM2_REMOVE_LIST_NODE 0xFFFF0005 +#define OCTAPI_LLM2_REMOVE_LAST_NODE 0xFFFF0006 +#define OCTAPI_LLM2_REMOVE_BEFORE_LAST_NODE 0xFFFF0007 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus*/ + +#define octapi_llm_alloc_get_size( number_of_items, l_size) OctapiLlmAllocGetSize( (UINT32) number_of_items,(PUINT32) l_size ) +#define octapi_llm_alloc_init( l, number_of_items) OctapiLlmAllocInit( (PVOID*) l,(UINT32) number_of_items) +#define octapi_llm_alloc_info( l, allocated_items, available_items) OctapiLlmAllocInfo( (PVOID) l, (PUINT32) allocated_items, (PUINT32) available_items ) +#define octapi_llm_alloc_alloc( l, blocknum) OctapiLlmAllocAlloc( (PVOID) l, (PUINT32) blocknum ) +#define octapi_llm_alloc_dealloc( l, blocknum) OctapiLlmAllocDealloc( (PVOID) l,(UINT32) blocknum ) +#define octapi_llm_list_get_size( number_of_items, number_of_lists, user_info_size, l_size) OctApiLlmListGetSize( (UINT32) number_of_items,(UINT32) number_of_lists,(UINT32) user_info_size,(PUINT32) l_size ) +#define octapi_llm_list_init( l, number_of_items, number_of_lists, user_info_size) OctApiLlmListInit( (PVOID*) l,(UINT32) number_of_items,(UINT32) number_of_lists,(UINT32) user_info_size ) +#define octapi_llm_list_info( l, allocated_lists, allocated_items, free_lists, free_items ) OctApiLlmListInfo( (PVOID) l,(PUINT32) allocated_lists,(PUINT32) allocated_items,(PUINT32) free_lists,(PUINT32) free_items ) +#define octapi_llm_list_create( l, list_handle) OctApiLlmListCreate( (PVOID) l,(PUINT32) list_handle ) +#define octapi_llm_list_create_full( l, list_length, plist_handle) OctApiLlmListCreateFull( (PVOID) l, (UINT32) list_length, (PUINT32) plist_handle ) +#define octapi_llm_list_append_items( l, list_handle, num_items) OctApiLlmListAppendItems( (PVOID) l, (UINT32) list_handle, (UINT32) num_items ) +#define octapi_llm_list_append_and_set_items( l, list_handle, num_items, data_list) OctApiLlmListAppendAndSetItems( (PVOID) l, (UINT32) list_handle, (UINT32) num_items, (PVOID) data_list ) +#define octapi_llm_list_delete( l, list_handle ) OctApiLlmListDelete( (PVOID) l,(UINT32) list_handle ) +#define octapi_llm_list_length( l, list_handle, number_of_items_in_list) OctApiLlmListLength( (PVOID) l,(UINT32) list_handle, (PUINT32) number_of_items_in_list ) +#define octapi_llm_list_insert_item( l, list_handle, item_number, item_data_pnt) OctApiLlmListInsertItem( (PVOID) l,(UINT32) list_handle,(UINT32) item_number,(PVOID*) item_data_pnt ) +#define octapi_llm_list_remove_item( l, list_handle, item_number) OctApiLlmListRemoveItem( (PVOID) l,(UINT32) list_handle,(UINT32) item_number ) +#define octapi_llm_list_item_data( l, list_handle, item_number, item_data_pnt) OctApiLlmListItemData( (PVOID) l,(UINT32) list_handle,(UINT32) item_number,(PVOID*) item_data_pnt ) +#define octapi_llm_list_copy_data( l, list_handle, start_item, data_length, pdata_list) OctApiLlmListCopyData( (PVOID) l, (UINT32) list_handle, (UINT32) start_item, (UINT32) data_length, (PVOID) pdata_list ) +#define octapi_llm_list_set_items( l, list_handle, start_item, data_length, pdata_list) OctApiLlmListSetItems( (PVOID) l, (UINT32) list_handle, (UINT32) start_item, (UINT32) data_length, (PVOID) pdata_list ) + + +/* Alloc man.*/ +static UINT32 OctapiLlmAllocGetSize( UINT32 number_of_items,PUINT32 l_size ); +static UINT32 OctapiLlmAllocInit( PVOID* l,UINT32 number_of_items); +static UINT32 OctapiLlmAllocInfo( PVOID l, PUINT32 allocated_items, PUINT32 available_items ); +static UINT32 OctapiLlmAllocAlloc( PVOID l, PUINT32 blocknum ); +static UINT32 OctapiLlmAllocDealloc( PVOID l,UINT32 blocknum ); + +/* Time managed alloc man.*/ +UINT32 OctApiTllmAllocGetSize( UINT32 number_of_items, PUINT32 l_size ); +UINT32 OctApiTllmAllocInit( PVOID* l, UINT32 number_of_items ); +UINT32 OctApiTllmAllocInfo( PVOID l, PUINT32 allocated_items, PUINT32 available_items ); +UINT32 OctApiTllmAllocAlloc( PVOID l, PUINT32 blocknum, UINT32 current_time[2] ); +UINT32 OctApiTllmAllocDealloc( PVOID l, UINT32 blocknum, UINT32 timeout_value, UINT32 current_time[2] ); + +/* List man.*/ +UINT32 OctApiLlmListGetSize( UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size,PUINT32 l_size ); +UINT32 OctApiLlmListInit( PVOID* l,UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size ); +UINT32 OctApiLlmListInfo( PVOID l,PUINT32 allocated_lists,PUINT32 allocated_items,PUINT32 free_lists,PUINT32 free_items ); +UINT32 OctApiLlmListCreate( PVOID l,PUINT32 list_handle ); +UINT32 OctApiLlmListCreateFull( PVOID l, UINT32 list_length, UINT32* plist_handle ); +UINT32 OctApiLlmListAppendItems( PVOID l, UINT32 list_handle, UINT32 num_items ); +UINT32 OctApiLlmListAppendAndSetItems( PVOID l, UINT32 list_handle, UINT32 num_items, PVOID data_list ); +UINT32 OctApiLlmListDelete( PVOID l,UINT32 list_handle ); +UINT32 OctApiLlmListLength( PVOID l,UINT32 list_handle, PUINT32 number_of_items_in_list ); +UINT32 OctApiLlmListInsertItem( PVOID l,UINT32 list_handle,UINT32 item_number,PVOID* item_data_pnt ); +UINT32 OctApiLlmListRemoveItem( PVOID l,UINT32 list_handle,UINT32 item_number ); +UINT32 OctApiLlmListItemData( PVOID l,UINT32 list_handle,UINT32 item_number,PVOID* item_data_pnt ); +UINT32 OctApiLlmListCopyData( PVOID l, UINT32 list_handle, UINT32 start_item, UINT32 data_length, PVOID pdata_list ); +UINT32 OctApiLlmListSetItems( PVOID l, UINT32 list_handle, UINT32 start_item, UINT32 data_length, PVOID pdata_list ); + +/* Second list manager using a key to order info in the list.*/ +UINT32 OctApiLlm2ListGetSize( UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size,PUINT32 l_size ); +UINT32 OctApiLlm2ListInit( PVOID* l,UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size ); +UINT32 OctApiLlm2ListCreate( PVOID l,PUINT32 list_handle ); +UINT32 OctApiLlm2ListLength( PVOID l,UINT32 list_handle, PUINT32 number_of_items_in_list ); +UINT32 OctApiLlm2ListInsertItem(void * l,UINT32 list_handle,UINT32 item_key,void ** item_data_pnt, void ** prev_item_data_pnt, void ** prev_prev_item_data_pnt, PUINT32 insert_status_pnt ); +UINT32 OctApiLlm2ListRemoveItem(void * l,UINT32 list_handle,UINT32 item_key, PUINT32 prev_item_key_pnt, PUINT32 prev_prev_item_key_pnt, PUINT32 remove_status_pnt ); +UINT32 OctApiLlm2ListItemData( PVOID l,UINT32 list_handle,UINT32 item_key,PVOID* item_data_pnt, PUINT32 item_number ); + + +#ifdef __cplusplus +} +#endif /* __cplusplus*/ diff --git a/include/oct6100api/oct6100_adpcm_chan_inst.h b/include/oct6100api/oct6100_adpcm_chan_inst.h new file mode 100644 index 0000000..b74ce9e --- /dev/null +++ b/include/oct6100api/oct6100_adpcm_chan_inst.h @@ -0,0 +1,74 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_adpcm_chan_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_adpcm_chan.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_adpcm_chan_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 5 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_ADPCM_CHAN_INST_H__ +#define __OCT6100_ADPCM_CHAN_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_ADPCM_CHAN_ +{ + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Count used to manage entry handles allocated to user. */ + UINT8 byEntryOpenCnt; + + /* TSI chariot memory entry. */ + UINT16 usTsiMemIndex; + + /* ADPCM memory entry. */ + UINT16 usAdpcmMemIndex; + + /* Input and output timeslot information. */ + UINT16 usInputTimeslot; + UINT16 usInputStream; + UINT8 byInputNumTssts; + UINT8 byInputPcmLaw; + + UINT16 usOutputTimeslot; + UINT16 usOutputStream; + UINT8 byOutputNumTssts; + UINT8 byOutputPcmLaw; + + /* Internal info for quick access to structures associated to this TSI cnct. */ + UINT16 usInputTsstIndex; + UINT16 usOutputTsstIndex; + +} tOCT6100_API_ADPCM_CHAN, *tPOCT6100_API_ADPCM_CHAN; + +#endif /* __OCT6100_ADPCM_CHAN_INST_H__ */ diff --git a/include/oct6100api/oct6100_adpcm_chan_priv.h b/include/oct6100api/oct6100_adpcm_chan_priv.h new file mode 100644 index 0000000..4d2ce4e --- /dev/null +++ b/include/oct6100api/oct6100_adpcm_chan_priv.h @@ -0,0 +1,131 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_adpcm_chan_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_adpcm_chan.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_adpcm_chan_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 5 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_ADPCM_CHAN_PRIV_H__ +#define __OCT6100_ADPCM_CHAN_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/* ADPCM channel list pointer macros. */ +#define mOCT6100_GET_ADPCM_CHAN_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_ADPCM_CHAN )(( PVOID )pSharedInfo + pSharedInfo->ulAdpcmChanListOfst ); + +#define mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_ADPCM_CHAN )(( PVOID )pSharedInfo + pSharedInfo->ulAdpcmChanListOfst)) + ulIndex; + +#define mOCT6100_GET_ADPCM_CHAN_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulAdpcmChanAllocOfst); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetAdpcmChanSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiAdpcmChanSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + + +UINT32 Oct6100AdpcmChanOpenSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen ); + +UINT32 Oct6100ApiCheckAdpcmChanParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen ); + +UINT32 Oct6100ApiReserveAdpcmChanResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen, + OUT PUINT16 f_pusTsiChanIndex, + OUT PUINT16 f_pusAdpcmMemIndex, + OUT PUINT16 f_pusTsiMemIndex, + OUT PUINT16 f_pusInputTsstIndex, + OUT PUINT16 f_pusOutputTsstIndex ); + +UINT32 Oct6100ApiWriteAdpcmChanStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen, + IN UINT16 f_usAdpcmMemIndex, + IN UINT16 f_usTsiMemIndex, + IN UINT16 f_usInputTsstIndex, + IN UINT16 f_usOutputTsstIndex ); + +UINT32 Oct6100ApiUpdateAdpcmChanEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen, + IN UINT16 f_usTsiChanIndex, + IN UINT16 f_usAdpcmMemIndex, + IN UINT16 f_usTsiMemIndex, + IN UINT16 f_usInputTsstIndex, + IN UINT16 f_usOutputTsstIndex ); + +UINT32 Oct6100AdpcmChanCloseSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose ); + +UINT32 Oct6100ApiAssertAdpcmChanParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose, + OUT PUINT16 f_pusTsiChanIndex, + OUT PUINT16 f_pusAdpcmMemIndex, + OUT PUINT16 f_pusTsiMemIndex, + OUT PUINT16 f_pusInputTsstIndex, + OUT PUINT16 f_pusOutputTsstIndex ); + +UINT32 Oct6100ApiInvalidateAdpcmChanStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usAdpcmChanIndex, + IN UINT16 f_usInputTsstIndex, + IN UINT16 f_usOutputTsstIndex ); + +UINT32 Oct6100ApiReleaseAdpcmChanResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsiChanIndex, + IN UINT16 f_usAdpcmMemIndex, + IN UINT16 f_usTsiMemIndex ); + +UINT32 Oct6100ApiReserveAdpcmChanEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusAdpcmChanIndex ); + +UINT32 Oct6100ApiReleaseAdpcmChanEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usAdpcmChanIndex ); + +#endif /* __OCT6100_ADPCM_CHAN_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_adpcm_chan_pub.h b/include/oct6100api/oct6100_adpcm_chan_pub.h new file mode 100644 index 0000000..f0c32d9 --- /dev/null +++ b/include/oct6100api/oct6100_adpcm_chan_pub.h @@ -0,0 +1,90 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_adpcm_chan_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_adpcm_chan.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_adpcm_chan_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 4 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_ADPCM_CHAN_PUB_H__ +#define __OCT6100_ADPCM_CHAN_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_ADPCM_CHAN_OPEN_ +{ + PUINT32 pulChanHndl; + + UINT32 ulInputTimeslot; + UINT32 ulInputStream; + UINT32 ulInputNumTssts; + UINT32 ulInputPcmLaw; + + UINT32 ulOutputTimeslot; + UINT32 ulOutputStream; + UINT32 ulOutputNumTssts; + UINT32 ulOutputPcmLaw; + + UINT32 ulChanMode; /* Encoding or decoding. */ + + UINT32 ulEncodingRate; + UINT32 ulDecodingRate; + + UINT32 ulAdpcmNibblePosition; + +} tOCT6100_ADPCM_CHAN_OPEN, *tPOCT6100_ADPCM_CHAN_OPEN; + +typedef struct _OCT6100_ADPCM_CHAN_CLOSE_ +{ + UINT32 ulChanHndl; + +} tOCT6100_ADPCM_CHAN_CLOSE, *tPOCT6100_ADPCM_CHAN_CLOSE; + + +/************************** FUNCTION PROTOTYPES *****************************/ + + +UINT32 Oct6100AdpcmChanOpenDef( + OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen ); +UINT32 Oct6100AdpcmChanOpen( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen ); + +UINT32 Oct6100AdpcmChanCloseDef( + OUT tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose ); +UINT32 Oct6100AdpcmChanClose( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose ); + +#endif /* __OCT6100_ADPCM_CHAN_PUB_H__ */ diff --git a/include/oct6100api/oct6100_api.h b/include/oct6100api/oct6100_api.h new file mode 100644 index 0000000..5652375 --- /dev/null +++ b/include/oct6100api/oct6100_api.h @@ -0,0 +1,84 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_api.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + Header file containing all definitions used throughout the API. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 22 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_API_H__ +#define __OCT6100_API_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100_defines.h" +#include "oct6100_errors.h" + +#include "oct6100_apiud.h" +#include "oct6100_tlv_inst.h" +#include "oct6100_chip_stats_inst.h" +#include "oct6100_tsi_cnct_inst.h" +#include "oct6100_mixer_inst.h" +#include "oct6100_events_inst.h" +#include "oct6100_tone_detection_inst.h" +#include "oct6100_conf_bridge_inst.h" +#include "oct6100_playout_buf_inst.h" + +#include "oct6100_adpcm_chan_inst.h" +#include "oct6100_phasing_tsst_inst.h" +#include "oct6100_channel_inst.h" +#include "oct6100_interrupts_inst.h" +#include "oct6100_remote_debug_inst.h" +#include "oct6100_debug_inst.h" +#include "oct6100_chip_open_inst.h" +#include "oct6100_api_inst.h" + +#include "oct6100_interrupts_pub.h" +#include "oct6100_tsi_cnct_pub.h" +#include "oct6100_events_pub.h" +#include "oct6100_tone_detection_pub.h" +#include "oct6100_mixer_pub.h" +#include "oct6100_conf_bridge_pub.h" +#include "oct6100_playout_buf_pub.h" + +#include "oct6100_channel_pub.h" +#include "oct6100_remote_debug_pub.h" +#include "oct6100_debug_pub.h" +#include "oct6100_chip_open_pub.h" +#include "oct6100_chip_stats_pub.h" +#include "oct6100_adpcm_chan_pub.h" +#include "oct6100_phasing_tsst_pub.h" + +#ifdef __cplusplus +} +#endif + +#endif /* __OCT6100_API_H__ */ diff --git a/include/oct6100api/oct6100_api_inst.h b/include/oct6100api/oct6100_api_inst.h new file mode 100644 index 0000000..679d9e6 --- /dev/null +++ b/include/oct6100api/oct6100_api_inst.h @@ -0,0 +1,138 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_api_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing the definition of the API instance structure. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 39 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_API_INST_H__ +#define __OCT6100_API_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_SHARED_INFO_ +{ + /* Local copy of chip configuration structure. */ + tOCT6100_API_CHIP_CONFIG ChipConfig; + + /* Miscellaneous calculations and mapping of static structures in external memory. */ + tOCT6100_API_MISCELLANEOUS MiscVars; + tOCT6100_API_MEMORY_MAP MemoryMap; + + /* Error stats structure. */ + tOCT6100_API_CHIP_ERROR_STATS ErrorStats; + tOCT6100_API_CHIP_STATS ChipStats; + + /* Mixer information. */ + tOCT6100_API_MIXER MixerInfo; + + /* Image breakdown information. */ + tOCT6100_API_IMAGE_REGION ImageRegion[ cOCT6100_MAX_IMAGE_REGION ]; + tOCT6100_API_IMAGE_INFO ImageInfo; + + /* Configuration and management of interrupts. */ + tOCT6100_API_INTRPT_CONFIG IntrptConfig; + tOCT6100_API_INTRPT_MANAGE IntrptManage; + /* Remote debugging. */ + tOCT6100_API_REMOTE_DEBUG_INFO RemoteDebugInfo; + /* Chip debugging information. */ + tOCT6100_API_DEBUG DebugInfo; + + /* Management variables of software and hardware buffers. */ + tOCT6100_API_SOFT_BUFS SoftBufs; + + /* Caller buffer playout memory management structure. */ + tOCT6100_API_BUFFER_PLAYOUT_MALLOC_INFO PlayoutInfo; + + + + UINT32 ulChannelListOfst; + UINT32 ulChannelAllocOfst; + + UINT32 ulConversionMemoryAllocOfst; + + UINT32 ulTsiMemoryAllocOfst; + UINT32 ulExtraTsiMemoryAllocOfst; + UINT32 ulEchoMemoryAllocOfst; + + UINT32 ulTsstAllocOfst; + UINT32 ulTsstListOfst; + UINT32 ulTsstListAllocOfst; + + UINT32 ulTsiCnctListOfst; + UINT32 ulTsiCnctAllocOfst; + + UINT32 ulMixerEventListOfst; + UINT32 ulMixerEventAllocOfst; + + UINT32 ulCopyEventListOfst; + UINT32 ulCopyEventAllocOfst; + + UINT32 ulBiDirChannelListOfst; + UINT32 ulBiDirChannelAllocOfst; + + UINT32 ulConfBridgeListOfst; + UINT32 ulConfBridgeAllocOfst; + + UINT32 ulFlexConfParticipantListOfst; + UINT32 ulFlexConfParticipantAllocOfst; + + UINT32 ulPlayoutBufListOfst; + UINT32 ulPlayoutBufAllocOfst; + UINT32 ulPlayoutBufMemoryNodeListOfst; + + + + UINT32 ulAdpcmChanListOfst; + UINT32 ulAdpcmChanAllocOfst; + + UINT32 ulPhasingTsstListOfst; + UINT32 ulPhasingTsstAllocOfst; + +} tOCT6100_SHARED_INFO, *tPOCT6100_SHARED_INFO; + +typedef struct _OCT6100_INSTANCE_API_ +{ + /* Pointer to portion of API instance structure shared amongst all processes. */ + tPOCT6100_SHARED_INFO pSharedInfo; + + /* Pointer to user-supplied, process context structure. The structure is + a parameter to all user-supplied functions. */ + PVOID pProcessContext; + + /* Handles to all serialization objects used by the API. */ + UINT32 ulApiSerObj; + + +} tOCT6100_INSTANCE_API, *tPOCT6100_INSTANCE_API; + +#endif /* __OCT6100_API_INST_H__ */ diff --git a/include/oct6100api/oct6100_apimi.h b/include/oct6100api/oct6100_apimi.h new file mode 100644 index 0000000..abcad76 --- /dev/null +++ b/include/oct6100api/oct6100_apimi.h @@ -0,0 +1,69 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_apimi.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the declaration of all functions exported from the + APIMI block. The APIMI block contains only one function: + Oct6100InterruptMask. + The function is used to mask out the interrupt pin of the chip. This + function is used when a deferred procedure call treats the interrupt (new + interrupts must not be generated until the signalled interrupt is treated). + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 5 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_APIMI_H__ +#define __OCT6100_APIMI_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_INTERRUPT_MASK_ +{ + UINT32 ulUserChipIndex; + PVOID pProcessContext; + + +} tOCT6100_INTERRUPT_MASK, *tPOCT6100_INTERRUPT_MASK; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100InterruptMaskDef( + OUT tPOCT6100_INTERRUPT_MASK f_pInterruptMask ); +UINT32 Oct6100InterruptMask( + IN tPOCT6100_INTERRUPT_MASK f_pInterruptMask ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __OCT6100_APIMI_H__ */ diff --git a/include/oct6100api/oct6100_apiud.h b/include/oct6100api/oct6100_apiud.h new file mode 100644 index 0000000..7f21de7 --- /dev/null +++ b/include/oct6100api/oct6100_apiud.h @@ -0,0 +1,309 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_apiud.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + Header file containing the definitions and prototypes that are to be + completed by the user. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 15 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_APIUD_H__ +#define __OCT6100_APIUD_H__ + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +/***************************** DEFINES *************************************/ + + +/* Determines the maximum length of a burst of reads/writes. This value must + be in the range 8 - 1024. This value obtains best performance if set to + a power of 2 (i.e. 2^n). */ +#define cOCT6100_MAX_RW_ACCESSES 32 + +/* The define used to specify that the Oct6100SeizeSerializeObject function + is not to return until the specified serialization object has been seized. */ +#define cOCT6100_WAIT_INFINITELY 0xFFFFFFFF + + +/* Compile option: enabling this compile option inserts code to check every + call to a user provided function to make sure the function parameters + are not changed, as required by the API specification. */ +#define cOCT6100_USER_FUNCTION_CHECK + + + +#define cOCT6100_GET_TIME_FAILED_0 0xFFFF0000 +#define cOCT6100_GET_TIME_FAILED_1 0xFFFF0001 +#define cOCT6100_GET_TIME_FAILED_2 0xFFFF0002 +#define cOCT6100_GET_TIME_FAILED_3 0xFFFF0003 +#define cOCT6100_GET_TIME_FAILED_4 0xFFFF0004 + +#define cOCT6100_CREATE_SERIAL_FAILED_0 0xFFFF0010 +#define cOCT6100_CREATE_SERIAL_FAILED_1 0xFFFF0011 +#define cOCT6100_CREATE_SERIAL_FAILED_2 0xFFFF0012 +#define cOCT6100_CREATE_SERIAL_FAILED_3 0xFFFF0013 +#define cOCT6100_CREATE_SERIAL_FAILED_4 0xFFFF0014 + +#define cOCT6100_DESTROY_SERIAL_FAILED_0 0xFFFF0020 +#define cOCT6100_DESTROY_SERIAL_FAILED_1 0xFFFF0021 +#define cOCT6100_DESTROY_SERIAL_FAILED_2 0xFFFF0022 +#define cOCT6100_DESTROY_SERIAL_FAILED_3 0xFFFF0023 +#define cOCT6100_DESTROY_SERIAL_FAILED_4 0xFFFF0024 + +#define cOCT6100_INVALID_SERIAL_HANDLE_0 0xFFFF0030 +#define cOCT6100_INVALID_SERIAL_HANDLE_1 0xFFFF0031 +#define cOCT6100_INVALID_SERIAL_HANDLE_2 0xFFFF0032 +#define cOCT6100_INVALID_SERIAL_HANDLE_3 0xFFFF0033 +#define cOCT6100_INVALID_SERIAL_HANDLE_4 0xFFFF0034 + +#define cOCT6100_RELEASE_SERIAL_FAILED_0 0xFFFF0040 +#define cOCT6100_RELEASE_SERIAL_FAILED_1 0xFFFF0041 +#define cOCT6100_RELEASE_SERIAL_FAILED_2 0xFFFF0042 +#define cOCT6100_RELEASE_SERIAL_FAILED_3 0xFFFF0043 +#define cOCT6100_RELEASE_SERIAL_FAILED_4 0xFFFF0044 + +#define cOCT6100_SEIZE_SERIAL_FAILED_0 0xFFFF0050 +#define cOCT6100_SEIZE_SERIAL_FAILED_1 0xFFFF0051 +#define cOCT6100_SEIZE_SERIAL_FAILED_2 0xFFFF0052 +#define cOCT6100_SEIZE_SERIAL_FAILED_3 0xFFFF0053 +#define cOCT6100_SEIZE_SERIAL_FAILED_4 0xFFFF0054 + +#define cOCT6100_DRIVER_WRITE_FAILED_0 0xFFFF0060 +#define cOCT6100_DRIVER_WRITE_FAILED_1 0xFFFF0061 +#define cOCT6100_DRIVER_WRITE_FAILED_2 0xFFFF0062 +#define cOCT6100_DRIVER_WRITE_FAILED_3 0xFFFF0063 +#define cOCT6100_DRIVER_WRITE_FAILED_4 0xFFFF0064 + +#define cOCT6100_DRIVER_WSMEAR_FAILED_0 0xFFFF0070 +#define cOCT6100_DRIVER_WSMEAR_FAILED_1 0xFFFF0071 +#define cOCT6100_DRIVER_WSMEAR_FAILED_2 0xFFFF0072 +#define cOCT6100_DRIVER_WSMEAR_FAILED_3 0xFFFF0073 +#define cOCT6100_DRIVER_WSMEAR_FAILED_4 0xFFFF0074 + +#define cOCT6100_DRIVER_WBURST_FAILED_0 0xFFFF0080 +#define cOCT6100_DRIVER_WBURST_FAILED_1 0xFFFF0081 +#define cOCT6100_DRIVER_WBURST_FAILED_2 0xFFFF0082 +#define cOCT6100_DRIVER_WBURST_FAILED_3 0xFFFF0083 +#define cOCT6100_DRIVER_WBURST_FAILED_4 0xFFFF0084 + +#define cOCT6100_DRIVER_READ_FAILED_0 0xFFFF0090 +#define cOCT6100_DRIVER_READ_FAILED_1 0xFFFF0091 +#define cOCT6100_DRIVER_READ_FAILED_2 0xFFFF0092 +#define cOCT6100_DRIVER_READ_FAILED_3 0xFFFF0093 +#define cOCT6100_DRIVER_READ_FAILED_4 0xFFFF0094 + +#define cOCT6100_DRIVER_RBURST_FAILED_0 0xFFFF00A0 +#define cOCT6100_DRIVER_RBURST_FAILED_1 0xFFFF00A1 +#define cOCT6100_DRIVER_RBURST_FAILED_2 0xFFFF00A2 +#define cOCT6100_DRIVER_RBURST_FAILED_3 0xFFFF00A3 +#define cOCT6100_DRIVER_RBURST_FAILED_4 0xFFFF00A4 + + + + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_GET_TIME_ +{ + PVOID pProcessContext; + UINT32 aulWallTimeUs[ 2 ]; + +} tOCT6100_GET_TIME, *tPOCT6100_GET_TIME; + + + + + +typedef struct _OCT6100_CREATE_SERIALIZE_OBJECT_ +{ + PVOID pProcessContext; + PSZ pszSerialObjName; + UINT32 ulSerialObjHndl; + +} tOCT6100_CREATE_SERIALIZE_OBJECT, *tPOCT6100_CREATE_SERIALIZE_OBJECT; + + +typedef struct _OCT6100_DESTROY_SERIALIZE_OBJECT_ +{ + PVOID pProcessContext; + UINT32 ulSerialObjHndl; + +} tOCT6100_DESTROY_SERIALIZE_OBJECT, *tPOCT6100_DESTROY_SERIALIZE_OBJECT; + + +typedef struct _OCT6100_SEIZE_SERIALIZE_OBJECT_ +{ + PVOID pProcessContext; + UINT32 ulSerialObjHndl; + UINT32 ulTryTimeMs; + +} tOCT6100_SEIZE_SERIALIZE_OBJECT, *tPOCT6100_SEIZE_SERIALIZE_OBJECT; + + +typedef struct _OCT6100_RELEASE_SERIALIZE_OBJECT_ +{ + PVOID pProcessContext; + UINT32 ulSerialObjHndl; + +} tOCT6100_RELEASE_SERIALIZE_OBJECT, *tPOCT6100_RELEASE_SERIALIZE_OBJECT; + + +typedef struct _OCT6100_WRITE_PARAMS_ +{ + PVOID pProcessContext; + + UINT32 ulUserChipId; + UINT32 ulWriteAddress; + UINT16 usWriteData; + +} tOCT6100_WRITE_PARAMS, *tPOCT6100_WRITE_PARAMS; + + +typedef struct _OCT6100_WRITE_SMEAR_PARAMS_ +{ + PVOID pProcessContext; + + UINT32 ulUserChipId; + UINT32 ulWriteAddress; + UINT32 ulWriteLength; + UINT16 usWriteData; + +} tOCT6100_WRITE_SMEAR_PARAMS, *tPOCT6100_WRITE_SMEAR_PARAMS; + + +typedef struct _OCT6100_WRITE_BURST_PARAMS_ +{ + PVOID pProcessContext; + + UINT32 ulUserChipId; + UINT32 ulWriteAddress; + UINT32 ulWriteLength; + PUINT16 pusWriteData; + +} tOCT6100_WRITE_BURST_PARAMS, *tPOCT6100_WRITE_BURST_PARAMS; + + +typedef struct _OCT6100_READ_PARAMS_ +{ + PVOID pProcessContext; + + UINT32 ulUserChipId; + UINT32 ulReadAddress; + PUINT16 pusReadData; + +} tOCT6100_READ_PARAMS, *tPOCT6100_READ_PARAMS; + + +typedef struct _OCT6100_READ_BURST_PARAMS_ +{ + PVOID pProcessContext; + + UINT32 ulUserChipId; + UINT32 ulReadAddress; + UINT32 ulReadLength; + PUINT16 pusReadData; + +} tOCT6100_READ_BURST_PARAMS, *tPOCT6100_READ_BURST_PARAMS; + + + + + + + + +/************************** FUNCTION PROTOTYPES *****************************/ + +/* Time function. */ +static UINT32 Oct6100UserGetTime( + IN OUT tPOCT6100_GET_TIME f_pTime ); + + + +/* Memory management functions. */ +static UINT32 Oct6100UserMemSet( + IN PVOID f_pAddress, + IN UINT32 f_ulPattern, + IN UINT32 f_ulLength ); + +static UINT32 Oct6100UserMemCopy( + IN PVOID f_pDestination, + IN PVOID f_pSource, + IN UINT32 f_ulLength ); + +/* Serialization functions. */ +static UINT32 Oct6100UserCreateSerializeObject( + IN OUT tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate); + +static UINT32 Oct6100UserDestroySerializeObject( + IN tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy); + +static UINT32 Oct6100UserSeizeSerializeObject( + IN tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize); + +static UINT32 Oct6100UserReleaseSerializeObject( + IN tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease); + +/* Read/Write functions.*/ +static UINT32 Oct6100UserDriverWriteApi( + IN tPOCT6100_WRITE_PARAMS f_pWriteParams ); + +UINT32 Oct6100UserDriverWriteOs( + IN tPOCT6100_WRITE_PARAMS f_pWriteParams ); + +static UINT32 Oct6100UserDriverWriteSmearApi( + IN tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams ); + +UINT32 Oct6100UserDriverWriteSmearOs( + IN tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams ); + +static UINT32 Oct6100UserDriverWriteBurstApi( + IN tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams ); + +UINT32 Oct6100UserDriverWriteBurstOs( + IN tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams ); + +static UINT32 Oct6100UserDriverReadApi( + IN OUT tPOCT6100_READ_PARAMS f_pReadParams ); + +UINT32 Oct6100UserDriverReadOs( + IN OUT tPOCT6100_READ_PARAMS f_pReadParams ); + +static UINT32 Oct6100UserDriverReadBurstApi( + IN OUT tPOCT6100_READ_BURST_PARAMS f_pBurstParams ); + +UINT32 Oct6100UserDriverReadBurstOs( + IN OUT tPOCT6100_READ_BURST_PARAMS f_pBurstParams ); + + + + + + + +#endif /* __OCT6100_APIUD_H__ */ diff --git a/include/oct6100api/oct6100_channel_inst.h b/include/oct6100api/oct6100_channel_inst.h new file mode 100644 index 0000000..8480c98 --- /dev/null +++ b/include/oct6100api/oct6100_channel_inst.h @@ -0,0 +1,386 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_channel_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_channel.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_channel_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 84 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHANNEL_INST_H__ +#define __OCT6100_CHANNEL_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_CHANNEL_TDM_ +{ + /* Laws. */ + UINT8 byRinPcmLaw; + UINT8 bySinPcmLaw; + UINT8 byRoutPcmLaw; + UINT8 bySoutPcmLaw; + + /* RIN port. */ + UINT16 usRinTimeslot; + UINT16 usRinStream; + + /* SIN port. */ + UINT16 usSinTimeslot; + UINT16 usSinStream; + + /* ROUT port. */ + UINT16 usRoutTimeslot; + UINT16 usRoutStream; + + /* SOUT port. */ + UINT16 usSoutTimeslot; + UINT16 usSoutStream; + + /* ROUT broadcast info. */ + UINT16 usRoutBrdcastTsstFirstEntry; + UINT16 usRoutBrdcastTsstNumEntry; + + /* SOUT broadcast info. */ + UINT16 usSoutBrdcastTsstFirstEntry; + UINT16 usSoutBrdcastTsstNumEntry; + + UINT8 byRinNumTssts; + UINT8 bySinNumTssts; + UINT8 byRoutNumTssts; + UINT8 bySoutNumTssts; + +} tOCT6100_API_CHANNEL_TDM, *tPOCT6100_API_CHANNEL_TDM; + +typedef struct _OCT6100_API_CHANNEL_VQE_ +{ + UINT8 fEnableNlp; + UINT8 fEnableTailDisplacement; + UINT16 usTailDisplacement; + UINT16 usTailLength; + + UINT8 fSinDcOffsetRemoval; + UINT8 fRinDcOffsetRemoval; + UINT8 fRinLevelControl; + UINT8 fSoutLevelControl; + + UINT8 fRinAutomaticLevelControl; + UINT8 fSoutAutomaticLevelControl; + INT8 chRinAutomaticLevelControlTargetDb; + INT8 chSoutAutomaticLevelControlTargetDb; + + UINT8 fRinHighLevelCompensation; + INT8 chRinHighLevelCompensationThresholdDb; + + UINT8 bySoutAutomaticListenerEnhancementGainDb; + UINT8 fSoutNaturalListenerEnhancement; + + UINT8 fSoutAdaptiveNoiseReduction; + UINT8 fDtmfToneRemoval; + UINT8 fAcousticEcho; + UINT8 byComfortNoiseMode; + + UINT8 byNonLinearityBehaviorA; + UINT8 byNonLinearityBehaviorB; + INT8 chRinLevelControlGainDb; + INT8 chSoutLevelControlGainDb; + + INT8 chDefaultErlDb; + INT8 chAecDefaultErlDb; + + UINT8 fRoutNoiseReduction; + INT8 chAnrSnrEnhancementDb; + + UINT8 fEnableMusicProtection; + UINT8 fIdleCodeDetection; + + UINT8 byAnrVoiceNoiseSegregation; + UINT8 bySoutNaturalListenerEnhancementGainDb; + + UINT16 usToneDisablerVqeActivationDelay; + UINT16 usAecTailLength; + + UINT8 byDoubleTalkBehavior; + UINT8 fSoutNoiseBleaching; + + + + UINT8 fSoutConferencingNoiseReduction; + + + +} tOCT6100_API_CHANNEL_VQE, *tPOCT6100_API_CHANNEL_VQE; + +typedef struct _OCT6100_API_CHANNEL_CODEC_ +{ + UINT8 byAdpcmNibblePosition; + UINT8 fEnableSilenceSuppression; + + UINT8 byEncoderPort; + UINT8 byEncodingRate; + + UINT8 byDecoderPort; + UINT8 byDecodingRate; + + UINT8 byPhase; + UINT8 byPhasingType; + +} tOCT6100_API_CHANNEL_CODEC, *tPOCT6100_API_CHANNEL_CODEC; + +typedef struct _OCT6100_API_CHANNEL_ +{ + /*=======================================================================*/ + /* Channel configuration. */ + + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Count used to manage entry handles allocated to user. */ + UINT8 byEntryOpenCnt; + + /* Is this a bidirectionnal channel? */ + UINT8 fBiDirChannel; + + /* Enable tone disabler? */ + UINT8 fEnableToneDisabler; + + /* TSI chariot memory entry for the Rin/Rout stream. */ + UINT16 usRinRoutTsiMemIndex; + + /* TSI chariot memory entry for the Sin/Sout stream. */ + UINT16 usSinSoutTsiMemIndex; + + /* Additional TSI entry used to temporarily store the SIN signal. */ + UINT16 usExtraSinTsiMemIndex; + UINT16 usExtraSinTsiDependencyCnt; + + /* Additional TSI entry used to temporarily store the RIN signal. */ + UINT16 usExtraRinTsiMemIndex; + UINT16 usExtraRinTsiDependencyCnt; + + /* Conversion chariot memory entry. */ + UINT16 usRinRoutConversionMemIndex; + UINT16 usSinSoutConversionMemIndex; + + /* TSST control memory entry. */ + UINT16 usRinTsstIndex; + UINT16 usSinTsstIndex; + UINT16 usRoutTsstIndex; + UINT16 usSoutTsstIndex; + + /* SSPX memory entry. */ + UINT16 usEchoMemIndex; + + /* Active mixer events count to test for last event. */ + UINT16 usMixerEventCnt; + + /* User channel ID, transparently passed to the user. */ + UINT32 ulUserChanId; + + /* Copy events. */ + UINT16 usSinCopyEventIndex; + UINT16 usSoutCopyEventIndex; + + /* Silence events. */ + UINT16 usRinSilenceEventIndex; + UINT16 usSinSilenceEventIndex; + + /* TDM configuration. */ + tOCT6100_API_CHANNEL_TDM TdmConfig; + + /* VQE configuration. */ + tOCT6100_API_CHANNEL_VQE VqeConfig; + + /* Current echo operation mode. */ + UINT8 byEchoOperationMode; + + /* Currently muted ports. */ + UINT16 usMutedPorts; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Statistics section. */ + + INT16 sComfortNoiseLevel; + + UINT16 usCurrentEchoDelay; + UINT16 usMaxEchoDelay; + + UINT16 usNumEchoPathChanges; + UINT16 usNumEchoPathChangesOfst; + + INT16 sCurrentERL; + INT16 sCurrentERLE; + + INT16 sMaxERL; + INT16 sMaxERLE; + + INT16 sRinLevel; + INT16 sSinLevel; + + INT16 sRinAppliedGain; + INT16 sSoutAppliedGain; + + UINT8 byToneDisablerStatus; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Bridge information. */ + + UINT16 usBridgeIndex; + + UINT8 fMute; + UINT8 fTap; + UINT8 fBeingTapped; + UINT8 fCopyEventCreated; + + UINT16 usLoadEventIndex; + UINT16 usSubStoreEventIndex; + + UINT16 usFlexConfParticipantIndex; + UINT16 usTapBridgeIndex; + UINT16 usTapChanIndex; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Buffer playout information. */ + + UINT32 ulRinBufWritePtr; + UINT32 ulRinBufSkipPtr; + + UINT8 fSoutBufPlaying; + UINT8 fRinBufPlaying; + + UINT8 fRinBufPlayoutNotifyOnStop; + UINT8 fRinBufPlayoutRepeatUsed; + + UINT32 ulSoutBufWritePtr; + UINT32 ulSoutBufSkipPtr; + + UINT8 fSoutBufPlayoutNotifyOnStop; + UINT8 fSoutBufPlayoutRepeatUsed; + + UINT8 fRinHardStop; + UINT8 fSoutHardStop; + + UINT32 ulRinUserBufPlayoutEventId; + UINT32 ulSoutUserBufPlayoutEventId; + + UINT8 byRinPlayoutStopEventType; + UINT8 bySoutPlayoutStopEventType; + + UINT8 fRinBufAdded; + UINT8 fSoutBufAdded; + + UINT8 fBufPlayoutActive; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Copy events information. */ + + /* Number of copy events created. */ + UINT16 usCopyEventCnt; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Extended tone detection info. */ + + /* Enable extended tone detection. */ + UINT8 fEnableExtToneDetection; + + UINT16 usExtToneChanIndex; + UINT16 usExtToneMixerIndex; + UINT16 usExtToneTsiIndex; + + /* Mode of operation of the channel based on the extended tone detection configuration. */ + UINT32 ulExtToneChanMode; + + /*=======================================================================*/ + + /* Tone detection state. */ + /* This array is configured as follow. */ + /* Index 0 contain event 0 to 31 and Index 1 contains event 32 - 55 */ + UINT32 aulToneConf[ 2 ]; + UINT32 ulLastSSToneDetected; + UINT32 ulLastSSToneTimestamp; + + /*=======================================================================*/ + + + /*=======================================================================*/ + + /* Index of the phasing TSST */ + UINT16 usPhasingTsstIndex; + + /* State of the codec structure associated to this channel. */ + UINT8 fSinSoutCodecActive; + UINT8 fRinRoutCodecActive; + + /* Codec configuration. */ + tOCT6100_API_CHANNEL_CODEC CodecConfig; + + /*=======================================================================*/ + + + + + + + + /* Nlp Conf Dword, index 0 contains the dword where the dword is located. and + index 1 is the actual value of the dword.*/ + UINT32 aulNlpConfDword[ cOCT6100_MAX_NLP_CONF_DWORD ][ 2 ]; + +} tOCT6100_API_CHANNEL, *tPOCT6100_API_CHANNEL; + +typedef struct _OCT6100_API_BIDIR_CHANNEL_ +{ + UINT16 usFirstChanIndex; + UINT16 usSecondChanIndex; + + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Count used to manage entry handles allocated to user. */ + UINT8 byEntryOpenCnt; + +} tOCT6100_API_BIDIR_CHANNEL, *tPOCT6100_API_BIDIR_CHANNEL; + +#endif /* __OCT6100_CHANNEL_INST_H__ */ diff --git a/include/oct6100api/oct6100_channel_priv.h b/include/oct6100api/oct6100_channel_priv.h new file mode 100644 index 0000000..46c8057 --- /dev/null +++ b/include/oct6100api/oct6100_channel_priv.h @@ -0,0 +1,517 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_channel_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_channel.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_channel_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 59 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHANNEL_PRIV_H__ +#define __OCT6100_CHANNEL_PRIV_H__ + + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +/* ECHO channel list pointer macros. */ +#define mOCT6100_GET_CHANNEL_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_CHANNEL )(( PVOID )pSharedInfo + pSharedInfo->ulChannelListOfst ); + +#define mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_CHANNEL )(( PVOID )pSharedInfo + pSharedInfo->ulChannelListOfst)) + ulIndex; + +#define mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulChannelAllocOfst); + +#define mOCT6100_GET_BIDIR_CHANNEL_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_BIDIR_CHANNEL )(( PVOID )pSharedInfo + pSharedInfo->ulBiDirChannelListOfst ); + +#define mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_BIDIR_CHANNEL )(( PVOID )pSharedInfo + pSharedInfo->ulBiDirChannelListOfst)) + ulIndex; + +#define mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulBiDirChannelAllocOfst ); + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_ECHO_CHAN_INDEX_ +{ + /* Index of the channel in the API echo channel list.*/ + UINT16 usEchoChanIndex; + + /* TSI chariot memory entry for the Rin/Rout stream. */ + UINT16 usRinRoutTsiMemIndex; + + /* TSI chariot memory entry for the Sin/Sout stream. */ + UINT16 usSinSoutTsiMemIndex; + + /* SSPX memory entry. */ + UINT16 usEchoMemIndex; + + /* TDM sample conversion control memory entry. */ + UINT16 usRinRoutConversionMemIndex; + UINT16 usSinSoutConversionMemIndex; + + /* Internal info for quick access to structures associated to this TSI cnct. */ + UINT16 usRinTsstIndex; + UINT16 usSinTsstIndex; + UINT16 usRoutTsstIndex; + UINT16 usSoutTsstIndex; + + /* Index of the phasing TSST */ + UINT16 usPhasingTsstIndex; + + UINT8 fSinSoutCodecActive; + UINT8 fRinRoutCodecActive; + + + /* Extended Tone Detection resources.*/ + UINT16 usExtToneChanIndex; + UINT16 usExtToneMixerIndex; + UINT16 usExtToneTsiIndex; +} tOCT6100_API_ECHO_CHAN_INDEX, *tPOCT6100_API_ECHO_CHAN_INDEX; + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetChannelsEchoSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiChannelsEchoSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ChannelOpenSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen ); + +static UINT32 Oct6100ApiCheckChannelParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ); + +static UINT32 Oct6100ApiReserveChannelResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ); + +static UINT32 Oct6100ApiWriteChannelStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ); + +static UINT32 Oct6100ApiUpdateChannelEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ); + +UINT32 Oct6100ChannelCloseSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose ); + +UINT32 Oct6100ApiAssertChannelParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose, + + IN OUT PUINT16 f_pusChanIndex ); + +UINT32 Oct6100ApiInvalidateChannelStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + + IN UINT16 f_usChanIndex ); + +UINT32 Oct6100ApiReleaseChannelResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usChannelIndex ); + +static UINT32 Oct6100ChannelModifySer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify ); + +static UINT32 Oct6100ApiCheckChannelModify( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN OUT tPOCT6100_CHANNEL_OPEN f_pTempChanOpen, + OUT PUINT16 f_pusNewPhasingTsstIndex, + OUT PUINT16 f_pusChanIndex ); + +static UINT32 Oct6100ApiModifyChannelResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN UINT16 f_usChanIndex, + OUT PUINT16 f_pusNewRinTsstIndex, + OUT PUINT16 f_pusNewSinTsstIndex, + OUT PUINT16 f_pusNewRoutTsstIndex, + OUT PUINT16 f_pusNewSoutTsstIndex ); + +static UINT32 Oct6100ApiModifyChannelStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usNewPhasingTsstIndex, + OUT PUINT8 f_pfSinSoutCodecActive, + OUT PUINT8 f_pfRinRoutCodecActive, + IN UINT16 f_usNewRinTsstIndex, + IN UINT16 f_uslNewSinTsstIndex, + IN UINT16 f_usNewRoutTsstIndex, + IN UINT16 f_usNewSoutTsstIndex ); + +static UINT32 Oct6100ApiModifyChannelEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usNewPhasingTsstIndex, + IN UINT8 f_fSinSoutCodecActive, + IN UINT8 f_fRinRoutCodecActive, + IN UINT16 f_usNewRinTsstIndex, + IN UINT16 f_usNewSinTsstIndex, + IN UINT16 f_usNewRoutTsstIndex, + IN UINT16 f_usNewSoutTsstIndex ); + +UINT32 Oct6100ChannelBroadcastTsstAddSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd ); + +UINT32 Oct6100ApiCheckChanTsstAddParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstRemove, + OUT PUINT16 f_pusChanIndex ); + +UINT32 Oct6100ApiReserveTsstAddResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstRemove, + IN UINT16 f_usChanIndex, + OUT PUINT16 f_pusNewTsstIndex, + OUT PUINT16 f_pusNewTsstEntry ); + +UINT32 Oct6100ApiWriteTsstAddStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstRemove, + IN UINT16 f_usChanIndex, + IN UINT16 f_usNewTsstIndex ); + +UINT32 Oct6100ApiUpdateTsstAddChanEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstRemove, + IN UINT16 f_usChanIndex, + IN UINT16 f_usNewTsstIndex, + IN UINT16 f_usNewTsstEntry ); + +static UINT32 Oct6100ChannelBroadcastTsstRemoveSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove); + +static UINT32 Oct6100ApiAssertChanTsstRemoveParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove, + OUT PUINT16 f_pusChanIndex, + OUT PUINT16 f_pusTsstIndex, + OUT PUINT16 f_pusTsstEntry, + OUT PUINT16 f_pusPrevTsstEntry ); + +static UINT32 Oct6100ApiInvalidateTsstRemoveStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usChanIndex, + IN UINT16 f_usTsstIndex, + IN UINT32 f_ulPort, + IN BOOL f_fRemoveAll ); + +static UINT32 Oct6100ApiReleaseTsstRemoveResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove, + IN UINT16 f_usChanIndex, + IN UINT16 f_usTsstIndex, + IN UINT16 f_usTsstEntry, + IN UINT16 f_usPrevTsstEntry ); + +UINT32 Oct6100ApiChannelGetStatsSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_STATS f_pChannelStats ); + +static UINT32 Oct6100ApiReserveEchoEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusEchoIndex ); + +static UINT32 Oct6100ApiReleaseEchoEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEchoChanIndex ); + +static UINT32 Oct6100ApiCheckTdmConfig( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig ); + +static UINT32 Oct6100ApiCheckVqeConfig( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN BOOL f_fEnableToneDisabler ); + +static UINT32 Oct6100ApiCheckCodecConfig( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_CODEC f_pCodecConfig, + IN UINT32 f_ulDecoderNumTssts, + OUT PUINT16 f_pusPhasingTsstIndex ); + +static UINT32 Oct6100ApiWriteInputTsstControlMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsstIndex, + IN UINT16 f_usTsiMemIndex, + IN UINT32 f_ulTsstInputLaw ); + +static UINT32 Oct6100ApiWriteOutputTsstControlMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsstIndex, + IN UINT32 f_ulAdpcmNibblePosition, + IN UINT32 f_ulNumTssts, + IN UINT16 f_usTsiMemIndex ); + +static UINT32 Oct6100ApiWriteEncoderMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulEncoderIndex, + IN UINT32 f_ulCompType, + IN UINT16 f_usTsiMemIndex, + IN UINT32 f_ulEnableSilenceSuppression, + IN UINT32 f_ulAdpcmNibblePosition, + IN UINT16 f_usPhasingTsstIndex, + IN UINT32 f_ulPhasingType, + IN UINT32 f_ulPhase ); + +static UINT32 Oct6100ApiWriteDecoderMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usDecoderIndex, + IN UINT32 f_ulCompType, + IN UINT16 f_usTsiMemIndex, + IN UINT32 f_ulPcmLaw, + IN UINT32 f_ulAdpcmNibblePosition ); + + +static UINT32 Oct6100ApiClearConversionMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usConversionMemIndex ); + +static UINT32 Oct6100ApiWriteVqeMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearPlayoutPointers, + IN BOOL f_fModifyOnly ); + +static UINT32 Oct6100ApiWriteVqeNlpMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearPlayoutPointers, + IN BOOL f_fModifyOnly ); + +static UINT32 Oct6100ApiWriteVqeAfMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearPlayoutPointers, + IN BOOL f_fModifyOnly ); + +static UINT32 Oct6100ApiWriteEchoMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usEchoIndex, + IN UINT16 f_usRinRoutTsiIndex, + IN UINT16 f_usSinSoutTsiIndex ); + +static UINT32 Oct6100ApiUpdateOpenStruct( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChanModify, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChanOpen, + IN tPOCT6100_API_CHANNEL f_pChanEntry ); + + + + + +UINT32 Oct6100ApiRetrieveNlpConfDword( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_API_CHANNEL f_pChanEntry, + IN UINT32 f_ulAddress, + OUT PUINT32 f_pulConfigDword ); + +UINT32 Oct6100ApiSaveNlpConfDword( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_API_CHANNEL f_pChanEntry, + IN UINT32 f_ulAddress, + IN UINT32 f_ulConfigDword ); + +UINT32 Oct6100ChannelCreateBiDirSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir ); + +UINT32 Oct6100ApiCheckChannelCreateBiDirParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir, + OUT PUINT16 f_pusFirstChanIndex, + OUT PUINT16 f_pusFirstChanExtraTsiIndex, + OUT PUINT16 f_pusFirstChanSinCopyEventIndex, + OUT PUINT16 f_pusSecondChanIndex, + OUT PUINT16 f_pusSecondChanExtraTsiIndex, + OUT PUINT16 f_pusSecondChanSinCopyEventIndex ); + +UINT32 Oct6100ApiReserveChannelCreateBiDirResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusBiDirChanIndex, + IN OUT PUINT16 f_pusFirstChanExtraTsiIndex, + IN OUT PUINT16 f_pusFirstChanSinCopyEventIndex, + OUT PUINT16 f_pusFirstChanSoutCopyEventIndex, + IN OUT PUINT16 f_pusSecondChanExtraTsiIndex, + IN OUT PUINT16 f_pusSecondChanSinCopyEventIndex, + OUT PUINT16 f_pusSecondChanSoutCopyEventIndex ); + +UINT32 Oct6100ApiWriteChannelCreateBiDirStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usFirstChanIndex, + IN UINT16 f_usFirstChanExtraTsiIndex, + IN UINT16 f_usFirstChanSinCopyEventIndex, + IN UINT16 f_usFirstChanSoutCopyEventIndex, + IN UINT16 f_usSecondChanIndex, + IN UINT16 f_usSecondChanExtraTsiIndex, + IN UINT16 f_usSecondChanSinCopyEventIndex, + IN UINT16 f_usSecondChanSoutCopyEventIndex ); + +UINT32 Oct6100ApiUpdateBiDirChannelEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir, + IN UINT16 f_usBiDirChanIndex, + IN UINT16 f_usFirstChanIndex, + IN UINT16 f_usFirstChanExtraTsiIndex, + IN UINT16 f_usFirstChanSinCopyEventIndex, + IN UINT16 f_usFirstChanSoutCopyEventIndex, + IN UINT16 f_usSecondChanIndex, + IN UINT16 f_usSecondChanExtraTsiIndex, + IN UINT16 f_usSecondChanSinCopyEventIndex, + IN UINT16 f_usSecondChanSoutCopyEventIndex ); + +UINT32 Oct6100ChannelDestroyBiDirSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir ); + +UINT32 Oct6100ApiAssertDestroyBiDirChanParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir, + IN OUT PUINT16 f_pusBiDirChanIndex, + IN OUT PUINT16 f_pusFirstChanIndex, + IN OUT PUINT16 f_pusSecondChanIndex ); + +UINT32 Oct6100ApiInvalidateBiDirChannelStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usFirstChanIndex, + IN UINT16 f_usSecondChanIndex ); + +UINT32 Oct6100ApiReleaseBiDirChannelResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usBiDirChanIndex, + IN UINT16 f_usFirstChanIndex, + IN UINT16 f_usSecondChanIndex ); + +static UINT32 Oct6100ApiWriteDebugChanMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN UINT16 f_usRinRoutTsiIndex, + IN UINT16 f_usSinSoutTsiIndex ); + +static UINT32 Oct6100ApiDebugChannelOpen( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiMutePorts( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEchoIndex, + IN UINT16 f_usRinTsstIndex, + IN UINT16 f_usSinTsstIndex, + IN BOOL f_fCheckBridgeIndex ); + +static UINT32 Oct6100ApiSetChannelLevelControl( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearAlcHlcStatusBit ); + +static UINT32 Oct6100ApiSetChannelTailConfiguration( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fModifyOnly ); + +UINT32 Oct6100ChannelMuteSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MUTE f_pChannelMute ); + +UINT32 Oct6100ApiAssertChannelMuteParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MUTE f_pChannelMute, + OUT PUINT16 f_pusChanIndex, + OUT PUINT16 f_pusPorts ); + +UINT32 Oct6100ChannelUnMuteSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute ); + +UINT32 Oct6100ApiAssertChannelUnMuteParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute, + OUT PUINT16 f_pusChanIndex, + OUT PUINT16 f_pusPorts ); + +UINT32 Oct6100ApiMuteChannelPorts( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usChanIndex, + IN UINT16 f_usPortMask, + IN BOOL f_fMute ); + +INT32 Oct6100ApiOctFloatToDbEnergyByte( + IN UINT8 x ); + +INT32 Oct6100ApiOctFloatToDbEnergyHalf( + IN UINT16 x ); + +static UINT16 Oct6100ApiDbAmpHalfToOctFloat( + IN INT32 x ); + +#endif /* __OCT6100_CHANNEL_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_channel_pub.h b/include/oct6100api/oct6100_channel_pub.h new file mode 100644 index 0000000..2ed2797 --- /dev/null +++ b/include/oct6100api/oct6100_channel_pub.h @@ -0,0 +1,542 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_channel_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_channel.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_channel_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 79 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHANNEL_PUB_H__ +#define __OCT6100_CHANNEL_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +/* Channel open structures. */ +typedef struct _OCT6100_CHANNEL_OPEN_TDM_ +{ + UINT32 ulRinNumTssts; + UINT32 ulSinNumTssts; + UINT32 ulRoutNumTssts; + UINT32 ulSoutNumTssts; + + UINT32 ulSinTimeslot; + UINT32 ulSinStream; + UINT32 ulSinPcmLaw; + + UINT32 ulSoutTimeslot; + UINT32 ulSoutStream; + UINT32 ulSoutPcmLaw; + + UINT32 ulRinTimeslot; + UINT32 ulRinStream; + UINT32 ulRinPcmLaw; + + UINT32 ulRoutTimeslot; + UINT32 ulRoutStream; + UINT32 ulRoutPcmLaw; + +} tOCT6100_CHANNEL_OPEN_TDM, *tPOCT6100_CHANNEL_OPEN_TDM; + +typedef struct _OCT6100_CHANNEL_OPEN_VQE_ +{ + BOOL fEnableNlp; + BOOL fEnableTailDisplacement; + UINT32 ulTailDisplacement; + UINT32 ulTailLength; + + BOOL fSinDcOffsetRemoval; + BOOL fRinDcOffsetRemoval; + BOOL fRinLevelControl; + BOOL fSoutLevelControl; + BOOL fRinAutomaticLevelControl; + BOOL fSoutAutomaticLevelControl; + BOOL fRinHighLevelCompensation; + BOOL fAcousticEcho; + BOOL fSoutAdaptiveNoiseReduction; + BOOL fDtmfToneRemoval; + + BOOL fSoutNoiseBleaching; + BOOL fSoutConferencingNoiseReduction; + + UINT32 ulComfortNoiseMode; + UINT32 ulNonLinearityBehaviorA; + UINT32 ulNonLinearityBehaviorB; + + INT32 lRinLevelControlGainDb; + INT32 lSoutLevelControlGainDb; + INT32 lRinAutomaticLevelControlTargetDb; + INT32 lSoutAutomaticLevelControlTargetDb; + INT32 lRinHighLevelCompensationThresholdDb; + INT32 lDefaultErlDb; + INT32 lAecDefaultErlDb; + UINT32 ulAecTailLength; + UINT32 ulSoutAutomaticListenerEnhancementGainDb; + UINT32 ulSoutNaturalListenerEnhancementGainDb; + BOOL fSoutNaturalListenerEnhancement; + BOOL fRoutNoiseReduction; + INT32 lAnrSnrEnhancementDb; + UINT32 ulAnrVoiceNoiseSegregation; + UINT32 ulDoubleTalkBehavior; + + UINT32 ulToneDisablerVqeActivationDelay; + + BOOL fEnableMusicProtection; + BOOL fIdleCodeDetection; + + + +} tOCT6100_CHANNEL_OPEN_VQE, *tPOCT6100_CHANNEL_OPEN_VQE; + +typedef struct _OCT6100_CHANNEL_OPEN_CODEC_ +{ + UINT32 ulAdpcmNibblePosition; + + UINT32 ulEncoderPort; + UINT32 ulEncodingRate; + + UINT32 ulDecoderPort; + UINT32 ulDecodingRate; + + BOOL fEnableSilenceSuppression; + UINT32 ulPhase; + UINT32 ulPhasingType; + UINT32 ulPhasingTsstHndl; + +} tOCT6100_CHANNEL_OPEN_CODEC, *tPOCT6100_CHANNEL_OPEN_CODEC; + +typedef struct _OCT6100_CHANNEL_OPEN_ +{ + PUINT32 pulChannelHndl; + UINT32 ulUserChanId; + + UINT32 ulEchoOperationMode; + + BOOL fEnableToneDisabler; + + BOOL fEnableExtToneDetection; + + tOCT6100_CHANNEL_OPEN_TDM TdmConfig; + tOCT6100_CHANNEL_OPEN_VQE VqeConfig; + tOCT6100_CHANNEL_OPEN_CODEC CodecConfig; + + + +} tOCT6100_CHANNEL_OPEN, *tPOCT6100_CHANNEL_OPEN; + +/* Channel close structure. */ +typedef struct _OCT6100_CHANNEL_CLOSE_ +{ + UINT32 ulChannelHndl; + +} tOCT6100_CHANNEL_CLOSE, *tPOCT6100_CHANNEL_CLOSE; + +/* Channel modify structures. */ +typedef struct _OCT6100_CHANNEL_MODIFY_TDM_ +{ + UINT32 ulRinNumTssts; + UINT32 ulSinNumTssts; + UINT32 ulRoutNumTssts; + UINT32 ulSoutNumTssts; + + UINT32 ulSinTimeslot; + UINT32 ulSinStream; + UINT32 ulSinPcmLaw; + + UINT32 ulSoutTimeslot; + UINT32 ulSoutStream; + UINT32 ulSoutPcmLaw; + + UINT32 ulRinTimeslot; + UINT32 ulRinStream; + UINT32 ulRinPcmLaw; + + UINT32 ulRoutTimeslot; + UINT32 ulRoutStream; + UINT32 ulRoutPcmLaw; + +} tOCT6100_CHANNEL_MODIFY_TDM, *tPOCT6100_CHANNEL_MODIFY_TDM; + +typedef struct _OCT6100_CHANNEL_MODIFY_VQE_ +{ + BOOL fEnableNlp; + BOOL fEnableTailDisplacement; + UINT32 ulTailDisplacement; + + BOOL fSinDcOffsetRemoval; + BOOL fRinDcOffsetRemoval; + BOOL fRinLevelControl; + BOOL fSoutLevelControl; + BOOL fRinAutomaticLevelControl; + BOOL fSoutAutomaticLevelControl; + BOOL fRinHighLevelCompensation; + BOOL fAcousticEcho; + BOOL fSoutAdaptiveNoiseReduction; + BOOL fDtmfToneRemoval; + + BOOL fSoutConferencingNoiseReduction; + BOOL fSoutNoiseBleaching; + + UINT32 ulNonLinearityBehaviorA; + UINT32 ulNonLinearityBehaviorB; + UINT32 ulComfortNoiseMode; + + INT32 lRinLevelControlGainDb; + INT32 lSoutLevelControlGainDb; + INT32 lRinAutomaticLevelControlTargetDb; + INT32 lSoutAutomaticLevelControlTargetDb; + INT32 lRinHighLevelCompensationThresholdDb; + INT32 lDefaultErlDb; + INT32 lAecDefaultErlDb; + UINT32 ulAecTailLength; + UINT32 ulSoutAutomaticListenerEnhancementGainDb; + UINT32 ulSoutNaturalListenerEnhancementGainDb; + BOOL fSoutNaturalListenerEnhancement; + BOOL fRoutNoiseReduction; + INT32 lAnrSnrEnhancementDb; + UINT32 ulAnrVoiceNoiseSegregation; + UINT32 ulDoubleTalkBehavior; + + UINT32 ulToneDisablerVqeActivationDelay; + + BOOL fEnableMusicProtection; + BOOL fIdleCodeDetection; + + + +} tOCT6100_CHANNEL_MODIFY_VQE, *tPOCT6100_CHANNEL_MODIFY_VQE; + +typedef struct _OCT6100_CHANNEL_MODIFY_CODEC_ +{ + UINT32 ulEncoderPort; + UINT32 ulEncodingRate; + + UINT32 ulDecoderPort; + UINT32 ulDecodingRate; + + BOOL fEnableSilenceSuppression; + UINT32 ulPhase; + UINT32 ulPhasingType; + UINT32 ulPhasingTsstHndl; + +} tOCT6100_CHANNEL_MODIFY_CODEC, *tPOCT6100_CHANNEL_MODIFY_CODEC; + +typedef struct _OCT6100_CHANNEL_MODIFY_ +{ + UINT32 ulChannelHndl; + UINT32 ulUserChanId; + UINT32 ulEchoOperationMode; + + BOOL fEnableToneDisabler; + + BOOL fApplyToAllChannels; + + BOOL fDisableToneDetection; + BOOL fStopBufferPlayout; + BOOL fRemoveConfBridgeParticipant; + BOOL fRemoveBroadcastTssts; + + BOOL fTdmConfigModified; /* TRUE/FALSE */ + BOOL fVqeConfigModified; /* TRUE/FALSE */ + BOOL fCodecConfigModified; /* TRUE/FALSE */ + + + tOCT6100_CHANNEL_MODIFY_TDM TdmConfig; + tOCT6100_CHANNEL_MODIFY_VQE VqeConfig; + tOCT6100_CHANNEL_MODIFY_CODEC CodecConfig; + +} tOCT6100_CHANNEL_MODIFY, *tPOCT6100_CHANNEL_MODIFY; + +typedef struct _OCT6100_CHANNEL_BROADCAST_TSST_ADD_ +{ + UINT32 ulChannelHndl; + + UINT32 ulPort; + UINT32 ulTimeslot; + UINT32 ulStream; + +} tOCT6100_CHANNEL_BROADCAST_TSST_ADD, *tPOCT6100_CHANNEL_BROADCAST_TSST_ADD; + +typedef struct _OCT6100_CHANNEL_BROADCAST_TSST_REMOVE_ +{ + UINT32 ulChannelHndl; + + UINT32 ulPort; + UINT32 ulTimeslot; + UINT32 ulStream; + + BOOL fRemoveAll; + +} tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE, *tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE; + +/* Channel open structures.*/ +typedef struct _OCT6100_CHANNEL_STATS_TDM_ +{ + UINT32 ulMaxBroadcastTssts; + UINT32 ulNumRoutBroadcastTssts; + BOOL fMoreRoutBroadcastTssts; + UINT32 ulNumSoutBroadcastTssts; + BOOL fMoreSoutBroadcastTssts; + + UINT32 ulSinNumTssts; + UINT32 ulSoutNumTssts; + UINT32 ulRinNumTssts; + UINT32 ulRoutNumTssts; + + UINT32 ulSinTimeslot; + UINT32 ulSinStream; + UINT32 ulSinPcmLaw; + + UINT32 ulSoutTimeslot; + UINT32 ulSoutStream; + UINT32 ulSoutPcmLaw; + + PUINT32 pulSoutBroadcastTimeslot; + PUINT32 pulSoutBroadcastStream; + + UINT32 ulRinTimeslot; + UINT32 ulRinStream; + UINT32 ulRinPcmLaw; + + UINT32 ulRoutTimeslot; + UINT32 ulRoutStream; + UINT32 ulRoutPcmLaw; + + PUINT32 pulRoutBroadcastTimeslot; + PUINT32 pulRoutBroadcastStream; + +} tOCT6100_CHANNEL_STATS_TDM, *tPOCT6100_CHANNEL_STATS_TDM; + +typedef struct _OCT6100_CHANNEL_STATS_VQE_ +{ + BOOL fEnableNlp; + BOOL fEnableTailDisplacement; + UINT32 ulTailDisplacement; + UINT32 ulTailLength; + + BOOL fSinDcOffsetRemoval; + BOOL fRinDcOffsetRemoval; + BOOL fRinLevelControl; + BOOL fSoutLevelControl; + BOOL fRinAutomaticLevelControl; + BOOL fSoutAutomaticLevelControl; + BOOL fRinHighLevelCompensation; + BOOL fAcousticEcho; + BOOL fSoutAdaptiveNoiseReduction; + BOOL fDtmfToneRemoval; + + BOOL fSoutConferencingNoiseReduction; + BOOL fSoutNoiseBleaching; + + UINT32 ulComfortNoiseMode; + UINT32 ulNonLinearityBehaviorA; + UINT32 ulNonLinearityBehaviorB; + + INT32 lRinLevelControlGainDb; + INT32 lSoutLevelControlGainDb; + INT32 lRinAutomaticLevelControlTargetDb; + INT32 lSoutAutomaticLevelControlTargetDb; + INT32 lRinHighLevelCompensationThresholdDb; + INT32 lDefaultErlDb; + INT32 lAecDefaultErlDb; + UINT32 ulAecTailLength; + UINT32 ulSoutAutomaticListenerEnhancementGainDb; + UINT32 ulSoutNaturalListenerEnhancementGainDb; + BOOL fSoutNaturalListenerEnhancement; + BOOL fRoutNoiseReduction; + INT32 lAnrSnrEnhancementDb; + UINT32 ulAnrVoiceNoiseSegregation; + UINT32 ulDoubleTalkBehavior; + + UINT32 ulToneDisablerVqeActivationDelay; + + BOOL fEnableMusicProtection; + BOOL fIdleCodeDetection; + + + +} tOCT6100_CHANNEL_STATS_VQE, *tPOCT6100_CHANNEL_STATS_VQE; + +typedef struct _OCT6100_CHANNEL_STATS_CODEC_ +{ + UINT32 ulAdpcmNibblePosition; + + UINT32 ulEncoderPort; + UINT32 ulEncodingRate; + + UINT32 ulDecoderPort; + UINT32 ulDecodingRate; + + BOOL fEnableSilenceSuppression; + UINT32 ulPhase; + UINT32 ulPhasingType; + UINT32 ulPhasingTsstHndl; + +} tOCT6100_CHANNEL_STATS_CODEC, *tPOCT6100_CHANNEL_STATS_CODEC; + +typedef struct _OCT6100_CHANNEL_STATS_ +{ + BOOL fResetStats; + + UINT32 ulChannelHndl; + UINT32 ulUserChanId; + + UINT32 ulEchoOperationMode; + BOOL fEnableToneDisabler; + + UINT32 ulMutePortsMask; + BOOL fEnableExtToneDetection; + + tOCT6100_CHANNEL_STATS_TDM TdmConfig; + tOCT6100_CHANNEL_STATS_VQE VqeConfig; + tOCT6100_CHANNEL_STATS_CODEC CodecConfig; + + /* Real stats. */ + UINT32 ulNumEchoPathChanges; + UINT32 ulToneDisablerStatus; + + INT32 lCurrentERL; + INT32 lCurrentERLE; + UINT32 ulCurrentEchoDelay; + + INT32 lMaxERL; + INT32 lMaxERLE; + UINT32 ulMaxEchoDelay; + + INT32 lRinLevel; + INT32 lSinLevel; + INT32 lRinAppliedGain; + INT32 lSoutAppliedGain; + INT32 lComfortNoiseLevel; + + BOOL fEchoCancellerConverged; + BOOL fSinVoiceDetected; + + + +} tOCT6100_CHANNEL_STATS, *tPOCT6100_CHANNEL_STATS; + +typedef struct _OCT6100_CHANNEL_CREATE_BIDIR_ +{ + PUINT32 pulBiDirChannelHndl; + + UINT32 ulFirstChannelHndl; + UINT32 ulSecondChannelHndl; + +} tOCT6100_CHANNEL_CREATE_BIDIR, *tPOCT6100_CHANNEL_CREATE_BIDIR; + +typedef struct _OCT6100_CHANNEL_DESTROY_BIDIR_ +{ + UINT32 ulBiDirChannelHndl; + +} tOCT6100_CHANNEL_DESTROY_BIDIR, *tPOCT6100_CHANNEL_DESTROY_BIDIR; + +typedef struct _OCT6100_CHANNEL_MUTE_ +{ + UINT32 ulChannelHndl; + UINT32 ulPortMask; + +} tOCT6100_CHANNEL_MUTE, *tPOCT6100_CHANNEL_MUTE; + +typedef struct _OCT6100_CHANNEL_UNMUTE_ +{ + UINT32 ulChannelHndl; + UINT32 ulPortMask; + +} tOCT6100_CHANNEL_UNMUTE, *tPOCT6100_CHANNEL_UNMUTE; + + +/************************** FUNCTION PROTOTYPES *****************************/ + + +static UINT32 Oct6100ChannelOpenDef( + OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen ); +static UINT32 Oct6100ChannelOpen( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen ); + +UINT32 Oct6100ChannelCloseDef( + OUT tPOCT6100_CHANNEL_CLOSE f_pChannelClose ); +UINT32 Oct6100ChannelClose( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_CLOSE f_pChannelClose ); + +static UINT32 Oct6100ChannelModifyDef( + OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify ); +static UINT32 Oct6100ChannelModify( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify ); + +UINT32 Oct6100ChannelBroadcastTsstAddDef( + OUT tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd ); +UINT32 Oct6100ChannelBroadcastTsstAdd( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd ); + +static UINT32 Oct6100ChannelBroadcastTsstRemoveDef( + OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove ); +UINT32 Oct6100ChannelBroadcastTsstRemove( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove ); + +UINT32 Oct6100ChannelGetStatsDef( + OUT tPOCT6100_CHANNEL_STATS f_pChannelStats ); +UINT32 Oct6100ChannelGetStats( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_STATS f_pChannelStats ); + +UINT32 Oct6100ChannelCreateBiDirDef( + OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir ); +UINT32 Oct6100ChannelCreateBiDir( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir ); + +UINT32 Oct6100ChannelDestroyBiDirDef( + OUT tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir ); +UINT32 Oct6100ChannelDestroyBiDir( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir ); + +UINT32 Oct6100ChannelMuteDef( + OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute ); +UINT32 Oct6100ChannelMute( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute ); + +UINT32 Oct6100ChannelUnMuteDef( + OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute ); +UINT32 Oct6100ChannelUnMute( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute ); + +#endif /* __OCT6100_CHANNEL_PUB_H__ */ diff --git a/include/oct6100api/oct6100_chip_open_inst.h b/include/oct6100api/oct6100_chip_open_inst.h new file mode 100644 index 0000000..f1ee150 --- /dev/null +++ b/include/oct6100api/oct6100_chip_open_inst.h @@ -0,0 +1,511 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_open_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_chip_open.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_chip_open_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 116 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHIP_OPEN_INST_H__ +#define __OCT6100_CHIP_OPEN_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_CHIP_CONFIG_ +{ + UINT32 ulUserChipId; + PVOID pProcessContext; + + PUINT8 pbyImageFile; /* Byte pointer to the image file to be uploaded into the chip. */ + UINT32 ulImageSize; /* Size of the image file (in bytes). */ + + UINT32 ulMemClkFreq; + UINT32 ulUpclkFreq; /* 33.33 or 66.66 MHz. */ + UINT8 fEnableMemClkOut; /* TRUE/FALSE */ + + UINT8 fMultiProcessSystem; + + UINT8 byMemoryType; /* SDRAM or DDR */ + UINT8 byNumMemoryChips; /* Number of memory chips present. */ + UINT32 ulMemoryChipSize; /* The size of the memory chips. */ + + UINT16 usMaxRwAccesses; + UINT16 usTailDisplacement; + + /* Resource allocation parameters. */ + UINT16 usMaxChannels; + UINT16 usMaxBiDirChannels; + + UINT32 aulTdmStreamFreqs[ cOCT6100_TDM_STREAM_MAX_GROUPS ]; + + UINT8 byMaxTdmStreams; + UINT8 byTdmSampling; + + UINT8 fEnableFastH100Mode; + UINT8 fEnableAcousticEcho; /* Acoustic echo enabled. */ + + UINT16 ausTimestampTimeslots[ 4 ]; + UINT16 ausTimestampStreams[ 4 ]; + + UINT8 fUseSynchTimestamp; + + /* Debug feature used to record stream information from a channel.*/ + UINT8 fEnableChannelRecording; + + UINT16 usMaxRemoteDebugSessions; + + UINT8 byInterruptPolarity; + + UINT16 usMaxTsiCncts; + + UINT8 fEnableExtToneDetection; + + + UINT16 usMaxConfBridges; + UINT16 usMaxFlexibleConfParticipants; + UINT16 usMaxPlayoutBuffers; + + /* Playout event software buffer size. */ + UINT32 ulSoftBufPlayoutEventsBufSize; + + /* Soft buffer size. */ + UINT32 ulSoftToneEventsBufSize; + + UINT16 usMaxPhasingTssts; + UINT16 usMaxAdpcmChannels; + + + + + + UINT8 fEnableProductionBist; + UINT32 ulNumProductionBistLoops; + +} tOCT6100_API_CHIP_CONFIG, *tPOCT6100_API_CHIP_CONFIG; + + +typedef struct _OCT6100_API_MISCELLANEOUS_ +{ + /* Total size of external memories. */ + UINT32 ulTotalMemSize; + + UINT32 ulH100SlaveMode; + + /* Mclk frequency generated by the chip. */ + UINT32 ulMclkFreq; + + /* Array of UINT32s used to perform a burst of writes (avoids having to + allocate on the stack. The size of this array MUST NOT CHANGE (it's + used everywhere). */ + UINT16 ausSuperArray[ cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ]; + UINT16 ausSuperArray1[ cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ]; + UINT16 ausSuperArray2[ cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ]; + + /* Chip ID and revision.*/ + UINT16 usChipId; + UINT16 usChipRevision; + + /* Lsu CPU access variables.*/ + UINT16 usCpuLsuWritePtr; + UINT16 usCodepoint; + + /* Max number of channel supported.*/ + UINT16 usMaxNumberOfChannels; + UINT16 usMaxH100Speed; + UINT16 usTdmClkBoundary; + + UINT16 usNumBridgesOpened; + UINT16 usFirstBridge; + + + + + +} tOCT6100_API_MISCELLANEOUS, *tPOCT6100_API_MISCELLANEOUS; + +typedef struct _OCT6100_API_MEMORY_MAP_ +{ + /*-----------------------------------------------------------------------------*/ + /* Structure contained in external memory. */ + + /* Memory mapping filled using TLV information from the chip. */ + + /* Main channel memory. */ + UINT32 ulChanMainMemBase; + UINT32 ulChanMainMemSize; + + UINT32 ulChanMainIoMemOfst; + + UINT32 ulChanMainRinCBMemOfst; + UINT32 ulChanMainRinCBMemSize; + UINT32 ulChanMainSinCBMemOfst; + UINT32 ulChanMainSinCBMemSize; + UINT32 ulChanMainSoutCBMemOfst; + UINT32 ulChanMainSoutCBMemSize; + + /* Free memory base address. */ + UINT32 ulFreeMemBaseAddress; + + /* Root channel config offset. */ + UINT32 ulChanRootConfOfst; + + /* Playout buffer info. */ + UINT32 ulChanMainRinPlayoutMemOfst; + UINT32 ulChanMainRinPlayoutMemSize; + UINT32 ulChanMainSoutPlayoutMemOfst; + UINT32 ulChanMainSoutPlayoutMemSize; + + /* Channel Stats location */ + UINT32 ulChanMainIoStatsOfst; + UINT32 ulChanMainIoStatsSize; + + /* Buffer playout fields. */ + tOCT6100_TLV_OFFSET PlayoutRinWritePtrOfst; + tOCT6100_TLV_OFFSET PlayoutRinIgnoreSkipCleanOfst; + tOCT6100_TLV_OFFSET PlayoutRinSkipPtrOfst; + tOCT6100_TLV_OFFSET PlayoutSoutWritePtrOfst; + tOCT6100_TLV_OFFSET PlayoutSoutIgnoreSkipCleanOfst; + tOCT6100_TLV_OFFSET PlayoutSoutSkipPtrOfst; + tOCT6100_TLV_OFFSET PlayoutRinReadPtrOfst; + tOCT6100_TLV_OFFSET PlayoutSoutReadPtrOfst; + tOCT6100_TLV_OFFSET PlayoutRinHardSkipOfst; + tOCT6100_TLV_OFFSET PlayoutSoutHardSkipOfst; + + /* Adaptive noise reduction. */ + tOCT6100_TLV_OFFSET AdaptiveNoiseReductionOfst; + + /* DC offset removal. */ + tOCT6100_TLV_OFFSET RinDcOffsetRemovalOfst; + tOCT6100_TLV_OFFSET SinDcOffsetRemovalOfst; + + /* Level control. */ + tOCT6100_TLV_OFFSET RinLevelControlOfst; + tOCT6100_TLV_OFFSET SoutLevelControlOfst; + + /* Auto level control. */ + tOCT6100_TLV_OFFSET RinAutoLevelControlTargetOfst; + tOCT6100_TLV_OFFSET SoutAutoLevelControlTargetOfst; + + /* High level compensation. */ + tOCT6100_TLV_OFFSET RinHighLevelCompensationThresholdOfst; + tOCT6100_TLV_OFFSET SoutHighLevelCompensationThresholdOfst; + + /* Auto level control and high level compensation status. */ + tOCT6100_TLV_OFFSET AlcHlcStatusOfst; + + /* Confort Noise Mode. */ + tOCT6100_TLV_OFFSET ComfortNoiseModeOfst; + + /* NLP control field. */ + tOCT6100_TLV_OFFSET NlpControlFieldOfst; + + /* VAD control field offset.*/ + tOCT6100_TLV_OFFSET VadControlFieldOfst; + + /* NLP Trivial field offset. */ + tOCT6100_TLV_OFFSET NlpTrivialFieldOfst; + + /* Acoustic echo field offset. */ + tOCT6100_TLV_OFFSET AecFieldOfst; + + /* Acoustic echo default ERL field offset. */ + tOCT6100_TLV_OFFSET AecDefaultErlFieldOfst; + + /* Non-linearity behavior A and B field offset. */ + tOCT6100_TLV_OFFSET PcmLeakFieldOfst; + tOCT6100_TLV_OFFSET NlpConvCapFieldOfst; + + /* Default ERL field offset. */ + tOCT6100_TLV_OFFSET DefaultErlFieldOfst; + + /* Tone Removal field offset.*/ + tOCT6100_TLV_OFFSET ToneRemovalFieldOfst; + + + + /* Channel config fields offset. */ + tOCT6100_TLV_OFFSET ChanMainIoMaxEchoPointOfst; + tOCT6100_TLV_OFFSET TailDisplEnableOfst; + + /* Pouch fields offset. */ + tOCT6100_TLV_OFFSET PouchBootInstructionOfst; + tOCT6100_TLV_OFFSET PouchBootResultOfst; + tOCT6100_TLV_OFFSET PouchTailDisplOfst; + + /* 2100 Hz Auto disabling fields offset. */ + tOCT6100_TLV_OFFSET ToneDisablerControlOfst; + + /* Conferencing dominant speaker field offset. */ + tOCT6100_TLV_OFFSET DominantSpeakerFieldOfst; + + /* Conferencing noise reduction field offset. */ + tOCT6100_TLV_OFFSET ConferencingNoiseReductionOfst; + + /* Per channel tail displacement field offset. */ + tOCT6100_TLV_OFFSET PerChanTailDisplacementFieldOfst; + + /* Per channel tail length field offset. */ + tOCT6100_TLV_OFFSET PerChanTailLengthFieldOfst; + + /* AF control/echo cancellation bypass. */ + tOCT6100_TLV_OFFSET AftControlOfst; + + /* Voice detected stat field offset. */ + tOCT6100_TLV_OFFSET SinVoiceDetectedStatOfst; + + /* Rin currently applied gain field offset. */ + tOCT6100_TLV_OFFSET RinAppliedGainStatOfst; + + /* Sout currently applied gain field offset. */ + tOCT6100_TLV_OFFSET SoutAppliedGainStatOfst; + + /* Adaptive listener enhancement field offset. */ + tOCT6100_TLV_OFFSET AdaptiveAleOfst; + + /* Rin NR field offset. */ + tOCT6100_TLV_OFFSET RinAnrOfst; + + /* Sin Mute field offset. */ + tOCT6100_TLV_OFFSET SinMuteOfst; + + /* Rin Mute field offset. */ + tOCT6100_TLV_OFFSET RinMuteOfst; + + /* Sout ANR SNR enhancement offset. */ + tOCT6100_TLV_OFFSET AnrSnrEnhancementOfst; + + /* Sout ANR voice-noise segregation offset. */ + tOCT6100_TLV_OFFSET AnrVoiceNoiseSegregationOfst; + + /* Tone disabler VQE activation delay offset. */ + tOCT6100_TLV_OFFSET ToneDisablerVqeActivationDelayOfst; + + /* AF tail displacement value configuration offset. */ + tOCT6100_TLV_OFFSET AfTailDisplacementFieldOfst; + + /* Pouch counter field offset. */ + tOCT6100_TLV_OFFSET PouchCounterFieldOfst; + + /* Acoustic echo tail length. */ + tOCT6100_TLV_OFFSET AecTailLengthFieldOfst; + + /* Is ISR called field offset. */ + tOCT6100_TLV_OFFSET IsIsrCalledFieldOfst; + + /* Music protection enable field offset. */ + tOCT6100_TLV_OFFSET MusicProtectionFieldOfst; + + /* Rin port energy level statistics field offset. */ + tOCT6100_TLV_OFFSET RinEnergyStatFieldOfst; + + /* Sout port energy level statistics field offset. */ + tOCT6100_TLV_OFFSET SoutEnergyStatFieldOfst; + + /* Double talk behavior field offset. */ + tOCT6100_TLV_OFFSET DoubleTalkBehaviorFieldOfst; + + /* Idle code detection field offset. */ + tOCT6100_TLV_OFFSET IdleCodeDetectionFieldOfst; + + /* TSI memory mapping information.*/ + UINT32 ulNumTsiEntries; + + /*-----------------------------------------------------------------------------*/ + +} tOCT6100_API_MEMORY_MAP, *tPOCT6100_API_MEMORY_MAP; + +typedef struct _OCT6100_API_SOFT_BUFS_ +{ + /* To avoid compilation errors. */ + UINT32 ulDummyVariable; + + /* Tone events buffer pointers. */ + UINT32 ulToneEventBufferWritePtr; + UINT32 ulToneEventBufferReadPtr; + UINT32 ulToneEventBufferSize; + UINT32 ulToneEventBufferMemOfst; + UINT32 ulToneEventBufferOverflowCnt; + + /* Playout events buffer pointers. */ + UINT32 ulBufPlayoutEventBufferWritePtr; + UINT32 ulBufPlayoutEventBufferReadPtr; + UINT32 ulBufPlayoutEventBufferSize; + UINT32 ulBufPlayoutEventBufferMemOfst; + UINT32 ulBufPlayoutEventBufferOverflowCnt; + +} tOCT6100_API_SOFT_BUFS, *tPOCT6100_API_SOFT_BUFS; + +typedef struct _OCT6100_API_IMAGE_REGION_ +{ + UINT32 ulPart1Size; + UINT32 ulPart2Size; + UINT32 ulClockInfo; + + UINT32 ulReserved; + + UINT32 ulPart1BaseAddress; + UINT32 ulPart2BaseAddress; + +} tOCT6100_API_IMAGE_REGION, *tPOCT6100_API_IMAGE_REGION; + +typedef struct _OCT6100_API_IMAGE_INFO_ +{ + UINT8 fBufferPlayout; + UINT8 fAdaptiveNoiseReduction; + UINT8 fRinDcOffsetRemoval; + UINT8 fSinDcOffsetRemoval; + + UINT8 fRinAutoLevelControl; + UINT8 fSoutAutoLevelControl; + UINT8 fRinHighLevelCompensation; + UINT8 fSoutHighLevelCompensation; + + UINT8 fAlcHlcStatus; + UINT8 fComfortNoise; + UINT8 fNlpControl; + UINT8 fSilenceSuppression; + + UINT8 fToneDisabler; + UINT8 fTailDisplacement; + UINT8 fPerChannelTailDisplacement; + UINT8 fAcousticEcho; + + UINT8 fAecEnabled; + UINT8 fToneRemoval; + UINT8 fDefaultErl; + UINT8 fMaxEchoPoint; + + UINT8 fNonLinearityBehaviorA; + UINT8 fNonLinearityBehaviorB; + UINT8 fAecDefaultErl; + UINT8 fAdpcm; + + UINT8 fConferencing; + UINT8 fConferencingNoiseReduction; + UINT8 fMusicProtection; + UINT8 fDominantSpeakerEnabled; + + UINT8 fAftControl; + UINT8 fSinVoiceDetectedStat; + UINT8 fRinAppliedGainStat; + UINT8 fSoutAppliedGainStat; + + UINT8 fListenerEnhancement; + UINT8 fRoutNoiseReduction; + UINT8 fRinMute; + UINT8 fSinMute; + + UINT8 fAnrSnrEnhancement; + UINT8 fAnrVoiceNoiseSegregation; + UINT8 fRinBufferPlayoutHardSkip; + UINT8 fSoutBufferPlayoutHardSkip; + + UINT16 usMaxNumberOfChannels; + UINT8 fPerChannelTailLength; + UINT8 fToneDisablerVqeActivationDelay; + + UINT32 ulToneProfileNumber; + + UINT16 usMaxTailDisplacement; + UINT16 usMaxTailLength; + + UINT8 byNumToneDetectors; + UINT8 byMaxNumberPlayoutEvents; + + UINT8 fAfTailDisplacement; + UINT8 fAecTailLength; + + UINT8 fMusicProtectionConfiguration; + UINT8 byImageType; + + UINT8 fBufferPlayoutSkipInEvents; + UINT8 fSoutNoiseBleaching; + + UINT8 fRinEnergyStat; + UINT8 fSoutEnergyStat; + + UINT8 fDoubleTalkBehavior; + UINT8 fDoubleTalkBehaviorFieldOfst; + + UINT8 fIdleCodeDetection; + UINT8 fIdleCodeDetectionConfiguration; + + UINT8 fSinLevel; + + + + UINT8 szVersionNumber[ cOCT6100_VERSION_NUMBER_MAX_SIZE ]; + UINT32 ulBuildId; + + tOCT6100_TLV_TONE_INFO aToneInfo[ cOCT6100_MAX_TONE_EVENT ]; + +} tOCT6100_API_IMAGE_INFO, *tPOCT6100_API_IMAGE_INFO; + +typedef struct _OCT6100_API_MIXER_ +{ + /* Pointer to the various event region. */ + UINT16 usFirstSoutCopyEventPtr; + UINT16 usLastSoutCopyEventPtr; + + UINT16 usFirstBridgeEventPtr; + UINT16 usLastBridgeEventPtr; + + UINT16 usFirstSinCopyEventPtr; + UINT16 usLastSinCopyEventPtr; + + /* Recording event info. */ + UINT16 usRecordCopyEventIndex; + UINT16 usRecordSinEventIndex; + +} tOCT6100_API_MIXER, tPOCT6100_API_MIXER; + + +typedef struct _OCT6100_API_BUFFER_PLAYOUT_MALLOC_INFO_ +{ + /* Next node to be checked for free memory. */ + UINT32 ulRovingNode; + + /* First unused node in the unused list. */ + UINT32 ulFirstUnusedNode; + + /* Last unused node in the unused list. */ + UINT32 ulLastUnusedNode; + + /* Count of unused nodes. */ + UINT32 ulUnusedNodeCnt; + +} tOCT6100_API_BUFFER_PLAYOUT_MALLOC_INFO, *tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_INFO; + + + + +#endif /* __OCT6100_CHIP_OPEN_INST_H__ */ diff --git a/include/oct6100api/oct6100_chip_open_priv.h b/include/oct6100api/oct6100_chip_open_priv.h new file mode 100644 index 0000000..a8259f0 --- /dev/null +++ b/include/oct6100api/oct6100_chip_open_priv.h @@ -0,0 +1,242 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_open_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_chip_open.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_chip_open_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 56 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHIP_OPEN_PRIV_H__ +#define __OCT6100_CHIP_OPEN_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_INSTANCE_SIZES_ +{ + /* Each of the following elements indicates the size of the instance memory */ + /* needed by the corresponding API module. All sizes are in bytes. */ + UINT32 ulChannelList; + UINT32 ulChannelAlloc; + + UINT32 ulTsiCnctList; + UINT32 ulTsiCnctAlloc; + + UINT32 ulMixerEventList; + UINT32 ulMixerEventAlloc; + + UINT32 ulBiDirChannelList; + UINT32 ulBiDirChannelAlloc; + + UINT32 ulAdpcmChannelList; + UINT32 ulAdpcmChannelAlloc; + + UINT32 ulSoftBufPlayoutEventsBuffer; + + UINT32 ulCopyEventList; + UINT32 ulCopyEventAlloc; + + UINT32 ulConfBridgeList; + UINT32 ulConfBridgeAlloc; + + UINT32 ulFlexConfParticipantsList; + UINT32 ulFlexConfParticipantsAlloc; + + UINT32 ulPlayoutBufList; + UINT32 ulPlayoutBufAlloc; + UINT32 ulPlayoutBufMemoryNodeList; + + + + UINT32 ulSoftToneEventsBuffer; + + UINT32 ulPhasingTsstList; + UINT32 ulPhasingTsstAlloc; + + UINT32 ulConversionMemoryAlloc; + + UINT32 ulTsiMemoryAlloc; + UINT32 ulTsstAlloc; + + UINT32 ulTsstEntryList; + UINT32 ulTsstEntryAlloc; + + UINT32 ulRemoteDebugList; + UINT32 ulRemoteDebugTree; + UINT32 ulRemoteDebugPktCache; + UINT32 ulRemoteDebugDataBuf; + + /* Memory consumed by static members of API instance. */ + UINT32 ulApiInstStatic; + + /* Total memory size for API instance. */ + UINT32 ulApiInstTotal; + +} tOCT6100_API_INSTANCE_SIZES, *tPOCT6100_API_INSTANCE_SIZES; + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiCheckChipConfiguration( + IN tPOCT6100_CHIP_OPEN f_pOpenChip ); + +static UINT32 Oct6100ApiCopyChipConfiguration( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHIP_OPEN f_pOpenChip ); + +static UINT32 Oct6100ApiInitializeMiscellaneousVariables( + IN OUT tPOCT6100_INSTANCE_API f_pInstance ); + +static UINT32 Oct6100ApiCalculateInstanceSizes( + IN OUT tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstanceSizes ); + +static UINT32 Oct6100ApiAllocateInstanceMemory( + IN OUT tPOCT6100_INSTANCE_API f_pInstance, + IN tPOCT6100_API_INSTANCE_SIZES f_pInstanceSizes ); + +static UINT32 Oct6100ApiInitializeInstanceMemory( + IN OUT tPOCT6100_INSTANCE_API f_pInstance ); + +static UINT32 Oct6100ApiGetChipRevisionNum( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100ApiMapExternalMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiDecodeKeyAndBist( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiBootFc2Pll( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiProgramFc1Pll( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiBootFc1Pll( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100ApiWriteH100Registers( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiExternalMemoryBist( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiExternalMemoryInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiLoadImage( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiCpuRegisterBist( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiBootSdram( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiEnableClocks( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiProgramNLP( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiSetH100Register( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiWriteMiscellaneousRegisters( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT16 Oct6100ApiGenerateNumber( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulIndex, + IN UINT32 f_ulDataMask ); + +static UINT32 Oct6100ApiRandomMemoryWrite( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulMemBase, + IN UINT32 f_ulMemSize, + IN UINT32 f_ulNumDataBits, + IN UINT32 f_ulNumAccesses, + IN UINT32 f_ulErrorCode ); + +static UINT32 Oct6100ApiUserIoTest( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiCreateSerializeObjects( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulUserChipId ); + +static UINT32 Oct6100ApiDestroySerializeObjects( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiRunEgo( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN BOOL f_fStoreFlag, + IN UINT32 f_ulNumEntry, + OUT PUINT32 f_aulEntry ); + +static UINT32 Oct6100ApiCreateEgoEntry( + IN OUT UINT32 f_ulExternalAddress, + IN UINT32 f_ulInternalAddress, + IN UINT32 f_ulNumBytes, + IN UINT32 f_aulEntry[ 2 ] ); + + + + + +static UINT32 Oct6100ApiInitChannels( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiInitMixer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiInitRecordResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100FreeResourcesSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_FREE_RESOURCES f_pFreeResources ); + +UINT32 Oct6100ProductionBistSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_PRODUCTION_BIST f_pProductionBist ); + +static UINT32 Oct6100ApiProductionCrc( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN PUINT32 f_pulMessage, + IN UINT32 f_ulMessageLength, + OUT PUINT32 f_pulCrcResult ); + +static UINT32 Oct6100ApiInitToneInfo( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); +#endif /* __OCT6100_CHIP_OPEN_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_chip_open_pub.h b/include/oct6100api/oct6100_chip_open_pub.h new file mode 100644 index 0000000..ef4151f --- /dev/null +++ b/include/oct6100api/oct6100_chip_open_pub.h @@ -0,0 +1,222 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_open_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_chip_open.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_chip_open_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 48 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHIP_OPEN_PUB_H__ +#define __OCT6100_CHIP_OPEN_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_CHIP_OPEN_ +{ + UINT32 ulUserChipId; + BOOL fMultiProcessSystem; + PVOID pProcessContext; + + UINT32 ulMaxRwAccesses; + + PUINT8 pbyImageFile; /* Byte pointer to the image file to be uploaded into the chip. */ + UINT32 ulImageSize; /* Size of the image file (in bytes). */ + + UINT32 ulMemClkFreq; /* 10 - 133.3 MHz. */ + UINT32 ulUpclkFreq; /* 1 - 66.6 MHz. */ + BOOL fEnableMemClkOut; + + UINT32 ulMemoryType; /* SDRAM or DDR type external memory. */ + UINT32 ulNumMemoryChips; /* Number of memory chips present. */ + UINT32 ulMemoryChipSize; /* The size of the memory chips. */ + + UINT32 ulTailDisplacement; /* Tail displacement supported by the chip. */ + + BOOL fEnableAcousticEcho;/* Acoustic echo cancellation enabled. */ + + /* Resource allocation parameters. */ + UINT32 ulMaxChannels; + UINT32 ulMaxTsiCncts; + UINT32 ulMaxBiDirChannels; + UINT32 ulMaxConfBridges; + UINT32 ulMaxFlexibleConfParticipants; + UINT32 ulMaxPlayoutBuffers; + + + UINT32 ulMaxPhasingTssts; + UINT32 ulMaxAdpcmChannels; + BOOL fUseSynchTimestamp; + UINT32 aulTimestampTimeslots[ 4 ]; + UINT32 aulTimestampStreams[ 4 ]; + UINT32 ulInterruptPolarity; + tOCT6100_INTERRUPT_CONFIGURE InterruptConfig; + + UINT32 aulTdmStreamFreqs[ cOCT6100_TDM_STREAM_MAX_GROUPS ]; + UINT32 ulMaxTdmStreams; + UINT32 ulTdmSampling; + + BOOL fEnableFastH100Mode; + + UINT32 ulSoftToneEventsBufSize; /* In events. */ + BOOL fEnableExtToneDetection; + + + UINT32 ulSoftBufferPlayoutEventsBufSize; /* In events. */ + UINT32 ulMaxRemoteDebugSessions; + + BOOL fEnableChannelRecording; + + BOOL fEnableProductionBist; + UINT32 ulNumProductionBistLoops; + +} tOCT6100_CHIP_OPEN, *tPOCT6100_CHIP_OPEN; + +typedef struct _OCT6100_GET_INSTANCE_SIZE_ +{ + UINT32 ulApiInstanceSize; + +} tOCT6100_GET_INSTANCE_SIZE, *tPOCT6100_GET_INSTANCE_SIZE; + +typedef struct _OCT6100_CHIP_CLOSE_ +{ + UINT32 ulDummyVariable; + +} tOCT6100_CHIP_CLOSE, *tPOCT6100_CHIP_CLOSE; + +typedef struct _OCT6100_CREATE_LOCAL_INSTANCE_ +{ + tPOCT6100_INSTANCE_API pApiInstShared; + tPOCT6100_INSTANCE_API pApiInstLocal; + PVOID pProcessContext; + UINT32 ulUserChipId; + +} tOCT6100_CREATE_LOCAL_INSTANCE, *tPOCT6100_CREATE_LOCAL_INSTANCE; + +typedef struct _OCT6100_DESTROY_LOCAL_INSTANCE_ +{ + UINT32 ulDummy; + +} tOCT6100_DESTROY_LOCAL_INSTANCE, *tPOCT6100_DESTROY_LOCAL_INSTANCE; + +typedef struct _OCT6100_GET_HW_REVISION_ +{ + UINT32 ulUserChipId; + PVOID pProcessContext; + UINT32 ulRevisionNum; + +} tOCT6100_GET_HW_REVISION, *tPOCT6100_GET_HW_REVISION; + +typedef struct _OCT6100_FREE_RESOURCES_ +{ + BOOL fFreeTsiConnections; + BOOL fFreeConferenceBridges; + BOOL fFreePlayoutBuffers; + BOOL fFreePhasingTssts; + BOOL fFreeAdpcmChannels; + +} tOCT6100_FREE_RESOURCES, *tPOCT6100_FREE_RESOURCES; + +typedef struct _OCT6100_PRODUCTION_BIST_ +{ + UINT32 ulCurrentAddress; + UINT32 ulCurrentLoop; + UINT32 ulCurrentTest; + UINT32 ulBistStatus; + UINT32 ulFailedAddress; + UINT32 ulReadValue; + UINT32 ulExpectedValue; + +} tOCT6100_PRODUCTION_BIST, *tPOCT6100_PRODUCTION_BIST; + +typedef struct _OCT6100_API_GET_VERSION_ +{ + UINT8 achApiVersion[ cOCT6100_API_VERSION_STRING_LENGTH ]; + +} tOCT6100_API_GET_VERSION, *tPOCT6100_API_GET_VERSION; + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ChipOpenDef( + OUT tPOCT6100_CHIP_OPEN f_pChipOpen ); +static UINT32 Oct6100ChipOpen( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHIP_OPEN f_pChipOpen ); + +static UINT32 Oct6100ChipCloseDef( + OUT tPOCT6100_CHIP_CLOSE f_pChipClose ); +static UINT32 Oct6100ChipClose( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHIP_CLOSE f_pChipClose ); + +static UINT32 Oct6100GetInstanceSizeDef( + OUT tPOCT6100_GET_INSTANCE_SIZE f_pInstanceSize ); +static UINT32 Oct6100GetInstanceSize( + IN OUT tPOCT6100_CHIP_OPEN f_pChipOpen, + IN OUT tPOCT6100_GET_INSTANCE_SIZE f_pInstanceSize ); + +UINT32 Oct6100CreateLocalInstanceDef( + OUT tPOCT6100_CREATE_LOCAL_INSTANCE f_pCreateLocal ); +UINT32 Oct6100CreateLocalInstance( + IN OUT tPOCT6100_CREATE_LOCAL_INSTANCE f_pCreateLocal ); + +UINT32 Oct6100DestroyLocalInstanceDef( + OUT tPOCT6100_DESTROY_LOCAL_INSTANCE f_pDestroyLocal ); +UINT32 Oct6100DestroyLocalInstance( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_DESTROY_LOCAL_INSTANCE f_pDestroyLocal ); + +UINT32 Oct6100ApiGetVersionDef( + OUT tPOCT6100_API_GET_VERSION f_pApiGetVersion ); +UINT32 Oct6100ApiGetVersion( + IN OUT tPOCT6100_API_GET_VERSION f_pApiGetVersion ); + +UINT32 Oct6100GetHwRevisionDef( + OUT tPOCT6100_GET_HW_REVISION f_pRevision ); +UINT32 Oct6100GetHwRevision( + IN OUT tPOCT6100_GET_HW_REVISION f_pRevision ); + +UINT32 Oct6100FreeResourcesDef( + OUT tPOCT6100_FREE_RESOURCES f_pFreeResources ); +UINT32 Oct6100FreeResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_FREE_RESOURCES f_pFreeResources ); + +UINT32 Oct6100ProductionBistDef( + OUT tPOCT6100_PRODUCTION_BIST f_pProductionBist ); +UINT32 Oct6100ProductionBist( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_PRODUCTION_BIST f_pProductionBist ); + +#endif /* __OCT6100_CHIP_OPEN_PUB_H__ */ diff --git a/include/oct6100api/oct6100_chip_stats_inst.h b/include/oct6100api/oct6100_chip_stats_inst.h new file mode 100644 index 0000000..1c4156b --- /dev/null +++ b/include/oct6100api/oct6100_chip_stats_inst.h @@ -0,0 +1,84 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_stats_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_chip_stats.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_chip_stats_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 21 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHIP_STATS_INST_H__ +#define __OCT6100_CHIP_STATS_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_CHIP_ERROR_STATS_ +{ + UINT8 fFatalChipError; + + UINT32 ulInternalReadTimeoutCnt; + UINT32 ulSdramRefreshTooLateCnt; + UINT32 ulPllJitterErrorCnt; + + /* Internal tone detector error counter. */ + UINT32 ulToneDetectorErrorCnt; + + UINT32 ulOverflowToneEventsCnt; + + UINT32 ulH100OutOfSyncCnt; + UINT32 ulH100ClkABadCnt; + UINT32 ulH100ClkBBadCnt; + UINT32 ulH100FrameABadCnt; + + + +} tOCT6100_API_CHIP_ERROR_STATS, *tPOCT6100_API_CHIP_ERROR_STATS; + +typedef struct _OCT6100_API_CHIP_STATS_ +{ + UINT16 usNumberChannels; + UINT16 usNumberBiDirChannels; + UINT16 usNumberTsiCncts; + UINT16 usNumberConfBridges; + UINT16 usNumberPlayoutBuffers; + UINT16 usNumEcChanUsingMixer; + + UINT32 ulPlayoutMemUsed; + UINT16 usNumberActiveBufPlayoutPorts; + + UINT16 usNumberPhasingTssts; + UINT16 usNumberAdpcmChans; + +} tOCT6100_API_CHIP_STATS, *tPOCT6100_API_CHIP_STATS; + +#endif /* __OCT6100_CHIP_STATS_INST_H__ */ diff --git a/include/oct6100api/oct6100_chip_stats_priv.h b/include/oct6100api/oct6100_chip_stats_priv.h new file mode 100644 index 0000000..936b0ee --- /dev/null +++ b/include/oct6100api/oct6100_chip_stats_priv.h @@ -0,0 +1,55 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_stats_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_chip_stats.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_chip_stats_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 8 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHIP_STATS_PRIV_H__ +#define __OCT6100_CHIP_STATS_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiChipStatsSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100ChipGetStatsSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT tPOCT6100_CHIP_STATS f_pChipStats ); + +#endif /* __OCT6100_CHIP_STATS_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_chip_stats_pub.h b/include/oct6100api/oct6100_chip_stats_pub.h new file mode 100644 index 0000000..57add0e --- /dev/null +++ b/include/oct6100api/oct6100_chip_stats_pub.h @@ -0,0 +1,149 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_stats_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_chip_stats.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_chip_stats_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 55 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CHIP_STATS_PUB_H__ +#define __OCT6100_CHIP_STATS_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_CHIP_STATS_ +{ + BOOL fResetChipStats; + + UINT32 ulNumberChannels; + UINT32 ulNumberTsiCncts; + UINT32 ulNumberConfBridges; + UINT32 ulNumberPlayoutBuffers; + UINT32 ulPlayoutFreeMemSize; + UINT32 ulNumberPhasingTssts; + UINT32 ulNumberAdpcmChannels; + + UINT32 ulH100OutOfSynchCount; + UINT32 ulH100ClockABadCount; + UINT32 ulH100FrameABadCount; + UINT32 ulH100ClockBBadCount; + + UINT32 ulInternalReadTimeoutCount; + UINT32 ulSdramRefreshTooLateCount; + UINT32 ulPllJitterErrorCount; + + UINT32 ulOverflowToneEventsCount; + UINT32 ulSoftOverflowToneEventsCount; + + UINT32 ulSoftOverflowBufferPlayoutEventsCount; + +} tOCT6100_CHIP_STATS, *tPOCT6100_CHIP_STATS; + +typedef struct _OCT6100_CHIP_TONE_INFO_ +{ + UINT32 ulToneID; + UINT32 ulDetectionPort; + + UINT8 aszToneName[ cOCT6100_TLV_MAX_TONE_NAME_SIZE ]; + +} tOCT6100_CHIP_TONE_INFO, *tPOCT6100_CHIP_TONE_INFO; + +typedef struct _OCT6100_CHIP_IMAGE_INFO_ +{ + BOOL fBufferPlayout; + BOOL fAdaptiveNoiseReduction; + BOOL fSoutNoiseBleaching; + BOOL fAutoLevelControl; + BOOL fHighLevelCompensation; + BOOL fSilenceSuppression; + + BOOL fAdpcm; + BOOL fConferencing; + BOOL fConferencingNoiseReduction; + BOOL fDominantSpeaker; + + BOOL fAcousticEcho; + BOOL fAecTailLength; + BOOL fToneRemoval; + + BOOL fDefaultErl; + BOOL fNonLinearityBehaviorA; + BOOL fNonLinearityBehaviorB; + BOOL fPerChannelTailDisplacement; + BOOL fPerChannelTailLength; + BOOL fListenerEnhancement; + BOOL fRoutNoiseReduction; + BOOL fAnrSnrEnhancement; + BOOL fAnrVoiceNoiseSegregation; + BOOL fToneDisablerVqeActivationDelay; + BOOL fMusicProtection; + BOOL fDoubleTalkBehavior; + BOOL fIdleCodeDetection; + BOOL fSinLevel; + + UINT32 ulMaxChannels; + UINT32 ulNumTonesAvailable; + UINT32 ulToneProfileNumber; + UINT32 ulMaxTailDisplacement; + UINT32 ulMaxTailLength; + UINT32 ulDebugEventSize; + UINT32 ulMaxPlayoutEvents; + + UINT32 ulImageType; + + UINT8 szVersionNumber[ cOCT6100_VERSION_NUMBER_MAX_SIZE ]; + UINT32 ulBuildId; + + tOCT6100_CHIP_TONE_INFO aToneInfo[ cOCT6100_MAX_TONE_EVENT ]; + +} tOCT6100_CHIP_IMAGE_INFO, *tPOCT6100_CHIP_IMAGE_INFO; + + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100ChipGetStatsDef( + OUT tPOCT6100_CHIP_STATS f_pChipStats ); + +UINT32 Oct6100ChipGetStats( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_CHIP_STATS f_pChipStats ); + +UINT32 Oct6100ChipGetImageInfoDef( + OUT tPOCT6100_CHIP_IMAGE_INFO f_pChipImageInfo ); + +UINT32 Oct6100ChipGetImageInfo( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + OUT tPOCT6100_CHIP_IMAGE_INFO f_pChipImageInfo ); + +#endif /* __OCT6100_CHIP_STATS_PUB_H__ */ diff --git a/include/oct6100api/oct6100_conf_bridge_inst.h b/include/oct6100api/oct6100_conf_bridge_inst.h new file mode 100644 index 0000000..ebe2da3 --- /dev/null +++ b/include/oct6100api/oct6100_conf_bridge_inst.h @@ -0,0 +1,104 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_conf_bridge_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_conf_bridge.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_conf_bridge_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 19 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CONF_BRIDGE_INST_H__ +#define __OCT6100_CONF_BRIDGE_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_CONF_BRIDGE_ +{ + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Entry counter for the resources. */ + UINT8 byEntryOpenCnt; + + /* Next bridge pointer. */ + UINT16 usNextBridgePtr; + + /* Previous bridge pointer. */ + UINT16 usPrevBridgePtr; + + /* Number of clients connected to the bridge. */ + UINT16 usNumClients; + + /* Store the index of the load event, to diffentiate him form the accumulate. */ + UINT16 usLoadIndex; + + /* Pointer to the first bridge events.*/ + UINT16 usFirstLoadEventPtr; + UINT16 usFirstSubStoreEventPtr; + UINT16 usLastSubStoreEventPtr; + + /* Pointer to the silence load event, if it exists. */ + UINT16 usSilenceLoadEventPtr; + + /* Flag specifying whether the dominant speaker is set or not. */ + UINT16 usDominantSpeakerChanIndex; + UINT8 fDominantSpeakerSet; + + /* Flag specifying if this is flexible conferencing bridge. */ + UINT8 fFlexibleConferencing; + + /* Number of clients being tapped. */ + UINT16 usNumTappedClients; + +} tOCT6100_API_CONF_BRIDGE, *tPOCT6100_API_CONF_BRIDGE; + +typedef struct _OCT6100_API_FLEX_CONF_PARTICIPANT_ +{ + /* Input port of the conferencing for this participant. */ + UINT32 ulInputPort; + + /* Whether the flexible mixer has been created. */ + UINT8 fFlexibleMixerCreated; + + /* Listener mask ( who can hear us ). */ + UINT32 ulListenerMask; + + /* Our index in the listener mask. */ + UINT32 ulListenerMaskIndex; + + /* Mixer event indexes for this participant's mixer. */ + UINT16 ausLoadOrAccumulateEventIndex[ cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE ]; + +} tOCT6100_API_FLEX_CONF_PARTICIPANT, *tPOCT6100_API_FLEX_CONF_PARTICIPANT; + +#endif /* __OCT6100_CONF_BRIDGE_INST_H__ */ diff --git a/include/oct6100api/oct6100_conf_bridge_priv.h b/include/oct6100api/oct6100_conf_bridge_priv.h new file mode 100644 index 0000000..764e56d --- /dev/null +++ b/include/oct6100api/oct6100_conf_bridge_priv.h @@ -0,0 +1,318 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_conf_bridge_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_conf_bridge.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_conf_bridge_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 29 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CONF_BRIDGE_PRIV_H__ +#define __OCT6100_CONF_BRIDGE_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +#define mOCT6100_GET_CONF_BRIDGE_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_CONF_BRIDGE )(( PVOID )pSharedInfo + pSharedInfo->ulConfBridgeListOfst); + +#define mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_CONF_BRIDGE )(( PVOID )pSharedInfo + pSharedInfo->ulConfBridgeListOfst)) + ulIndex; + +#define mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulConfBridgeAllocOfst); + +#define mOCT6100_GET_FLEX_CONF_PARTICIPANT_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_FLEX_CONF_PARTICIPANT )(( PVOID )pSharedInfo + pSharedInfo->ulFlexConfParticipantListOfst); + +#define mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_FLEX_CONF_PARTICIPANT )(( PVOID )pSharedInfo + pSharedInfo->ulFlexConfParticipantListOfst)) + ulIndex; + +#define mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulFlexConfParticipantAllocOfst); + + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetConfBridgeSwSizes( + IN OUT tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiConfBridgeSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst ); + +UINT32 Oct6100ConfBridgeOpenSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen ); + +UINT32 Oct6100ApiCheckBridgeParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen ); + +UINT32 Oct6100ApiReserveBridgeResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + OUT PUINT16 f_pusBridgeIndex ); + +UINT32 Oct6100ApiUpdateBridgeEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen, + IN UINT16 f_usBridgeIndex ); + +static UINT32 Oct6100ConfBridgeCloseSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose ); + +static UINT32 Oct6100ApiAssertBridgeParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose, + OUT PUINT16 f_pusBridgeIndex ); + +static UINT32 Oct6100ApiReleaseBridgeResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex ); + +UINT32 Oct6100ConfBridgeChanAddSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_ADD f_pConfBridgeAdd ); + +UINT32 Oct6100ApiCheckBridgeAddParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_ADD f_pConfBridgeAdd, + OUT PUINT16 f_pusBridgeIndex, + OUT PUINT16 f_pusChannelIndex, + OUT PUINT8 f_pfMute, + OUT PUINT32 f_pulInputPort, + OUT PUINT8 f_pfFlexibleConfBridge, + OUT PUINT32 f_pulListenerMaskIndex, + OUT PUINT32 f_pulListenerMask, + OUT PUINT8 f_pfTap, + OUT PUINT16 f_pusTapChannelIndex ); + +UINT32 Oct6100ApiReserveBridgeAddResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChanIndex, + IN UINT32 f_ulInputPort, + IN UINT8 f_fFlexibleConfBridge, + IN UINT32 f_ulListenerMaskIndex, + IN UINT32 f_ulListenerMask, + IN UINT8 f_fTap, + OUT PUINT16 f_pusLoadEventIndex, + OUT PUINT16 f_pusSubStoreEventIndex, + OUT PUINT16 f_pusCopyEventIndex, + OUT PUINT16 f_pusTapBridgeIndex ); + +UINT32 Oct6100ApiBridgeEventAdd( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChannelIndex, + IN UINT8 f_fFlexibleConfBridge, + IN UINT16 f_usLoadEventIndex, + IN UINT16 f_usSubStoreEventIndex, + IN UINT16 f_usCopyEventIndex, + IN UINT32 f_ulInputPort, + IN UINT8 f_fMute, + IN UINT32 f_ulListenerMaskIndex, + IN UINT32 f_ulListenerMask, + IN UINT8 f_fTap, + IN UINT16 f_usTapBridgeIndex, + IN UINT16 f_usTapChanIndex ); + +UINT32 Oct6100ApiBridgeAddParticipantToChannel( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usSourceChannelIndex, + IN UINT16 f_usDestinationChannelIndex, + IN UINT16 f_usLoadOrAccumulateEventIndex, + IN UINT16 f_usStoreEventIndex, + IN UINT16 f_usCopyEventIndex, + IN UINT32 f_ulSourceInputPort, + IN UINT32 f_ulDestinationInputPort ); + +static UINT32 Oct6100ConfBridgeChanRemoveSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove ); + +static UINT32 Oct6100ApiCheckChanRemoveParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove, + OUT PUINT16 f_pusBridgeIndex, + OUT PUINT16 f_pusChannelIndex, + OUT PUINT8 f_pfFlexibleConfBridge, + OUT PUINT8 f_pfTap, + OUT PUINT16 f_pusLoadEventIndex, + OUT PUINT16 f_pusSubStoreEventIndex, + OUT PUINT16 f_pusCopyEventIndex ); + +static UINT32 Oct6100ApiReleaseChanEventResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChanIndex, + IN UINT8 f_fFlexibleConfBridge, + IN UINT16 f_usLoadEventIndex, + IN UINT16 f_usSubStoreEventIndex, + IN UINT16 f_usCopyEventIndex ); + +static UINT32 Oct6100ApiBridgeEventRemove ( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChannelIndex, + IN UINT8 f_fFlexibleConfBridge, + IN UINT16 f_usLoadEventIndex, + IN UINT16 f_usSubStoreEventIndex, + IN UINT16 f_usCopyEventIndex, + IN UINT8 f_fTap ); + +static UINT32 Oct6100ApiBridgeRemoveParticipantFromChannel( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usSourceChannelIndex, + IN UINT16 f_usDestinationChannelIndex, + IN UINT8 f_fRemovePermanently ); + +UINT32 Oct6100ConfBridgeChanMuteSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute ); + +UINT32 Oct6100ApiUpdateBridgeMuteResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usChanIndex, + IN UINT16 f_usLoadEventIndex, + IN UINT16 f_usSubStoreEventIndex, + IN UINT8 f_fFlexibleConfBridge ); + +UINT32 Oct6100ApiCheckBridgeMuteParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute, + OUT PUINT16 f_pusChannelIndex, + OUT PUINT16 f_pusLoadEventIndex, + OUT PUINT16 f_pusSubStoreEventIndex, + OUT PUINT8 f_pfFlexibleConfBridge ); + +UINT32 Oct6100ConfBridgeChanUnMuteSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute ); + +UINT32 Oct6100ApiCheckBridgeUnMuteParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute, + OUT PUINT16 f_pusChannelIndex, + OUT PUINT16 f_pusLoadEventIndex, + OUT PUINT16 f_pusSubStoreEventIndex, + OUT PUINT8 f_pfFlexibleConfBridge ); + +UINT32 Oct6100ApiUpdateBridgeUnMuteResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usChanIndex, + IN UINT16 f_usLoadEventIndex, + IN UINT16 f_usSubStoreEventIndex, + IN UINT8 f_fFlexibleConfBridge ); + +UINT32 Oct6100ConfBridgeDominantSpeakerSetSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker ); + +UINT32 Oct6100ApiCheckBridgeDominantSpeakerParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker, + OUT PUINT16 f_pusChannelIndex, + OUT PUINT16 f_pusBridgeIndex ); + +UINT32 Oct6100ApiUpdateBridgeDominantSpeakerResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usChanIndex, + IN UINT16 f_usBridgeIndex ); + +UINT32 Oct6100ConfBridgeMaskChangeSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange ); + +UINT32 Oct6100ApiCheckBridgeMaskChangeParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange, + OUT PUINT16 f_pusChannelIndex, + OUT PUINT16 f_pusBridgeIndex, + OUT PUINT32 f_pulNewParticipantMask ); + +UINT32 Oct6100ApiUpdateMaskModifyResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChanIndex, + IN UINT32 f_ulNewListenerMask ); + +UINT32 Oct6100ApiBridgeUpdateMask( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChanIndex, + IN UINT32 f_ulNewListenerMask ); + +UINT32 Oct6100ConfBridgeGetStatsSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_CONF_BRIDGE_STATS f_pConfBridgeStats ); + +UINT32 Oct6100ApiReserveBridgeEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + OUT PUINT16 f_pusConfBridgeIndex ); + +static UINT32 Oct6100ApiReleaseBridgeEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usConfBridgeIndex ); + +static UINT32 Oct6100ApiGetPrevLastSubStoreEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usBridgeFirstLoadEventPtr, + OUT PUINT16 f_pusLastSubStoreEventIndex ); + +static UINT32 Oct6100ApiGetPreviousEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usStartIndex, + IN UINT16 f_usSearchedIndex, + IN UINT16 f_usLoopCnt, + OUT PUINT16 f_pusPreviousIndex ); + +static UINT32 Oct6100ApiBridgeSetDominantSpeaker( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usChannelIndex, + IN UINT16 f_usDominantSpeakerIndex ); + +UINT32 Oct6100ApiReserveFlexConfParticipantEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + OUT PUINT16 f_pusParticipantIndex ); + +static UINT32 Oct6100ApiReleaseFlexConfParticipantEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN UINT16 f_usParticipantIndex ); + +#endif /* __OCT6100_CONF_BRIDGE_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_conf_bridge_pub.h b/include/oct6100api/oct6100_conf_bridge_pub.h new file mode 100644 index 0000000..5998be7 --- /dev/null +++ b/include/oct6100api/oct6100_conf_bridge_pub.h @@ -0,0 +1,169 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_conf_bridge_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_conf_bridge.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_conf_bridge_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 22 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_CONF_BRIDGE_PUB_H__ +#define __OCT6100_CONF_BRIDGE_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_CONF_BRIDGE_OPEN_ +{ + PUINT32 pulConfBridgeHndl; /* Handle returned when the bridge is opened. */ + BOOL fFlexibleConferencing; + +} tOCT6100_CONF_BRIDGE_OPEN, *tPOCT6100_CONF_BRIDGE_OPEN; + +typedef struct _OCT6100_CONF_BRIDGE_CLOSE_ +{ + UINT32 ulConfBridgeHndl; + +} tOCT6100_CONF_BRIDGE_CLOSE, *tPOCT6100_CONF_BRIDGE_CLOSE; + +typedef struct _OCT6100_CONF_BRIDGE_CHAN_ADD_ +{ + UINT32 ulConfBridgeHndl; + UINT32 ulChannelHndl; + UINT32 ulInputPort; + UINT32 ulListenerMaskIndex; + UINT32 ulListenerMask; + BOOL fMute; + UINT32 ulTappedChannelHndl; + +} tOCT6100_CONF_BRIDGE_CHAN_ADD, *tPOCT6100_CONF_BRIDGE_CHAN_ADD; + +typedef struct _OCT6100_CONF_BRIDGE_CHAN_REMOVE_ +{ + UINT32 ulConfBridgeHndl; + UINT32 ulChannelHndl; + BOOL fRemoveAll; + +} tOCT6100_CONF_BRIDGE_CHAN_REMOVE, *tPOCT6100_CONF_BRIDGE_CHAN_REMOVE; + +typedef struct _OCT6100_CONF_BRIDGE_CHAN_MUTE_ +{ + UINT32 ulChannelHndl; + +} tOCT6100_CONF_BRIDGE_CHAN_MUTE, *tPOCT6100_CONF_BRIDGE_CHAN_MUTE; + +typedef struct _OCT6100_CONF_BRIDGE_CHAN_UNMUTE_ +{ + UINT32 ulChannelHndl; + +} tOCT6100_CONF_BRIDGE_CHAN_UNMUTE, *tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE; + +typedef struct _OCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET_ +{ + UINT32 ulConfBridgeHndl; + UINT32 ulChannelHndl; + +} tOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET, *tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET; + +typedef struct _OCT6100_CONF_BRIDGE_MASK_CHANGE_ +{ + UINT32 ulChannelHndl; + UINT32 ulNewListenerMask; + +} tOCT6100_CONF_BRIDGE_MASK_CHANGE, *tPOCT6100_CONF_BRIDGE_MASK_CHANGE; + +typedef struct _OCT6100_CONF_BRIDGE_STATS_ +{ + UINT32 ulConfBridgeHndl; + UINT32 ulNumChannels; + UINT32 ulNumTappedChannels; + BOOL fFlexibleConferencing; + +} tOCT6100_CONF_BRIDGE_STATS, *tPOCT6100_CONF_BRIDGE_STATS; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100ConfBridgeOpenDef( + OUT tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen ); +UINT32 Oct6100ConfBridgeOpen( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen ); + +static UINT32 Oct6100ConfBridgeCloseDef( + OUT tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose ); +UINT32 Oct6100ConfBridgeClose( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose ); + +UINT32 Oct6100ConfBridgeChanAddDef( + OUT tPOCT6100_CONF_BRIDGE_CHAN_ADD f_pConfBridgeAdd ); +UINT32 Oct6100ConfBridgeChanAdd( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_CHAN_ADD f_pConfBridgeAdd ); + +static UINT32 Oct6100ConfBridgeChanRemoveDef( + OUT tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove ); +UINT32 Oct6100ConfBridgeChanRemove( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove ); + +UINT32 Oct6100ConfBridgeChanMuteDef( + OUT tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute ); +UINT32 Oct6100ConfBridgeChanMute( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute ); + +UINT32 Oct6100ConfBridgeChanUnMuteDef( + OUT tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute ); +UINT32 Oct6100ConfBridgeChanUnMute( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute ); + +UINT32 Oct6100ConfBridgeDominantSpeakerSetDef( + OUT tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker ); +UINT32 Oct6100ConfBridgeDominantSpeakerSet( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker ); + +UINT32 Oct6100ConfBridgeMaskChangeDef( + OUT tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange ); +UINT32 Oct6100ConfBridgeMaskChange( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange ); + +UINT32 Oct6100ConfBridgeGetStatsDef( + OUT tPOCT6100_CONF_BRIDGE_STATS f_pConfBridgeStats ); +UINT32 Oct6100ConfBridgeGetStats( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CONF_BRIDGE_STATS f_pConfBridgeStats ); + +#endif /* __OCT6100_CONF_BRIDGE_PUB_H__ */ diff --git a/include/oct6100api/oct6100_debug_inst.h b/include/oct6100api/oct6100_debug_inst.h new file mode 100644 index 0000000..7635411 --- /dev/null +++ b/include/oct6100api/oct6100_debug_inst.h @@ -0,0 +1,121 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_debug_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_debug.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_debug_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 9 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_DEBUG_INST_H__ +#define __OCT6100_DEBUG_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_DEBUG_ +{ + /* Information from the TLVs. */ + UINT32 ulDebugEventSize; + UINT32 ulMatrixBaseAddress; + UINT32 ulDebugChanStatsByteSize; + UINT32 ulDebugChanLiteStatsByteSize; + UINT32 ulHotChannelSelectBaseAddress; + UINT32 ulMatrixTimestampBaseAddress; + UINT32 ulAfWritePtrByteOffset; + UINT32 ulRecordedPcmEventByteSize; + UINT32 ulMatrixWpBaseAddress; + + /* Pouch counter presence in the image. */ + UINT8 fPouchCounter; + + /* Record channel indexes. */ + UINT16 usRecordMemIndex; + UINT16 usRecordChanIndex; + + UINT16 usRecordRinRoutTsiMemIndex; + UINT16 usRecordSinSoutTsiMemIndex; + + /* Debug channel information.*/ + UINT16 usCurrentDebugChanIndex; + + /* Matrix event mask. */ + UINT16 usMatrixCBMask; + + /* If data is being dumped now. */ + UINT8 fDebugDataBeingDumped; + + /* Index of the last event retrieved. */ + UINT16 usLastDebugEventIndex; + + /* Number of events to retrieve. */ + UINT16 usNumEvents; + + /* Chip debug event write ptr. */ + UINT16 usChipDebugEventWritePtr; + + /* Hot channel read data. */ + UINT16 ausHotChannelData[ 2 ]; + + /* Last PCM sample index. */ + UINT32 ulLastPcmSampleIndex; + + /* Last AF log read pointer. */ + UINT16 usLastAfLogReadPtr; + + /* AF log hardware write pointer. */ + UINT16 usAfLogWritePtr; + + /* Last tone event index retrieved. */ + UINT16 usLastToneEventIndex; + + /* Whether the image version string has been copied in the user buffer. */ + BOOL fImageVersionCopied; + + /* Whether the api version string has been copied in the user buffer. */ + BOOL fApiVersionCopied; + + /* Total number of bytes that will be returned for the current dump. */ + UINT32 ulDebugDataTotalNumBytes; + + /* Field to detect if the ISR is called present? */ + BOOL fIsIsrCalledField; + + /* Remaining number of bytes that will be returned for the current dump. */ + UINT32 ulDebugDataRemainingNumBytes; + + /* AF events control block size. */ + UINT32 ulAfEventCbByteSize; + +} tOCT6100_API_DEBUG, *tPOCT6100_API_DEBUG; + +#endif /* __OCT6100_DEBUG_INST_H__ */ diff --git a/include/oct6100api/oct6100_debug_priv.h b/include/oct6100api/oct6100_debug_priv.h new file mode 100644 index 0000000..a00e6d2 --- /dev/null +++ b/include/oct6100api/oct6100_debug_priv.h @@ -0,0 +1,58 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_debug_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_debug.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_debug_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 12 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_DEBUG_PRIV_H__ +#define __OCT6100_DEBUG_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + + +UINT32 Oct6100DebugSelectChannelSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan, + IN BOOL f_fCheckChannelRecording ); + +UINT32 Oct6100DebugGetDataSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_DEBUG_GET_DATA f_pGetData ); + +#endif /* __OCT6100_DEBUG_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_debug_pub.h b/include/oct6100api/oct6100_debug_pub.h new file mode 100644 index 0000000..fe61a5f --- /dev/null +++ b/include/oct6100api/oct6100_debug_pub.h @@ -0,0 +1,75 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_debug_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_debug.c. All elements defined in this file are for public + usage of the API. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 13 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_DEBUG_PUB_H__ +#define __OCT6100_DEBUG_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_DEBUG_SELECT_CHANNEL_ +{ + UINT32 ulChannelHndl; + +} tOCT6100_DEBUG_SELECT_CHANNEL, *tPOCT6100_DEBUG_SELECT_CHANNEL; + +typedef struct _OCT6100_DEBUG_GET_DATA_ +{ + UINT32 ulGetDataMode; + UINT32 ulRemainingNumBytes; + UINT32 ulTotalNumBytes; + UINT32 ulMaxBytes; + UINT32 ulValidNumBytes; + PUINT8 pbyData; + +} tOCT6100_DEBUG_GET_DATA, *tPOCT6100_DEBUG_GET_DATA; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100DebugSelectChannelDef( + OUT tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan ); +UINT32 Oct6100DebugSelectChannel( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan ); + +UINT32 Oct6100DebugGetDataDef( + OUT tPOCT6100_DEBUG_GET_DATA f_pGetData ); +UINT32 Oct6100DebugGetData( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_DEBUG_GET_DATA f_pGetData ); + +#endif /* __OCT6100_DEBUG_PUB_H__ */ diff --git a/include/oct6100api/oct6100_defines.h b/include/oct6100api/oct6100_defines.h new file mode 100644 index 0000000..67e8d2e --- /dev/null +++ b/include/oct6100api/oct6100_defines.h @@ -0,0 +1,642 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_defines.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + Header file containing all defines used throughout the API. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.7 + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 164 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_DEFINES_H__ +#define __OCT6100_DEFINES_H__ + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +/***************************** DEFINES *************************************/ + +/* 32-bits values. */ +#define cOCT6100_FFFFFFFF 0xFFFFFFFF +#define cOCT6100_FFFFFFFE 0xFFFFFFFE +#define cOCT6100_7FFFFFFF 0x7FFFFFFF + +/* 16-bits values. */ +#define cOCT6100_FFFD 0xFFFD +#define cOCT6100_FFFE 0xFFFE +#define cOCT6100_FFFF 0xFFFF +#define cOCT6100_7FFF 0x7FFF + +/* 8-bits values. */ +#define cOCT6100_FF 0xFF + +#define cOCT6100_CURRENT_VALUE cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_CHIP_ID cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_HANDLE cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_TIMESLOT cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_STREAM cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_VALUE cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_STAT cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_STAT_W cOCT6100_FFFF +#define cOCT6100_INVALID_PCM_LAW cOCT6100_FF +#define cOCT6100_INVALID_EVENT cOCT6100_FFFF +#define cOCT6100_INVALID_INDEX cOCT6100_FFFF +#define cOCT6100_INVALID_TONE cOCT6100_FFFFFFFF +#define cOCT6100_INVALID_PORT cOCT6100_FF + +#define cOCT6100_AUTO_SELECT cOCT6100_FFFFFFFE +#define cOCT6100_AUTO_SELECT_TAIL cOCT6100_FFFE + +#define cOCT6100_INVALID_BOOL 2 + +#define cOCT6100_KEEP_PREVIOUS_SETTING 0x70100000 + +#define cOCT6100_INVALID_SIGNED_STAT cOCT6100_7FFFFFFF +#define cOCT6100_INVALID_SIGNED_STAT_W cOCT6100_7FFF +#define cOCT6100_INVALID_ECHO_DELAY 0x400 + + + +#define cOCT6100_SIZE_128 128 +#define cOCT6100_SIZE_256 256 +#define cOCT6100_SIZE_512 512 +#define cOCT6100_SIZE_1K 1024 +#define cOCT6100_SIZE_2K 2048 +#define cOCT6100_SIZE_4K 4096 +#define cOCT6100_SIZE_8K 8192 +#define cOCT6100_SIZE_16K 16384 +#define cOCT6100_SIZE_32K 32768 +#define cOCT6100_SIZE_64K 65536 +#define cOCT6100_SIZE_128K 131072 +#define cOCT6100_SIZE_256K 262144 +#define cOCT6100_SIZE_512K 524288 +#define cOCT6100_SIZE_1M 1048576 +#define cOCT6100_SIZE_2M 2097152 +#define cOCT6100_SIZE_4M 4194304 +#define cOCT6100_SIZE_8M 8388608 +#define cOCT6100_SIZE_16M 16777216 +#define cOCT6100_SIZE_32M 33554432 +#define cOCT6100_SIZE_64M 67108864 +#define cOCT6100_SIZE_128M 134217728 +#define cOCT6100_SIZE_256M 268435456 +#define cOCT6100_SIZE_512M 536870912 +#define cOCT6100_SIZE_1G 1073741824 +#define cOCT6100_SIZE_2G 2147483648 + +#define cOCT6100_HNDL_TAG_MASK 0xFF000000 +#define cOCT6100_HNDL_INDEX_MASK 0x0000FFFF +#define cOCT6100_ENTRY_OPEN_CNT_MASK 0x000000FF +#define cOCT6100_ENTRY_OPEN_CNT_SHIFT 16 + +#define cOCT6100_HNDL_TAG_INVALID 0xFF000000 + +#define cOCT6100_HNDL_TAG_CHANNEL 0x01000000 +#define cOCT6100_HNDL_TAG_TSI_CNCT 0x02000000 +#define cOCT6100_HNDL_TAG_CONF_BRIDGE 0x03000000 +#define cOCT6100_HNDL_TAG_PHASING_TSST 0x04000000 +#define cOCT6100_HNDL_TAG_BIDIR_CHANNEL 0x05000000 +#define cOCT6100_HNDL_TAG_COPY_EVENT 0x06000000 +#define cOCT6100_HNDL_TAG_ADPCM_CHANNEL 0x07000000 + +#define cOCT6100_INVALID_HANDLE_TYPE cOCT6100_INVALID_VALUE + +#define cOCT6100_MEMORY_ROUND_SIZE 16 + +#define mOCT6100_ROUND_MEMORY_SIZE( ulMemorySize, ulTempVar ) \ + if ((ulTempVar = ulMemorySize % cOCT6100_MEMORY_ROUND_SIZE) != 0) \ + ulMemorySize += cOCT6100_MEMORY_ROUND_SIZE - ulTempVar; + +#define mOCT6100_ROUND_ADDRESS( ulAddress, ulBoundary, ulTempVar ) \ + if ((ulTempVar = ulAddress % ulBoundary) != 0) \ + ulAddress += ulBoundary - ulTempVar; + +#define cOCT6100_INTERNAL_CLOCK_SOURCE 0 +#define cOCT6100_EXTERNAL_CLOCK_SOURCE 1 + +#define cOCT6100_ACTIVE_HIGH_POLARITY 0 +#define cOCT6100_ACTIVE_LOW_POLARITY 1 + +#define cOCT6100_TDM_SAMPLE_AT_3_QUARTERS 0 +#define cOCT6100_TDM_SAMPLE_AT_RISING_EDGE 1 +#define cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE 2 + +#define cOCT6100_TDM_STREAM_FREQ_2MHZ 0 +#define cOCT6100_TDM_STREAM_FREQ_4MHZ 1 +#define cOCT6100_TDM_STREAM_FREQ_8MHZ 2 +#define cOCT6100_TDM_STREAM_FREQ_16MHZ 3 + +#define cOCT6100_TDM_STREAM_MAX_GROUPS 8 + +#define cOCT6100_PCM_U_LAW 0 +#define cOCT6100_PCM_A_LAW 1 +#define cOCT6100_PCM_UNCHANGED 2 +#define cOCT6100_ADPCM_ENCODED 3 + +#define cOCT6100_INTERRUPT_DISABLE 0 +#define cOCT6100_INTERRUPT_NO_TIMEOUT 1 +#define cOCT6100_INTERRUPT_TIMEOUT 2 + +#define cOCT6100_NUMBER_TSSTS_1 1 +#define cOCT6100_NUMBER_TSSTS_2 2 + +#define cOCT6100_G711_64KBPS 1 +#define cOCT6100_G726_40KBPS 2 +#define cOCT6100_G726_32KBPS 3 +#define cOCT6100_G726_24KBPS 4 +#define cOCT6100_G726_16KBPS 5 +#define cOCT6100_G727_40KBPS_4_1 6 +#define cOCT6100_G727_40KBPS_3_2 7 +#define cOCT6100_G727_40KBPS_2_3 8 +#define cOCT6100_G727_32KBPS_4_0 9 +#define cOCT6100_G727_32KBPS_3_1 10 +#define cOCT6100_G727_32KBPS_2_2 11 +#define cOCT6100_G727_24KBPS_3_0 12 +#define cOCT6100_G727_24KBPS_2_1 13 +#define cOCT6100_G727_16KBPS_2_0 14 +#define cOCT6100_G726_ENCODED 15 +#define cOCT6100_G711_G726_ENCODED 16 +#define cOCT6100_G711_G727_2C_ENCODED 17 +#define cOCT6100_G711_G727_3C_ENCODED 18 +#define cOCT6100_G711_G727_4C_ENCODED 19 +#define cOCT6100_G727_2C_ENCODED 20 +#define cOCT6100_G727_3C_ENCODED 21 +#define cOCT6100_G727_4C_ENCODED 22 + +#define cOCT6100_ADPCM_IN_HIGH_BITS 0 +#define cOCT6100_ADPCM_IN_LOW_BITS 1 + +/* The values of these defines must not change. */ +#define cOCT6100_H100_TRACKA 0 +#define cOCT6100_H100_TRACKB 1 +#define cOCT6100_H100_TRACKA_FALLBACKB 2 +#define cOCT6100_H100_TRACKB_FALLBACKA 3 +#define cOCT6100_H100_DISABLED 4 +#define cOCT6100_H100_MASTERA 5 +#define cOCT6100_H100_BACKUPA 6 +#define cOCT6100_H100_MASTERB 7 +#define cOCT6100_H100_BACKUPB 8 + +#define cOCT6100_FREE_TSST 0 +#define cOCT6100_RX_TSST 16 +#define cOCT6100_TX_TSST 32 + +#define cOCT6100_INTRPT_ACTIVE 0 +#define cOCT6100_INTRPT_WILL_TIMEOUT 1 +#define cOCT6100_INTRPT_IN_TIMEOUT 2 +#define cOCT6100_INTRPT_DISABLED 3 + +#define cOCT6100_EXTERNAL_MEM_BIST_TIMEOUT 1000000 + +/* Clocks defines */ +#define cOCT6100_UPCLK_FREQ_33_33_MHZ 33333333 +#define cOCT6100_UPCLK_FREQ_66_67_MHZ 66666667 + +#define cOCT6100_MCLK_FREQ_133_MHZ 133000000 +#define cOCT6100_MCLK_FREQ_125_MHZ 125000000 +#define cOCT6100_MCLK_FREQ_117_MHZ 117000000 +#define cOCT6100_MCLK_FREQ_108_MHZ 108000000 +#define cOCT6100_MCLK_FREQ_100_MHZ 100000000 +#define cOCT6100_MCLK_FREQ_92_MHZ 92000000 +#define cOCT6100_MCLK_FREQ_83_MHZ 83000000 +#define cOCT6100_MCLK_FREQ_75_MHZ 75000000 + +/* Tone buffer defines.*/ +#define cOCT6100_MAX_NUM_TONE_BUFFERS 1344 +#define cOCT6100_MAX_TONES_PER_CALL 32 + +/* Memory defines.*/ +#define cOCT6100_MEM_TYPE_SDR 0 +#define cOCT6100_MEM_TYPE_DDR 1 +#define cOCT6100_MEM_TYPE_SDR_PLL_BYPASS 2 + +#define cOCT6100_MEMORY_CHIP_SIZE_8MB cOCT6100_SIZE_8M +#define cOCT6100_MEMORY_CHIP_SIZE_16MB cOCT6100_SIZE_16M +#define cOCT6100_MEMORY_CHIP_SIZE_32MB cOCT6100_SIZE_32M +#define cOCT6100_MEMORY_CHIP_SIZE_64MB cOCT6100_SIZE_64M +#define cOCT6100_MEMORY_CHIP_SIZE_128MB cOCT6100_SIZE_128M + +#define cOCT6100_MAX_NUM_MEMORY_CHIP 2 + +#define cOCT6100_16MB_MEMORY_BANKS 0 +#define cOCT6100_32MB_MEMORY_BANKS 1 +#define cOCT6100_64MB_MEMORY_BANKS 2 +#define cOCT6100_128MB_MEMORY_BANKS 3 + +#define cOCT6100_1_MEMORY_BANKS 0 +#define cOCT6100_2_MEMORY_BANKS 1 +#define cOCT6100_3_MEMORY_BANKS 2 +#define cOCT6100_4_MEMORY_BANKS 3 + +/* Chip open defines.*/ +#define cOCT6100_INTERNAL_TONE_ARRAY_SIZE 256 /* in words.*/ +#define cOCT6100_INTERNAL_SUPER_ARRAY_SIZE 1024 /* in words.*/ + +/* Internal memory mapping.*/ + +/*=======================================================================*/ +#define cOCT6100_TSST_CONTROL_MEM_BASE 0x26000 + +#define cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE 2 /* Each entries are 2 bytes.*/ +#define cOCT6100_TSST_CONTROL_MEM_INPUT_TSST 0x0800 +#define cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST 0x2000 + +#define cOCT6100_TSST_CONTROL_MEM_PCM_LAW_OFFSET 12 +#define cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET 11 +#define cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET 12 + +#define cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK 0x7FF + +#define cOCT6100_TSST_CONTROL_PHASING_TSST_BASE_ENTRY 1344 +#define cOCT6100_TSST_CONTROL_TIMESTAMP_BASE_ENTRY 1516 + +/*=======================================================================*/ +#define cOCT6100_CONVERSION_CONTROL_MEM_BASE 0x28000 + +/* Each entries are 8 bytes but an 8 bytes mixer entry is located inbetween each entry.*/ +#define cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE 16 +#define cOCT6100_CONVERSION_CONTROL_MEM_ENCODER 0x0000 +#define cOCT6100_CONVERSION_CONTROL_MEM_DECODER 0x8000 +#define cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY 0x8000 +#define cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR 0x8000 + +#define cOCT6100_CONVERSION_CONTROL_MEM_PHASE_OFFSET 12 +#define cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET 9 +#define cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET 11 +#define cOCT6100_CONVERSION_CONTROL_MEM_LAW_OFFSET 8 +#define cOCT6100_CONVERSION_CONTROL_MEM_SIL_SUP_OFFSET 8 + +#define cOCT6100_CONVERSION_CONTROL_PHASE_SIZE_BASE_ADD 0x5400 + +/*=======================================================================*/ +#define cOCT6100_MIXER_CONTROL_MEM_BASE 0x28008 + +/* Each entries are 8 bytes but an 8 bytes mixer entry is located inbetween each entry.*/ +#define cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE 16 +#define cOCT6100_MIXER_CONTROL_MEM_SUB_STORE 0xA000 +#define cOCT6100_MIXER_CONTROL_MEM_STORE 0x8000 +#define cOCT6100_MIXER_CONTROL_MEM_LOAD 0x4000 +#define cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE 0x6000 +#define cOCT6100_MIXER_CONTROL_MEM_COPY 0x2000 +#define cOCT6100_MIXER_CONTROL_MEM_NO_OP 0x0000 + +#define cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET 11 + +#define cOCT6100_MIXER_HEAD_NODE 0 +#define cOCT6100_MIXER_TAIL_NODE 1 +#define cOCT6100_MIXER_RECORD_COPY_NODE 2 + +/*=======================================================================*/ +#define cOCT6100_ECHO_CONTROL_MEM_BASE 0x14000 + +#define cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE 4 /* Each entries are 8 bytes.*/ +#define cOCT6100_ECHO_CONTROL_MEM_ACTIVATE_ENTRY 0x8000 +#define cOCT6100_ECHO_CONTROL_MEM_EXTERNAL_AF_CTRL 0x2000 + +#define cOCT6100_ECHO_CONTROL_MEM_DEBUG_OFFSET 14 +#define cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL 14 +#define cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET 12 +#define cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET 11 + +#define cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK 0x7FF + +/*=======================================================================*/ +#define cOCT6100_ST_CONTROL_MEM_BASE 0x2000000 + +#define cOCT6100_ST_CONTROL_MEM_ENTRY_SIZE 16 /* Each entries are 8 bytes.*/ + +/*=======================================================================*/ +#define cOCT6100_PART1_BASE 0x00080000 +#define cOCT6100_PART1_CPU_LSU_CB_BASE cOCT6100_PART1_BASE+0x0000E3C0 /* 8 * 8 = 64 bytes */ +#define cOCT6100_PART1_HW_LSU_CB_BASE cOCT6100_PART1_BASE+0x0000E400 /* 8 * 128 = 1K byte */ +#define cOCT6100_PART1_END_STATICS_BASE cOCT6100_PART1_BASE+0x0000E9F0 /* 912 bytes available for your viewing pleasure. */ +#define cOCT6100_PART1_API_SCRATCH_PAD cOCT6100_PART1_END_STATICS_BASE+4+(12*8) +#define cOCT6100_PART1_EGO_REG cOCT6100_PART1_BASE+0x0007FF00 + +/* External Memory mapping. */ +#define cOCT6100_EXTERNAL_MEM_BLOCK_SIZE 1024 +#define cOCT6100_EXTERNAL_MEM_BASE_ADDRESS 0x08000000 + + +#define cOCT6100_TLV_BASE ( 0x00016000 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) +#define cOCT6100_CHANNEL_ROOT_BASE ( 0x00020000 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) +#define cOCT6100_PGSP_EVENT_OUT_BASE ( 0x002C0000 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) +#define cOCT6100_POUCH_BASE ( 0x002E0000 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) +#define cOCT6100_IMAGE_FILE_BASE ( 0x00300000 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) + +#define cOCT6100_CHANNEL_ROOT_SIZE 4096 +#define cOCT6100_CHANNEL_ROOT_TOTAL_SIZE ( 672 * cOCT6100_CHANNEL_ROOT_SIZE ) +#define cOCT6100_PGSP_EVENT_OUT_SIZE 131072 +#define cOCT6100_PGSP_TONE_EVENT_SIZE 0x40 +#define cOCT6100_IMAGE_FILE_SIZE 0x100000 + +#define cOCT6100_MATRIX_TIMESTAMP_DWORD_ADD cOCT6100_POUCH_BASE + 0x8 +#define cOCT6100_MATRIX_CHAN_SELECT_DWORD_ADD cOCT6100_POUCH_BASE + 0x14 +#define cOCT6100_MATRIX_WRITE_PTR_DWORD_ADD cOCT6100_POUCH_BASE + 0x4 +#define cOCT6100_MATRIX_PLL_JITTER_COUNT_ADD cOCT6100_POUCH_BASE + 0x1C +#define cOCT6100_MATRIX_DWORD_BASE cOCT6100_POUCH_BASE + 0xE0000 + +#define cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET 0x0000 + +#define cOCT6100_NUM_WORDS_PER_TONE_EVENT 32 +#define cOCT6100_NUM_PGSP_EVENT_OUT 2048 +#define cOCT6100_VALID_TONE_EVENT 0x8000 +#define cOCT6100_LOCAL_TIMESTAMP_INCREMENT 32 /* 4 ms increment. */ +#define cOCT6100_ABSOLUTE_MAX_NUM_PGSP_EVENT_OUT 65535 +#define cOCT6100_MIN_TIMESLOT_FOR_TIMESTAMP 5 + + +/*=======================================================================*/ +#define cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET 0x0C +#define cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET 0x10 +#define cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET 0x14 +#define cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET 0x18 +#define cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET 0x1C + +#define cOCT6100_GSC_BUFFER_LAW_OFFSET 27 + +/*=======================================================================*/ +#define cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET 0x00000 +#define cOCT6100_CH_MAIN_TONE_EVENT_OFFSET 0x00488 + +/*=======================================================================*/ +#define cOCT6100_PLAYOUT_EVENT_REPEAT_OFFSET 31 +#define cOCT6100_PLAYOUT_EVENT_LAW_OFFSET 30 +#define cOCT6100_PLAYOUT_EVENT_MIX_OFFSET 28 +#define cOCT6100_PLAYOUT_EVENT_LOOP_TIMES_OFFSET 27 +#define cOCT6100_PLAYOUT_EVENT_GAIN_OFFSET 24 + +#define cOCT6100_PLAYOUT_EVENT_MEM_SIZE 16 + +/* Image related defines.*/ +#define cOCT6100_MIN_IMAGE_SIZE 0x001000 +#define cOCT6100_MAX_IMAGE_SIZE 0x100000 +#define cOCT6100_MAX_IMAGE_REGION 60 +#define cOCT6100_IMAGE_AF_CST_OFFSET 0x1000; + +/* Max defines.*/ +#define cOCT6100_MAX_ECHO_CHANNELS 672 +#define cOCT6100_MAX_TSI_CNCTS 1530 +#define cOCT6100_MAX_CALLER_ID_PLAYOUT_BUFFERS ( 3328 + 6 ) +#define cOCT6100_MAX_PLAYOUT_BUFFERS ( 1344 + cOCT6100_MAX_CALLER_ID_PLAYOUT_BUFFERS ) +#define cOCT6100_MAX_CONF_BRIDGE 672 +#define cOCT6100_MAX_FLEX_CONF_PARTICIPANTS cOCT6100_MAX_ECHO_CHANNELS +#define cOCT6100_MAX_PHASING_TSST 16 +#define cOCT6100_MAX_ADPCM_CHANNELS 672 + +#define cOCT6100_NUM_TSI_B4_PHASING 1344 +#define cOCT6100_TOTAL_TSI_CONTROL_MEM_ENTRY 1534 +#define cOCT6100_MAX_TSI_CONTROL_MEM_ENTRY 1344 +#define cOCT6100_MAX_ECHO_CONTROL_MEM_ENTRY 672 +#define cOCT6100_MAX_TSI_B4_TIMESTAMP 172 +#define cOCT6100_TSI_MEM_FOR_TIMESTAMP 4 +#define cOCT6100_API_EXT_TONE_EXTRA_TSI 1533 + +/* Echo channel ports */ +#define cOCT6100_CHANNEL_PORT_RIN 0 +#define cOCT6100_CHANNEL_PORT_ROUT 1 +#define cOCT6100_CHANNEL_PORT_SIN 2 +#define cOCT6100_CHANNEL_PORT_SOUT 3 +#define cOCT6100_CHANNEL_PORT_ROUT_SOUT 4 + +#define cOCT6100_NO_ENCODING 10 +#define cOCT6100_NO_DECODING 11 + +/* Buffer playout defines */ +#define cOCT6100_NO_SKIP 0 +#define cOCT6100_BUFFER_PLAYOUT_MIN_SIZE 1024 +#define cOCT6100_DEFAULT_TIMESTAMP 0 +#define cOCT6100_MIXING_0_DB 0 +#define cOCT6100_MIXING_MINUS_6_DB 1 +#define cOCT6100_MIXING_MINUS_12_DB 2 +#define cOCT6100_MIXING_MUTE 3 +#define cOCT6100_PLAYOUT_GAIN 0x41000000 +#define cOCT6100_PLAYOUT_EVENT 1 +#define cOCT6100_MINIMUM_BUFFER_SIZE 64 +#define cOCT6100_BUFFER_SIZE_GRANULARITY 16 +#define cOCT6100_REPEAT_INFINITELY cOCT6100_INVALID_VALUE +#define cOCT6100_REPEAT_MAX 32767 +#define cOCT6100_SAMPLES_PER_MS 8 + +/* For the playout events. */ +#define cOCT6100_MAX_BUFFER_PLAYOUT_EVENT_PER_CALL 32 +#define cOCT6100_MIN_BUFFER_PLAYOUT_EVENT 128 +#define cOCT6100_MAX_BUFFER_PLAYOUT_EVENT 65535 +/* Event types */ +#define cOCT6100_BUFFER_PLAYOUT_EVENT_INVALID cOCT6100_INVALID_VALUE +#define cOCT6100_BUFFER_PLAYOUT_EVENT_STOP 1 + + +/* Phasing defines.*/ +#define cOCT6100_SINGLE_PHASING 0 +#define cOCT6100_DUAL_PHASING 1 +#define cOCT6100_NO_PHASING 2 + +/* Echo canceller mode.*/ +#define cOCT6100_ELECTRIC_EC 0 +#define cOCT6100_ELECTRIC_EC_DISPLACEMENT 1 +#define cOCT6100_ACCOUSTIC_ES 2 + +/* Echo control modes.*/ +#define cOCT6100_ECHO_OP_MODE_NORMAL 0 +#define cOCT6100_ECHO_OP_MODE_HT_FREEZE 1 +#define cOCT6100_ECHO_OP_MODE_HT_RESET 2 +#define cOCT6100_ECHO_OP_MODE_POWER_DOWN 3 +#define cOCT6100_ECHO_OP_MODE_EXTERNAL 4 +#define cOCT6100_ECHO_OP_MODE_NO_ECHO 5 +#define cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION 6 +#define cOCT6100_ECHO_OP_MODE_G169_ALC cOCT6100_ECHO_OP_MODE_NO_ECHO + +/* 2100 Hz disabling configuration. */ +#define cOCT6100_NEVER_DISABLED 0 +#define cOCT6100_G164_2100_HZ 1 +#define cOCT6100_G165_2100_HZ_WITH_PHASE_REV 2 + +/* TSST defines.*/ +#define cOCT6100_UNASSIGNED cOCT6100_FFFD + +#define cOCT6100_MAX_TSSTS 4096 +#define cOCT6100_TWO_TSSTS_INDEX_MASK 0x8000 +#define cOCT6100_TSST_INDEX_MASK 0x7FFF +#define cOCT6100_INPUT_TSST 0 +#define cOCT6100_OUTPUT_TSST 1 + +/* Conference bridges defines.*/ +#define cOCT6100_MAX_MIXER_EVENTS 1344 +#define cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE 32 +#define cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED 672 +#define cOCT6100_CONF_NO_DOMINANT_SPEAKER_HNDL cOCT6100_FFFFFFFE + +/* Conversion memory defines.*/ +#define cOCT6100_MAX_CONVERSION_MEMORY_BLOCKS 1344 + +/* Tone detection defines.*/ +#define cOCT6100_MAX_TONE_NUMBER 55 + +/* Register definition and address. */ +#define cOCT6100_TONE_EVENT_WRITE_PTR_REG 0x722 +#define cOCT6100_TONE_EVENT_READ_PTR_REG 0x720 + +/* Special tone IDs. */ + +/* System 5/7 Section */ +#define cOCT6100_TONE_SIN_SYSTEM7_2000 0x20000023 +#define cOCT6100_TONE_SIN_SYSTEM7_1780 0x20000024 +#define cOCT6100_CHIP_ID_REVISION_REG 0x17E + +/* BOOT type. */ +#define cOCT6100_AF_BOOT_TYPE 0x5 +#define cOCT6100_PRODUCTION_BOOT_TYPE 0x7 + +/* Interrupt register masks.*/ +#define cOCT6100_INTRPT_MASK_REG_102H 0x0001 +#define cOCT6100_INTRPT_MASK_REG_202H 0x1C01 +#define cOCT6100_INTRPT_MASK_REG_302H 0xF100 +#define cOCT6100_INTRPT_MASK_REG_502H 0x0002 +#define cOCT6100_INTRPT_MASK_REG_702H 0x0002 + +#define cOCT6100_DECODER_MEMORY_OFFSET 672 + +/* Debug defines.*/ +#define cOCT6100_DEBUG_MAX_READ_LENGTH 10240 +#define cOCT6100_DEBUG_SOUT_MAX_READ_LENGTH 2560 +#define cOCT6100_DEBUG_CHAN_RECORD_INDEX 64 +#define cOCT6100_DEBUG_RECORD_BUFFER_BYTE_SIZE 0x20000 +#define cOCT6100_DEBUG_RECORD_MATRIX_SIZE 0x8000 +#define cOCT6100_DEBUG_RECORD_READ_DATA_BYTE_SIZE 1024 +#define cOCT6100_DEBUG_RECORD_BLOCK_BYTE_SIZE 0x1000 + +/* Tone event defines.*/ +#define cOCT6100_MAX_TONE_EVENT 56 +#define cOCT6100_TONE_PRESENT 0 +#define cOCT6100_TONE_STOP 1 +#define cOCT6100_TONE_REFRESH 2 + +/* TLV defines.*/ +#define cOCT6100_TLV_MAX_ADDRESS 0x10000000 +#define cOCT6100_TLV_MAX_TONE_NAME_SIZE 64 + +#define cOCT6100_VERSION_NUMBER_MAX_SIZE 1016 + +/* Echo Tail defines.*/ +#define cOCT6100_TAIL_LENGTH_32MS 32 +#define cOCT6100_TAIL_LENGTH_64MS 64 +#define cOCT6100_TAIL_LENGTH_128MS 128 +#define cOCT6100_MAX_ECHO_TAIL_DISPLACEMENT 5600 /* In milliseconds */ + + + + + +/* Generic loop counter.*/ +#define cOCT6100_MAX_LOOP 0x2000 +/* CPU boot timeout counter. */ +#define cOCT6100_MAX_LOOP_CPU_TIMEOUT 0x20000 + +/* Automatic level control */ +#define cOCT6100_PASS_THROUGH_LEVEL_CONTROL 0x90 + +/* Channel stats debug info */ +#define cOCT6100_DEBUG_CHAN_STATS_EVENT_BYTE_SIZE 1024 +#define cOCT6100_DEBUG_CHAN_STATS_LITE_EVENT_BYTE_SIZE 720 + +/* Tone image info defines.*/ +#define cOCT6100_TONE_INFO_START_STRING "[ToneDetectorInfo]" +#define cOCT6100_TONE_INFO_STOP_STRING "[~ToneDetectorInfo]" +#define cOCT6100_TONE_INFO_EVENT_STRING "TONEEVENT=0x" + +#define cOCT6100_MAX_NLP_CONF_DWORD 20 + +/* Tail displacement info.*/ +#define cOCT6100_MAX_TAIL_DISPLACEMENT 896 + +/* Comfort noise define */ +#define cOCT6100_COMFORT_NOISE_NORMAL 0x0 +#define cOCT6100_COMFORT_NOISE_EXTENDED 0x3 +#define cOCT6100_COMFORT_NOISE_OFF 0x2 +#define cOCT6100_COMFORT_NOISE_FAST_LATCH 0x1 + +/* Mixer event type.*/ +#define cOCT6100_EVENT_TYPE_SOUT_COPY 0x0 +#define cOCT6100_EVENT_TYPE_SIN_COPY 0x1 + +/* Tone disabler status.*/ +#define cOCT6100_TONE_DISABLER_EC_ENABLED 0 +#define cOCT6100_TONE_DISABLER_EC_DISABLED 1 + +/* ADPCM Channel defines */ +#define cOCT6100_ADPCM_ENCODING 0 +#define cOCT6100_ADPCM_DECODING 1 + +/* Double talk behavior modes. */ +#define cOCT6100_DOUBLE_TALK_BEH_NORMAL 0x0 +#define cOCT6100_DOUBLE_TALK_BEH_LESS_AGGRESSIVE 0x1 + +/* Api Version string length.*/ +#define cOCT6100_API_VERSION_STRING_LENGTH 32 + +/* Extended tone detection information. */ +#define cOCT6100_API_EXT_TONE_DISABLED 0 +#define cOCT6100_API_EXT_TONE_SIN_PORT_MODE 1 +#define cOCT6100_API_EXT_TONE_RIN_PORT_MODE 2 + + + +/* Mute/UnMute defines. */ +#define cOCT6100_CHANNEL_MUTE_PORT_NONE 0x00 +#define cOCT6100_CHANNEL_MUTE_PORT_RIN 0x01 +#define cOCT6100_CHANNEL_MUTE_PORT_ROUT 0x02 +#define cOCT6100_CHANNEL_MUTE_PORT_SIN 0x04 +#define cOCT6100_CHANNEL_MUTE_PORT_SOUT 0x08 +#define cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES 0x10 + +/* Debug get data dump modes. */ +#define cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE 0x0 +#define cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE 0x1 +#define cOCT6100_DEBUG_GET_DATA_MODE_16S 0x2 +#define cOCT6100_DEBUG_GET_DATA_MODE_120S 0x3 + + + +#define cOCT6100_BIST_IN_PROGRESS 0x0 +#define cOCT6100_BIST_CONFIGURATION_FAILED 0x1 +#define cOCT6100_BIST_STATUS_CRC_FAILED 0x2 +#define cOCT6100_BIST_MEMORY_FAILED 0x3 +#define cOCT6100_BIST_SUCCESS 0x4 + +/* Image types. */ +#define cOCT6100_IMAGE_TYPE_WIRELINE 0x0 +#define cOCT6100_IMAGE_TYPE_COMBINED 0x1 + +/* Fatal general error types. */ +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_1 0x0001 +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_2 0x0002 +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_3 0x0004 +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_4 0x0008 +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_5 0x0010 +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_6 0x0020 +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_7 0x0040 +#define cOCT6100_FATAL_GENERAL_ERROR_TYPE_8 0x0080 + +#endif /* __OCT6100_DEFINES_H__ */ + diff --git a/include/oct6100api/oct6100_errors.h b/include/oct6100api/oct6100_errors.h new file mode 100644 index 0000000..787965c --- /dev/null +++ b/include/oct6100api/oct6100_errors.h @@ -0,0 +1,816 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_errors.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + Header file containing all defines used for error codes. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 189 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_ERRORS_H__ +#define __OCT6100_ERRORS_H__ + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +/***************************** DEFINES *************************************/ + +#define cOCT6100_ERR_OK 0x00000000 +#define cOCT6100_ERR_BASE 0x00100000 + +#define cOCT6100_NOT_SUPPORTED_BASE (0xFF000 + cOCT6100_ERR_BASE) + +/* Not supported defines. */ +#define cOCT6100_ERR_NOT_SUPPORTED_OPEN_DEBUG_RECORD (0x00000 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLP_CONTROL (0x00001 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_BKG_NOISE_FREEZE (0x00002 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_DC_OFFSET_REM (0x00003 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_DC_OFFSET_REM (0x00004 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC (0x00005 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC (0x00006 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR (0x00007 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_DISPLACEMENT (0x00008 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ENCODING (0x00009 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DECODING (0x0000A + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION (0x0000B + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO (0x0000C + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DEFAULT_ERL (0x0000D + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DOUBLE_TALK (0x0000E + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NON_LINEARITY_B (0x0000F + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_AEC_DEFAULT_ERL (0x00010 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP (0x00011 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_PER_CHAN_TAIL (0x00012 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIL_SUP (0x00013 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_OPEN_ACOUSTIC_ECHO (0x00014 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_OPEN_TAIL_DISPLACEMENT_VALUE (0x00015 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE (0x00016 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALE (0x00017 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLE (0x00018 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NR (0x00019 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_MUTE_FEATURES (0x0001A + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SNR_ENHANCEMENT (0x0001B + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SEGREGATION (0x0001C + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_OPEN_USE_SYNCH_TIMESTAMP (0x0001D + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_LENGTH (0x0001E + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY (0x0001F + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH (0x00020 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_MUSIC_PROTECTION (0x00021 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_DEBUG_DATA_MODE_120S (0x00022 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE (0x00023 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_DOUBLE_TALK_BEHAVIOR_MODE (0x00024 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION (0x00025 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG (0x00026 + cOCT6100_NOT_SUPPORTED_BASE) + +#define cOCT6100_ERR_NOT_SUPPORTED_BUFFER_PLAYOUT (0x00100 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_CNR (0x00101 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CONF_BRIDGE (0x00102 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CALLER_ID (0x00104 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NOISE_BLEACHING (0x00105 + cOCT6100_NOT_SUPPORTED_BASE) + +#define cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_REMOVAL (0x00300 + cOCT6100_NOT_SUPPORTED_BASE) +#define cOCT6100_ERR_NOT_SUPPORTED_DOMINANT_SPEAKER (0x00301 + cOCT6100_NOT_SUPPORTED_BASE) + + +#define cOCT6100_ERR_OPEN_INVALID_DEVICE (0x03000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INSUFFICIENT_EXTERNAL_MEMORY (0x03001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MEMORY_CHIP_SIZE (0x03002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_UP_CLK_FREQ (0x03003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_USER_CHIP_ID (0x03004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MULTI_PROCESS_SYSTEM (0x03005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_RW_ACCESSES (0x03006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_IMAGE_SIZE (0x03007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_IMAGE_FILE (0x03008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MEM_CLK_FREQ (0x03009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MEMORY_CHIPS_NUMBER (0x0300A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TOTAL_MEMORY_SIZE (0x0300B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_USE_SYNCH_TIMESTAMP (0x0300C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TIMESTAMP_STREAM (0x0300D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TIMESTAMP_TIMESLOT (0x0300E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TIMESTAMP_TSSTS (0x0300F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TDM_STREAM_FREQS (0x03010 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TDM_SAMPLING (0x03011 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_FAST_H100_MODE (0x03012 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS (0x03013 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_PLAYOUT_BUFFERS (0x03014 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_TSI_CNCTS (0x03015 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_PHASING_TSSTS (0x03016 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_EXTERNAL_MEM_BIST_FAILED (0x03017 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_EXTERNAL_MEM_BIST_TIMEOUT (0x03018 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_SDRAM_BIST_FAILED (0x03019 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_CORRUPTED_IMAGE (0x0301A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR (0x0301B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_SOFT_TONE_EVENT_SIZE (0x0301C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INTERRUPT_POLARITY (0x0301D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_FATAL_GENERAL_CONFIG (0x0301E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_REMOTE_DEBUG_SESSIONS (0x0301F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ENABLE_MEM_CLK_OUT (0x03020 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_TDM_STREAM (0x03021 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_CONF_BRIDGES (0x03022 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_OPEN_AF_CPU_TIMEOUT (0x03024 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MEMORY_TYPE (0x03025 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_FATAL_MEMORY_CONFIG (0x03026 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ERROR_MEMORY_CONFIG (0x03027 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_CONFIG (0x03028 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ERROR_H100_CONFIG (0x03029 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_FATAL_MEMORY_TIMEOUT (0x0302A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ERROR_MEMORY_TIMEOUT (0x0302B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_TIMEOUT (0x0302C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ERROR_H100_TIMEOUT (0x0302D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_IMAGE_WRITE_FAILED (0x0302E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_CRC_ERROR (0x0302F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_EGO_TIMEOUT (0x03030 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_SOFT_DEBUG_EVENT_BUF_SIZE (0x03031 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TONE_INFO_START_TAG_NOT_FOUND (0x03032 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TONE_INFO_STOP_TAG_NOT_FOUND (0x03033 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INVALID_TONE_EVENT (0x03034 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INVALID_TONE_NAME (0x03035 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INVALID_EVENT_NUMBER_SIZE (0x03036 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INTERNAL_MEMORY_BIST (0x03037 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_TAIL_DISPLACEMENT (0x03038 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_DEBUG_CHANNEL_RECORDING (0x03039 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_BIDIR_CHANNELS (0x0303A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_FUNCTIONAL_BIST_FAILED (0x0303C + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_OPEN_MAX_ADPCM_CHANNELS (0x0303E + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_OPEN_ENABLE_EXT_TONE_DETECTION (0x03040 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_SOFT_PLAYOUT_STOP_EVENT_SIZE (0x03041 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INVALID_FIRMWARE_OR_CAPACITY_PINS (0x03042 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ENABLE_ACOUSTIC_ECHO (0x03043 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_OPEN_USER_WRITE_BURST_FAILED (0x03045 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_USER_WRITE_SMEAR_FAILED (0x03046 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED (0x03047 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_MAX_FLEXIBLE_CONF_PARTICIPANTS (0x03048 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_OPEN_DEBUG_MEM_INDEX (0x03051 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_ENABLE_CALLER_ID (0x03052 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_CALLER_ID_PLAYOUT_BUFFERS (0x03053 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_OPEN_ENABLE_PRODUCTION_BIST (0x03055 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_PRODUCTION_BIST_ACTIVATED (0x03056 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_NUM_PRODUCTION_BIST_LOOPS (0x03057 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_PRODUCTION_BOOT_FAILED (0x03058 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_PRODUCTION_BIST_CONF_FAILED (0x03059 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_PRODUCTION_BIST_POUCH_ERROR (0x0305A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_OPEN_INVALID_TLV_LENGTH (0x0305B + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_TSI_CNCT_ALL_CHANNELS_ARE_OPENED (0x04000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_DISABLED (0x04001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE (0x04002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_INPUT_TIMESLOT (0x04003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_INPUT_STREAM (0x04004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_OUTPUT_TIMESLOT (0x04005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_OUTPUT_STREAM (0x04006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_INPUT_PCM_LAW (0x04007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_TIMESLOT (0x04008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_STREAM (0x04009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_TSST_RESERVED (0x0400A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_NOT_OPEN (0x0400B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_ASSOCIATED_TSST_RESERVED (0x0400C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSI_CNCT_NO_MORE_TSI_AVAILABLE (0x0400D + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED (0x05000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_PATTERN (0x05001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_TOO_SMALL (0x05002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_PCM_LAW (0x05003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ALL_BUFFERS_OPEN (0x05004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE (0x05005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX (0x05006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_NOT_OPEN (0x05007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ACTIVE_DEPENDENCIES (0x05008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID (0x05009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_NOT_OPEN (0x0500A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ROUT_PORT_PLAYING (0x0500B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_SOUT_PORT_PLAYING (0x0500C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_PORT_INVALID (0x0500D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT (0x0500E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL (0x0500F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ADD_REPEAT (0x05010 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ADD_MIXING (0x05011 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_STOP_CLEANLY (0x05012 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_NOT_STARTED (0x05013 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_WRITE_BYTE_COUNT (0x05015 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ECHO_OP_MODE (0x05016 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_BLOCK_LENGTH_INVALID (0x05017 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_BLOCK_OFFSET_INVALID (0x05018 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_RESET (0x05019 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_BUF_EMPTY (0x0501A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_MAX_EVENT (0x0501B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_DISABLED (0x0501C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_NOTIFY_ON_STOP (0x0501D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ALLOW_ACTIVE (0x0501E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_STILL_ACTIVE (0x0501F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_REPEAT_USED (0x05020 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_NLP_DISABLED (0x05021 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_MALLOC_ZERO (0x05022 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_NO_MEMORY (0x05023 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_MALLOC_POINT_NOT_FOUND (0x05024 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ADD_REPEAT_COUNT (0x05025 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_ADD_GAIN_DB (0x05026 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_BUFFER_PLAYOUT_LIST_EMPTY (0x05027 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_MEMORY_ALL_TSI_MEM_ENTRY_RESERVED (0x06000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MEMORY_ALL_ECHO_MEM_ENTRY_RESERVED (0x06002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MEMORY_EXTERNAL_MEMORY_FULL (0x06003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MEMORY_ALL_CONVERSION_MEM_ENTRY_RESERVED (0x06004 + cOCT6100_ERR_BASE) + + +#define cOCT6100_ERR_CHANNEL_DISABLED (0x07000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_INVALID_HANDLE (0x07001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_NUM_TSSTS (0x07002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_NUM_TSSTS (0x07003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_NUM_TSSTS (0x07004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_NUM_TSSTS (0x07005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_TIMESLOT (0x07006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_STREAM (0x07007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_TIMESLOT (0x07008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_STREAM (0x07009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT (0x0700A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_STREAM (0x0700B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT (0x0700C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_STREAM (0x0700D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_MISSING_TSST (0x07012 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIL_SUP_ENABLE (0x07013 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_PHASING_TYPE (0x07014 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE (0x07015 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_PHASING_TSST_NOT_OPEN (0x07016 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_PHASING_INVALID_PHASE (0x07017 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_DEBUG (0x07018 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ECHO_OP_MODE (0x0701F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_DC_OFFSET_REM (0x07020 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_DC_OFFSET_REM (0x07021 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL (0x07022 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL (0x07023 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL_GAIN (0x07024 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL_GAIN (0x07025 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_ADAPT_NOISE_REDUCTION (0x07026 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ALL_CHANNELS_ARE_OPENED (0x07027 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_NOT_OPEN (0x07029 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ADPCM_NIBBLE (0x0702A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_ADD_PORT (0x0702B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_ADD_TIMESLOT (0x0702C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_ADD_STREAM (0x0702D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_INVALID (0x0702E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_PCM_LAW (0x0702F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_PCM_LAW (0x07030 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_PCM_LAW (0x07031 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_PCM_LAW (0x07032 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_DECODER_PORT (0x07033 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ENCODER_PORT (0x07034 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_DECODING_RATE (0x07035 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ENCODING_RATE (0x07036 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ENABLE_NLP (0x07037 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_COMFORT_NOISE_MODE (0x07038 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED (0x07039 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIL_SUP_INVALID_ENCODER_PORT (0x0703A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_MODIFY_CODEC_CONFIG (0x0703B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_MODIFY_VQE_CONFIG (0x0703C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_MODIFY_TDM_CONFIG (0x0703D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_RIN_PORT_INVALID (0x0703E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_SIN_PORT_INVALID (0x0703F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_REMOVE_PORT (0x07041 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_REMOVE_TIMESLOT (0x07042 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_REMOVE_STREAM (0x07043 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_REMOVE_INVALID_TSST (0x07044 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_GET_STATS_MAX_BROADCAST_TSST (0x07045 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_TIMESLOT (0x07046 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_STREAM (0x07047 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_TIMESLOT (0x07048 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_STREAM (0x07049 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ACTIVE_DEPENDENCIES (0x0704A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE (0x0704B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TAIL_LENGTH (0x07053 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT (0x07054 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE (0x07058 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TSST_REMOVE_NO_BROADCAST_TSST (0x07059 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION (0x0705A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_STATS_RESET (0x0705B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ENABLE_TAIL_DISPLACEMENT (0x0705C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE (0x0705E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE (0x0705F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE (0x07060 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED (0x07061 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ALREADY_BIDIR (0x07062 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ALL_BIDIR_CHANNELS_ARE_OPENED (0x07063 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_FIRST_CHAN_SOUT_PORT (0x07064 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_FIRST_CHAN_RIN_PORT (0x07065 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SECOND_CHAN_SOUT_PORT (0x07066 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SECOND_CHAN_RIN_PORT (0x07067 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_BIDIR_PCM_LAW (0x07068 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_BIDIR_CHAN_NOT_OPEN (0x07069 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION (0x0706A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION (0x0706B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL (0x0706C + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_CHANNEL_NO_VALID_TDM_CLOCKS (0x0706E + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY (0x07073 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TONE_REMOVAL (0x07075 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO (0x07077 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_DEFAULT_ERL (0x07079 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_DOUBLE_TALK (0x0707B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_PHASE_TYPE_REQUIRED (0x0707C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED (0x0707D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ENABLE_EXT_TONE_DETECTION (0x0707E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT (0x0707F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DISABLED (0x07080 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_NON_LINEARITY_B (0x07082 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_FIRST_CHAN_IN_CONFERENCE (0x07083 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SECOND_CHAN_IN_CONFERENCE (0x07084 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT_CANNOT_MODIFY (0x07085 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_NON_LINEARITY_B_CANNOT_MODIFY (0x07086 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_NOT_ENABLED (0x07087 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_CHANNEL_BIDIR_DISABLED (0x0708B + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT_INVALID (0x0708D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_PER_CHAN_TAIL_DISPLACEMENT (0x0708E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_CONFERENCE_NOISE_REDUCTION (0x0708F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_AEC_DEFAULT_ERL (0x07092 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED (0x07093 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL (0x07094 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL (0x07095 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET (0x07096 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET (0x07097 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_MANUAL (0x07098 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_MANUAL (0x07099 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP (0x0709A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_HIGH_LEVEL_COMP (0x0709C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_MANUAL (0x0709D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_THRESHOLD (0x0709E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_MUTE_MASK (0x0709F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_MUTE_MASK_SIN (0x070A0 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ALE_RATIO (0x070A1 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_NLE_FLAG (0x070A2 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ALE_NLE_SIMULTANEOUSLY (0x070A3 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION (0x070A4 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ANR_SNR_ENHANCEMENT (0x070A5 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ANR_SEGREGATION (0x070A6 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_NLE_RATIO (0x070A7 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_APPLY_TO_ALL_CHANNELS (0x070A8 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_STREAM_UNASSIGN (0x070A9 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT_UNASSIGN (0x070AA + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_STREAM_UNASSIGN (0x070AB + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_RIN_TIMESLOT_UNASSIGN (0x070AC + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_STREAM_UNASSIGN (0x070AD + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT_UNASSIGN (0x070AE + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_STREAM_UNASSIGN (0x070AF + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SIN_TIMESLOT_UNASSIGN (0x070B0 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_DISABLE_TONE_DETECTION (0x070B1 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_STOP_BUFFER_PLAYOUT (0x070B2 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_REMOVE_CONF_BRIDGE_PARTICIPANT (0x070B3 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_REMOVE_BROADCAST_TSSTS (0x070B4 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY (0x070B5 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS (0x070B8 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH (0x070B9 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ENABLE_MUSIC_PROTECTION (0x070BA + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_TAIL_LENGTH_INVALID (0x070BB + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_SUM (0x070BC + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_DOUBLE_TALK_MODE (0x070BD + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING (0x070BE + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING_NR (0x070BF + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_ANR_CNR_SIMULTANEOUSLY (0x070C0 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_IDLE_CODE_DETECTION (0x070C1 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CHANNEL_MUST_ENABLE_TONE_DISABLER (0x070C2 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_PHASING_TSST_ALL_ENTRIES_ARE_OPENED (0x08000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_PHASING_TSST_DISABLED (0x08001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_PHASING_TSST_INVALID_HANDLE (0x08002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_PHASING_TSST_TIMESLOT (0x08003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_PHASING_TSST_STREAM (0x08004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_PHASING_TSST_PHASING_LENGTH (0x08005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_PHASING_TSST_NOT_OPEN (0x08006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_PHASING_TSST_ACTIVE_DEPENDENCIES (0x08007 + cOCT6100_ERR_BASE) + + +#define cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE (0x09000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_DISABLED (0x09001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN (0x09002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_ACTIVE_DEPENDENCIES (0x09003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_HANDLE (0x09004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND (0x09005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_ALL_BUFFERS_OPEN (0x09006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_REMOVE_INVALID_HANDLE (0x09007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHAN_NOT_ON_BRIDGE (0x09008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_MUTE (0x09009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_INVALID_HANDLE (0x0900A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_ALREADY_MUTED (0x0900B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_NOT_MUTED (0x0900C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_CODEC_ACTIVE (0x0900D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_MIXER_FULL (0x0900E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ALREADY_ON_BRIDGE (0x0900F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_REMOVE_ALL (0x09010 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_EXT_TONE_ENABLED (0x09011 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_INVALID_INPUT_PORT (0x09012 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_DOMINANT_SPEAKER (0x09013 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_BIDIR (0x09015 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CNR_MUST_BE_ENABLED (0x09016 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_NLP_MUST_BE_ENABLED (0x09017 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF (0x09018 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_PARTICIPANT_CNT (0x09019 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_LISTENER_MASK_INDEX (0x0901A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_ALL_BUFFERS_OPEN (0x0901B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_DISABLED (0x0901C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_LISTENER_INDEX_USED (0x0901D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_SIMPLE_BRIDGE (0x0901E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_COPY_EVENTS (0x0901F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_TAP_HANDLE (0x09020 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_TAP_NOT_SUPPORTED (0x09021 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_NOT_ON_BRIDGE (0x09022 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY (0x09023 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_NOT_ON_SAME_BRIDGE (0x09024 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_TAP_SOUT_ONLY (0x09025 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_ALREADY_TAPPED (0x09026 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_ALWAYS_MUTE (0x09027 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_CONF_BRIDGE_CHANNEL_LAW_CONVERSION (0x09028 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_MISC_CANNOT_ROUND_UP_NUMBER (0x0A000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MISC_ASCII_CONVERSION_FAILED (0x0A001 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID (0x0B000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TONE_DETECTION_CHANNEL_NOT_OPEN (0x0B001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TONE_DETECTION_TONE_NUMBER_INVALID (0x0B002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TONE_DETECTION_TONE_NOT_ACTIVATED (0x0B003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TONE_DETECTION_TONE_ACTIVATED (0x0B004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TONE_DETECTION_TONE_NOT_AVAILABLE (0x0B005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TONE_DETECTION_DISABLE_ALL (0x0B006 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_EVENTS_GET_TONE_RESET_BUFS (0x0C000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_EVENTS_TONE_BUF_EMPTY (0x0C001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_EVENTS_MAX_TONES (0x0C002 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_INTRPTS_RW_ERROR (0x0D000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_NOT_ACTIVE (0x0D001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_FATAL_GENERAL_CONFIG (0x0D002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_FATAL_MEMORY_CONFIG (0x0D003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_CONFIG (0x0D004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_CONFIG (0x0D005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_H100_ERROR_CONFIG (0x0D006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_FATAL_GENERAL_TIMEOUT (0x0D007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_FATAL_MEMORY_TIMEOUT (0x0D008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_TIMEOUT (0x0D009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_TIMEOUT (0x0D00A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_H100_ERROR_TIMEOUT (0x0D00B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT (0x0D00C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT (0x0D00D + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_TSST_TIMESLOT (0x0E000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSST_STREAM (0x0E001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSST_TSST_RESERVED (0x0E002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSST_ASSOCIATED_TSST_RESERVED (0x0E003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_TSST_ALL_TSSTS_ARE_OPENED (0x0E004 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_MULTIPROC_API_INST_SHARED (0x10000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MULTIPROC_API_INST_LOCAL (0x10001 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_DEBUG_CHANNEL_INVALID_HANDLE (0x11000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_PORT (0x11001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_READ_LENGTH (0x11002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_SOUT_READ_LENGTH (0x11003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_READ_DATA (0x11004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_GET_EVENTS_RESET_BUFS (0x11005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_GET_EVENTS_BUF_EMPTY (0x11006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RECORD_RIN_PTR_INVALID (0x11007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RECORD_SIN_PTR_INVALID (0x11008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RECORD_ROUT_PTR_INVALID (0x11009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RECORD_SOUT_PTR_INVALID (0x1100A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RECORD_RAW_DATA_PTR_INVALID (0x1100B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RECORD_LENGTH_INVALID (0x1100C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RECORD_NO_CHAN_SELECTED (0x1100D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_PCM_LAW (0x1100E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_CHANNEL_RECORDING_DISABLED (0x1100F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_GET_DATA_MAX_BYTES (0x11010 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_GET_DATA_PTR_INVALID (0x11011 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_RC_CHANNEL_RECORDING_DISABLED (0x11012 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_DEBUG_GET_DATA_MODE (0x11013 + cOCT6100_ERR_BASE) + + +#define cOCT6100_ERR_MIXER_ALL_COPY_EVENT_ENTRY_OPENED (0x12000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE (0x12001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE (0x12002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE (0x12003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_SOURCE_PORT (0x12004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_DESTINATION_PORT (0x12005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_EVENT_NOT_OPEN (0x12006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_SOURCE_ADPCM_RESOURCES_ACTIVATED (0x12007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_DEST_ADPCM_RESOURCES_ACTIVATED (0x12008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_MIXER_ALL_MIXER_EVENT_ENTRY_OPENED (0x12009 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_ADPCM_CHAN_DISABLED (0x13000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_INVALID_HANDLE (0x13001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_INPUT_TIMESLOT (0x13002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_INPUT_STREAM (0x13003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_OUTPUT_TIMESLOT (0x13004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_OUTPUT_STREAM (0x13005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_INPUT_NUM_TSSTS (0x13006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_OUTPUT_NUM_TSSTS (0x13007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_INPUT_PCM_LAW (0x13008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_MODE (0x13009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_ENCODING_RATE (0x1300A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_DECODING_RATE (0x1300B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_INCOMPATIBLE_NUM_TSSTS (0x1300C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_NO_MORE_TSI_AVAILABLE (0x1300D + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_OUTPUT_PCM_LAW (0x1300E + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_ADPCM_NIBBLE_POSITION (0x1300F + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_NOT_OPEN (0x13010 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_ADPCM_CHAN_ALL_ADPCM_CHAN_ARE_OPENED (0x13011 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_CHIP_STATS_RESET (0x14000 + cOCT6100_ERR_BASE) + + + +#define cOCT6100_ERR_PRODUCTION_BIST_DISABLED (0x16000 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_REMOTEDEBUG_RECEIVED_PKT_PAYLOAD (0x2C000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_RESPONSE_PKT_PAYLOAD (0x2C001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_RECEIVED_PKT_LENGTH (0x2C002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_RESPONSE_PKT_LENGTH (0x2C003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_ENDIAN_DETECTION_FIELD (0x2C004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_CHECKSUM (0x2C005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTE_DEBUG_PARSING_ERROR (0x2C006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_ALL_SESSIONS_OPEN (0x2C007 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_INVALID_PACKET (0x2C008 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_TRANSACTION_ANSWERED (0x2C009 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_INAVLID_SESSION_NUMBER (0x2C00A + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_INVALID_HOT_CHAN_INDEX (0x2C00B + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_DISABLED (0x2C00C + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_REMOTEDEBUG_INVALID_RPC_COMMAND_NUM (0x2C00D + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_TLV_TIMEOUT (0x31000 + cOCT6100_ERR_BASE) + +/* Fatal errors must always be greater or equal to 0xE000. */ +#define cOCT6100_ERR_FATAL (0xDE000 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_FATAL_DRIVER_WRITE_API (0xDE000 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_FATAL_DRIVER_WRITE_EXT_API (0xDE001 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_FATAL_DRIVER_WRITE_SMEAR_API (0xDE002 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_FATAL_DRIVER_WRITE_BURST_API (0xDE003 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_FATAL_DRIVER_READ_API (0xDE004 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_FATAL_DRIVER_READ_BURST_API (0xDE005 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_FATAL_DRIVER_READ_DEBUG_API (0xDE006 + cOCT6100_ERR_BASE) +#define cOCT6100_ERR_FATAL_DRIVER_WRITE_ARRAY_API (0xDE007 + cOCT6100_ERR_BASE) + +#define cOCT6100_FATAL_BASE (0xDF000 + cOCT6100_ERR_BASE) + +#define cOCT6100_ERR_FATAL_0 (0x00000 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_1 (0x00001 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_2 (0x00002 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_3 (0x00003 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_4 (0x00004 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_5 (0x00005 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_6 (0x00006 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_7 (0x00007 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_8 (0x00008 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_9 (0x00009 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A (0x0000A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B (0x0000B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C (0x0000C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D (0x0000D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E (0x0000E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_F (0x0000F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_10 (0x00010 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_11 (0x00011 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_12 (0x00012 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_13 (0x00013 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_14 (0x00014 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_15 (0x00015 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_16 (0x00016 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_17 (0x00017 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_18 (0x00018 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_19 (0x00019 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_1A (0x0001A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_1B (0x0001B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_1C (0x0001C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_1D (0x0001D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_1E (0x0001E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_1F (0x0001F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_20 (0x00020 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_21 (0x00021 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_22 (0x00022 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_23 (0x00023 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_24 (0x00024 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_25 (0x00025 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_26 (0x00026 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_27 (0x00027 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_28 (0x00028 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_29 (0x00029 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_2A (0x0002A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_2B (0x0002B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_2C (0x0002C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_2D (0x0002D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_2E (0x0002E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_2F (0x0002F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_30 (0x00030 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_31 (0x00031 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_32 (0x00032 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_33 (0x00033 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_34 (0x00034 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_35 (0x00035 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_36 (0x00036 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_37 (0x00037 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_38 (0x00038 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_39 (0x00039 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_3A (0x0003A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_3B (0x0003B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_3C (0x0003C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_3D (0x0003D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_3E (0x0003E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_3F (0x0003F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_40 (0x00040 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_41 (0x00041 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_42 (0x00042 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_43 (0x00043 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_44 (0x00044 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_45 (0x00045 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_46 (0x00046 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_47 (0x00047 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_48 (0x00048 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_49 (0x00049 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_4A (0x0004A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_4B (0x0004B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_4C (0x0004C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_4D (0x0004D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_4E (0x0004E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_4F (0x0004F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_50 (0x00050 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_51 (0x00051 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_52 (0x00052 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_53 (0x00053 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_54 (0x00054 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_55 (0x00055 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_56 (0x00056 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_57 (0x00057 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_58 (0x00058 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_59 (0x00059 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_5A (0x0005A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_5B (0x0005B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_5C (0x0005C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_5D (0x0005D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_5E (0x0005E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_5F (0x0005F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_60 (0x00060 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_61 (0x00061 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_62 (0x00062 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_63 (0x00063 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_64 (0x00064 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_65 (0x00065 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_66 (0x00066 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_67 (0x00067 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_68 (0x00068 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_69 (0x00069 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_6A (0x0006A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_6B (0x0006B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_6C (0x0006C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_6D (0x0006D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_6E (0x0006E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_6F (0x0006F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_70 (0x00070 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_71 (0x00071 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_72 (0x00072 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_73 (0x00073 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_74 (0x00074 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_75 (0x00075 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_76 (0x00076 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_77 (0x00077 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_78 (0x00078 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_79 (0x00079 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_7A (0x0007A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_7B (0x0007B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_7C (0x0007C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_7D (0x0007D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_7E (0x0007E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_7F (0x0007F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_80 (0x00080 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_81 (0x00081 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_82 (0x00082 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_83 (0x00083 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_84 (0x00084 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_85 (0x00085 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_86 (0x00086 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_87 (0x00087 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_88 (0x00088 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_89 (0x00089 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_8A (0x0008A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_8B (0x0008B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_8C (0x0008C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_8D (0x0008D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_8E (0x0008E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_8F (0x0008F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_90 (0x00090 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_91 (0x00091 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_92 (0x00092 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_93 (0x00093 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_94 (0x00094 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_95 (0x00095 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_96 (0x00096 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_97 (0x00097 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_98 (0x00098 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_99 (0x00099 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_9A (0x0009A + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_9B (0x0009B + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_9C (0x0009C + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_9D (0x0009D + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_9E (0x0009E + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_9F (0x0009F + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A0 (0x000A0 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A1 (0x000A1 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A2 (0x000A2 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A3 (0x000A3 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A4 (0x000A4 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A5 (0x000A5 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A6 (0x000A6 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A7 (0x000A7 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A8 (0x000A8 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_A9 (0x000A9 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_AA (0x000AA + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_AB (0x000AB + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_AC (0x000AC + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_AD (0x000AD + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_AE (0x000AE + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_AF (0x000AF + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B0 (0x000B0 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B1 (0x000B1 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B2 (0x000B2 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B3 (0x000B3 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B4 (0x000B4 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B5 (0x000B5 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B6 (0x000B6 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B7 (0x000B7 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B8 (0x000B8 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_B9 (0x000B9 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_BA (0x000BA + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_BB (0x000BB + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_BC (0x000BC + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_BD (0x000BD + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_BE (0x000BE + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_BF (0x000BF + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C0 (0x000C0 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C1 (0x000C1 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C2 (0x000C2 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C3 (0x000C3 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C4 (0x000C4 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C5 (0x000C5 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C6 (0x000C6 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C7 (0x000C7 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C8 (0x000C8 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_C9 (0x000C9 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_CA (0x000CA + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_CB (0x000CB + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_CC (0x000CC + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_CD (0x000CD + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_CE (0x000CE + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_CF (0x000CF + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D0 (0x000D0 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D1 (0x000D1 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D2 (0x000D2 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D3 (0x000D3 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D4 (0x000D4 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D5 (0x000D5 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D6 (0x000D6 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D7 (0x000D7 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D8 (0x000D8 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_D9 (0x000D9 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_DA (0x000DA + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_DB (0x000DB + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_DC (0x000DC + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_DD (0x000DD + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_DE (0x000DE + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_DF (0x000DF + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E0 (0x000E0 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E1 (0x000E1 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E2 (0x000E2 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E3 (0x000E3 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E4 (0x000E4 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E5 (0x000E5 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E6 (0x000E6 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E7 (0x000E7 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E8 (0x000E8 + cOCT6100_FATAL_BASE) +#define cOCT6100_ERR_FATAL_E9 (0x000E9 + cOCT6100_FATAL_BASE) + +#endif /* __OCT6100_ERRORS_H__ */ diff --git a/include/oct6100api/oct6100_events_inst.h b/include/oct6100api/oct6100_events_inst.h new file mode 100644 index 0000000..8d0a049 --- /dev/null +++ b/include/oct6100api/oct6100_events_inst.h @@ -0,0 +1,69 @@ +#ifndef cOCT6100_REMOVE_EVENTS +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_events_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_events.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_events_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 11 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_EVENTS_INST_H__ +#define __OCT6100_EVENTS_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_TONE_EVENT_ +{ + UINT32 ulChannelHandle; + UINT32 ulUserChanId; + UINT32 ulToneDetected; /* Tone number of the tone detected. */ + UINT32 ulTimestamp; + UINT32 ulEventType; + UINT32 ulExtToneDetectionPort; + +} tOCT6100_API_TONE_EVENT, *tPOCT6100_API_TONE_EVENT; + +typedef struct _OCT6100_API_BUFFER_PLAYOUT_EVENT_ +{ + UINT32 ulChannelHandle; + UINT32 ulUserChanId; + UINT32 ulChannelPort; + UINT32 ulTimestamp; + UINT32 ulUserEventId; + UINT32 ulEventType; + +} tOCT6100_API_BUFFER_PLAYOUT_EVENT, *tPOCT6100_API_BUFFER_PLAYOUT_EVENT; + +#endif /* __OCT6100_EVENTS_INST_H__ */ +#endif /* cOCT6100_REMOVE_EVENTS */ diff --git a/include/oct6100api/oct6100_events_priv.h b/include/oct6100api/oct6100_events_priv.h new file mode 100644 index 0000000..add4a68 --- /dev/null +++ b/include/oct6100api/oct6100_events_priv.h @@ -0,0 +1,84 @@ +#ifndef cOCT6100_REMOVE_EVENTS +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_events_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_events.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_events_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 12 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_EVENTS_PRIV_H__ +#define __OCT6100_EVENTS_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +#define mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftBuf ) \ + pSoftBuf = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->SoftBufs.ulToneEventBufferMemOfst ); + +#define mOCT6100_GET_BUFFER_PLAYOUT_EVENT_BUF_PNT( pSharedInfo, pSoftBuf ) \ + pSoftBuf = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferMemOfst ); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetEventsSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100EventGetToneSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_EVENT_GET_TONE f_pEventGetTone ); + +static UINT32 Oct6100ApiTransferToneEvents( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulResetBuf ); + + + +UINT32 Oct6100BufferPlayoutGetEventSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_GET_EVENT f_pBufPlayoutGetEvent ); + +static UINT32 Oct6100BufferPlayoutTransferEvents( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulResetBuf ); + +static UINT32 Oct6100BufferPlayoutCheckForSpecificEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulChannelPort, + IN BOOL f_fSaveToSoftBuffer, + OUT PBOOL f_pfEventDetected ); + +#endif /* __OCT6100_EVENTS_PRIV_H__ */ +#endif /* cOCT6100_REMOVE_EVENTS */ diff --git a/include/oct6100api/oct6100_events_pub.h b/include/oct6100api/oct6100_events_pub.h new file mode 100644 index 0000000..96fbc39 --- /dev/null +++ b/include/oct6100api/oct6100_events_pub.h @@ -0,0 +1,112 @@ +#ifndef cOCT6100_REMOVE_EVENTS +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_events_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_events.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_events_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 13 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_EVENTS_PUB_H__ +#define __OCT6100_EVENTS_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_TONE_EVENT_ +{ + UINT32 ulChannelHndl; + UINT32 ulUserChanId; + + UINT32 ulToneDetected; + + UINT32 ulTimestamp; + UINT32 ulEventType; + + UINT32 ulExtToneDetectionPort; + +} tOCT6100_TONE_EVENT, *tPOCT6100_TONE_EVENT; + +typedef struct _OCT6100_EVENT_GET_TONE_ +{ + BOOL fMoreEvents; + BOOL fResetBufs; + + UINT32 ulMaxToneEvent; + UINT32 ulNumValidToneEvent; + + tPOCT6100_TONE_EVENT pToneEvent; + +} tOCT6100_EVENT_GET_TONE, *tPOCT6100_EVENT_GET_TONE; + +typedef struct _OCT6100_BUFFER_PLAYOUT_EVENT_ +{ + UINT32 ulChannelHndl; + UINT32 ulUserChanId; + UINT32 ulChannelPort; + + UINT32 ulTimestamp; + + UINT32 ulUserEventId; + UINT32 ulEventType; + +} tOCT6100_BUFFER_PLAYOUT_EVENT, *tPOCT6100_BUFFER_PLAYOUT_EVENT; + +typedef struct _OCT6100_BUFFER_PLAYOUT_GET_EVENT_ +{ + BOOL fMoreEvents; + BOOL fResetBufs; + + UINT32 ulMaxEvent; + UINT32 ulNumValidEvent; + + tPOCT6100_BUFFER_PLAYOUT_EVENT pBufferPlayoutEvent; + +} tOCT6100_BUFFER_PLAYOUT_GET_EVENT, *tPOCT6100_BUFFER_PLAYOUT_GET_EVENT; + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100EventGetToneDef( + OUT tPOCT6100_EVENT_GET_TONE f_pEventGetTone ); +static UINT32 Oct6100EventGetTone( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_EVENT_GET_TONE f_pEventGetTone ); + +UINT32 Oct6100BufferPlayoutGetEventDef( + OUT tPOCT6100_BUFFER_PLAYOUT_GET_EVENT f_pBufPlayoutGetEvent ); +UINT32 Oct6100BufferPlayoutGetEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_BUFFER_PLAYOUT_GET_EVENT f_pBufPlayoutGetEvent ); + +#endif /* __OCT6100_EVENTS_PUB_H__ */ +#endif /* cOCT6100_REMOVE_EVENTS */ diff --git a/include/oct6100api/oct6100_interrupts_inst.h b/include/oct6100api/oct6100_interrupts_inst.h new file mode 100644 index 0000000..00bfd4c --- /dev/null +++ b/include/oct6100api/oct6100_interrupts_inst.h @@ -0,0 +1,134 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_interrupts_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_interrupts.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_interrupts_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 16 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_INTERRUPTS_INST_H__ +#define __OCT6100_INTERRUPTS_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_INTRPT_CONFIG_ +{ + /* The configuration of each group of interrupts. Each can have one of the + following values: + cOCT6100_INTRPT_DISABLE, + cOCT6100_INTRPT_NO_TIMEOUT, + cOCT6100_INTRPT_TIMEOUT. */ + UINT8 byFatalGeneralConfig; + UINT8 byFatalMemoryConfig; + UINT8 byErrorMemoryConfig; + UINT8 byErrorOverflowToneEventsConfig; + UINT8 byErrorH100Config; + + /* The timeout value for each interrupt group, if the corresponding + configuration variable is set to cOCT6100_INTRPT_TIMEOUT. This + value is kept in mclk cycles. */ + UINT32 ulFatalMemoryTimeoutMclk; + UINT32 ulErrorMemoryTimeoutMclk; + UINT32 ulErrorOverflowToneEventsTimeoutMclk; + UINT32 ulErrorH100TimeoutMclk; + +} tOCT6100_API_INTRPT_CONFIG, *tPOCT6100_API_INTRPT_CONFIG; + +typedef struct _OCT6100_API_INTRPT_MANAGE_ +{ + /* Number of mclk cycles in 1ms. */ + UINT32 ulNumMclkCyclesIn1Ms; + + /* Whether the mclk interrupt is active. */ + UINT8 fMclkIntrptActive; + UINT32 ulNextMclkIntrptTimeHigh; + UINT32 ulNextMclkIntrptTimeLow; + + /* Mclk time read from registers. */ + UINT32 ulRegMclkTimeHigh; + UINT32 ulRegMclkTimeLow; + + /* Used by the interrupt service routine. */ + UINT16 usRegister102h; + UINT16 usRegister202h; + UINT16 usRegister302h; + UINT16 usRegister502h; + UINT16 usRegister702h; + + /* The state of each interrupt group. Can be one of the following: + cOCT6100_INTRPT_ACTIVE, + cOCT6100_INTRPT_WILL_TIMEOUT, + cOCT6100_INTRPT_IN_TIMEOUT, + cOCT6100_INTRPT_WILL_DISABLED. */ + UINT16 byFatalGeneralState; + UINT16 byFatalMemoryState; + UINT16 byErrorMemoryState; + UINT16 byErrorOverflowToneEventsState; + UINT16 byErrorH100State; + + /* The time at which each disabled interrupt was disabled, in mclk cycles. */ + UINT32 ulFatalMemoryDisableMclkHigh; + UINT32 ulFatalMemoryDisableMclkLow; + UINT32 ulErrorMemoryDisableMclkHigh; + UINT32 ulErrorMemoryDisableMclkLow; + UINT32 ulErrorOverflowToneEventsDisableMclkHigh; + UINT32 ulErrorOverflowToneEventsDisableMclkLow; + UINT32 ulErrorH100DisableMclkHigh; + UINT32 ulErrorH100DisableMclkLow; + + /* The time at which each disabled interrupt group is to be reenabled, + in number of mclk cycles. */ + UINT32 ulFatalGeneralEnableMclkHigh; + UINT32 ulFatalGeneralEnableMclkLow; + UINT32 ulFatalMemoryEnableMclkHigh; + UINT32 ulFatalMemoryEnableMclkLow; + UINT32 ulErrorMemoryEnableMclkHigh; + UINT32 ulErrorMemoryEnableMclkLow; + UINT32 ulErrorOverflowToneEventsEnableMclkHigh; + UINT32 ulErrorOverflowToneEventsEnableMclkLow; + UINT32 ulErrorH100EnableMclkHigh; + UINT32 ulErrorH100EnableMclkLow; + + /* If this is set, buffer playout events are pending. */ + UINT8 fBufferPlayoutEventsPending; + /* If this is set, tone events are pending. */ + UINT8 fToneEventsPending; + + + + UINT8 fIsrCalled; + +} tOCT6100_API_INTRPT_MANAGE, *tPOCT6100_API_INTRPT_MANAGE; + +#endif /* __OCT6100_INTERRUPTS_INST_H__ */ diff --git a/include/oct6100api/oct6100_interrupts_priv.h b/include/oct6100api/oct6100_interrupts_priv.h new file mode 100644 index 0000000..f3d2d1d --- /dev/null +++ b/include/oct6100api/oct6100_interrupts_priv.h @@ -0,0 +1,155 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_interrupts_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_interrupts.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_interrupts_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 8 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_INTERRUPTS_PRIV_H__ +#define __OCT6100_INTERRUPTS_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +#define mOCT6100_GET_INTRPT_ENABLE_TIME( \ + ulRegMclkTimeHigh, \ + ulRegMclkTimeLow, \ + ulIntrptState, \ + ulIntrptEnableMclkHigh, \ + ulIntrptEnableMclkLow, \ + ulIntrptTimeoutMclk, \ + ulTimeDiff ) \ + if ( ulIntrptState == cOCT6100_INTRPT_WILL_TIMEOUT ) \ + { \ + ulIntrptEnableMclkLow = ulRegMclkTimeLow + ulIntrptTimeoutMclk; \ + if ( ulIntrptEnableMclkLow < ulRegMclkTimeLow ) \ + ulIntrptEnableMclkHigh = (ulRegMclkTimeHigh + 1) & 0xFF; \ + else \ + ulIntrptEnableMclkHigh = ulRegMclkTimeHigh; \ + \ + ulIntrptState = cOCT6100_INTRPT_IN_TIMEOUT; \ + } \ + \ + if ( ulIntrptEnableMclkLow < ulRegMclkTimeLow ) \ + { \ + ulTimeDiff = (cOCT6100_FFFFFFFF - ulRegMclkTimeLow - 1) + ulIntrptEnableMclkLow; \ + } \ + else \ + { \ + ulTimeDiff = ulIntrptEnableMclkLow - ulRegMclkTimeLow; \ + } + +#define mOCT6100_CHECK_INTRPT_TIMEOUT( \ + ulRegMclkTimePlus5MsHigh, \ + ulRegMclkTimePlus5MsLow, \ + ulIntrptDisableMclkHigh, \ + ulIntrptDisableMclkLow, \ + ulIntrptEnableMclkHigh, \ + ulIntrptEnableMclkLow, \ + ulIntrptState, \ + fIntrptChange ) \ + /* Branch depending on whether the disable time is lesser or greater than the timeout time. */ \ + if ( ulIntrptDisableMclkLow < ulIntrptEnableMclkLow ) \ + { \ + /* Disable period is over if mclk is greater than timeout time or less than disabled time. */ \ + if ( ulRegMclkTimePlus5MsLow > ulIntrptEnableMclkLow || \ + ulRegMclkTimePlus5MsLow < ulIntrptDisableMclkLow || \ + ulRegMclkTimePlus5MsHigh != ulIntrptEnableMclkHigh ) \ + { \ + fIntrptChange = TRUE; \ + ulIntrptState = cOCT6100_INTRPT_ACTIVE; \ + } \ + } \ + else \ + { \ + /* Disable period is over if mclk is lesser than disable time and greater than timeout. */ \ + if ( (ulRegMclkTimePlus5MsLow > ulIntrptEnableMclkLow && ulRegMclkTimePlus5MsLow < ulIntrptDisableMclkLow) || \ + (ulRegMclkTimePlus5MsHigh != ulIntrptDisableMclkHigh && ulRegMclkTimePlus5MsHigh != ulIntrptEnableMclkHigh) ) \ + { \ + fIntrptChange = TRUE; \ + ulIntrptState = cOCT6100_INTRPT_ACTIVE; \ + } \ + } + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiIsrSwInit( + IN tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiIsrHwInit( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig ); + +static UINT32 Oct6100InterruptConfigureSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig, + IN BOOL f_fCheckParams ); + +static UINT32 Oct6100InterruptServiceRoutineSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ); + +static UINT32 Oct6100ApiWriteIeRegs( + IN tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiReadIntrptRegs( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags, + IN UINT32 f_ulRegister210h ); + +static UINT32 Oct6100ApiUpdateIntrptStates( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ); + +static UINT32 Oct6100ApiWriteIntrptRegs( + IN tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiReadChipMclkTime( + IN tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiUpdateIntrptTimeouts( + IN tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100ApiScheduleNextMclkIntrpt( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulIntrptToSet ); + +static UINT32 Oct6100ApiScheduleNextMclkIntrptSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiCheckProcessorState( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ); + +#endif /* __OCT6100_INTERRUPTS_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_interrupts_pub.h b/include/oct6100api/oct6100_interrupts_pub.h new file mode 100644 index 0000000..d75f72d --- /dev/null +++ b/include/oct6100api/oct6100_interrupts_pub.h @@ -0,0 +1,102 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_interrupts_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_interrupts.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_interrupts_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 23 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_INTERRUPTS_PUB_H__ +#define __OCT6100_INTERRUPTS_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_INTERRUPT_CONFIGURE_ +{ + UINT32 ulFatalGeneralConfig; + UINT32 ulFatalMemoryConfig; + + UINT32 ulErrorMemoryConfig; + UINT32 ulErrorOverflowToneEventsConfig; + UINT32 ulErrorH100Config; + + UINT32 ulFatalMemoryTimeout; + UINT32 ulErrorMemoryTimeout; + UINT32 ulErrorOverflowToneEventsTimeout; + UINT32 ulErrorH100Timeout; + +} tOCT6100_INTERRUPT_CONFIGURE, *tPOCT6100_INTERRUPT_CONFIGURE; + +typedef struct _OCT6100_INTERRUPT_FLAGS_ +{ + BOOL fFatalGeneral; + UINT32 ulFatalGeneralFlags; + + BOOL fFatalReadTimeout; + + BOOL fErrorRefreshTooLate; + BOOL fErrorPllJitter; + + BOOL fErrorOverflowToneEvents; + + BOOL fErrorH100OutOfSync; + BOOL fErrorH100ClkA; + BOOL fErrorH100ClkB; + BOOL fErrorH100FrameA; + + BOOL fToneEventsPending; + BOOL fBufferPlayoutEventsPending; + + BOOL fApiSynch; + + + +} tOCT6100_INTERRUPT_FLAGS, *tPOCT6100_INTERRUPT_FLAGS; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100InterruptConfigureDef( + OUT tPOCT6100_INTERRUPT_CONFIGURE f_pConfigInts ); +UINT32 Oct6100InterruptConfigure( + IN tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_INTERRUPT_CONFIGURE f_pConfigInts ); + +static UINT32 Oct6100InterruptServiceRoutineDef( + OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ); +static UINT32 Oct6100InterruptServiceRoutine( + IN tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ); + +#endif /* __OCT6100_INTERRUPTS_PUB_H__ */ + diff --git a/include/oct6100api/oct6100_memory_priv.h b/include/oct6100api/oct6100_memory_priv.h new file mode 100644 index 0000000..97f81fa --- /dev/null +++ b/include/oct6100api/oct6100_memory_priv.h @@ -0,0 +1,97 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_memory_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_memory.c. All elements defined in this + file are for private usage of the API. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 16 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_MEMORY_PRIV_H__ +#define __OCT6100_MEMORY_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +/* TSI allocation pointer macros. */ +#define mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulTsiMemoryAllocOfst ); + +/* Conversion memory allocation pointer macros. */ +#define mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulConversionMemoryAllocOfst ); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetMemorySwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiMemorySwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiBufferPlayoutMemorySwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100ApiReserveBufferPlayoutMemoryNode( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT32 f_pulNewNode ); + +UINT32 Oct6100ApiReleaseBufferPlayoutMemoryNode( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulOldNode ); + +UINT32 Oct6100ApiReserveBufferPlayoutMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulSize, + OUT PUINT32 f_pulMallocAddress ); + +UINT32 Oct6100ApiReleaseBufferPlayoutMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulMallocAddress ); + +static UINT32 Oct6100ApiReserveTsiMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusTsiMemIndex ); + +static UINT32 Oct6100ApiReleaseTsiMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsiMemIndex ); + +static UINT32 Oct6100ApiReserveConversionMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusConversionMemIndex ); + +static UINT32 Oct6100ApiReleaseConversionMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usConversionMemIndex ); + +#endif /* __OCT6100_MEMORY_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_miscellaneous_priv.h b/include/oct6100api/oct6100_miscellaneous_priv.h new file mode 100644 index 0000000..3d7226e --- /dev/null +++ b/include/oct6100api/oct6100_miscellaneous_priv.h @@ -0,0 +1,431 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_miscellaneous_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_miscellaneous.c. All elements defined in + this file are for private usage of the API. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 20 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_MISCELLANEOUS_PRIV_H__ +#define __OCT6100_MISCELLANEOUS_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/*---------------------------------------------------------------------------*\ + Macros used to shell the user function calls. These macros are used to + assert that the user does not change any of the members of the function's + parameter structure, as required and indicated in the API specification. + Ofcourse, these macros make the code heavier and thus slower. That is why + there is a compile option for disabling the extra checking. These can be + very helpful tools in debugging. +\*---------------------------------------------------------------------------*/ + +#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK +#define mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) \ +{ \ + PVOID _pProcessContext; \ + UINT32 _ulUserChipId; \ + UINT32 _ulWriteAddress; \ + UINT16 _usWriteData; \ + \ + /* Store the data that is to be passed to the user. */ \ + _pProcessContext = WriteParams.pProcessContext; \ + _ulUserChipId = WriteParams.ulUserChipId; \ + _ulWriteAddress = WriteParams.ulWriteAddress; \ + _usWriteData = WriteParams.usWriteData; \ + \ + /* Call user function. */ \ + ulResult = Oct6100UserDriverWriteApi( &WriteParams ); \ + \ + /* Check if user changed members of function's parameter structure. */ \ + if ( WriteParams.pProcessContext != _pProcessContext || \ + WriteParams.ulUserChipId != _ulUserChipId || \ + WriteParams.ulWriteAddress != _ulWriteAddress || \ + WriteParams.ulWriteAddress != _ulWriteAddress || \ + WriteParams.usWriteData != _usWriteData ) \ + ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_API; \ +} +#else +#define mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) \ + ulResult = Oct6100UserDriverWriteApi( &WriteParams ); +#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */ + + +#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK +#define mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ) \ +{ \ + PVOID _pProcessContext; \ + UINT32 _ulUserChipId; \ + UINT32 _ulWriteAddress; \ + UINT16 _usWriteData; \ + UINT32 _ulWriteLength; \ + \ + /* Store the data that is to be passed to the user. */ \ + _pProcessContext = SmearParams.pProcessContext; \ + _ulUserChipId = SmearParams.ulUserChipId; \ + _ulWriteAddress = SmearParams.ulWriteAddress; \ + _usWriteData = SmearParams.usWriteData; \ + _ulWriteLength = SmearParams.ulWriteLength; \ + \ + /* Call user function. */ \ + ulResult = Oct6100UserDriverWriteSmearApi( &SmearParams ); \ + \ + /* Check if user changed members of function's paraeter structure. */ \ + if ( SmearParams.pProcessContext != _pProcessContext || \ + SmearParams.ulUserChipId != _ulUserChipId || \ + SmearParams.usWriteData != _usWriteData || \ + SmearParams.ulWriteLength != _ulWriteLength) \ + ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_SMEAR_API; \ +} +#else +#define mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ) \ + ulResult = Oct6100UserDriverWriteSmearApi( &SmearParams ); +#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */ + + +#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK +#define mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ) \ +{ \ + PVOID _pProcessContext; \ + UINT32 _ulUserChipId; \ + UINT32 _ulWriteAddress; \ + PUINT16 _pusWriteData; \ + UINT32 _ulWriteLength; \ + \ + /* Store the data that is to be passed to the user. */ \ + _pProcessContext = BurstParams.pProcessContext; \ + _ulUserChipId = BurstParams.ulUserChipId; \ + _ulWriteAddress = BurstParams.ulWriteAddress; \ + _pusWriteData = BurstParams.pusWriteData; \ + _ulWriteLength = BurstParams.ulWriteLength; \ + \ + /* Call user function. */ \ + ulResult = Oct6100UserDriverWriteBurstApi( &BurstParams ); \ + \ + /* Check if user changed members of function's parameter structure. */ \ + if ( BurstParams.pProcessContext != _pProcessContext || \ + BurstParams.ulUserChipId != _ulUserChipId || \ + BurstParams.ulWriteAddress != _ulWriteAddress || \ + BurstParams.pusWriteData != _pusWriteData || \ + BurstParams.ulWriteLength != _ulWriteLength ) \ + ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_BURST_API; \ +} +#else +#define mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ) \ + ulResult = Oct6100UserDriverWriteBurstApi( &BurstParams ); +#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */ + + +#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK +#define mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) \ +{ \ + PVOID _pProcessContext; \ + UINT32 _ulUserChipId; \ + UINT32 _ulReadAddress; \ + PUINT16 _pusReadData; \ + \ + /* Store the data that is to be passed to the user. */ \ + _pProcessContext = ReadParams.pProcessContext; \ + _ulUserChipId = ReadParams.ulUserChipId; \ + _ulReadAddress = ReadParams.ulReadAddress; \ + _pusReadData = ReadParams.pusReadData; \ + \ + /* Call user function. */ \ + ulResult = Oct6100UserDriverReadApi( &ReadParams ); \ + \ + /* Check if user changed members of function's parameter structure. */ \ + if ( ReadParams.pProcessContext != _pProcessContext || \ + ReadParams.ulUserChipId != _ulUserChipId || \ + ReadParams.ulReadAddress != _ulReadAddress || \ + ReadParams.pusReadData != _pusReadData ) \ + ulResult = cOCT6100_ERR_FATAL_DRIVER_READ_API; \ +} +#else +#define mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) \ + ulResult = Oct6100UserDriverReadApi( &ReadParams ); +#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */ + + +#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK +#define mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult ) \ +{ \ + PVOID _pProcessContext; \ + UINT32 _ulUserChipId; \ + UINT32 _ulReadAddress; \ + PUINT16 _pusReadData; \ + UINT32 _ulReadLength; \ + \ + /* Store the data that is to be passed to the user. */ \ + _pProcessContext = BurstParams.pProcessContext; \ + _ulUserChipId = BurstParams.ulUserChipId; \ + _ulReadAddress = BurstParams.ulReadAddress; \ + _pusReadData = BurstParams.pusReadData; \ + _ulReadLength = BurstParams.ulReadLength; \ + \ + /* Call user function. */ \ + ulResult = Oct6100UserDriverReadBurstApi( &BurstParams ); \ + \ + /* Check if user changed members of function's parameter structure. */ \ + if ( BurstParams.pProcessContext != _pProcessContext || \ + BurstParams.ulUserChipId != _ulUserChipId || \ + BurstParams.ulReadAddress != _ulReadAddress || \ + BurstParams.pusReadData != _pusReadData || \ + BurstParams.ulReadLength != _ulReadLength ) \ + ulResult = cOCT6100_ERR_FATAL_DRIVER_READ_BURST_API; \ +} +#else +#define mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult ) \ + ulResult = Oct6100UserDriverReadBurstApi( &BurstParams ); +#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */ + +#define mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, Params ) + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: mOCT6100_RETRIEVE_NLP_CONF_DWORD + +Description: This function is used by the API to store on a per channel basis + the various confguration DWORD from the device. The API performs + less read to the chip that way since it is always in synch + with the chip. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +IN f_pApiInst Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. +IN f_pChanEntry Pointer to an API channel structure.. +IN f_ulAddress Address that needs to be modified.. +IN f_pulConfigDword Pointer to the content stored in the API located at the + desired address. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#define mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInst, f_pChanEntry, f_ulAddress, f_pulConfigDword, f_ulResult ) \ +{ \ + UINT32 _ulFirstEmptyIndex = 0xFFFFFFFF; \ + UINT32 _i; \ + \ + f_ulResult = cOCT6100_ERR_FATAL_8E; \ + (*f_pulConfigDword) = cOCT6100_INVALID_VALUE; \ + \ + /* Search for the Dword.*/ \ + for ( _i = 0; _i < cOCT6100_MAX_NLP_CONF_DWORD; _i++ ) \ + { \ + if ( ( _ulFirstEmptyIndex == 0xFFFFFFFF ) && ( f_pChanEntry->aulNlpConfDword[ _i ][ 0 ] == 0x0 ) ) \ + _ulFirstEmptyIndex = _i; \ + \ + if ( f_pChanEntry->aulNlpConfDword[ _i ][ 0 ] == f_ulAddress ) \ + { \ + /* We found the matching Dword.*/ \ + (*f_pulConfigDword) = f_pChanEntry->aulNlpConfDword[ _i ][ 1 ]; \ + f_ulResult = cOCT6100_ERR_OK; \ + } \ + } \ + \ + if ( ( _i == cOCT6100_MAX_NLP_CONF_DWORD ) && ( _ulFirstEmptyIndex == 0xFFFFFFFF ) ) \ + { \ + /* Nothing to do here, a fatal error occured, no memory was left. */ \ + } \ + else \ + { \ + if ( f_ulResult != cOCT6100_ERR_OK ) \ + { \ + tOCT6100_READ_PARAMS _ReadParams; \ + UINT16 _usReadData; \ + \ + /* We did not found any entry, let's create a new entry.*/ \ + f_pChanEntry->aulNlpConfDword[ _ulFirstEmptyIndex ][ 0 ] = f_ulAddress; \ + \ + _ReadParams.pProcessContext = f_pApiInst->pProcessContext; \ + mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, _ReadParams ); \ + _ReadParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId; \ + _ReadParams.pusReadData = &_usReadData; \ + \ + /* Read the first 16 bits.*/ \ + _ReadParams.ulReadAddress = f_ulAddress; \ + mOCT6100_DRIVER_READ_API( _ReadParams, f_ulResult ); \ + if ( f_ulResult == cOCT6100_ERR_OK ) \ + { \ + /* Save data.*/ \ + (*f_pulConfigDword) = _usReadData << 16; \ + \ + /* Read the last 16 bits .*/ \ + _ReadParams.ulReadAddress += 2; \ + mOCT6100_DRIVER_READ_API( _ReadParams, f_ulResult ); \ + if ( f_ulResult == cOCT6100_ERR_OK ) \ + { \ + /* Save data.*/ \ + (*f_pulConfigDword) |= _usReadData; \ + f_ulResult = cOCT6100_ERR_OK; \ + } \ + } \ + } \ + } \ +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: mOCT6100_SAVE_NLP_CONF_DWORD + +Description: This function stores a configuration Dword within an API channel + structure and then writes it into the chip. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +IN f_pApiInst Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. +IN f_pChanEntry Pointer to an API channel structure.. +IN f_ulAddress Address that needs to be modified.. +IN f_pulConfigDword content to be stored in the API located at the + desired address. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#define mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInst, f_pChanEntry, f_ulAddress, f_ulConfigDword, f_ulResult ) \ +{ \ + UINT32 _i; \ + UINT32 _ulLastValue = 0x0; \ + \ + /* Search for the Dword.*/ \ + for ( _i = 0; _i < cOCT6100_MAX_NLP_CONF_DWORD; _i++ ) \ + { \ + if ( f_pChanEntry->aulNlpConfDword[ _i ][ 0 ] == f_ulAddress ) \ + { \ + /* We found the matching Dword.*/ \ + _ulLastValue = f_pChanEntry->aulNlpConfDword[ _i ][ 1 ]; \ + f_pChanEntry->aulNlpConfDword[ _i ][ 1 ] = f_ulConfigDword; \ + break; \ + } \ + } \ + \ + if ( _i == cOCT6100_MAX_NLP_CONF_DWORD ) \ + { \ + f_ulResult = cOCT6100_ERR_FATAL_8F; \ + } \ + else \ + { \ + /* Write the config DWORD. */ \ + tOCT6100_WRITE_PARAMS _WriteParams; \ + \ + _WriteParams.pProcessContext = f_pApiInst->pProcessContext; \ + mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, _WriteParams ) \ + _WriteParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId; \ + \ + /* Check if it is worth calling the user function. */ \ + if ( ( f_ulConfigDword & 0xFFFF0000 ) != ( _ulLastValue & 0xFFFF0000 ) ) \ + { \ + /* Write the first 16 bits. */ \ + _WriteParams.ulWriteAddress = f_ulAddress; \ + _WriteParams.usWriteData = (UINT16)((f_ulConfigDword >> 16) & 0xFFFF); \ + mOCT6100_DRIVER_WRITE_API( _WriteParams, f_ulResult ); \ + } \ + else \ + { \ + f_ulResult = cOCT6100_ERR_OK; \ + } \ + \ + if ( f_ulResult == cOCT6100_ERR_OK ) \ + { \ + if ( ( f_ulConfigDword & 0x0000FFFF ) != ( _ulLastValue & 0x0000FFFF ) ) \ + { \ + /* Write the last word. */ \ + _WriteParams.ulWriteAddress = f_ulAddress + 2; \ + _WriteParams.usWriteData = (UINT16)(f_ulConfigDword & 0xFFFF); \ + mOCT6100_DRIVER_WRITE_API( _WriteParams, f_ulResult ); \ + } \ + } \ + } \ +} + + +#define mOCT6100_CREATE_FEATURE_MASK( f_ulFieldSize, f_ulFieldBitOffset, f_pulFieldMask ) \ +{ \ + (*f_pulFieldMask) = ( 1 << f_ulFieldSize ); \ + (*f_pulFieldMask) --; \ + (*f_pulFieldMask) <<= f_ulFieldBitOffset; \ +} + + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiWaitForTime( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_aulWaitTime[ 2 ] ); + +static UINT32 Oct6100ApiWaitForPcRegisterBit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulPcRegAdd, + IN UINT32 f_ulPcBitNum, + IN UINT32 f_ulValue, + IN UINT32 f_ulTimeoutUs, + OUT PBOOL f_pfBitEqual ); + +static UINT32 Oct6100ApiWriteDword( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulAddress, + IN UINT32 f_ulWriteData ); + +static UINT32 Oct6100ApiReadDword( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulAddress, + OUT PUINT32 f_pulReadData ); + +VOID Oct6100ApiCreateFeatureMask( + IN UINT32 f_ulFieldSize, + IN UINT32 f_ulFieldBitOffset, + OUT PUINT32 f_pulFieldMask ); + +static PUINT8 Oct6100ApiStrStr( + IN PUINT8 f_pszSource, + IN PUINT8 f_pszString, + IN PUINT8 f_pszLastCharPtr ); + +static UINT32 Oct6100ApiStrLen( + IN PUINT8 f_pszString ); + +static UINT32 Oct6100ApiAsciiToHex( + IN UINT8 f_chCharacter, + IN PUINT32 f_pulValue ); + +static UINT8 Oct6100ApiHexToAscii( + IN UINT32 f_ulNumber ); + +static UINT32 Oct6100ApiRand( + IN UINT32 f_ulRange ); + +#endif /* __OCT6100_MISCELLANEOUS_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_mixer_inst.h b/include/oct6100api/oct6100_mixer_inst.h new file mode 100644 index 0000000..2c7707f --- /dev/null +++ b/include/oct6100api/oct6100_mixer_inst.h @@ -0,0 +1,86 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_mixer_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_mixer.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_mixer_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 13 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_MIXER_INST_H__ +#define __OCT6100_MIXER_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_MIXER_EVENT_ +{ + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Type of the event.*/ + UINT16 usEventType; + + /* Source channel index */ + UINT16 usSourceChanIndex; + + /* Destination channel index */ + UINT16 usDestinationChanIndex; + + /* Pointer to the next entry.*/ + UINT16 usNextEventPtr; + +} tOCT6100_API_MIXER_EVENT, *tPOCT6100_API_MIXER_EVENT; + + +typedef struct _OCT6100_API_COPY_EVENT_ +{ + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Count used to manage entry handles allocated to user. */ + UINT8 byEntryOpenCnt; + + /* Source + destination ports. */ + UINT8 bySourcePort; + UINT8 byDestinationPort; + + /* Index of the channels associated to this event.*/ + UINT16 usSourceChanIndex; + UINT16 usDestinationChanIndex; + + UINT16 usMixerEventIndex; + +} tOCT6100_API_COPY_EVENT, *tPOCT6100_API_COPY_EVENT; + + +#endif /* __OCT6100_MIXER_INST_H__ */ diff --git a/include/oct6100api/oct6100_mixer_priv.h b/include/oct6100api/oct6100_mixer_priv.h new file mode 100644 index 0000000..f739f97 --- /dev/null +++ b/include/oct6100api/oct6100_mixer_priv.h @@ -0,0 +1,150 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_mixer_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_mixer.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_mixer_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 17 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_MIXER_PRIV_H__ +#define __OCT6100_MIXER_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +#define mOCT6100_GET_MIXER_EVENT_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_MIXER_EVENT )(( PVOID )pSharedInfo + pSharedInfo->ulMixerEventListOfst); + +#define mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_MIXER_EVENT )(( PVOID )pSharedInfo + pSharedInfo->ulMixerEventListOfst)) + ulIndex; + +#define mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulMixerEventAllocOfst); + +#define mOCT6100_GET_COPY_EVENT_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_COPY_EVENT )(( PVOID )pSharedInfo + pSharedInfo->ulCopyEventListOfst); + +#define mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_COPY_EVENT )(( PVOID )pSharedInfo + pSharedInfo->ulCopyEventListOfst)) + ulIndex; + +#define mOCT6100_GET_COPY_EVENT_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulCopyEventAllocOfst); + +/***************************** TYPES ***************************************/ + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetMixerSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiMixerSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiMixerEventAdd( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEventIndex, + IN UINT16 f_usEventType, + IN UINT16 f_usDestinationChanIndex ); + +static UINT32 Oct6100ApiMixerEventRemove( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEventIndex, + IN UINT16 f_usEventType ); + +UINT32 Oct6100MixerCopyEventCreateSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate ); + +UINT32 Oct6100ApiCheckCopyEventCreateParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate, + OUT PUINT16 f_pusSourceChanIndex, + OUT PUINT16 f_pusDestinationChanIndex ); + +UINT32 Oct6100ApiReserveCopyEventCreateResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusCopyEntryIndex, + IN OUT PUINT16 f_pusCopyEventIndex ); + +UINT32 Oct6100ApiWriteCopyEventCreateStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate, + IN UINT16 f_usMixerEventIndex, + IN UINT16 f_usSourceChanIndex, + IN UINT16 f_usDestinationChanIndex ); + +UINT32 Oct6100ApiUpdateCopyEventCreateEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate, + IN UINT16 f_usCopyEventIndex, + IN UINT16 f_usMixerEventIndex, + IN UINT16 f_usSourceChanIndex, + IN UINT16 f_usDestinationChanIndex ); + +UINT32 Oct6100MixerCopyEventDestroySer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy ); + +UINT32 Oct6100ApiAssertCopyEventDestroyParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy, + IN OUT PUINT16 f_pusCopyEventIndex, + IN OUT PUINT16 f_pusMixerEventIndex ); + +UINT32 Oct6100ApiInvalidateCopyEventStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usCopyEventIndex, + IN UINT16 f_usMixerEventIndex ); + +UINT32 Oct6100ApiReleaseCopyEventResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usCopyEventIndex, + IN UINT16 f_usMixerEventIndex ); + +static UINT32 Oct6100ApiReserveMixerEventEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusEventIndex ); + +static UINT32 Oct6100ApiReleaseMixerEventEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEventIndex ); + +static UINT32 Oct6100ApiGetFreeMixerEventCnt( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT32 f_pulFreeEventCnt ); + +UINT32 Oct6100ApiReserveCopyEventEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusEventIndex ); + +UINT32 Oct6100ApiReleaseCopyEventEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEventIndex ); +#endif /* __OCT6100_MIXER_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_mixer_pub.h b/include/oct6100api/oct6100_mixer_pub.h new file mode 100644 index 0000000..004d1e5 --- /dev/null +++ b/include/oct6100api/oct6100_mixer_pub.h @@ -0,0 +1,77 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_mixer_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_mixer.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_mixer_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 7 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_MIXER_PUB_H__ +#define __OCT6100_MIXER_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_COPY_EVENT_CREATE_ +{ + PUINT32 pulCopyEventHndl; + + UINT32 ulSourceChanHndl; + UINT32 ulSourcePort; + + UINT32 ulDestinationChanHndl; + UINT32 ulDestinationPort; + +} tOCT6100_COPY_EVENT_CREATE, *tPOCT6100_COPY_EVENT_CREATE; + +typedef struct _OCT6100_COPY_EVENT_DESTROY_ +{ + UINT32 ulCopyEventHndl; + +} tOCT6100_COPY_EVENT_DESTROY, *tPOCT6100_COPY_EVENT_DESTROY; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100MixerCopyEventCreateDef( + OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate ); +UINT32 Oct6100MixerCopyEventCreate( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate ); + +UINT32 Oct6100MixerCopyEventDestroyDef( + OUT tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy ); +UINT32 Oct6100MixerCopyEventDestroy( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy ); + +#endif /* __OCT6100_MIXER_PUB_H__ */ diff --git a/include/oct6100api/oct6100_phasing_tsst_inst.h b/include/oct6100api/oct6100_phasing_tsst_inst.h new file mode 100644 index 0000000..5624238 --- /dev/null +++ b/include/oct6100api/oct6100_phasing_tsst_inst.h @@ -0,0 +1,68 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_phasing_tsst_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_phasing_tsst.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_phasing_tsst_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 9 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_PHASING_TSST_INST_H__ +#define __OCT6100_PHASING_TSST_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_PHASING_TSST_ +{ + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Count used to manage entry handles allocated to user. */ + UINT8 byEntryOpenCnt; + + /* Count of number of resources connected in some way to this buffer. */ + UINT16 usDependencyCnt; + + /* TDM timeslot and stream where the counter is read. */ + UINT16 usStream; + UINT16 usTimeslot; + + /* Length of the phasing TSST counter. */ + UINT16 usPhasingLength; + + /* TSST control index where the counter comes from. */ + UINT16 usPhasingTsstIndex; + +} tOCT6100_API_PHASING_TSST, *tPOCT6100_API_PHASING_TSST; + +#endif /* __OCT6100_PHASING_TSST_INST_H__ */ diff --git a/include/oct6100api/oct6100_phasing_tsst_priv.h b/include/oct6100api/oct6100_phasing_tsst_priv.h new file mode 100644 index 0000000..cad047c --- /dev/null +++ b/include/oct6100api/oct6100_phasing_tsst_priv.h @@ -0,0 +1,114 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_phasing_tsst_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_phasing_tsst.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_phasing_tsst_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 10 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_PHASING_TSST_PRIV_H__ +#define __OCT6100_PHASING_TSST_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +#define mOCT6100_GET_PHASING_TSST_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_PHASING_TSST )(( PVOID )pSharedInfo + pSharedInfo->ulPhasingTsstListOfst); + +#define mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_PHASING_TSST )(( PVOID )pSharedInfo + pSharedInfo->ulPhasingTsstListOfst)) + ulIndex; + +#define mOCT6100_GET_PHASING_TSST_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulPhasingTsstAllocOfst); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetPhasingTsstSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiPhasingTsstSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100PhasingTsstOpenSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen ); + +UINT32 Oct6100ApiCheckPhasingParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen ); + +UINT32 Oct6100ApiReservePhasingResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen, + OUT PUINT16 f_pusPhasingIndex, + OUT PUINT16 f_pusTsstIndex ); + +UINT32 Oct6100ApiWritePhasingStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen, + IN UINT16 f_usPhasingIndex, + IN UINT16 f_usTsstIndex ); + +UINT32 Oct6100ApiUpdatePhasingEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen, + IN UINT16 f_usPhasingIndex, + IN UINT16 f_usTsstIndex ); + +UINT32 Oct6100PhasingTsstCloseSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose ); + +UINT32 Oct6100ApiAssertPhasingParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose, + OUT PUINT16 f_pusPhasingIndex, + OUT PUINT16 f_pusTsstIndex ); + +UINT32 Oct6100ApiInvalidatePhasingStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsstIndex ); + +UINT32 Oct6100ApiReleasePhasingResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT UINT16 f_usPhasingIndex ); + +UINT32 Oct6100ApiReservePhasingEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusPhasingIndex ); + +UINT32 Oct6100ApiReleasePhasingEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usPhasingIndex ); + +#endif /* __OCT6100_PHASING_TSST_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_phasing_tsst_pub.h b/include/oct6100api/oct6100_phasing_tsst_pub.h new file mode 100644 index 0000000..b5f5e8e --- /dev/null +++ b/include/oct6100api/oct6100_phasing_tsst_pub.h @@ -0,0 +1,77 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_phasing_tsst_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_phasing_tsst.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_phasing_tsst_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 9 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_PHASING_TSST_PUB_H__ +#define __OCT6100_PHASING_TSST_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_PHASING_TSST_OPEN_ +{ + PUINT32 pulPhasingTsstHndl; + + UINT32 ulPhasingLength; + UINT32 ulTimeslot; + UINT32 ulStream; + + + +} tOCT6100_PHASING_TSST_OPEN, *tPOCT6100_PHASING_TSST_OPEN; + +typedef struct _OCT6100_PHASING_TSST_CLOSE_ +{ + UINT32 ulPhasingTsstHndl; + +} tOCT6100_PHASING_TSST_CLOSE, *tPOCT6100_PHASING_TSST_CLOSE; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100PhasingTsstOpenDef( + OUT tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen ); +UINT32 Oct6100PhasingTsstOpen( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen ); + +UINT32 Oct6100PhasingTsstCloseDef( + OUT tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose ); +UINT32 Oct6100PhasingTsstClose( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose ); + +#endif /* __OCT6100_PHASING_TSST_PUB_H__ */ diff --git a/include/oct6100api/oct6100_playout_buf_inst.h b/include/oct6100api/oct6100_playout_buf_inst.h new file mode 100644 index 0000000..9cc297d --- /dev/null +++ b/include/oct6100api/oct6100_playout_buf_inst.h @@ -0,0 +1,88 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_playout_buf_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_playout_buf.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_playout_buf_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 9 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_PLAYOUT_BUF_INST_H__ +#define __OCT6100_PLAYOUT_BUF_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +#define mOCT6100_GET_BUFFER_MEMORY_NODE_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE )(( PVOID )pSharedInfo + pSharedInfo->ulPlayoutBufMemoryNodeListOfst ); + +#define mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE )(( PVOID )pSharedInfo + pSharedInfo->ulPlayoutBufMemoryNodeListOfst)) + ulIndex; + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE_ +{ + /* Next node. */ + UINT32 ulNext; + + /* Previous node. */ + UINT32 ulPrevious; + + /* Start address of this node. */ + UINT32 ulStartAddress; + + /* Size of this node. */ + UINT32 ulSize; + + /* Allocated node? Free node? */ + UINT8 fAllocated; + +} tOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE, *tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE; + +typedef struct _OCT6100_API_BUFFER_ +{ + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Pcm law of the buffer. */ + UINT8 byBufferPcmLaw; + + /* Number of channels currently playing this buffer.*/ + UINT16 usDependencyCnt; + + /* Length of the buffer ( in bytes ).*/ + UINT32 ulBufferSize; + + /* Address in external memory of the buffer. */ + UINT32 ulBufferBase; + +} tOCT6100_API_BUFFER, *tPOCT6100_API_BUFFER; + +#endif /* __OCT6100_PLAYOUT_BUF_INST_H__ */ diff --git a/include/oct6100api/oct6100_playout_buf_priv.h b/include/oct6100api/oct6100_playout_buf_priv.h new file mode 100644 index 0000000..83ebc49 --- /dev/null +++ b/include/oct6100api/oct6100_playout_buf_priv.h @@ -0,0 +1,201 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_playout_buf_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_playout_buf.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_playout_buf_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 21 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_PLAYOUT_BUF_PRIV_H__ +#define __OCT6100_PLAYOUT_BUF_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/* Playout buffer list pointer macros. */ +#define mOCT6100_GET_BUFFER_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_BUFFER )(( PVOID )pSharedInfo + pSharedInfo->ulPlayoutBufListOfst ); + +#define mOCT6100_GET_BUFFER_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_BUFFER )(( PVOID )pSharedInfo + pSharedInfo->ulPlayoutBufListOfst)) + ulIndex; + +#define mOCT6100_GET_BUFFER_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulPlayoutBufAllocOfst); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetPlayoutBufferSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiPlayoutBufferSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100BufferLoadSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad, + IN BOOL f_fReserveListStruct, + IN UINT32 f_ulBufIndex ); + +UINT32 Oct6100BufferLoadBlockInitSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit ); + +UINT32 Oct6100BufferLoadBlockSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock ); + +UINT32 Oct6100ApiCheckBufferParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_LOAD f_pBufferLoad, + IN BOOL f_fCheckBufferPtr ); + +UINT32 Oct6100ApiCheckBufferLoadBlockParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock, + OUT PUINT32 f_pulBufferBase ); + +UINT32 Oct6100ApiReserveBufferResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_LOAD f_pBufferLoad, + IN BOOL f_fReserveListStruct, + IN UINT32 f_ulBufIndex, + OUT PUINT32 f_pulBufIndex, + OUT PUINT32 f_pulBufBase ); + +UINT32 Oct6100ApiWriteBufferInMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulBufferBase, + IN UINT32 f_ulBufferLength, + IN PUINT8 f_pbyBuffer ); + +UINT32 Oct6100ApiUpdateBufferEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad, + IN UINT32 f_ulBufIndex, + IN UINT32 f_ulBufBase ); + +UINT32 Oct6100BufferUnloadSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_UNLOAD f_pBufferUnload, + IN BOOL f_fReleaseListStruct ); + +UINT32 Oct6100ApiAssertBufferParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_UNLOAD f_pBufferUnload, + OUT PUINT32 f_pulBufIndex, + OUT PUINT32 f_pulBufBase ); + +UINT32 Oct6100ApiReleaseBufferResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulBufIndex, + IN UINT32 f_ulBufBase, + IN BOOL f_fReleaseListStruct ); + +UINT32 Oct6100BufferPlayoutAddSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd ); + +UINT32 Oct6100ApiCheckPlayoutAddParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT32 f_pulBufferIndex ); + +UINT32 Oct6100ApiWriteBufferAddStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulBufferIndex ); + +UINT32 Oct6100BufferPlayoutStartSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart, + IN UINT32 f_ulPlayoutStopEventType ); + +UINT32 Oct6100ApiCheckPlayoutStartParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT32 f_pulBufferIndex, + OUT PBOOL f_pfNotifyOnPlayoutStop, + OUT PUINT32 f_pulUserEventId, + OUT PBOOL f_pfAllowStartIfActive ); + +UINT32 Oct6100ApiWriteChanPlayoutStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulBufferIndex, + IN BOOL f_fNotifyOnPlayoutStop, + IN UINT32 f_ulUserEventId, + IN BOOL f_fAllowStartIfActive, + IN UINT32 f_ulPlayoutStopEventType ); + +UINT32 Oct6100ApiUpdateChanPlayoutEntry ( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulBufferIndex ); + +static UINT32 Oct6100BufferPlayoutStopSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop ); + +static UINT32 Oct6100ApiAssertPlayoutStopParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT16 f_pusEchoMemIndex ); + +static UINT32 Oct6100ApiInvalidateChanPlayoutStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop, + IN UINT32 f_ulChannelIndex, + IN UINT16 f_usEchoMemIndex + + ); + +UINT32 Oct6100ApiReleaseChanPlayoutResources ( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop, + IN UINT32 f_ulChannelIndex ); + +UINT32 Oct6100ApiReserveBufPlayoutListEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT32 f_pulBufIndex ); + +UINT32 Oct6100ApiReleaseBufPlayoutListEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulBufIndex ); + +#endif /* __OCT6100_PLAYOUT_BUF_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_playout_buf_pub.h b/include/oct6100api/oct6100_playout_buf_pub.h new file mode 100644 index 0000000..97c110c --- /dev/null +++ b/include/oct6100api/oct6100_playout_buf_pub.h @@ -0,0 +1,183 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_playout_buf_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_playout_buf.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_playout_buf_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 21 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_PLAYOUT_BUF_PUB_H__ +#define __OCT6100_PLAYOUT_BUF_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_BUFFER_LOAD_ +{ + PUINT32 pulBufferIndex; /* Index identifying the buffer. */ + PUINT32 pulPlayoutFreeMemSize; /* Amount of free memory available for other buffers. */ + + PUINT8 pbyBufferPattern; /* A byte pointer pointing to a valid buffer to be loaded into the chip's external memory. */ + UINT32 ulBufferSize; /* Size of the buffer loaded into external memory. */ + + UINT32 ulBufferPcmLaw; /* Buffer PCM law. */ + +} tOCT6100_BUFFER_LOAD, *tPOCT6100_BUFFER_LOAD; + +typedef struct _OCT6100_BUFFER_LOAD_BLOCK_INIT_ +{ + PUINT32 pulBufferIndex; /* Index identifying the buffer. */ + PUINT32 pulPlayoutFreeMemSize; /* Amount of free memory available for other buffers. */ + + UINT32 ulBufferSize; /* Size of the buffer to be loaded in memory. This space will be reserved. */ + + UINT32 ulBufferPcmLaw; /* Buffer PCM law. */ + +} tOCT6100_BUFFER_LOAD_BLOCK_INIT, *tPOCT6100_BUFFER_LOAD_BLOCK_INIT; + +typedef struct _OCT6100_BUFFER_LOAD_BLOCK_ +{ + UINT32 ulBufferIndex; /* Index identifying the buffer. */ + + /* Offset, in bytes, of the first byte in the block to be loaded. */ + /* This offset is with respect to the beginning of the buffer. */ + /* This value must be modulo 2 */ + UINT32 ulBlockOffset; + + /* Size of the block to be loaded into external memory. */ + /* This value must be modulo 2. */ + UINT32 ulBlockLength; + + /* A pointer pointing to a valid buffer block to be loaded */ + /* into the chip's external memory. This is a pointer to the entire */ + /* buffer. The API uses the ulBlockOffset and ulBlockLength to index */ + /* within this buffer and obtain the block to be loaded. */ + PUINT8 pbyBufferPattern; + +} tOCT6100_BUFFER_LOAD_BLOCK, *tPOCT6100_BUFFER_LOAD_BLOCK; + +typedef struct _OCT6100_BUFFER_UNLOAD_ +{ + UINT32 ulBufferIndex; /* Index identifying the buffer. */ + +} tOCT6100_BUFFER_UNLOAD, *tPOCT6100_BUFFER_UNLOAD; + +typedef struct _OCT6100_BUFFER_PLAYOUT_ADD_ +{ + UINT32 ulChannelHndl; /* Echo cancelling channel on which to play the buffer. */ + + UINT32 ulBufferIndex; /* Index identifying the buffer. */ + + UINT32 ulPlayoutPort; /* Selected channel port where to play to tone. */ + UINT32 ulMixingMode; /* Weither or not the voice stream will be muted while playing the buffer. */ + + INT32 lGainDb; /* Gain applied to the buffer that will be played on the specified port. */ + + BOOL fRepeat; /* Use ulRepeatCount variable. */ + UINT32 ulRepeatCount; /* Number of times to repeat playing the selected buffer. */ + + UINT32 ulDuration; /* Duration in millisecond that this buffer should play. Setting this overrides fRepeat. */ + + UINT32 ulBufferLength; /* Length of the buffer to play (starting at the beginning), AUTO_SELECT for all. */ + +} tOCT6100_BUFFER_PLAYOUT_ADD, *tPOCT6100_BUFFER_PLAYOUT_ADD; + +typedef struct _OCT6100_BUFFER_PLAYOUT_START_ +{ + UINT32 ulChannelHndl; /* Echo cancelling channel on which to play the buffer. */ + UINT32 ulPlayoutPort; /* Selected channel port where to play to tone. */ + + BOOL fNotifyOnPlayoutStop; /* Check if the buffers have finished playing on this channel/port. */ + /* The events are queued in a soft buffer that the user must empty regularly. */ + UINT32 ulUserEventId; /* Returned to the user when the playout is finished and the user has set the fNotifyOnPlayoutStop flag. */ + + BOOL fAllowStartWhileActive; /* Use this to add buffers to something that is already playing on the channel/port. */ + +} tOCT6100_BUFFER_PLAYOUT_START, *tPOCT6100_BUFFER_PLAYOUT_START; + +typedef struct _OCT6100_BUFFER_PLAYOUT_STOP_ +{ + UINT32 ulChannelHndl; /* Echo cancelling channel on which to play the buffer. */ + UINT32 ulPlayoutPort; /* Selected channel port where to play to tone. */ + BOOL fStopCleanly; /* Whether or not the skip will be clean. */ + + PBOOL pfAlreadyStopped; /* Whether playout was already stopped or not. */ + PBOOL pfNotifyOnPlayoutStop; /* Whether the user chosed to receive an event on playout stop. */ + +} tOCT6100_BUFFER_PLAYOUT_STOP, *tPOCT6100_BUFFER_PLAYOUT_STOP; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100BufferPlayoutLoadDef( + OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad ); +UINT32 Oct6100BufferPlayoutLoad( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad ); + +UINT32 Oct6100BufferPlayoutLoadBlockInitDef( + OUT tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit ); +UINT32 Oct6100BufferPlayoutLoadBlockInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit ); + +UINT32 Oct6100BufferPlayoutLoadBlockDef( + OUT tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock ); +UINT32 Oct6100BufferPlayoutLoadBlock( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock ); + +UINT32 Oct6100BufferPlayoutUnloadDef( + OUT tPOCT6100_BUFFER_UNLOAD f_pBufferUnload ); +UINT32 Oct6100BufferPlayoutUnload( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_UNLOAD f_pBufferUnload ); + +UINT32 Oct6100BufferPlayoutAddDef( + OUT tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd ); +UINT32 Oct6100BufferPlayoutAdd( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd ); + +UINT32 Oct6100BufferPlayoutStartDef( + OUT tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart ); +UINT32 Oct6100BufferPlayoutStart( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart ); + +static UINT32 Oct6100BufferPlayoutStopDef( + OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop ); +UINT32 Oct6100BufferPlayoutStop( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop ); + +#endif /* __OCT6100_PLAYOUT_BUF_PUB_H__ */ diff --git a/include/oct6100api/oct6100_remote_debug_inst.h b/include/oct6100api/oct6100_remote_debug_inst.h new file mode 100644 index 0000000..d12415a --- /dev/null +++ b/include/oct6100api/oct6100_remote_debug_inst.h @@ -0,0 +1,73 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_remote_debug_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_remote_debug.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_remote_debug_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 6 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_REMOTE_DEBUG_INST_H__ +#define __OCT6100_REMOTE_DEBUG_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_REMOTE_DEBUG_INFO_ +{ + UINT32 ulSessionTreeOfst; + UINT32 ulSessionListOfst; + UINT32 ulSessionListHead; + UINT32 ulSessionListTail; + + UINT32 ulPktCacheOfst; + UINT32 ulDataBufOfst; + + UINT32 ulNumSessionsOpen; + UINT32 ulMaxSessionsOpen; + +} tOCT6100_API_REMOTE_DEBUG_INFO, *tPOCT6100_API_REMOTE_DEBUG_INFO; + +typedef struct _OCT6100_API_REMOTE_DEBUG_SESSION_ +{ + UINT32 ulSessionNum; + UINT32 ulTransactionNum; + UINT32 ulPktRetryNum; + UINT32 ulPktByteSize; + + UINT32 aulLastPktTime[ 2 ]; + UINT32 ulForwardLink; + UINT32 ulBackwardLink; + +} tOCT6100_API_REMOTE_DEBUG_SESSION, *tPOCT6100_API_REMOTE_DEBUG_SESSION; + +#endif /* __OCT6100_REMOTE_DEBUG_INST_H__ */ diff --git a/include/oct6100api/oct6100_remote_debug_priv.h b/include/oct6100api/oct6100_remote_debug_priv.h new file mode 100644 index 0000000..e41b705 --- /dev/null +++ b/include/oct6100api/oct6100_remote_debug_priv.h @@ -0,0 +1,144 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_remote_debug_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_remote_debug.c. All elements defined in this + file are for private usage of the API. All public elements are defined + in the oct6100_remote_debug_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 12 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_REMOTE_DEBUG_PRIV_H__ +#define __OCT6100_REMOTE_DEBUG_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +#define mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, ulIndex, pEntry ) \ + pEntry = ( tPOCT6100_API_REMOTE_DEBUG_SESSION )(( PVOID )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulSessionListOfst) + ulIndex; + +#define mOCT6100_GET_REMOTE_DEBUG_TREE_PNT( pSharedInfo, pList ) \ + pList = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulSessionTreeOfst); + +#define mOCT6100_GET_REMOTE_DEBUG_DATA_BUF_PNT( pSharedInfo, pulDataBuf ) \ + pulDataBuf = ( PUINT16 )(( PVOID )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulDataBufOfst); + +#define mOCT6100_GET_REMOTE_DEBUG_SESSION_PKT_CACHE_PNT( pSharedInfo, pulPktCache, ulSessionIndex ) \ + pulPktCache = ( PUINT32 )(( PVOID )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulPktCacheOfst) + (ulSessionIndex * (cOCTRPC_MAX_PACKET_BYTE_LENGTH / 4)); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetRemoteDebugSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiRemoteDebuggingSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +UINT32 Oct6100ApiCheckEndianDetectField( + IN tPOCTRPC_OGRDTP_HEADER f_pOgrdtpHeader, + IN UINT32 f_ulPktLengthDword ); + +VOID Oct6100ApiCalculateChecksum( + IN PUINT32 f_pulPktPayload, + IN UINT32 f_ulPktLengthDword, + OUT PUINT32 f_pulChecksum ); + +VOID Oct6100ApiFormResponsePkt( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN PUINT32 f_pulRcvPktPayload, + IN OUT PUINT32 f_pulRspPktPayload, + IN UINT32 f_ulPktLengthDword, + IN BOOL f_fRetryPktResponse, + IN BOOL f_fReplaceProtocolNum, + IN BOOL f_fReplaceInterfaceType, + IN BOOL f_fReplaceInterfaceVersion, + IN UINT32 f_ulSessionIndex, + IN UINT32 f_ulParsingErrorValue, + IN UINT32 f_ulPayloadDwordIndex, + IN UINT32 f_ulChecksum ); + +UINT32 Oct6100ApiCheckPktCommands( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN PUINT32 f_pulRcvPktPayload, + IN OUT PUINT32 f_pulRspPktPayload, + IN UINT32 f_ulSessionIndex, + IN UINT32 f_ulPktLengthDword, + IN UINT32 f_ulChecksum ); + +VOID Oct6100ApiExecutePktCommands( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN PUINT32 f_pulRcvPktPayload, + IN UINT32 f_ulPktLengthDword ); + +UINT32 Oct6100ApiCheckSessionNum( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCTRPC_OGRDTP_HEADER f_pOgrdtpHeader, + OUT PUINT32 f_pulSessionIndex ); + +VOID Oct6100ApiRpcReadWord( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcReadBurst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcReadArray( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcWriteWord( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcWriteSmear( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcWriteBurst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcSetHotChannel( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcGetDebugChanIndex( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader ); + +VOID Oct6100ApiRpcDisconnect( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader, + IN OUT UINT32 f_ulSessionNumber ); + +#endif /* __OCT6100_REMOTE_DEBUG_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_remote_debug_pub.h b/include/oct6100api/oct6100_remote_debug_pub.h new file mode 100644 index 0000000..967011d --- /dev/null +++ b/include/oct6100api/oct6100_remote_debug_pub.h @@ -0,0 +1,64 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_remote_debug_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_remote_debug.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_remote_debug_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 6 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_REMOTE_DEBUG_PUB_H__ +#define __OCT6100_REMOTE_DEBUG_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_REMOTE_DEBUG_ +{ + PUINT32 pulReceivedPktPayload; + UINT32 ulReceivedPktLength; + + PUINT32 pulResponsePktPayload; + UINT32 ulMaxResponsePktLength; + UINT32 ulResponsePktLength; + +} tOCT6100_REMOTE_DEBUG, *tPOCT6100_REMOTE_DEBUG; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100RemoteDebugDef( + OUT tPOCT6100_REMOTE_DEBUG f_pRemoteDebug ); +UINT32 Oct6100RemoteDebug( + IN OUT tPOCT6100_INSTANCE_API f_pApiInst, + IN OUT tPOCT6100_REMOTE_DEBUG f_pRemoteDebug ); + +#endif /* __OCT6100_REMOTE_DEBUG_PUB_H__ */ diff --git a/include/oct6100api/oct6100_tlv_inst.h b/include/oct6100api/oct6100_tlv_inst.h new file mode 100644 index 0000000..d4d670b --- /dev/null +++ b/include/oct6100api/oct6100_tlv_inst.h @@ -0,0 +1,72 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tlv_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_tlv.c. All elements defined in this file are for public + usage of the API. All instate elements are defined in the + oct6100_tlv_inst.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 7 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TLV_INST_H__ +#define __OCT6100_TLV_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_TLV_OFFSET_ +{ + /* The dword offset contain the number of dword from a base address to reach the desired dword. + + i.e. usDwordOffset = (total bit offset) / 32; */ + + UINT16 usDwordOffset; + + /* The bit offset will contain the bit offset required to right shift the DWORD read and obtain + the desired value. This field is depend on the field size. + + i.e. byBitOffset = 31 - ((total bit offset) % 32) - byFieldSize; */ + + UINT8 byBitOffset; + UINT8 byFieldSize; + +} tOCT6100_TLV_OFFSET, *tPOCT6100_TLV_OFFSET; + +typedef struct _OCT6100_TLV_TONE_INFO_ +{ + UINT32 ulToneID; + UINT32 ulDetectionPort; + + UINT8 aszToneName[ cOCT6100_TLV_MAX_TONE_NAME_SIZE ]; + + + +} tOCT6100_TLV_TONE_INFO, *tPOCT6100_TLV_TONE_INFO; + +#endif /* __OCT6100_TLV_INST_H__ */ diff --git a/include/oct6100api/oct6100_tlv_priv.h b/include/oct6100api/oct6100_tlv_priv.h new file mode 100644 index 0000000..2527e5d --- /dev/null +++ b/include/oct6100api/oct6100_tlv_priv.h @@ -0,0 +1,510 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tlv_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_tlv.c. All elements defined in this + file are for private usage of the API. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 54 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TLV_PRIV_H__ +#define __OCT6100_TLV_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +/* List of TLV types supported by this API. */ +#define cOCT6100_TLV_TYPE_VERSION_NUMBER 0 +#define cOCT6100_TLV_TYPE_CUSTOMER_PROJECT_ID 2 + +#define cOCT6100_TLV_TYPE_POUCH_BASE_ADDRESS 3 +#define cOCT6100_TLV_TYPE_CH0_MAIN_BASE_ADDRESS 4 +#define cOCT6100_TLV_TYPE_CH_MAIN_SIZE 5 +#define cOCT6100_TLV_TYPE_CH_MAIN_IO_OFFSET 6 +#define cOCT6100_TLV_TYPE_CH_MAIN_ZCB_OFFSET 7 +#define cOCT6100_TLV_TYPE_CH_MAIN_ZCB_SIZE 8 +#define cOCT6100_TLV_TYPE_CH_MAIN_XCB_OFFSET 9 +#define cOCT6100_TLV_TYPE_CH_MAIN_XCB_SIZE 10 +#define cOCT6100_TLV_TYPE_CH_MAIN_YCB_OFFSET 11 +#define cOCT6100_TLV_TYPE_CH_MAIN_YCB_SIZE 12 +#define cOCT6100_TLV_TYPE_FREE_MEM_BASE_ADDRESS 13 +#define cOCT6100_TLV_TYPE_CH_ROOT_CONF_OFFSET 14 + +#define cOCT6100_TLV_TYPE_POA_CH_MAIN_ZPO_OFFSET 15 +#define cOCT6100_TLV_TYPE_POA_CH_MAIN_ZPO_SIZE 16 +#define cOCT6100_TLV_TYPE_POA_CH_MAIN_YPO_OFFSET 17 +#define cOCT6100_TLV_TYPE_POA_CH_MAIN_YPO_SIZE 18 +#define cOCT6100_TLV_TYPE_POA_BOFF_RW_ZWP 19 +#define cOCT6100_TLV_TYPE_POA_BOFF_RW_ZIS 20 +#define cOCT6100_TLV_TYPE_POA_BOFF_RW_ZSP 21 +#define cOCT6100_TLV_TYPE_POA_BOFF_RW_YWP 22 +#define cOCT6100_TLV_TYPE_POA_BOFF_RW_YIS 23 +#define cOCT6100_TLV_TYPE_POA_BOFF_RW_YSP 24 +#define cOCT6100_TLV_TYPE_POA_BOFF_RO_ZRP 25 +#define cOCT6100_TLV_TYPE_POA_BOFF_RO_YRP 26 + +#define cOCT6100_TLV_TYPE_CNR_CONF_BOFF_RW_ENABLE 27 +#define cOCT6100_TLV_TYPE_ANR_CONF_BOFF_RW_ENABLE 28 + +#define cOCT6100_TLV_TYPE_HZ_CONF_BOFF_RW_ENABLE 29 +#define cOCT6100_TLV_TYPE_HX_CONF_BOFF_RW_ENABLE 30 + +#define cOCT6100_TLV_TYPE_LCA_Z_CONF_BOFF_RW_GAIN 31 +#define cOCT6100_TLV_TYPE_LCA_Y_CONF_BOFF_RW_GAIN 32 + +#define cOCT6100_TLV_TYPE_CNA_CONF_BOFF_RW_ENABLE 33 + +#define cOCT6100_TLV_TYPE_NOA_CONF_BOFF_RW_ENABLE 34 + +#define cOCT6100_TLV_TYPE_VFA_CONF_BOFF_RW_ENABLE 35 + +#define cOCT6100_TLV_TYPE_TLA_MAIN_IO_BOFF_RW_TAIL_DISP 37 + +#define cOCT6100_TLV_TYPE_STATSA_MAIN_IO_BOFF_RO_EPC 38 +#define cOCT6100_TLV_TYPE_BOOTA_POUCH_BOFF_RW_BOOT_INST 39 +#define cOCT6100_TLV_TYPE_BOOTA_POUCH_BOFF_RW_BOOT_RESULT 40 + +#define cOCT6100_TLV_TYPE_DIS_CONF_BOFF_RW_ENABLE 41 +#define cOCT6100_TLV_TYPE_TDM_CONF_BOFF_RW_ENABLE 42 +#define cOCT6100_TLV_TYPE_NT_CONF_BOFF_RW_ENABLE 43 +#define cOCT6100_TLV_TYPE_AEC_CONF_BOFF_RW_ENABLE 44 + +#define cOCT6100_TLV_TYPE_PCM_LEAK_CONF_BOFF_RW 45 +#define cOCT6100_TLV_TYPE_DEFAULT_ERL_CONF_BOFF_RW 46 +#define cOCT6100_TLV_TYPE_TONE_REM_CONF_BOFF_RW_ENABLE 47 + +#define cOCT6100_TLV_TYPE_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT 48 + +#define cOCT6100_TLV_TYPE_NLP_CONV_CAP_CONF_BOFF_RW 49 +#define cOCT6100_TLV_TYPE_MATRIX_EVENT_SIZE 50 +#define cOCT6100_TLV_TYPE_CNR_RW_ENABLE 51 +#define cOCT6100_TLV_TYPE_MAX_TAIL_LENGTH_RW_ENABLE 52 + +#define cOCT6100_TLV_TYPE_PLAYOUT_ENABLE 53 +#define cOCT6100_TLV_TYPE_DOMINANT_SPEAKER_BOFF_RW_ENABLE 54 + +#define cOCT6100_TLV_TYPE_ANR_RW_ENABLE 57 +#define cOCT6100_TLV_TYPE_TONE_REMOVAL_ENABLE 58 +#define cOCT6100_TLV_TYPE_MUSIC_PROTECTION_RW_ENABLE 59 +#define cOCT6100_TLV_TYPE_TAIL_DISP_CONF_BOFF_RW_ENABLE 60 +#define cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_ENABLE 62 + +#define cOCT6100_TLV_TYPE_AEC_DEFAULT_ERL_BOFF 64 + +#define cOCT6100_TLV_TYPE_Z_ALC_TARGET_BOFF 65 +#define cOCT6100_TLV_TYPE_Y_ALC_TARGET_BOFF 66 +#define cOCT6100_TLV_TYPE_Z_HLC_TARGET_BOFF 67 +#define cOCT6100_TLV_TYPE_Y_HLC_TARGET_BOFF 68 +#define cOCT6100_TLV_TYPE_ALC_HLC_STATUS_BOFF 69 + +#define cOCT6100_TLV_TYPE_Z_PLAYOUT_HARD_SKIP_BOFF 70 +#define cOCT6100_TLV_TYPE_Y_PLAYOUT_HARD_SKIP_BOFF 71 + +#define cOCT6100_TLV_TYPE_AFT_FIELD_BOFF 72 + +#define cOCT6100_TLV_TYPE_VOICE_DETECTED_STAT_BOFF 73 + +#define cOCT6100_TLV_TYPE_GAIN_APPLIED_RIN_STAT_BOFF 74 +#define cOCT6100_TLV_TYPE_GAIN_APPLIED_SOUT_STAT_BOFF 75 + +#define cOCT6100_TLV_TYPE_MAX_ADAPT_ALE_BOFF 77 +#define cOCT6100_TLV_TYPE_RIN_ANR_BOFF 78 + +#define cOCT6100_TLV_TYPE_NUMBER_PLAYOUT_EVENTS 79 + +#define cOCT6100_TLV_TYPE_RIN_MUTE_BOFF 80 +#define cOCT6100_TLV_TYPE_SIN_MUTE_BOFF 81 + +#define cOCT6100_TLV_TYPE_CHAN_TAIL_LENGTH_BOFF 82 + +#define cOCT6100_TLV_TYPE_CHAN_VQE_TONE_DISABLING_BOFF 83 + +#define cOCT6100_TLV_TYPE_ANR_SNR_IMPROVEMENT_BOFF 84 +#define cOCT6100_TLV_TYPE_ANR_AGRESSIVITY_BOFF 85 + +#define cOCT6100_TLV_TYPE_RIN_TONE_REM_CONF_BOFF_RW_ENABLE 86 +#define cOCT6100_TLV_TYPE_RIN_TONE_REM_COUNTER_BOFF 87 + +#define cOCT6100_TLV_TYPE_AF_TAIL_DISP_VALUE_BOFF 88 + +#define cOCT6100_TLV_TYPE_POUCH_COUNTER_BOFF 89 + +#define cOCT6100_TLV_TYPE_AEC_TAIL_LENGTH_BOFF 90 + +#define cOCT6100_TLV_TYPE_MATRIX_DWORD_BASE 91 +#define cOCT6100_TLV_TYPE_DEBUG_CHAN_STATS_BYTE_SIZE 92 +#define cOCT6100_TLV_TYPE_RECORDED_PCM_EVENT_BYTE_SIZE 93 +#define cOCT6100_TLV_TYPE_HOT_CHANNEL_SELECT_DWORD_BASE 94 +#define cOCT6100_TLV_TYPE_IS_ISR_CALLED_BOFF 95 + +#define cOCT6100_TLV_TYPE_MATRIX_TIMESTAMP_DWORD_BASE 96 + +#define cOCT6100_TLV_TYPE_CHAN_MAIN_IO_STATS_OFFSET 100 +#define cOCT6100_TLV_TYPE_CHAN_MAIN_IO_STATS_SIZE 101 + +#define cOCT6100_TLV_TYPE_AF_WRITE_PTR_BYTE_OFFSET 104 +#define cOCT6100_TLV_TYPE_MATRIX_WP_DWORD_BASE 105 +#define cOCT6100_TLV_TYPE_DEBUG_CHAN_LITE_STATS_BYTE_SIZE 106 + +#define cOCT6100_TLV_TYPE_MUSIC_PROTECTION_ENABLE_BOFF 107 + +#define cOCT6100_TLV_TYPE_IMAGE_TYPE 108 +#define cOCT6100_TLV_TYPE_MAX_WIRELINE_CHANNELS 111 + +#define cOCT6100_TLV_TYPE_AF_EVENT_CB_SIZE 112 + +#define cOCT6100_TLV_TYPE_ZZ_ENERGY_CHAN_STATS_BOFF 116 +#define cOCT6100_TLV_TYPE_YY_ENERGY_CHAN_STATS_BOFF 117 + +#define cOCT6100_TLV_TYPE_BUFFER_PLAYOUT_SKIP_IN_EVENTS 119 + +#define cOCT6100_TLV_TYPE_SOUT_NOISE_BLEACHING 121 + +#define cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE 124 +#define cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE_BOFF 125 + +#define cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_BOFF 136 + +#define cOCT6100_TLV_TYPE_NLP_STATISTICS 138 + +#define cOCT6100_TLV_TYPE_ADPCM_ENABLE 150 +#define cOCT6100_TLV_TYPE_NUM_TONE_DETECTOR 151 +#define cOCT6100_TLV_TYPE_CONFERENCING_ENABLE 152 +#define cOCT6100_TLV_TYPE_MAX_NUMBER_OF_CHANNELS 153 +#define cOCT6100_TLV_TYPE_DEBUG_CHAN_INDEX_VALUE 154 +#define cOCT6100_TLV_TYPE_TONE_DETECTOR_PROFILE 155 +#define cOCT6100_TLV_TYPE_TEST_MODE_ENABLE 156 +#define cOCT6100_TLV_TYPE_MAX_TAIL_DISPLACEMENT 157 + + +/* TLV length defines. */ +#define cOCT6100_TLV_MIN_LENGTH_DEFAULT 4 +#define cOCT6100_TLV_MAX_LENGTH_DEFAULT 0xFFFFFFFF + +#define cOCT6100_TLV_MIN_LENGTH_VERSION_NUMBER 4 +#define cOCT6100_TLV_MAX_LENGTH_VERSION_NUMBER 1016 +#define cOCT6100_TLV_MIN_LENGTH_CUSTOMER_PROJECT_ID 4 +#define cOCT6100_TLV_MAX_LENGTH_CUSTOMER_PROJECT_ID 4 + + +#define cOCT6100_TLV_MIN_LENGTH_CH0_MAIN_BASE_ADDRESS 4 +#define cOCT6100_TLV_MAX_LENGTH_CH0_MAIN_BASE_ADDRESS 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_IO_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_IO_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_ZCB_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_ZCB_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_ZCB_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_ZCB_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_XCB_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_XCB_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_XCB_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_XCB_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_YCB_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_YCB_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_MAIN_YCB_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_MAIN_YCB_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_FREE_MEM_BASE_ADDRESS 4 +#define cOCT6100_TLV_MAX_LENGTH_FREE_MEM_BASE_ADDRESS 4 +#define cOCT6100_TLV_MIN_LENGTH_CH_ROOT_CONF_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_CH_ROOT_CONF_OFFSET 4 + +#define cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_ZPO_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_ZPO_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_ZPO_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_ZPO_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_YPO_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_YPO_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_YPO_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_YPO_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZWP 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZWP 8 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZIS 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZIS 8 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZSP 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZSP 8 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YWP 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YWP 8 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YIS 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YIS 8 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YSP 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YSP 8 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RO_ZRP 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RO_ZRP 8 +#define cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RO_YRP 8 +#define cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RO_YRP 8 + +#define cOCT6100_TLV_MIN_LENGTH_CNR_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_CNR_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_ANR_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_ANR_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_HZ_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_HZ_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_HX_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_HX_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_LCA_Z_CONF_BOFF_RW_GAIN 8 +#define cOCT6100_TLV_MAX_LENGTH_LCA_Z_CONF_BOFF_RW_GAIN 8 +#define cOCT6100_TLV_MIN_LENGTH_LCA_Y_CONF_BOFF_RW_GAIN 8 +#define cOCT6100_TLV_MAX_LENGTH_LCA_Y_CONF_BOFF_RW_GAIN 8 + +#define cOCT6100_TLV_MIN_LENGTH_CNA_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_CNA_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_NOA_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_NOA_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_VFA_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_VFA_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_TLA_MAIN_IO_BOFF_RW_TAIL_DISP 8 +#define cOCT6100_TLV_MAX_LENGTH_TLA_MAIN_IO_BOFF_RW_TAIL_DISP 8 + +#define cOCT6100_TLV_MIN_LENGTH_STATSA_MAIN_IO_BOFF_RO_EPC 8 +#define cOCT6100_TLV_MAX_LENGTH_STATSA_MAIN_IO_BOFF_RO_EPC 8 + +#define cOCT6100_TLV_MIN_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_INST 8 +#define cOCT6100_TLV_MAX_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_INST 8 +#define cOCT6100_TLV_MIN_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_RESULT 8 +#define cOCT6100_TLV_MAX_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_RESULT 8 + +#define cOCT6100_TLV_MIN_LENGTH_CHAN_MAIN_IO_STATS_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_CHAN_MAIN_IO_STATS_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_CHAN_MAIN_IO_STATS_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_CHAN_MAIN_IO_STATS_SIZE 4 + +#define cOCT6100_TLV_MIN_LENGTH_CDA_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_CDA_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_TDM_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_TDM_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_DIS_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_DIS_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_NT_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_NT_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_AEC_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_AEC_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_PCM_LEAK_CONF_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_PCM_LEAK_CONF_BOFF_RW 8 +#define cOCT6100_TLV_MIN_LENGTH_DEFAULT_ERL_CONF_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_DEFAULT_ERL_CONF_BOFF_RW 8 +#define cOCT6100_TLV_MIN_LENGTH_TONE_REM_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_TONE_REM_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_NLP_CONV_CAP_CONF_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_NLP_CONV_CAP_CONF_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT 8 +#define cOCT6100_TLV_MAX_LENGTH_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT 8 + +#define cOCT6100_TLV_MIN_LENGTH_DOMINANT_SPEAKER_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_DOMINANT_SPEAKER_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_TAIL_DISP_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_TAIL_DISP_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_AEC_DEFAULT_ERL_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_AEC_DEFAULT_ERL_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_Z_ALC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_Z_ALC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_Y_ALC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_Y_ALC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_Z_HLC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_Z_HLC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_Y_HLC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_Y_HLC_TARGET_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MIN_LENGTH_ALC_HLC_STATUS_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_ALC_HLC_STATUS_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_Z_PLAYOUT_HARD_SKIP_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_Z_PLAYOUT_HARD_SKIP_BOFF_RW 8 +#define cOCT6100_TLV_MIN_LENGTH_Y_PLAYOUT_HARD_SKIP_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_Y_PLAYOUT_HARD_SKIP_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_AFT_FIELD_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_AFT_FIELD_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_VOICE_DETECTED_STAT_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_VOICE_DETECTED_STAT_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_GAIN_APPLIED_RIN_STAT_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_GAIN_APPLIED_RIN_STAT_BOFF_RW 8 +#define cOCT6100_TLV_MIN_LENGTH_GAIN_APPLIED_SOUT_STAT_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_GAIN_APPLIED_SOUT_STAT_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_MAX_ADAPT_ALE_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_MAX_ADAPT_ALE_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_RIN_ANR_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_RIN_ANR_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_RIN_MUTE_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_RIN_MUTE_BOFF_RW 8 +#define cOCT6100_TLV_MIN_LENGTH_SIN_MUTE_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_SIN_MUTE_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_ANR_SNR_IMPROVEMENT_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_ANR_SNR_IMPROVEMENT_BOFF_RW 8 +#define cOCT6100_TLV_MIN_LENGTH_ANR_AGRESSIVITY_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_ANR_AGRESSIVITY_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_CHAN_TAIL_LENGTH_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_CHAN_TAIL_LENGTH_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_CHAN_VQE_TONE_DIS_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_CHAN_VQE_TONE_DIS_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_RIN_TONE_REM_CONF_BOFF_RW_ENABLE 8 +#define cOCT6100_TLV_MAX_LENGTH_RIN_TONE_REM_CONF_BOFF_RW_ENABLE 8 + +#define cOCT6100_TLV_MIN_LENGTH_RIN_TONE_REM_COUNTER_BOFF_RW 8 +#define cOCT6100_TLV_MAX_LENGTH_RIN_TONE_REM_COUNTER_BOFF_RW 8 + +#define cOCT6100_TLV_MIN_LENGTH_AF_TAIL_DISP_VALUE_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_AF_TAIL_DISP_VALUE_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_POUCH_COUNTER_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_POUCH_COUNTER_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_AEC_TAIL_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_AEC_TAIL_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_IS_ISR_CALLED_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_IS_ISR_CALLED_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_MUSIC_PROTECTION_ENABLE_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_MUSIC_PROTECTION_ENABLE_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_ZZ_ENERGY_CHAN_STATS_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_ZZ_ENERGY_CHAN_STATS_BOFF 8 +#define cOCT6100_TLV_MIN_LENGTH_YY_ENERGY_CHAN_STATS_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_YY_ENERGY_CHAN_STATS_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_DOUBLE_TALK_BEH_MODE_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_DOUBLE_TALK_BEH_MODE_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_IDLE_CODE_DETECTION_BOFF 8 +#define cOCT6100_TLV_MAX_LENGTH_IDLE_CODE_DETECTION_BOFF 8 + +#define cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_INDEX_VALUE 4 +#define cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_INDEX_VALUE 4 +#define cOCT6100_TLV_MIN_LENGTH_ADPCM_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_ADPCM_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_NUM_TONE_DETECTOR 4 +#define cOCT6100_TLV_MAX_LENGTH_NUM_TONE_DETECTOR 4 +#define cOCT6100_TLV_MIN_LENGTH_CONFERENCING_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_CONFERENCING_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_MAX_NUMBER_OF_CHANNELS 4 +#define cOCT6100_TLV_MAX_LENGTH_MAX_NUMBER_OF_CHANNELS 4 +#define cOCT6100_TLV_MIN_LENGTH_TONE_DETECTOR_PROFILE 4 +#define cOCT6100_TLV_MAX_LENGTH_TONE_DETECTOR_PROFILE 4 +#define cOCT6100_TLV_MIN_LENGTH_TEST_MODE_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_TEST_MODE_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_MAX_TAIL_DISPLACEMENT 4 +#define cOCT6100_TLV_MAX_LENGTH_MAX_TAIL_DISPLACEMENT 4 +#define cOCT6100_TLV_MIN_LENGTH_MATRIX_EVENT_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_MATRIX_EVENT_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_CNR_RW_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_CNR_RW_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_ANR_RW_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_ANR_RW_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_MAX_TAIL_LENGTH_RW_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_MAX_TAIL_LENGTH_RW_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_PLAYOUT_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_PLAYOUT_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_MUSIC_PROTECTION_RW_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_MUSIC_PROTECTION_RW_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_TONE_REMOVAL_ENABLE 4 +#define cOCT6100_TLV_MAX_LENGTH_TONE_REMOVAL_ENABLE 4 +#define cOCT6100_TLV_MIN_LENGTH_NUMBER_PLAYOUT_EVENTS 4 +#define cOCT6100_TLV_MAX_LENGTH_NUMBER_PLAYOUT_EVENTS 4 +#define cOCT6100_TLV_MIN_LENGTH_MATRIX_DWORD_BASE 4 +#define cOCT6100_TLV_MAX_LENGTH_MATRIX_DWORD_BASE 4 +#define cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_STATS_BYTE_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_STATS_BYTE_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_HOT_CHANNEL_SELECT_DWORD_BASE 4 +#define cOCT6100_TLV_MAX_LENGTH_HOT_CHANNEL_SELECT_DWORD_BASE 4 +#define cOCT6100_TLV_MIN_LENGTH_TIMESTAMP_DWORD_BASE 4 +#define cOCT6100_TLV_MAX_LENGTH_TIMESTAMP_DWORD_BASE 4 +#define cOCT6100_TLV_MIN_LENGTH_AF_WRITE_PTR_BYTE_OFFSET 4 +#define cOCT6100_TLV_MAX_LENGTH_AF_WRITE_PTR_BYTE_OFFSET 4 +#define cOCT6100_TLV_MIN_LENGTH_RECORDED_PCM_EVENT_BYTE_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_RECORDED_PCM_EVENT_BYTE_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_MATRIX_WP_DWORD_BASE 4 +#define cOCT6100_TLV_MAX_LENGTH_MATRIX_WP_DWORD_BASE 4 +#define cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_LITE_STATS_BYTE_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_LITE_STATS_BYTE_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_IMAGE_TYPE 4 +#define cOCT6100_TLV_MAX_LENGTH_IMAGE_TYPE 4 +#define cOCT6100_TLV_MIN_LENGTH_MAX_WIRELINE_CHANNELS 4 +#define cOCT6100_TLV_MAX_LENGTH_MAX_WIRELINE_CHANNELS 4 +#define cOCT6100_TLV_MIN_LENGTH_AF_EVENT_CB_BYTE_SIZE 4 +#define cOCT6100_TLV_MAX_LENGTH_AF_EVENT_CB_BYTE_SIZE 4 +#define cOCT6100_TLV_MIN_LENGTH_BUFFER_PLAYOUT_SKIP_IN_EVENTS 4 +#define cOCT6100_TLV_MAX_LENGTH_BUFFER_PLAYOUT_SKIP_IN_EVENTS 4 +#define cOCT6100_TLV_MIN_LENGTH_DOUBLE_TALK_BEH_MODE 4 +#define cOCT6100_TLV_MAX_LENGTH_DOUBLE_TALK_BEH_MODE 4 +#define cOCT6100_TLV_MIN_LENGTH_SOUT_NOISE_BLEACHING 4 +#define cOCT6100_TLV_MAX_LENGTH_SOUT_NOISE_BLEACHING 4 +#define cOCT6100_TLV_MIN_LENGTH_IDLE_CODE_DETECTION 4 +#define cOCT6100_TLV_MAX_LENGTH_IDLE_CODE_DETECTION 4 +#define cOCT6100_TLV_MIN_LENGTH_NLP_STATISTICS 4 +#define cOCT6100_TLV_MAX_LENGTH_NLP_STATISTICS 4 + + +/***************************** TYPES ***************************************/ + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiProcessTlvRegion( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiInterpretTlvEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulTlvFieldType, + IN UINT32 f_ulTlvFieldLength, + IN UINT32 f_ulTlvValueAddress ); + +static UINT32 Oct6100ApiTlvCheckLengthField( + IN OUT UINT32 f_ulTlvFieldLength, + IN UINT32 f_ulMinLengthValue, + IN UINT32 f_ulMaxLengthValue ); + +UINT32 Oct6100ApiTlvReadDword( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulAddress, + OUT PUINT32 f_pulReadData ); + +static UINT32 Oct6100ApiTlvReadBitOffsetStruct( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulAddress, + OUT tPOCT6100_TLV_OFFSET f_pBitOffsetStruct ); + +#endif /* __OCT6100_TLV_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_tone_detection_inst.h b/include/oct6100api/oct6100_tone_detection_inst.h new file mode 100644 index 0000000..3e1b72e --- /dev/null +++ b/include/oct6100api/oct6100_tone_detection_inst.h @@ -0,0 +1,46 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tone_detection_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_tone_detection_buf.c. All elements defined in this file are for + public usage of the API. All private elements are defined in the + oct6100_tone_detection_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 8 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TONE_DETECTION_INST_H__ +#define __OCT6100_TONE_DETECTION_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + + +#endif /* __OCT6100_TONE_DETECTION_INST_H__ */ diff --git a/include/oct6100api/oct6100_tone_detection_priv.h b/include/oct6100api/oct6100_tone_detection_priv.h new file mode 100644 index 0000000..24bcd4c --- /dev/null +++ b/include/oct6100api/oct6100_tone_detection_priv.h @@ -0,0 +1,106 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tone_detection_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_tone_detection.c. All elements defined in + this file are for private usage of the API. All public elements are + defined in the oct6100_tone_detection_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 13 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TONE_DETECTION_PRIV_H__ +#define __OCT6100_TONE_DETECTION_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ToneDetectionEnableSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable ); + +static UINT32 Oct6100ApiCheckToneEnableParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT32 f_pulToneEventNumber, + + OUT PUINT32 f_pulExtToneChanIndex ); + +static UINT32 Oct6100ApiWriteToneDetectEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + + IN UINT32 f_ulExtToneChanIndex ); + +static UINT32 Oct6100ApiUpdateChanToneDetectEntry ( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + IN UINT32 f_ulExtToneChanIndex ); + +static UINT32 Oct6100ToneDetectionDisableSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable ); + +static UINT32 Oct6100ApiAssertToneDetectionParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT32 f_pulToneEventNumber, + OUT PUINT32 f_pulExtToneChanIndex, + + OUT PBOOL f_pfDisableAll ); + +static UINT32 Oct6100ApiClearToneDetectionEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + IN UINT32 f_ulExtToneChanIndex, + + IN BOOL f_fDisableAll ); + +static UINT32 Oct6100ApiReleaseToneDetectionEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + IN UINT32 f_ulExtToneChanIndex, + IN BOOL f_fDisableAll ); + +static UINT32 Oct6100ApiIsSSTone( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulToneEventNumber, + OUT PBOOL f_fSSTone ); + +#endif /* __OCT6100_TONE_DETECTION_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_tone_detection_pub.h b/include/oct6100api/oct6100_tone_detection_pub.h new file mode 100644 index 0000000..93e9688 --- /dev/null +++ b/include/oct6100api/oct6100_tone_detection_pub.h @@ -0,0 +1,74 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tone_detection_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_tone_detection.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_tone_detection_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 10 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TONE_DETECTION_PUB_H__ +#define __OCT6100_TONE_DETECTION_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_TONE_DETECTION_ENABLE_ +{ + UINT32 ulChannelHndl; + UINT32 ulToneNumber; + +} tOCT6100_TONE_DETECTION_ENABLE, *tPOCT6100_TONE_DETECTION_ENABLE; + +typedef struct _OCT6100_TONE_DETECTION_DISABLE_ +{ + UINT32 ulChannelHndl; + UINT32 ulToneNumber; + BOOL fDisableAll; + +} tOCT6100_TONE_DETECTION_DISABLE, *tPOCT6100_TONE_DETECTION_DISABLE; + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ToneDetectionEnableDef( + OUT tPOCT6100_TONE_DETECTION_ENABLE f_pBufferLoad ); +static UINT32 Oct6100ToneDetectionEnable( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TONE_DETECTION_ENABLE f_pBufferLoad ); + +static UINT32 Oct6100ToneDetectionDisableDef( + OUT tPOCT6100_TONE_DETECTION_DISABLE f_pBufferUnload ); +UINT32 Oct6100ToneDetectionDisable( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TONE_DETECTION_DISABLE f_pBufferUnload ); + +#endif /* __OCT6100_TONE_DETECTION_PUB_H__ */ diff --git a/include/oct6100api/oct6100_tsi_cnct_inst.h b/include/oct6100api/oct6100_tsi_cnct_inst.h new file mode 100644 index 0000000..31f9be3 --- /dev/null +++ b/include/oct6100api/oct6100_tsi_cnct_inst.h @@ -0,0 +1,70 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tsi_cnct_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_tsi_cnct.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_tsi_cnct_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 8 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TSI_CNCT_INST_H__ +#define __OCT6100_TSI_CNCT_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_TSI_CNCT_ +{ + /* Flag specifying whether the entry is used or not. */ + UINT8 fReserved; + + /* Count used to manage entry handles allocated to user. */ + UINT8 byEntryOpenCnt; + + /* Input PCM law. */ + UINT8 byInputPcmLaw; + + /* TSI chariot memory entry. */ + UINT16 usTsiMemIndex; + + /* Input and output timeslot information. */ + UINT16 usInputTimeslot; + UINT16 usInputStream; + + UINT16 usOutputTimeslot; + UINT16 usOutputStream; + + /* Internal info for quick access to structures associated to this TSI cnct. */ + UINT16 usInputTsstIndex; + UINT16 usOutputTsstIndex; + +} tOCT6100_API_TSI_CNCT, *tPOCT6100_API_TSI_CNCT; + +#endif /* __OCT6100_TSI_CNCT_INST_H__ */ diff --git a/include/oct6100api/oct6100_tsi_cnct_priv.h b/include/oct6100api/oct6100_tsi_cnct_priv.h new file mode 100644 index 0000000..5e70cb0 --- /dev/null +++ b/include/oct6100api/oct6100_tsi_cnct_priv.h @@ -0,0 +1,126 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tsi_cnct_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_tsi_cnct.c. All elements defined in + this file are for private usage of the API. All public elements are + defined in the oct6100_tsi_cnct_pub.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 12 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TSI_CNCT_PRIV_H__ +#define __OCT6100_TSI_CNCT_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + +/***************************** DEFINES *************************************/ + +/* TSI connection list pointer macros. */ +#define mOCT6100_GET_TSI_CNCT_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_TSI_CNCT )(( PVOID )pSharedInfo + pSharedInfo->ulTsiCnctListOfst ); + +#define mOCT6100_GET_TSI_CNCT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_TSI_CNCT )(( PVOID )pSharedInfo + pSharedInfo->ulTsiCnctListOfst)) + ulIndex; + +#define mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulTsiCnctAllocOfst); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetTsiCnctSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiTsiCnctSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + + +UINT32 Oct6100TsiCnctOpenSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ); + +UINT32 Oct6100ApiCheckTsiParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ); + +UINT32 Oct6100ApiReserveTsiResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen, + OUT PUINT16 f_pusTsiChanIndex, + OUT PUINT16 f_pusTsiMemIndex, + OUT PUINT16 f_pusInputTsstIndex, + OUT PUINT16 f_pusOutputTsstIndex ); + +UINT32 Oct6100ApiWriteTsiStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen, + IN UINT16 f_usTsiMemIndex, + IN UINT16 f_usInputTsstIndex, + IN UINT16 f_usOutputTsstIndex ); + +UINT32 Oct6100ApiUpdateTsiEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen, + IN UINT16 f_usTsiChanIndex, + IN UINT16 f_usTsiMemIndex, + IN UINT16 f_usInputTsstIndex, + IN UINT16 f_usOutputTsstIndex ); + + +UINT32 Oct6100TsiCnctCloseSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose ); + +UINT32 Oct6100ApiAssertTsiParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose, + OUT PUINT16 f_pusTsiChanIndex, + OUT PUINT16 f_pusTsiMemIndex, + OUT PUINT16 f_pusInputTsstIndex, + OUT PUINT16 f_pusOutputTsstIndex ); + +UINT32 Oct6100ApiInvalidateTsiStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usInputTsstIndex, + IN UINT16 f_usOutputTsstIndex ); + +UINT32 Oct6100ApiReleaseTsiResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsiChanIndex, + IN UINT16 f_usTsiMemIndex ); + +UINT32 Oct6100ApiReserveTsiCnctEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusTsiChanIndex ); + +UINT32 Oct6100ApiReleaseTsiCnctEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsiChanIndex ); + +#endif /* __OCT6100_TSI_CNCT_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_tsi_cnct_pub.h b/include/oct6100api/oct6100_tsi_cnct_pub.h new file mode 100644 index 0000000..9a8ae50 --- /dev/null +++ b/include/oct6100api/oct6100_tsi_cnct_pub.h @@ -0,0 +1,77 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tsi_cnct_pub.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_tsi_cnct.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_tsi_cnct_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 10 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TSI_CNCT_PUB_H__ +#define __OCT6100_TSI_CNCT_PUB_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_TSI_CNCT_OPEN_ +{ + PUINT32 pulTsiCnctHndl; + + UINT32 ulInputTimeslot; + UINT32 ulInputStream; + UINT32 ulOutputTimeslot; + UINT32 ulOutputStream; + +} tOCT6100_TSI_CNCT_OPEN, *tPOCT6100_TSI_CNCT_OPEN; + +typedef struct _OCT6100_TSI_CNCT_CLOSE_ +{ + UINT32 ulTsiCnctHndl; + +} tOCT6100_TSI_CNCT_CLOSE, *tPOCT6100_TSI_CNCT_CLOSE; + +/************************** FUNCTION PROTOTYPES *****************************/ + +UINT32 Oct6100TsiCnctOpenDef( + OUT tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ); +UINT32 Oct6100TsiCnctOpen( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ); + +UINT32 Oct6100TsiCnctCloseDef( + OUT tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose ); +UINT32 Oct6100TsiCnctClose( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose ); + +#endif /* __OCT6100_TSI_CNCT_PUB_H__ */ + diff --git a/include/oct6100api/oct6100_tsst_inst.h b/include/oct6100api/oct6100_tsst_inst.h new file mode 100644 index 0000000..34bb022 --- /dev/null +++ b/include/oct6100api/oct6100_tsst_inst.h @@ -0,0 +1,55 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tsst_inst.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all defines, macros, and structures pertaining to the file + oct6100_tsst.c. All elements defined in this file are for public + usage of the API. All private elements are defined in the + oct6100_tsst_priv.h file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 5 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TSST_INST_H__ +#define __OCT6100_TSST_INST_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + + +/***************************** TYPES ***************************************/ + +typedef struct _OCT6100_API_TSST_ENTRY_ +{ + UINT16 usTsstMemoryIndex; /* Index in the TSST memory of the TSST */ + UINT16 usTsstValue; /* Tsst value given by the user. */ + /* bit 5:0 = stream value, bit 13:6 = timeslot value. */ + + UINT16 usNextEntry; /* Pointer to the next entry in the list. */ + +} tOCT6100_API_TSST_ENTRY, *tPOCT6100_API_TSST_ENTRY; + +#endif /* __OCT6100_TSST_INST_H__ */ diff --git a/include/oct6100api/oct6100_tsst_priv.h b/include/oct6100api/oct6100_tsst_priv.h new file mode 100644 index 0000000..fce0142 --- /dev/null +++ b/include/oct6100api/oct6100_tsst_priv.h @@ -0,0 +1,89 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tsst_priv.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + File containing all private defines, macros, structures and prototypes + pertaining to the file oct6100_tsst.c. All elements defined in + this file are for private usage of the API. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 13 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_TSST_PRIV_H__ +#define __OCT6100_TSST_PRIV_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ + +/* TSST allocation and serialization pointer macros. */ +#define mOCT6100_GET_TSST_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PUINT32 )(( PVOID )pSharedInfo + pSharedInfo->ulTsstAllocOfst); + +#define mOCT6100_GET_TSST_LIST_PNT( pSharedInfo, pList ) \ + pList = ( tPOCT6100_API_TSST_ENTRY )(( PVOID )pSharedInfo + pSharedInfo->ulTsstListOfst ); + +#define mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \ + pEntry = (( tPOCT6100_API_TSST_ENTRY )(( PVOID )pSharedInfo + pSharedInfo->ulTsstListOfst)) + ulIndex; + +#define mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pAlloc ) \ + pAlloc = ( PVOID )(( PVOID )pSharedInfo + pSharedInfo->ulTsstListAllocOfst); + +/***************************** TYPES ***************************************/ + + +/************************** FUNCTION PROTOTYPES *****************************/ + +static UINT32 Oct6100ApiGetTsstSwSizes( + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ); + +static UINT32 Oct6100ApiTsstSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ); + +static UINT32 Oct6100ApiValidateTsst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulNumTssts, + IN UINT32 f_ulTimeslot, + IN UINT32 f_ulStream, + IN UINT32 f_ulDirection ); + +static UINT32 Oct6100ApiReserveTsst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulTimeslot, + IN UINT32 f_ulStream, + IN UINT32 f_ulNumTsst, + IN UINT32 f_ulDirection, + OUT PUINT16 f_pusTsstMemIndex, + OUT PUINT16 f_pusTsstListIndex ); + +static UINT32 Oct6100ApiReleaseTsst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulTimeslot, + IN UINT32 f_ulStream, + IN UINT32 f_ulNumTsst, + IN UINT32 f_ulDirection, + IN UINT16 f_usTsstListIndex ); + +#endif /* __OCT6100_TSST_PRIV_H__ */ diff --git a/include/oct6100api/oct6100_version.h b/include/oct6100api/oct6100_version.h new file mode 100644 index 0000000..31db16e --- /dev/null +++ b/include/oct6100api/oct6100_version.h @@ -0,0 +1,39 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_version.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the version of API. To obtain that version + number, the user must call the API function Oct6100ApiGetVersion(). + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 39 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_VERSION_H__ +#define __OCT6100_VERSION_H__ + +/* String version of the OCT6100 API.*/ + +#define cOCT6100_API_VERSION "OCT6100API-01.00-PR38" + +#endif /* __OCT6100_VERSION_H__ */ diff --git a/include/octdef.h b/include/octdef.h new file mode 100644 index 0000000..9631727 --- /dev/null +++ b/include/octdef.h @@ -0,0 +1,104 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octdef.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: Common system definitions + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 11 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCTDEF_H__ +#define __OCTDEF_H__ + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** INCLUDE FILES *******************************/ + +/*-------------------------------------------------------------------------- + Get Platform Dependency headers +----------------------------------------------------------------------------*/ +#include "octosdependant.h" + + +/*-------------------------------------------------------------------------- + Common Type definitions +----------------------------------------------------------------------------*/ +#include "octtype.h" + +/***************************** DEFINES *************************************/ + + + +/*-------------------------------------------------------------------------- + Miscellaneous constants +----------------------------------------------------------------------------*/ + +#ifndef PROTO +#define PROTO extern +#endif + +/* Generic return codes */ +#define cOCTDEF_RC_OK 0 /* Generic Ok */ +#define cOCTDEF_RC_ERROR 1 /* Generic Error */ + +/* Default return values of all OCTAPI functions.*/ +#ifndef GENERIC_OK +#define GENERIC_OK 0x00000000 +#endif + +#ifndef GENERIC_ERROR +#define GENERIC_ERROR 0x00000001 +#endif + +#ifndef GENERIC_BAD_PARAM +#define GENERIC_BAD_PARAM 0x00000002 +#endif + +/* Defines of boolean expressions (TRUE/FALSE)*/ +#ifndef FALSE +#define FALSE (BOOL)0 +#endif + +#ifndef TRUE +#define TRUE (BOOL)1 +#endif + +/*-------------------------------------------------------------------------- + DLL Import-Export +----------------------------------------------------------------------------*/ + +#ifdef OCT_WINENV +#define DLLIMP __declspec( dllimport ) +#define DLLEXP __declspec( dllexport ) +#else +#define DLLIMP +#define DLLEXP +#endif + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif /* __OCTDEF_H__ */ diff --git a/include/octmac.h b/include/octmac.h new file mode 100644 index 0000000..f8ce932 --- /dev/null +++ b/include/octmac.h @@ -0,0 +1,90 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octmac.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 13 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#ifndef __OCTMAC_H__ +#define __OCTMAC_H__ + + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + + +/***************************** DEFINES *************************************/ + +/* Combine l & h to form a 32 bit quantity. */ +#define mMAKEULONG(l, h) ((ULONG)(((USHORT)(l)) | (((ULONG)((USHORT)(h))) << 16))) + +#define mLOUCHAR(w) ((UCHAR)(w)) +#define mHIUCHAR(w) ((UCHAR)(((USHORT)(w) >> 8) & 0xff)) +#define mLOUSHORT(l) ((USHORT)((ULONG)l)) +#define mHIUSHORT(l) ((USHORT)(((ULONG)(l) >> 16) & 0xffff)) +#define mLOSHORT(l) ((SHORT)((ULONG)l)) +#define mHISHORT(l) ((SHORT)(((ULONG)(l) >> 16) & 0xffff)) + +/* Combine l & h to form a 16 bit quantity. */ +#define mMAKEUSHORT(l, h) (((USHORT)(l)) | ((USHORT)(h)) << 8) +#define mMAKESHORT(l, h) ((SHORT)mMAKEUSHORT(l, h)) + +/* Extract high and low order parts of 16 and 32 bit quantity */ +#define mLOBYTE(w) mLOUCHAR(w) +#define mHIBYTE(w) mHIUCHAR(w) +#define mMAKELONG(l, h) ((LONG)mMAKEULONG(l, h)) + +/*-------------------------------------------------------------------------- + Bite conversion macro +----------------------------------------------------------------------------*/ +#define mSWAP_INT16(x) mMAKEUSHORT( mHIBYTE(x), mLOBYTE(x) ) +#define mSWAP_INT32(x) mMAKEULONG( mSWAP_INT16(mHIUSHORT(x)), mSWAP_INT16(mLOUSHORT(x)) ) + + +/* Cast any variable to an instance of the specified type. */ +#define mMAKETYPE(v, type) (*((type *)&v)) + +/* Calculate the byte offset of a field in a structure of type type. */ +#define mFIELDOFFSET(type, field) ((UINT32)&(((type *)0)->field)) +#define mCOUNTOF(array) (sizeof(array)/sizeof(array[0])) + +#define mMAX(a,b) (((a) > (b)) ? (a) : (b)) +#define mMIN(a,b) (((a) < (b)) ? (a) : (b)) + +#define mDIM(x) (sizeof(x) / sizeof(x[0])) + +#define mFROMDIGIT(ch) ((ch) - 0x30) /* digit to char */ +#define mTODIGIT(ch) ((ch) + 0x30) /* int to char */ + +#define mISLEAP(a) ( !( a % 400 ) || ( ( a % 100 ) && !( a % 4 ) ) ) + +#define mFOREVER for( ;; ) + +#define mROUND_TO_NEXT_4( a ) ( ((a) % 4) ? ( (a) + 4 - ((a)%4) ) : (a) ) + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* __OCTMAC_H__ */ diff --git a/include/octosdependant.h b/include/octosdependant.h new file mode 100644 index 0000000..a55fcf1 --- /dev/null +++ b/include/octosdependant.h @@ -0,0 +1,145 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octosdependant.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: This file is included to set target-specific constants + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 15 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCTOSDEPENDANT_H__ +#define __OCTOSDEPENDANT_H__ + + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + + + +/***************************************************************************** + + Known define values + + MSDEV: + WIN32 == WINDOWS 32 bit app + __WIN32__ == WINDOWS 32 bit app + _Windows == WINDOWS 16 bit app + + _WINDOWS == Windows application .. not console + _DLL == Dll Application + _CONSOLE == Console Application .. no windows + + BORLANDC + __TURBOC__ == Turbo Compiler + __BORLANDC__ == Borland compiler + __OS2__ == Borland OS2 compiler + _Windows == Windows 16 bit app + + GCC Compiler + __GNUC__ == GCC Compiler + __unix__ == Unix system + __vax__ == Unix system + unix == Unix system + vax == vax system + + TORNADO + _VXWORKS_ == VXWORK + + ECOS/CYGWIN + _ECOS_ == eCos + + SOLARIS + _SOLARIS_ == Solaris + +*****************************************************************************/ + +/* Machine endian type */ + +#define OCT_MACH_LITTLE_ENDIAN 1 +#define OCT_MACH_BIG_ENDIAN 2 + +/* Try to find current OCT_MACH_ENDIAN from compiler define values */ +#if !defined( MACH_TYPE_BIG_ENDIAN ) && !defined( MACH_TYPE_LITTLE_ENDIAN ) + + /* Look for intel */ + #if defined( _M_IX86 ) + #define OCT_MACH_ENDIAN OCT_MACH_LITTLE_ENDIAN + /* Look for PowerPC */ + #elif defined( _M_MPPC ) || defined( _M_PPC ) + #define OCT_MACH_ENDIAN OCT_MACH_BIG_ENDIAN + #elif defined( CPU ) + #if CPU==PPC860 || CPU==SIMNT + #define OCT_MACH_ENDIAN OCT_MACH_BIG_ENDIAN + #else + #define OCT_MACH_ENDIAN OCT_MACH_LITTLE_ENDIAN + #endif + /* Default is little endian */ + #else + #define OCT_MACH_ENDIAN OCT_MACH_LITTLE_ENDIAN + #endif +#else + #if defined( MACH_TYPE_BIG_ENDIAN ) + #define OCT_MACH_ENDIAN OCT_MACH_BIG_ENDIAN + #else + #define OCT_MACH_ENDIAN OCT_MACH_LITTLE_ENDIAN + #endif +#endif + +/* Find system type if not already defined */ +#if !defined( OCT_NTDRVENV ) && !defined( OCT_VXENV ) && !defined( OCT_WINENV ) + +#if defined( WIN32 ) || defined( __WIN32__ ) || defined( _WIN32_ ) || defined( WIN32S ) + /* Verif if building a win32 driver */ + #if ( defined( WIN32 ) && WIN32==100 ) + #define OCT_NTDRVENV + #else + #define OCT_WINENV + #endif +#elif defined( _VXWORKS_ ) + #define OCT_VXENV +#elif defined( _ECOS_ ) + #define OCT_ECOSENV +#elif defined( _SOLARIS_ ) + #define OCT_SOLARISENV +#elif defined( _LINUX_ ) + #define OCT_LINUXENV +#else + /* Unknown environment */ + #define OCT_UNKNOWNENV +#endif /* WIN env */ + +#endif /* Already defined */ + +#if defined( __KERNEL__ ) && defined( OCT_LINUXENV ) +#define OCT_LINUXDRVENV +#endif + +#ifdef _DEBUG +#define OCT_OPT_USER_DEBUG +#endif +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* __OCTOSDEPENDANT_H__ */ + diff --git a/include/octrpc/oct6100_rpc_protocol.h b/include/octrpc/oct6100_rpc_protocol.h new file mode 100644 index 0000000..a017a34 --- /dev/null +++ b/include/octrpc/oct6100_rpc_protocol.h @@ -0,0 +1,344 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_rpc_protocol.h + +Copyright (c) 2002 Octasic Inc. All rights reserved. + +Description: + +This section defines the intent of the file. + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 4 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCT6100_RPC_PROTOCOL_H__ +#define __OCT6100_RPC_PROTOCOL_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ +#define cOCTRPC_INTERFACE_VERSION 0x00010002 + +/* Octasic commands */ +#define cOCT6100_RPC_CHIP_LIST 0xFF000000 +#define cOCT6100_RPC_CHIP_CHOICE 0xFF000001 +#define cOCT6100_RPC_ENV_DISCONNECT 0xFF000002 + +/* Commands */ +/* Read commands */ +#define cOCT6100_RPC_READ_WORD 0x00000000 +#define cOCT6100_RPC_READ_BURST 0x00000001 +#define cOCT6100_RPC_READ_DEBUG 0x00000002 +#define cOCT6100_RPC_READ_ARRAY 0x00000003 +#define cOCT6100_RPC_API_DISCONNECT 0x00000004 + +/* Write commands */ +#define cOCT6100_RPC_WRITE_WORD 0x00000010 +#define cOCT6100_RPC_WRITE_BURST 0x00000011 +#define cOCT6100_RPC_WRITE_SMEAR 0x00000012 +#define cOCT6100_RPC_WRITE_INC 0x00000013 + +/* Debug commands.*/ +#define cOCT6100_RPC_SET_HOT_CHANNEL 0x00000014 +#define cOCT6100_RPC_GET_DEBUG_CHAN_INDEX 0x00000015 + +#define cOCTRPC_UNKNOWN_COMMAND_NUM 0xFFFFFFFF + +/* Errors */ +#define cOCT6100_RPCERR_OK 0x00000000 +#define cOCT6100_RPCERR_INVALID_COMMAND_NUMBER 0x00000001 +#define cOCT6100_RPCERR_INVALID_COMMAND_PAYLOAD 0x00000002 +#define cOCT6100_RPCERR_INVALID_COMMAND_LENGTH 0x00000003 + +/***************************** TYPES ***************************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_READ_WORD + +Description: Command structure for the read of one word. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulAddress Address at which to read. +OUT ulReadData The word read, returned. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_READ_WORD_ +{ + UINT32 IN ulAddress; + UINT32 OUT ulReadData; + +} tOCT6100_RPC_READ_WORD, *tPOCT6100_RPC_READ_WORD; + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_READ_BURST + +Description: Command structure for a read burst. The burst starts at the + given address and reads the specified number of consecutive + words. + + Whereas every command structure uses a complete dword for every + member, irrespective of the size of data unit needed, this + structure does not do so for the read data. To save bandwidth + the read data words are returned two per dword. + +Example packet: 31 16 15 0 + ------------------------------------------- + | ulAddress = 0x100 | + ------------------------------------------- + | ulBurstLength = 0x3 | + ------------------------------------------- + aulReadData -> | D0 | D1 | + ------------------------------------------- + | D2 | xx | + ------------------------------------------- + + Dy is the read data at ulAddress + 2 * y. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulAddress Address at which to read. +IN ulBurstLength The number of consecutive words to be read. +OUT aulReadData The read data returned. The dwords of the structure + starting at this address are arranged as indicated in + the example packet above. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_READ_BURST_ +{ + UINT32 IN ulAddress; + UINT32 IN ulBurstLength; + UINT32 OUT aulReadData[ 1 ]; + +} tOCT6100_RPC_READ_BURST, *tPOCT6100_RPC_READ_BURST; + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_READ_ARRAY + +Description: Command structure for a variable number of reads. The reads do + not have to be at contiguous addresses. + + Whereas every command structure uses a complete dword for every + member, irrespective of the size of data unit needed, this + structure does not do so for the read data. To save bandwidth + the read data words are returned two per dword, and the + parity bits are returned 16 per dword (two parity bits per read + access). + +Example packet: 31 16 15 0 + ------------------------------------------- + | ulArrayLength = 0x3 | + ------------------------------------------- + aulArrayData ->| A0 | + ------------------------------------------- + | A1 | + ------------------------------------------- + | A2 | + ------------------------------------------- + | D0 | D1 | + ------------------------------------------- + | D2 | xx | + ------------------------------------------- + + Ay is the address for access y. + Dy is the read data at Ay. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulArrayLength Number of reads to do. +IN OUT aulArrayData The addresses at which to read (IN) and the read data + returned (OUT). The dwords of the command structure + starting at this address are arranged as indicated in + the example packet above. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_READ_ARRAY +{ + UINT32 IN ulArrayLength; + UINT32 IN OUT aulArrayData[ 1 ]; + +} tOCT6100_RPC_READ_ARRAY, *tPOCT6100_RPC_READ_ARRAY; + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_WRITE_WORD + +Description: Command structure for the write of one word. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulAddress Address at which to write. +IN ulWriteData The word to write. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_WRITE_WORD_ +{ + UINT32 IN ulAddress; + UINT32 IN ulParity; + UINT32 IN ulWriteData; + +} tOCT6100_RPC_WRITE_WORD, *tPOCT6100_RPC_WRITE_WORD; + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_WRITE_SMEAR + +Description: Command structure for the write of one word at one or many + consecutive addresses. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulAddress Address of first write. +IN ulSmearLength Number of consecutive addresses to write. +IN ulWriteData The word to write at each address. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_WRITE_SMEAR_ +{ + UINT32 IN ulAddress; + UINT32 IN ulSmearLength; + UINT32 IN ulParity; + UINT32 IN ulWriteData; + +} tOCT6100_RPC_WRITE_SMEAR, *tPOCT6100_RPC_WRITE_SMEAR; + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_WRITE_INC + +Description: Command structure for the write of an incremental pattern at + one or many consecutive addresses. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulAddress Address of first write. +IN ulIncLength Number of consecutive addresses to write. +IN ulWriteData The first word of the incremental pattern. For each + consecutive write the word will be incremented by 1. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_WRITE_INC_ +{ + UINT32 IN ulAddress; + UINT32 IN ulIncLength; + UINT32 IN ulParity; + UINT32 IN ulWriteData; + +} tOCT6100_RPC_WRITE_INC, *tPOCT6100_RPC_WRITE_INC; + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_WRITE_BURST + +Description: Command structure for a write burst. The burst starts at the + given address and writes a given word for each address. + + Whereas every command structure uses a complete dword for every + member, irrespective of the size of data unit needed, this + structure does not do so for the write data. To save bandwidth + the write data words are sent two per dword. + +Example packet: 31 16 15 0 + ------------------------------------------- + | ulAddress = 0x100 | + ------------------------------------------- + | ulBurstLength = 0x3 | + ------------------------------------------- + aulWriteData ->| D0 | D1 | + ------------------------------------------- + | D2 | xx | + ------------------------------------------- + + Dy is the write data for ulAddress + 2 * y. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulAddress First address at which to write. +IN ulBurstLength The number of consecutive addresses to be write. +IN aulWriteData The write data words. The dwords of the structure + starting at this address are arranged as indicated in + the example packet above. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_WRITE_BURST_ +{ + UINT32 IN ulAddress; + UINT32 IN ulBurstLength; + UINT32 IN ulParity; + UINT32 IN aulWriteData[ 1 ]; + +} tOCT6100_RPC_WRITE_BURST, *tPOCT6100_RPC_WRITE_BURST; + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_SET_HOT_CHANNEL + +Description: Command structure to set the hot channel. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulDebugChannel Index of the channel to debug. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_SET_HOT_CHANNEL_ +{ + UINT32 IN ulHotChannel; + UINT32 IN ulPcmLaw; + +} tOCT6100_RPC_SET_HOT_CHANNEL, *tPOCT6100_RPC_SET_HOT_CHANNEL; + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Structure: OCT6100_RPC_GET_DEBUG_CHAN_INDEX + +Description: Command structure to get the debug channel index used by the API. + +------------------------------------------------------------------------------- +| Member | Description +------------------------------------------------------------------------------- +IN ulDebugChannel Index of the channel to debug. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +typedef struct _OCT6100_RPC_GET_DEBUG_CHAN_INDEX_ +{ + UINT32 OUT ulDebugChanIndex; + +} tOCT6100_RPC_GET_DEBUG_CHAN_INDEX, *tPOCT6100_RPC_GET_DEBUG_CHAN_INDEX; + + +/************************** FUNCTION PROTOTYPES *****************************/ + + +#endif /* __OCT6100_RPC_PROTOCOL_H__ */ diff --git a/include/octrpc/rpc_protocol.h b/include/octrpc/rpc_protocol.h new file mode 100644 index 0000000..4cbefd0 --- /dev/null +++ b/include/octrpc/rpc_protocol.h @@ -0,0 +1,107 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: rpc_protocol.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: + +This section defines the intent of the file. + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 22 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __RPC_PROTOCOL_H__ +#define __RPC_PROTOCOL_H__ + +/***************************** INCLUDE FILES *******************************/ + + +/***************************** DEFINES *************************************/ +#define cOCTRPC_ENDIAN_DETECT 0x27182819 +#define cOCTRPC_ENDIAN_DETECT_BYTE_W 0x19 +#define cOCTRPC_ENDIAN_DETECT_BYTE_X 0x28 +#define cOCTRPC_ENDIAN_DETECT_BYTE_Y 0x18 +#define cOCTRPC_ENDIAN_DETECT_BYTE_Z 0x27 +#define cOCTRPC_ECHO_PROTOCOL 0x00000000 + +#define cOCTRPC_MIN_PACKET_BYTE_LENGTH (sizeof( tOCTRPC_OGRDTP_HEADER )) +#define cOCTRPC_FIRST_COMMAND_BYTE_OFFSET (sizeof( tOCTRPC_OGRDTP_HEADER ) + sizeof( tOCTRPC_INTERFACE_HEADER )) +#define cOCTRPC_GENERIC_HEADERS_BYTE_SIZE (sizeof( tOCTRPC_OGRDTP_HEADER ) + sizeof( tOCTRPC_INTERFACE_HEADER ) + sizeof( tOCTRPC_COMMAND_HEADER )) +#define cOCTRPC_MAX_PACKET_BYTE_LENGTH 32768 + +/* Protocol versions */ +#define cOCTRPC_PROTOCOL_V1_0 0x00010000 +#define cOCTRPC_PROTOCOL_V1_1 0x00010001 +#define cOCTRPC_PROTOCOL_V1_2 0x00010002 +#define cOCTRPC_PROTOCOL_V1_3 0x00010003 +#define cOCTRPC_OCTASIC_PROTOCOL_V1_0 0xFF010000 +#define cOCTRPC_OCTASIC_PROTOCOL_V1_1 0xFF010001 +#define cOCTRPC_OCTASIC_PROTOCOL_V1_2 0xFF010002 +#define cOCTRPC_OCTASIC_PROTOCOL_V1_3 0xFF010003 + +/* Chips */ +#define cOCTRPC_OCT8304_INTERFACE 0x00000000 +#define cOCTRPC_OCT6100_INTERFACE 0x00000001 + +/* Timeout values. */ +#define cOCTRPC_SESSION_TIMEOUT 30 + +/* Generic errors */ +#define cOCTRPC_RDBGERR_OK 0x00000000 +#define cOCTRPC_RDBGERR_NO_ANSWER 0xFFFF0000 +#define cOCTRPC_RDBGERR_ALL_SESSIONS_OPEN 0xFFFF0001 +#define cOCTRPC_RDBGERR_PROTOCOL_NUMBER 0xFFFF0002 +#define cOCTRPC_RDBGERR_NO_COMMAND_HEADER 0xFFFF0003 +#define cOCTRPC_RDBGERR_INTERFACE_TYPE 0xFFFF0004 +#define cOCTRPC_RDBGERR_INTERFACE_VERSION 0xFFFF0005 +#define cOCTRPC_RDBGERR_INVALID_PACKET_LENGTH 0xFFFF0006 +#define cOCTRPC_RDBGERR_INVALID_COMMAND_LENGTH 0xFFFF0007 +#define cOCTRPC_RDBGERR_INVALID_COMMAND_NUMBER 0xFFFF0008 +#define cOCTRPC_RDBGERR_PACKET_TOO_LARGE 0xFFFF0009 +#define cOCTRPC_RDBGERR_LIST_EMPTY 0xFFFF000A + +#define cOCTRPC_RDBGERR_FATAL 0xFFFFFFFF + + +/***************************** TYPES ***************************************/ +typedef struct _OCTRPC_OGRDTP_HEADER_ +{ + UINT32 IN ulEndianDetect; + UINT32 IN ulDebugSessionNum; + UINT32 IN ulTransactionNum; + UINT32 IN ulPktRetryNum; + UINT32 IN ulPktByteSize; + UINT32 IN ulChecksum; + UINT32 OUT ulParsingError; + UINT32 IN ulRpcProtocolNum; + +} tOCTRPC_OGRDTP_HEADER, *tPOCTRPC_OGRDTP_HEADER; + +typedef struct _OCTRPC_INTERFACE_HEADER_ +{ + UINT32 IN ulInterfaceType; + UINT32 IN ulInterfaceVersion; + +} tOCTRPC_INTERFACE_HEADER, *tPOCTRPC_INTERFACE_HEADER; + +typedef struct _OCTRPC_COMMAND_HEADER_ +{ + UINT32 IN ulCommandByteSize; + UINT32 IN OUT ulRpcCommandNum; + UINT32 OUT ulFunctionResult; + +} tOCTRPC_COMMAND_HEADER, *tPOCTRPC_COMMAND_HEADER; + + + +#endif /* __RPC_PROTOCOL_H__ */ diff --git a/include/octtype.h b/include/octtype.h new file mode 100644 index 0000000..6757fa9 --- /dev/null +++ b/include/octtype.h @@ -0,0 +1,142 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octtype.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: This file defines the base storage types. + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 15 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#ifndef __OCTTYPE_H__ +#define __OCTTYPE_H__ + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------------- + Include target-specific header if available +----------------------------------------------------------------------------*/ +#if defined( OCT_NTDRVENV ) + #include "octtypentdrv.h" /* All NT driver typedef */ +#elif defined( OCT_WINENV ) + #include "octtypewin.h" /* All Win32 typedef */ +#elif defined( OCT_VXENV ) + #include "octtypevx.h" /* All VxWorks typedef */ +#else +/*-------------------------------------------------------------------------- + No target-specific header available +----------------------------------------------------------------------------*/ + +/***************************** DEFINES *************************************/ +/* 16-bit integer */ +typedef unsigned short UINT16; +typedef signed short INT16; +typedef unsigned short *PUINT16; +typedef signed short *PINT16; + +/* 8-bit integer */ +typedef unsigned char UINT8; +typedef signed char INT8; +typedef unsigned char *PUINT8; +typedef signed char *PINT8; + + +/* 32 bit integer */ +typedef unsigned int UINT32; +typedef signed int INT32; +typedef INT32 * PINT32; +typedef UINT32 * PUINT32; + +/* Long integer */ +typedef signed long LONG; +typedef unsigned long ULONG; +typedef long * PLONG; +typedef unsigned long * PULONG; + +/* Short integer */ +typedef short SHORT; +typedef unsigned short USHORT; +typedef short * PSHORT; +typedef unsigned short *PUSHORT; + +/* 8-bit integer*/ +typedef unsigned char BYTE; +typedef BYTE * PBYTE; +typedef unsigned char UCHAR; + +/* Character and strings */ +typedef char CHAR; +typedef CHAR SZ; +typedef CHAR * PSZ; +typedef CHAR * PCHAR; + +/* Double integers */ +typedef double DOUBLE; +typedef double * PDOUBLE; +typedef float FLOAT; +typedef float * PFLOAT; + +typedef void VOID; +typedef void * PVOID; + +/* Booleans */ +typedef int BOOL; +typedef BOOL * PBOOL; + +/* Integers */ +typedef int INT; +typedef int * PINT; +typedef unsigned int UINT; +typedef unsigned int * PUINT; + +/* Define pseudo-keywords IN and OUT if not defined yet */ +#ifndef IN +#define IN /* IN param */ +#endif + +#ifndef OUT +#define OUT /* OUT param */ +#endif + +/* LONG LONG */ +#define LLONG signed long long +#define PLLONG signed long long * +#define ULLONG unsigned long long +#define PULLONG unsigned long long * + +#ifndef OPT +#define OPT /* OPT param */ +#endif + +typedef PSZ * PPSZ; + +#ifndef NULL +#define NULL 0 +#endif + +#endif + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* __OCTTYPE_H__ */ diff --git a/include/octtypevx.h b/include/octtypevx.h new file mode 100644 index 0000000..e4c79dd --- /dev/null +++ b/include/octtypevx.h @@ -0,0 +1,120 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octtypevx.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: This file defines the base storage types for the VxWorks + environment. + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 5 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCTTYPEVX_H__ +#define __OCTTYPEVX_H__ + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vxWorks.h" + +/* 16-bit pointer integer */ +typedef unsigned short *PUINT16; +typedef signed short *PINT16; + +/* 8-bit integer pointer */ +typedef unsigned char *PUINT8; +typedef signed char *PINT8; + +/* 32-bit integer pointer */ +typedef INT32 * PINT32; +typedef UINT32 * PUINT32; + +/* Long integer pointer */ +#ifndef DATATYPE_H /*Intel library for file system definition*/ +typedef long LONG; +#endif +typedef long * PLONG; +typedef unsigned long * PULONG; + +/* Short integer pointer */ +typedef short SHORT; +typedef short * PSHORT; +typedef unsigned short *PUSHORT; + +/* 8-bit integer*/ +#if (CPU!=SIMNT) && !defined(DATATYPE_H) +typedef char BYTE; +#endif + + +typedef BYTE * PBYTE; + +/* Character and strings */ +#ifndef DATATYPE_H /*Intel library for file system definition*/ +typedef char CHAR; +#endif +typedef char * PCHAR; +typedef CHAR SZ; +typedef CHAR * PSZ; + +/* Double integers */ +typedef double DOUBLE; +typedef double * PDOUBLE; +typedef float FLOAT; +typedef float * PFLOAT; + +typedef void * PVOID; + +/* Booleans */ +typedef BOOL * PBOOL; + +/* Integers */ +typedef int INT; +typedef int * PINT; +typedef unsigned int PUINT; + +/* Define pseudo-keywords IN and OUT if not defined yet */ +#ifndef IN +#define IN /* IN param */ +#endif + +#ifndef OUT +#define OUT /* OUT param */ +#endif + +/* LONG LONG */ +#define LLONG signed long long +#define PLLONG signed long long * +#define ULLONG unsigned long long +#define PULLONG unsigned long long * + +#ifndef OPT +#define OPT /* OPT param */ +#endif + +typedef PSZ * PPSZ; + + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif /* __OCTTYPEVX_H__ */ diff --git a/include/octtypewin.h b/include/octtypewin.h new file mode 100644 index 0000000..e87e0ba --- /dev/null +++ b/include/octtypewin.h @@ -0,0 +1,84 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octtypewin.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: This file defines the base storage types for the Windows + environment. + Includes the Windows definition file and add the missing ones here. + +This source code is Octasic Confidential. Use of and access to this code +is covered by the Octasic Device Enabling Software License Agreement. +Acknowledgement of the Octasic Device Enabling Software License was +required for access to this code. A copy was also provided with the release. + + +$Octasic_Release: OCT610xAPI-01.00-PR37 $ + +$Octasic_Revision: 12 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + +#ifndef __OCTTYPEWIN_H__ +#define __OCTTYPEWIN_H__ + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ +#define WIN32_LEAN_AND_MEAN /* just get the base type definition from Windows */ +#include <windows.h> + +/* Disable argument not used warning */ +#pragma warning( disable : 4100 ) +/* Disable Level 4 warning: nonstandard extension used : translation unit is empty */ +#pragma warning( disable : 4206 ) + + +#ifdef __cplusplus +extern "C" { +#endif + +/* 16-bit integer */ +typedef unsigned short UINT16; +typedef signed short INT16; +typedef unsigned short *PUINT16; +typedef signed short *PINT16; + +/* 8-bit integer */ +typedef unsigned char UINT8; +typedef signed char INT8; +typedef unsigned char *PUINT8; +typedef signed char *PINT8; + +typedef double DOUBLE; + +/* 32 bit integer */ +#if ( defined( _MSC_VER ) && _MSC_VER == 1100 ) +/* MFC5 compiler does not define UINT32 */ +typedef unsigned int UINT32; +typedef signed int INT32; +typedef INT32 * PINT32; +typedef UINT32 * PUINT32; +#endif /* _MSC_VER */ + +/* LONG LONG */ +#define LLONG signed __int64 +#define PLLONG signed __int64 * +#define ULLONG unsigned __int64 +#define PULLONG unsigned __int64 * + +#ifndef OPT +#define OPT /* OPT param */ +#endif + +typedef PSZ * PPSZ; + +/*-------------------------------------------------------------------------- + C language +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif /* __OCTTYPEWIN_H__ */ diff --git a/octapi_bt0_private.h b/octapi_bt0_private.h new file mode 100644 index 0000000..8bece66 --- /dev/null +++ b/octapi_bt0_private.h @@ -0,0 +1,93 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_bt0_private.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: + + Library used to manage a binary tree of variable max size. Library is + made to use one block of contiguous memory to manage the tree. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 11 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#ifndef __OCTAPI_BT0_PRIVATE_H__ +#define __OCTAPI_BT0_PRIVATE_H__ + + + +#include "octdef.h" + +#define OCTAPI_BT0_LKEY_LARGER 0x0 +#define OCTAPI_BT0_LKEY_SMALLER 0x1 +#define OCTAPI_BT0_LKEY_EQUAL 0x2 + +typedef struct __OCTAPI_BT0_LINK__ +{ + UINT32 node_number; + UINT32 depth; +} OCTAPI_BT0_LINK; + +typedef struct __OCTAPI_BT0_NODE__ +{ + UINT32 next_free_node; /* Number of the next node in the free node link-list.*/ + OCTAPI_BT0_LINK l[2]; /* 0 = left link; 1 = right link.*/ +} OCTAPI_BT0_NODE; + + +typedef struct __OCTAPI_BT0__ +{ + UINT32 number_of_items; /* Number of items on total that can be allocated in the tree.*/ + UINT32 key_size; /* Size is in UINT32s*/ + UINT32 data_size; /* Size is in UINT32s*/ + + /* Empty node linked-list:*/ + UINT32 next_free_node; /* 0xFFFFFFFF means that no nodes are free.*/ + + /* Tree as such:*/ + OCTAPI_BT0_NODE * node; /* Array of nodes (number_of_items in size).*/ + + /* Tree root:*/ + OCTAPI_BT0_LINK root_link; + + /* Associated key structure*/ + UINT32 * key; /* Array of keys associated to NODEs.*/ + + /* Associated data structure.*/ + UINT32 * data; /* Array of data associated to NODEs.*/ + + UINT32 invalid_value; + UINT32 no_smaller_key; + +} OCTAPI_BT0; + +static void OctApiBt0CorrectPointers( OCTAPI_BT0 * bb ); +static UINT32 OctApiBt0AddNode2( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link, UINT32 * lkey, UINT32 new_node_number ); +static UINT32 OctApiBt0AddNode3( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link, UINT32 * lkey, UINT32 *p_new_node_number ); +static UINT32 OctApiBt0AddNode4(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 *p_new_node_number, UINT32 *p_prev_node_number, UINT32 state ); +static UINT32 OctApiBt0KeyCompare( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link, UINT32 * lkey ); +static void OctApiBt0UpdateLinkDepth( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link ); +static void OctApiBt0Rebalance( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * root_link ); +static void OctApiBt0ExternalHeavy( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * root_link ); +static UINT32 OctApiBt0RemoveNode2( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link, UINT32 * lkey, OCTAPI_BT0_LINK * link_to_removed_node, UINT32 state, OCTAPI_BT0_LINK * volatile_grandparent_link ); + + + +#endif /*__OCTAPI_BT0_PRIVATE_H__*/ diff --git a/octapi_llman_private.h b/octapi_llman_private.h new file mode 100644 index 0000000..f182cf1 --- /dev/null +++ b/octapi_llman_private.h @@ -0,0 +1,206 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_llman_private.h + +Copyright (c) 2001 Octasic Inc. All rights reserved. + +Description: + + Library used to manage allocation tables and linked lists. The library is + made such that only a block of contiguous memory is needed for the + management of the linked list/allocation table. + + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 13 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#ifndef __OCTAPI_LLMAN_PRIVATE_H__ +#define __OCTAPI_LLMAN_PRIVATE_H__ + +#include "octdef.h" + + +/**************************************** llm_alloc section **********************************************/ + + +/* Most basic linked list model. + LLM_STR contains a list of "number_of_items" that + are each "unassigned" or "assigned". When requesting + a new element, llm_alloc must choose an "unassigned" + element. An element that is deallocated will be last + to be allocated. +*/ + +typedef struct _LLM_ALLOC +{ + UINT32 *linked_list; /* Each item is either used (0xFFFFFFFE)*/ + /* or unused (pointer to next unused item, 0xFFFFFFFF means last item reached).*/ + UINT32 next_avail_num; /* Points to the next available item in linked list. (0xFFFFFFFF means none available)*/ + UINT32 number_of_items; /* Total number of items in linked list.*/ + UINT32 allocated_items; /* Allocated items in linked list.*/ + +} LLM_ALLOC; + +typedef struct _TLLM_ALLOC_NODE_ +{ + UINT32 value; /* Each item is either used (0xFFFFFFFE)*/ + /* or unused (pointer to next unused item, 0xFFFFFFFF means last item reached).*/ + UINT32 timeout[2]; /* Timeout value that must be exceeded for the node to be considered free again.*/ + +} TLLM_ALLOC_NODE; + + +typedef struct _TLLM_ALLOC_ +{ + TLLM_ALLOC_NODE *linked_list; /* List of nodes used by the link list.*/ + + UINT32 next_avail_num; /* Points to the next available item in linked list. (0xFFFFFFFF means none available)*/ + UINT32 number_of_items; /* Total number of items in linked list.*/ + UINT32 allocated_items; /* Allocated items in linked list.*/ + + UINT32 number_of_timeout; /* Number of block currently in timeout.*/ + UINT32 next_timeout_num; /* Points to the next block currently in timeout.*/ + UINT32 last_timeout_num; /* Last node of the timeout list.*/ + + UINT32 last_known_time[2]; /* last known time.*/ + +} TLLM_ALLOC; + +/* +void octapi_llm_alloc_build_structure(void *l, LLM_ALLOC ** ls); +*/ +/**************************************** llm_alloc section **********************************************/ + + + +/**************************************** llm_list section **********************************************/ +/* This section contains memory structures and functions used + to maintain a variable number of lists (FIFOs) that each + have a variable amount of items. A total amount of items + can be assigned through-out all the lists. Each item in + each list contains a UINT32 specified by the software using + the lists. Each used item in the list is accessible through + it's position in the list. */ + +typedef struct _LLM_LIST_HEAD +{ + UINT32 list_length; /* Current number of items in the list.*/ + /* 0xFFFFFFFF means that the list is not used.*/ + UINT32 head_pointer; /* Number of the item in the item pool that is the first of this list.*/ + /* 0xFFFFFFFF indicates end-of-list link.*/ + UINT32 tail_pointer; /* Number of the item in the item pool that is the last of this list.*/ + + /* Item cache (pointer within the list of the last accessed item):*/ + UINT32 cache_item_number; /* Number of the last accessed item in the list. 0xFFFFFFFF indicates invalid cache.*/ + UINT32 cache_item_pointer; /* Number of the last accessed item in the item pool.*/ +} LLM_LIST_HEAD; + +typedef struct _LLM_LIST_ITEM +{ + UINT32 forward_link; /* Number of the item in the item pool that is next in this list.*/ + /* 0xFFFFFFFF indicates end-of-list link.*/ + + /* User item info (variable size)*/ + UINT32 user_info[1]; +} LLM_LIST_ITEM; + +typedef struct _LLM_LIST +{ + UINT32 user_info_bytes; /* In bytes, size of the user info in a single item.*/ + UINT32 user_info_size; /* In bytes, size of the user info in a single item.*/ + UINT32 item_size; + + UINT32 head_alloc_size; + UINT32 total_items; + UINT32 assigned_items; + + UINT32 total_lists; + UINT32 assigned_lists; + + UINT32 next_empty_item; /* Contains a pointer to the next empty item in the*/ + /* item pool.*/ + + /* Table of all the possible list heads:*/ + LLM_LIST_HEAD * lh; + void * list_head_alloc; /* LLM_ALLOC structure used for list head allocation!*/ + + /* Table of the list items:*/ + LLM_LIST_ITEM * li; +} LLM_LIST; + + +/**********************************************************************************/ +/* These structures are are used by the Llm2 functions to creates lists of ordered + items based on a key given by the user when a new node is inserted in a list. */ +typedef struct _LLM2_LIST_HEAD +{ + UINT32 list_length; /* Current number of items in the list.*/ + /* 0xFFFFFFFF means that the list is not used.*/ + UINT32 head_pointer; /* Number of the item in the item pool that is the first of this list.*/ + /* 0xFFFFFFFF indicates end-of-list link.*/ + UINT32 tail_pointer; /* Number of the item in the item pool that is the last of this list.*/ + +} LLM2_LIST_HEAD; + +typedef struct _LLM2_LIST_ITEM +{ + UINT32 forward_link; /* Number of the item in the item pool that is next in this list.*/ + /* 0xFFFFFFFF indicates end-of-list link.*/ + UINT32 key; /* Key used to order the entries.*/ + + /* User item info (variable size)*/ + UINT32 user_info[1]; +} LLM2_LIST_ITEM; + +typedef struct _LLM2_LIST +{ + UINT32 user_info_bytes; /* In bytes, size of the user info in a single item.*/ + UINT32 user_info_size; /* In bytes, size of the user info in a single item.*/ + UINT32 item_size; + + UINT32 head_alloc_size; + UINT32 total_items; + UINT32 assigned_items; + + UINT32 total_lists; + UINT32 assigned_lists; + + UINT32 next_empty_item; /* Contains a pointer to the next empty item in the*/ + /* item pool.*/ + + /* Table of all the possible list heads:*/ + LLM2_LIST_HEAD * lh; + void * list_head_alloc; /* LLM_ALLOC structure used for list head allocation!*/ + + /* Table of the list items:*/ + LLM2_LIST_ITEM * li; +} LLM2_LIST; + +/*void octapi_llm_list_build_structure(void *l, LLM_LIST ** ls);*/ +LLM_LIST_ITEM * OctApiLlmListGetItemPointer( LLM_LIST * ls, UINT32 item_number ); +LLM2_LIST_ITEM * OctApiLlm2ListGetItemPointer( LLM2_LIST * ls, UINT32 item_number ); +UINT32 OctApiTllmCheckTimeoutList( TLLM_ALLOC *ls, UINT32 current_time[2] ); +VOID * OctApiLlmMemCpy( VOID *f_pvDestination, const VOID * f_pvSource, UINT32 f_ulSize ); +/**************************************** llm_list section **********************************************/ + + + + + +#endif /*__OCTAPI_LLMAN_PRIVATE_H__*/ diff --git a/octvpm.h b/octvpm.h new file mode 100644 index 0000000..c2b5382 --- /dev/null +++ b/octvpm.h @@ -0,0 +1,99 @@ +#include "vpm450m_fw.h" + +static int init_vpm450m(void *wc) +{ + tOCT6100_CHIP_OPEN ChipOpen; + tOCT6100_GET_INSTANCE_SIZE InstanceSize; + UINT32 ulResult; + tOCT6100_CHANNEL_OPEN ChannelOpen; + + struct stat sb; + char *filename = "OCT6104-128D.ima"; + int fd; + void *fw; + int x; + + Oct6100ChipOpenDef(&ChipOpen); + + /* Setup Chip Open Parameters */ + ChipOpen.ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ; + Oct6100GetInstanceSizeDef(&InstanceSize); + + ChipOpen.pbyImageFile = vpm450m_fw; + ChipOpen.pProcessContext = wc; + ChipOpen.ulImageSize = sizeof(vpm450m_fw); + ChipOpen.fEnableMemClkOut = TRUE; + ChipOpen.ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ; + ChipOpen.ulMaxChannels = 128; + ChipOpen.ulMemoryType = cOCT6100_MEM_TYPE_DDR; + ChipOpen.ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_32MB; + ChipOpen.ulNumMemoryChips = 1; + ChipOpen.ulMaxTdmStreams = 4; + ChipOpen.aulTdmStreamFreqs[0] = cOCT6100_TDM_STREAM_FREQ_8MHZ; + ChipOpen.ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE; +#if 0 + ChipOpen.fEnableAcousticEcho = TRUE; +#endif + + ulResult = Oct6100GetInstanceSize(&ChipOpen, &InstanceSize); + if (ulResult != cOCT6100_ERR_OK) { + fprintf(stderr, "Failed to get instance size, code %08x!\n", ulResult); + return -1; + } + + + pApiInstance = malloc(InstanceSize.ulApiInstanceSize); + if (!pApiInstance) { + fprintf(stderr, "Out of memory (can't allocate %d bytes)!\n", InstanceSize.ulApiInstanceSize); + return -1; + } + + ulResult = Oct6100ChipOpen(pApiInstance, &ChipOpen); + if (ulResult != cOCT6100_ERR_OK) { + fprintf(stderr, "Failed to open chip, code %08x!\n", ulResult); + return -1; + } + for (x=0;x<128;x++) { + Oct6100ChannelOpenDef(&ChannelOpen);tOCT6100_CHIP_OPEN + ChannelOpen.pulChannelHndl = &aulEchoChanHndl[x]; + ChannelOpen.ulUserChanId = x; + ChannelOpen.TdmConfig.ulRinPcmLaw = cOCT6100_PCM_U_LAW; + ChannelOpen.TdmConfig.ulRinStream = 1; + ChannelOpen.TdmConfig.ulRinTimeslot = x; + ChannelOpen.TdmConfig.ulSinPcmLaw = cOCT6100_PCM_U_LAW; + ChannelOpen.TdmConfig.ulSinStream = 0; + ChannelOpen.TdmConfig.ulSinTimeslot = x; + ChannelOpen.TdmConfig.ulSoutPcmLaw = cOCT6100_PCM_U_LAW; + ChannelOpen.TdmConfig.ulSoutStream = 3; + ChannelOpen.TdmConfig.ulSoutTimeslot = x; + ChannelOpen.TdmConfig.ulRoutPcmLaw = cOCT6100_PCM_U_LAW; + ChannelOpen.TdmConfig.ulRoutStream = 2; + ChannelOpen.TdmConfig.ulRoutTimeslot = x; + + ChannelOpen.VqeConfig.fEnableNlp = TRUE; + ChannelOpen.VqeConfig.fRinDcOffsetRemoval = TRUE; + ChannelOpen.VqeConfig.fSinDcOffsetRemoval = TRUE; + + ChannelOpen.fEnableToneDisabler = TRUE; + ChannelOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_POWER_DOWN; + + ulResult = Oct6100ChannelOpen(pApiInstance, &ChannelOpen); + if (ulResult != GENERIC_OK) { + fprintf(stderr, "Failed to open channel %d!\n", x); + } + } + return 0; +} + +static int close_chip(void) +{ + UINT32 ulResult; + tOCT6100_CHIP_CLOSE ChipClose; + Oct6100ChipCloseDef(&ChipClose); + ulResult = Oct6100ChipClose(pApiInstance, &ChipClose); + if (ulResult != cOCT6100_ERR_OK) { + fprintf(stderr, "Failed to close chip, code %08x!\n", ulResult); + return -1; + } + return 0; +} diff --git a/vpm450m.c b/vpm450m.c new file mode 100644 index 0000000..f6bf563 --- /dev/null +++ b/vpm450m.c @@ -0,0 +1,29633 @@ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_adpcm_chan.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to open and close ADPCM channels. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 15 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "apilib/octapi_largmath.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_adpcm_chan_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_adpcm_chan_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_tsst_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_adpcm_chan_priv.h" + +#include <linux/slab.h> +#include <linux/vmalloc.h> + +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetAdpcmChanSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of the ADPCM memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetAdpcmChanSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Determine the amount of memory required for the API ADPCM channel list.*/ + f_pInstSizes->ulAdpcmChannelList = f_pOpenChip->ulMaxAdpcmChannels * sizeof( tOCT6100_API_ADPCM_CHAN ); + + if ( f_pOpenChip->ulMaxAdpcmChannels > 0 ) + { + /* Calculate memory needed for ADPCM memory allocation */ + ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxAdpcmChannels, &f_pInstSizes->ulAdpcmChannelAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_48; + } + else + { + f_pInstSizes->ulAdpcmChannelAlloc = 0; + } + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulAdpcmChannelList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulAdpcmChannelAlloc, ulTempVar ) + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAdpcmChanSwInit + +Description: Initializes all elements of the instance structure associated + to the ADPCM memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAdpcmChanSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_ADPCM_CHAN pChannelsTsiList; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulMaxAdpcmChannels; + PVOID pAdpcmChannelsAlloc; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Initialize the ADPCM channel API list.*/ + ulMaxAdpcmChannels = pSharedInfo->ChipConfig.usMaxAdpcmChannels; + + /* Set all entries in the ADPCM channel list to unused. */ + mOCT6100_GET_ADPCM_CHAN_LIST_PNT( pSharedInfo, pChannelsTsiList ) + + /* Clear the memory */ + Oct6100UserMemSet( pChannelsTsiList, 0x00, sizeof(tOCT6100_API_ADPCM_CHAN) * ulMaxAdpcmChannels ); + + /* Initialize the ADPCM channel allocation structures to "all free". */ + if ( ulMaxAdpcmChannels > 0 ) + { + mOCT6100_GET_ADPCM_CHAN_ALLOC_PNT( pSharedInfo, pAdpcmChannelsAlloc ) + + ulResult = OctapiLlmAllocInit( &pAdpcmChannelsAlloc, ulMaxAdpcmChannels ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_BD; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_channel.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to open, modify and close echo + cancellation channels. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 449 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_mixer_inst.h" +#include "oct6100api/oct6100_tsi_cnct_inst.h" +#include "oct6100api/oct6100_conf_bridge_inst.h" +#include "oct6100api/oct6100_tone_detection_inst.h" +#include "oct6100api/oct6100_phasing_tsst_inst.h" +#include "oct6100api/oct6100_tsst_inst.h" +#include "oct6100api/oct6100_channel_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_tsi_cnct_pub.h" +#include "oct6100api/oct6100_playout_buf_pub.h" +#include "oct6100api/oct6100_phasing_tsst_pub.h" +#include "oct6100api/oct6100_mixer_pub.h" +#include "oct6100api/oct6100_conf_bridge_pub.h" +#include "oct6100api/oct6100_tone_detection_pub.h" +#include "oct6100api/oct6100_channel_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_tsst_priv.h" +#include "oct6100_mixer_priv.h" +#include "oct6100_phasing_tsst_priv.h" +#include "oct6100_tsi_cnct_priv.h" +#include "oct6100_playout_buf_priv.h" +#include "oct6100_conf_bridge_priv.h" +#include "oct6100_tone_detection_priv.h" +#include "oct6100_channel_priv.h" + + +/**************************** PUBLIC FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelOpen + +Description: This function opens a echo cancellation channel. An echo cancellation + channel is constituted of two voice stream (RIN/ROUT and SIN/SOUT), and + an echo cancelling core. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelOpen Pointer to echo channel open structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelOpenDef( + IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen ) +{ + f_pChannelOpen->pulChannelHndl = NULL; + f_pChannelOpen->ulUserChanId = cOCT6100_INVALID_VALUE; + f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_POWER_DOWN; + f_pChannelOpen->fEnableToneDisabler = FALSE; + f_pChannelOpen->fEnableExtToneDetection = FALSE; + + /* VQE configuration.*/ + f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval = TRUE; + f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval = TRUE; + f_pChannelOpen->VqeConfig.fRinLevelControl = FALSE; + f_pChannelOpen->VqeConfig.lRinLevelControlGainDb = 0; + f_pChannelOpen->VqeConfig.fSoutLevelControl = FALSE; + f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb = 0; + f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl = FALSE; + f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = -20; + f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl = FALSE; + f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = -20; + f_pChannelOpen->VqeConfig.fRinHighLevelCompensation = FALSE; + f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = -10; + f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE; + f_pChannelOpen->VqeConfig.fSoutNoiseBleaching = FALSE; + f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction = FALSE; + f_pChannelOpen->VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL; + f_pChannelOpen->VqeConfig.fEnableNlp = TRUE; + f_pChannelOpen->VqeConfig.fEnableTailDisplacement = FALSE; + f_pChannelOpen->VqeConfig.ulTailDisplacement = cOCT6100_AUTO_SELECT_TAIL; + f_pChannelOpen->VqeConfig.ulTailLength = cOCT6100_AUTO_SELECT_TAIL; + + f_pChannelOpen->VqeConfig.fDtmfToneRemoval = FALSE; + + f_pChannelOpen->VqeConfig.fAcousticEcho = FALSE; + f_pChannelOpen->VqeConfig.lDefaultErlDb = -6; + f_pChannelOpen->VqeConfig.ulAecTailLength = 128; + f_pChannelOpen->VqeConfig.lAecDefaultErlDb = 0; + f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA = 1; + f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB = 0; + f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior = cOCT6100_DOUBLE_TALK_BEH_NORMAL; + f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = 0; + f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = 0; + f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement = FALSE; + f_pChannelOpen->VqeConfig.fRoutNoiseReduction = FALSE; + f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb = -18; + f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation = 6; + f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay = 300; + f_pChannelOpen->VqeConfig.fEnableMusicProtection = FALSE; + /* Older images have idle code detection hard-coded to enabled. */ + f_pChannelOpen->VqeConfig.fIdleCodeDetection = TRUE; + + /* TDM configuration.*/ + f_pChannelOpen->TdmConfig.ulRinNumTssts = 1; + f_pChannelOpen->TdmConfig.ulSinNumTssts = 1; + f_pChannelOpen->TdmConfig.ulRoutNumTssts = 1; + f_pChannelOpen->TdmConfig.ulSoutNumTssts = 1; + + f_pChannelOpen->TdmConfig.ulRinTimeslot = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulRinStream = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulRinPcmLaw = cOCT6100_PCM_U_LAW; + + f_pChannelOpen->TdmConfig.ulSinTimeslot = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulSinStream = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulSinPcmLaw = cOCT6100_PCM_U_LAW; + + f_pChannelOpen->TdmConfig.ulRoutTimeslot = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulRoutStream = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulRoutPcmLaw = cOCT6100_PCM_U_LAW; + + f_pChannelOpen->TdmConfig.ulSoutTimeslot = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulSoutStream = cOCT6100_UNASSIGNED; + f_pChannelOpen->TdmConfig.ulSoutPcmLaw = cOCT6100_PCM_U_LAW; + + /* CODEC configuration.*/ + f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition = cOCT6100_ADPCM_IN_LOW_BITS; + + f_pChannelOpen->CodecConfig.ulEncoderPort = cOCT6100_CHANNEL_PORT_SOUT; + f_pChannelOpen->CodecConfig.ulEncodingRate = cOCT6100_G711_64KBPS; + f_pChannelOpen->CodecConfig.ulDecoderPort = cOCT6100_CHANNEL_PORT_RIN; + f_pChannelOpen->CodecConfig.ulDecodingRate = cOCT6100_G711_64KBPS; + + f_pChannelOpen->CodecConfig.fEnableSilenceSuppression = FALSE; + f_pChannelOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE; + f_pChannelOpen->CodecConfig.ulPhase = 0; + f_pChannelOpen->CodecConfig.ulPhasingType = cOCT6100_NO_PHASING; + + + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100ChannelOpen( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen ) +{ + tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; + tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; + UINT32 ulSerRes = cOCT6100_ERR_OK; + UINT32 ulFncRes = cOCT6100_ERR_OK; + + /* Set the process context of the serialize structure.*/ + SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; + ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; + + /* Seize all list semaphores needed by this function. */ + SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; + ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); + if ( ulSerRes == cOCT6100_ERR_OK ) + { + /* Call the serialized function. */ + ulFncRes = Oct6100ChannelOpenSer( f_pApiInstance, f_pChannelOpen ); + } + else + { + return ulSerRes; + } + + /* Release the seized semaphores. */ + ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); + + /* If an error occured then return the error code. */ + if ( ulSerRes != cOCT6100_ERR_OK ) + return ulSerRes; + if ( ulFncRes != cOCT6100_ERR_OK ) + return ulFncRes; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelModify + +Description: This function will modify the parameter of an echo channel. If + the call to this channel allows the channel to go from power down + to enable, the API will activate it. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelModify Pointer to echo channel change structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelModifyDef( + IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify ) +{ + f_pChannelModify->ulChannelHndl = cOCT6100_INVALID_HANDLE; + f_pChannelModify->ulUserChanId = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->ulEchoOperationMode = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->fEnableToneDisabler = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->fApplyToAllChannels = FALSE; + + f_pChannelModify->fDisableToneDetection = FALSE; + f_pChannelModify->fStopBufferPlayout = FALSE; + f_pChannelModify->fRemoveConfBridgeParticipant = FALSE; + f_pChannelModify->fRemoveBroadcastTssts = FALSE; + + f_pChannelModify->fTdmConfigModified = FALSE; + f_pChannelModify->fVqeConfigModified = FALSE; + f_pChannelModify->fCodecConfigModified = FALSE; + + /* VQE config. */ + f_pChannelModify->VqeConfig.fSinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fRinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fRinLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lRinLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fSoutLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lSoutLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fRinAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lRinAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fSoutAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lSoutAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fRinHighLevelCompensation = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lRinHighLevelCompensationThresholdDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fSoutAdaptiveNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fSoutNoiseBleaching = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fSoutConferencingNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulComfortNoiseMode = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fEnableNlp = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fEnableTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->VqeConfig.fDtmfToneRemoval = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->VqeConfig.fAcousticEcho = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulAecTailLength = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lAecDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulNonLinearityBehaviorA = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulNonLinearityBehaviorB = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulDoubleTalkBehavior = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fSoutNaturalListenerEnhancement = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fRoutNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.lAnrSnrEnhancementDb = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulAnrVoiceNoiseSegregation = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fEnableMusicProtection = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fIdleCodeDetection = cOCT6100_KEEP_PREVIOUS_SETTING; + + /* TDM config. */ + f_pChannelModify->TdmConfig.ulRinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulSinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulRoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulSoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->TdmConfig.ulRinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulRinStream = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulRinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->TdmConfig.ulSinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulSinStream = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulSinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->TdmConfig.ulRoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulRoutStream = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulRoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->TdmConfig.ulSoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulSoutStream = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->TdmConfig.ulSoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING; + + /* CODEC config. */ + f_pChannelModify->CodecConfig.ulEncoderPort = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->CodecConfig.ulEncodingRate = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->CodecConfig.ulDecoderPort = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->CodecConfig.ulDecodingRate = cOCT6100_KEEP_PREVIOUS_SETTING; + + f_pChannelModify->CodecConfig.fEnableSilenceSuppression = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->CodecConfig.ulPhasingTsstHndl = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->CodecConfig.ulPhase = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->CodecConfig.ulPhasingType = cOCT6100_KEEP_PREVIOUS_SETTING; + + + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100ChannelModify( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify ) +{ + tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; + tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; + UINT32 ulSerRes = cOCT6100_ERR_OK; + UINT32 ulFncRes = cOCT6100_ERR_OK; + + /* Set the process context of the serialize structure.*/ + SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; + ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; + + /* Seize all list semaphores needed by this function. */ + SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; + ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); + if ( ulSerRes == cOCT6100_ERR_OK ) + { + /* Check the apply to all channels flag first. */ + if ( f_pChannelModify->fApplyToAllChannels != TRUE && + f_pChannelModify->fApplyToAllChannels != FALSE ) + return cOCT6100_ERR_CHANNEL_APPLY_TO_ALL_CHANNELS; + + /* Check if must apply modification to all channels. */ + if ( f_pChannelModify->fApplyToAllChannels == TRUE ) + { + tPOCT6100_API_CHANNEL pChanEntry; + UINT16 usChanIndex; + + /* Loop through all channels and look for the opened ones. */ + for ( usChanIndex = 0; usChanIndex < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; usChanIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex ); + + /* Check if this one is opened. */ + if ( pChanEntry->fReserved == TRUE ) + { + /* Channel is opened. Form handle and call actual modify function. */ + f_pChannelModify->ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | usChanIndex; + + /* Call the serialized function. */ + ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify ); + if ( ulFncRes != cOCT6100_ERR_OK ) + break; + } + } + } + else /* if ( f_pChannelModify->fApplyToAllChannels == FALSE ) */ + { + /* Call the serialized function. */ + ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify ); + } + } + else + { + return ulSerRes; + } + + /* Release the seized semaphores. */ + ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); + + /* If an error occured then return the error code. */ + if ( ulSerRes != cOCT6100_ERR_OK ) + return ulSerRes; + if ( ulFncRes != cOCT6100_ERR_OK ) + return ulFncRes; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelBroadcastTsstRemove + +Description: This function removes a TSST from one of the two output ports of a channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pChannelBroadcastTsstRemove Pointer to the a Remove Broadcast TSST structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelBroadcastTsstRemoveDef( + tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelBroadcastTsstRemove ) +{ + f_pChannelBroadcastTsstRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE; + + f_pChannelBroadcastTsstRemove->ulPort = cOCT6100_INVALID_PORT; + f_pChannelBroadcastTsstRemove->ulTimeslot = cOCT6100_INVALID_TIMESLOT; + f_pChannelBroadcastTsstRemove->ulStream = cOCT6100_INVALID_STREAM; + + f_pChannelBroadcastTsstRemove->fRemoveAll = FALSE; + + return cOCT6100_ERR_OK; +} + +#if 0 /* unused functions */ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelMute + +Description: This function mutes some or all of the ports designated by + ulChannelHndl. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelMute Pointer to a tPOCT6100_CHANNEL_MUTE structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelMuteDef( + IN OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute ) +{ + f_pChannelMute->ulChannelHndl = cOCT6100_INVALID_HANDLE; + f_pChannelMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE; + + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100ChannelMute( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute ) +{ + tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; + tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; + UINT32 ulSerRes = cOCT6100_ERR_OK; + UINT32 ulFncRes = cOCT6100_ERR_OK; + + /* Set the process context of the serialize structure.*/ + SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; + ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; + + /* Seize all list semaphores needed by this function. */ + SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; + ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); + if ( ulSerRes == cOCT6100_ERR_OK ) + { + /* Call the serialized function. */ + ulFncRes = Oct6100ChannelMuteSer( f_pApiInstance, f_pChannelMute ); + } + else + { + return ulSerRes; + } + + /* Release the seized semaphores. */ + ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); + + /* If an error occured then return the error code. */ + if ( ulSerRes != cOCT6100_ERR_OK ) + return ulSerRes; + if ( ulFncRes != cOCT6100_ERR_OK ) + return ulFncRes; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelUnMute + +Description: This function unmutes some or all of the ports designated by + ulChannelHndl. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelUnMute Pointer to a tPOCT6100_CHANNEL_UNMUTE structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelUnMuteDef( + IN OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute ) +{ + f_pChannelUnMute->ulChannelHndl = cOCT6100_INVALID_HANDLE; + f_pChannelUnMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE; + + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100ChannelUnMute( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute ) +{ + tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; + tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; + UINT32 ulSerRes = cOCT6100_ERR_OK; + UINT32 ulFncRes = cOCT6100_ERR_OK; + + /* Set the process context of the serialize structure.*/ + SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; + ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; + + /* Seize all list semaphores needed by this function. */ + SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; + ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); + if ( ulSerRes == cOCT6100_ERR_OK ) + { + /* Call the serialized function. */ + ulFncRes = Oct6100ChannelUnMuteSer( f_pApiInstance, f_pChannelUnMute ); + } + else + { + return ulSerRes; + } + + /* Release the seized semaphores. */ + ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); + + /* If an error occured then return the error code. */ + if ( ulSerRes != cOCT6100_ERR_OK ) + return ulSerRes; + if ( ulFncRes != cOCT6100_ERR_OK ) + return ulFncRes; + + return cOCT6100_ERR_OK; +} +#endif +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetChannelsEchoSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of the ECHO memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetChannelsEchoSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + UINT32 ulMaxChannels; + + ulMaxChannels = f_pOpenChip->ulMaxChannels; + + if ( f_pOpenChip->fEnableChannelRecording == TRUE && ulMaxChannels != 672 ) + ulMaxChannels++; + + /* Determine the amount of memory required for the API echo channel list.*/ + f_pInstSizes->ulChannelList = ulMaxChannels * sizeof( tOCT6100_API_CHANNEL ); /* Add one for the record channel.*/ + f_pInstSizes->ulBiDirChannelList = f_pOpenChip->ulMaxBiDirChannels * sizeof( tOCT6100_API_BIDIR_CHANNEL ); + if ( ulMaxChannels > 0 ) + { + /* Calculate memory needed for ECHO memory allocation */ + ulResult = OctapiLlmAllocGetSize( ulMaxChannels, &f_pInstSizes->ulChannelAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_0; + } + else + { + f_pInstSizes->ulChannelAlloc = 0; + } + if ( f_pOpenChip->ulMaxBiDirChannels > 0 ) + { + /* Calculate memory needed for ECHO memory allocation */ + ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxBiDirChannels, &f_pInstSizes->ulBiDirChannelAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_0; + } + else + { + f_pInstSizes->ulBiDirChannelAlloc = 0; + } + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelAlloc, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelAlloc, ulTempVar ) + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiChannelsEchoSwInit + +Description: Initializes all elements of the instance structure associated + to the ECHO memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiChannelsEchoSwInit( + IN tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_CHANNEL pChannelsEchoList; + tPOCT6100_API_BIDIR_CHANNEL pBiDirChannelsList; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT16 usMaxChannels; + PVOID pEchoChanAlloc; + PVOID pBiDirChanAlloc; + UINT32 ulResult; + + /* Get local pointer to shared portion of the API instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Initialize the ECHO channel API list.*/ + usMaxChannels = pSharedInfo->ChipConfig.usMaxChannels; + + /* add a channel to initialize if the recording is activated. */ + if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE ) + usMaxChannels++; + + /* Set all entries in the ADCPM channel list to unused. */ + mOCT6100_GET_CHANNEL_LIST_PNT( pSharedInfo, pChannelsEchoList ); + + /* Initialize the API ECHO channels allocation software to "all free". */ + if ( usMaxChannels > 0 ) + { + /* Clear the memory */ + Oct6100UserMemSet( pChannelsEchoList, 0x00, sizeof(tOCT6100_API_CHANNEL) * usMaxChannels ); + + mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoChanAlloc ) + + ulResult = OctapiLlmAllocInit( &pEchoChanAlloc, usMaxChannels ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1; + } + + mOCT6100_GET_BIDIR_CHANNEL_LIST_PNT( pSharedInfo, pBiDirChannelsList ); + + if ( pSharedInfo->ChipConfig.usMaxBiDirChannels > 0 ) + { + /* Clear the memory */ + Oct6100UserMemSet( pBiDirChannelsList, 0x00, sizeof(tOCT6100_API_BIDIR_CHANNEL) * pSharedInfo->ChipConfig.usMaxBiDirChannels ); + + mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pBiDirChanAlloc ) + + ulResult = OctapiLlmAllocInit( &pBiDirChanAlloc, pSharedInfo->ChipConfig.usMaxBiDirChannels ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_A9; + + } + + return cOCT6100_ERR_OK; +} + + + + + + + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelOpenSer + +Description: Opens a echo cancellation channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelOpen Pointer to channel configuration structure. Then handle + identifying the buffer in all future function calls is + returned in this structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelOpenSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen ) +{ + tOCT6100_API_ECHO_CHAN_INDEX ChannelIndexConf; + UINT32 ulResult; + + /* Check the user's configuration of the echo cancellation channel for errors. */ + ulResult = Oct6100ApiCheckChannelParams( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Reserve all resources needed by the echo cancellation channel. */ + ulResult = Oct6100ApiReserveChannelResources( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write all necessary structures to activate the echo cancellation channel. */ + ulResult = Oct6100ApiWriteChannelStructs( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update the new echo cancellation channels's entry in the ECHO channel list. */ + ulResult = Oct6100ApiUpdateChannelEntry( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckChannelParams + +Description: Checks the user's echo cancellation channel open configuration for errors. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelOpen Pointer to echo cancellation channel open configuration structure. +f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckChannelParams( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ) +{ + tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig; + tPOCT6100_CHANNEL_OPEN_VQE pVqeConfig; + tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig; + UINT32 ulDecoderNumTssts; + UINT32 ulResult; + + /* Dereference the configuration structure for clearer code and faster access.*/ + pTdmConfig = &f_pChannelOpen->TdmConfig; + pVqeConfig = &f_pChannelOpen->VqeConfig; + pCodecConfig = &f_pChannelOpen->CodecConfig; + + /* Check for errors. */ + if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels == 0 ) + return cOCT6100_ERR_CHANNEL_DISABLED; + + if ( f_pChannelOpen->pulChannelHndl == NULL ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL && + f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE && + f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET && + f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN && + f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL && + f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION && + f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO ) + return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE; + + /* Check the 2100Hz echo disabling configuration.*/ + if ( f_pChannelOpen->fEnableToneDisabler != TRUE && + f_pChannelOpen->fEnableToneDisabler != FALSE ) + return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE; + + /* Check the extended Tone Detection flag value.*/ + if ( f_pChannelOpen->fEnableExtToneDetection != TRUE && + f_pChannelOpen->fEnableExtToneDetection != FALSE ) + return cOCT6100_ERR_CHANNEL_ENABLE_EXT_TONE_DETECTION; + + /* Check that extented tone detection is actually enabled by the user. */ + if ( ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) && + ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableExtToneDetection == FALSE ) ) + return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DISABLED; + + + + /*==============================================================================*/ + /* Check the TDM configuration parameters.*/ + + ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance, pTdmConfig ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Now validate the VQE parameters */ + + ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance, pVqeConfig, f_pChannelOpen->fEnableToneDisabler ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Verify if the echo operation mode selected can be applied. */ + if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO ) + && ( pVqeConfig->fEnableNlp == FALSE ) ) + return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED; + + /*==============================================================================*/ + + /*==============================================================================*/ + /* Finally, validate the CODEC configuration.*/ + + if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + ulDecoderNumTssts = pTdmConfig->ulRinNumTssts; + else /* pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */ + ulDecoderNumTssts = pTdmConfig->ulSinNumTssts; + + ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance, pCodecConfig, ulDecoderNumTssts, &f_pChanIndexConf->usPhasingTsstIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + + + /* make sure that if silence suppression is activated, the NLP is enabled.*/ + if ( pCodecConfig->fEnableSilenceSuppression == TRUE && pVqeConfig->fEnableNlp == FALSE ) + return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED; + + /* Verify if law conversion is allowed. */ + if ( pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING || + pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING ) + { + /* No law conversion can occurs if one ADPCM memory is not reserved.*/ + if ( pTdmConfig->ulRinPcmLaw != pTdmConfig->ulRoutPcmLaw ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION; + + if ( pTdmConfig->ulSinPcmLaw != pTdmConfig->ulSoutPcmLaw ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION; + } + + /* Verify if the config supports extended tone detection.*/ + if ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) + { + if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT; + } + /*==============================================================================*/ + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReserveChannelResources + +Description: Reserves all resources needed for the new channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelOpen Pointer to echo cancellation channel configuration structure. +f_pulChannelIndex Allocated entry in ECHO channel list. +f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReserveChannelResources( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig; + tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig; + + UINT32 ulResult; + UINT32 ulTempVar; + UINT32 ulFreeMixerEventCnt; + + BOOL fRinTsstEntry = FALSE; + BOOL fSinTsstEntry = FALSE; + BOOL fRoutTsstEntry = FALSE; + BOOL fSoutTsstEntry = FALSE; + + BOOL fRinRoutTsiMemEntry = FALSE; + BOOL fSinSoutTsiMemEntry = FALSE; + + BOOL fEchoChanEntry = FALSE; + + PUINT16 pusRinRoutConversionMemIndex = NULL; + PUINT16 pusSinSoutConversionMemIndex = NULL; + BOOL fRinRoutConversionMemEntry = FALSE; + BOOL fSinSoutConversionMemEntry = FALSE; + + BOOL fExtToneChanEntry = FALSE; + BOOL fExtToneTsiEntry = FALSE; + BOOL fExtToneMixerEntry = FALSE; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain a local pointer to the configuration structures.*/ + pTdmConfig = &f_pChannelOpen->TdmConfig; + pCodecConfig = &f_pChannelOpen->CodecConfig; + + /*===============================================================================*/ + /* Reserve Echo and TSI entries. */ + + ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, + &f_pChanIndexConf->usEchoChanIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fEchoChanEntry = TRUE; + + /* Set the echo, encoder and decoder memory indexes.*/ + f_pChanIndexConf->usEchoMemIndex = f_pChanIndexConf->usEchoChanIndex; + + /* Reserve an entry for the RIN/ROUT tsi chariot memory. */ + ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, + &f_pChanIndexConf->usRinRoutTsiMemIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fRinRoutTsiMemEntry = TRUE; + + /* Reserve an entry for the SIN/SOUT tsi chariot memory. */ + ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, + &f_pChanIndexConf->usSinSoutTsiMemIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fSinSoutTsiMemEntry = TRUE; + + /* Reserve an ADPCM memory block for compression if required.*/ + if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex; + } + else if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT ) + { + pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex; + } + + /* Reserve an ADPCM memory block for decompression if required.*/ + if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex; + } + else if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) + { + pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex; + } + + + /* Reserve the conversion memories. */ + if ( pusRinRoutConversionMemIndex != NULL ) + { + /* Reserve a conversion memory for the Rin/Rout stream. */ + ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, + pusRinRoutConversionMemIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fRinRoutConversionMemEntry = TRUE; + } + } + else + { + /* No conversion memory reserved.*/ + f_pChanIndexConf->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX; + } + + if ( ( pusSinSoutConversionMemIndex != NULL ) && + ( ulResult == cOCT6100_ERR_OK ) ) + { + /* Reserve a conversion memory for the Sin/Sout stream. */ + ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, + pusSinSoutConversionMemIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fSinSoutConversionMemEntry = TRUE; + } + } + else + { + /* No conversion memory reserved.*/ + f_pChanIndexConf->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX; + } + + /* Reserve any resources required if the extended Tone detection is enabled.*/ + if ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) + { + ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, + &f_pChanIndexConf->usExtToneChanIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fExtToneChanEntry = TRUE; + + /* Reserve an entry for the TSI chariot memory for the additionnal channel. */ + ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, + &f_pChanIndexConf->usExtToneTsiIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fExtToneTsiEntry = TRUE; + + /* Reserve an entry for the TSI chariot memory for the additionnal channel. */ + ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, + &f_pChanIndexConf->usExtToneMixerIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + fExtToneMixerEntry = TRUE; + } + } + } + else + { + f_pChanIndexConf->usExtToneChanIndex = cOCT6100_INVALID_INDEX; + f_pChanIndexConf->usExtToneMixerIndex = cOCT6100_INVALID_INDEX; + f_pChanIndexConf->usExtToneTsiIndex = cOCT6100_INVALID_INDEX; + } + } + else + { + /* Return an error other then a Fatal.*/ + ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY; + } + } + else + { + /* Return an error other then a Fatal.*/ + ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY; + } + } + + /*===============================================================================*/ + + /*===============================================================================*/ + /* Now reserve the TSST entries if required.*/ + + /* Reserve the Rin TSST entry */ + if ( (ulResult == cOCT6100_ERR_OK ) && + (pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED && + pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED) ) + { + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pTdmConfig->ulRinTimeslot, + pTdmConfig->ulRinStream, + pTdmConfig->ulRinNumTssts, + cOCT6100_INPUT_TSST, + &f_pChanIndexConf->usRinTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + fRinTsstEntry = TRUE; + } + else + { + f_pChanIndexConf->usRinTsstIndex = cOCT6100_INVALID_INDEX; + } + + + if ( (ulResult == cOCT6100_ERR_OK ) && + (pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED && + pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED) ) + { + /* Reserve the Sin TSST entry.*/ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pTdmConfig->ulSinTimeslot, + pTdmConfig->ulSinStream, + pTdmConfig->ulSinNumTssts, + cOCT6100_INPUT_TSST, + &f_pChanIndexConf->usSinTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + fSinTsstEntry = TRUE; + } + else + { + f_pChanIndexConf->usSinTsstIndex = cOCT6100_INVALID_INDEX; + } + + if ( (ulResult == cOCT6100_ERR_OK ) && + (pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED && + pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED) ) + { + /* Reserve the Rout TSST entry.*/ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pTdmConfig->ulRoutTimeslot, + pTdmConfig->ulRoutStream, + pTdmConfig->ulRoutNumTssts, + cOCT6100_OUTPUT_TSST, + &f_pChanIndexConf->usRoutTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + fRoutTsstEntry = TRUE; + } + else + { + f_pChanIndexConf->usRoutTsstIndex = cOCT6100_INVALID_INDEX; + } + + + if ( (ulResult == cOCT6100_ERR_OK ) && + (pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED && + pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED) ) + { + /* Reserve the Sout TSST entry.*/ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pTdmConfig->ulSoutTimeslot, + pTdmConfig->ulSoutStream, + pTdmConfig->ulSoutNumTssts, + cOCT6100_OUTPUT_TSST, + &f_pChanIndexConf->usSoutTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + fSoutTsstEntry = TRUE; + } + else + { + f_pChanIndexConf->usSoutTsstIndex = cOCT6100_INVALID_INDEX; + } + + /*===============================================================================*/ + + + /*===============================================================================*/ + /* Check if there are a couple of mixer events available for us. */ + + if ( ulResult == cOCT6100_ERR_OK ) + { + UINT32 ulMixerEventCntNeeded = 0; + + /* Calculate how many mixer events are needed. */ + if ( f_pChanIndexConf->usRinTsstIndex == cOCT6100_INVALID_INDEX ) + ulMixerEventCntNeeded++; + + if ( f_pChanIndexConf->usSinTsstIndex == cOCT6100_INVALID_INDEX ) + ulMixerEventCntNeeded++; + + /* If at least 1 mixer event is needed, check if those are available. */ + if ( ulMixerEventCntNeeded != 0 ) + { + ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt ); + if ( ulResult == cOCT6100_ERR_OK ) + { + /* The API might need more mixer events if the ports have to be muted. */ + /* Check if these are available. */ + if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded ) + { + ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS; + } + } + } + } + + /*===============================================================================*/ + + + /*===============================================================================*/ + /* Release the resources if something went wrong */ + if ( ulResult != cOCT6100_ERR_OK ) + { + /*===============================================================================*/ + /* Release the previously reserved resources .*/ + if( fRinTsstEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pTdmConfig->ulRinTimeslot, + pTdmConfig->ulRinStream, + pTdmConfig->ulRinNumTssts, + cOCT6100_INPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fSinTsstEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pTdmConfig->ulSinTimeslot, + pTdmConfig->ulSinStream, + pTdmConfig->ulSinNumTssts, + cOCT6100_INPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fRoutTsstEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pTdmConfig->ulRoutTimeslot, + pTdmConfig->ulRoutStream, + pTdmConfig->ulRoutNumTssts, + cOCT6100_OUTPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fSoutTsstEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pTdmConfig->ulSoutTimeslot, + pTdmConfig->ulSoutStream, + pTdmConfig->ulSoutNumTssts, + cOCT6100_OUTPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fRinRoutTsiMemEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, + f_pChanIndexConf->usRinRoutTsiMemIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fSinSoutTsiMemEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, + f_pChanIndexConf->usSinSoutTsiMemIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /*===============================================================================*/ + + /*===============================================================================*/ + /* Release the previously reserved echo resources .*/ + if( fEchoChanEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance, + f_pChanIndexConf->usEchoChanIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /*===============================================================================*/ + + /*===============================================================================*/ + /* Release the previously reserved resources for the extended tone detection.*/ + if( fExtToneChanEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance, + f_pChanIndexConf->usExtToneChanIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fExtToneTsiEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, + f_pChanIndexConf->usExtToneTsiIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fExtToneMixerEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, + f_pChanIndexConf->usExtToneMixerIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + /*===============================================================================*/ + + /*===============================================================================*/ + /* Release the conversion resources. */ + if( fRinRoutConversionMemEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, + f_pChanIndexConf->usRinRoutConversionMemIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if( fSinSoutConversionMemEntry == TRUE ) + { + ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, + f_pChanIndexConf->usSinSoutConversionMemIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /*===============================================================================*/ + + return ulResult; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteChannelStructs + +Description: Performs all the required structure writes to configure the + new echo cancellation channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelOpen Pointer to echo cancellation channel configuration structure. +f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteChannelStructs( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig; + tOCT6100_WRITE_PARAMS WriteParams; + tPOCT6100_API_CHANNEL pChanEntry; + UINT32 ulResult; + UINT32 ulDwordAddress; + UINT32 ulDwordData; + BOOL fConversionEnabled = FALSE; + BOOL fProgramAdpcmMem; + UINT32 ulCompType = 0; + UINT32 ulPcmLaw; + UINT16 usTempTsiMemIndex; + UINT16 usConversionMemIndex; + UINT32 ulToneEventNumber; + BOOL fSSTone; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain a local pointer to the TDM configuration structure.*/ + pTdmConfig = &f_pChannelOpen->TdmConfig; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex ); + + /*==============================================================================*/ + /* Configure the Tsst control memory.*/ + + /* Set the RIN Tsst control entry.*/ + if ( f_pChanIndexConf->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + f_pChanIndexConf->usRinTsstIndex, + f_pChanIndexConf->usRinRoutTsiMemIndex, + pTdmConfig->ulRinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Set the ROUT Tsst control entry.*/ + if ( f_pChanIndexConf->usRoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + f_pChanIndexConf->usRoutTsstIndex, + f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition, + pTdmConfig->ulRoutNumTssts, + f_pChanIndexConf->usRinRoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Set the SIN Tsst control entry.*/ + if ( f_pChanIndexConf->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + f_pChanIndexConf->usSinTsstIndex, + f_pChanIndexConf->usSinSoutTsiMemIndex, + pTdmConfig->ulSinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Set the SOUT Tsst control entry.*/ + if ( f_pChanIndexConf->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + f_pChanIndexConf->usSoutTsstIndex, + f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition, + pTdmConfig->ulSoutNumTssts, + f_pChanIndexConf->usSinSoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*==============================================================================*/ + + /*==============================================================================*/ + /* Configure the ADPCM control memory for the Decoder.*/ + + /* Set the codec state flags.*/ + f_pChanIndexConf->fRinRoutCodecActive = FALSE; + f_pChanIndexConf->fSinSoutCodecActive = FALSE; + + if ( f_pChannelOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING ) + { + fProgramAdpcmMem = TRUE; + + switch( f_pChannelOpen->CodecConfig.ulDecodingRate ) + { + case cOCT6100_G711_64KBPS: + ulCompType = 0x8; + if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw ) + fProgramAdpcmMem = FALSE; + } + else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */ + { + if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw ) + fProgramAdpcmMem = FALSE; + } + break; + case cOCT6100_G726_40KBPS: + ulCompType = 0x3; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_32KBPS: + ulCompType = 0x2; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_24KBPS: + ulCompType = 0x1; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_16KBPS: + ulCompType = 0x0; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_2C_ENCODED: + ulCompType = 0x4; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_3C_ENCODED: + ulCompType = 0x5; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_4C_ENCODED: + ulCompType = 0x6; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_ENCODED: + ulCompType = 0x9; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G726_ENCODED: + ulCompType = 0xA; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G727_2C_ENCODED: + ulCompType = 0xC; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G727_3C_ENCODED: + ulCompType = 0xD; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G727_4C_ENCODED: + ulCompType = 0xE; + fConversionEnabled = TRUE; + break; + default: + return cOCT6100_ERR_FATAL_D4; + } + + if ( fProgramAdpcmMem == TRUE ) + { + /* Set the chariot memory based on the selected port.*/ + if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex; + ulPcmLaw = pTdmConfig->ulRoutPcmLaw; /* Set the law for later use */ + + /* Set the codec state flags.*/ + f_pChanIndexConf->fRinRoutCodecActive = TRUE; + + /* Set the conversion memory index to use for decompression */ + usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex; + } + else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */ + { + usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex; + ulPcmLaw = pTdmConfig->ulSoutPcmLaw; /* Set the law for later use */ + + /* Set the codec state flags.*/ + f_pChanIndexConf->fSinSoutCodecActive = TRUE; + + /* Set the conversion memory index to use for decompression */ + usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex; + } + + ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance, + usConversionMemIndex, + ulCompType, + usTempTsiMemIndex, + ulPcmLaw, + f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Configure the ADPCM control memory for the Encoder */ + + if ( f_pChannelOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING ) + { + fProgramAdpcmMem = TRUE; + + switch( f_pChannelOpen->CodecConfig.ulEncodingRate ) + { + case cOCT6100_G711_64KBPS: + if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + if ( pTdmConfig->ulRoutPcmLaw == cOCT6100_PCM_U_LAW ) + ulCompType = 0x4; + else + ulCompType = 0x5; + + /* Check for law conversion.*/ + if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw ) + fProgramAdpcmMem = FALSE; + } + else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + if ( pTdmConfig->ulSoutPcmLaw == cOCT6100_PCM_U_LAW ) + ulCompType = 0x4; + else + ulCompType = 0x5; + + /* Check for law conversion.*/ + if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw ) + fProgramAdpcmMem = FALSE; + } + + break; + case cOCT6100_G726_40KBPS: + ulCompType = 0x3; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_32KBPS: + ulCompType = 0x2; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_24KBPS: + ulCompType = 0x1; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_16KBPS: + ulCompType = 0x0; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_40KBPS_4_1: + ulCompType = 0xD; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_40KBPS_3_2: + ulCompType = 0xA; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_40KBPS_2_3: + ulCompType = 0x6; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_32KBPS_4_0: + ulCompType = 0xE; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_32KBPS_3_1: + ulCompType = 0xB; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_32KBPS_2_2: + ulCompType = 0x7; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_24KBPS_3_0: + ulCompType = 0xC; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_24KBPS_2_1: + ulCompType = 0x8; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_16KBPS_2_0: + ulCompType = 0x9; + fConversionEnabled = TRUE; + break; + + default: + return cOCT6100_ERR_FATAL_D5; + } + + /* Program the APDCM memory only if ADPCM is requried.*/ + if ( fProgramAdpcmMem == TRUE || f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Set the chariot memory based on the selected port.*/ + if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex; + + /* Set the codec state flags.*/ + f_pChanIndexConf->fRinRoutCodecActive = TRUE; + + /* Set the conversion memory index to use for compression */ + usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex; + } + + else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex; + + /* Set the codec state flags.*/ + f_pChanIndexConf->fSinSoutCodecActive = TRUE; + + /* Set the conversion memory index to use for compression */ + usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex; + } + + ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance, + usConversionMemIndex, + ulCompType, + usTempTsiMemIndex, + f_pChannelOpen->CodecConfig.fEnableSilenceSuppression, + f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition, + f_pChanIndexConf->usPhasingTsstIndex, + f_pChannelOpen->CodecConfig.ulPhasingType, + f_pChannelOpen->CodecConfig.ulPhase ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Clearing the tone events bit vector */ + + ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usEchoChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); + ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; + ulDwordData = 0x00000000; + + ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulDwordAddress += 4; + + ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Write the VQE memory */ + + ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance, + &f_pChannelOpen->VqeConfig, + f_pChannelOpen, + f_pChanIndexConf->usEchoChanIndex, + f_pChanIndexConf->usEchoMemIndex, + TRUE, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + /*==============================================================================*/ + /* Write the echo memory */ + + ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance, + pTdmConfig, + f_pChannelOpen, + f_pChanIndexConf->usEchoMemIndex, + f_pChanIndexConf->usRinRoutTsiMemIndex, + f_pChanIndexConf->usSinSoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + + + /*==============================================================================*/ + /* Mute channel if required, this is done on a port basis */ + + /* Initialize the silence indexes to invalid for now. */ + pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX; + pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX; + + /* Set the TSI memory indexes. */ + pChanEntry->usRinRoutTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex; + pChanEntry->usSinSoutTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex; + + ulResult = Oct6100ApiMutePorts( f_pApiInstance, + f_pChanIndexConf->usEchoChanIndex, + f_pChanIndexConf->usRinTsstIndex, + f_pChanIndexConf->usSinTsstIndex, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Set the dominant speaker to unassigned, if required. */ + + if ( f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled == TRUE ) + { + ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_pChanIndexConf->usEchoChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*==============================================================================*/ + + + /*==============================================================================*/ + /* If necessary, configure the extended tone detection channel.*/ + + if ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) + { + UINT32 ulTempSinLaw; + UINT32 ulTempSoutLaw; + UINT32 ulTempEchoOpMode; + + /* save the original law.*/ + ulTempSinLaw = pTdmConfig->ulSinPcmLaw; + ulTempSoutLaw = pTdmConfig->ulSoutPcmLaw; + ulTempEchoOpMode = f_pChannelOpen->ulEchoOperationMode; + + /* Now, make sure the Sin and Sout law are the same as the Rin law.*/ + + pTdmConfig->ulSinPcmLaw = pTdmConfig->ulRinPcmLaw; + pTdmConfig->ulSoutPcmLaw = pTdmConfig->ulRinPcmLaw; + + f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_NORMAL; + + /* Write the Echo and VQE memory of the extended channel.*/ + + ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance, + pTdmConfig, + &f_pChannelOpen->VqeConfig, + f_pChannelOpen, + f_pChanIndexConf->usExtToneChanIndex, + f_pChanIndexConf->usExtToneChanIndex, + cOCT6100_API_EXT_TONE_EXTRA_TSI, + f_pChanIndexConf->usExtToneTsiIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now, write the mixer event used to copy the RIN signal of the original channel + into the SIN signal of the exteded channel. */ + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_pChanIndexConf->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY; + WriteParams.usWriteData |= f_pChanIndexConf->usRinRoutTsiMemIndex; + WriteParams.usWriteData |= pTdmConfig->ulRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = f_pChanIndexConf->usExtToneTsiIndex; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Now insert the Sin copy event into the list.*/ + + ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance, + f_pChanIndexConf->usExtToneMixerIndex, + cOCT6100_EVENT_TYPE_SIN_COPY, + f_pChanIndexConf->usEchoChanIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*=======================================================================*/ + + /*==============================================================================*/ + /* Clearing the tone events bit vector */ + + ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); + ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; + ulDwordData = 0x00000000; + + ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulDwordAddress += 4; + + ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + /* Write back the original values in the channel open structure.*/ + + pTdmConfig->ulSinPcmLaw = ulTempSinLaw; + pTdmConfig->ulSoutPcmLaw = ulTempSoutLaw; + + f_pChannelOpen->ulEchoOperationMode = ulTempEchoOpMode; + } + + /*==============================================================================*/ + + + /*==============================================================================*/ + /* If necessary, configure the SS tone detection. */ + + for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ ) + { + /* Check if the current tone is a SS tone. */ + ulResult = Oct6100ApiIsSSTone( + f_pApiInstance, + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID, + &fSSTone ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( fSSTone == TRUE ) + { + /* Write to all resources needed to activate tone detection on this SS tone. */ + ulResult = Oct6100ApiWriteToneDetectEvent( + f_pApiInstance, + f_pChanIndexConf->usEchoChanIndex, + ulToneEventNumber, + + cOCT6100_INVALID_INDEX ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /*==============================================================================*/ + + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiUpdateChannelEntry + +Description: Updates the new channel in the ECHO channel list. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pChannelOpen Pointer to echo cancellation channel configuration structure. +f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiUpdateChannelEntry( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig; + tPOCT6100_CHANNEL_OPEN_VQE pVqeConfig; + tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig; + + /* Obtain a pointer to the config structures of the tPOCT6100_CHANNEL_OPEN structure. */ + pTdmConfig = &f_pChannelOpen->TdmConfig; + pVqeConfig = &f_pChannelOpen->VqeConfig; + pCodecConfig = &f_pChannelOpen->CodecConfig; + + /* Obtain a pointer to the new buffer's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex ) + + /*=======================================================================*/ + /* Copy the channel's configuration and allocated resources. */ + pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId; + pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF ); + pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF ); + pChanEntry->fEnableExtToneDetection = (UINT8)( f_pChannelOpen->fEnableExtToneDetection & 0xFF ); + + /* Save the VQE configuration.*/ + pChanEntry->VqeConfig.byComfortNoiseMode = (UINT8)( pVqeConfig->ulComfortNoiseMode & 0xFF ); + pChanEntry->VqeConfig.fEnableNlp = (UINT8)( pVqeConfig->fEnableNlp & 0xFF ); + pChanEntry->VqeConfig.fEnableTailDisplacement = (UINT8)( pVqeConfig->fEnableTailDisplacement ); + pChanEntry->VqeConfig.usTailDisplacement = (UINT16)( pVqeConfig->ulTailDisplacement & 0xFFFF ); + pChanEntry->VqeConfig.usTailLength = (UINT16)( pVqeConfig->ulTailLength & 0xFFFF ); + + pChanEntry->VqeConfig.fSinDcOffsetRemoval = (UINT8)( pVqeConfig->fSinDcOffsetRemoval & 0xFF ); + pChanEntry->VqeConfig.fRinDcOffsetRemoval = (UINT8)( pVqeConfig->fRinDcOffsetRemoval & 0xFF ); + pChanEntry->VqeConfig.fRinLevelControl = (UINT8)( pVqeConfig->fRinLevelControl & 0xFF ); + pChanEntry->VqeConfig.chRinLevelControlGainDb = (INT8)( pVqeConfig->lRinLevelControlGainDb & 0xFF ); + pChanEntry->VqeConfig.fSoutLevelControl = (UINT8)( pVqeConfig->fSoutLevelControl & 0xFF ); + pChanEntry->VqeConfig.chSoutLevelControlGainDb = (INT8)( pVqeConfig->lSoutLevelControlGainDb & 0xFF ); + pChanEntry->VqeConfig.fRinAutomaticLevelControl = (UINT8)( pVqeConfig->fRinAutomaticLevelControl & 0xFF ); + pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb = (INT8)( pVqeConfig->lRinAutomaticLevelControlTargetDb & 0xFF ); + pChanEntry->VqeConfig.fSoutAutomaticLevelControl = (UINT8)( pVqeConfig->fSoutAutomaticLevelControl & 0xFF ); + pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb = (INT8)( pVqeConfig->lSoutAutomaticLevelControlTargetDb & 0xFF ); + pChanEntry->VqeConfig.fRinHighLevelCompensation = (UINT8)( pVqeConfig->fRinHighLevelCompensation & 0xFF ); + pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb = (INT8)( pVqeConfig->lRinHighLevelCompensationThresholdDb & 0xFF ); + pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction = (UINT8)( pVqeConfig->fSoutAdaptiveNoiseReduction & 0xFF ); + pChanEntry->VqeConfig.fSoutNoiseBleaching = (UINT8)( pVqeConfig->fSoutNoiseBleaching & 0xFF ); + pChanEntry->VqeConfig.fSoutConferencingNoiseReduction = (UINT8)( pVqeConfig->fSoutConferencingNoiseReduction & 0xFF ); + + pChanEntry->VqeConfig.fAcousticEcho = (UINT8)( pVqeConfig->fAcousticEcho & 0xFF ); + + pChanEntry->VqeConfig.fDtmfToneRemoval = (UINT8)( pVqeConfig->fDtmfToneRemoval & 0xFF ); + + pChanEntry->VqeConfig.chDefaultErlDb = (INT8)( pVqeConfig->lDefaultErlDb & 0xFF ); + pChanEntry->VqeConfig.chAecDefaultErlDb = (INT8)( pVqeConfig->lAecDefaultErlDb & 0xFF ); + pChanEntry->VqeConfig.usAecTailLength = (UINT16)( pVqeConfig->ulAecTailLength & 0xFFFF ); + pChanEntry->VqeConfig.byNonLinearityBehaviorA = (UINT8)( pVqeConfig->ulNonLinearityBehaviorA & 0xFF ); + pChanEntry->VqeConfig.byNonLinearityBehaviorB = (UINT8)( pVqeConfig->ulNonLinearityBehaviorB & 0xFF ); + pChanEntry->VqeConfig.byDoubleTalkBehavior = (UINT8)( pVqeConfig->ulDoubleTalkBehavior & 0xFF ); + pChanEntry->VqeConfig.chAnrSnrEnhancementDb = (INT8)( pVqeConfig->lAnrSnrEnhancementDb & 0xFF ); + pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation = (UINT8)( pVqeConfig->ulAnrVoiceNoiseSegregation & 0xFF ); + pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay = (UINT16)( pVqeConfig->ulToneDisablerVqeActivationDelay & 0xFFFF ); + + pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb & 0xFF ); + pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutNaturalListenerEnhancementGainDb & 0xFF ); + pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement = (UINT8)( pVqeConfig->fSoutNaturalListenerEnhancement & 0xFF ); + pChanEntry->VqeConfig.fRoutNoiseReduction = (UINT8)( pVqeConfig->fRoutNoiseReduction & 0xFF ); + pChanEntry->VqeConfig.fEnableMusicProtection = (UINT8)( pVqeConfig->fEnableMusicProtection & 0xFF ); + pChanEntry->VqeConfig.fIdleCodeDetection = (UINT8)( pVqeConfig->fIdleCodeDetection & 0xFF ); + + /* Save the codec information.*/ + pChanEntry->CodecConfig.byAdpcmNibblePosition = (UINT8)( pCodecConfig->ulAdpcmNibblePosition & 0xFF ); + + pChanEntry->CodecConfig.byDecoderPort = (UINT8)( pCodecConfig->ulDecoderPort & 0xFF ); + pChanEntry->CodecConfig.byDecodingRate = (UINT8)( pCodecConfig->ulDecodingRate & 0xFF ); + pChanEntry->CodecConfig.byEncoderPort = (UINT8)( pCodecConfig->ulEncoderPort & 0xFF ); + pChanEntry->CodecConfig.byEncodingRate = (UINT8)( pCodecConfig->ulEncodingRate & 0xFF ); + + pChanEntry->CodecConfig.fEnableSilenceSuppression = (UINT8)( pCodecConfig->fEnableSilenceSuppression & 0xFF ); + pChanEntry->CodecConfig.byPhase = (UINT8)( pCodecConfig->ulPhase & 0xFF ); + pChanEntry->CodecConfig.byPhasingType = (UINT8)( pCodecConfig->ulPhasingType & 0xFF ); + + /* Save the RIN settings.*/ + pChanEntry->TdmConfig.byRinPcmLaw = (UINT8)( pTdmConfig->ulRinPcmLaw & 0xFF ); + pChanEntry->TdmConfig.usRinTimeslot = (UINT16)( pTdmConfig->ulRinTimeslot & 0xFFFF ); + pChanEntry->TdmConfig.usRinStream = (UINT16)( pTdmConfig->ulRinStream & 0xFFFF ); + + /* Save the SIN settings.*/ + pChanEntry->TdmConfig.bySinPcmLaw = (UINT8)( pTdmConfig->ulSinPcmLaw & 0xFF ); + pChanEntry->TdmConfig.usSinTimeslot = (UINT16)( pTdmConfig->ulSinTimeslot & 0xFFFF ); + pChanEntry->TdmConfig.usSinStream = (UINT16)( pTdmConfig->ulSinStream & 0xFFFF ); + + /* Save the ROUT settings.*/ + pChanEntry->TdmConfig.byRoutPcmLaw = (UINT8)( pTdmConfig->ulRoutPcmLaw & 0xFF ); + pChanEntry->TdmConfig.usRoutTimeslot = (UINT16)( pTdmConfig->ulRoutTimeslot & 0xFFFF ); + pChanEntry->TdmConfig.usRoutStream = (UINT16)( pTdmConfig->ulRoutStream & 0xFFFF ); + + pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX; + pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0; + + /* Save the SOUT settings.*/ + pChanEntry->TdmConfig.bySoutPcmLaw = (UINT8)( pTdmConfig->ulSoutPcmLaw & 0xFF ); + pChanEntry->TdmConfig.usSoutTimeslot = (UINT16)( pTdmConfig->ulSoutTimeslot & 0xFFFF ); + pChanEntry->TdmConfig.usSoutStream = (UINT16)( pTdmConfig->ulSoutStream & 0xFFFF ); + + pChanEntry->TdmConfig.byRinNumTssts = (UINT8)( pTdmConfig->ulRinNumTssts & 0xFF ); + pChanEntry->TdmConfig.bySinNumTssts = (UINT8)( pTdmConfig->ulSinNumTssts & 0xFF ); + pChanEntry->TdmConfig.byRoutNumTssts = (UINT8)( pTdmConfig->ulRoutNumTssts & 0xFF ); + pChanEntry->TdmConfig.bySoutNumTssts = (UINT8)( pTdmConfig->ulSoutNumTssts & 0xFF ); + pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX; + pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0; + + /* Save the extended Tone detection information.*/ + pChanEntry->usExtToneChanIndex = f_pChanIndexConf->usExtToneChanIndex; + pChanEntry->usExtToneMixerIndex = f_pChanIndexConf->usExtToneMixerIndex; + pChanEntry->usExtToneTsiIndex = f_pChanIndexConf->usExtToneTsiIndex; + + if ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) + { + tPOCT6100_API_CHANNEL pExtToneChanEntry; + + /* Set the mode of the original channel. He is the channel performing detection on the + SIN port. The extended channel will perform detection on the RIN port.*/ + pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_SIN_PORT_MODE; + + /* Now, program the associated channel.*/ + + /* Obtain a pointer to the extended tone detection channel entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pExtToneChanEntry, f_pChanIndexConf->usExtToneChanIndex ); + + pExtToneChanEntry->fReserved = TRUE; + pExtToneChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_RIN_PORT_MODE; /* Detect on RIN port.*/ + pExtToneChanEntry->usExtToneChanIndex = f_pChanIndexConf->usEchoChanIndex; + + pExtToneChanEntry->aulToneConf[ 0 ] = 0; + pExtToneChanEntry->aulToneConf[ 1 ] = 0; + + } + else + { + /* No extended tone detection supported.*/ + pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED; + } + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Store hardware related information.*/ + pChanEntry->usRinRoutTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex; + pChanEntry->usSinSoutTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex; + pChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; + pChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX; + + /* We are not being tapped for now. */ + pChanEntry->fBeingTapped = FALSE; + + pChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX; + pChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX; + + /* The copy event has not yet been created. */ + pChanEntry->fCopyEventCreated = FALSE; + + pChanEntry->usRinRoutConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex; + pChanEntry->usSinSoutConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex; + + pChanEntry->usPhasingTsstIndex = f_pChanIndexConf->usPhasingTsstIndex; + + pChanEntry->fSinSoutCodecActive = f_pChanIndexConf->fSinSoutCodecActive; + pChanEntry->fRinRoutCodecActive = f_pChanIndexConf->fRinRoutCodecActive; + + + + pChanEntry->usEchoMemIndex = f_pChanIndexConf->usEchoMemIndex; + + pChanEntry->usRinTsstIndex = f_pChanIndexConf->usRinTsstIndex; + pChanEntry->usSinTsstIndex = f_pChanIndexConf->usSinTsstIndex; + pChanEntry->usRoutTsstIndex = f_pChanIndexConf->usRoutTsstIndex; + pChanEntry->usSoutTsstIndex = f_pChanIndexConf->usSoutTsstIndex; + + pChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX; + pChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX; + + /* Nothing muted for now. */ + pChanEntry->usMutedPorts = cOCT6100_CHANNEL_MUTE_PORT_NONE; + + /* Set all the GW feature initial value.*/ + /* Bridge info */ + pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX; + pChanEntry->fMute = FALSE; + + pChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX; + pChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX; + + /* Buffer playout info.*/ + pChanEntry->fRinBufPlaying = FALSE; + pChanEntry->fSoutBufPlaying = FALSE; + + /* Tone detection state. */ + /* This array is configured as follow.*/ + /* Index 0 contain event 0 to 31 (msb = event 31) and Index 1 contain index 32 - 55 */ + pChanEntry->aulToneConf[ 0 ] = 0; + pChanEntry->aulToneConf[ 1 ] = 0; + pChanEntry->ulLastSSToneDetected = cOCT6100_INVALID_VALUE; + pChanEntry->ulLastSSToneTimestamp = cOCT6100_INVALID_VALUE; + + /* Initialize the bidirectional flag.*/ + pChanEntry->fBiDirChannel = FALSE; + + /*=======================================================================*/ + /* Init some of the stats.*/ + + pChanEntry->sMaxERL = cOCT6100_INVALID_SIGNED_STAT_W; + pChanEntry->sMaxERLE = cOCT6100_INVALID_SIGNED_STAT_W; + pChanEntry->usMaxEchoDelay = cOCT6100_INVALID_STAT_W; + pChanEntry->usNumEchoPathChangesOfst = 0; + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Update the dependency of the phasing TSST if one is associated to the chanel.*/ + + if ( f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX ) + { + tPOCT6100_API_PHASING_TSST pPhasingEntry; + + mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanIndexConf->usPhasingTsstIndex ); + + pPhasingEntry->usDependencyCnt++; + } + /*=======================================================================*/ + + /*=======================================================================*/ + + /* Form handle returned to user. */ + *f_pChannelOpen->pulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanIndexConf->usEchoChanIndex; + + /* Finally, mark the channel as open. */ + pChanEntry->fReserved = TRUE; + pChanEntry->usExtraSinTsiDependencyCnt = 0; + + /* Increment the number of channel open.*/ + f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels++; + + /*=======================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelModifySer + +Description: Modify an echo cancellation channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelModify Pointer to channel configuration structure. The handle + identifying the buffer in all future function calls is + returned in this structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelModifySer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify ) +{ + UINT16 usChanIndex; + UINT32 ulResult; + UINT16 usNewRinTsstIndex; + UINT16 usNewSinTsstIndex; + UINT16 usNewRoutTsstIndex; + UINT16 usNewSoutTsstIndex; + UINT8 fSinSoutCodecActive = FALSE; + UINT8 fRinRoutCodecActive = FALSE; + UINT16 usNewPhasingTsstIndex; + tOCT6100_CHANNEL_OPEN *pTempChanOpen; + + /* We don't want this 290 byte structure on the stack */ + pTempChanOpen = (tOCT6100_CHANNEL_OPEN *)kmalloc(sizeof(tOCT6100_CHANNEL_OPEN),GFP_ATOMIC); + if(!pTempChanOpen) + return cOCT6100_ERR_CHANNEL_NOT_OPEN; + + /* Check the user's configuration of the echo cancellation channel for errors. */ + ulResult = Oct6100ApiCheckChannelModify( f_pApiInstance, + f_pChannelModify, + pTempChanOpen, + &usNewPhasingTsstIndex, + &usChanIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Reserve all resources needed by the echo cancellation channel. */ + ulResult = Oct6100ApiModifyChannelResources( f_pApiInstance, + f_pChannelModify, + usChanIndex, + &usNewRinTsstIndex, + &usNewSinTsstIndex, + &usNewRoutTsstIndex, + &usNewSoutTsstIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write all necessary structures to activate the echo cancellation channel. */ + ulResult = Oct6100ApiModifyChannelStructs( f_pApiInstance, + f_pChannelModify, + pTempChanOpen, + usChanIndex, + usNewPhasingTsstIndex, + &fSinSoutCodecActive, + &fRinRoutCodecActive, + usNewRinTsstIndex, + usNewSinTsstIndex, + usNewRoutTsstIndex, + usNewSoutTsstIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update the new echo cancellation channels's entry in the ECHO channel list. */ + ulResult = Oct6100ApiModifyChannelEntry( f_pApiInstance, + f_pChannelModify, + pTempChanOpen, + usChanIndex, + usNewPhasingTsstIndex, + fSinSoutCodecActive, + fRinRoutCodecActive, + usNewRinTsstIndex, + usNewSinTsstIndex, + usNewRoutTsstIndex, + usNewSoutTsstIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + kfree(pTempChanOpen); + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckChannelModify + +Description: Checks the user's echo cancellation channel modify structure for errors. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelModify Pointer to echo cancellation channel modify structure. +f_pTempChanOpen Pointer to a channel open structure. +f_pusNewPhasingTsstIndex Pointer to a new phasing TSST index within the API instance. +f_pusChanIndex Pointer to the channel index within the API instance channel list + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckChannelModify( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN tPOCT6100_CHANNEL_OPEN f_pTempChanOpen, + OUT PUINT16 f_pusNewPhasingTsstIndex, + OUT PUINT16 f_pusChanIndex ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + UINT32 ulResult; + UINT32 ulEntryOpenCnt; + UINT32 ulDecoderNumTssts; + + /* Check the provided handle. */ + if ( (f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + *f_pusChanIndex = (UINT16)( f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = ( f_pChannelModify->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pChanEntry->fReserved != TRUE ) + return cOCT6100_ERR_CHANNEL_NOT_OPEN; + if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Check the general modify parameters. */ + + if ( f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL && + f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE && + f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET && + f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN && + f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL && + f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION && + f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO ) + return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE; + + /* Check the 2100Hz echo disabling configuration.*/ + if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->fEnableToneDisabler != TRUE && + f_pChannelModify->fEnableToneDisabler != FALSE ) + return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE; + + /* Check the disable tone detection flag. */ + if ( f_pChannelModify->fDisableToneDetection != TRUE && + f_pChannelModify->fDisableToneDetection != FALSE ) + return cOCT6100_ERR_CHANNEL_DISABLE_TONE_DETECTION; + + /* Check the stop buffer playout flag. */ + if ( f_pChannelModify->fStopBufferPlayout != TRUE && + f_pChannelModify->fStopBufferPlayout != FALSE ) + return cOCT6100_ERR_CHANNEL_STOP_BUFFER_PLAYOUT; + + /* Check the remove conference bridge participant flag. */ + if ( f_pChannelModify->fRemoveConfBridgeParticipant != TRUE && + f_pChannelModify->fRemoveConfBridgeParticipant != FALSE ) + return cOCT6100_ERR_CHANNEL_REMOVE_CONF_BRIDGE_PARTICIPANT; + + /* Check the remove broadcast timeslots flag. */ + if ( f_pChannelModify->fRemoveBroadcastTssts != TRUE && + f_pChannelModify->fRemoveBroadcastTssts != FALSE ) + return cOCT6100_ERR_CHANNEL_REMOVE_BROADCAST_TSSTS; + + if ( f_pChannelModify->fCodecConfigModified != TRUE && + f_pChannelModify->fCodecConfigModified != FALSE ) + return cOCT6100_ERR_CHANNEL_MODIFY_CODEC_CONFIG; + + if ( f_pChannelModify->fVqeConfigModified != TRUE && + f_pChannelModify->fVqeConfigModified != FALSE ) + return cOCT6100_ERR_CHANNEL_MODIFY_VQE_CONFIG; + + if ( f_pChannelModify->fTdmConfigModified != TRUE && + f_pChannelModify->fTdmConfigModified != FALSE ) + return cOCT6100_ERR_CHANNEL_MODIFY_TDM_CONFIG; + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Verify if any law change was requested. If so reprogram all structures.*/ + + if (( f_pChannelModify->fTdmConfigModified == TRUE ) && + ( f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )) + { + f_pChannelModify->fVqeConfigModified = TRUE; + f_pChannelModify->fCodecConfigModified = TRUE; + } + /*=======================================================================*/ + + ulResult = Oct6100ApiUpdateOpenStruct( f_pApiInstance, f_pChannelModify, f_pTempChanOpen, pChanEntry ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* All further check will now be performed using the TempOpenChan structure in order + to reuse the checks written for the open channel structure.*/ + + + + /* Check the TDM config.*/ + if ( f_pChannelModify->fTdmConfigModified == TRUE ) + { + tPOCT6100_CHANNEL_MODIFY_TDM pModifyTdm; + tPOCT6100_CHANNEL_OPEN_TDM pOpenTdm; + + pModifyTdm = &f_pChannelModify->TdmConfig; + pOpenTdm = &f_pTempChanOpen->TdmConfig; + + ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance, + pOpenTdm ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if that Stream and Timeslot values are valid.*/ + + /* Check the RIN port.*/ + if ( f_pChannelModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT; + + if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_RIN_STREAM; + + if ( pChanEntry->fBeingTapped == TRUE ) + { + /* Check that the Rin stream + timeslot are not being assigned. */ + if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_RIN_STREAM; + + if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT; + } + } + + /* Check the SIN port.*/ + if ( f_pChannelModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT; + + if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_SIN_STREAM; + + /* Check the ROUT port.*/ + if ( f_pChannelModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT; + + if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_ROUT_STREAM; + + /* Check the SOUT port.*/ + if ( f_pChannelModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT; + + if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + return cOCT6100_ERR_CHANNEL_SOUT_STREAM; + + /* Verify if the channel is currently part of a bidirectional channel, and if */ + /* so perform the required checks. */ + if ( pChanEntry->fBiDirChannel == TRUE ) + { + /* Check the ports that must remain unassigned.*/ + if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT; + if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT; + + /* Check that no PCM law change is requested.*/ + if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION; + if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION; + } + + /* If this channel is on a conference bridge, a few more things must be checked. */ + if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX ) + { + /* If conferencing, law conversion cannot be applied. */ + /* This check is done only if both input and output ports are assigned. */ + if ( ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED ) + && ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED ) ) + { + /* Laws must be the same! */ + if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION; + } + + /* Check for Sin. */ + if ( ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED ) + && ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) ) + { + /* Laws must be the same! */ + if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION; + } + + /* Check if ADPCM is requested. */ + if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING && + f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS ) + { + /* No ADPCM in a conference bridge! */ + return cOCT6100_ERR_CHANNEL_ENCODING_RATE; + } + + if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING && + f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS ) + { + /* No ADPCM in a conference bridge! */ + return cOCT6100_ERR_CHANNEL_DECODING_RATE; + } + } + + if ( f_pTempChanOpen->CodecConfig.ulEncoderPort == cOCT6100_NO_ENCODING || + f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_NO_DECODING ) + { + /* Make sure no law conversion is attempted since it is not supported by the device.*/ + if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION; + if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw ) + return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION; + } + + if ( pChanEntry->fEnableExtToneDetection == TRUE && + f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT; + + /* A few special checks must be done if the configuration is to be applied */ + /* to all opened channels. */ + if ( f_pChannelModify->fApplyToAllChannels == TRUE ) + { + /* When the configuration to be applied is for all channels, */ + /* check that the stream and timeslot parameters are not being assigned. */ + + /* Check the Rout port. */ + if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Check that the Rout ports is being unassigned. */ + if ( f_pTempChanOpen->TdmConfig.ulRoutStream != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_ROUT_STREAM_UNASSIGN; + if ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT_UNASSIGN; + } + + /* Check the Rin port. */ + if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Check that the Rin ports is being unassigned. */ + if ( f_pTempChanOpen->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_RIN_STREAM_UNASSIGN; + if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT_UNASSIGN; + } + + /* Check the Sout port. */ + if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Check that the Sout ports is being unassigned. */ + if ( f_pTempChanOpen->TdmConfig.ulSoutStream != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_SOUT_STREAM_UNASSIGN; + if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT_UNASSIGN; + } + + /* Check the Sin port. */ + if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Check that the Sin ports is being unassigned. */ + if ( f_pTempChanOpen->TdmConfig.ulSinStream != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_SIN_STREAM_UNASSIGN; + if ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT_UNASSIGN; + } + } + } + + /* Check the VQE config.*/ + if ( f_pChannelModify->fVqeConfigModified == TRUE ) + { + ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance, + &f_pTempChanOpen->VqeConfig, + f_pTempChanOpen->fEnableToneDisabler ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Verify if the echo operation mode selected can be applied. */ + if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO ) + && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) ) + return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED; + + /* Check the Codec config.*/ + if ( f_pChannelModify->fCodecConfigModified == TRUE ) + { + if ( f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulRinNumTssts; + else /* f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */ + ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulSinNumTssts; + + ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance, + &f_pTempChanOpen->CodecConfig, + ulDecoderNumTssts, + f_pusNewPhasingTsstIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + + + /* make sure that if silence suppression is activated, the NLP is enabled.*/ + if ( f_pTempChanOpen->CodecConfig.fEnableSilenceSuppression == TRUE && f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) + return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED; + + /* Verify if the channel is currently part of a bidirectional channel, and if so perform + the required checks.*/ + if ( pChanEntry->fBiDirChannel == TRUE ) + { + /* Check the ports that must remain unassigned.*/ + if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING && + f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS ) + return cOCT6100_ERR_CHANNEL_ENCODING_RATE; + + if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING && + f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS ) + return cOCT6100_ERR_CHANNEL_DECODING_RATE; + } + + } + /*=======================================================================*/ + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiModifyChannelResources + +Description: Reserves any new resources needed for the channel +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelModify Pointer to echo cancellation channel configuration structure. +f_usChanIndex Allocated entry in ECHO channel list. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiModifyChannelResources( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN UINT16 f_usChanIndex, + OUT PUINT16 f_pusNewRinTsstIndex, + OUT PUINT16 f_pusNewSinTsstIndex, + OUT PUINT16 f_pusNewRoutTsstIndex, + OUT PUINT16 f_pusNewSoutTsstIndex ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + + tPOCT6100_API_CHANNEL_TDM pApiTdmConf; + tPOCT6100_CHANNEL_MODIFY_TDM pModifyTdmConf; + + UINT32 ulResult = cOCT6100_ERR_OK; + UINT32 ulTempVar = cOCT6100_ERR_OK; + UINT32 ulFreeMixerEventCnt; + + BOOL fRinReleased = FALSE; + BOOL fSinReleased = FALSE; + BOOL fRoutReleased = FALSE; + BOOL fSoutReleased = FALSE; + + BOOL fRinReserved = FALSE; + BOOL fSinReserved = FALSE; + BOOL fRoutReserved = FALSE; + BOOL fSoutReserved = FALSE; + + BOOL fReserveRin = FALSE; + BOOL fReserveSin = FALSE; + BOOL fReserveRout = FALSE; + BOOL fReserveSout = FALSE; + + BOOL fRinRoutConversionMemReserved = FALSE; + BOOL fSinSoutConversionMemReserved = FALSE; + + + UINT32 ulRinNumTssts = 1; + UINT32 ulSinNumTssts = 1; + UINT32 ulRoutNumTssts = 1; + UINT32 ulSoutNumTssts = 1; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_CHANNEL_MODIFY structure. */ + pModifyTdmConf = &f_pChannelModify->TdmConfig; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ) + + /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_API_CHANNEL structure. */ + pApiTdmConf = &pChanEntry->TdmConfig; + + /*===============================================================================*/ + /* Modify TSST resources if required.*/ + if ( f_pChannelModify->fTdmConfigModified == TRUE ) + { + /* First release any entry that need to be released.*/ + if ( ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + || ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + ) + { + if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Release the previously reserved entry.*/ + ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, + pChanEntry->TdmConfig.usRinTimeslot, + pChanEntry->TdmConfig.usRinStream, + pChanEntry->TdmConfig.byRinNumTssts, + cOCT6100_INPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fRinReleased = TRUE; + } + } + + fReserveRin = TRUE; + } + + /* Release SIN port.*/ + if ( ( ulResult == cOCT6100_ERR_OK ) + && ( ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + || ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + ) ) + { + if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Release the previously reserved entry.*/ + ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, + pChanEntry->TdmConfig.usSinTimeslot, + pChanEntry->TdmConfig.usSinStream, + pChanEntry->TdmConfig.bySinNumTssts, + cOCT6100_INPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fSinReleased = TRUE; + } + } + + fReserveSin = TRUE; + } + + /* Release ROUT port.*/ + if ( ( ulResult == cOCT6100_ERR_OK ) + && ( ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + || ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + ) ) + { + if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Release the previously reserved entry.*/ + ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, + pChanEntry->TdmConfig.usRoutTimeslot, + pChanEntry->TdmConfig.usRoutStream, + pChanEntry->TdmConfig.byRoutNumTssts, + cOCT6100_OUTPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fRoutReleased = TRUE; + } + } + + fReserveRout = TRUE; + } + + /* Release the SOUT port.*/ + if ( ( ulResult == cOCT6100_ERR_OK ) + && ( ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + || ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + ) ) + { + if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Release the previously reserved entry.*/ + ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, + pChanEntry->TdmConfig.usSoutTimeslot, + pChanEntry->TdmConfig.usSoutStream, + pChanEntry->TdmConfig.bySoutNumTssts, + cOCT6100_OUTPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fSoutReleased = TRUE; + } + } + + fReserveSout = TRUE; + } + + /* Now reserve any new entry required.*/ + + /* Modify RIN port.*/ + if ( ( fReserveRin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) ) + { + if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_UNASSIGNED ) + { + /* Check what number of TSSTs should be reserved this time. */ + if ( pModifyTdmConf->ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + ulRinNumTssts = pApiTdmConf->byRinNumTssts; + } + else /* if ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* New number of TSSTs. */ + ulRinNumTssts = pModifyTdmConf->ulRinNumTssts; + } + + if ( pModifyTdmConf->ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Reserve the new number of TSSTs. */ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pApiTdmConf->usRinTimeslot, + pApiTdmConf->usRinStream, + ulRinNumTssts, + cOCT6100_INPUT_TSST, + f_pusNewRinTsstIndex, + NULL ); + } + else /* if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* Reserve the new TSST.*/ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pModifyTdmConf->ulRinTimeslot, + pModifyTdmConf->ulRinStream, + ulRinNumTssts, + cOCT6100_INPUT_TSST, + f_pusNewRinTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fRinReserved = TRUE; + } + } + } + else + { + *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX; + } + } + else + { + *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX; + } + + /* Modify SIN port.*/ + if ( ( fReserveSin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) ) + { + if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_UNASSIGNED ) + { + /* Check what number of TSSTs should be reserved this time. */ + if ( pModifyTdmConf->ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + ulSinNumTssts = pApiTdmConf->bySinNumTssts; + } + else /* if ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* New number of TSSTs. */ + ulSinNumTssts = pModifyTdmConf->ulSinNumTssts; + } + + if ( pModifyTdmConf->ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Reserve the new number of TSSTs. */ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pApiTdmConf->usSinTimeslot, + pApiTdmConf->usSinStream, + ulSinNumTssts, + cOCT6100_INPUT_TSST, + f_pusNewSinTsstIndex, + NULL ); + } + else /* if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* Reserve the new TSST.*/ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pModifyTdmConf->ulSinTimeslot, + pModifyTdmConf->ulSinStream, + ulSinNumTssts, + cOCT6100_INPUT_TSST, + f_pusNewSinTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fSinReserved = TRUE; + } + } + } + else + { + *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX; + } + } + else + { + *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX; + } + + /* Modify ROUT port.*/ + if ( ( fReserveRout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) ) + { + if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_UNASSIGNED ) + { + /* Check what number of TSSTs should be reserved this time. */ + if ( pModifyTdmConf->ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + ulRoutNumTssts = pApiTdmConf->byRoutNumTssts; + } + else /* if ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* New number of TSSTs. */ + ulRoutNumTssts = pModifyTdmConf->ulRoutNumTssts; + } + + if ( pModifyTdmConf->ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Reserve the new number of TSSTs. */ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pApiTdmConf->usRoutTimeslot, + pApiTdmConf->usRoutStream, + ulRoutNumTssts, + cOCT6100_OUTPUT_TSST, + f_pusNewRoutTsstIndex, + NULL ); + } + else /* if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* Reserve the new TSST.*/ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pModifyTdmConf->ulRoutTimeslot, + pModifyTdmConf->ulRoutStream, + ulRoutNumTssts, + cOCT6100_OUTPUT_TSST, + f_pusNewRoutTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fRoutReserved = TRUE; + } + } + } + else + { + *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX; + } + } + else + { + *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX; + } + + /* Modify SOUT port.*/ + if ( ( fReserveSout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) ) + { + if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_UNASSIGNED ) + { + /* Check what number of TSSTs should be reserved this time. */ + if ( pModifyTdmConf->ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + ulSoutNumTssts = pApiTdmConf->bySoutNumTssts; + } + else /* if ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* New number of TSSTs. */ + ulSoutNumTssts = pModifyTdmConf->ulSoutNumTssts; + } + + if ( pModifyTdmConf->ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* Reserve the new number of TSSTs. */ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pApiTdmConf->usSoutTimeslot, + pApiTdmConf->usSoutStream, + ulSoutNumTssts, + cOCT6100_OUTPUT_TSST, + f_pusNewSoutTsstIndex, + NULL ); + } + else /* if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */ + { + /* Reserve the new TSST.*/ + ulResult = Oct6100ApiReserveTsst( f_pApiInstance, + pModifyTdmConf->ulSoutTimeslot, + pModifyTdmConf->ulSoutStream, + ulSoutNumTssts, + cOCT6100_OUTPUT_TSST, + f_pusNewSoutTsstIndex, + NULL ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fSoutReserved = TRUE; + } + } + } + else + { + *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX; + } + } + else + { + *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX; + } + + + } + + if ( f_pChannelModify->fCodecConfigModified == TRUE ) + { + if ( ulResult == cOCT6100_ERR_OK && + pChanEntry->usRinRoutConversionMemIndex == cOCT6100_INVALID_INDEX && + ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT || + f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) ) + { + /* Reserve an ADPCM memory block.*/ + ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usRinRoutConversionMemIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fRinRoutConversionMemReserved = TRUE; + } + } + + if ( ulResult == cOCT6100_ERR_OK && + pChanEntry->usSinSoutConversionMemIndex == cOCT6100_INVALID_INDEX && + ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT || + f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) ) + { + /* Reserve an ADPCM memory block.*/ + ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usSinSoutConversionMemIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + { + fSinSoutConversionMemReserved = TRUE; + } + } + } + + + /*===============================================================================*/ + /* Check if there are a couple of mixer events available for us. */ + + if ( ulResult == cOCT6100_ERR_OK ) + { + UINT32 ulMixerEventCntNeeded = 0; + + /* Calculate how many mixer events are needed. */ + if ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX ) + { + /* If the channel is in bidir mode, do not create the Rin silence event!!! */ + if ( pChanEntry->fBiDirChannel == FALSE ) + { + if ( ( *f_pusNewRinTsstIndex == cOCT6100_INVALID_INDEX ) + && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) ) + ulMixerEventCntNeeded++; + } + } + + if ( ( *f_pusNewSinTsstIndex == cOCT6100_INVALID_INDEX ) + && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) ) + { + ulMixerEventCntNeeded++; + } + + /* If at least 1 mixer event is needed, check if those are available. */ + if ( ulMixerEventCntNeeded != 0 ) + { + ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt ); + if ( ulResult == cOCT6100_ERR_OK ) + { + /* The API might need more mixer events if the ports have to be muted. */ + /* Check if these are available. */ + if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded ) + { + ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS; + } + } + } + } + + /*===============================================================================*/ + + /* Verify if an error occured. */ + if ( ulResult != cOCT6100_ERR_OK ) + { + /* Release any resources newly reserved.*/ + if ( fRinReserved == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pModifyTdmConf->ulRinTimeslot, + pModifyTdmConf->ulRinStream, + ulRinNumTssts, + cOCT6100_INPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* For the SIN port.*/ + if ( fSinReserved == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pModifyTdmConf->ulSinTimeslot, + pModifyTdmConf->ulSinStream, + ulSinNumTssts, + cOCT6100_INPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* For the ROUT port.*/ + if ( fRoutReserved == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pModifyTdmConf->ulRoutTimeslot, + pModifyTdmConf->ulRoutStream, + ulRoutNumTssts, + cOCT6100_OUTPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* For the SOUT port.*/ + if ( fSoutReserved == TRUE ) + { + ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, + pModifyTdmConf->ulSoutTimeslot, + pModifyTdmConf->ulSoutStream, + ulSoutNumTssts, + cOCT6100_OUTPUT_TSST, + cOCT6100_INVALID_INDEX ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* Now make sure any resources released gets reserved back again.*/ + + /* For the RIN port.*/ + if ( fRinReleased == TRUE ) + { + /* Reserve the new TSST.*/ + ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, + pChanEntry->TdmConfig.usRinTimeslot, + pChanEntry->TdmConfig.usRinStream, + pChanEntry->TdmConfig.byRinNumTssts, + cOCT6100_INPUT_TSST, + &pChanEntry->usRinTsstIndex, + NULL ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* For the SIN port.*/ + if ( fSinReleased == TRUE ) + { + /* Reserve the new TSST.*/ + ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, + pChanEntry->TdmConfig.usSinTimeslot, + pChanEntry->TdmConfig.usSinStream, + pChanEntry->TdmConfig.bySinNumTssts, + cOCT6100_INPUT_TSST, + &pChanEntry->usSinTsstIndex, + NULL ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* For the ROUT port.*/ + if ( fRoutReleased == TRUE ) + { + /* Reserve the new TSST.*/ + ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, + pChanEntry->TdmConfig.usRoutTimeslot, + pChanEntry->TdmConfig.usRoutStream, + pChanEntry->TdmConfig.byRoutNumTssts, + cOCT6100_OUTPUT_TSST, + &pChanEntry->usRoutTsstIndex, + NULL ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* For the SOUT port.*/ + if ( fSoutReleased == TRUE ) + { + /* Reserve the new TSST.*/ + ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, + pChanEntry->TdmConfig.usSoutTimeslot, + pChanEntry->TdmConfig.usSoutStream, + pChanEntry->TdmConfig.bySoutNumTssts, + cOCT6100_OUTPUT_TSST, + &pChanEntry->usSoutTsstIndex, + NULL ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* Release the conversion memories if they were reserved.*/ + if ( fRinRoutConversionMemReserved == TRUE ) + { + ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, + pChanEntry->usRinRoutConversionMemIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + if ( fSinSoutConversionMemReserved == TRUE ) + { + ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, + pChanEntry->usSinSoutConversionMemIndex ); + if ( ulTempVar != cOCT6100_ERR_OK ) + return ulTempVar; + } + + /* Now return the error.*/ + return ulResult; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiModifyChannelStructs + +Description: Performs all the required structure writes to configure the + echo cancellation channel based on the new modifications. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelModify Pointer to echo cancellation channel configuration structure. +f_pChannelOpen Pointer to a structure used to store the multiple resources indexes. +f_usChanIndex Index of the channel within the API's channel list. +f_usNewPhasingTsstIndex Index of the new phasing TSST. +f_pfSinSoutCodecActive Pointer to the state of the SIN/SOUT codec. +f_pfRinRoutCodecActive Pointer to the state of the RIN/ROUT codec. +f_usNewRinTsstIndex New RIN TSST memory index. +f_usNewSinTsstIndex New SIN TSST memory index. +f_usNewRoutTsstIndex New ROUT TSST memory index. +f_usNewSoutTsstIndex New SOUT TSST memory index. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiModifyChannelStructs( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usNewPhasingTsstIndex, + OUT PUINT8 f_pfSinSoutCodecActive, + OUT PUINT8 f_pfRinRoutCodecActive, + IN UINT16 f_usNewRinTsstIndex, + IN UINT16 f_usNewSinTsstIndex, + IN UINT16 f_usNewRoutTsstIndex, + IN UINT16 f_usNewSoutTsstIndex ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_WRITE_PARAMS WriteParams; + tPOCT6100_API_CHANNEL_CODEC pApiCodecConf; + tPOCT6100_API_CHANNEL_TDM pApiTdmConf; + tPOCT6100_API_CHANNEL_VQE pApiVqeConf; + + UINT32 ulResult; + UINT16 usReadData; + + UINT16 usSinTsstIndex; + UINT16 usRinTsstIndex; + + UINT32 ulToneConfIndex; + BOOL fClearPlayoutPointers = FALSE; + + BOOL fConversionEnabled = FALSE; + + + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ) + + /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */ + pApiCodecConf = &pChanEntry->CodecConfig; + pApiTdmConf = &pChanEntry->TdmConfig; + pApiVqeConf = &pChanEntry->VqeConfig; + + /*=======================================================================*/ + /* Init the RIN and SIN TSST index */ + + usRinTsstIndex = pChanEntry->usRinTsstIndex; + usSinTsstIndex = pChanEntry->usSinTsstIndex; + + + /*==============================================================================*/ + /* Clear the TSST that will be release.*/ + + if ( f_pChannelModify->fTdmConfigModified == TRUE ) + { + /* Modify RIN port.*/ + if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Clear the previous entry */ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Modify SIN port.*/ + if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Clear the previous entry */ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Modify ROUT port.*/ + if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Clear the previous entry */ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Modify SOUT port.*/ + if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING) + { + if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Clear the previous entry */ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Now, Configure the Tsst control memory.*/ + + if ( f_pChannelModify->fTdmConfigModified == TRUE ) + { + /* Modify RIN port.*/ + if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + usRinTsstIndex = f_usNewRinTsstIndex; + + if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + f_usNewRinTsstIndex, + pChanEntry->usExtraRinTsiMemIndex, + f_pChannelOpen->TdmConfig.ulRinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + f_usNewRinTsstIndex, + pChanEntry->usRinRoutTsiMemIndex, + f_pChannelOpen->TdmConfig.ulRinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + if ( f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX ) + { + if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pChanEntry->usRinTsstIndex, + pChanEntry->usExtraRinTsiMemIndex, + f_pChannelOpen->TdmConfig.ulRinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else + { + if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pChanEntry->usRinTsstIndex, + pChanEntry->usRinRoutTsiMemIndex, + f_pChannelOpen->TdmConfig.ulRinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + + /* Modify SIN port.*/ + if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + usSinTsstIndex = f_usNewSinTsstIndex; + + if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX ) + { + /* Write the new entry now.*/ + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + f_usNewSinTsstIndex, + pChanEntry->usExtraSinTsiMemIndex, + f_pChannelOpen->TdmConfig.ulSinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + /* Write the new entry now.*/ + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + f_usNewSinTsstIndex, + pChanEntry->usSinSoutTsiMemIndex, + f_pChannelOpen->TdmConfig.ulSinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + if ( f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING && + f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX ) + { + if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pChanEntry->usSinTsstIndex , + pChanEntry->usExtraSinTsiMemIndex, + f_pChannelOpen->TdmConfig.ulSinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else + { + if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pChanEntry->usSinTsstIndex , + pChanEntry->usSinSoutTsiMemIndex, + f_pChannelOpen->TdmConfig.ulSinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + + /* Modify ROUT port.*/ + if ( ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + || ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + ) + { + if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + if ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* If this output port is not muted. */ + if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) + { + /* Write the new entry now.*/ + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + f_usNewRoutTsstIndex, + pApiCodecConf->byAdpcmNibblePosition, + f_pChannelModify->TdmConfig.ulRoutNumTssts, + pChanEntry->usRinRoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else + { + /* If this output port is not muted. */ + if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) + { + /* Write the new entry now.*/ + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + f_usNewRoutTsstIndex, + pApiCodecConf->byAdpcmNibblePosition, + pApiTdmConf->byRoutNumTssts, + pChanEntry->usRinRoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + } + + /* Modify SOUT port.*/ + if ( ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + || ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + ) + { + if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + if ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + /* If this output port is not muted. */ + if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) + { + /* Write the new entry now.*/ + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + f_usNewSoutTsstIndex, + pApiCodecConf->byAdpcmNibblePosition, + f_pChannelModify->TdmConfig.ulSoutNumTssts, + pChanEntry->usSinSoutTsiMemIndex ); + + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else + { + /* If this output port is not muted. */ + if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) + { + /* Write the new entry now.*/ + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + f_usNewSoutTsstIndex, + pApiCodecConf->byAdpcmNibblePosition, + pApiTdmConf->bySoutNumTssts, + pChanEntry->usSinSoutTsiMemIndex ); + + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + } + + + + } + + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Modify the Encoder/Decoder memory if required.*/ + + if ( f_pChannelModify->fCodecConfigModified == TRUE ) + { + UINT32 ulCompType = 0; + UINT16 usTempTsiMemIndex; + UINT16 usDecoderMemIndex; + UINT16 usEncoderMemIndex; + UINT32 ulPcmLaw; + UINT16 usPhasingIndex; + BOOL fModifyAdpcmMem = TRUE; + + /*==============================================================================*/ + /* Reprogram the Decoder memory.*/ + + if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + usDecoderMemIndex = pChanEntry->usRinRoutConversionMemIndex; + } + else + { + usDecoderMemIndex = pChanEntry->usSinSoutConversionMemIndex; + } + + if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + usEncoderMemIndex = pChanEntry->usRinRoutConversionMemIndex; + } + else + { + usEncoderMemIndex = pChanEntry->usSinSoutConversionMemIndex; + } + + if ( usDecoderMemIndex != cOCT6100_INVALID_INDEX ) + { + switch( f_pChannelOpen->CodecConfig.ulDecodingRate ) + { + case cOCT6100_G711_64KBPS: + ulCompType = 0x8; + + if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw ) + fModifyAdpcmMem = FALSE; + + /* Check if both ports are assigned. If not, no law conversion needed here.. */ + if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED ) + || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) ) + fModifyAdpcmMem = FALSE; + } + else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */ + { + if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw ) + fModifyAdpcmMem = FALSE; + + /* Check if both ports are assigned. If not, no law conversion needed here.. */ + if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED ) + || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) ) + fModifyAdpcmMem = FALSE; + } + + break; + case cOCT6100_G726_40KBPS: + ulCompType = 0x3; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_32KBPS: + ulCompType = 0x2; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_24KBPS: + ulCompType = 0x1; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_16KBPS: + ulCompType = 0x0; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_2C_ENCODED: + ulCompType = 0x4; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_3C_ENCODED: + ulCompType = 0x5; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_4C_ENCODED: + ulCompType = 0x6; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_ENCODED: + ulCompType = 0x9; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G726_ENCODED: + ulCompType = 0xA; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G727_2C_ENCODED: + ulCompType = 0xC; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G727_3C_ENCODED: + ulCompType = 0xD; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G711_G727_4C_ENCODED: + ulCompType = 0xE; + fConversionEnabled = TRUE; + break; + + default: + return cOCT6100_ERR_FATAL_D6; + } + + if ( fModifyAdpcmMem == TRUE ) + { + /* Set the chariot memory based on the selected port.*/ + if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex; + ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */ + + /* Flag the entry as active.*/ + *f_pfRinRoutCodecActive = TRUE; + } + else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */ + { + usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex; + ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */ + + /* Flag the entry as active.*/ + *f_pfSinSoutCodecActive = TRUE; + } + + ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance, + usDecoderMemIndex, + ulCompType, + usTempTsiMemIndex, + ulPcmLaw, + pApiCodecConf->byAdpcmNibblePosition ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, + usDecoderMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Flag the entry as deactivated.*/ + if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + *f_pfRinRoutCodecActive = FALSE; + } + else + { + *f_pfSinSoutCodecActive = FALSE; + } + } + } + + /*==============================================================================*/ + + + + + /*==============================================================================*/ + /* Reprogram the Encoder memory.*/ + + if ( usEncoderMemIndex != cOCT6100_INVALID_INDEX ) + { + + fModifyAdpcmMem = TRUE; + + /* Set the chariot memory based on the selected port.*/ + if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex; + ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */ + } + else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex; + ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */ + } + + /* Set the phasing index .*/ + if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX ) + usPhasingIndex = f_usNewPhasingTsstIndex; + else + usPhasingIndex = pChanEntry->usPhasingTsstIndex; + + switch( f_pChannelOpen->CodecConfig.ulEncodingRate ) + { + case cOCT6100_G711_64KBPS: + if ( ulPcmLaw == cOCT6100_PCM_U_LAW ) + ulCompType = 0x4; + else /* ulPcmLaw == cOCT6100_PCM_A_LAW */ + ulCompType = 0x5; + + if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw ) + fModifyAdpcmMem = FALSE; + + /* Check if both ports are assigned. If not, no law conversion needed here.. */ + if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED ) + || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) ) + fModifyAdpcmMem = FALSE; + } + else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw ) + fModifyAdpcmMem = FALSE; + + /* Check if both ports are assigned. If not, no law conversion needed here.. */ + if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED ) + || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) ) + fModifyAdpcmMem = FALSE; + } + break; + case cOCT6100_G726_40KBPS: + ulCompType = 0x3; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_32KBPS: + ulCompType = 0x2; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_24KBPS: + ulCompType = 0x1; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G726_16KBPS: + ulCompType = 0x0; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_40KBPS_4_1: + ulCompType = 0xD; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_40KBPS_3_2: + ulCompType = 0xA; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_40KBPS_2_3: + ulCompType = 0x6; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_32KBPS_4_0: + ulCompType = 0xE; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_32KBPS_3_1: + ulCompType = 0xB; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_32KBPS_2_2: + ulCompType = 0x7; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_24KBPS_3_0: + ulCompType = 0xC; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_24KBPS_2_1: + ulCompType = 0x8; + fConversionEnabled = TRUE; + break; + + case cOCT6100_G727_16KBPS_2_0: + ulCompType = 0x9; + fConversionEnabled = TRUE; + break; + + default: + return cOCT6100_ERR_FATAL_D7; + } + + if ( fModifyAdpcmMem == TRUE ) + { + if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + *f_pfRinRoutCodecActive = TRUE; + } + else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + *f_pfSinSoutCodecActive = TRUE; + } + + ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance, + usEncoderMemIndex, + ulCompType, + usTempTsiMemIndex, + f_pChannelOpen->CodecConfig.fEnableSilenceSuppression, + pApiCodecConf->byAdpcmNibblePosition, + usPhasingIndex, + f_pChannelOpen->CodecConfig.ulPhasingType, + f_pChannelOpen->CodecConfig.ulPhase ); + + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, + usEncoderMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + *f_pfRinRoutCodecActive = FALSE; + } + else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + *f_pfSinSoutCodecActive = FALSE; + } + } + } + + /*==============================================================================*/ + } + + + + + /*==============================================================================*/ + /* Modify the VQE parameter if required.*/ + + if ( ( f_pChannelModify->fVqeConfigModified == TRUE ) + || ( (UINT8)f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) + || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) + { + ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance, + &f_pChannelOpen->VqeConfig, + f_pChannelOpen, + f_usChanIndex, + pChanEntry->usEchoMemIndex, + FALSE, + TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*==============================================================================*/ + /* Modify the Echo memory if required.*/ + if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING || + f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance, + &f_pChannelOpen->TdmConfig, + f_pChannelOpen, + pChanEntry->usEchoMemIndex, + pChanEntry->usRinRoutTsiMemIndex, + pChanEntry->usSinSoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Synch all the buffer playout field if needed by echo operation mode. */ + /* Note that Oct6100ApiWriteVqeMemory does not clear the playout pointers */ + /* since the flag is set to FALSE. */ + if ( ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE ) + && ( ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_HT_FREEZE ) + || ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN ) ) ) + { + /* Buffer playout must be stopped. */ + fClearPlayoutPointers = TRUE; + } + } + + /*==============================================================================*/ + /* Modify the Mixer events if law changes are requested. */ + + if ( pChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX && + f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Modify the value according to the new law.*/ + if ( f_pChannelModify->TdmConfig.ulSinPcmLaw == cOCT6100_PCM_A_LAW ) + WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )); + else + WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ))); + + /* Write back the new value.*/ + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + if ( pChanEntry->usSoutCopyEventIndex != cOCT6100_INVALID_INDEX && + f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Modify the value according to the new law.*/ + if ( f_pChannelModify->TdmConfig.ulSoutPcmLaw == cOCT6100_PCM_A_LAW ) + WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )); + else + WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ))); + + /* Write back the new value.*/ + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*==============================================================================*/ + /* Mute channel if required, this is done on a port basis */ + + ulResult = Oct6100ApiMutePorts( f_pApiInstance, + f_usChanIndex, + usRinTsstIndex, + usSinTsstIndex, + TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + /* Completely disable tone detection? */ + if ( f_pChannelModify->fDisableToneDetection == TRUE ) + { + /* Check if tone detection has been enabled on this channel. */ + for ( ulToneConfIndex = 0; ulToneConfIndex < ( sizeof( pChanEntry->aulToneConf ) / sizeof(UINT32) ); ulToneConfIndex ++ ) + { + /* Check if some tone has been activated on this channel. */ + if ( pChanEntry->aulToneConf[ ulToneConfIndex ] != 0 ) + { + tOCT6100_TONE_DETECTION_DISABLE ToneDetectDisable; + + /* Call the default function to make sure all parameters are assigned default values. */ + ulResult = Oct6100ToneDetectionDisableDef( &ToneDetectDisable ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Form channel handle. */ + ToneDetectDisable.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex; + + /* Disable all tones activated on this channel. */ + ToneDetectDisable.fDisableAll = TRUE; + + /* Call tone detection serialized function. */ + ulResult = Oct6100ToneDetectionDisableSer( f_pApiInstance, &ToneDetectDisable ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Get out of the loop, tone detection has been disabled! */ + break; + } + } + } + + /* Hard-stop buffer playout? */ + if ( f_pChannelModify->fStopBufferPlayout == TRUE ) + { + /* Check if playout has been started on the Rout port. */ + if ( ( pChanEntry->fRinBufPlaying == TRUE ) || ( pChanEntry->fRinBufAdded == TRUE ) ) + { + tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop; + + /* Call the default function to make sure all parameters are assigned default values. */ + ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Hard stop request. */ + PlayoutStop.fStopCleanly = FALSE; + + /* Form channel handle. */ + PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex; + + /* For the Rout port. */ + PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT; + + /* Call buffer playout stop serialized function. */ + ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + /* The chip might still be playing a last buffer. Make sure it hard-stops! */ + fClearPlayoutPointers = TRUE; + } + + /* Check if playout has been started on the Sout port. */ + if ( ( pChanEntry->fSoutBufPlaying == TRUE ) || ( pChanEntry->fSoutBufAdded == TRUE ) ) + { + tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop; + + /* Call the default function to make sure all parameters are assigned default values. */ + ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Hard stop request. */ + PlayoutStop.fStopCleanly = FALSE; + + /* Form channel handle. */ + PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex; + + /* For the Rout port. */ + PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT; + + /* Call buffer playout stop serialized function. */ + ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + /* The chip might still be playing a last buffer. Make sure it hard-stops! */ + fClearPlayoutPointers = TRUE; + } + } + + /* Remove participant from bridge? */ + if ( f_pChannelModify->fRemoveConfBridgeParticipant == TRUE ) + { + /* Check if this channel is on a bridge. */ + if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX ) + { + /* Channel is on a bridge, remove it. */ + tOCT6100_CONF_BRIDGE_CHAN_REMOVE BridgeChanRemove; + + /* Call the default function to make sure all parameters are assigned default values. */ + ulResult = Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Form channel handle. */ + BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex; + + /* Do not remove all channels, only the one specified. */ + BridgeChanRemove.fRemoveAll = FALSE; + + /* No need to assign conference bridge handle, the remove function will figure it out. */ + + /* Call conference bridge channel remove serialized function. */ + ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY ) + { + tPOCT6100_API_CHANNEL pTapChanEntry; + + /* Get a pointer to the tap channel's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTapChanEntry, pChanEntry->usTapChanIndex ) + + /* Form tap channel handle. */ + BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pTapChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | pChanEntry->usTapChanIndex; + + ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Re-form original channel handle. */ + BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex; + + ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + return ulResult; + } + } + } + } + + /* Remove all broadcast TSSTs? */ + if ( f_pChannelModify->fRemoveBroadcastTssts == TRUE ) + { + /* Check if broadcast TSSTs were used on the Rout port. */ + if ( pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX ) + { + tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove; + + ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Form channel handle. */ + BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex; + + /* Remove all broadcast TSSTs associated to the current channel. */ + BroadcastTsstRemove.fRemoveAll = TRUE; + + /* On the Rout port. */ + BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_ROUT; + + ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + + /* Check if broadcast TSSTs were used on the Sout port. */ + if ( pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX ) + { + tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove; + + ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Form channel handle. */ + BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex; + + /* Remove all broadcast TSSTs associated to the current channel. */ + BroadcastTsstRemove.fRemoveAll = TRUE; + + /* On the Sout port. */ + BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_SOUT; + + ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Check if have to make sure buffer playout is stopped. */ + if ( fClearPlayoutPointers == TRUE ) + { + tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop; + + Oct6100BufferPlayoutStopDef( &BufferPlayoutStop ); + + BufferPlayoutStop.fStopCleanly = FALSE; + BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT; + + ulResult = Oct6100ApiInvalidateChanPlayoutStructs( + f_pApiInstance, + &BufferPlayoutStop, + f_usChanIndex, + pChanEntry->usEchoMemIndex + + ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT; + ulResult = Oct6100ApiInvalidateChanPlayoutStructs( + f_pApiInstance, + &BufferPlayoutStop, + f_usChanIndex, + pChanEntry->usEchoMemIndex + + ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiModifyChannelEntry + +Description: Updates the channel structure in the ECHO channel list. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pChannelModify Pointer to echo cancellation channel modify structure. +f_pChannelOpen Pointer to echo cancellation channel configuration structure. +f_usChanIndex Index of the channel within the API's channel list. +f_usNewPhasingTsstIndex Index of the new phasing TSST. +f_fSinSoutCodecActive State of the SIN/SOUT codec. +f_fRinRoutCodecActive State of the RIN/ROUT codec. +f_usNewRinTsstIndex New RIN TSST memory index. +f_usNewSinTsstIndex New SIN TSST memory index. +f_usNewRoutTsstIndex New ROUT TSST memory index. +f_usNewSoutTsstIndex New SOUT TSST memory index. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiModifyChannelEntry( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usNewPhasingTsstIndex, + IN UINT8 f_fSinSoutCodecActive, + IN UINT8 f_fRinRoutCodecActive, + IN UINT16 f_usNewRinTsstIndex, + IN UINT16 f_usNewSinTsstIndex, + IN UINT16 f_usNewRoutTsstIndex, + IN UINT16 f_usNewSoutTsstIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_API_CHANNEL_CODEC pApiCodecConf; + tPOCT6100_API_CHANNEL_TDM pApiTdmConf; + tPOCT6100_API_CHANNEL_VQE pApiVqeConf; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ) + + /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */ + pApiCodecConf = &pChanEntry->CodecConfig; + pApiTdmConf = &pChanEntry->TdmConfig; + pApiVqeConf = &pChanEntry->VqeConfig; + + /*=======================================================================*/ + /* Copy the channel's general configuration. */ + + pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId; + pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF ); + pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF ); + + /* Save the codec state.*/ + pChanEntry->fSinSoutCodecActive = (UINT8)( f_fSinSoutCodecActive & 0xFF ); + pChanEntry->fRinRoutCodecActive = (UINT8)( f_fRinRoutCodecActive & 0xFF ); + + /*=======================================================================*/ + /* Copy the channel's TDM configuration of all the modified fields. */ + + if ( f_pChannelModify->fTdmConfigModified == TRUE ) + { + pApiTdmConf->byRinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRinPcmLaw & 0xFF ); + pApiTdmConf->bySinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSinPcmLaw & 0xFF ); + pApiTdmConf->byRoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutPcmLaw & 0xFF ); + pApiTdmConf->bySoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutPcmLaw & 0xFF ); + + pApiTdmConf->byRinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRinNumTssts & 0xFF ); + pApiTdmConf->bySinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSinNumTssts & 0xFF ); + pApiTdmConf->byRoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutNumTssts & 0xFF ); + pApiTdmConf->bySoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutNumTssts & 0xFF ); + + if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + pApiTdmConf->usRinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRinStream & 0xFFFF ); + pApiTdmConf->usRinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRinTimeslot & 0xFFFF ); + pChanEntry->usRinTsstIndex = f_usNewRinTsstIndex; + } + else /* f_ulNewRinTsstIndex != cOCT6100_INVALID_INDEX */ + { + pApiTdmConf->usRinStream = cOCT6100_UNASSIGNED; + pApiTdmConf->usRinTimeslot = cOCT6100_UNASSIGNED; + pChanEntry->usRinTsstIndex = cOCT6100_INVALID_INDEX; + } + } + + if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + pApiTdmConf->usSinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSinStream & 0xFFFF ); + pApiTdmConf->usSinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSinTimeslot & 0xFFFF ); + pChanEntry->usSinTsstIndex = f_usNewSinTsstIndex; + } + else /* f_ulNewSinTsstIndex != cOCT6100_INVALID_INDEX */ + { + pApiTdmConf->usSinStream = cOCT6100_UNASSIGNED; + pApiTdmConf->usSinTimeslot = cOCT6100_UNASSIGNED; + pChanEntry->usSinTsstIndex = cOCT6100_INVALID_INDEX; + } + } + + if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + pApiTdmConf->usRoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutStream & 0xFFFF ); + pApiTdmConf->usRoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutTimeslot & 0xFFFF ); + pChanEntry->usRoutTsstIndex = f_usNewRoutTsstIndex; + } + else /* f_ulNewRoutTsstIndex != cOCT6100_INVALID_INDEX */ + { + pApiTdmConf->usRoutStream = cOCT6100_UNASSIGNED; + pApiTdmConf->usRoutTimeslot = cOCT6100_UNASSIGNED; + pChanEntry->usRoutTsstIndex = cOCT6100_INVALID_INDEX; + } + } + + if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + pApiTdmConf->usSoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutStream & 0xFFFF ); + pApiTdmConf->usSoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutTimeslot & 0xFFFF ); + pChanEntry->usSoutTsstIndex = f_usNewSoutTsstIndex; + } + else /* f_ulNewSoutTsstIndex != cOCT6100_INVALID_INDEX */ + { + pApiTdmConf->usSoutStream = cOCT6100_UNASSIGNED; + pApiTdmConf->usSoutTimeslot = cOCT6100_UNASSIGNED; + pChanEntry->usSoutTsstIndex = cOCT6100_INVALID_INDEX; + } + } + } + + /*=======================================================================*/ + /* Copy the channel's VQE configuration of all the modified fields. */ + + if ( f_pChannelModify->fVqeConfigModified == TRUE ) + { + pApiVqeConf->fEnableNlp = (UINT8)( f_pChannelOpen->VqeConfig.fEnableNlp & 0xFF ); + pApiVqeConf->byComfortNoiseMode = (UINT8)( f_pChannelOpen->VqeConfig.ulComfortNoiseMode & 0xFF ); + pApiVqeConf->fSinDcOffsetRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval & 0xFF ); + pApiVqeConf->fRinDcOffsetRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval & 0xFF ); + pApiVqeConf->fRinLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fRinLevelControl & 0xFF ); + pApiVqeConf->fSoutLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutLevelControl & 0xFF ); + pApiVqeConf->fRinAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl & 0xFF ); + pApiVqeConf->fSoutAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl & 0xFF ); + pApiVqeConf->fRinHighLevelCompensation = (UINT8)( f_pChannelOpen->VqeConfig.fRinHighLevelCompensation & 0xFF ); + + pApiVqeConf->fSoutAdaptiveNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction & 0xFF ); + pApiVqeConf->fSoutNoiseBleaching = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNoiseBleaching & 0xFF ); + pApiVqeConf->fSoutConferencingNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction & 0xFF ); + pApiVqeConf->chRinLevelControlGainDb = (INT8)( f_pChannelOpen->VqeConfig.lRinLevelControlGainDb & 0xFF ); + pApiVqeConf->chSoutLevelControlGainDb = (INT8)( f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb & 0xFF ); + pApiVqeConf->chRinAutomaticLevelControlTargetDb = (INT8)( f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb & 0xFF ); + pApiVqeConf->chSoutAutomaticLevelControlTargetDb = (INT8)( f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb & 0xFF ); + pApiVqeConf->chRinHighLevelCompensationThresholdDb = (INT8)( f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb & 0xFF ); + pApiVqeConf->fEnableTailDisplacement = (UINT8)( f_pChannelOpen->VqeConfig.fEnableTailDisplacement & 0xFF ); + pApiVqeConf->usTailDisplacement = (UINT16)( f_pChannelOpen->VqeConfig.ulTailDisplacement & 0xFFFF ); + pApiVqeConf->usTailLength = (UINT16)( f_pChannelOpen->VqeConfig.ulTailLength & 0xFFFF ); + pApiVqeConf->fAcousticEcho = (UINT8)( f_pChannelOpen->VqeConfig.fAcousticEcho & 0xFF ); + pApiVqeConf->fDtmfToneRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fDtmfToneRemoval & 0xFF ); + + pApiVqeConf->chDefaultErlDb = (INT8)( f_pChannelOpen->VqeConfig.lDefaultErlDb & 0xFF ); + pApiVqeConf->chAecDefaultErlDb = (INT8)( f_pChannelOpen->VqeConfig.lAecDefaultErlDb & 0xFF ); + pApiVqeConf->usAecTailLength = (UINT16)( f_pChannelOpen->VqeConfig.ulAecTailLength & 0xFFFF ); + pApiVqeConf->chAnrSnrEnhancementDb = (INT8)( f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb & 0xFF ); + pApiVqeConf->byAnrVoiceNoiseSegregation = (UINT8)( f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation & 0xFF ); + pApiVqeConf->usToneDisablerVqeActivationDelay = (UINT16)( f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay & 0xFFFF ); + pApiVqeConf->byNonLinearityBehaviorA = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA & 0xFF ); + pApiVqeConf->byNonLinearityBehaviorB = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB & 0xFF ); + pApiVqeConf->byDoubleTalkBehavior = (UINT8)( f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior & 0xFF ); + pApiVqeConf->bySoutAutomaticListenerEnhancementGainDb = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb & 0xFF ); + pApiVqeConf->bySoutNaturalListenerEnhancementGainDb = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb & 0xFF ); + pApiVqeConf->fSoutNaturalListenerEnhancement = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement & 0xFF ); + pApiVqeConf->fRoutNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fRoutNoiseReduction & 0xFF ); + pApiVqeConf->fEnableMusicProtection = (UINT8)( f_pChannelOpen->VqeConfig.fEnableMusicProtection & 0xFF ); + pApiVqeConf->fIdleCodeDetection = (UINT8)( f_pChannelOpen->VqeConfig.fIdleCodeDetection & 0xFF ); + } + + /*=======================================================================*/ + /* Copy the channel's CODEC configuration of all the modified fields. */ + if ( f_pChannelModify->fCodecConfigModified == TRUE ) + { + pApiCodecConf->byAdpcmNibblePosition = (UINT8)( f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition & 0xFF ); + pApiCodecConf->byEncoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulEncoderPort & 0xFF ); + pApiCodecConf->byEncodingRate = (UINT8)( f_pChannelOpen->CodecConfig.ulEncodingRate & 0xFF ); + pApiCodecConf->byDecoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulDecoderPort & 0xFF ); + pApiCodecConf->byDecodingRate = (UINT8)( f_pChannelOpen->CodecConfig.ulDecodingRate & 0xFF ); + pApiCodecConf->fEnableSilenceSuppression = (UINT8)( f_pChannelOpen->CodecConfig.fEnableSilenceSuppression & 0xFF ); + pApiCodecConf->byPhase = (UINT8)( f_pChannelOpen->CodecConfig.ulPhase & 0xFF ); + pApiCodecConf->byPhasingType = (UINT8)( f_pChannelOpen->CodecConfig.ulPhasingType & 0xFF ); + + /* Update the API phasing TSST structure */ + if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX ) + { + tPOCT6100_API_PHASING_TSST pPhasingTsst; + + /* Release the previous phasing TSST if the channel was already bound to one.*/ + if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX ) + { + mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, pChanEntry->usPhasingTsstIndex ); + + pPhasingTsst->usDependencyCnt--; + } + + mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, f_usNewPhasingTsstIndex ); + + pPhasingTsst->usDependencyCnt++; + pChanEntry->usPhasingTsstIndex = f_usNewPhasingTsstIndex; + + } + } + + + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelBroadcastTsstRemoveSer + +Description: Removes a broadcast TSST from one of the output port of an + echo cancellation channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelTsstRemove Pointer to TSST remove structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelBroadcastTsstRemoveSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove) +{ + UINT16 usChanIndex; + UINT16 usTsstIndex; + UINT16 usTsstEntry; + UINT16 usPrevTsstEntry; + UINT32 ulResult; + + ulResult = Oct6100ApiAssertChanTsstRemoveParams( f_pApiInstance, f_pChannelTsstRemove, &usChanIndex, &usTsstIndex, &usTsstEntry, &usPrevTsstEntry ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiInvalidateTsstRemoveStructs( f_pApiInstance, usChanIndex, usTsstIndex, f_pChannelTsstRemove->ulPort, f_pChannelTsstRemove->fRemoveAll ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiReleaseTsstRemoveResources( f_pApiInstance, f_pChannelTsstRemove, usChanIndex, usTsstIndex, usTsstEntry, usPrevTsstEntry ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAssertChanTsstRemoveParams + +Description: Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE + structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelTsstRemove Pointer to echo cancellation channel open configuration structure. +f_pulChanIndex Pointer to a channel index. +f_pulNewTsstIndex Pointer to a TSST index within the TSST control memory. +f_pulNewTsstEntry Pointer to a TSST entry within the API TSST list. +f_pulPrevTsstEntry Pointer to the previous TSST entry. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAssertChanTsstRemoveParams( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove, + OUT PUINT16 f_pusChanIndex, + OUT PUINT16 f_pusTsstIndex, + OUT PUINT16 f_pusTsstEntry, + OUT PUINT16 f_pusPrevTsstEntry ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_API_TSST_ENTRY pTsstEntry; + UINT32 ulResult; + UINT32 ulNumTssts = 1; + UINT32 ulEntryOpenCnt; + UINT16 usCurrentEntry; + UINT16 usTsstValue; + UINT16 usNumEntry; + + /* Check the provided handle. */ + if ( (f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + *f_pusChanIndex = (UINT16)( f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = ( f_pChannelTsstRemove->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pChanEntry->fReserved != TRUE ) + return cOCT6100_ERR_CHANNEL_NOT_OPEN; + if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + /*=======================================================================*/ + + /* validate the port parameter.*/ + if ( f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_ROUT && + f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_SOUT ) + return cOCT6100_ERR_CHANNEL_TSST_REMOVE_PORT; + + /* Verify that the requested entry is present in the channel's port broadcast TSST.*/ + if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry; + usNumEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry; + } + else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry; + usNumEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry; + } + + /* Verify if at least one TSST is present on the channel port.*/ + if ( usNumEntry == 0 ) + return cOCT6100_ERR_CHANNEL_TSST_REMOVE_NO_BROADCAST_TSST; + + /* Get the required number of TSST based on the port.*/ + switch( f_pChannelTsstRemove->ulPort ) + { + case cOCT6100_CHANNEL_PORT_ROUT: + ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts; + break; + case cOCT6100_CHANNEL_PORT_SOUT: + ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts; + break; + default: + return cOCT6100_ERR_FATAL_E; + } + + /* Initialize the TSST entry to invalid.*/ + *f_pusTsstEntry = cOCT6100_INVALID_INDEX; + *f_pusPrevTsstEntry = cOCT6100_INVALID_INDEX; + *f_pusTsstIndex = cOCT6100_INVALID_INDEX; + + if ( f_pChannelTsstRemove->fRemoveAll != TRUE ) + { + /* Check the validity of the timeslot and Stream.*/ + ulResult = Oct6100ApiValidateTsst( f_pApiInstance, + ulNumTssts, + f_pChannelTsstRemove->ulTimeslot, + f_pChannelTsstRemove->ulStream, + cOCT6100_OUTPUT_TSST ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT ) + { + return cOCT6100_ERR_CHANNEL_TSST_REMOVE_TIMESLOT; + } + else if ( ulResult == cOCT6100_ERR_TSST_STREAM ) + { + return cOCT6100_ERR_CHANNEL_TSST_REMOVE_STREAM; + } + else + { + return ulResult; + } + } + + /* Set the TSST value based on the timeslot and stream value.*/ + usTsstValue = (UINT16)( (f_pChannelTsstRemove->ulTimeslot << 5) | f_pChannelTsstRemove->ulStream ); + + while( usCurrentEntry != cOCT6100_INVALID_INDEX ) + { + mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry ); + + if ( usTsstValue == pTsstEntry->usTsstValue ) + { + /* A match was found.*/ + *f_pusTsstEntry = usCurrentEntry; + *f_pusTsstIndex = pTsstEntry->usTsstMemoryIndex; + break; + } + + /* Move on to the next entry.*/ + *f_pusPrevTsstEntry = usCurrentEntry; + usCurrentEntry = pTsstEntry->usNextEntry; + } + + if ( *f_pusTsstEntry == cOCT6100_INVALID_INDEX ) + return cOCT6100_ERR_CHANNEL_TSST_REMOVE_INVALID_TSST; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInvalidateTsstRemoveStructs + +Description: Invalidate the entry of the broadcast TSST. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_usChanIndex Channel index. +f_usTsstIndex TSST index within the TSST control memory. +f_ulPort Channel port where the TSST are removed from. (only used if remove all == TRUE) +f_fRemoveAll Remove all flag. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInvalidateTsstRemoveStructs( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usChanIndex, + IN UINT16 f_usTsstIndex, + IN UINT32 f_ulPort, + IN BOOL f_fRemoveAll ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + if ( f_fRemoveAll == FALSE ) + { + /* Deactivate the entry now.*/ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else /* f_fRemoveAll == TRUE */ + { + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_API_TSST_ENTRY pTsstEntry; + UINT16 usTsstEntry; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex ); + + /* Clear all entry associated to the selected port.*/ + if ( f_ulPort == cOCT6100_CHANNEL_PORT_ROUT ) + usTsstEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry; + else + usTsstEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry; + + do + { + mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usTsstEntry ); + + /* Deactivate the entry now.*/ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( ( pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usTsstEntry = pTsstEntry->usNextEntry; + + } while ( usTsstEntry != cOCT6100_INVALID_INDEX ); + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseTsstRemoveResources + +Description: Release all API resources associated to the Removed TSST and + update the channel entry accordingly. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChannelTsstRemove Pointer to echo cancellation channel open configuration structure. +f_usChanIndex Channel index. +f_usTsstIndex TSST index within the TSST control memory. +f_usTsstEntry TSST entry within the API's TSST list. +f_usPrevTsstEntry Previous TSST entry within the API's TSST list. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseTsstRemoveResources( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove, + IN UINT16 f_usChanIndex, + IN UINT16 f_usTsstIndex, + IN UINT16 f_usTsstEntry, + IN UINT16 f_usPrevTsstEntry ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_API_TSST_ENTRY pTsstEntry; + tPOCT6100_API_TSST_ENTRY pPrevTsstEntry; + UINT16 usCurrentEntry; + UINT32 ulResult; + UINT32 ulTimeslot; + UINT32 ulStream; + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex ); + + if ( f_pChannelTsstRemove->fRemoveAll == FALSE ) + { + mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usTsstEntry ); + + /* Update the channel entry.*/ + if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + /* Check if the entry was the first in the list.*/ + if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX ) + { + pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry; + } + else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */ + { + /* Get a pointer to the previous entry.*/ + mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry ); + pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry; + } + + /* Decrement the number of entry.*/ + pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry--; + } + else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + /* Check if the entry was the first in the list.*/ + if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX ) + { + pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry; + } + else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */ + { + /* Get a pointer to the previous entry.*/ + mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry ); + pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry; + } + + /* Decrement the number of entry.*/ + pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry--; + } + + ulTimeslot = pTsstEntry->usTsstValue >> 5; + ulStream = pTsstEntry->usTsstValue & 0x1F; + + /* Release the entry.*/ + ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, + ulTimeslot, + ulStream, + cOCT6100_NUMBER_TSSTS_1, + cOCT6100_OUTPUT_TSST, + f_usTsstEntry ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else /* f_pChannelTsstRemove->fRemoveAll == TRUE */ + { + + /* Update the channel entry.*/ + if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT ) + usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry; + else + usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry; + + do + { + mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry ); + + ulTimeslot = pTsstEntry->usTsstValue >> 5; + ulStream = pTsstEntry->usTsstValue & 0x1F; + + /* Release the entry.*/ + ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, + ulTimeslot, + ulStream, + cOCT6100_NUMBER_TSSTS_1, + cOCT6100_OUTPUT_TSST, + usCurrentEntry ); /* Release the entry.*/ + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usCurrentEntry = pTsstEntry->usNextEntry; + + /* Clear the previous node.*/ + pTsstEntry->usTsstMemoryIndex = 0xFFFF; + pTsstEntry->usTsstValue = 0xFFFF; + pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX; + + } while ( usCurrentEntry != cOCT6100_INVALID_INDEX ); + + /* Reset the channel status.*/ + if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX; + pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0; + } + else + { + pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX; + pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0; + } + } + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReserveEchoEntry + +Description: Reserves one of the echo channel API entry. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pusEchoIndex Resulting index reserved in the echo channel list. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReserveEchoEntry( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusEchoIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pEchoAlloc; + UINT32 ulResult; + UINT32 ulEchoIndex; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc ) + + ulResult = OctapiLlmAllocAlloc( pEchoAlloc, &ulEchoIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT ) + return cOCT6100_ERR_CHANNEL_ALL_CHANNELS_ARE_OPENED; + else + return cOCT6100_ERR_FATAL_11; + } + + *f_pusEchoIndex = (UINT16)( ulEchoIndex & 0xFFFF ); + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseEchoEntry + +Description: Releases the specified ECHO channel API entry. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_usEchoIndex Index reserved in the echo channel list. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseEchoEntry( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEchoIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pEchoAlloc; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc ) + + ulResult = OctapiLlmAllocDealloc( pEchoAlloc, f_usEchoIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_12; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckTdmConfig + +Description: This function will check the validity of the TDM config parameter + of an Open TDM config structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pTdmConfig TDM config of the channel. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckTdmConfig( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig ) +{ + UINT32 ulResult; + + /*==============================================================================*/ + /* Check the TDM configuration parameters.*/ + + /* Check the validity of the timeslot and Stream only if it is defined.*/ + if ( f_pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED || + f_pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED ) + { + if ( f_pTdmConfig->ulRinNumTssts != 1 && + f_pTdmConfig->ulRinNumTssts != 2 ) + return cOCT6100_ERR_CHANNEL_RIN_NUM_TSSTS; + + /* Check the RIN TDM streams, timeslots component for errors.*/ + ulResult = Oct6100ApiValidateTsst( f_pApiInstance, + f_pTdmConfig->ulRinNumTssts, + f_pTdmConfig->ulRinTimeslot, + f_pTdmConfig->ulRinStream, + cOCT6100_INPUT_TSST ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT ) + { + return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT; + } + else if ( ulResult == cOCT6100_ERR_TSST_STREAM ) + { + return cOCT6100_ERR_CHANNEL_RIN_STREAM; + } + else + { + return ulResult; + } + } + } + + /* Check the validity of the timeslot and Stream only if it is defined.*/ + if ( f_pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED || + f_pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED ) + { + if ( f_pTdmConfig->ulRoutNumTssts != 1 && + f_pTdmConfig->ulRoutNumTssts != 2 ) + return cOCT6100_ERR_CHANNEL_ROUT_NUM_TSSTS; + + /* Check the ROUT TDM streams, timeslots component for errors.*/ + ulResult = Oct6100ApiValidateTsst( f_pApiInstance, + f_pTdmConfig->ulRoutNumTssts, + f_pTdmConfig->ulRoutTimeslot, + f_pTdmConfig->ulRoutStream, + cOCT6100_OUTPUT_TSST ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT ) + { + return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT; + } + else if ( ulResult == cOCT6100_ERR_TSST_STREAM ) + { + return cOCT6100_ERR_CHANNEL_ROUT_STREAM; + } + else + { + return ulResult; + } + } + } + + /* Check the validity of the timeslot and Stream only if it is defined.*/ + if ( f_pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED || + f_pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED ) + { + if ( f_pTdmConfig->ulSinNumTssts != 1 && + f_pTdmConfig->ulSinNumTssts != 2 ) + return cOCT6100_ERR_CHANNEL_SIN_NUM_TSSTS; + + /* Check the SIN TDM streams, timeslots component for errors.*/ + ulResult = Oct6100ApiValidateTsst( f_pApiInstance, + f_pTdmConfig->ulSinNumTssts, + f_pTdmConfig->ulSinTimeslot, + f_pTdmConfig->ulSinStream, + cOCT6100_INPUT_TSST ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT ) + { + return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT; + } + else if ( ulResult == cOCT6100_ERR_TSST_STREAM ) + { + return cOCT6100_ERR_CHANNEL_SIN_STREAM; + } + else + { + return ulResult; + } + } + } + + /* Check the validity of the timeslot and Stream only if it is defined.*/ + if ( f_pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED || + f_pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED ) + { + if ( f_pTdmConfig->ulSoutNumTssts != 1 && + f_pTdmConfig->ulSoutNumTssts != 2 ) + return cOCT6100_ERR_CHANNEL_SOUT_NUM_TSSTS; + + /* Check the ROUT TDM streams, timeslots component for errors.*/ + ulResult = Oct6100ApiValidateTsst( f_pApiInstance, + f_pTdmConfig->ulSoutNumTssts, + f_pTdmConfig->ulSoutTimeslot, + f_pTdmConfig->ulSoutStream, + cOCT6100_OUTPUT_TSST ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT ) + { + return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT; + } + else if ( ulResult == cOCT6100_ERR_TSST_STREAM ) + { + return cOCT6100_ERR_CHANNEL_SOUT_STREAM; + } + else + { + return ulResult; + } + } + } + + /* Check the PCM law parameters.*/ + if ( f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_U_LAW && + f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_A_LAW ) + return cOCT6100_ERR_CHANNEL_RIN_PCM_LAW; + + if ( f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_U_LAW && + f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_A_LAW ) + return cOCT6100_ERR_CHANNEL_SIN_PCM_LAW; + + if ( f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_U_LAW && + f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_A_LAW ) + return cOCT6100_ERR_CHANNEL_ROUT_PCM_LAW; + + if ( f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_U_LAW && + f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_A_LAW ) + return cOCT6100_ERR_CHANNEL_SOUT_PCM_LAW; + + /*==============================================================================*/ + + + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckVqeConfig + +Description: This function will check the validity of the VQE config parameter + of an Open VQE config structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pVqeConfig VQE config of the channel. +f_fEnableToneDisabler Whether the tone disabler is active or not. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckVqeConfig( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN BOOL f_fEnableToneDisabler ) +{ + tPOCT6100_API_IMAGE_INFO pImageInfo; + + pImageInfo = &f_pApiInstance->pSharedInfo->ImageInfo; + + if ( f_pVqeConfig->fEnableNlp != TRUE && f_pVqeConfig->fEnableNlp != FALSE ) + return cOCT6100_ERR_CHANNEL_ENABLE_NLP; + + if ( f_pVqeConfig->fEnableNlp == TRUE && pImageInfo->fNlpControl == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLP_CONTROL; + + + + /* Check the comfort noise mode.*/ + if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF && pImageInfo->fComfortNoise == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_BKG_NOISE_FREEZE; + + if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_NORMAL && + f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_EXTENDED && + f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_FAST_LATCH && + f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF ) + return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_MODE; + + /* Check the DC offset removal.*/ + if ( f_pVqeConfig->fSinDcOffsetRemoval != TRUE && f_pVqeConfig->fSinDcOffsetRemoval != FALSE ) + return cOCT6100_ERR_CHANNEL_SIN_DC_OFFSET_REM; + + if ( f_pVqeConfig->fSinDcOffsetRemoval == TRUE && pImageInfo->fSinDcOffsetRemoval == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_DC_OFFSET_REM; + + if ( f_pVqeConfig->fRinDcOffsetRemoval != TRUE && f_pVqeConfig->fRinDcOffsetRemoval != FALSE ) + return cOCT6100_ERR_CHANNEL_RIN_DC_OFFSET_REM; + + if ( f_pVqeConfig->fRinDcOffsetRemoval == TRUE && pImageInfo->fRinDcOffsetRemoval == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_DC_OFFSET_REM; + + /* Check the Level control.*/ + if ( f_pVqeConfig->fRinLevelControl != TRUE && f_pVqeConfig->fRinLevelControl != FALSE ) + return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL; + + if ( f_pVqeConfig->fSoutLevelControl != TRUE && f_pVqeConfig->fSoutLevelControl != FALSE ) + return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL; + + if ( ( f_pVqeConfig->lRinLevelControlGainDb < -24 ) || ( f_pVqeConfig->lRinLevelControlGainDb > 24 ) ) + return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL_GAIN; + + if ( ( f_pVqeConfig->lSoutLevelControlGainDb < -24 ) || ( f_pVqeConfig->lSoutLevelControlGainDb > 24 ) ) + return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL_GAIN; + + if ( ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) && ( f_pVqeConfig->fRinAutomaticLevelControl != FALSE ) ) + return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL; + + if ( ( f_pVqeConfig->fRinHighLevelCompensation != TRUE ) && ( f_pVqeConfig->fRinHighLevelCompensation != FALSE ) ) + return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP; + + if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) && ( pImageInfo->fRinAutoLevelControl == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC; + + if ( ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) && ( pImageInfo->fRinHighLevelCompensation == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP; + + if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) + { + if ( f_pVqeConfig->fRinLevelControl == TRUE ) + return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_MANUAL; + + if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) + return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_HIGH_LEVEL_COMP; + + if ( ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lRinAutomaticLevelControlTargetDb > 0 ) ) + return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET; + } + + if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) + { + if ( f_pVqeConfig->fRinLevelControl == TRUE ) + return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_MANUAL; + + if ( ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb < -40 || f_pVqeConfig->lRinHighLevelCompensationThresholdDb > 0 ) ) + return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_THRESHOLD; + } + + if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE && f_pVqeConfig->fSoutAutomaticLevelControl != FALSE ) + return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL; + + if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC; + + if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) + { + if ( f_pVqeConfig->fSoutLevelControl == TRUE ) + return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_MANUAL; + + if ( ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lSoutAutomaticLevelControlTargetDb > 0 ) ) + return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET; + } + + if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != TRUE && + f_pVqeConfig->fSoutAdaptiveNoiseReduction != FALSE ) + return cOCT6100_ERR_CHANNEL_SOUT_ADAPT_NOISE_REDUCTION; + + if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && pImageInfo->fAdaptiveNoiseReduction == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR; + + if ( f_pVqeConfig->fSoutConferencingNoiseReduction != TRUE && + f_pVqeConfig->fSoutConferencingNoiseReduction != FALSE ) + return cOCT6100_ERR_CHANNEL_SOUT_CONFERENCE_NOISE_REDUCTION; + + if ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE && pImageInfo->fConferencingNoiseReduction == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_CNR; + + /* Validate Sout noise bleaching parameter. */ + if ( f_pVqeConfig->fSoutNoiseBleaching != TRUE && + f_pVqeConfig->fSoutNoiseBleaching != FALSE ) + return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING; + + /* Check if firmware supports Sout noise bleaching. */ + if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE && pImageInfo->fSoutNoiseBleaching == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NOISE_BLEACHING; + + /* If Sout noise bleaching is requested, no ANR or CNR shall be activated. */ + if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE ) + { + /* No xNR! */ + if ( ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE ) + || ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE ) ) + return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING_NR; + } + + /* Cannot activate both ANR and CNR when noise bleaching is present */ + if ( pImageInfo->fSoutNoiseBleaching == TRUE ) + { + if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && + f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE ) + return cOCT6100_ERR_CHANNEL_ANR_CNR_SIMULTANEOUSLY; + } + + /* Validate the DTMF tone removal parameter.*/ + if ( f_pVqeConfig->fDtmfToneRemoval != TRUE && f_pVqeConfig->fDtmfToneRemoval != FALSE ) + return cOCT6100_ERR_CHANNEL_TONE_REMOVAL; + + if ( f_pVqeConfig->fDtmfToneRemoval == TRUE && pImageInfo->fToneRemoval == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_REMOVAL; + + + + /* Check the Tail displacement enable.*/ + if ( f_pVqeConfig->fEnableTailDisplacement != TRUE && f_pVqeConfig->fEnableTailDisplacement != FALSE ) + return cOCT6100_ERR_CHANNEL_ENABLE_TAIL_DISPLACEMENT; + + if ( f_pVqeConfig->fEnableTailDisplacement == TRUE && pImageInfo->fTailDisplacement == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_DISPLACEMENT; + + /* Check the Tail displacement value.*/ + if ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) + { + if ( f_pVqeConfig->ulTailDisplacement != cOCT6100_AUTO_SELECT_TAIL ) + { + /* Check if this feature is supported by the image. */ + if ( pImageInfo->fPerChannelTailDisplacement == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_PER_CHAN_TAIL; + + /* Check that this value is not greater then what the image supports. */ + if ( f_pVqeConfig->ulTailDisplacement > pImageInfo->usMaxTailDisplacement ) + return cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT_INVALID; + } + } + + /* Check the tail length value. */ + if ( f_pVqeConfig->ulTailLength != cOCT6100_AUTO_SELECT_TAIL ) + { + /* Check if this feature is supported by the image. */ + if ( ( pImageInfo->fPerChannelTailLength == FALSE ) + && ( (UINT16)( f_pVqeConfig->ulTailLength & 0xFFFF ) != pImageInfo->usMaxTailLength ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_LENGTH; + + if ( ( f_pVqeConfig->ulTailLength < 32 ) || ( f_pVqeConfig->ulTailLength > 128 ) + || ( ( f_pVqeConfig->ulTailLength % 4 ) != 0x0 ) ) + return cOCT6100_ERR_CHANNEL_TAIL_LENGTH; + + /* Check if the requested tail length is supported by the chip. */ + if ( f_pVqeConfig->ulTailLength > pImageInfo->usMaxTailLength ) + return cOCT6100_ERR_CHANNEL_TAIL_LENGTH_INVALID; + } + + /* Validate the acoustic echo cancellation parameter.*/ + if ( f_pVqeConfig->fAcousticEcho != TRUE && f_pVqeConfig->fAcousticEcho != FALSE ) + return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO; + + if ( f_pVqeConfig->fAcousticEcho == TRUE && pImageInfo->fAcousticEcho == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO; + + if ( f_pVqeConfig->fAcousticEcho == TRUE ) + { + /* Check if acoustic echo tail length configuration is supported in the image. */ + if ( ( f_pVqeConfig->ulAecTailLength != 128 ) && ( pImageInfo->fAecTailLength == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH; + + /* Check the requested acoustic echo tail length. */ + if ( ( f_pVqeConfig->ulAecTailLength != 128 ) + && ( f_pVqeConfig->ulAecTailLength != 256 ) + && ( f_pVqeConfig->ulAecTailLength != 512 ) + && ( f_pVqeConfig->ulAecTailLength != 1024 ) ) + return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH; + + if ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) + { + UINT32 ulTailSum; + + /* Start with requested tail displacement. */ + if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTailSum = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement; + } + else + { + ulTailSum = f_pVqeConfig->ulTailDisplacement; + } + + /* Add requested tail length. */ + if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTailSum += f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength; + } + else + { + ulTailSum += f_pVqeConfig->ulTailLength; + } + + /* The tail sum must be smaller then the requested AEC tail length. */ + if ( ulTailSum > f_pVqeConfig->ulAecTailLength ) + return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_SUM; + } + } + + /* Validate the Default ERL parameter.*/ + if ( f_pVqeConfig->lDefaultErlDb != -6 && pImageInfo->fDefaultErl == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DEFAULT_ERL; + + if ( ( f_pVqeConfig->lDefaultErlDb != 0 ) && + ( f_pVqeConfig->lDefaultErlDb != -3 ) && + ( f_pVqeConfig->lDefaultErlDb != -6 ) && + ( f_pVqeConfig->lDefaultErlDb != -9 ) && + ( f_pVqeConfig->lDefaultErlDb != -12 ) ) + return cOCT6100_ERR_CHANNEL_DEFAULT_ERL; + + /* Validate the Default AEC ERL parameter.*/ + if ( f_pVqeConfig->lAecDefaultErlDb != 0 && pImageInfo->fAecDefaultErl == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_AEC_DEFAULT_ERL; + + if ( f_pVqeConfig->lAecDefaultErlDb != 0 && f_pVqeConfig->lAecDefaultErlDb != -3 && f_pVqeConfig->lAecDefaultErlDb != -6 ) + return cOCT6100_ERR_CHANNEL_AEC_DEFAULT_ERL; + + /* Validate the non-linearity A parameter.*/ + if ( f_pVqeConfig->ulNonLinearityBehaviorA != 1 && pImageInfo->fNonLinearityBehaviorA == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DOUBLE_TALK; + + if ( f_pVqeConfig->ulNonLinearityBehaviorA >= 14 ) + return cOCT6100_ERR_CHANNEL_DOUBLE_TALK; + + /* Validate the non-linearity B parameter.*/ + if ( f_pVqeConfig->ulNonLinearityBehaviorB != 0 && pImageInfo->fNonLinearityBehaviorB == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NON_LINEARITY_B; + + if ( f_pVqeConfig->ulNonLinearityBehaviorB >= 9 ) + return cOCT6100_ERR_CHANNEL_NON_LINEARITY_B; + + /* Check if configuring the double talk behavior is supported in the firmware. */ + if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && pImageInfo->fDoubleTalkBehavior == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_DOUBLE_TALK_BEHAVIOR_MODE; + + /* Validate the double talk behavior mode parameter. */ + if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_LESS_AGGRESSIVE ) + return cOCT6100_ERR_CHANNEL_DOUBLE_TALK_MODE; + + /* Validate the Sout automatic listener enhancement ratio. */ + if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 && pImageInfo->fListenerEnhancement == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALE; + + if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb > 30 ) + return cOCT6100_ERR_CHANNEL_ALE_RATIO; + + /* Validate the Sout natural listener enhancement ratio. */ + if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != TRUE && f_pVqeConfig->fSoutNaturalListenerEnhancement != FALSE ) + return cOCT6100_ERR_CHANNEL_NLE_FLAG; + + if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE && pImageInfo->fListenerEnhancement == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLE; + + if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) + { + if ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb > 30 ) + return cOCT6100_ERR_CHANNEL_NLE_RATIO; + } + + /* Both ALE and NLE cannot be activated simultaneously. */ + if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 ) + && ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) ) + return cOCT6100_ERR_CHANNEL_ALE_NLE_SIMULTANEOUSLY; + + /* Validate Rout noise reduction. */ + if ( f_pVqeConfig->fRoutNoiseReduction != TRUE && f_pVqeConfig->fRoutNoiseReduction != FALSE ) + return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION; + + /* Check if Rout noise reduction is supported. */ + if ( f_pVqeConfig->fRoutNoiseReduction == TRUE && pImageInfo->fRoutNoiseReduction == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NR; + + /* Check if ANR SNRE is supported. */ + if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 ) && ( pImageInfo->fAnrSnrEnhancement == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SNR_ENHANCEMENT; + + /* Validate Sout ANR SNR enhancement. */ + if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -9 ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != -12 ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != -15 ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != -21 ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != -24 ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != -27 ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != -30 ) ) + return cOCT6100_ERR_CHANNEL_ANR_SNR_ENHANCEMENT; + + /* Validate ANR voice-noise segregation. */ + if ( f_pVqeConfig->ulAnrVoiceNoiseSegregation > 15 ) + return cOCT6100_ERR_CHANNEL_ANR_SEGREGATION; + + /* Check if ANR VN segregation is supported. */ + if ( ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != 6 ) && ( pImageInfo->fAnrVoiceNoiseSegregation == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SEGREGATION; + + /* Check if the loaded image supports tone disabler VQE activation delay. */ + if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != 300 ) + && ( pImageInfo->fToneDisablerVqeActivationDelay == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY; + + /* Check if the specified tone disabler VQE activation delay is correct. */ + if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay < 300 ) + || ( ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) % 512 ) != 0 ) ) + return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY; + + /* Check if the tone disabler is activated when the user requests a different activation delay. */ + if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != 300 ) + && ( f_fEnableToneDisabler == FALSE ) ) + return cOCT6100_ERR_CHANNEL_MUST_ENABLE_TONE_DISABLER; + + /* Check the enable music protection flag. */ + if ( ( f_pVqeConfig->fEnableMusicProtection != TRUE ) && ( f_pVqeConfig->fEnableMusicProtection != FALSE ) ) + return cOCT6100_ERR_CHANNEL_ENABLE_MUSIC_PROTECTION; + + /* The music protection module can only be activated if the image supports it. */ + if ( ( f_pVqeConfig->fEnableMusicProtection == TRUE ) && + ( pImageInfo->fMusicProtection == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_MUSIC_PROTECTION; + + /* Check the enable idle code detection flag. */ + if ( ( f_pVqeConfig->fIdleCodeDetection != TRUE ) && ( f_pVqeConfig->fIdleCodeDetection != FALSE ) ) + return cOCT6100_ERR_CHANNEL_IDLE_CODE_DETECTION; + + /* The idle code detection module can only be activated if the image supports it. */ + if ( ( f_pVqeConfig->fIdleCodeDetection == TRUE ) && ( pImageInfo->fIdleCodeDetection == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION; + + /* The idle code detection module can be disabled only if idle code detection configuration */ + /* is supported in the image. */ + if ( ( f_pVqeConfig->fIdleCodeDetection == FALSE ) && ( pImageInfo->fIdleCodeDetectionConfiguration == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckCodecConfig + +Description: This function will check the validity of the Codec config parameter + of an Open Codec config structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pCodecConfig Codec config of the channel. +f_ulDecoderNumTssts Number of TSST for the decoder. +f_pusPhasingTsstIndex Pointer to the Phasing TSST index within the API's phasing TSST list. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckCodecConfig( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_CODEC f_pCodecConfig, + IN UINT32 f_ulDecoderNumTssts, + OUT PUINT16 f_pusPhasingTsstIndex ) +{ + + /* Verify the ADPCM nibble value.*/ + if ( f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_LOW_BITS && + f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_HIGH_BITS ) + return cOCT6100_ERR_CHANNEL_ADPCM_NIBBLE; + + /* Verify the Encoder port.*/ + if ( f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_ROUT && + f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT && + f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING ) + return cOCT6100_ERR_CHANNEL_ENCODER_PORT; + + /* Verify the Decoder port.*/ + if ( f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_RIN && + f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_SIN && + f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING ) + return cOCT6100_ERR_CHANNEL_DECODER_PORT; + + /* The codec cannot be on the same stream.*/ + if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT && + f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION; + + if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT && + f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) + return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION; + + /* Verify if the requested functions are supported by the chip.*/ + if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE && + f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING ) + { + if ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ENCODING; + } + + if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE && + f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING ) + { + if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DECODING; + } + + /* Check if encoder port has been specified when a rate has been set. */ + if ( f_pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING && + f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS ) + return cOCT6100_ERR_CHANNEL_ENCODER_PORT; + + /* Check if decoder port has been specified when a rate has been set. */ + if ( f_pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING && + f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS ) + return cOCT6100_ERR_CHANNEL_DECODER_PORT; + + /* Check Encoder related parameter if one is used.*/ + if ( f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING ) + { + /* Check the Encoder compression rate.*/ + if ( ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_40KBPS ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_32KBPS ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_24KBPS ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_16KBPS ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_4_1 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_3_2 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_2_3 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_4_0 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_3_1 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_2_2 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_24KBPS_3_0 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_24KBPS_2_1 ) && + ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_16KBPS_2_0 ) ) + return cOCT6100_ERR_CHANNEL_ENCODING_RATE; + + /* Verify phasing information.*/ + if ( f_pCodecConfig->ulPhasingType != cOCT6100_SINGLE_PHASING && + f_pCodecConfig->ulPhasingType != cOCT6100_DUAL_PHASING && + f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING ) + return cOCT6100_ERR_CHANNEL_PHASING_TYPE; + + /* Verify the silence suppression parameters.*/ + if ( f_pCodecConfig->fEnableSilenceSuppression != TRUE && + f_pCodecConfig->fEnableSilenceSuppression != FALSE ) + return cOCT6100_ERR_CHANNEL_SIL_SUP_ENABLE; + + if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE && + f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIL_SUP; + + if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE && + f_pCodecConfig->ulPhasingType == cOCT6100_NO_PHASING ) + return cOCT6100_ERR_CHANNEL_PHASE_TYPE_REQUIRED; + + if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE && + f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE ) + return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED; + + if ( f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE && + f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING ) + return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED; + + /* Silence suppression can only be performed if the encoder is using the SOUT port.*/ + if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE && + f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT ) + return cOCT6100_ERR_CHANNEL_SIL_SUP_INVALID_ENCODER_PORT; + + /* Check phasing TSST info if phasing is required.*/ + if ( f_pCodecConfig->ulPhasingTsstHndl != cOCT6100_INVALID_HANDLE ) + { + tPOCT6100_API_PHASING_TSST pPhasingEntry; + UINT32 ulEntryOpenCnt; + + /* Check the provided handle. */ + if ( (f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_PHASING_TSST ) + return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE; + + *f_pusPhasingTsstIndex = (UINT16)( f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusPhasingTsstIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPhasingTssts ) + return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE; + + mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, *f_pusPhasingTsstIndex ); + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = (f_pCodecConfig->ulPhasingTsstHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Verify if the state of the phasing TSST.*/ + if ( pPhasingEntry->fReserved != TRUE ) + return cOCT6100_ERR_CHANNEL_PHASING_TSST_NOT_OPEN; + if ( ulEntryOpenCnt != pPhasingEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE; + + /* Check the specified phase value against the phasing length of the phasing TSST.*/ + if ( f_pCodecConfig->ulPhase >= pPhasingEntry->usPhasingLength ) + return cOCT6100_ERR_CHANNEL_PHASING_INVALID_PHASE; + } + else + { + *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX; + } + } + else + { + *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX; + } + + + /* Check Decoder related parameter if one is used.*/ + if ( f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING ) + { + /* Check the Decoding rate.*/ + if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS && + f_pCodecConfig->ulDecodingRate != cOCT6100_G726_40KBPS && + f_pCodecConfig->ulDecodingRate != cOCT6100_G726_32KBPS && + f_pCodecConfig->ulDecodingRate != cOCT6100_G726_24KBPS && + f_pCodecConfig->ulDecodingRate != cOCT6100_G726_16KBPS && + f_pCodecConfig->ulDecodingRate != cOCT6100_G726_ENCODED && + f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G726_ENCODED && + f_pCodecConfig->ulDecodingRate != cOCT6100_G727_2C_ENCODED && + f_pCodecConfig->ulDecodingRate != cOCT6100_G727_3C_ENCODED && + f_pCodecConfig->ulDecodingRate != cOCT6100_G727_4C_ENCODED && + f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_2C_ENCODED && + f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_3C_ENCODED && + f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_4C_ENCODED ) + return cOCT6100_ERR_CHANNEL_DECODING_RATE; + + /* Make sure that two timeslot are allocated if PCM-ECHO encoded is selected.*/ + if ( (f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G726_ENCODED || + f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_2C_ENCODED || + f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_3C_ENCODED || + f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_4C_ENCODED ) && + f_ulDecoderNumTssts != 2 ) + return cOCT6100_ERR_CHANNEL_MISSING_TSST; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteInputTsstControlMemory + +Description: This function configure a TSST control memory entry in internal memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_usTsstIndex TSST index within the TSST control memory. +f_usTsiMemIndex TSI index within the TSI chariot memory. +f_ulTsstInputLaw PCM law of the input TSST. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteInputTsstControlMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsstIndex, + IN UINT16 f_usTsiMemIndex, + IN UINT32 f_ulTsstInputLaw ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_INPUT_TSST; + WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK; + + /* Set the PCM law.*/ + WriteParams.usWriteData |= f_ulTsstInputLaw << cOCT6100_TSST_CONTROL_MEM_PCM_LAW_OFFSET; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteOutputTsstControlMemory + +Description: This function configure a TSST control memory entry in internal memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteOutputTsstControlMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsstIndex, + IN UINT32 f_ulAdpcmNibblePosition, + IN UINT32 f_ulNumTssts, + IN UINT16 f_usTsiMemIndex ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST; + WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET; + WriteParams.usWriteData |= (f_ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET; + WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteEncoderMemory + +Description: This function configure a Encoded memory entry in internal memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_ulEncoderIndex Index of the encoder block within the ADPCM context memory. +f_ulCompType Compression rate of the encoder. +f_usTsiMemIndex TSI index within the TSI chariot memory used by the encoder. +f_ulEnableSilenceSuppression Silence suppression enable flag. +f_ulAdpcmNibblePosition ADPCM nibble position. +f_usPhasingTsstIndex Phasing TSST index within the API's Phassing TSST list. +f_ulPhasingType Type of the Phasing TSST. +f_ulPhase Phase used with this encoder. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteEncoderMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulEncoderIndex, + IN UINT32 f_ulCompType, + IN UINT16 f_usTsiMemIndex, + IN UINT32 f_ulEnableSilenceSuppression, + IN UINT32 f_ulAdpcmNibblePosition, + IN UINT16 f_usPhasingTsstIndex, + IN UINT32 f_ulPhasingType, + IN UINT32 f_ulPhase ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /*==============================================================================*/ + /* Conversion Control Base */ + WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_ulEncoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ENCODER; + WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET; + WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + /* Conversion Control Base + 2 */ + WriteParams.ulWriteAddress += 2; + + /* Set the phasing TSST number.*/ + if ( f_usPhasingTsstIndex != cOCT6100_INVALID_INDEX ) + WriteParams.usWriteData = (UINT16)( f_usPhasingTsstIndex << cOCT6100_CONVERSION_CONTROL_MEM_PHASE_OFFSET ); + else + WriteParams.usWriteData = 0; + + /* Set the phasing type and the phase value if required.*/ + switch( f_ulPhasingType ) + { + case cOCT6100_NO_PHASING: + WriteParams.usWriteData |= 0x1 << 10; + break; + case cOCT6100_SINGLE_PHASING: + WriteParams.usWriteData |= f_ulPhase; + break; + case cOCT6100_DUAL_PHASING: + WriteParams.usWriteData |= 0x1 << 11; + WriteParams.usWriteData |= f_ulPhase; + break; + default: + /* No problem. */ + break; + } + + /* Set the silence suppression flag.*/ + WriteParams.usWriteData |= f_ulEnableSilenceSuppression << cOCT6100_CONVERSION_CONTROL_MEM_SIL_SUP_OFFSET; + + /* Set the nibble position.*/ + WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + /* Conversion Control Base + 4 */ + WriteParams.ulWriteAddress += 2; + + /* Set the reset mode */ + WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + /* Conversion Control Base + 6 */ + WriteParams.ulWriteAddress += 2; + + /* Set the reset mode */ + WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteDecoderMemory + +Description: This function configure a Decoder memory entry in internal memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_usDecoderIndex Index of the decoder block within the ADPCM context memory. +f_ulCompType Decompression rate of the decoder. +f_usTsiMemIndex TSI index within the TSI chariot memory. +f_ulPcmLaw PCM law of the decoded samples. +f_ulAdpcmNibblePosition ADPCM nibble position. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteDecoderMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usDecoderIndex, + IN UINT32 f_ulCompType, + IN UINT16 f_usTsiMemIndex, + IN UINT32 f_ulPcmLaw, + IN UINT32 f_ulAdpcmNibblePosition ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + + /*==============================================================================*/ + /* Conversion Control Base */ + WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usDecoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_DECODER; + WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET; + WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + /* Conversion Control Base + 2 */ + WriteParams.ulWriteAddress += 2; + + /* Set the nibble position.*/ + WriteParams.usWriteData = (UINT16)( f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET ); + + /* Set the law.*/ + WriteParams.usWriteData |= f_ulPcmLaw << cOCT6100_CONVERSION_CONTROL_MEM_LAW_OFFSET; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + /* Conversion Control Base + 4 */ + WriteParams.ulWriteAddress += 2; + + /* Set the reset mode */ + WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + /* Conversion Control Base + 6 */ + WriteParams.ulWriteAddress += 2; + + /* Set the reset mode */ + WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiClearConversionMemory + +Description: This function clears a conversion memory entry in internal + memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_usConversionMemIndex Index of the block within the conversion memory. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiClearConversionMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usConversionMemIndex ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + UINT32 ulBaseAddress; + UINT16 usReadData; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + WriteParams.usWriteData = 0; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /*==============================================================================*/ + /* Clear the entry */ + ulBaseAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usConversionMemIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE ); + /* The "activate" bit at offset +6 must be cleared first. */ + WriteParams.ulWriteAddress = ulBaseAddress + 6; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Read at 0x200 to make sure there is no corruption on channel 0. */ + ReadParams.ulReadAddress = 0x200; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Then clear the rest of the structure. */ + WriteParams.ulWriteAddress = ulBaseAddress + 4; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = ulBaseAddress + 2; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = ulBaseAddress; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteVqeMemory + +Description: This function configure an echo memory entry in internal memory and + external memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pVqeConfig Pointer to a VQE config structure. +f_pChannelOpen Pointer to a channel configuration structure. +f_usChanIndex Index of the echo channel in the API instance. +f_usEchoMemIndex Index of the echo channel within the SSPX memory. +f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared. +f_fModifyOnly Flag indicating if the configuration should be + modified only. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteVqeMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearPlayoutPointers, + IN BOOL f_fModifyOnly ) +{ + UINT32 ulResult; + + /* Write the NLP software configuration structure. */ + ulResult = Oct6100ApiWriteVqeNlpMemory( + f_pApiInstance, + f_pVqeConfig, + f_pChannelOpen, + f_usChanIndex, + f_usEchoMemIndex, + f_fClearPlayoutPointers, + f_fModifyOnly ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write the AF software configuration structure. */ + ulResult = Oct6100ApiWriteVqeAfMemory( + f_pApiInstance, + f_pVqeConfig, + f_pChannelOpen, + f_usChanIndex, + f_usEchoMemIndex, + f_fClearPlayoutPointers, + f_fModifyOnly ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteVqeNlpMemory + +Description: This function configures the NLP related VQE features of an + echo channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pVqeConfig Pointer to a VQE config structure. +f_pChannelOpen Pointer to a channel configuration structure. +f_usChanIndex Index of the echo channel in the API instance. +f_usEchoMemIndex Index of the echo channel within the SSPX memory. +f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared. +f_fModifyOnly Flag indicating if the configuration should be + modified only. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteVqeNlpMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearPlayoutPointers, + IN BOOL f_fModifyOnly ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop; + UINT32 ulResult; + UINT32 ulTempData; + UINT32 ulNlpConfigBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulMask; + UINT16 usTempData; + BOOL fEchoOperationModeChanged; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Obtain a pointer to the new buffer's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ); + + /*==============================================================================*/ + /* Configure the CPU NLP configuration of the channel feature by feature.*/ + + ulNlpConfigBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; + + /* Set initial value to zero.*/ + ulTempData = 0; + + /* Configure Adaptive Noise Reduction.*/ + if ( pSharedInfo->ImageInfo.fAdaptiveNoiseReduction == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction ) + || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching ) + ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set adaptive noise reduction on the SOUT port.*/ + ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutAdaptiveNoiseReduction ) << ulFeatureBitOffset ); + + /* If SOUT noise bleaching is requested, ANR must be activated. */ + ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutNoiseBleaching ) << ulFeatureBitOffset ); + + /* First read the DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Configure Rout Noise Reduction. */ + if ( pSharedInfo->ImageInfo.fRoutNoiseReduction == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAnrOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set noise reduction on the Rout port. */ + ulTempData |= ( ( (UINT32)f_pVqeConfig->fRoutNoiseReduction ) << ulFeatureBitOffset ); + + /* Write the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Configure Sout ANR SNR enhancement. */ + if ( pSharedInfo->ImageInfo.fAnrSnrEnhancement == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->lAnrSnrEnhancementDb != pChanEntry->VqeConfig.chAnrSnrEnhancementDb ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set ANR SNR enhancement on the Sout port. */ + switch( f_pVqeConfig->lAnrSnrEnhancementDb ) + { + case -9: ulTempData |= ( 7 << ulFeatureBitOffset ); + break; + case -12: ulTempData |= ( 6 << ulFeatureBitOffset ); + break; + case -15: ulTempData |= ( 5 << ulFeatureBitOffset ); + break; + case -21: ulTempData |= ( 3 << ulFeatureBitOffset ); + break; + case -24: ulTempData |= ( 2 << ulFeatureBitOffset ); + break; + case -27: ulTempData |= ( 1 << ulFeatureBitOffset ); + break; + case -30: ulTempData |= ( 0 << ulFeatureBitOffset ); + break; + default: ulTempData |= ( 4 << ulFeatureBitOffset ); + /* -18 */ + break; + } + + /* Write the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Configure Sout ANR voice-noise segregation. */ + if ( pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set ANR voice-noise segregation on the Sout port. */ + ulTempData |= ( ( (UINT32)f_pVqeConfig->ulAnrVoiceNoiseSegregation ) << ulFeatureBitOffset ); + + /* Write the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Configure the tone disabler VQE activation delay. */ + if ( pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set the tone disabler VQE activation delay. */ + ulTempData |= ( ( (UINT32)( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) / 512 ) ) << ulFeatureBitOffset ); + + /* Write the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Configure Conferencing Noise Reduction.*/ + if ( pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->fSoutConferencingNoiseReduction != pChanEntry->VqeConfig.fSoutConferencingNoiseReduction ) + || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching ) ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set conferencing noise reduction on the SOUT port. */ + ulTempData |= (f_pVqeConfig->fSoutConferencingNoiseReduction << ulFeatureBitOffset ); + + /* If SOUT noise bleaching is requested, CNR must be activated. */ + ulTempData |= (f_pVqeConfig->fSoutNoiseBleaching << ulFeatureBitOffset ); + + /* Save the DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the DC removal on RIN ports.*/ + if ( pSharedInfo->ImageInfo.fRinDcOffsetRemoval == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fRinDcOffsetRemoval != pChanEntry->VqeConfig.fRinDcOffsetRemoval ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set adaptive noise reduction on the SOUT port.*/ + ulTempData |= ( ( (UINT32)f_pVqeConfig->fRinDcOffsetRemoval ) << ulFeatureBitOffset ); + + /* The write the new DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the DC removal on SIN ports.*/ + if ( pSharedInfo->ImageInfo.fSinDcOffsetRemoval == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fSinDcOffsetRemoval != pChanEntry->VqeConfig.fSinDcOffsetRemoval ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set adaptive noise reduction on the SOUT port.*/ + ulTempData |= ( ( (UINT32)f_pVqeConfig->fSinDcOffsetRemoval ) << ulFeatureBitOffset ); + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the level control. */ + if ( ( pChanEntry->byEchoOperationMode != f_pChannelOpen->ulEchoOperationMode ) + && ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NORMAL ) ) + fEchoOperationModeChanged = TRUE; + else + fEchoOperationModeChanged = FALSE; + + /* If opening the channel, all level control configuration must be written. */ + if ( f_fModifyOnly == FALSE ) + fEchoOperationModeChanged = TRUE; + ulResult = Oct6100ApiSetChannelLevelControl( f_pApiInstance, + f_pVqeConfig, + f_usChanIndex, + f_usEchoMemIndex, + fEchoOperationModeChanged ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the background noise freeze.*/ + if ( pSharedInfo->ImageInfo.fComfortNoise == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->ulComfortNoiseMode != pChanEntry->VqeConfig.byComfortNoiseMode ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + ulTempData |= ( f_pVqeConfig->ulComfortNoiseMode << ulFeatureBitOffset ); + + /* Save the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the state of the NLP */ + if ( pSharedInfo->ImageInfo.fNlpControl == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fEnableNlp != pChanEntry->VqeConfig.fEnableNlp ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpControlFieldOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->fEnableNlp == FALSE ) + ulTempData |= 0x1 << ulFeatureBitOffset; + + /* Save the new DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the tail configuration. */ + ulResult = Oct6100ApiSetChannelTailConfiguration( + f_pApiInstance, + f_pVqeConfig, + f_usChanIndex, + f_usEchoMemIndex, + f_fModifyOnly ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the Default ERL. */ + if ( ( pSharedInfo->ImageInfo.fDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == FALSE ) ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb ) + || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) + || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Convert the DB value to octasic's float format. (In energy) */ + if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO ) + && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) ) + { + usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb ); + } + else + { + /* Clear the defautl ERL when using the no echo cancellation operation mode. */ + usTempData = 0x0; + } + + if ( ulFeatureFieldLength < 16 ) + usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) ); + + ulTempData |= ( usTempData << ulFeatureBitOffset ); + + /* Save the new DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the Acoustic echo control.*/ + if ( pSharedInfo->ImageInfo.fAcousticEcho == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AecFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AecFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field. */ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + ulTempData |= ( ( (UINT32)f_pVqeConfig->fAcousticEcho ) << ulFeatureBitOffset ); + + /* Then save the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the Acoustic Echo Default ERL. */ + if ( ( pSharedInfo->ImageInfo.fAecDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == TRUE ) ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->lAecDefaultErlDb != pChanEntry->VqeConfig.chAecDefaultErlDb ) + || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field. */ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO ) + && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) ) + { + /* Convert the DB value to octasic's float format. (In energy) */ + usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lAecDefaultErlDb ); + } + else + { + /* Clear the AEC defautl ERL when using the no echo cancellation operation mode. */ + usTempData = 0x0; + } + + if ( ulFeatureFieldLength < 16 ) + usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) ); + + ulTempData |= ( usTempData << ulFeatureBitOffset ); + + /* Then save the DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the DTMF tone removal bit.*/ + if ( pSharedInfo->ImageInfo.fToneRemoval == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fDtmfToneRemoval != pChanEntry->VqeConfig.fDtmfToneRemoval ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + ulTempData |= ( ( (UINT32)f_pVqeConfig->fDtmfToneRemoval ) << ulFeatureBitOffset ); + + /* First read the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + + + /* Set the non-linear behavior A.*/ + if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorA == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->ulNonLinearityBehaviorA != pChanEntry->VqeConfig.byNonLinearityBehaviorA ) + || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) ) + { + UINT16 ausLookupTable[ 14 ] = { 0x3663, 0x3906, 0x399C, 0x3A47, 0x3B06, 0x3B99, 0x3C47, 0x3D02, 0x3D99, 0x3E47, 0x3F00, 0x3F99, 0x4042, 0x4100 }; + + ulFeatureBytesOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO ) + || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) ) + ulTempData |= ( 0x0 << ulFeatureBitOffset ); + else + ulTempData |= ( ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] << ulFeatureBitOffset ); + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Synch all the buffer playout field.*/ + if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE && f_fClearPlayoutPointers == TRUE ) + { + Oct6100BufferPlayoutStopDef( &BufferPlayoutStop ); + + BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE; + BufferPlayoutStop.fStopCleanly = TRUE; + + BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT; + ulResult = Oct6100ApiInvalidateChanPlayoutStructs( + f_pApiInstance, + &BufferPlayoutStop, + f_usChanIndex, + f_usEchoMemIndex + + ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT; + ulResult = Oct6100ApiInvalidateChanPlayoutStructs( + f_pApiInstance, + &BufferPlayoutStop, + f_usChanIndex, + f_usEchoMemIndex + + ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*==============================================================================*/ + /* Write the 2100 Hz Echo Disabling mode */ + + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* This is a disable bit, so it must be set only if the enable flag is set to false. */ + if ( f_pChannelOpen->fEnableToneDisabler == FALSE ) + ulTempData |= 0x1 << ulFeatureBitOffset; + + /* Save the DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Write the Nlp Trivial enable flag. */ + + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( + + ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO ) + || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) ) + { + ulTempData |= TRUE << ulFeatureBitOffset; + } + + + /* Then write the DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Set the double talk behavior mode. */ + if ( pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->ulDoubleTalkBehavior != pChanEntry->VqeConfig.byDoubleTalkBehavior ) ) ) + { + /* The field is located in the CPURO structure. */ + ulFeatureBytesOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + ulTempData |= (f_pVqeConfig->ulDoubleTalkBehavior << ulFeatureBitOffset ); + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Set the music protection enable. */ + if ( ( pSharedInfo->ImageInfo.fMusicProtection == TRUE ) + && ( pSharedInfo->ImageInfo.fMusicProtectionConfiguration == TRUE ) ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fEnableMusicProtection != pChanEntry->VqeConfig.fEnableMusicProtection ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + if ( f_pVqeConfig->fEnableMusicProtection == TRUE ) + ulTempData |= ( 1 << ulFeatureBitOffset ); + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteVqeAfMemory + +Description: This function configures the AF related VQE features of an + echo channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pVqeConfig Pointer to a VQE config structure. +f_pChannelOpen Pointer to a channel configuration structure. +f_usChanIndex Index of the echo channel in the API instance. +f_usEchoMemIndex Index of the echo channel within the SSPX memory. +f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared. +f_fModifyOnly Flag indicating if the configuration should be + modified only. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteVqeAfMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearPlayoutPointers, + IN BOOL f_fModifyOnly ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + UINT32 ulTempData; + UINT32 ulAfConfigBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulMask; + UINT16 usTempData; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Obtain a pointer to the new buffer's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ); + + /*==============================================================================*/ + /* Write the AF CPU configuration of the channel feature by feature.*/ + + /* Calculate AF CPU configuration base address. */ + ulAfConfigBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst; + + /* Set initial value to zero.*/ + ulTempData = 0; + + /*==============================================================================*/ + /* Program the Maximum echo point within the Main channel memory.*/ + if ( pSharedInfo->ImageInfo.fMaxEchoPoint == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb ) + || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) ) + { + /* Write the echo tail length */ + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Convert the DB value to octasic's float format.*/ + if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO ) + { + usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb ); + } + else + { + /* Clear max echo point. No echo cancellation here. */ + usTempData = 0x0; + } + + if ( ulFeatureFieldLength < 16 ) + usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) ); + + ulTempData |= usTempData << ulFeatureBitOffset; + + /* First read the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Set the non-linear behavior B.*/ + if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorB == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->ulNonLinearityBehaviorB != pChanEntry->VqeConfig.byNonLinearityBehaviorB ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + ulTempData |= (f_pVqeConfig->ulNonLinearityBehaviorB << ulFeatureBitOffset ); + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Set the listener enhancement feature. */ + if ( pSharedInfo->ImageInfo.fListenerEnhancement == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb ) + || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement ) + || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveAleOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 ) + { + UINT32 ulGainDb; + + ulGainDb = f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb / 3; + + /* Round up. */ + if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb % 3 ) != 0x0 ) + ulGainDb ++; + + ulTempData |= ( ulGainDb << ulFeatureBitOffset ); + } + else if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != 0 ) + { + UINT32 ulGainDb; + + ulGainDb = f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb / 3; + + /* Round up. */ + if ( ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb % 3 ) != 0x0 ) + ulGainDb ++; + + ulTempData |= ( ( 0x80 | ulGainDb ) << ulFeatureBitOffset ); + } + + /* Now write the DWORD where the field is located containing the new configuration. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Set the idle code detection enable. */ + if ( ( pSharedInfo->ImageInfo.fIdleCodeDetection == TRUE ) + && ( pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration == TRUE ) ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->fIdleCodeDetection != pChanEntry->VqeConfig.fIdleCodeDetection ) ) ) + { + /* Calculate base address in the AF software configuration. */ + ulFeatureBytesOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + if ( f_pVqeConfig->fIdleCodeDetection == FALSE ) + ulTempData |= ( 1 << ulFeatureBitOffset ); + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + + /*==============================================================================*/ + /* Set the AFT control field. */ + if ( pSharedInfo->ImageInfo.fAftControl == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AftControlOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AftControlOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AftControlOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* If the operation mode is no echo, set the field such that echo cancellation is disabled. */ + if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO ) + { + ulTempData |= ( 0x1234 << ulFeatureBitOffset ); + } + else if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) + { + /* For clarity. */ + ulTempData |= ( 0x0 << ulFeatureBitOffset ); + } + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfigBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /*==============================================================================*/ + + return cOCT6100_ERR_OK; +} + + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteEchoMemory + +Description: This function configure an echo memory entry in internal memory.and + external memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pTdmConfig Pointer to a TDM config structure. +f_pChannelOpen Pointer to a channel configuration structure. +f_usEchoIndex Echo channel index within the SSPX memory. +f_usRinRoutTsiIndex RIN/ROUT TSI index within the TSI chariot memory +f_usSinSoutTsiIndex SIN/SOUT TSI index within the TSI chariot memory + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteEchoMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usEchoIndex, + IN UINT16 f_usRinRoutTsiIndex, + IN UINT16 f_usSinSoutTsiIndex ) + +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + UINT32 ulTempData; + UINT32 ulBaseAddress; + UINT32 ulRinPcmLaw; + UINT32 ulRoutPcmLaw; + UINT32 ulSinPcmLaw; + UINT32 ulSoutPcmLaw; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Set immediately the PCM law to be programmed in the SSPX and NLP memory.*/ + if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) + { + ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; + ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; + ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw; + ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw; + } + else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */ + { + ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw; + ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw; + ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; + ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; + } + + /*==============================================================================*/ + /* Configure the Global Static Configuration of the channel.*/ + + ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET; + + /* Set the PGSP context base address. */ + ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the PGSP init context base address. */ + ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the RIN circular buffer base address. */ + ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst) & 0x07FFFF00; + ulTempData |= ( ulRoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET ); + + /* Set the circular buffer size.*/ + if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 ) + return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE; + ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the SIN circular buffer base address. */ + ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst) & 0x07FFFF00; + ulTempData |= ( ulSinPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET ); + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the SOUT circular buffer base address. */ + ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst ) & 0x07FFFF00; + ulTempData |= ( ulSoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET ); + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + + /*==============================================================================*/ + /* ECHO SSPX Memory configuration.*/ + + WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( f_usEchoIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE ); + + /* ECHO memory BASE + 2 */ + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = 0x0000; + + /* Set the echo control field.*/ + if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO ) + || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) ) + { + WriteParams.usWriteData |= cOCT6100_ECHO_OP_MODE_NORMAL << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL; + } + else if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL ) + { + WriteParams.usWriteData |= f_pChannelOpen->ulEchoOperationMode << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL; + } + + /* Set the SIN/SOUT law.*/ + WriteParams.usWriteData |= ulSinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET; + WriteParams.usWriteData |= ulSoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET; + + /* Set the TSI chariot memory field.*/ + WriteParams.usWriteData |= f_usSinSoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* ECHO memory BASE */ + WriteParams.ulWriteAddress -= 2; + WriteParams.usWriteData = cOCT6100_ECHO_CONTROL_MEM_ACTIVATE_ENTRY; + + /* Set the RIN/ROUT law.*/ + WriteParams.usWriteData |= ulRinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET; + WriteParams.usWriteData |= ulRoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET; + + /* Set the RIN external echo control bit.*/ + if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_EXTERNAL ) + WriteParams.usWriteData |= cOCT6100_ECHO_CONTROL_MEM_EXTERNAL_AF_CTRL; + + /* Set the TSI chariot memory field.*/ + WriteParams.usWriteData |= f_usRinRoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiUpdateOpenStruct + +Description: This function will copy the new parameter from the modify structure + into a channel open structure to be processed later by the same path + as the channel open function. + If a parameter is set to keep previous, it's current value will be + extracted from the channel entry in the API. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +IN f_pApiInstance Pointer to an API instance structure. +IN f_pChanModify Pointer to a channel modify structure. +IN OUT f_pChanOpen Pointer to a channel open structure. +IN f_pChanEntry Pointer to an API channel structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiUpdateOpenStruct( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MODIFY f_pChanModify, + IN OUT tPOCT6100_CHANNEL_OPEN f_pChanOpen, + IN tPOCT6100_API_CHANNEL f_pChanEntry ) +{ + + /* Check the generic Echo parameters.*/ + if ( f_pChanModify->ulEchoOperationMode == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->ulEchoOperationMode = f_pChanEntry->byEchoOperationMode; + else + f_pChanOpen->ulEchoOperationMode = f_pChanModify->ulEchoOperationMode; + + + if ( f_pChanModify->fEnableToneDisabler == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->fEnableToneDisabler = f_pChanEntry->fEnableToneDisabler; + else + f_pChanOpen->fEnableToneDisabler = f_pChanModify->fEnableToneDisabler; + + + if ( f_pChanModify->ulUserChanId == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->ulUserChanId = f_pChanEntry->ulUserChanId; + else + f_pChanOpen->ulUserChanId = f_pChanModify->ulUserChanId; + + + + /*======================================================================*/ + /* Now update the TDM config.*/ + /* Rin PCM LAW */ + if ( f_pChanModify->TdmConfig.ulRinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanEntry->TdmConfig.byRinPcmLaw; + else + f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanModify->TdmConfig.ulRinPcmLaw; + + /* Sin PCM LAW */ + if ( f_pChanModify->TdmConfig.ulSinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanEntry->TdmConfig.bySinPcmLaw; + else + f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanModify->TdmConfig.ulSinPcmLaw; + + /* Rout PCM LAW */ + if ( f_pChanModify->TdmConfig.ulRoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanEntry->TdmConfig.byRoutPcmLaw; + else + f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanModify->TdmConfig.ulRoutPcmLaw; + + /* Sout PCM LAW */ + if ( f_pChanModify->TdmConfig.ulSoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanEntry->TdmConfig.bySoutPcmLaw; + else + f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanModify->TdmConfig.ulSoutPcmLaw; + + + /* Rin Timeslot */ + if ( f_pChanModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanEntry->TdmConfig.usRinTimeslot; + else + f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanModify->TdmConfig.ulRinTimeslot; + + /* Rin Stream */ + if ( f_pChanModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRinStream = f_pChanEntry->TdmConfig.usRinStream; + else + f_pChanOpen->TdmConfig.ulRinStream = f_pChanModify->TdmConfig.ulRinStream; + + /* Rin Num TSSTs */ + if ( f_pChanModify->TdmConfig.ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanEntry->TdmConfig.byRinNumTssts; + else + f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanModify->TdmConfig.ulRinNumTssts; + + + /* Sin Timeslot */ + if ( f_pChanModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanEntry->TdmConfig.usSinTimeslot; + else + f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanModify->TdmConfig.ulSinTimeslot; + + /* Sin Stream */ + if ( f_pChanModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSinStream = f_pChanEntry->TdmConfig.usSinStream; + else + f_pChanOpen->TdmConfig.ulSinStream = f_pChanModify->TdmConfig.ulSinStream; + + /* Sin Num TSSTs */ + if ( f_pChanModify->TdmConfig.ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanEntry->TdmConfig.bySinNumTssts; + else + f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanModify->TdmConfig.ulSinNumTssts; + + + /* Rout Timeslot */ + if ( f_pChanModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanEntry->TdmConfig.usRoutTimeslot; + else + f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanModify->TdmConfig.ulRoutTimeslot; + + /* Rout Stream */ + if ( f_pChanModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRoutStream = f_pChanEntry->TdmConfig.usRoutStream; + else + f_pChanOpen->TdmConfig.ulRoutStream = f_pChanModify->TdmConfig.ulRoutStream; + + /* Rout Num TSSTs */ + if ( f_pChanModify->TdmConfig.ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanEntry->TdmConfig.byRoutNumTssts; + else + f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanModify->TdmConfig.ulRoutNumTssts; + + + /* Sout Timeslot */ + if ( f_pChanModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanEntry->TdmConfig.usSoutTimeslot; + else + f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanModify->TdmConfig.ulSoutTimeslot; + + /* Sout Stream */ + if ( f_pChanModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSoutStream = f_pChanEntry->TdmConfig.usSoutStream; + else + f_pChanOpen->TdmConfig.ulSoutStream = f_pChanModify->TdmConfig.ulSoutStream; + + /* Sout Num TSSTs */ + if ( f_pChanModify->TdmConfig.ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanEntry->TdmConfig.bySoutNumTssts; + else + f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanModify->TdmConfig.ulSoutNumTssts; + + /*======================================================================*/ + + /*======================================================================*/ + /* Now update the VQE config.*/ + + if ( f_pChanModify->VqeConfig.ulComfortNoiseMode == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanEntry->VqeConfig.byComfortNoiseMode; + else + f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanModify->VqeConfig.ulComfortNoiseMode; + + if ( f_pChanModify->VqeConfig.fEnableNlp == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fEnableNlp = f_pChanEntry->VqeConfig.fEnableNlp; + else + f_pChanOpen->VqeConfig.fEnableNlp = f_pChanModify->VqeConfig.fEnableNlp; + + if ( f_pChanModify->VqeConfig.fEnableTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanEntry->VqeConfig.fEnableTailDisplacement; + else + f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanModify->VqeConfig.fEnableTailDisplacement; + + if ( f_pChanModify->VqeConfig.ulTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanEntry->VqeConfig.usTailDisplacement; + else + f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanModify->VqeConfig.ulTailDisplacement; + + /* Tail length cannot be modifed. */ + f_pChanOpen->VqeConfig.ulTailLength = f_pChanEntry->VqeConfig.usTailLength; + + + + if ( f_pChanModify->VqeConfig.fRinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanEntry->VqeConfig.fRinDcOffsetRemoval; + else + f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanModify->VqeConfig.fRinDcOffsetRemoval; + + + if ( f_pChanModify->VqeConfig.fRinLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanEntry->VqeConfig.fRinLevelControl; + else + f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanModify->VqeConfig.fRinLevelControl; + + + if ( f_pChanModify->VqeConfig.fRinAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanEntry->VqeConfig.fRinAutomaticLevelControl; + else + f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanModify->VqeConfig.fRinAutomaticLevelControl; + + + if ( f_pChanModify->VqeConfig.fRinHighLevelCompensation == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanEntry->VqeConfig.fRinHighLevelCompensation; + else + f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanModify->VqeConfig.fRinHighLevelCompensation; + + + if ( f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb; + else + f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb; + + + if ( f_pChanModify->VqeConfig.fSinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanEntry->VqeConfig.fSinDcOffsetRemoval; + else + f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanModify->VqeConfig.fSinDcOffsetRemoval; + + + if ( f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction; + else + f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction; + + + if ( f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanEntry->VqeConfig.fSoutConferencingNoiseReduction; + else + f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction; + + + if ( f_pChanModify->VqeConfig.fSoutNoiseBleaching == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanEntry->VqeConfig.fSoutNoiseBleaching; + else + f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanModify->VqeConfig.fSoutNoiseBleaching; + + + if ( f_pChanModify->VqeConfig.fSoutLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanEntry->VqeConfig.fSoutLevelControl; + else + f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanModify->VqeConfig.fSoutLevelControl; + + + if ( f_pChanModify->VqeConfig.fSoutAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanEntry->VqeConfig.fSoutAutomaticLevelControl; + else + f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanModify->VqeConfig.fSoutAutomaticLevelControl; + + + if ( f_pChanModify->VqeConfig.lRinLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) ) + f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanEntry->VqeConfig.chRinLevelControlGainDb; + else + f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanModify->VqeConfig.lRinLevelControlGainDb; + + + if ( f_pChanModify->VqeConfig.lSoutLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) ) + f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanEntry->VqeConfig.chSoutLevelControlGainDb; + else + f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanModify->VqeConfig.lSoutLevelControlGainDb; + + + if ( f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) ) + f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb; + else + f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb; + + + if ( f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) ) + f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb; + else + f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb; + + + if ( f_pChanModify->VqeConfig.lDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) ) + f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanEntry->VqeConfig.chDefaultErlDb; + else + f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanModify->VqeConfig.lDefaultErlDb; + + + if ( f_pChanModify->VqeConfig.lAecDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) ) + f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanEntry->VqeConfig.chAecDefaultErlDb; + else + f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanModify->VqeConfig.lAecDefaultErlDb; + + + if ( f_pChanModify->VqeConfig.ulAecTailLength == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanEntry->VqeConfig.usAecTailLength; + else + f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanModify->VqeConfig.ulAecTailLength; + + + if ( f_pChanModify->VqeConfig.fAcousticEcho == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanEntry->VqeConfig.fAcousticEcho; + else + f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanModify->VqeConfig.fAcousticEcho; + + + if ( f_pChanModify->VqeConfig.fDtmfToneRemoval == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanEntry->VqeConfig.fDtmfToneRemoval; + else + f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanModify->VqeConfig.fDtmfToneRemoval; + + + + + + if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorA == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanEntry->VqeConfig.byNonLinearityBehaviorA; + else + f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanModify->VqeConfig.ulNonLinearityBehaviorA; + + + if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorB == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanEntry->VqeConfig.byNonLinearityBehaviorB; + else + f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanModify->VqeConfig.ulNonLinearityBehaviorB; + + + if ( f_pChanModify->VqeConfig.ulDoubleTalkBehavior == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanEntry->VqeConfig.byDoubleTalkBehavior; + else + f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanModify->VqeConfig.ulDoubleTalkBehavior; + + + if ( f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb; + else + f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb; + + + if ( f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb; + else + f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb; + + + if ( f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement; + else + f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement; + + + if ( f_pChanModify->VqeConfig.fRoutNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanEntry->VqeConfig.fRoutNoiseReduction; + else + f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanModify->VqeConfig.fRoutNoiseReduction; + + + if ( f_pChanModify->VqeConfig.lAnrSnrEnhancementDb == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanEntry->VqeConfig.chAnrSnrEnhancementDb; + else + f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanModify->VqeConfig.lAnrSnrEnhancementDb; + + + if ( f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation; + else + f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation; + + + if ( f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay; + else + f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay; + + + if ( f_pChanModify->VqeConfig.fEnableMusicProtection == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanEntry->VqeConfig.fEnableMusicProtection; + else + f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanModify->VqeConfig.fEnableMusicProtection; + + + if ( f_pChanModify->VqeConfig.fIdleCodeDetection == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanEntry->VqeConfig.fIdleCodeDetection; + else + f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanModify->VqeConfig.fIdleCodeDetection; + + /*======================================================================*/ + + + /*======================================================================*/ + /* Finaly the codec config.*/ + + if ( f_pChanModify->CodecConfig.ulDecoderPort == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanEntry->CodecConfig.byDecoderPort; + else + f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanModify->CodecConfig.ulDecoderPort; + + + if ( f_pChanModify->CodecConfig.ulDecodingRate == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanEntry->CodecConfig.byDecodingRate; + else + f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanModify->CodecConfig.ulDecodingRate; + + + if ( f_pChanModify->CodecConfig.ulEncoderPort == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanEntry->CodecConfig.byEncoderPort; + else + f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanModify->CodecConfig.ulEncoderPort; + + + if ( f_pChanModify->CodecConfig.ulEncodingRate == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanEntry->CodecConfig.byEncodingRate; + else + f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanModify->CodecConfig.ulEncodingRate; + + if ( f_pChanModify->CodecConfig.fEnableSilenceSuppression == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanEntry->CodecConfig.fEnableSilenceSuppression; + else + f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanModify->CodecConfig.fEnableSilenceSuppression; + + if ( f_pChanModify->CodecConfig.ulPhasingType == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->CodecConfig.ulPhasingType = f_pChanEntry->CodecConfig.byPhasingType; + else + f_pChanOpen->CodecConfig.ulPhasingType = f_pChanModify->CodecConfig.ulPhasingType; + + if ( f_pChanModify->CodecConfig.ulPhase == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->CodecConfig.ulPhase = f_pChanEntry->CodecConfig.byPhase; + else + f_pChanOpen->CodecConfig.ulPhase = f_pChanModify->CodecConfig.ulPhase; + + if ( f_pChanModify->CodecConfig.ulPhasingTsstHndl == cOCT6100_KEEP_PREVIOUS_SETTING ) + { + if ( f_pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX ) + { + tPOCT6100_API_PHASING_TSST pPhasingEntry; + + mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanEntry->usPhasingTsstIndex ); + + /* Now recreate the Phasing TSST handle.*/ + f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanEntry->usPhasingTsstIndex; + } + else + { + f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE; + } + } + else + { + f_pChanOpen->CodecConfig.ulPhasingTsstHndl = f_pChanModify->CodecConfig.ulPhasingTsstHndl; + } + + f_pChanOpen->CodecConfig.ulAdpcmNibblePosition = f_pChanEntry->CodecConfig.byAdpcmNibblePosition; + /*======================================================================*/ + + return cOCT6100_ERR_OK; +} + +static UINT16 Oct6100ApiDbAmpHalfToOctFloat(INT32 x) +{ + INT32 db_div6; + INT32 db_mod6; + UINT16 rval; + INT32 x_unsigned; + + if(x < 0) + { + x_unsigned = -x; + } + else + { + x_unsigned = x; + } + + db_div6 = x_unsigned / 6; + db_mod6 = x_unsigned % 6; + + if(x < 0) + { + if(db_mod6 == 0) + { + /* Change nothing! */ + db_div6 = -db_div6; + } + else + { + /* When we are negative, round down, and then adjust modulo. For example, if + x is -1, then db_div6 is 0 and db_mod6 is 1. We adjust so db_div6 = -1 and + db_mod6 = 5, which gives the correct adjustment. */ + db_div6 = -db_div6-1; + db_mod6 = 6 - db_mod6; + } + } + + rval = (UINT16)(0x4100 + db_div6 * 0x100); + + if(db_mod6 == 0) + { + rval += 0x0000; + } + else if(db_mod6 == 1) + { + rval += 0x0020; + } + else if(db_mod6 == 2) + { + rval += 0x0040; + } + else if(db_mod6 == 3) + { + rval += 0x0070; + } + else if(db_mod6 == 4) + { + rval += 0x0090; + } + else /* if(db_mod6 == 5) */ + { + rval += 0x00D0; + } + + return rval; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteDebugChanMemory + +Description: This function configure a debug channel echo memory entry + in internal memory.and external memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pTdmConfig Pointer to a TDM configuration structure. +f_pVqeConfig Pointer to a VQE configuration structure. +f_pChannelOpen Pointer to a channel configuration structure. +f_usChanIndex Index of the echo channel in the API instance. +f_usEchoMemIndex Index of the echo channel within the SSPX memory. +f_usRinRoutTsiIndex RIN/ROUT TSI index within the TSI chariot memory. +f_usSinSoutTsiIndex SIN/SOUT TSI index within the TSI chariot memory. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteDebugChanMemory( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN UINT16 f_usRinRoutTsiIndex, + IN UINT16 f_usSinSoutTsiIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulResult; + + /* Obtain pointer to local portion of the instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /*==============================================================================*/ + /* Write the VQE configuration of the debug channel. */ + + ulResult = Oct6100ApiWriteVqeMemory( + f_pApiInstance, + f_pVqeConfig, + f_pChannelOpen, + f_usChanIndex, + f_usEchoMemIndex, + TRUE, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + + /*==============================================================================*/ + + /* Write the echo memory configuration of the debug channel. */ + ulResult = Oct6100ApiWriteEchoMemory( + f_pApiInstance, + f_pTdmConfig, + f_pChannelOpen, + f_usEchoMemIndex, + f_usRinRoutTsiIndex, + f_usSinSoutTsiIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiDebugChannelOpen + +Description: Internal function used to open a debug channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiDebugChannelOpen( + IN tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_CHANNEL_OPEN TempChanOpen; + + UINT32 ulResult; + UINT16 usChanIndex; + UINT16 usDummyEchoIndex; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Let's program the channel memory.*/ + Oct6100ChannelOpenDef( &TempChanOpen ); + + TempChanOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_HT_RESET; /* Activate the channel in reset.*/ + TempChanOpen.VqeConfig.fEnableNlp = FALSE; + TempChanOpen.VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL; + TempChanOpen.VqeConfig.fSinDcOffsetRemoval = FALSE; + TempChanOpen.VqeConfig.fRinDcOffsetRemoval = FALSE; + TempChanOpen.VqeConfig.lDefaultErlDb = 0; + + /* Loop to reserve the proper entry for the debug channel */ + for( usChanIndex = 0; usChanIndex < ( pSharedInfo->DebugInfo.usRecordChanIndex + 1 ); usChanIndex ++ ) + { + ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, &usDummyEchoIndex ); + if( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Loop to free all entries except the one for the debug channel */ + for( usChanIndex = pSharedInfo->DebugInfo.usRecordChanIndex; usChanIndex > 0; ) + { + usChanIndex--; + ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, usChanIndex ); + if( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance, + &TempChanOpen.TdmConfig, + &TempChanOpen.VqeConfig, + &TempChanOpen, + pSharedInfo->DebugInfo.usRecordChanIndex, + pSharedInfo->DebugInfo.usRecordMemIndex, + pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex, + pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiMuteChannelPort + +Description: This function will verify if a input TSST is bound to the RIN and + SIN port. If not, the port will be muted. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiMutePorts( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEchoIndex, + IN UINT16 f_usRinTsstIndex, + IN UINT16 f_usSinTsstIndex, + IN BOOL f_fCheckBridgeIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pChanEntry; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Obtain a pointer to the new buffer's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usEchoIndex ); + + /* Mute the Rin port. */ + if ( ( f_fCheckBridgeIndex == FALSE ) + || ( ( f_fCheckBridgeIndex == TRUE ) && ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX ) ) ) + { + /* If the channel is in bidir mode, do not create the Rin silence event!!! */ + if ( pChanEntry->fBiDirChannel == FALSE ) + { + if ( ( ( f_usRinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) ) + && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) ) + { + ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, + &pChanEntry->usRinSilenceEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now, write the mixer event used to copy the RIN signal of the silence channel + into the RIN signal of the current channel. */ + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usRinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY; + WriteParams.usWriteData |= 1534; + WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = pChanEntry->usRinRoutTsiMemIndex; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Now insert the Sin copy event into the list.*/ + + ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance, + pChanEntry->usRinSilenceEventIndex, + cOCT6100_EVENT_TYPE_SOUT_COPY, + f_usEchoIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + + /* Mute the Sin port. */ + if ( ( ( f_usSinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) + && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) ) + { + ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, + &pChanEntry->usSinSilenceEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now, write the mixer event used to copy the SIN signal of the silence channel + into the SIN signal of the current channel. */ + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY; + WriteParams.usWriteData |= 1534; + WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = pChanEntry->usSinSoutTsiMemIndex; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Now insert the Sin copy event into the list.*/ + + ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance, + pChanEntry->usSinSilenceEventIndex, + cOCT6100_EVENT_TYPE_SOUT_COPY, + f_usEchoIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Unmute the Rin port if it was muted. */ + if ( ( ( f_usRinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) ) + && ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) ) + { + /* Remove the event from the list.*/ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, + pChanEntry->usRinSilenceEventIndex, + cOCT6100_EVENT_TYPE_SOUT_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_E1; + + pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX; + } + + /* Unmute the Sin port if it was muted. */ + if ( ( ( f_usSinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) ) + && ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) ) + { + /* Remove the event from the list.*/ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, + pChanEntry->usSinSilenceEventIndex, + cOCT6100_EVENT_TYPE_SOUT_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_E2; + + pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiSetChannelLevelControl + +Description: This function will configure the level control on a given + channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pVqeConfig VQE config of the channel. +f_usChanIndex Index of the channel within the API instance. +f_usEchoMemIndex Index of the echo channel within the SSPX memory. +f_fClearAlcHlcStatusBit If this is set, the ALC-HLC status bit must be + incremented. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiSetChannelLevelControl( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fClearAlcHlcStatusBit ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulResult; + UINT32 ulTempData; + UINT32 ulBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulMask; + UINT32 i; + UINT16 usTempData; + UINT8 byLastStatus; + BOOL fDisableAlcFirst; + + /* Get local pointer to shared portion of the API instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain a pointer to the channel list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ); + + /* Before doing anything, check if the configuration has changed. */ + if ( ( f_fClearAlcHlcStatusBit == TRUE ) + || ( f_pVqeConfig->fRinLevelControl != pChanEntry->VqeConfig.fRinLevelControl ) + || ( f_pVqeConfig->lRinLevelControlGainDb != pChanEntry->VqeConfig.chRinLevelControlGainDb ) + || ( f_pVqeConfig->fRinAutomaticLevelControl != pChanEntry->VqeConfig.fRinAutomaticLevelControl ) + || ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb ) + || ( f_pVqeConfig->fRinHighLevelCompensation != pChanEntry->VqeConfig.fRinHighLevelCompensation ) + || ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb != pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb ) + || ( f_pVqeConfig->fSoutLevelControl != pChanEntry->VqeConfig.fSoutLevelControl ) + || ( f_pVqeConfig->lSoutLevelControlGainDb != pChanEntry->VqeConfig.chSoutLevelControlGainDb ) + || ( f_pVqeConfig->fSoutAutomaticLevelControl != pChanEntry->VqeConfig.fSoutAutomaticLevelControl ) + || ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb ) + || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement ) + || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb ) + || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) ) + { + /* Calculate base address for manual level control configuration. */ + ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; + + /* Set the Level control on RIN port.*/ + ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.RinLevelControlOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( ( f_pVqeConfig->fRinLevelControl == TRUE ) + || ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) + || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) ) + { + /* Set the level control value.*/ + if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) + || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) ) + ulTempData |= ( 0xFF << ulFeatureBitOffset ); + else + { + /* Convert the dB value into OctFloat format.*/ + usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lRinLevelControlGainDb ); + usTempData -= 0x3800; + usTempData &= 0x0FF0; + usTempData >>= 4; + + ulTempData |= ( usTempData << ulFeatureBitOffset ); + } + } + else /* ( ( f_pVqeConfig->fRinLevelControl == FALSE ) && ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) && ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) ) */ + { + ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the Level control on SOUT port.*/ + ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutLevelControlOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( ( f_pVqeConfig->fSoutLevelControl == TRUE ) + || ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) + || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) + || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) ) + { + /* Set the level control value.*/ + if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) + || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) + || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) ) + ulTempData |= ( 0xFF << ulFeatureBitOffset ); + else + { + /* Convert the dB value into OctFloat format.*/ + usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lSoutLevelControlGainDb ); + usTempData -= 0x3800; + usTempData &= 0x0FF0; + usTempData >>= 4; + + ulTempData |= ( usTempData << ulFeatureBitOffset ); + } + } + else + { + ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Calculate base address for auto level control + high level compensation configuration. */ + ulBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst; + + /* Check which one is to be disabled first. */ + if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) + fDisableAlcFirst = FALSE; + else + fDisableAlcFirst = TRUE; + + for ( i = 0; i < 2; i ++ ) + { + /* Set the auto level control target Db for the Rin port. */ + if ( ( ( i == 0 ) && ( fDisableAlcFirst == TRUE ) ) || ( ( i == 1 ) && ( fDisableAlcFirst == FALSE ) ) ) + { + if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) + { + /* Convert the dB value into OctFloat format.*/ + usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinAutomaticLevelControlTargetDb ); + + /* Set auto level control target on the Rin port. */ + ulTempData |= ( usTempData << ulFeatureBitOffset ); + } + else /* if ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) */ + { + /* Disable auto level control. */ + ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else + { + /* Set the high level compensation threshold Db for the Rin port. */ + if ( pSharedInfo->ImageInfo.fRinHighLevelCompensation == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) + { + /* Convert the dB value into OctFloat format.*/ + usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinHighLevelCompensationThresholdDb ); + + /* Set high level compensation threshold on the Rin port. */ + ulTempData |= ( usTempData << ulFeatureBitOffset ); + } + else /* if ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) */ + { + /* Disable high level compensation. */ + ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + + /* Set the auto level control target Db for the Sout port. */ + if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) + { + /* Convert the dB value into OctFloat format.*/ + usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lSoutAutomaticLevelControlTargetDb ); + + /* Set auto level control target on the Sout port. */ + ulTempData |= ( usTempData << ulFeatureBitOffset ); + } + else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) */ + { + /* Disable auto level control. */ + ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Set the high level compensation threshold Db for the Sout port. */ + if ( pSharedInfo->ImageInfo.fSoutHighLevelCompensation == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Disable high level compensation on Sout for now. */ + ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Check if have to clear the ALC-HLC status. */ + if ( ( pSharedInfo->ImageInfo.fAlcHlcStatus == TRUE ) + && ( f_fClearAlcHlcStatusBit == TRUE ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Get previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + /* Retrieve last status. */ + byLastStatus = (UINT8)( ( ( ulTempData & ulMask ) >> ulFeatureBitOffset ) & 0xFF ); + + /* Increment to reset context. */ + byLastStatus ++; + + /* Just in case, not to overwrite some context in external memory. */ + byLastStatus &= ( 0x1 << ulFeatureFieldLength ) - 1; + + /* Clear last status. */ + ulTempData &= (~ulMask); + + /* Set new status. */ + ulTempData |= ( byLastStatus << ulFeatureBitOffset ); + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiSetChannelTailConfiguration + +Description: This function will configure the tail displacement and length + on a given channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pVqeConfig VQE config of the channel. +f_usChanIndex Index of the channel within the API instance. +f_usEchoMemIndex Index of the echo channel within the SSPX memory. +f_fModifyOnly Function called from a modify or open? + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiSetChannelTailConfiguration( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig, + IN UINT16 f_usChanIndex, + IN UINT16 f_usEchoMemIndex, + IN BOOL f_fModifyOnly ) +{ + tPOCT6100_API_CHANNEL pChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulResult; + UINT32 ulTempData; + UINT32 ulNlpConfBaseAddress; + UINT32 ulAfConfBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulMask; + UINT32 ulTailSum; + BOOL fTailDisplacementModified = FALSE; + + /* Get local pointer to shared portion of the API instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain a pointer to the channel list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ); + + /* Calculate base addresses of NLP + AF configuration structure for the specified channel. */ + ulNlpConfBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; + ulAfConfBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainIoMemOfst; + + /* Set the tail displacement.*/ + if ( pSharedInfo->ImageInfo.fTailDisplacement == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->fEnableTailDisplacement != pChanEntry->VqeConfig.fEnableTailDisplacement ) + || ( f_pVqeConfig->ulTailDisplacement != pChanEntry->VqeConfig.usTailDisplacement ) + || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) ) + { + /* Remember that the tail displacement parameters were changed. */ + fTailDisplacementModified = TRUE; + + /* Check if we must set the tail displacement value. */ + if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) + && ( pSharedInfo->ImageInfo.fPerChannelTailDisplacement == TRUE ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) + && ( f_pVqeConfig->ulTailDisplacement != 0x0 ) ) + { + if ( pSharedInfo->ImageInfo.fAfTailDisplacement == FALSE ) + { + if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset ); + } + else + { + ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset ); + } + } + else /* if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE ) */ + { + /* If AEC is not activated, this must be set to the requested tail displacement. */ + if ( f_pVqeConfig->fAcousticEcho == FALSE ) + { + if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement; + } + else + { + ulTailSum = f_pVqeConfig->ulTailDisplacement; + } + + if ( ulTailSum == 0 ) + { + ulTempData |= ( ( 0 ) << ulFeatureBitOffset ); + } + else if ( ulTailSum <= 128 ) + { + ulTempData |= ( ( 1 ) << ulFeatureBitOffset ); + } + else if ( ulTailSum <= 384 ) + { + ulTempData |= ( ( 3 ) << ulFeatureBitOffset ); + } + else /* if ( ulTailSum <= 896 ) */ + { + ulTempData |= ( ( 7 ) << ulFeatureBitOffset ); + } + } + else /* if ( f_pVqeConfig->fAcousticEcho == FALSE ) */ + { + /* Otherwise, the tail displacement is configured differently. This field stays to 0. */ + ulTempData |= ( 0x0 << ulFeatureBitOffset ); + } + } + } + + /* Then save the new DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE ) + { + /* Set the tail displacement offset in the AF. */ + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset ); + } + else + { + ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset ); + } + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + ulFeatureBytesOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.TailDisplEnableOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + ulTempData |= ( ( (UINT32)f_pVqeConfig->fEnableTailDisplacement ) << ulFeatureBitOffset ); + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the tail length. */ + if ( pSharedInfo->ImageInfo.fPerChannelTailLength == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( ( f_fModifyOnly == TRUE ) + && ( f_pVqeConfig->ulTailLength != pChanEntry->VqeConfig.usTailLength ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + /* Check if must automatically select maximum or if must use user specific value. */ + if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTempData |= ( ( ( pSharedInfo->ImageInfo.usMaxTailLength - 32 ) / 4 ) << ulFeatureBitOffset ); + } + else + { + ulTempData |= ( ( ( f_pVqeConfig->ulTailLength - 32 ) / 4 ) << ulFeatureBitOffset ); + } + + /* Then save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulAfConfBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Configure AEC tail length. */ + if ( pSharedInfo->ImageInfo.fAecTailLength == TRUE ) + { + /* Check if the configuration has been changed. */ + if ( ( f_fModifyOnly == FALSE ) + || ( fTailDisplacementModified == TRUE ) + || ( ( f_fModifyOnly == TRUE ) + && ( ( f_pVqeConfig->ulAecTailLength != pChanEntry->VqeConfig.usAecTailLength ) + || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set acoustic echo tail length. */ + if ( f_pVqeConfig->fAcousticEcho == TRUE ) + { + switch( f_pVqeConfig->ulAecTailLength ) + { + case 1024: + ulTempData |= ( ( 3 ) << ulFeatureBitOffset ); + break; + case 512: + ulTempData |= ( ( 2 ) << ulFeatureBitOffset ); + break; + case 256: + ulTempData |= ( ( 1 ) << ulFeatureBitOffset ); + break; + case 128: + default: + ulTempData |= ( ( 0 ) << ulFeatureBitOffset ); + break; + } + } + else if ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) + { + /* No acoustic echo case. */ + + /* Start with requested tail displacement. */ + if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement; + } + else + { + ulTailSum = f_pVqeConfig->ulTailDisplacement; + } + + /* Add requested tail length. */ + if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL ) + { + ulTailSum += pSharedInfo->ImageInfo.usMaxTailLength; + } + else + { + ulTailSum += f_pVqeConfig->ulTailLength; + } + + /* Round this value up. */ + if ( ulTailSum <= 128 ) + { + ulTempData |= ( ( 0 ) << ulFeatureBitOffset ); + } + else if ( ulTailSum <= 256 ) + { + ulTempData |= ( ( 1 ) << ulFeatureBitOffset ); + } + else if ( ulTailSum <= 512 ) + { + ulTempData |= ( ( 2 ) << ulFeatureBitOffset ); + } + else /* if ( ulTailSum <= 1024 ) */ + { + ulTempData |= ( ( 3 ) << ulFeatureBitOffset ); + } + } + else + { + /* Keep this to zero. */ + ulTempData |= ( ( 0 ) << ulFeatureBitOffset ); + } + + /* Write the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulNlpConfBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + return cOCT6100_ERR_OK; +} + +#if 0 /* unused functions */ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelMuteSer + +Description: This function will mute some of the ports on a given + channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pChannelMute What channel/ports to mute. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelMuteSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MUTE f_pChannelMute ) +{ + UINT32 ulResult; + UINT16 usChanIndex; + UINT16 usPortMask; + + /* Verify that all the parameters given match the state of the API. */ + ulResult = Oct6100ApiAssertChannelMuteParams( f_pApiInstance, + f_pChannelMute, + &usChanIndex, + &usPortMask ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Call the actual channel mute ports function. */ + ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance, + usChanIndex, + usPortMask, + TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAssertChannelMuteParams + +Description: Check the user parameters passed to the channel mute function. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pChannelMute What channel/ports to mute. +f_pusChanIndex Resulting channel index where the muting should + be applied. +f_pusPorts Port mask on which to apply the muting. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAssertChannelMuteParams( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_MUTE f_pChannelMute, + OUT PUINT16 f_pusChanIndex, + OUT PUINT16 f_pusPorts ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pChanEntry; + UINT32 ulEntryOpenCnt; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Check the provided handle. */ + if ( (f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + *f_pusChanIndex = (UINT16)( f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = ( f_pChannelMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pChanEntry->fReserved != TRUE ) + return cOCT6100_ERR_CHANNEL_NOT_OPEN; + if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + if ( pChanEntry->fBiDirChannel == TRUE ) + return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL; + + /*=======================================================================*/ + + /* Check the provided port mask. */ + + if ( ( f_pChannelMute->ulPortMask & + ~( cOCT6100_CHANNEL_MUTE_PORT_NONE | + cOCT6100_CHANNEL_MUTE_PORT_RIN | + cOCT6100_CHANNEL_MUTE_PORT_ROUT | + cOCT6100_CHANNEL_MUTE_PORT_SIN | + cOCT6100_CHANNEL_MUTE_PORT_SOUT | + cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 ) + return cOCT6100_ERR_CHANNEL_MUTE_MASK; + + /* Sin + Sin with features cannot be muted simultaneously. */ + if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) + && ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) + return cOCT6100_ERR_CHANNEL_MUTE_MASK_SIN; + + /* Check if Sin mute with features is supported by the firmware. */ + if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) + && ( pSharedInfo->ImageInfo.fSinMute == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_MUTE_FEATURES; + + /* Return the ports to the calling function. */ + *f_pusPorts = (UINT16)( f_pChannelMute->ulPortMask & 0xFFFF ); + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChannelUnMuteSer + +Description: This function will unmute some of the ports on a given + channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pChannelUnMute What channel/ports to unmute. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChannelUnMuteSer( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute ) +{ + UINT32 ulResult; + UINT16 usChanIndex; + UINT16 usPortMask; + + /* Verify that all the parameters given match the state of the API. */ + ulResult = Oct6100ApiAssertChannelUnMuteParams( f_pApiInstance, + f_pChannelUnMute, + &usChanIndex, + &usPortMask ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Call the actual channel mute ports function. */ + ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance, + usChanIndex, + usPortMask, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAssertChannelUnMuteParams + +Description: Check the user parameters passed to the channel unmute function. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pChannelUnMute What channel/ports to Unmute. +f_pusChanIndex Resulting channel index where the muting should + be applied. +f_pusPorts Port mask on which to apply the muting. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAssertChannelUnMuteParams( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute, + OUT PUINT16 f_pusChanIndex, + OUT PUINT16 f_pusPorts ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pChanEntry; + UINT32 ulEntryOpenCnt; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Check the provided handle. */ + if ( (f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + *f_pusChanIndex = (UINT16)( f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + + /*=======================================================================*/ + /* Get a pointer to the channel's list entry. */ + + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = ( f_pChannelUnMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pChanEntry->fReserved != TRUE ) + return cOCT6100_ERR_CHANNEL_NOT_OPEN; + if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CHANNEL_INVALID_HANDLE; + if ( pChanEntry->fBiDirChannel == TRUE ) + return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL; + + /*=======================================================================*/ + + /* Check the provided port mask. */ + + if ( ( f_pChannelUnMute->ulPortMask & + ~( cOCT6100_CHANNEL_MUTE_PORT_NONE | + cOCT6100_CHANNEL_MUTE_PORT_RIN | + cOCT6100_CHANNEL_MUTE_PORT_ROUT | + cOCT6100_CHANNEL_MUTE_PORT_SIN | + cOCT6100_CHANNEL_MUTE_PORT_SOUT | + cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 ) + return cOCT6100_ERR_CHANNEL_MUTE_MASK; + + /* Return the ports to the calling function. */ + *f_pusPorts = (UINT16)( f_pChannelUnMute->ulPortMask & 0xFFFF ); + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiMuteChannelPorts + +Description: Mute or Unmute the specified ports, according to the mask. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_usChanIndex Resulting channel index where the muting should + be applied. +f_usPortMask Port mask on which to apply the muting/unmuting. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiMuteChannelPorts( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usChanIndex, + IN UINT16 f_usPortMask, + IN BOOL f_fMute ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pChanEntry; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + UINT32 ulTempData; + UINT32 ulBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulMask; + BOOL fDisableSinWithFeatures = FALSE; + BOOL fEnableSinWithFeatures = FALSE; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Get a pointer to the channel's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ) + + /* Rin port. */ + if ( ( f_fMute == TRUE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) ) + { + /* Mute this port. */ + pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_RIN; + + ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + { + pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN; + return ulResult; + } + } + else if ( ( f_fMute == FALSE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) ) + { + /* Unmute this port. */ + pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN; + + ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Rout port. */ + if ( ( f_fMute == TRUE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) ) + { + /* Mute this port. */ + + if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Deactivate the TSST entry.*/ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRoutTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_ROUT; + } + else if ( ( f_fMute == FALSE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) ) + { + /* Unmute this port. */ + + if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + pChanEntry->usRoutTsstIndex, + pChanEntry->CodecConfig.byAdpcmNibblePosition, + pChanEntry->TdmConfig.byRoutNumTssts, + pChanEntry->usRinRoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_ROUT; + } + + /* Sin port. */ + if ( ( f_fMute == TRUE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) ) + { + /* Mute this port. */ + pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN; + + ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + { + pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN; + return ulResult; + } + } + else if ( + ( ( f_fMute == FALSE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) + || + ( ( f_fMute == TRUE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) ) + { + /* Unmute this port. */ + pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN; + + ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Sout port. */ + if ( ( f_fMute == TRUE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) ) + { + /* Mute this port. */ + + if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + /* Deactivate the TSST entry.*/ + WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSoutTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SOUT; + } + else if ( ( f_fMute == FALSE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) ) + { + /* Unmute this port. */ + + if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, + pChanEntry->usSoutTsstIndex, + pChanEntry->CodecConfig.byAdpcmNibblePosition, + pChanEntry->TdmConfig.bySoutNumTssts, + pChanEntry->usSinSoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SOUT; + } + + /* Sin with features port. */ + if ( ( f_fMute == TRUE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) == 0x0 ) ) + { + /* Mute this port. */ + pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES; + fEnableSinWithFeatures = TRUE; + } + else if ( + ( ( f_fMute == FALSE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) + || + ( ( f_fMute == TRUE ) + && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) + && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) ) + { + /* Unmute this port. */ + pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES; + + fDisableSinWithFeatures = TRUE; + } + + /* Check if must enable or disable SIN mute with features. */ + if ( fDisableSinWithFeatures == TRUE || fEnableSinWithFeatures == TRUE ) + { + ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; + + if ( pSharedInfo->ImageInfo.fSinMute == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + /* Clear the mute flag. */ + ulTempData &= (~ulMask); + + /* Set the mute flag on the Sin port.*/ + if ( fEnableSinWithFeatures == TRUE ) + ulTempData |= ( 0x1 << ulFeatureBitOffset ); + + /* Write the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + return cOCT6100_ERR_OK; +} +#endif + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_open.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the functions used to power-up the chip according to the + user's configuration. Also, the API instance is initialized to reflect the + desired configuration. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 305 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" + +#include "apilib/octapi_bt0.h" +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_apiud.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_tsi_cnct_inst.h" +#include "oct6100api/oct6100_events_inst.h" +#include "oct6100api/oct6100_conf_bridge_inst.h" +#include "oct6100api/oct6100_playout_buf_inst.h" + +#include "oct6100api/oct6100_mixer_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_adpcm_chan_inst.h" +#include "oct6100api/oct6100_phasing_tsst_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_api_inst.h" + +#include "oct6100api/oct6100_chip_stats_pub.h" +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_tsi_cnct_pub.h" +#include "oct6100api/oct6100_events_pub.h" +#include "oct6100api/oct6100_conf_bridge_pub.h" +#include "oct6100api/oct6100_playout_buf_pub.h" + +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_adpcm_chan_pub.h" +#include "oct6100api/oct6100_phasing_tsst_pub.h" +#include "oct6100api/oct6100_remote_debug_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_mixer_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_debug_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_interrupts_priv.h" +#include "oct6100_chip_stats_priv.h" +#include "octrpc/rpc_protocol.h" +#include "oct6100_remote_debug_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_tsst_priv.h" +#include "oct6100_tsi_cnct_priv.h" +#include "oct6100_mixer_priv.h" +#include "oct6100_events_priv.h" +#include "oct6100_conf_bridge_priv.h" +#include "oct6100_playout_buf_priv.h" + +#include "oct6100_channel_priv.h" +#include "oct6100_adpcm_chan_priv.h" +#include "oct6100_phasing_tsst_priv.h" +#include "oct6100_tlv_priv.h" +#include "oct6100_debug_priv.h" +#include "oct6100_version.h" + + + + +/**************************** PUBLIC FUNCTIONS *****************************/ + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100GetInstanceSizeDef + +Description: Retrieves the size of the required API instance structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pGetSize Structure containing API instance size. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100GetInstanceSizeDef( + tPOCT6100_GET_INSTANCE_SIZE f_pGetSize ) +{ + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100GetInstanceSize( + tPOCT6100_CHIP_OPEN f_pChipOpen, + tPOCT6100_GET_INSTANCE_SIZE f_pGetSize ) +{ + tOCT6100_API_INSTANCE_SIZES InstanceSizes; + UINT32 ulResult; + + /* Check user configuration for errors and conflicts. */ + ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Calculate the instance size required for user's configuration. */ + ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Return required size to user. */ + f_pGetSize->ulApiInstanceSize = InstanceSizes.ulApiInstTotal; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChipOpenDef + +Description: Inserts default chip configuration parameters into the + structure pointed to by f_pChipOpen. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_pChipOpen Structure containing user chip configuration. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChipOpenDef( + tPOCT6100_CHIP_OPEN f_pChipOpen ) +{ + UINT32 i; + + f_pChipOpen->ulUserChipId = 0; + f_pChipOpen->fMultiProcessSystem = FALSE; + f_pChipOpen->pProcessContext = NULL; + + f_pChipOpen->ulMaxRwAccesses = 8; + + f_pChipOpen->pbyImageFile = NULL; + f_pChipOpen->ulImageSize = 0; + + f_pChipOpen->ulMemClkFreq = 133000000; /* 133 Mhz */ + f_pChipOpen->ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ; /* 33.33 Mhz */ + f_pChipOpen->fEnableMemClkOut = TRUE; + + f_pChipOpen->ulMemoryType = cOCT6100_MEM_TYPE_DDR; + f_pChipOpen->ulNumMemoryChips = 1; + f_pChipOpen->ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_64MB; + + /* Set the tail displacement to zero. */ + f_pChipOpen->ulTailDisplacement = 0; + + /* Disable acoustic echo by default. */ + f_pChipOpen->fEnableAcousticEcho = FALSE; + + /* Resource allocation parameters. */ + f_pChipOpen->ulMaxChannels = 672; + f_pChipOpen->ulMaxTsiCncts = 0; + f_pChipOpen->ulMaxBiDirChannels = 0; + f_pChipOpen->ulMaxConfBridges = 0; + f_pChipOpen->ulMaxFlexibleConfParticipants = 0; + f_pChipOpen->ulMaxPlayoutBuffers = 0; + + f_pChipOpen->ulMaxPhasingTssts = 0; + f_pChipOpen->ulMaxAdpcmChannels = 0; + f_pChipOpen->ulMaxTdmStreams = 32; + f_pChipOpen->fUseSynchTimestamp = FALSE; + for ( i = 0; i < 4; i++ ) + { + f_pChipOpen->aulTimestampTimeslots[ i ] = cOCT6100_INVALID_TIMESLOT; + f_pChipOpen->aulTimestampStreams[ i ] = cOCT6100_INVALID_STREAM; + } + f_pChipOpen->fEnableFastH100Mode = FALSE; + + /* Configure the soft tone event buffer. */ + f_pChipOpen->ulSoftToneEventsBufSize = 2048; + f_pChipOpen->fEnableExtToneDetection = FALSE; + + /* Configure the soft playout event buffer. */ + f_pChipOpen->ulSoftBufferPlayoutEventsBufSize = cOCT6100_INVALID_VALUE; + + /* Interrupt configuration. */ + f_pChipOpen->ulInterruptPolarity = cOCT6100_ACTIVE_LOW_POLARITY; + + f_pChipOpen->InterruptConfig.ulErrorMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT; + f_pChipOpen->InterruptConfig.ulFatalGeneralConfig = cOCT6100_INTERRUPT_NO_TIMEOUT; + f_pChipOpen->InterruptConfig.ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT; + f_pChipOpen->InterruptConfig.ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT; + f_pChipOpen->InterruptConfig.ulErrorH100Config = cOCT6100_INTERRUPT_NO_TIMEOUT; + f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig = cOCT6100_INTERRUPT_NO_TIMEOUT; + + f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout = 100; + f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout = 100; + f_pChipOpen->InterruptConfig.ulErrorH100Timeout = 100; + f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout = 100; + f_pChipOpen->ulMaxRemoteDebugSessions = 1; + f_pChipOpen->ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_3_QUARTERS; + for ( i = 0; i < cOCT6100_TDM_STREAM_MAX_GROUPS; i++ ) + f_pChipOpen->aulTdmStreamFreqs[ i ] = cOCT6100_TDM_STREAM_FREQ_8MHZ; + + + + f_pChipOpen->fEnableChannelRecording = FALSE; + f_pChipOpen->fEnableProductionBist = FALSE; + f_pChipOpen->ulNumProductionBistLoops = 1; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChipOpen + +Description: Configures the chip according to the user specified + configuration f_pChipOpen. This function will perform all I/O + accesses necessary and initialize the API instance to reflect + the configuration. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChipOpen Structure containing user chip configuration. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChipOpen( + tPOCT6100_INSTANCE_API f_pApiInstance, + tPOCT6100_CHIP_OPEN f_pChipOpen ) +{ + tOCT6100_API_INSTANCE_SIZES InstanceSizes; + UINT32 ulStructSize; + UINT32 ulResult; + UINT32 ulTempVar; + + /* Check user chip configuration parameters for errors. */ + ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if the host system is multi-process or not and adjust instance accordingly. */ + if ( f_pChipOpen->fMultiProcessSystem != TRUE ) + { + /* Set pointer to tOCT6100_SHARED_INFO structure within instance. */ + ulStructSize = sizeof( tOCT6100_INSTANCE_API ); + mOCT6100_ROUND_MEMORY_SIZE( ulStructSize, ulTempVar ) + + f_pApiInstance->pSharedInfo = ( tPOCT6100_SHARED_INFO )(( PVOID )f_pApiInstance + ulStructSize); + + /* Save the process context specified by the user. */ + f_pApiInstance->pProcessContext = f_pChipOpen->pProcessContext; + + + /* Create serialization object handles. */ + ulResult = Oct6100ApiCreateSerializeObjects( f_pApiInstance, f_pChipOpen->ulUserChipId ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Copy the configuration structure. */ + ulResult = Oct6100ApiCopyChipConfiguration( f_pApiInstance, f_pChipOpen ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Perform various calculations based on user chip configuration. */ + ulResult = Oct6100ApiInitializeMiscellaneousVariables( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Calculate the amount of memory needed for the API instance structure. */ + ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Allocate the memory for the API instance structure internal pointers. */ + ulResult = Oct6100ApiAllocateInstanceMemory( f_pApiInstance, &InstanceSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Initialize the allocated instance structure memory. */ + ulResult = Oct6100ApiInitializeInstanceMemory( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Initialize the tone information structure. */ + ulResult = Oct6100ApiInitToneInfo( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Test the CPU registers. */ + ulResult = Oct6100ApiCpuRegisterBist( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Boot the FC2 PLL. */ + ulResult = Oct6100ApiBootFc2Pll( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Program the FC1 PLL. */ + ulResult = Oct6100ApiProgramFc1Pll( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Decode the key and bist internal memories. */ + ulResult = Oct6100ApiDecodeKeyAndBist( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Boot the FC1 PLL. */ + ulResult = Oct6100ApiBootFc1Pll( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Boot the SDRAM. */ + ulResult = Oct6100ApiBootSdram( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Bist the external memory. */ + ulResult = Oct6100ApiExternalMemoryBist( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Initialize the external memory. */ + ulResult = Oct6100ApiExternalMemoryInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Load the image into the chip. */ + ulResult = Oct6100ApiLoadImage( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write the clock distribution registers. */ + ulResult = Oct6100ApiEnableClocks( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Program the NLP processor. */ + ulResult = Oct6100ApiProgramNLP( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == cOCT6100_ERR_OPEN_EGO_TIMEOUT ) + ulResult = Oct6100ApiProgramNLP( f_pApiInstance ); + } + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( f_pChipOpen->fEnableProductionBist == FALSE ) + { + /* Read all TLV fields present in external memory. */ + ulResult = Oct6100ApiProcessTlvRegion( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Configure the H.100 interface. */ + ulResult = Oct6100ApiSetH100Register( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Write miscellaneous registers. */ + ulResult = Oct6100ApiWriteMiscellaneousRegisters( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Proceed with the rest only if the production BIST has not been requested. */ + if ( f_pChipOpen->fEnableProductionBist == FALSE ) + { + /* Configure the interrupt registers. */ + ulResult = Oct6100ApiIsrHwInit( f_pApiInstance, &f_pChipOpen->InterruptConfig ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Initialize the errors counters. */ + ulResult = Oct6100ApiChipStatsSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Configure all interrupts of the chip. */ + ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, &f_pChipOpen->InterruptConfig, FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Get revision number of chip. */ + ulResult = Oct6100ApiGetChipRevisionNum( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + + + + + /* Initialize the channels. */ + ulResult = Oct6100ApiInitChannels( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Initialize the mixer memory. */ + ulResult = Oct6100ApiInitMixer( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Initialize the mixer memory. */ + ulResult = Oct6100ApiInitRecordResources( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Initialize free external memory for buffer playout. */ + ulResult = Oct6100ApiBufferPlayoutMemorySwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + + + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ChipCloseDef + +Description: Puts the chip into soft reset. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChipClose Pointer to a tOCT6100_CHIP_CLOSE structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ChipCloseDef( + tPOCT6100_CHIP_CLOSE f_pChipClose ) +{ + f_pChipClose->ulDummyVariable = 0; + + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100ChipClose( + tPOCT6100_INSTANCE_API f_pApiInstance, + tPOCT6100_CHIP_CLOSE f_pChipClose ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + WriteParams.ulWriteAddress = 0x100; + WriteParams.usWriteData = 0x0000; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Destroy the allocated ressources used for serialization. */ + ulResult = Oct6100ApiDestroySerializeObjects( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + +/*************************** PRIVATE FUNCTIONS *****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiStrStr + +Description: OCT6100 API version of strstr() + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_pszSource Source string to analyze. +f_pszString String to look for. +f_pszLastCharPtr Last character in the source string. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static PUINT8 Oct6100ApiStrStr( + IN PUINT8 f_pszSource, + IN PUINT8 f_pszString, + IN PUINT8 f_pszLastCharPtr ) +{ + UINT32 ulCurrentPos; + UINT32 ulStringLength; + UINT32 ulNumMatchingCharFound = 0; + PUINT8 pchFirstChar = NULL; + UINT32 ulSourceLength; + + if ( f_pszLastCharPtr < f_pszSource ) + return NULL; + + ulSourceLength = f_pszLastCharPtr - f_pszSource; + ulStringLength = Oct6100ApiStrLen( f_pszString ); + + for ( ulCurrentPos = 0; ulCurrentPos < ulSourceLength; ulCurrentPos++ ) + { + /* Check if the character matches. */ + if ( f_pszSource[ ulCurrentPos ] == f_pszString[ ulNumMatchingCharFound ] ) + { + if ( ulNumMatchingCharFound == 0 ) + pchFirstChar = ( f_pszSource + ulCurrentPos ); + + ulNumMatchingCharFound++; + + /* Check if the whole string matched. */ + if ( ulNumMatchingCharFound == ulStringLength ) + break; + } + else if ( ulNumMatchingCharFound != 0 ) + { + ulNumMatchingCharFound = 0; + + /* Reset the search, but take a look at the current character. It might */ + /* be the beginning of the string we are looking for. */ + if ( f_pszSource[ ulCurrentPos ] == f_pszString[ ulNumMatchingCharFound ] ) + { + pchFirstChar = ( f_pszSource + ulCurrentPos ); + ulNumMatchingCharFound++; + + /* Check if the whole string matched. */ + /* This check must be done in case we have the 1 character strstr */ + if ( ulNumMatchingCharFound == ulStringLength ) + break; + } + } + } + + if ( ulCurrentPos == ulSourceLength ) + return NULL; + else + return pchFirstChar; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiStrLen + +Description: OCT6100 API version of strlen() + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_pszString Source string to count length of. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiStrLen( + IN PUINT8 f_pszString ) +{ + UINT32 ulCount = 0; + + while( f_pszString[ ulCount ] != '\0' ) + ulCount++; + + return ulCount; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAsciiToHex + +Description: Convert an ASCII character to an hexadecimal value. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_chCharacter ASCII character to convert. +f_pulValue Resulting hexadecimal value. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAsciiToHex( + IN UINT8 f_chCharacter, + OUT PUINT32 f_pulValue ) +{ + switch ( f_chCharacter ) + { + case '0': + (*f_pulValue) = 0x0; + break; + case '1': + (*f_pulValue) = 0x1; + break; + case '2': + (*f_pulValue) = 0x2; + break; + case '3': + (*f_pulValue) = 0x3; + break; + case '4': + (*f_pulValue) = 0x4; + break; + case '5': + (*f_pulValue) = 0x5; + break; + case '6': + (*f_pulValue) = 0x6; + break; + case '7': + (*f_pulValue) = 0x7; + break; + case '8': + (*f_pulValue) = 0x8; + break; + case '9': + (*f_pulValue) = 0x9; + break; + case 'A': + case 'a': + (*f_pulValue) = 0xA; + break; + case 'B': + case 'b': + (*f_pulValue) = 0xB; + break; + case 'C': + case 'c': + (*f_pulValue) = 0xC; + break; + case 'D': + case 'd': + (*f_pulValue) = 0xD; + break; + case 'E': + case 'e': + (*f_pulValue) = 0xE; + break; + case 'F': + case 'f': + (*f_pulValue) = 0xF; + break; + default: + (*f_pulValue) = 0x0; + return cOCT6100_ERR_MISC_ASCII_CONVERSION_FAILED; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiHexToAscii + +Description: Convert an hexadecimal value to an ASCII character. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_ulNumber Hexadecimal value to convert. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT8 Oct6100ApiHexToAscii( + IN UINT32 f_ulNumber ) +{ + if ( f_ulNumber >= 0xA ) + return (UINT8)( 55 + f_ulNumber ); /* Hex values from 0xA to 0xF */ + else + return (UINT8)( 48 + f_ulNumber ); /* Hex values from 0x0 to 0x9 */ +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiRand + +Description: Random number generator. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_ulRange Range of the random number to be generated. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiRand( + IN UINT32 f_ulRange ) +{ + static UINT32 ulRandomSeed = 0x12345678; + UINT32 ulBit0; + + UINT32 i, j; + UINT16 ulWithinRange = FALSE; + + UINT32 ulResult = cOCT6100_ERR_OK; + UINT16 ulLoop; + + UINT32 ulRangeMask; + UINT32 ulAddedValue; + + + ulRangeMask = 1; + ulLoop = TRUE; + i = 1; + + while ( ulLoop ) + { + + ulAddedValue = 2; + for ( j = 1; j < i; j++ ) + ulAddedValue *= 2; + + ulRangeMask = ulRangeMask + ulAddedValue; + + if ( ulRangeMask >= f_ulRange ) + ulLoop = FALSE; + + i++; + } + + while ( !ulWithinRange ) + { + ulBit0 = ((ulRandomSeed >> 19) & 0x1) ^ ((ulRandomSeed >> 16) & 0x1); + ulRandomSeed = ((ulRandomSeed << 1) & 0xFFFFF) | ulBit0; + + ulResult = ulRandomSeed & ulRangeMask; + + if ( ulResult <= f_ulRange ) + ulWithinRange = TRUE; + } + + return ulResult; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckChipConfiguration + +Description: Checks the user chip configuration structure for errors. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_pChipOpen Pointer to chip configuration structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckChipConfiguration( + IN tPOCT6100_CHIP_OPEN f_pChipOpen ) +{ + UINT32 ulTempVar; + UINT32 i; + + /*-----------------------------------------------------------------------------*/ + /* Check general parameters. */ + if ( f_pChipOpen->fMultiProcessSystem != TRUE && + f_pChipOpen->fMultiProcessSystem != FALSE ) + return cOCT6100_ERR_OPEN_MULTI_PROCESS_SYSTEM; + + if ( f_pChipOpen->ulMaxRwAccesses < 1 || + f_pChipOpen->ulMaxRwAccesses > 1024) + return cOCT6100_ERR_OPEN_MAX_RW_ACCESSES; + + /* Check the clocks. */ + if ( f_pChipOpen->ulUpclkFreq != cOCT6100_UPCLK_FREQ_33_33_MHZ && + f_pChipOpen->ulUpclkFreq != cOCT6100_UPCLK_FREQ_66_67_MHZ ) + return cOCT6100_ERR_OPEN_UP_CLK_FREQ; + + if ( f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_133_MHZ && + f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_125_MHZ && + f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_117_MHZ && + f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_108_MHZ && + f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_100_MHZ && + f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_92_MHZ && + f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_83_MHZ && + f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_75_MHZ ) + return cOCT6100_ERR_OPEN_MEM_CLK_FREQ; + + if ( f_pChipOpen->fEnableMemClkOut != TRUE && + f_pChipOpen->fEnableMemClkOut != FALSE ) + return cOCT6100_ERR_OPEN_ENABLE_MEM_CLK_OUT; + + /* Check the image file. */ + if ( f_pChipOpen->ulImageSize < cOCT6100_MIN_IMAGE_SIZE || + f_pChipOpen->ulImageSize > cOCT6100_MAX_IMAGE_SIZE ) + return cOCT6100_ERR_OPEN_IMAGE_SIZE; + + if ( f_pChipOpen->pbyImageFile == NULL ) + return cOCT6100_ERR_OPEN_IMAGE_FILE; + + /* Check the acoustic echo activation flag. */ + if ( f_pChipOpen->fEnableAcousticEcho != TRUE && + f_pChipOpen->fEnableAcousticEcho != FALSE ) + return cOCT6100_ERR_OPEN_ENABLE_ACOUSTIC_ECHO; + + /* Check the tail displacement parameter. */ + if ( f_pChipOpen->ulTailDisplacement > cOCT6100_MAX_TAIL_DISPLACEMENT ) + return cOCT6100_ERR_OPEN_TAIL_DISPLACEMENT; + + /*-----------------------------------------------------------------------------*/ + /* Check TDM bus configuration parameters. */ + for ( i = 0; i < 8; i++ ) + { + if ( f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_2MHZ && + f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_4MHZ && + f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_8MHZ) + return cOCT6100_ERR_OPEN_TDM_STREAM_FREQS; + } + + if ( f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_3_QUARTERS && + f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_RISING_EDGE && + f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE ) + return cOCT6100_ERR_OPEN_TDM_SAMPLING; + + if ( f_pChipOpen->fEnableFastH100Mode != TRUE && + f_pChipOpen->fEnableFastH100Mode != FALSE ) + return cOCT6100_ERR_OPEN_FAST_H100_MODE; + + /*-----------------------------------------------------------------------------*/ + /* Check external memory configuration parameters. */ + if ( f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_SDR && + f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_DDR && + f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_SDR_PLL_BYPASS ) + return cOCT6100_ERR_OPEN_MEMORY_TYPE; + + if ( f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_8MB && + f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_16MB && + f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_32MB && + f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_64MB && + f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_128MB ) + return cOCT6100_ERR_OPEN_MEMORY_CHIP_SIZE; + + if ( f_pChipOpen->ulMemoryChipSize == cOCT6100_MEMORY_CHIP_SIZE_8MB && + f_pChipOpen->ulMemoryType == cOCT6100_MEM_TYPE_DDR ) + return cOCT6100_ERR_OPEN_MEMORY_CHIP_SIZE; + + if ( f_pChipOpen->ulNumMemoryChips < 1 || + f_pChipOpen->ulNumMemoryChips > cOCT6100_MAX_NUM_MEMORY_CHIP ) + return cOCT6100_ERR_OPEN_MEMORY_CHIPS_NUMBER; + + /* Check the total memory size. */ + ulTempVar = f_pChipOpen->ulMemoryChipSize * f_pChipOpen->ulNumMemoryChips; + if ( ulTempVar < cOCT6100_MEMORY_CHIP_SIZE_16MB || + ulTempVar > cOCT6100_MEMORY_CHIP_SIZE_128MB ) + return cOCT6100_ERR_OPEN_TOTAL_MEMORY_SIZE; + + if ( f_pChipOpen->ulMaxTdmStreams != 4 && + f_pChipOpen->ulMaxTdmStreams != 8 && + f_pChipOpen->ulMaxTdmStreams != 16 && + f_pChipOpen->ulMaxTdmStreams != 32 ) + return cOCT6100_ERR_OPEN_MAX_TDM_STREAM; + + if ( f_pChipOpen->ulMaxTdmStreams > 8 && + f_pChipOpen->ulMemClkFreq == cOCT6100_MCLK_FREQ_75_MHZ ) + return cOCT6100_ERR_OPEN_MAX_TDM_STREAM; + + if ( f_pChipOpen->fUseSynchTimestamp != TRUE && + f_pChipOpen->fUseSynchTimestamp != FALSE ) + return cOCT6100_ERR_OPEN_USE_SYNCH_TIMESTAMP; + + if ( f_pChipOpen->fUseSynchTimestamp == TRUE ) + { + return cOCT6100_ERR_NOT_SUPPORTED_OPEN_USE_SYNCH_TIMESTAMP; + } + + /*-----------------------------------------------------------------------------*/ + /* Check soft buffer for tone events size. */ + if ( f_pChipOpen->ulSoftToneEventsBufSize < cOCT6100_NUM_PGSP_EVENT_OUT || + f_pChipOpen->ulSoftToneEventsBufSize > cOCT6100_ABSOLUTE_MAX_NUM_PGSP_EVENT_OUT ) + return cOCT6100_ERR_OPEN_SOFT_TONE_EVENT_SIZE; + + if ( f_pChipOpen->fEnableExtToneDetection != TRUE && + f_pChipOpen->fEnableExtToneDetection != FALSE ) + return cOCT6100_ERR_OPEN_ENABLE_EXT_TONE_DETECTION; + + /* Check soft buffer for playout events size. */ + if ( ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE ) + && ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize < cOCT6100_MIN_BUFFER_PLAYOUT_EVENT || + f_pChipOpen->ulSoftBufferPlayoutEventsBufSize > cOCT6100_MAX_BUFFER_PLAYOUT_EVENT ) ) + return cOCT6100_ERR_OPEN_SOFT_PLAYOUT_STOP_EVENT_SIZE; + + /*-----------------------------------------------------------------------------*/ + /* Check interrupt configuration parameters. */ + if ( f_pChipOpen->ulInterruptPolarity != cOCT6100_ACTIVE_LOW_POLARITY && + f_pChipOpen->ulInterruptPolarity != cOCT6100_ACTIVE_HIGH_POLARITY ) + return cOCT6100_ERR_OPEN_INTERRUPT_POLARITY; + + if ( f_pChipOpen->InterruptConfig.ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT && + f_pChipOpen->InterruptConfig.ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE ) + return cOCT6100_ERR_OPEN_FATAL_GENERAL_CONFIG; + + if ( f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT && + f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT && + f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE ) + return cOCT6100_ERR_OPEN_FATAL_MEMORY_CONFIG; + + if ( f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT && + f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT && + f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE ) + return cOCT6100_ERR_OPEN_ERROR_MEMORY_CONFIG; + + if ( f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT && + f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT && + f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE ) + return cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_CONFIG; + + if ( f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT && + f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT && + f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE ) + return cOCT6100_ERR_OPEN_ERROR_H100_CONFIG; + + /* Check the timeout value. */ + if ( f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout < 10 || + f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout > 10000 ) + return cOCT6100_ERR_OPEN_FATAL_MEMORY_TIMEOUT; + + if ( f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout < 10 || + f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout > 10000 ) + return cOCT6100_ERR_OPEN_ERROR_MEMORY_TIMEOUT; + + if ( f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout < 10 || + f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout > 10000 ) + return cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_TIMEOUT; + + if ( f_pChipOpen->InterruptConfig.ulErrorH100Timeout < 10 || + f_pChipOpen->InterruptConfig.ulErrorH100Timeout > 10000 ) + return cOCT6100_ERR_OPEN_ERROR_H100_TIMEOUT; + + /*-----------------------------------------------------------------------------*/ + /* Check maximum resources. */ + + switch ( f_pChipOpen->ulMemClkFreq ) + { + case 133000000: + ulTempVar = 672; + break; + case 125000000: + ulTempVar = 624; + break; + case 117000000: + ulTempVar = 576; + break; + case 108000000: + ulTempVar = 528; + break; + case 100000000: + ulTempVar = 480; + break; + case 92000000: + ulTempVar = 432; + break; + case 83000000: + ulTempVar = 384; + break; + case 75000000: + ulTempVar = 336; + break; + default: + return cOCT6100_ERR_FATAL_DA; + } + + if ( f_pChipOpen->ulMaxChannels > ulTempVar ) + return cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS; + + if ( f_pChipOpen->ulMaxTsiCncts > cOCT6100_MAX_TSI_CNCTS ) + return cOCT6100_ERR_OPEN_MAX_TSI_CNCTS; + + if ( f_pChipOpen->ulMaxBiDirChannels > (f_pChipOpen->ulMaxChannels / 2) ) + return cOCT6100_ERR_OPEN_MAX_BIDIR_CHANNELS; + + if ( f_pChipOpen->ulMaxConfBridges > cOCT6100_MAX_CONF_BRIDGE ) + return cOCT6100_ERR_OPEN_MAX_CONF_BRIDGES; + + if ( f_pChipOpen->ulMaxFlexibleConfParticipants > cOCT6100_MAX_FLEX_CONF_PARTICIPANTS ) + return cOCT6100_ERR_OPEN_MAX_FLEXIBLE_CONF_PARTICIPANTS; + + if ( f_pChipOpen->ulMaxPlayoutBuffers > cOCT6100_MAX_PLAYOUT_BUFFERS ) + return cOCT6100_ERR_OPEN_MAX_PLAYOUT_BUFFERS; + + + + if ( f_pChipOpen->ulMaxPhasingTssts > cOCT6100_MAX_PHASING_TSST ) + return cOCT6100_ERR_OPEN_MAX_PHASING_TSSTS; + + if ( f_pChipOpen->ulMaxAdpcmChannels > cOCT6100_MAX_ADPCM_CHANNELS ) + return cOCT6100_ERR_OPEN_MAX_ADPCM_CHANNELS; + + if ( f_pChipOpen->ulMaxRemoteDebugSessions > 256 ) + return cOCT6100_ERR_OPEN_MAX_REMOTE_DEBUG_SESSIONS; + + + + + + /* Check the channel recording flag. */ + if ( f_pChipOpen->fEnableChannelRecording != TRUE && + f_pChipOpen->fEnableChannelRecording != FALSE ) + return cOCT6100_ERR_OPEN_DEBUG_CHANNEL_RECORDING; + + /* Check the enable production BIST flag. */ + if ( ( f_pChipOpen->fEnableProductionBist != TRUE ) + && ( f_pChipOpen->fEnableProductionBist != FALSE ) ) + return cOCT6100_ERR_OPEN_ENABLE_PRODUCTION_BIST; + + /* Check number of loops for the production BIST. */ + if ( f_pChipOpen->fEnableProductionBist == TRUE ) + { + if ( f_pChipOpen->ulNumProductionBistLoops == 0 ) + return cOCT6100_ERR_OPEN_NUM_PRODUCTION_BIST_LOOPS; + } + + /* If the production BIST has been requested, make sure all */ + /* other resources are disabled. */ + if ( f_pChipOpen->fEnableProductionBist == TRUE ) + { + /* All must be disabled. */ + f_pChipOpen->ulMaxChannels = 0; + f_pChipOpen->ulMaxTsiCncts = 0; + f_pChipOpen->fEnableChannelRecording = FALSE; + f_pChipOpen->ulMaxBiDirChannels = 0; + f_pChipOpen->ulMaxConfBridges = 0; + f_pChipOpen->ulMaxPlayoutBuffers = 0; + f_pChipOpen->ulSoftBufferPlayoutEventsBufSize = cOCT6100_INVALID_VALUE; + f_pChipOpen->ulMaxPhasingTssts = 0; + f_pChipOpen->ulMaxAdpcmChannels = 0; + + + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCopyChipConfiguration + +Description: Copies the chip configuration from the user supplied config + structure to the instance structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pChipOpen Pointer to chip configuration structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCopyChipConfiguration( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CHIP_OPEN f_pChipOpen ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 i; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + pSharedInfo->ChipConfig.ulUserChipId = f_pChipOpen->ulUserChipId; + pSharedInfo->ChipConfig.fMultiProcessSystem = (UINT8)( f_pChipOpen->fMultiProcessSystem & 0xFF ); + + pSharedInfo->ChipConfig.usMaxRwAccesses = (UINT16)( f_pChipOpen->ulMaxRwAccesses & 0xFFFF ); + + pSharedInfo->ChipConfig.pbyImageFile = f_pChipOpen->pbyImageFile; + pSharedInfo->ChipConfig.ulImageSize = f_pChipOpen->ulImageSize; + + pSharedInfo->ChipConfig.ulMemClkFreq = f_pChipOpen->ulMemClkFreq; + pSharedInfo->ChipConfig.ulUpclkFreq = f_pChipOpen->ulUpclkFreq; + + pSharedInfo->ChipConfig.byMemoryType = (UINT8)( f_pChipOpen->ulMemoryType & 0xFF ); + pSharedInfo->ChipConfig.byNumMemoryChips = (UINT8)( f_pChipOpen->ulNumMemoryChips & 0xFF ); + pSharedInfo->ChipConfig.ulMemoryChipSize = f_pChipOpen->ulMemoryChipSize; + + pSharedInfo->ChipConfig.usTailDisplacement = (UINT16)( f_pChipOpen->ulTailDisplacement & 0xFFFF ); + pSharedInfo->ChipConfig.fEnableAcousticEcho = (UINT8)( f_pChipOpen->fEnableAcousticEcho & 0xFF ); + /* Resource allocation parameters. */ + if ( f_pChipOpen->fEnableChannelRecording == TRUE && f_pChipOpen->ulMaxChannels == 672 ) + pSharedInfo->ChipConfig.usMaxChannels = (UINT16)( ( f_pChipOpen->ulMaxChannels - 1 ) & 0xFFFF ); + else + pSharedInfo->ChipConfig.usMaxChannels = (UINT16)( f_pChipOpen->ulMaxChannels & 0xFFFF ); + pSharedInfo->ChipConfig.usMaxTsiCncts = (UINT16)( f_pChipOpen->ulMaxTsiCncts & 0xFFFF ); + pSharedInfo->ChipConfig.usMaxBiDirChannels = (UINT16)( f_pChipOpen->ulMaxBiDirChannels & 0xFFFF ); + pSharedInfo->ChipConfig.usMaxConfBridges = (UINT16)( f_pChipOpen->ulMaxConfBridges & 0xFFFF ); + pSharedInfo->ChipConfig.usMaxFlexibleConfParticipants = (UINT16)( f_pChipOpen->ulMaxFlexibleConfParticipants & 0xFFFF ); + pSharedInfo->ChipConfig.usMaxPlayoutBuffers = (UINT16)( f_pChipOpen->ulMaxPlayoutBuffers & 0xFFFF ); + + pSharedInfo->ChipConfig.usMaxPhasingTssts = (UINT16)( f_pChipOpen->ulMaxPhasingTssts & 0xFFFF ); + pSharedInfo->ChipConfig.usMaxAdpcmChannels = (UINT16)( f_pChipOpen->ulMaxAdpcmChannels & 0xFFFF ); + pSharedInfo->ChipConfig.byMaxTdmStreams = (UINT8)( f_pChipOpen->ulMaxTdmStreams & 0xFF ); + pSharedInfo->ChipConfig.fUseSynchTimestamp = (UINT8)( f_pChipOpen->fUseSynchTimestamp & 0xFF ); + for ( i = 0; i < 4; i++ ) + { + pSharedInfo->ChipConfig.ausTimestampTimeslots[ i ] = (UINT16)( f_pChipOpen->aulTimestampTimeslots[ i ] & 0xFFFF ); + pSharedInfo->ChipConfig.ausTimestampStreams[ i ] = (UINT16)( f_pChipOpen->aulTimestampStreams[ i ] & 0xFFFF ); + } + pSharedInfo->ChipConfig.byInterruptPolarity = (UINT8)( f_pChipOpen->ulInterruptPolarity & 0xFF ); + + pSharedInfo->ChipConfig.byTdmSampling = (UINT8)( f_pChipOpen->ulTdmSampling & 0xFF ); + pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF ); + + for ( i = 0; i < cOCT6100_TDM_STREAM_MAX_GROUPS; i++ ) + { + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = cOCT6100_TDM_STREAM_FREQ_16MHZ; + else + pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = f_pChipOpen->aulTdmStreamFreqs[ i ]; + } + + pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF ); + pSharedInfo->ChipConfig.fEnableMemClkOut = (UINT8)( f_pChipOpen->fEnableMemClkOut & 0xFF ); + + /* Add 1 to the circular buffer such that all user requested events can fit in the circular queue. */ + pSharedInfo->ChipConfig.ulSoftToneEventsBufSize = f_pChipOpen->ulSoftToneEventsBufSize + 1; + pSharedInfo->ChipConfig.fEnableExtToneDetection = (UINT8)( f_pChipOpen->fEnableExtToneDetection & 0xFF ); + + if ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE ) + pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = f_pChipOpen->ulSoftBufferPlayoutEventsBufSize + 1; + else + pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = 0; + pSharedInfo->ChipConfig.usMaxRemoteDebugSessions = (UINT16)( f_pChipOpen->ulMaxRemoteDebugSessions & 0xFFFF ); + + pSharedInfo->ChipConfig.fEnableChannelRecording = (UINT8)( f_pChipOpen->fEnableChannelRecording & 0xFF ); + + + + pSharedInfo->ChipConfig.fEnableProductionBist = (UINT8)( f_pChipOpen->fEnableProductionBist & 0xFF ); + pSharedInfo->ChipConfig.ulNumProductionBistLoops = f_pChipOpen->ulNumProductionBistLoops; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInitializeMiscellaneousVariables + +Description: Function where all the various parameters from the API instance + are set to their defaults value. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInitializeMiscellaneousVariables( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 i; + + /* Obtain pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Calculate the total memory available. */ + pSharedInfo->MiscVars.ulTotalMemSize = pSharedInfo->ChipConfig.ulMemoryChipSize * pSharedInfo->ChipConfig.byNumMemoryChips; + + /* Software buffers initialization. */ + + /* Tones */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = 0; + pSharedInfo->SoftBufs.ulToneEventBufferSize = pSharedInfo->ChipConfig.ulSoftToneEventsBufSize; + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0; + + /* Playout */ + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr = 0; + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr = 0; + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize = pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize; + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt = 0; + + /* Set the number of conference bridges opened to zero. */ + pSharedInfo->MiscVars.usNumBridgesOpened = 0; + pSharedInfo->MiscVars.usFirstBridge = cOCT6100_INVALID_INDEX; + + /* Set the H.100 slave mode. */ + pSharedInfo->MiscVars.ulH100SlaveMode = cOCT6100_H100_TRACKA; + + /* Save the Mclk value.*/ + pSharedInfo->MiscVars.ulMclkFreq = pSharedInfo->ChipConfig.ulMemClkFreq; + + /* Init the NLP params. */ + pSharedInfo->MiscVars.usCodepoint = 0; + pSharedInfo->MiscVars.usCpuLsuWritePtr = 0; + + /* Pouch counter not present until TLVs are read. */ + pSharedInfo->DebugInfo.fPouchCounter = FALSE; + pSharedInfo->DebugInfo.fIsIsrCalledField = FALSE; + + /* Initialize the image info parameters */ + pSharedInfo->ImageInfo.fAdaptiveNoiseReduction = FALSE; + pSharedInfo->ImageInfo.fSoutNoiseBleaching = FALSE; + pSharedInfo->ImageInfo.fComfortNoise = FALSE; + pSharedInfo->ImageInfo.fBufferPlayout = TRUE; + pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip = FALSE; + pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip = FALSE; + pSharedInfo->ImageInfo.fNlpControl = FALSE; + pSharedInfo->ImageInfo.fRinAutoLevelControl = FALSE; + pSharedInfo->ImageInfo.fSoutAutoLevelControl = FALSE; + pSharedInfo->ImageInfo.fRinHighLevelCompensation = FALSE; + pSharedInfo->ImageInfo.fSoutHighLevelCompensation = FALSE; + pSharedInfo->ImageInfo.fAlcHlcStatus = FALSE; + pSharedInfo->ImageInfo.fRinDcOffsetRemoval = FALSE; + pSharedInfo->ImageInfo.fSilenceSuppression = FALSE; + pSharedInfo->ImageInfo.fSinDcOffsetRemoval = FALSE; + pSharedInfo->ImageInfo.fToneDisabler = FALSE; + pSharedInfo->ImageInfo.fAdpcm = FALSE; + pSharedInfo->ImageInfo.fTailDisplacement = FALSE; + pSharedInfo->ImageInfo.fConferencing = FALSE; + pSharedInfo->ImageInfo.fConferencingNoiseReduction = FALSE; + pSharedInfo->ImageInfo.fDominantSpeakerEnabled = FALSE; + pSharedInfo->ImageInfo.fAecEnabled = FALSE; + pSharedInfo->ImageInfo.fAcousticEcho = FALSE; + pSharedInfo->ImageInfo.fToneRemoval = FALSE; + + pSharedInfo->ImageInfo.fDefaultErl = FALSE; + pSharedInfo->ImageInfo.fMaxEchoPoint = FALSE; + pSharedInfo->ImageInfo.fNonLinearityBehaviorA = FALSE; + pSharedInfo->ImageInfo.fNonLinearityBehaviorB = FALSE; + pSharedInfo->ImageInfo.fPerChannelTailDisplacement = FALSE; + pSharedInfo->ImageInfo.fPerChannelTailLength = FALSE; + pSharedInfo->ImageInfo.fAfTailDisplacement = FALSE; + pSharedInfo->ImageInfo.fMusicProtection = FALSE; + pSharedInfo->ImageInfo.fAftControl = FALSE; + pSharedInfo->ImageInfo.fSinVoiceDetectedStat = FALSE; + pSharedInfo->ImageInfo.fRinAppliedGainStat = FALSE; + pSharedInfo->ImageInfo.fSoutAppliedGainStat = FALSE; + pSharedInfo->ImageInfo.fListenerEnhancement = FALSE; + pSharedInfo->ImageInfo.fRoutNoiseReduction = FALSE; + pSharedInfo->ImageInfo.fAnrSnrEnhancement = FALSE; + pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation = FALSE; + pSharedInfo->ImageInfo.fRinMute = FALSE; + pSharedInfo->ImageInfo.fSinMute = FALSE; + pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay = FALSE; + pSharedInfo->ImageInfo.fAecTailLength = FALSE; + pSharedInfo->ImageInfo.fMusicProtectionConfiguration= FALSE; + pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents = FALSE; + pSharedInfo->ImageInfo.fRinEnergyStat = FALSE; + pSharedInfo->ImageInfo.fSoutEnergyStat = FALSE; + pSharedInfo->ImageInfo.fDoubleTalkBehavior = FALSE; + pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst = FALSE; + pSharedInfo->ImageInfo.fIdleCodeDetection = TRUE; + pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration = FALSE; + pSharedInfo->ImageInfo.fSinLevel = TRUE; + + pSharedInfo->ImageInfo.usMaxNumberOfChannels = 0; + pSharedInfo->ImageInfo.ulToneProfileNumber = cOCT6100_INVALID_VALUE; + pSharedInfo->ImageInfo.ulBuildId = cOCT6100_INVALID_VALUE; + pSharedInfo->ImageInfo.byImageType = cOCT6100_IMAGE_TYPE_WIRELINE; + pSharedInfo->ImageInfo.usMaxTailDisplacement = 0; + pSharedInfo->ImageInfo.usMaxTailLength = cOCT6100_TAIL_LENGTH_128MS; + pSharedInfo->DebugInfo.ulDebugEventSize = 0x100; + pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents = 32; + pSharedInfo->DebugInfo.ulMatrixBaseAddress = cOCT6100_MATRIX_DWORD_BASE; + pSharedInfo->DebugInfo.ulDebugChanStatsByteSize = cOCT6100_DEBUG_CHAN_STATS_EVENT_BYTE_SIZE; + pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize = cOCT6100_DEBUG_CHAN_STATS_LITE_EVENT_BYTE_SIZE; + pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress= cOCT6100_MATRIX_CHAN_SELECT_DWORD_ADD; + pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress = cOCT6100_MATRIX_TIMESTAMP_DWORD_ADD; + pSharedInfo->DebugInfo.ulMatrixWpBaseAddress = cOCT6100_MATRIX_WRITE_PTR_DWORD_ADD; + pSharedInfo->DebugInfo.ulAfWritePtrByteOffset = 206; + pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize = 4096; + pSharedInfo->DebugInfo.ulAfEventCbByteSize = 0x100000; + + /* Set all tones to invalid. */ + pSharedInfo->ImageInfo.byNumToneDetectors = 0; + for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ ) + { + pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID = cOCT6100_INVALID_VALUE; + pSharedInfo->ImageInfo.aToneInfo[ i ].ulDetectionPort = cOCT6100_INVALID_PORT; + Oct6100UserMemSet( pSharedInfo->ImageInfo.aToneInfo[ i ].aszToneName, 0x00, cOCT6100_TLV_MAX_TONE_NAME_SIZE ); + } + /* Initialize the channel recording info. */ + pSharedInfo->DebugInfo.usRecordChanIndex = pSharedInfo->ChipConfig.usMaxChannels; + pSharedInfo->DebugInfo.usRecordMemIndex = cOCT6100_INVALID_INDEX; + + pSharedInfo->DebugInfo.usCurrentDebugChanIndex = cOCT6100_INVALID_INDEX; + /* Initialize the mixer information. */ + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastBridgeEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastSinCopyEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = cOCT6100_INVALID_INDEX; + + pSharedInfo->MixerInfo.usRecordCopyEventIndex = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usRecordSinEventIndex = cOCT6100_INVALID_INDEX; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCalculateInstanceSizes + +Description: Calculates the amount of memory needed for the instance + structure memory block based on the user's configuration. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pChipOpen Pointer to user chip configuration structure. + +f_pInstSizes Pointer to structure containing the size of memory needed + by all pointers internal to the API instance. The memory + is needed to keep track of the present state of all the + chip's resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCalculateInstanceSizes( + IN OUT tPOCT6100_CHIP_OPEN f_pChipOpen, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulApiInstProcessSpecific; + UINT32 ulTempVar; + UINT32 ulResult; + + /* Start with all instance sizes set to 0. */ + Oct6100UserMemSet( f_pInstSizes, 0x00, sizeof( tOCT6100_API_INSTANCE_SIZES ) ); + + /* All memory sizes are rounded up to the next multiple of 64 bytes. */ + + /*-----------------------------------------------------------------------------*/ + /* Obtain size of static members of API instance. */ + f_pInstSizes->ulApiInstStatic = sizeof( tOCT6100_SHARED_INFO ); + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulApiInstStatic, ulTempVar ) + + /* Calculate memory needed by pointers internal to the API instance. */ + + /*-----------------------------------------------------------------------------*/ + /* Calculate memory needed for the EC channels. */ + ulResult = Oct6100ApiGetChannelsEchoSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Memory needed by the TSI structures. */ + ulResult = Oct6100ApiGetTsiCnctSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Calculate memory needed for the conference bridges. */ + ulResult = Oct6100ApiGetConfBridgeSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Memory needed by the buffer playout structures. */ + ulResult = Oct6100ApiGetPlayoutBufferSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + + + /*-----------------------------------------------------------------------------*/ + /* Memory needed by soft Rx Event buffers. */ + ulResult = Oct6100ApiGetEventsSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Calculate memory needed for phasing tssts. */ + ulResult = Oct6100ApiGetPhasingTsstSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Calculate memory needed for the ADPCM channels. */ + ulResult = Oct6100ApiGetAdpcmChanSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Calculate memory needed for the management of TSSTs. */ + ulResult = Oct6100ApiGetTsstSwSizes( f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Calculate memory needed for the management of the mixer. */ + ulResult = Oct6100ApiGetMixerSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Determine amount of memory needed for memory allocation softwares. These + pieces of software will be responsible for the allocation of the chip's + external memory and API memory. */ + ulResult = Oct6100ApiGetMemorySwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Memory needed for remote debugging sessions. */ + ulResult = Oct6100ApiGetRemoteDebugSwSizes( f_pChipOpen, f_pInstSizes ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Calculate total memory needed by pointers internal to API instance. The + total contains both the process specific portion of the instance + (tOCT6100_INSTANCE_API) and the shared portion (tOCT6100_SHARED_INFO). The + process specific portion will be used only in the case where the host system + is a single-process one. */ + + ulApiInstProcessSpecific = sizeof( tOCT6100_INSTANCE_API ); + mOCT6100_ROUND_MEMORY_SIZE( ulApiInstProcessSpecific, ulTempVar ) + + f_pInstSizes->ulApiInstTotal = + f_pInstSizes->ulChannelList + + f_pInstSizes->ulChannelAlloc + + f_pInstSizes->ulTsiCnctList + + f_pInstSizes->ulTsiCnctAlloc + + f_pInstSizes->ulSoftToneEventsBuffer + + f_pInstSizes->ulSoftBufPlayoutEventsBuffer + + f_pInstSizes->ulBiDirChannelList + + f_pInstSizes->ulBiDirChannelAlloc + + f_pInstSizes->ulConfBridgeList + + f_pInstSizes->ulConfBridgeAlloc + + f_pInstSizes->ulFlexConfParticipantsList + + f_pInstSizes->ulFlexConfParticipantsAlloc + + f_pInstSizes->ulPlayoutBufList + + f_pInstSizes->ulPlayoutBufAlloc + + f_pInstSizes->ulPlayoutBufMemoryNodeList + + + f_pInstSizes->ulCopyEventList + + f_pInstSizes->ulCopyEventAlloc + + f_pInstSizes->ulMixerEventList + + f_pInstSizes->ulMixerEventAlloc + + f_pInstSizes->ulPhasingTsstList + + f_pInstSizes->ulPhasingTsstAlloc + + f_pInstSizes->ulAdpcmChannelList + + f_pInstSizes->ulAdpcmChannelAlloc + + f_pInstSizes->ulConversionMemoryAlloc + + f_pInstSizes->ulTsiMemoryAlloc + + f_pInstSizes->ulRemoteDebugList + + f_pInstSizes->ulRemoteDebugTree + + f_pInstSizes->ulRemoteDebugPktCache + + f_pInstSizes->ulRemoteDebugDataBuf + + f_pInstSizes->ulTsstEntryList + + f_pInstSizes->ulTsstEntryAlloc + + f_pInstSizes->ulTsstAlloc + + f_pInstSizes->ulApiInstStatic + + ulApiInstProcessSpecific; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAllocateInstanceMemory + +Description: Allocates the API instance memory to the various members of + the structure f_pApiInstance according to the sizes contained + in f_pInstSizes. No initialization of this memory is + performed. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pInstSizes Pointer to structure containing the size of memory needed + by all pointers internal to the API instance. The memory + is needed to keep track of the present state of all the + chip's resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAllocateInstanceMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulOffset; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get address of first UINT32 of memory in API instance structure following */ + /* the static members of the API instance structure. */ + ulOffset = f_pInstSizes->ulApiInstStatic; + + /*===================================================================*/ + /* Allocate memory for the echo channels.*/ + pSharedInfo->ulChannelListOfst = ulOffset; + ulOffset += f_pInstSizes->ulChannelList; + pSharedInfo->ulChannelAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulChannelAlloc; + + /*===================================================================*/ + /* Allocate memory for the TSI connections */ + pSharedInfo->ulTsiCnctListOfst = ulOffset; + ulOffset += f_pInstSizes->ulTsiCnctList; + pSharedInfo->ulTsiCnctAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulTsiCnctAlloc; + pSharedInfo->ulMixerEventListOfst = ulOffset; + ulOffset += f_pInstSizes->ulMixerEventList; + pSharedInfo->ulMixerEventAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulMixerEventAlloc; + + pSharedInfo->ulBiDirChannelListOfst = ulOffset; + ulOffset += f_pInstSizes->ulBiDirChannelList; + pSharedInfo->ulBiDirChannelAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulBiDirChannelAlloc; + pSharedInfo->ulCopyEventListOfst = ulOffset; + ulOffset += f_pInstSizes->ulCopyEventList; + pSharedInfo->ulCopyEventAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulCopyEventAlloc; + + /*===================================================================*/ + /* Allocate memory for the conference bridges */ + pSharedInfo->ulConfBridgeListOfst = ulOffset; + ulOffset += f_pInstSizes->ulConfBridgeList; + pSharedInfo->ulConfBridgeAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulConfBridgeAlloc; + + /*===================================================================*/ + /* Allocate memory for the flexible conferencing participants. */ + pSharedInfo->ulFlexConfParticipantListOfst = ulOffset; + ulOffset += f_pInstSizes->ulFlexConfParticipantsList; + pSharedInfo->ulFlexConfParticipantAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulFlexConfParticipantsAlloc; + + /*===================================================================*/ + /* Allocate memory for the play-out buffers */ + pSharedInfo->ulPlayoutBufListOfst = ulOffset; + ulOffset += f_pInstSizes->ulPlayoutBufList; + pSharedInfo->ulPlayoutBufAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulPlayoutBufAlloc; + pSharedInfo->ulPlayoutBufMemoryNodeListOfst = ulOffset; + ulOffset += f_pInstSizes->ulPlayoutBufMemoryNodeList; + + + + /*===================================================================*/ + /* Allocate memory for the phasing TSSTs */ + pSharedInfo->ulPhasingTsstListOfst = ulOffset; + ulOffset += f_pInstSizes->ulPhasingTsstList; + pSharedInfo->ulPhasingTsstAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulPhasingTsstAlloc; + + /*===================================================================*/ + /* Allocate memory for the ADPCM channel */ + pSharedInfo->ulAdpcmChanAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulAdpcmChannelAlloc; + pSharedInfo->ulAdpcmChanListOfst = ulOffset; + ulOffset += f_pInstSizes->ulAdpcmChannelList; + + /*===================================================================*/ + /* Allocate memory for the conversion memory */ + pSharedInfo->ulConversionMemoryAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulConversionMemoryAlloc; + + /*===================================================================*/ + /* Allocate memory for the TSI chariot memory */ + pSharedInfo->ulTsiMemoryAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulTsiMemoryAlloc; + + /*===================================================================*/ + /* Allocate memory for the TSST management */ + pSharedInfo->ulTsstAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulTsstAlloc; + pSharedInfo->ulTsstListOfst = ulOffset; + ulOffset += f_pInstSizes->ulTsstEntryList; + pSharedInfo->ulTsstListAllocOfst = ulOffset; + ulOffset += f_pInstSizes->ulTsstEntryAlloc; + + /*===================================================================*/ + pSharedInfo->SoftBufs.ulToneEventBufferMemOfst = ulOffset; + ulOffset += f_pInstSizes->ulSoftToneEventsBuffer; + + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferMemOfst = ulOffset; + ulOffset += f_pInstSizes->ulSoftBufPlayoutEventsBuffer; + /*===================================================================*/ + pSharedInfo->RemoteDebugInfo.ulSessionListOfst = ulOffset; + ulOffset += f_pInstSizes->ulRemoteDebugList; + + pSharedInfo->RemoteDebugInfo.ulSessionTreeOfst = ulOffset; + ulOffset += f_pInstSizes->ulRemoteDebugTree; + + pSharedInfo->RemoteDebugInfo.ulDataBufOfst = ulOffset; + ulOffset += f_pInstSizes->ulRemoteDebugDataBuf; + + pSharedInfo->RemoteDebugInfo.ulPktCacheOfst = ulOffset; + ulOffset += f_pInstSizes->ulRemoteDebugPktCache; + /*===================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInitializeInstanceMemory + +Description: Initializes the various members of the structure f_pApiInstance + to reflect the current state of the chip and its resources. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInitializeInstanceMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + UINT32 ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize API EC channels. */ + ulResult = Oct6100ApiChannelsEchoSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the API TSI connection structures. */ + ulResult = Oct6100ApiTsiCnctSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the API conference bridges. */ + ulResult = Oct6100ApiConfBridgeSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the API buffer playout structures. */ + ulResult = Oct6100ApiPlayoutBufferSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the API phasing tssts. */ + ulResult = Oct6100ApiPhasingTsstSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the API ADPCM channels. */ + ulResult = Oct6100ApiAdpcmChanSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the external memory management structures. */ + ulResult = Oct6100ApiMemorySwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize TSST management stuctures. */ + ulResult = Oct6100ApiTsstSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the mixer management stuctures. */ + ulResult = Oct6100ApiMixerSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Initialize the remote debugging session management variables. */ + ulResult = Oct6100ApiRemoteDebuggingSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*-----------------------------------------------------------------------------*/ + /* Configure the interrupt registers. */ + ulResult = Oct6100ApiIsrSwInit( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetChipRevisionNum + +Description: Reads the chip's revision number register. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetChipRevisionNum( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + UINT16 usReadData; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get the chip revision number. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.ulReadAddress = cOCT6100_CHIP_ID_REVISION_REG; + ReadParams.pusReadData = &usReadData; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save the info in the API miscellaneous structure. */ + pSharedInfo->MiscVars.usChipId = (UINT16)( usReadData & 0xFF ); + pSharedInfo->MiscVars.usChipRevision = (UINT16)( usReadData >> 8 ); + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiDecodeKeyAndBist + +Description: This function decodes the key and runs the automatic BIST. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiDecodeKeyAndBist( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT16 ausBistData[ 3 ]; + UINT16 usReadData; + UINT32 ulResult; + BOOL fBitEqual; + UINT32 i; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain a local pointer to the chip config structure */ + /* contained in the instance structure. */ + pChipConfig = &pSharedInfo->ChipConfig; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pChipConfig->ulUserChipId; + + /* Set the process context and user chip ID parameters once and for all. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pChipConfig->ulUserChipId; + + /* Write key in CPU internal memory. */ + for(i=0; i<8; i++) + { + WriteParams.ulWriteAddress = 0x150; + WriteParams.usWriteData = 0x0000; + if (( i % 2 ) == 0) + { + WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 2]) << 8; + WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 3]) << 0; + } + else + { + WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 0]) << 8; + WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 1]) << 0; + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x152; + WriteParams.usWriteData = (UINT16)( 0x8000 | i ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Write one in CPU internal memory. */ + for(i=0; i<8; i++) + { + WriteParams.ulWriteAddress = 0x150; + if (i == 0) + { + WriteParams.usWriteData = 0x0001; + } + else + { + WriteParams.usWriteData = 0x0000; + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x152; + WriteParams.usWriteData = (UINT16)( 0x8000 | ( i + 8 )); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Clear memory access registers: */ + WriteParams.ulWriteAddress = 0x150; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x152; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Run BISTs and key decode. */ + WriteParams.ulWriteAddress = 0x160; + WriteParams.usWriteData = 0x0081; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Wait for the key decode PC to clear. */ + ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x160, 0, 0, 100000, &fBitEqual ); + if ( TRUE != fBitEqual ) + return cOCT6100_ERR_FATAL_13; + + /* Read the key valid bit to make sure everything is ok. */ + ReadParams.ulReadAddress = 0x160; + ReadParams.pusReadData = &usReadData; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Either the firmware image was not loaded correctly (from pointer given by user) */ + /* or the channel capacity pins of the chip do not match what the firmware is expecting. */ + if ( ( usReadData & 0x4 ) == 0 ) + return cOCT6100_ERR_OPEN_INVALID_FIRMWARE_OR_CAPACITY_PINS; + + /* Read the result of the internal memory bist. */ + ReadParams.ulReadAddress = 0x110; + ReadParams.pusReadData = &ausBistData[ 0 ]; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ReadParams.ulReadAddress = 0x114; + ReadParams.pusReadData = &ausBistData[ 1 ]; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ReadParams.ulReadAddress = 0x118; + ReadParams.pusReadData = &ausBistData[ 2 ]; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if an error was reported. */ + if (ausBistData[0] != 0x0000 || ausBistData[1] != 0x0000 || ausBistData[2] != 0x0000) + return cOCT6100_ERR_OPEN_INTERNAL_MEMORY_BIST; + + /* Put key decoder in powerdown. */ + WriteParams.ulWriteAddress = 0x160; + WriteParams.usWriteData = 0x008A; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiBootFc2Pll + +Description: Configures the chip's FC2 PLL. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiBootFc2Pll( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 aulWaitTime[ 2 ]; + UINT32 ulResult; + UINT32 ulFc2PllDivisor = 0; + UINT32 ulMtDivisor = 0; + UINT32 ulFcDivisor = 0; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain local pointer to chip configuration structure. */ + pChipConfig = &pSharedInfo->ChipConfig; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pChipConfig->ulUserChipId; + + /* First put the chip and main registers in soft-reset. */ + WriteParams.ulWriteAddress = 0x100; + WriteParams.usWriteData = 0x0; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Select register configuration based on the memory frequency. */ + switch ( f_pApiInstance->pSharedInfo->ChipConfig.ulMemClkFreq ) + { + case 133000000: + ulFc2PllDivisor = 0x1050; + ulMtDivisor = 0x4300; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 672; + pSharedInfo->MiscVars.usMaxH100Speed = 124; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x050B; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0516; + + break; + case 125000000: + ulFc2PllDivisor = 0x0F50; + ulMtDivisor = 0x4300; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 624; + pSharedInfo->MiscVars.usMaxH100Speed = 116; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x04CA; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x04D4; + + break; + case 117000000: + ulFc2PllDivisor = 0x0E50; + ulMtDivisor = 0x4300; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 576; + pSharedInfo->MiscVars.usMaxH100Speed = 108; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0489; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0492; + + break; + case 108000000: + ulFc2PllDivisor = 0x0D50; + ulMtDivisor = 0x4300; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 528; + pSharedInfo->MiscVars.usMaxH100Speed = 99; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0408; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0410; + + break; + case 100000000: + ulFc2PllDivisor = 0x0C50; + ulMtDivisor = 0x4300; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 480; + pSharedInfo->MiscVars.usMaxH100Speed = 91; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x03C8; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x03D0; + + break; + case 92000000: + ulFc2PllDivisor = 0x0B50; + ulMtDivisor = 0x4300; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 432; + pSharedInfo->MiscVars.usMaxH100Speed = 83; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0387; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x038E; + + break; + case 83000000: + ulFc2PllDivisor = 0x0A50; + ulMtDivisor = 0x4300; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 384; + pSharedInfo->MiscVars.usMaxH100Speed = 74; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0346; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x034C; + + break; + case 75000000: + ulFc2PllDivisor = 0x0950; + ulMtDivisor = 0x4200; + ulFcDivisor = 0x4043; + pSharedInfo->MiscVars.usMaxNumberOfChannels = 336; + pSharedInfo->MiscVars.usMaxH100Speed = 64; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + pSharedInfo->MiscVars.usTdmClkBoundary = 0x0306; + else + pSharedInfo->MiscVars.usTdmClkBoundary = 0x030C; + + break; + default: + return cOCT6100_ERR_FATAL_DB; + } + + /* Verify that the max channel is not too big based on the chip frequency. */ + if ( pSharedInfo->ChipConfig.usMaxChannels > pSharedInfo->MiscVars.usMaxNumberOfChannels ) + return cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS; + + /* Setup delay chains. */ + if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) ) + { + /* SDRAM */ + WriteParams.ulWriteAddress = 0x1B0; + WriteParams.usWriteData = 0x1003; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1B2; + WriteParams.usWriteData = 0x0021; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1B4; + WriteParams.usWriteData = 0x4030; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1B6; + WriteParams.usWriteData = 0x0021; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else /* if ( cOCT6100_MEM_TYPE_DDR == pChipConfig->byMemoryType ) */ + { + /* DDR */ + WriteParams.ulWriteAddress = 0x1B0; + WriteParams.usWriteData = 0x201F; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1B2; + WriteParams.usWriteData = 0x0021; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1B4; + WriteParams.usWriteData = 0x1000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1B6; + WriteParams.usWriteData = 0x0021; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* udqs */ + WriteParams.ulWriteAddress = 0x1B8; + WriteParams.usWriteData = 0x1003; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1BA; + WriteParams.usWriteData = 0x0021; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* ldqs */ + WriteParams.ulWriteAddress = 0x1BC; + WriteParams.usWriteData = 0x1000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x1BE; + WriteParams.usWriteData = 0x0021; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x12C; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x12E; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Select fc2pll for fast_clk and mtsclk sources. Select mem_clk_i for afclk. */ + WriteParams.ulWriteAddress = 0x140; + WriteParams.usWriteData = (UINT16)ulMtDivisor; + + if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS ) + WriteParams.usWriteData |= 0x0001; + else + WriteParams.usWriteData |= 0x0004; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x144; + WriteParams.usWriteData = (UINT16)ulFcDivisor; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x13E; + WriteParams.usWriteData = 0x0001; /* Remove reset from above divisors */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Select upclk directly as ref source for fc2pll. */ + WriteParams.ulWriteAddress = 0x134; + if ( pChipConfig->ulUpclkFreq == cOCT6100_UPCLK_FREQ_66_67_MHZ ) + { + WriteParams.usWriteData = 0x0002; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Remove the reset */ + WriteParams.usWriteData = 0x0102; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else /* pChipConfig->ulUpclkFreq == cOCT6100_UPCLK_FREQ_33_33_MHZ */ + { + WriteParams.usWriteData = 0x0001; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Setup fc2pll. */ + WriteParams.ulWriteAddress = 0x132; + WriteParams.usWriteData = (UINT16)ulFc2PllDivisor; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.usWriteData |= 0x02; /* Raise fb divisor reset. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.usWriteData |= 0x80; /* Raise IDDTN signal.*/ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Wait for fc2pll to stabilize. */ + aulWaitTime[ 0 ] = 2000; + aulWaitTime[ 1 ] = 0; + ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Drive mem_clk_o out on proper interface. */ + if ( TRUE == pChipConfig->fEnableMemClkOut ) + { + if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) ) + { + WriteParams.ulWriteAddress = 0x128; + WriteParams.usWriteData = 0x0301; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + if ( pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_DDR || pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS ) + { + WriteParams.ulWriteAddress = 0x12A; + WriteParams.usWriteData = 0x000F; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiProgramFc1Pll + +Description: Configures the chip's FC1 PLL. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiProgramFc1Pll( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 aulWaitTime[ 2 ]; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain local pointer to chip configuration structure. */ + pChipConfig = &pSharedInfo->ChipConfig; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pChipConfig->ulUserChipId; + + /* Programm P/Z bits. */ + WriteParams.ulWriteAddress = 0x130; + + if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS ) + WriteParams.usWriteData = 0x0041; + else + WriteParams.usWriteData = 0x0040; + + WriteParams.usWriteData |= ( pChipConfig->byMemoryType << 8 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Raise FB divisor. */ + WriteParams.usWriteData |= 0x0002; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Raise IDDTN. */ + WriteParams.usWriteData |= 0x0080; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Wait for fc1pll to stabilize. */ + aulWaitTime[ 0 ] = 2000; + aulWaitTime[ 1 ] = 0; + ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Enable all the clock domains to do reset procedure. */ + WriteParams.ulWriteAddress = 0x186; + WriteParams.usWriteData = 0x015F; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + aulWaitTime[ 0 ] = 15000; + aulWaitTime[ 1 ] = 0; + ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiBootFc1Pll + +Description: Boot the chip's FC1 PLL. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiBootFc1Pll( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 aulWaitTime[ 2 ]; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain local pointer to chip configuration structure. */ + pChipConfig = &pSharedInfo->ChipConfig; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pChipConfig->ulUserChipId; + + /* Force bist_clk also (it too is used on resetable flops). */ + WriteParams.ulWriteAddress = 0x160; + WriteParams.usWriteData = 0x0188; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Force all cpu clocks on chariot controllers. */ + WriteParams.ulWriteAddress = 0x182; + WriteParams.usWriteData = 0x0002; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x184; + WriteParams.usWriteData = 0x0202; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + aulWaitTime[ 0 ] = 1000; + aulWaitTime[ 1 ] = 0; + ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Remove the reset on the entire chip and disable CPU access caching. */ + WriteParams.ulWriteAddress = 0x100; + WriteParams.usWriteData = 0x2003; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Remove the bist_clk. It is no longer needed.*/ + WriteParams.ulWriteAddress = 0x160; + WriteParams.usWriteData = 0x0088; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Disable all clks to prepare for bist clock switchover. */ + WriteParams.ulWriteAddress = 0x182; + WriteParams.usWriteData = 0x0001; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x186; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x184; + WriteParams.usWriteData = 0x0101; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Deassert bist_active */ + WriteParams.ulWriteAddress = 0x160; + WriteParams.usWriteData = 0x0008; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Change CPU interface to normal mode (from boot mode). */ + WriteParams.ulWriteAddress = 0x154; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Give a couple of BIST clock cycles to turn off the BIST permanently. */ + WriteParams.ulWriteAddress = 0x160; + WriteParams.usWriteData = 0x0108; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Turn BIST clock off for the last time. */ + WriteParams.ulWriteAddress = 0x160; + WriteParams.usWriteData = 0x0008; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Reset procedure done! */ + + /* Enable mclk for cpu interface and external memory controller. */ + WriteParams.ulWriteAddress = 0x186; + WriteParams.usWriteData = 0x0100; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiLoadImage + +Description: This function writes the firmware image in the external memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiLoadImage( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_BURST_PARAMS BurstParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + UINT32 ulTempPtr; + UINT32 ulNumWrites; + PUINT16 pusSuperArray; + PUINT8 pbyImageFile; + UINT32 ulByteCount = 0; + UINT16 usReadData; + UINT32 ulAddressOfst; + UINT32 i; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Set the process context and user chip ID parameters once and for all. */ + BurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Breakdown image into subcomponents. */ + ulTempPtr = cOCT6100_IMAGE_FILE_BASE + cOCT6100_IMAGE_AF_CST_OFFSET; + + for(i=0;i<cOCT6100_MAX_IMAGE_REGION;i++) + { + pSharedInfo->ImageRegion[ i ].ulPart1Size = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 0 ]; + pSharedInfo->ImageRegion[ i ].ulPart2Size = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 1 ]; + pSharedInfo->ImageRegion[ i ].ulClockInfo = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 2 ]; + pSharedInfo->ImageRegion[ i ].ulReserved = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 3 ]; + + if (i == 0) /* AF constant. */ + { + pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF; + pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0; + + ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 612 ); + } + else if (i == 1) /* NLP image */ + { + pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF; + pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0; + + ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2056 ); + } + else /* Others */ + { + pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF; + ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2064 ); + + pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = ulTempPtr & 0x07FFFFFF; + ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart2Size * 2448 ); + } + } + + /* Write the image in external memory. */ + ulNumWrites = pSharedInfo->ChipConfig.ulImageSize / 2; + + BurstParams.ulWriteAddress = cOCT6100_IMAGE_FILE_BASE; + BurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray; + + pusSuperArray = pSharedInfo->MiscVars.ausSuperArray; + pbyImageFile = pSharedInfo->ChipConfig.pbyImageFile; + + while ( ulNumWrites != 0 ) + { + if ( ulNumWrites >= pSharedInfo->ChipConfig.usMaxRwAccesses ) + BurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses; + else + BurstParams.ulWriteLength = ulNumWrites; + + for ( i = 0; i < BurstParams.ulWriteLength; i++ ) + { + pusSuperArray[ i ] = ( UINT16 )(( pbyImageFile [ ulByteCount++ ]) << 8); + pusSuperArray[ i ] |= ( UINT16 )pbyImageFile [ ulByteCount++ ]; + } + + mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + BurstParams.ulWriteAddress += 2 * BurstParams.ulWriteLength; + ulNumWrites -= BurstParams.ulWriteLength; + } + + /* Perform a serie of reads to make sure the image was correclty written into memory. */ + ulAddressOfst = ( pSharedInfo->ChipConfig.ulImageSize / 2 ) & 0xFFFFFFFE; + while ( ulAddressOfst != 0 ) + { + ReadParams.ulReadAddress = cOCT6100_IMAGE_FILE_BASE + ulAddressOfst; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( (usReadData >> 8) != pbyImageFile[ ulAddressOfst ] ) + return cOCT6100_ERR_OPEN_IMAGE_WRITE_FAILED; + + ulAddressOfst = (ulAddressOfst / 2) & 0xFFFFFFFE; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCpuRegisterBist + +Description: Tests the operation of the CPU registers. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCpuRegisterBist( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + UINT16 i; + UINT16 usReadData; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Assign read data pointer that will be used throughout the function. */ + ReadParams.pusReadData = &usReadData; + + /* Start with a walking bit test. */ + for ( i = 0; i < 16; i ++ ) + { + /* Write at address 0x150.*/ + WriteParams.ulWriteAddress = 0x150; + WriteParams.usWriteData = (UINT16)( 0x1 << i ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write at address 0x180.*/ + WriteParams.ulWriteAddress = 0x180; + WriteParams.usWriteData = (UINT16)( 0x1 << ( 15 - i ) ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now read back the two registers to make sure the acceses were successfull. */ + ReadParams.ulReadAddress = 0x150; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData != ( 0x1 << i ) ) + return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR; + + ReadParams.ulReadAddress = 0x180; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData != ( 0x1 << ( 15 - i ) ) ) + return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR; + } + + /* Write at address 0x150. */ + WriteParams.ulWriteAddress = 0x150; + WriteParams.usWriteData = 0xCAFE; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write at address 0x180. */ + WriteParams.ulWriteAddress = 0x180; + WriteParams.usWriteData = 0xDECA; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now read back the two registers to make sure the acceses were successfull. */ + ReadParams.ulReadAddress = 0x150; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData != 0xCAFE ) + return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR; + + ReadParams.ulReadAddress = 0x180; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData != 0xDECA ) + return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiBootSdram + +Description: Configure and test the SDRAM. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiBootSdram( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + UINT16 usReadData; + UINT16 usWriteData23E; + UINT16 usWriteData230; + UINT32 i; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get local pointer to the chip configuration structure.*/ + pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + usWriteData23E = 0x0000; + usWriteData230 = 0x0000; + + if ( (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) ) + { + /* SDRAM: */ + switch( pChipConfig->ulMemoryChipSize ) + { + case cOCT6100_MEMORY_CHIP_SIZE_8MB: + usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 ); + break; + case cOCT6100_MEMORY_CHIP_SIZE_16MB: + usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 ); + break; + case cOCT6100_MEMORY_CHIP_SIZE_32MB: + usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 ); + break; + case cOCT6100_MEMORY_CHIP_SIZE_64MB: + usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 ); + break; + default: + return cOCT6100_ERR_FATAL_16; + } + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Precharge all banks. */ + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0010; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Program the mode register. */ + usWriteData23E = 0x0030; + WriteParams.usWriteData = usWriteData23E; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0000; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Do CBR refresh (twice) */ + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0040; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else + { + /* DDR: */ + switch( pChipConfig->ulMemoryChipSize ) + { + case cOCT6100_MEMORY_CHIP_SIZE_16MB: + usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 ); + break; + case cOCT6100_MEMORY_CHIP_SIZE_32MB: + usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 ); + break; + case cOCT6100_MEMORY_CHIP_SIZE_64MB: + usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 ); + break; + case cOCT6100_MEMORY_CHIP_SIZE_128MB: + usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 ); + break; + default: + return cOCT6100_ERR_FATAL_17; + } + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Precharge all banks. */ + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0010; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Program DDR mode register. */ + usWriteData23E = 0x4000; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0000; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Program SDR mode register. */ + usWriteData23E = 0x0161; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0000; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Precharge all banks. */ + usWriteData23E = 0xFFFF; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0010; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Do CBR refresh (twice) */ + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0040; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle.*/ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Program SDR mode register. */ + usWriteData23E = 0x0061; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0000; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + usWriteData230 |= 0x0002; + + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x23E; + WriteParams.usWriteData = usWriteData23E; + for ( i = 0; i < 5; i++ ) + { + /* Wait cycle. */ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Set the refresh frequency. */ + WriteParams.ulWriteAddress = 0x242; + WriteParams.usWriteData = 0x0400; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x244; + WriteParams.usWriteData = 0x0200; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x248; + WriteParams.usWriteData = 0x800; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x246; + WriteParams.usWriteData = 0x0012; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Enable the SDRAM and refreshes. */ + usWriteData230 &= 0x000C; + usWriteData230 |= 0x0001; + + WriteParams.ulWriteAddress = 0x230; + WriteParams.usWriteData = usWriteData230; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x246; + WriteParams.usWriteData = 0x0013; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiEnableClocks + +Description: This function will disable clock masking for all the modules + of the chip. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiEnableClocks( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + /* Initialize the process context and user chip ID once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /* Enable tdmie / adpcm mclk clocks. */ + WriteParams.ulWriteAddress = 0x186; + WriteParams.usWriteData = 0x015F; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Configure the DQS register for the DDR memory */ + WriteParams.ulWriteAddress = 0x180; + WriteParams.usWriteData = 0xFF00; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Enable pgsp chariot clocks */ + WriteParams.ulWriteAddress = 0x182; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Enable af/mt chariot clocks */ + WriteParams.ulWriteAddress = 0x184; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiProgramNLP + +Description: This function will write image values to configure the NLP. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiProgramNLP( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + UINT32 ulResult; + UINT16 usReadData; + UINT16 usReadHighData; + BOOL fBitEqual; + UINT32 ulEgoEntry[4]; + UINT32 ulTempAddress; + UINT32 ulAfCpuUp = FALSE; + UINT32 i; + UINT32 ulLoopCounter = 0; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get local pointer to the chip configuration structure.*/ + pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig; + + /* Initialize the process context and user chip ID once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /* Initialize the process context and user chip ID once and for all. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE ) + { + UINT32 ulReadData; + UINT32 ulBitPattern; + UINT32 j, k; + + /* Since the pouch section (256 bytes) will not be tested by the firmware, */ + /* the API has to make sure this section is working correctly. */ + for ( k = 0; k < 2; k ++ ) + { + if ( k == 0 ) + ulBitPattern = 0x1; + else + ulBitPattern = 0xFFFFFFFE; + + for ( j = 0; j < 32; j ++ ) + { + /* Write the DWORDs. */ + for ( i = 0; i < 64; i ++ ) + { + ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, ulBitPattern << j ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Read the DWORDs. */ + for ( i = 0; i < 64; i ++ ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, &ulReadData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if the value matches. */ + if ( ( ulBitPattern << j ) != ulReadData ) + return cOCT6100_ERR_OPEN_PRODUCTION_BIST_POUCH_ERROR; + } + } + } + } + + /* Write the image info in the chip. */ + WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE; + WriteParams.usWriteData = (UINT16)( ( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress >> 16 ) & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + for( i = 0; i < 8; i++ ) + { + if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size != 0 ) + { + WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ); + WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress >> 16 ) & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size != 0 ) + { + WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 4; + WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress >> 16 ) & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 8; + WriteParams.usWriteData = 0x0000; + WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size << 8 ); + WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = 0x0000; + WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulClockInfo << 8 ); + WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulReserved; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Put NLP in config mode. */ + WriteParams.ulWriteAddress = 0x2C2; + WriteParams.usWriteData = 0x160E; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x692; + WriteParams.usWriteData = 0x010A; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Upload the up to 8 NLP pages + 1 AF page (for timing reasons). */ + for ( i = 0; i < pSharedInfo->ImageRegion[ 1 ].ulPart1Size; i++ ) + { + ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * ( i * 2 ), 0x1280, 1024, &(ulEgoEntry[0])); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * (( i * 2 ) + 1 ), 0x1680, 1024, &(ulEgoEntry[2])); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Shift mt chariot memories. This process will complete by the time */ + /* the next LSU transfer is done. */ + WriteParams.ulWriteAddress = 0x692; + WriteParams.usWriteData = 0x010B; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x692, 0, 0, 100000, &fBitEqual ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + if ( TRUE != fBitEqual ) + return cOCT6100_ERR_FATAL_1A; + } + + /* 1 AF page (for timing reasons). */ + ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 0), 0x1280, 512, &(ulEgoEntry[0])); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 1), 0x1480, 512, &(ulEgoEntry[2])); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 2), 0x1680, 512, &(ulEgoEntry[0])); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 3), 0x1880, 512, &(ulEgoEntry[2])); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write constant memory init context position in channel "672" for pgsp. */ + WriteParams.ulWriteAddress = 0x71A; + WriteParams.usWriteData = 0x8000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set fixed PGSP event_in base address to 800 on a 2k boundary */ + WriteParams.ulWriteAddress = 0x716; + WriteParams.usWriteData = 0x800 >> 11; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set fixed PGSP event_out to 0x2C0000h on a 16k boundary */ + WriteParams.ulWriteAddress = 0x71C; + WriteParams.usWriteData = 0x2C0000 >> 14; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Give chariot control of the chip. */ + WriteParams.ulWriteAddress = 0x712; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xC; + ulTempAddress = 0x300000 + 0x0800; + WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 16 ) & 0x07FF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xE; + WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 0 ) & 0xFF00 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write the init PGSP event in place. */ + WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x800; + WriteParams.usWriteData = 0x0200; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x802; + WriteParams.usWriteData = 0x02A0; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Also write the register 710, which tells PGSP how many tones are supported. */ + WriteParams.ulWriteAddress = 0x710; + WriteParams.usWriteData = 0x0000; + WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FA ] << 8; + WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FB ] << 0; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Start both processors in the NLP. */ + WriteParams.ulWriteAddress = 0x373FE; + WriteParams.usWriteData = 0x00FF; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x37BFE; + WriteParams.usWriteData = 0x00FE; /* Tell processor 1 to just go to sleep. */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x37FC6; + WriteParams.usWriteData = 0x8004; /* First PC.*/ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x37FD0; + WriteParams.usWriteData = 0x0002; /* Take out of reset. */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x37FD2; + WriteParams.usWriteData = 0x0002; /* Take out of reset. */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Start processor in the AF. */ + for ( i = 0; i < 16; i ++ ) + { + WriteParams.ulWriteAddress = cOCT6100_POUCH_BASE + ( i * 2 ); + if ( i == 9 ) + { + if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE ) + { + WriteParams.usWriteData = cOCT6100_PRODUCTION_BOOT_TYPE; + } + else + { + WriteParams.usWriteData = cOCT6100_AF_BOOT_TYPE; + } + } + else + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Check if the production BIST mode was requested. */ + if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE ) + { + UINT32 ulTotalElements = 3; + UINT32 ulCrcKey; + UINT32 aulMessage[ 4 ]; + UINT32 ulWriteAddress = 0x20 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS; + + /* Magic key. */ + aulMessage[ 0 ] = 0xCAFECAFE; + /* Memory size. */ + aulMessage[ 1 ] = pSharedInfo->MiscVars.ulTotalMemSize; + /* Loop count. */ + aulMessage[ 2 ] = pSharedInfo->ChipConfig.ulNumProductionBistLoops; + /* CRC initialized. */ + aulMessage[ 3 ] = 0; + + ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCrcKey ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + aulMessage[ 3 ] = ulCrcKey; + + /* Write the message to the external memory. */ + for ( i = 0; i < ulTotalElements + 1; i ++ ) + { + ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulWriteAddress + i * 4, aulMessage[ i ] ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + WriteParams.ulWriteAddress = 0xFFFC6; + WriteParams.usWriteData = 0x1284; /* First PC.*/ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0xFFFD0; + WriteParams.usWriteData = 0x0002; /* Take out of reset. */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + while ( ulAfCpuUp == FALSE ) + { + if ( ulAfCpuUp == FALSE ) + { + ReadParams.ulReadAddress = cOCT6100_POUCH_BASE; + ReadParams.pusReadData = &usReadHighData; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ReadParams.ulReadAddress += 2; + ReadParams.pusReadData = &usReadData; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE ) + { + /* Should read 0x0007 when bisting. */ + if ( ( usReadHighData & 0xFFFF ) == cOCT6100_PRODUCTION_BOOT_TYPE ) + { + /* Verify if the bist has started successfully. */ + if ( ( usReadData & 0xFFFF ) == 0x0002 ) + return cOCT6100_ERR_OPEN_PRODUCTION_BIST_CONF_FAILED; + else if ( ( usReadData & 0xFFFF ) != 0xEEEE ) + return cOCT6100_ERR_OPEN_PRODUCTION_BOOT_FAILED; + + ulAfCpuUp = TRUE; + } + } + else /* if ( pSharedInfo->ChipConfig.fEnableProductionBist == FALSE ) */ + { + if ( ( usReadHighData & 0xFFFF ) == cOCT6100_AF_BOOT_TYPE ) + { + /* Verify if the bist succeeded. */ + if ( ( usReadData & 0xFFFF ) != 0x0000 ) + return cOCT6100_ERR_OPEN_FUNCTIONAL_BIST_FAILED; /* Bad chip. */ + + ulAfCpuUp = TRUE; + } + } + } + + ulLoopCounter++; + + if ( ulLoopCounter == cOCT6100_MAX_LOOP_CPU_TIMEOUT ) + return cOCT6100_ERR_OPEN_AF_CPU_TIMEOUT; + } + + /* Return NLP in operationnal mode. */ + WriteParams.ulWriteAddress = 0x2C2; + WriteParams.usWriteData = 0x060E; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x692; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiSetH100Register + +Description: This function will configure the H.100 registers. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiSetH100Register( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + UINT32 i; + UINT32 ulOffset; + BOOL fAllStreamAt2Mhz = TRUE; + const UINT16 ausAdpcmResetContext[32] = { 0x1100, 0x0220, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000, 0x0100, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0040, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000}; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get local pointer to the chip configuration structure. */ + pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig; + + /* Initialize the process context and user chip ID once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /* Set the Global OE bit. */ + WriteParams.ulWriteAddress = 0x300; + WriteParams.usWriteData = 0x0004; + + /* Set the number of streams. */ + switch( pChipConfig->byMaxTdmStreams ) + { + case 32: + WriteParams.usWriteData |= ( 0 << 3 ); + break; + case 16: + WriteParams.usWriteData |= ( 1 << 3 ); + break; + case 8: + WriteParams.usWriteData |= ( 2 << 3 ); + break; + case 4: + WriteParams.usWriteData |= ( 3 << 3 ); + break; + default: + break; + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Configure the stream frequency. */ + WriteParams.ulWriteAddress = 0x330; + WriteParams.usWriteData = 0x0000; + for ( i = 0; i < (UINT32)(pChipConfig->byMaxTdmStreams / 4); i++) + { + ulOffset = i*2; + switch( pChipConfig->aulTdmStreamFreqs[ i ] ) + { + case cOCT6100_TDM_STREAM_FREQ_2MHZ: + WriteParams.usWriteData |= ( 0x0 << ulOffset ); + break; + case cOCT6100_TDM_STREAM_FREQ_4MHZ: + WriteParams.usWriteData |= ( 0x1 << ulOffset ); + fAllStreamAt2Mhz = FALSE; + break; + case cOCT6100_TDM_STREAM_FREQ_8MHZ: + WriteParams.usWriteData |= ( 0x2 << ulOffset ); + fAllStreamAt2Mhz = FALSE; + break; + default: + break; + } + } + + /* Set the stream to 16 MHz if the fast H.100 mode is selected. */ + if ( pChipConfig->fEnableFastH100Mode == TRUE ) + { + fAllStreamAt2Mhz = FALSE; + WriteParams.usWriteData = 0xFFFF; + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + { + /* Make the chip track both clock A and B to perform fast H.100 mode. */ + WriteParams.ulWriteAddress = 0x322; + WriteParams.usWriteData = 0x0004; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Enable the fast H.100 mode. */ + WriteParams.ulWriteAddress = 0x332; + WriteParams.usWriteData = 0x0003; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + WriteParams.ulWriteAddress = 0x376; + WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usTdmClkBoundary ); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Select delay for early clock (90 and 110). */ + WriteParams.ulWriteAddress = 0x378; + if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + WriteParams.usWriteData = 0x000A; + else + { + /* Set the TDM sampling. */ + if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_RISING_EDGE ) + { + WriteParams.usWriteData = 0x0AF0; + } + else if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE ) + { + WriteParams.usWriteData = 0x0A0F; + } + else /* pSharedInfo->ChipConfig.ulTdmSampling == cOCT6100_TDM_SAMPLE_AT_3_QUARTERS */ + { + WriteParams.usWriteData = 0x0A08; + } + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Protect chip by preventing too rapid timeslot arrival (mclk == 133 MHz). */ + WriteParams.ulWriteAddress = 0x37A; + WriteParams.usWriteData = (UINT16)pSharedInfo->MiscVars.usMaxH100Speed; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Allow H.100 TS to progress. */ + WriteParams.ulWriteAddress = 0x382; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set by-pass mode. */ + WriteParams.ulWriteAddress = 0x50E; + WriteParams.usWriteData = 0x0001; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* TDMIE bits. */ + WriteParams.ulWriteAddress = 0x500; + WriteParams.usWriteData = 0x0003; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write normal ADPCM reset values in ADPCM context 1344. */ + for(i=0;i<32;i++) + { + WriteParams.ulWriteAddress = 0x140000 + ( 0x40 * 1344 ) + ( i * 2 ); + WriteParams.usWriteData = ausAdpcmResetContext[i]; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Make sure delay flops are configured correctly if all streams are at 2 MHz. */ + if ( fAllStreamAt2Mhz == TRUE ) + { + /* Setup H.100 sampling to lowest value. */ + WriteParams.ulWriteAddress = 0x144; + WriteParams.usWriteData = 0x4041; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x378; + WriteParams.usWriteData = 0x0A00; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteMiscellaneousRegisters + +Description: This function will write to various registers to activate the chip. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteMiscellaneousRegisters( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + /* Initialize the process context and user chip ID once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */ + WriteParams.ulWriteAddress = 0x214; + WriteParams.usWriteData = 0x0000; + if ( f_pApiInstance->pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY ) + WriteParams.usWriteData |= 0x4000; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write MT chariot interval */ + WriteParams.ulWriteAddress = 0x2C2; + if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 640 ) + WriteParams.usWriteData = 0x05EA; + else if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 513 ) + WriteParams.usWriteData = 0x0672; + else /* if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels <= 513 ) */ + WriteParams.usWriteData = 0x0750; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write set second part5 time. */ + WriteParams.ulWriteAddress = 0x2C4; + WriteParams.usWriteData = 0x04A0; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write CPU bucket timer to guarantee 200 cycles between each CPU access. */ + WriteParams.ulWriteAddress = 0x234; + WriteParams.usWriteData = 0x0804; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x236; + WriteParams.usWriteData = 0x0100; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCreateSerializeObjects + +Description: Creates a handle to each serialization object used by the API. + + Note that in a multi-process system the user's process context + structure pointer is needed by this function. Thus, the + pointer must be valid. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulUserChipId User chip ID for this serialization object. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCreateSerializeObjects( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulUserChipId ) +{ + tOCT6100_CREATE_SERIALIZE_OBJECT CreateSerObj = { 0, }; + UINT32 ulResult; + CHAR szSerObjName[ 64 ] = "Oct6100ApiXXXXXXXXApiSerObj"; + + + /* Set some parameters of the create structure once and for all. */ + CreateSerObj.pProcessContext = f_pApiInstance->pProcessContext; + CreateSerObj.pszSerialObjName = szSerObjName; + + /*----------------------------------------------------------------------*/ + /* Set the chip ID in the semaphore name. */ + szSerObjName[ 10 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 28 ) & 0xFF ); + szSerObjName[ 11 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 24 ) & 0xFF ); + szSerObjName[ 12 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 20 ) & 0xFF ); + szSerObjName[ 13 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 16 ) & 0xFF ); + szSerObjName[ 14 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 12 ) & 0xFF ); + szSerObjName[ 15 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 8 ) & 0xFF ); + szSerObjName[ 16 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 4 ) & 0xFF ); + szSerObjName[ 17 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 0 ) & 0xFF ); + + ulResult = Oct6100UserCreateSerializeObject( &CreateSerObj ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + f_pApiInstance->ulApiSerObj = CreateSerObj.ulSerialObjHndl; + /*----------------------------------------------------------------------*/ + + + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiDestroySerializeObjects + +Description: Destroy handles to each serialization object used by the API. + + Note that in a multi-process system the user's process context + structure pointer is needed by this function. Thus, the + pointer must be valid. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiDestroySerializeObjects( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tOCT6100_DESTROY_SERIALIZE_OBJECT DestroySerObj; + UINT32 ulResult; + + /* Set some parameters of the create structure once and for all. */ + DestroySerObj.pProcessContext = f_pApiInstance->pProcessContext; + DestroySerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + + ulResult = Oct6100UserDestroySerializeObject( &DestroySerObj ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiRunEgo + +Description: Private function used to communicate with the internal processors. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_fStoreFlag Type of access performed. (Load or Store) +f_ulNumEntry Number of access. +f_aulEntry Array of access to perform. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiRunEgo( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN BOOL f_fStoreFlag, + IN UINT32 f_ulNumEntry, + OUT PUINT32 f_aulEntry ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + UINT32 aulCpuLsuCmd[ 2 ]; + UINT16 usReadData; + UINT32 i; + BOOL fConditionFlag = TRUE; + UINT32 ulLoopCounter = 0; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get local pointer to the chip configuration structure. */ + pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* No more than 2 entries may be requested. */ + if ( f_ulNumEntry > 2 ) + return cOCT6100_ERR_FATAL_1B; + + /* Write the requested entries at address reserved for CPU. */ + for( i = 0; i < f_ulNumEntry; i++ ) + { + WriteParams.ulWriteAddress = cOCT6100_PART1_API_SCRATCH_PAD + ( 0x8 * i ); + WriteParams.usWriteData = (UINT16)(( f_aulEntry[ i * 2 ] >> 16 ) & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( f_aulEntry[ i * 2 ] & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)(( f_aulEntry[ (i * 2) + 1] >> 16 ) & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( f_aulEntry[ (i * 2) + 1] & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Preincrement code point. */ + pSharedInfo->MiscVars.usCodepoint++; + + /* Create DWORD 0 of command. */ + aulCpuLsuCmd[0] = 0x00000000; + if ( f_fStoreFlag == FALSE ) + aulCpuLsuCmd[0] |= 0xC0000000; /* EGO load. */ + else + aulCpuLsuCmd[0] |= 0xE0000000; /* EGO store. */ + + aulCpuLsuCmd[0] |= (f_ulNumEntry - 1) << 19; + aulCpuLsuCmd[0] |= cOCT6100_PART1_API_SCRATCH_PAD; + + /* Create DWORD 1 of command. */ + aulCpuLsuCmd[1] = 0x00000000; + aulCpuLsuCmd[1] |= ( ( cOCT6100_PART1_API_SCRATCH_PAD + 0x10 ) & 0xFFFF ) << 16; + aulCpuLsuCmd[1] |= pSharedInfo->MiscVars.usCodepoint; + + /* Write the EGO command in the LSU CB. */ + WriteParams.ulWriteAddress = cOCT6100_PART1_CPU_LSU_CB_BASE + ((pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7) * 0x8 ); + WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 0 ] >> 16 ) & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 0 ] & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 1 ] >> 16 ) & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 1 ] & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Post increment the write pointer. */ + pSharedInfo->MiscVars.usCpuLsuWritePtr++; + + /* Indicate new write pointer position to HW. */ + WriteParams.ulWriteAddress = cOCT6100_PART1_EGO_REG + 0x5A; + WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Wait for codepoint to be updated before returning. */ + while( fConditionFlag ) + { + ReadParams.ulReadAddress = cOCT6100_PART1_API_SCRATCH_PAD + 0x12; + usReadData = (UINT16)( pSharedInfo->MiscVars.usCodepoint ); + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData == pSharedInfo->MiscVars.usCodepoint ) + fConditionFlag = FALSE; + + ulLoopCounter++; + + if ( ulLoopCounter == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_OPEN_EGO_TIMEOUT; + } + + /* CRC error bit must be zero. */ + ReadParams.ulReadAddress = 0x202; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( ( usReadData & 0x0400 ) != 0 ) + return cOCT6100_ERR_OPEN_CORRUPTED_IMAGE; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCreateEgoEntry + +Description: Private function used to create an access structure to be sent + to the internal processors. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_ulExternalAddress External memory address for the access. +f_ulInternalAddress Which process should receive the command. +f_ulNumBytes Number of bytes associated to the access. +f_aulEntry Array of access to perform. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCreateEgoEntry( + IN UINT32 f_ulExternalAddress, + IN UINT32 f_ulInternalAddress, + IN UINT32 f_ulNumBytes, + OUT UINT32 f_aulEntry[ 2 ] ) +{ + f_aulEntry[0] = 0x80000000; + f_aulEntry[0] |= f_ulExternalAddress & 0x07FFFFFC; + + f_aulEntry[1] = 0x0011C000; + f_aulEntry[1] |= (f_ulNumBytes / 8) << 23; + f_aulEntry[1] |= (f_ulInternalAddress >> 2) & 0x3FFF; + + return cOCT6100_ERR_OK; +} + + + + + + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInitChannels + +Description: This function will initialize all the channels to power down. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInitChannels( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 i; + UINT32 ulResult; + tOCT6100_WRITE_BURST_PARAMS BurstParams; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT16 usReadData; + UINT32 ulTempData; + UINT32 ulBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulMask; + UINT16 ausWriteData[ 4 ]; + UINT16 usLoopCount = 0; + UINT16 usWriteData = 0; + UINT16 usMclkRead; + UINT16 usLastMclkRead; + UINT16 usMclkDiff; + UINT32 ulNumberOfCycleToWait; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + BurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + BurstParams.pusWriteData = ausWriteData; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Verify that the image has enough memory to work correctly. */ + if ( ( pSharedInfo->MiscVars.ulTotalMemSize + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) < pSharedInfo->MemoryMap.ulFreeMemBaseAddress ) + return cOCT6100_ERR_OPEN_INSUFFICIENT_EXTERNAL_MEMORY; + + /* Verify that the tail length is supported by the device.*/ + if ( pSharedInfo->ChipConfig.usTailDisplacement > pSharedInfo->ImageInfo.usMaxTailDisplacement ) + return cOCT6100_ERR_NOT_SUPPORTED_OPEN_TAIL_DISPLACEMENT_VALUE; + + /* Verify that acoustic echo is supported by the device. */ + if ( pSharedInfo->ChipConfig.fEnableAcousticEcho == TRUE && pSharedInfo->ImageInfo.fAcousticEcho == FALSE ) + return cOCT6100_ERR_NOT_SUPPORTED_OPEN_ACOUSTIC_ECHO; + + /* Verify that the image supports all the requested channels. */ + if ( pSharedInfo->ChipConfig.usMaxChannels > pSharedInfo->ImageInfo.usMaxNumberOfChannels ) + return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE; + + /* Max number of channels the image supports + 1 for channel recording, if requested */ + if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE ) + && ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < cOCT6100_MAX_ECHO_CHANNELS ) + && ( pSharedInfo->ChipConfig.usMaxChannels == pSharedInfo->ImageInfo.usMaxNumberOfChannels ) ) + return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE; + + /* Initialize the memory for all required channels. */ + for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ ) + { + /*==============================================================================*/ + /* Configure the Global Static Configuration memory of the channel. */ + + ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( i * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET; + + /* Set the PGSP context base address. */ + ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the PGSP init context base address. */ + ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the RIN circular buffer base address. */ + ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst; + + /* Set the circular buffer size. */ + ulTempData &= 0xFFFFFF00; + if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 ) + return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE; + ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the SIN circular buffer base address. */ + ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the SOUT circular buffer base address. */ + ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst;; + + WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET; + WriteParams.usWriteData = (UINT16)( ulTempData >> 16 ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + } + + /* Put all channel in powerdown mode "3". */ + for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ ) + { + WriteParams.ulWriteAddress = 0x014000 + (i*4) + 0; + WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x014000 + (i*4) + 2; + WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Set the maximum number of channels. */ + WriteParams.ulWriteAddress = 0x690; + if ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < 384 ) + WriteParams.usWriteData = 384; + else + WriteParams.usWriteData = (UINT16)pSharedInfo->ImageInfo.usMaxNumberOfChannels; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set power-dowm TSI chariot memory to silence. */ + for( i = 0; i < 6; i++ ) + { + WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1534 * 2 ); + WriteParams.usWriteData = 0xFF; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1535 * 2 ); + WriteParams.usWriteData = 0xFF; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Remove chariot hold. */ + WriteParams.ulWriteAddress = 0x500; + WriteParams.usWriteData = 0x0001; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + for( usLoopCount = 0; usLoopCount < 4096; usLoopCount++ ) + { + if ( (usLoopCount % 16) < 8 ) + { + usWriteData = (UINT16)((usLoopCount / 16) << 7); + usWriteData |= (UINT16)((usLoopCount % 8)); + } + else + { + usWriteData = (UINT16)((usLoopCount / 16) << 7); + usWriteData |= (UINT16)((usLoopCount % 8)); + usWriteData |= 0x78; + } + + /* Set timeslot pointer. */ + WriteParams.ulWriteAddress = 0x50E; + WriteParams.usWriteData = 0x0003; + WriteParams.usWriteData |= usWriteData << 2; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now read the mclk counter. */ + ReadParams.ulReadAddress = 0x30A; + ReadParams.pusReadData = &usLastMclkRead; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + do { + ReadParams.pusReadData = &usMclkRead; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( ( usLoopCount % 16 ) != 15 ) + { + ulNumberOfCycleToWait = 133; + } + else + { + ulNumberOfCycleToWait = 20000; + } + + /* Evaluate the difference. */ + usMclkDiff = (UINT16)(( usMclkRead - usLastMclkRead ) & 0xFFFF); + + } while( usMclkDiff <= ulNumberOfCycleToWait ); + } + + /* Back to normal mode. */ + WriteParams.ulWriteAddress = 0x50E; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check for CRC errors. */ + ReadParams.pusReadData = &usReadData; + ReadParams.ulReadAddress = 0x202; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( (usReadData & 0x400) != 0x0000 ) + return cOCT6100_ERR_OPEN_CRC_ERROR; + + /* Clear the error rol raised by manually moving the clocks. */ + WriteParams.ulWriteAddress = 0x502; + WriteParams.usWriteData = 0x0002; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*======================================================================*/ + /* Write the tail displacement value in external memory. */ + + ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchTailDisplOfst.byFieldSize; + + ulResult = Oct6100ApiReadDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + &ulTempData ); + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + /* Set the tail displacement. */ + ulTempData |= (pSharedInfo->ChipConfig.usTailDisplacement << ulFeatureBitOffset ); + + /* Write the DWORD where the field is located. */ + ulResult = Oct6100ApiWriteDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + ulTempData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*======================================================================*/ + + + /*======================================================================*/ + /* Clear the pouch counter, if present. */ + + if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize; + + ulResult = Oct6100ApiReadDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + &ulTempData ); + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + /* Clear counter! */ + ulTempData &= (~ulMask); + + /* Write the DWORD where the field is located.*/ + ulResult = Oct6100ApiWriteDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + ulTempData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* The ISR has not yet been called. Set the appropriate bit in external memory. */ + if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize; + + ulResult = Oct6100ApiReadDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + &ulTempData ); + + /* Read previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + /* Toggle the bit to '1'. */ + ulTempData |= 1 << ulFeatureBitOffset; + + /* Write the DWORD where the field is located.*/ + ulResult = Oct6100ApiWriteDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + ulTempData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*======================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInitToneInfo + +Description: This function will parse the software image and retrieve + the information about the tones that it supports. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInitToneInfo( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + UINT32 ulResult; + + PUINT8 pszToneInfoStart = NULL; + PUINT8 pszToneInfoEnd = NULL; + + PUINT8 pszCurrentInfo; + PUINT8 pszNextInfo; + + UINT32 ulToneEventNumber; + UINT32 ulTempValue; + UINT32 ulNumCharForValue; + UINT32 ulUniqueToneId; + UINT32 ulToneNameSize; + UINT32 ulOffset = 0; + + UINT32 i; + + /* Init the tone detector parameter. */ + f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors = 0; + + /* Find the start and the end of the tone info section. */ + if ( f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize > 4096 ) + { + /* For performance reasons, and since the tone detector information */ + /* is always located at the end of the image file, try to start from the end */ + /* of the buffer. */ + + ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 2048; + pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset, + (PUINT8)cOCT6100_TONE_INFO_START_STRING, + f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize ); + + /* Check if the information was found. */ + if ( pszToneInfoStart == NULL ) + { + /* Try again, but giving a larger string to search. */ + ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 4096; + pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset, + (PUINT8)cOCT6100_TONE_INFO_START_STRING, + f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize ); + + } + } + + if ( pszToneInfoStart == NULL ) + { + /* Travel through the whole file buffer. */ + pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile, + (PUINT8)cOCT6100_TONE_INFO_START_STRING, + f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize ); + } + /* We have to return immediatly if no tones are found. */ + if ( pszToneInfoStart == NULL ) + return cOCT6100_ERR_OK; + + /* The end of the tone detector information is after the beginning of the tone information. */ + pszToneInfoEnd = Oct6100ApiStrStr( pszToneInfoStart, + (PUINT8)cOCT6100_TONE_INFO_STOP_STRING, + f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize ); + if ( pszToneInfoEnd == NULL ) + return cOCT6100_ERR_OPEN_TONE_INFO_STOP_TAG_NOT_FOUND; + + /* Find and process all tone events within the region. */ + pszCurrentInfo = Oct6100ApiStrStr( pszToneInfoStart, (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd ); + + while ( pszCurrentInfo != NULL ) + { + /* Skip the string. */ + pszCurrentInfo += ( Oct6100ApiStrLen( (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING ) ); + + /* Extract the number of char used to represent the tone event number ( 1 or 2 ). */ + pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo, (PUINT8)",", pszToneInfoEnd ); + ulNumCharForValue = pszNextInfo - pszCurrentInfo; + + /* Retreive the event number */ + ulToneEventNumber = 0; + for ( i = ulNumCharForValue; i > 0; i-- ) + { + ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulToneEventNumber |= ( ulTempValue << (( i - 1) * 4 ) ); + pszCurrentInfo++; + } + + if ( ulToneEventNumber >= cOCT6100_MAX_TONE_EVENT ) + return cOCT6100_ERR_OPEN_INVALID_TONE_EVENT; + + /* Skip the comma and the 0x. */ + pszCurrentInfo += 3; + + /*======================================================================*/ + /* Retreive the unique tone id. */ + ulUniqueToneId = 0; + for ( i = 0; i < 8; i++ ) + { + ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulOffset = 28 - ( i * 4 ); + ulUniqueToneId |= ( ulTempValue << ulOffset ); + pszCurrentInfo++; + } + + /*======================================================================*/ + + /* Skip the comma. */ + pszCurrentInfo++; + + /* Find out where the next event info starts */ + pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd ); + if ( pszNextInfo == NULL ) + pszNextInfo = pszToneInfoEnd; + + /* Extract the name size. */ + ulToneNameSize = pszNextInfo - pszCurrentInfo - 2; /* - 2 for 0x0D and 0x0A.*/ + + if ( ulToneNameSize > cOCT6100_TLV_MAX_TONE_NAME_SIZE ) + return cOCT6100_ERR_OPEN_INVALID_TONE_NAME; + + /* Copy the tone name into the image info structure. */ + ulResult = Oct6100UserMemCopy( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].aszToneName, + pszCurrentInfo, + ulToneNameSize ); + + + + /* Update the tone info into the image info structure. */ + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID = ulUniqueToneId; + /* Find out the port on which this tone detector is associated. */ + switch( (ulUniqueToneId >> 28) & 0xF ) + { + case 1: + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT; + break; + + case 2: + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SIN; + break; + + case 4: + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SOUT; + break; + + case 5: + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT_SOUT; + break; + + default: + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_INVALID_PORT; + break; + } + + /* Find out where the next event info starts */ + pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd ); + /* Update the current info pointer. */ + pszCurrentInfo = pszNextInfo; + + f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors++; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiExternalMemoryBist + +Description: Tests the functionality of the external memories. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiExternalMemoryBist( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulMemSize = 0; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Test the external memory. */ + switch ( pSharedInfo->ChipConfig.ulMemoryChipSize ) + { + case cOCT6100_MEMORY_CHIP_SIZE_8MB: + ulMemSize = cOCT6100_SIZE_8M; + break; + case cOCT6100_MEMORY_CHIP_SIZE_16MB: + ulMemSize = cOCT6100_SIZE_16M; + break; + case cOCT6100_MEMORY_CHIP_SIZE_32MB: + ulMemSize = cOCT6100_SIZE_32M; + break; + case cOCT6100_MEMORY_CHIP_SIZE_64MB: + ulMemSize = cOCT6100_SIZE_64M; + break; + case cOCT6100_MEMORY_CHIP_SIZE_128MB: + ulMemSize = cOCT6100_SIZE_128M; + break; + default: + return cOCT6100_ERR_FATAL_D9; + } + + ulMemSize *= pSharedInfo->ChipConfig.byNumMemoryChips; + + ulResult = Oct6100ApiRandomMemoryWrite( f_pApiInstance, cOCT6100_EXTERNAL_MEM_BASE_ADDRESS, ulMemSize, 16, 1000, cOCT6100_ERR_OPEN_EXTERNAL_MEM_BIST_FAILED ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Make sure the user I/O functions are working as required. */ + ulResult = Oct6100ApiUserIoTest( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGenerateNumber + +Description: Generate a number using an index. Passing the same + index generates the same number. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. +f_ulIndex Index used to generate the random number. +f_ulDataMask Data mask to apply to generated number. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT16 Oct6100ApiGenerateNumber( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulIndex, + IN UINT32 f_ulDataMask ) +{ + UINT16 usGeneratedNumber; + + usGeneratedNumber = (UINT16)( ( ( ~( f_ulIndex - 1 ) ) & 0xFF00 ) | ( ( f_ulIndex + 1 ) & 0xFF ) ); + + return (UINT16)( usGeneratedNumber & f_ulDataMask ); +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiRandomMemoryWrite + +Description: Writes to f_ulNumAccesses random locations in the indicated + memory and read back to test the operation of that memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. +f_ulMemBase Base address of the memory access. +f_ulMemSize Size of the memory to be tested. +f_ulNumDataBits Number of data bits. +f_ulNumAccesses Number of random access to be perform. +f_ulErrorCode Error code to be returned if the bist fails. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiRandomMemoryWrite( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulMemBase, + IN UINT32 f_ulMemSize, + IN UINT32 f_ulNumDataBits, + IN UINT32 f_ulNumAccesses, + IN UINT32 f_ulErrorCode ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulDataMask; + UINT32 ulResult, i, j; + UINT32 ulBistAddress; + UINT16 usReadData; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Make sure we don't perform more access then the size of our BIST resources. */ + if ( f_ulNumAccesses > 1024 ) + return cOCT6100_ERR_FATAL_C0; + + /* Determine mask for number of data bits. */ + ulDataMask = (1 << f_ulNumDataBits) - 1; + + /* Bist all data pin. */ + for ( i = 0; i < 32; i += 2 ) + { + WriteParams.ulWriteAddress = f_ulMemBase + i * 2; + WriteParams.usWriteData = (UINT16)(0x1 << (i / 2)); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = f_ulMemBase + i * 2 + 2; + WriteParams.usWriteData = (UINT16)(0x1 << (i / 2)); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Read back the data written. */ + for ( i = 0; i < 32; i += 2 ) + { + ReadParams.ulReadAddress = f_ulMemBase + i * 2; + ReadParams.pusReadData = &usReadData; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData != (UINT16)(0x1 << (i / 2)) ) + return f_ulErrorCode; + + ReadParams.ulReadAddress = f_ulMemBase + i * 2 + 2; + ReadParams.pusReadData = &usReadData; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData != (UINT16)(0x1 << (i / 2)) ) + return f_ulErrorCode; + } + + /* Perform the first write at address 0 + mem base */ + j = 0; + WriteParams.ulWriteAddress = f_ulMemBase; + WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask ); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Try each address line of the memory. */ + for ( i = 2, j = 1; i < f_ulMemSize; i <<= 1, j++ ) + { + WriteParams.ulWriteAddress = ( f_ulMemBase + i ); + WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask ); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + for ( i = 0; i < j; i++ ) + { + if ( i > 0 ) + ReadParams.ulReadAddress = ( f_ulMemBase + ( 0x1 << i ) ); + else + ReadParams.ulReadAddress = f_ulMemBase; + ReadParams.pusReadData = &usReadData; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData != Oct6100ApiGenerateNumber( f_pApiInstance, i, ulDataMask ) ) + return f_ulErrorCode; + } + + /* Write to random addresses of the memory. */ + for ( i = 0; i < f_ulNumAccesses; i++ ) + { + ulBistAddress = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16; + ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ); + ulBistAddress &= f_ulMemSize - 2; + ulBistAddress |= f_ulMemBase; + + WriteParams.ulWriteAddress = ulBistAddress; + WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + for ( i = 0; i < f_ulNumAccesses; i++ ) + { + ulBistAddress = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16; + ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ); + ulBistAddress &= f_ulMemSize - 2; + ulBistAddress |= f_ulMemBase; + + ReadParams.ulReadAddress = ulBistAddress; + ReadParams.pusReadData = &usReadData; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( ( usReadData & ulDataMask ) != ( Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) & ulDataMask ) ) + return f_ulErrorCode; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiUserIoTest + +Description: This function will verify the correct functionality of + the following user functions: + + - Oct6100UserDriverWriteBurstApi + - Oct6100UserDriverWriteSmearApi + - Oct6100UserDriverReadBurstApi + + The Oct6100UserDriverWriteApi and Oct6100UserDriverReadApi + functions do not need to be tested here as this has be done in + the external memory bisting function above. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiUserIoTest( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_BURST_PARAMS WriteBurstParams; + tOCT6100_WRITE_SMEAR_PARAMS WriteSmearParams; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_READ_BURST_PARAMS ReadBurstParams; + UINT32 ulResult, i; + UINT16 usReadData; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Set the process context and user chip ID parameters once and for all. */ + WriteBurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + /* Test what the user has specified is the maximum that can be used for a burst. */ + WriteBurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses; + WriteBurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray; + + WriteSmearParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteSmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + /* Test what the user has specified is the maximum that can be used for a smear. */ + WriteSmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + /* Test what the user has specified is the maximum that can be used for a burst. */ + ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses; + ReadBurstParams.pusReadData = pSharedInfo->MiscVars.ausSuperArray; + + + /*======================================================================*/ + /* Write burst check. */ + + WriteBurstParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS; + /* Set the random data to be written. */ + for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ ) + { + WriteBurstParams.pusWriteData[ i ] = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ); + } + mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Read back pattern using simple read function and make sure we are reading what's expected. */ + ReadParams.ulReadAddress = WriteBurstParams.ulWriteAddress; + for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ ) + { + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if the data matches. */ + if ( usReadData != WriteBurstParams.pusWriteData[ i ] ) + { + /* The values do not match. Something seems to be wrong with the WriteBurst user function. */ + return cOCT6100_ERR_OPEN_USER_WRITE_BURST_FAILED; + } + + /* Next address to check. */ + ReadParams.ulReadAddress += 2; + } + + /*======================================================================*/ + + + /*======================================================================*/ + /* Write smear check. */ + + WriteSmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + ( WriteBurstParams.ulWriteLength * 2 ); + /* Set the random data to be written. */ + WriteSmearParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, Oct6100ApiRand( 0xFFFF ), 0xFFFF ); + mOCT6100_DRIVER_WRITE_SMEAR_API( WriteSmearParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Read back pattern using simple read function and make sure we are reading what's expected. */ + ReadParams.ulReadAddress = WriteSmearParams.ulWriteAddress; + for ( i = 0; i < WriteSmearParams.ulWriteLength; i++ ) + { + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if the data matches. */ + if ( usReadData != WriteSmearParams.usWriteData ) + { + /* The values do not match. Something seems to be wrong with the WriteSmear user function. */ + return cOCT6100_ERR_OPEN_USER_WRITE_SMEAR_FAILED; + } + + /* Next address to check. */ + ReadParams.ulReadAddress += 2; + } + + /*======================================================================*/ + + + /*======================================================================*/ + /* Read burst check. */ + + /* First check with what the WriteBurst function wrote. */ + ReadBurstParams.ulReadAddress = WriteBurstParams.ulWriteAddress; + mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + for ( i = 0; i < ReadBurstParams.ulReadLength; i++ ) + { + /* Check if the data matches. */ + if ( ReadBurstParams.pusReadData[ i ] != Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) ) + { + /* The values do not match. Something seems to be wrong with the ReadBurst user function. */ + return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED; + } + } + + /* Then check with what the WriteSmear function wrote. */ + ReadBurstParams.ulReadAddress = WriteSmearParams.ulWriteAddress; + mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + for ( i = 0; i < ReadBurstParams.ulReadLength; i++ ) + { + /* Check if the data matches. */ + if ( ReadBurstParams.pusReadData[ i ] != WriteSmearParams.usWriteData ) + { + /* The values do not match. Something seems to be wrong with the ReadBurst user function. */ + return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED; + } + } + + /*======================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiExternalMemoryInit + +Description: Initialize the external memory before uploading the image. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiExternalMemoryInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_SMEAR_PARAMS SmearParams; + UINT32 ulTotalWordToWrite; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + SmearParams.pProcessContext = f_pApiInstance->pProcessContext; + + SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Clear the first part of the memory. */ + ulTotalWordToWrite = 0x400; + SmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS; + + while ( ulTotalWordToWrite != 0 ) + { + if ( ulTotalWordToWrite >= pSharedInfo->ChipConfig.usMaxRwAccesses ) + SmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses; + else + SmearParams.ulWriteLength = ulTotalWordToWrite; + + SmearParams.usWriteData = 0x0; + + mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update the number of words to write. */ + ulTotalWordToWrite -= SmearParams.ulWriteLength; + /* Update the address. */ + SmearParams.ulWriteAddress += ( SmearParams.ulWriteLength * 2 ); + } + + /* Clear the TLV flag.*/ + ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_TLV_BASE, 0x0 ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInitMixer + +Description: This function will initialize the mixer memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInitMixer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_BURST_PARAMS BurstParams; + UINT16 ausWriteData[ 4 ]; + UINT32 ulResult; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + BurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + BurstParams.pusWriteData = ausWriteData; + /*======================================================================*/ + /* Initialize the mixer memory if required. */ + if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE ) + { + /* Modify the mixer pointer by adding the record event into the link list. */ + pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex; + pSharedInfo->MixerInfo.usLastSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex; + pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex; + pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex; + + /* Program the Sin copy event. */ + BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordSinEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + BurstParams.ulWriteLength = 4; + + ausWriteData[ 0 ] = 0x0000; + ausWriteData[ 1 ] = 0x0000; + ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node.*/ + ausWriteData[ 3 ] = 0x0000; + + mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Program the Sout copy event. */ + BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + BurstParams.ulWriteLength = 4; + + ausWriteData[ 0 ] = 0x0000; + ausWriteData[ 1 ] = 0x0000; + ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordSinEventIndex & 0x7FF); + ausWriteData[ 3 ] = 0x0000; + + mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Configure the head node. */ + BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE; + BurstParams.ulWriteLength = 4; + + ausWriteData[ 0 ] = 0x0000; + ausWriteData[ 1 ] = 0x0000; + ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordCopyEventIndex & 0x7FF); + ausWriteData[ 3 ] = 0x0000; + + mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Init the mixer pointer */ + pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex; + } + else + { + /* Configure the head node. */ + BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE; + BurstParams.ulWriteLength = 4; + + ausWriteData[ 0 ] = 0x0000; + ausWriteData[ 1 ] = 0x0000; + ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node. */ + ausWriteData[ 3 ] = 0x0000; + + mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Configure the tail node. */ + BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + 0x10; + BurstParams.ulWriteLength = 4; + + ausWriteData[ 0 ] = 0x0000; + ausWriteData[ 1 ] = 0x0000; + ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_HEAD_NODE & 0x7FF); /* Head node. */ + ausWriteData[ 3 ] = 0x0000; + + mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInitRecordResources + +Description: This function will initialize the resources required to + perform recording on a debug channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInitRecordResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulResult; + + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Check if recording is enabled. */ + if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE ) + return cOCT6100_ERR_OK; + + if ( pSharedInfo->DebugInfo.usRecordMemIndex == cOCT6100_INVALID_INDEX ) + return cOCT6100_ERR_NOT_SUPPORTED_OPEN_DEBUG_RECORD; + + /* Check the provided recording memory index within the SSPX. */ + if ( pSharedInfo->DebugInfo.usRecordMemIndex != ( pSharedInfo->ImageInfo.usMaxNumberOfChannels - 1 ) ) + return cOCT6100_ERR_OPEN_DEBUG_MEM_INDEX; + + /* Reserve the TSI entries for the channel. */ + ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Open the debug channel. */ + ulResult = Oct6100ApiDebugChannelOpen( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiProductionCrc + +Description: This function calculates the crc for a production BIST + message. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pulMessage Message to be exchanged with the firmware. The CRC + will be calculated on this. +f_ulMessageLength Length of the message to be exchanged. This value + does not include the CRC value at the end +f_pulCrcResult Resulting calculated CRC value. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiProductionCrc( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN PUINT32 f_pulMessage, + IN UINT32 f_ulMessageLength, + OUT PUINT32 f_pulCrcResult ) +{ + UINT32 ulWidth = 32; + UINT32 ulKey, i, j; + UINT32 ulRemainder = 0; + + /* CRC the message. */ + ulRemainder = f_pulMessage[ f_ulMessageLength - 1 ]; + for ( j = f_ulMessageLength - 1; j != 0xFFFFFFFF ; j-- ) + { + for ( i = 0; i < ulWidth; i++ ) + { + if ( ( ( ulRemainder >> 0x1F ) & 0x1 ) == 0x1 ) + { + /* Division is by something meaningful */ + ulKey = 0x8765DCBA; + } + else + { + /* Remainder is less than our divisor */ + ulKey = 0; + } + ulRemainder = ulRemainder ^ ulKey; + + ulRemainder = ulRemainder << 1; + if ( j != 0 ) + { + ulRemainder = ulRemainder | ( ( f_pulMessage[ j - 1 ] ) >> ( 0x1F - i ) ); + } + } + } + + *f_pulCrcResult = ulRemainder; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_mixer.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the functions used to manage the allocation of mixer + blocks in memories. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 42 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" + +#include "apilib/octapi_llman.h" +#include "oct6100api/oct6100_apiud.h" +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_mixer_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_mixer_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_mixer_priv.h" + +/**************************** PRIVATE FUNCTIONS ****************************/ + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetMixerSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of mixer events. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- + +f_pOpenChip User chip configuration. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetMixerSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Calculate the API memory required for the resource entry lists. */ + f_pInstSizes->ulMixerEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT ); + + /* Calculate memory needed for mixers entry allocation. */ + ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_MIXER_EVENTS, &f_pInstSizes->ulMixerEventAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1D; + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventAlloc, ulTempVar ) + + + f_pInstSizes->ulCopyEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_COPY_EVENT ); + + ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_MIXER_EVENTS, &f_pInstSizes->ulCopyEventAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1D; + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventAlloc, ulTempVar ) + + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReserveMixerEventEntry + +Description: Reserves a free entry in the mixer event list. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pusEventIndex List entry reserved. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReserveMixerEventEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusEventIndex ) +{ + PVOID pMixerEventAlloc; + UINT32 ulResult; + UINT32 ulEventIndex; + + mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc ) + + ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT ) + return cOCT6100_ERR_MIXER_ALL_MIXER_EVENT_ENTRY_OPENED; + else + return cOCT6100_ERR_FATAL_2B; + } + + *f_pusEventIndex = (UINT16)( ulEventIndex & 0xFFFF ); + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiMixerSwInit + +Description: Initializes all elements of the instance structure associated + to the mixer events. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This mixer is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiMixerSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_MIXER_EVENT pMixerEventList; + PVOID pMixerEventAlloc; + PVOID pCopyEventAlloc; + UINT32 ulTempVar; + UINT32 ulResult; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /*===================================================================*/ + /* Initialize the mixer event list. */ + mOCT6100_GET_MIXER_EVENT_LIST_PNT( pSharedInfo, pMixerEventList ); + + /* Initialize the mixer event allocation software to "all free". */ + Oct6100UserMemSet( pMixerEventList, 0x00, cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT )); + + mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( pSharedInfo, pMixerEventAlloc ) + + ulResult = OctapiLlmAllocInit( &pMixerEventAlloc, cOCT6100_MAX_MIXER_EVENTS ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1F; + + /* Now reserve the first entry as the first node. */ + ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_20; + } + + /* Check that we obtain the first event. */ + if ( ulTempVar != 0 ) + return cOCT6100_ERR_FATAL_21; + + /* Now reserve the tail entry. */ + ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_AA; + } + /* Check that we obtain the first event. */ + if ( ulTempVar != 1 ) + return cOCT6100_ERR_FATAL_AB; + + /* Program the head node. */ + pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].fReserved = TRUE; + pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usNextEventPtr = cOCT6100_MIXER_TAIL_NODE; + pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + /* Program the tail node. */ + pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].fReserved = TRUE; + pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].usNextEventPtr = cOCT6100_INVALID_INDEX; + pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + /* Now reserve the entry used for channel recording if the feature is enabled. */ + if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE ) + { + UINT32 ulAllocIndex; + + /* Reserve an entry to copy the desire SOUT signal to the SIN signal of the recording channel. */ + ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulAllocIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_90; + } + + pSharedInfo->MixerInfo.usRecordCopyEventIndex = (UINT16)( ulAllocIndex & 0xFFFF ); + + /* Reserve an entry to copy the saved SIN signal of the debugged channel into it's original location. */ + ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulAllocIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_90; + } + + pSharedInfo->MixerInfo.usRecordSinEventIndex = (UINT16)( ulAllocIndex & 0xFFFF ); + + /* Configure the SIN event. */ + pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].fReserved = TRUE; + pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].usNextEventPtr = cOCT6100_MIXER_TAIL_NODE; + pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + /* Configure the SOUT copy event. */ + pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].fReserved = TRUE; + pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].usNextEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex; + pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + /* Program the head node. */ + pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usNextEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex; + } + + /* Initialize the copy event list. */ + mOCT6100_GET_COPY_EVENT_ALLOC_PNT( pSharedInfo, pCopyEventAlloc ) + + ulResult = OctapiLlmAllocInit( &pCopyEventAlloc, cOCT6100_MAX_MIXER_EVENTS ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_B4; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiMixerEventAdd + +Description: This function adds a mixer event event to the list of events + based on the event type passed to the function. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. +f_usEventIndex Index of the event within the API's mixer event list. +f_usEventType Type of mixer event. +f_usDestinationChanIndex Index of the destination channel within the API's + channel list. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiMixerEventAdd( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEventIndex, + IN UINT16 f_usEventType, + IN UINT16 f_usDestinationChanIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_MIXER_EVENT pCurrentEventEntry; + tPOCT6100_API_MIXER_EVENT pTempEventEntry; + tPOCT6100_API_CHANNEL pDestinationEntry; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + UINT16 usTempEventIndex; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Get a pointer to the event entry. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex ); + + /* Get a pointer to the destination channel entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, f_usDestinationChanIndex ); + + /* Now proceed according to the event type. */ + switch ( f_usEventType ) + { + case cOCT6100_EVENT_TYPE_SOUT_COPY: + + /* Now insert the Sin copy event */ + if ( pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr == cOCT6100_INVALID_INDEX ) + { + /* The only node in the list before the point where the node needs to */ + /* be inserted is the head node. */ + usTempEventIndex = cOCT6100_MIXER_HEAD_NODE; + + /* This node will be the first one in the Sout copy section. */ + pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = f_usEventIndex; + pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = f_usEventIndex; + } + else /* pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr != cOCT6100_INVALID_INDEX */ + { + usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr; + pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = f_usEventIndex; + } + + break; + + case cOCT6100_EVENT_TYPE_SIN_COPY: + + /* Now insert the Sin copy event. */ + if ( pSharedInfo->MixerInfo.usFirstSinCopyEventPtr == cOCT6100_INVALID_INDEX ) + { + /* This is the first Sin copy event. We must find the event that comes before */ + /* the event we want to add. First let's check for a bridge event. */ + if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == cOCT6100_INVALID_INDEX ) + { + /* No event in the bridge section, now let's check in the Sout copy section. */ + if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX ) + { + /* The only node in the list then is the head node. */ + usTempEventIndex = cOCT6100_MIXER_HEAD_NODE; + } + else + { + usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr; + } + } + else + { + usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr; + } + + /* This node will be the first one in the Sin copy section. */ + pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = f_usEventIndex; + pSharedInfo->MixerInfo.usLastSinCopyEventPtr = f_usEventIndex; + } + else /* pSharedInfo->MixerInfo.usFirstSinCopyEventPtr != cOCT6100_INVALID_INDEX */ + { + usTempEventIndex = pSharedInfo->MixerInfo.usLastSinCopyEventPtr; + pSharedInfo->MixerInfo.usLastSinCopyEventPtr = f_usEventIndex; + } + + break; + + default: + return cOCT6100_ERR_FATAL_AF; + + } + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex ); + + /*=======================================================================*/ + /* Program the Copy event. */ + + /* Set the Copy event first. */ + pCurrentEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_COPY; + pCurrentEventEntry->usNextEventPtr = pTempEventEntry->usNextEventPtr; + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + WriteParams.usWriteData = pCurrentEventEntry->usNextEventPtr; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Modify the previous node. */ + + /* Set the last Sub-store entry. */ + pTempEventEntry->usNextEventPtr = f_usEventIndex; + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + WriteParams.usWriteData = f_usEventIndex; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /* Save the destination channel index, needed when removing the event from the mixer. */ + pCurrentEventEntry->usDestinationChanIndex = f_usDestinationChanIndex; + + /* Mark the entry as reserved. */ + pCurrentEventEntry->fReserved = TRUE; + + /* Increment the event count on that particular destination channel */ + pDestinationEntry->usMixerEventCnt++; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiMixerEventRemove + +Description: This function removes a mixer event event from the list of events based + on the event type passed to the function. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_usEventIndex Index of event within the API's mixer event list. +f_usEventType Type of mixer event. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiMixerEventRemove( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEventIndex, + IN UINT16 f_usEventType ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_MIXER_EVENT pCurrentEventEntry; + tPOCT6100_API_MIXER_EVENT pTempEventEntry; + tPOCT6100_API_CHANNEL pDestinationEntry; + tOCT6100_WRITE_BURST_PARAMS BurstWriteParams; + tOCT6100_WRITE_PARAMS WriteParams; + BOOL fFirstSinCopyEvent = FALSE; + UINT32 ulResult; + UINT16 usTempEventIndex; + UINT32 ulLoopCount = 0; + UINT16 ausWriteData[ 4 ] = { 0 }; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + BurstWriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + BurstWriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + BurstWriteParams.pusWriteData = ausWriteData; + BurstWriteParams.ulWriteLength = 4; + + /* Get a pointer to the event entry. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex ); + + /* Get the pointer to the channel entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, pCurrentEventEntry->usDestinationChanIndex ); + + /* Now proceed according to the event type. */ + switch ( f_usEventType ) + { + case cOCT6100_EVENT_TYPE_SOUT_COPY: + + if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr ) + { + usTempEventIndex = cOCT6100_MIXER_HEAD_NODE; + } + else + { + /* Now insert the Sin copy event. */ + usTempEventIndex = pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr; + } + + /* Find the copy entry before the entry to remove. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex ); + + while( pTempEventEntry->usNextEventPtr != f_usEventIndex ) + { + usTempEventIndex = pTempEventEntry->usNextEventPtr; + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex ); + + ulLoopCount++; + if ( ulLoopCount == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_FATAL_B2; + } + + /*=======================================================================*/ + /* Update the global mixer pointers. */ + if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr ) + { + if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr ) + { + /* This event was the only of the list.*/ + pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = cOCT6100_INVALID_INDEX; + } + else + { + pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = pCurrentEventEntry->usNextEventPtr; + } + } + else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr ) + { + pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = usTempEventIndex; + } + /*=======================================================================*/ + + break; + + + case cOCT6100_EVENT_TYPE_SIN_COPY: + + if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr ) + { + fFirstSinCopyEvent = TRUE; + + if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr != cOCT6100_INVALID_INDEX ) + { + usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr; + } + else if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr != cOCT6100_INVALID_INDEX ) + { + usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr; + } + else + { + usTempEventIndex = cOCT6100_MIXER_HEAD_NODE; + } + } + else + { + /* Now insert the Sin copy event. */ + usTempEventIndex = pSharedInfo->MixerInfo.usFirstSinCopyEventPtr; + } + + /* Find the copy entry before the entry to remove. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex ); + + /* If we are not the first event of the Sin copy list. */ + if ( fFirstSinCopyEvent == FALSE ) + { + while( pTempEventEntry->usNextEventPtr != f_usEventIndex ) + { + usTempEventIndex = pTempEventEntry->usNextEventPtr; + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex ); + + ulLoopCount++; + if ( ulLoopCount == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_FATAL_B1; + } + } + + /*=======================================================================*/ + /* Update the global mixer pointers. */ + if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr ) + { + if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr ) + { + /* This event was the only of the list. */ + pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastSinCopyEventPtr = cOCT6100_INVALID_INDEX; + } + else + { + pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pCurrentEventEntry->usNextEventPtr; + } + } + else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr ) + { + pSharedInfo->MixerInfo.usLastSinCopyEventPtr = usTempEventIndex; + } + /*=======================================================================*/ + + break; + + default: + return cOCT6100_ERR_FATAL_B0; + + } + + /*=======================================================================*/ + /* Modify the previous event. */ + + pTempEventEntry->usNextEventPtr = pCurrentEventEntry->usNextEventPtr; + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + WriteParams.usWriteData = pTempEventEntry->usNextEventPtr; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Clear the current event. */ + + BurstWriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + mOCT6100_DRIVER_WRITE_BURST_API( BurstWriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Decrement the mixer event count active on that channel. */ + pDestinationEntry->usMixerEventCnt--; + + /*=======================================================================*/ + + + /*=======================================================================*/ + + /* This index of this channel is not valid anymore! */ + pCurrentEventEntry->usDestinationChanIndex = cOCT6100_INVALID_INDEX; + + /* Mark this entry as free. */ + pCurrentEventEntry->fReserved = FALSE; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetFreeMixerEventCnt + +Description: Retrieve the number of events left in the list. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pulFreeEventCnt How many events left. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetFreeMixerEventCnt( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT32 f_pulFreeEventCnt ) +{ + PVOID pMixerEventAlloc; + UINT32 ulResult; + UINT32 ulAllocatedEvents; + UINT32 ulAvailableEvents; + + mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc ) + + ulResult = OctapiLlmAllocInfo( pMixerEventAlloc, &ulAllocatedEvents, &ulAvailableEvents ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_E8; + + /* Return number of free events. */ + *f_pulFreeEventCnt = ulAvailableEvents; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteDword + +Description: Write a DWORD at specified address in external memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulAddress DWORD address where to write. +f_ulWriteData DWORD data to write. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteDword( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulAddress, + IN UINT32 f_ulWriteData ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /* Write the first 16 bits. */ + WriteParams.ulWriteAddress = f_ulAddress; + WriteParams.usWriteData = (UINT16)((f_ulWriteData >> 16) & 0xFFFF); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write the last word. */ + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)(f_ulWriteData & 0xFFFF); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseTsiMemEntry + +Description: Releases a TSI chariot memory entry specified. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_usTsiMemIndex Index reserved in the TSI chariot memory. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseTsiMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usTsiMemIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pTsiMemAlloc; + UINT32 ulResult; + UINT32 ulIndex; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Check if the entry programmed is greater then the timestamp entries. */ + if ( f_usTsiMemIndex > cOCT6100_TSST_CONTROL_TIMESTAMP_BASE_ENTRY ) + ulIndex = f_usTsiMemIndex - cOCT6100_TSI_MEM_FOR_TIMESTAMP; + else + ulIndex = f_usTsiMemIndex; + + /* Check if the entry programmed is greater then the phasing TSST entries. */ + if ( ulIndex > cOCT6100_TSST_CONTROL_PHASING_TSST_BASE_ENTRY ) + ulIndex -= pSharedInfo->ChipConfig.usMaxPhasingTssts; + + mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc ) + + ulResult = OctapiLlmAllocDealloc( pTsiMemAlloc, ulIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_93; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseMixerEventEntry + +Description: Release an entry from the mixer event list. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_usEventIndex List entry reserved. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseMixerEventEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEventIndex ) +{ + PVOID pMixerEventAlloc; + UINT32 ulResult; + + mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc ) + + ulResult = OctapiLlmAllocDealloc( pMixerEventAlloc, f_usEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_2C; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWaitForPcRegisterBit + +Description: Polls the specified PC register bit. The function exits once + the bit is cleared by hardware, or when the specified timeout + period has been expired. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulPcRegAdd Address of the register containing the PC bit. +f_ulPcBitNum Number of the PC bit within the register. +f_ulValue Expected value of the bit. +f_ulTimeoutUs The timeout period, in usec. +f_pfBitEqual Pointer to the result of the bit comparison. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWaitForPcRegisterBit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulPcRegAdd, + IN UINT32 f_ulPcBitNum, + IN UINT32 f_ulValue, + IN UINT32 f_ulTimeoutUs, + OUT PBOOL f_pfBitEqual ) +{ + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_GET_TIME StartTime; + tOCT6100_GET_TIME TimeoutTime; + tOCT6100_GET_TIME CurrentTime; + UINT32 ulResult; + UINT16 usReadData; + BOOL fConditionFlag = TRUE; + + /* Copy the process context. */ + StartTime.pProcessContext = f_pApiInstance->pProcessContext; + CurrentTime.pProcessContext = f_pApiInstance->pProcessContext; + + /* Get the current system time. */ + ulResult = Oct6100UserGetTime( &StartTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Mark the bit as not being equal, for now. */ + *f_pfBitEqual = FALSE; + + /* Determine the time at which the timeout has expired. */ + ulResult = octapi_lm_add( + StartTime.aulWallTimeUs, 1, + &f_ulTimeoutUs, 0, + TimeoutTime.aulWallTimeUs, 1 ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Prepare read structure. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.ulReadAddress = f_ulPcRegAdd; + ReadParams.pusReadData = &usReadData; + + /* Read the PC bit while the timeout period hasn't expired. */ + while ( fConditionFlag ) + { + /* Read the current time again to check for timeout. */ + ulResult = Oct6100UserGetTime( &CurrentTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100UserDriverReadApi( &ReadParams ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( ( UINT16 )((usReadData >> f_ulPcBitNum) & 0x1) == ( UINT16 )f_ulValue ) + { + /* Mark the bit as being equal. */ + *f_pfBitEqual = TRUE; + fConditionFlag = FALSE; + } + + if ( CurrentTime.aulWallTimeUs[ 1 ] > TimeoutTime.aulWallTimeUs[ 1 ] || + (CurrentTime.aulWallTimeUs[ 1 ] == TimeoutTime.aulWallTimeUs[ 1 ] && + CurrentTime.aulWallTimeUs[ 0 ] >= TimeoutTime.aulWallTimeUs[ 0 ]) ) + fConditionFlag = FALSE; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseConversionMemEntry + +Description: Releases the conversion chariot memory entry specified. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to + keep the present state of the chip and all its + resources. + +f_usConversionMemIndex Index reserved in the conversion chariot memory. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseConversionMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usConversionMemIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pConversionMemAlloc; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pConversionMemAlloc ) + + ulResult = OctapiLlmAllocDealloc( pConversionMemAlloc, f_usConversionMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_B7; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReadDword + +Description: Read a DWORD at specified address in external memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulAddress DWORD address where to read. +f_pulReadData Resulting data. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReadDword( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulAddress, + OUT PUINT32 f_pulReadData ) +{ + tOCT6100_READ_PARAMS ReadParams; + UINT16 usReadData; + + UINT32 ulResult; + UINT32 ulTempData; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /*==================================================================================*/ + /* Read the first 16 bits. */ + ReadParams.ulReadAddress = f_ulAddress; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTempData = usReadData << 16; + + /* Read the last 16 bits. */ + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTempData |= usReadData; + + /*==================================================================================*/ + + /* Return the read value.*/ + *f_pulReadData = ulTempData; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100BufferPlayoutStop + +Description: This function disables playout of a buffer on the specified + channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pBufferPlayoutStop Pointer to buffer playout stop structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100BufferPlayoutStopDef( + tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop ) +{ + f_pBufferPlayoutStop->ulChannelHndl = cOCT6100_INVALID_HANDLE; + f_pBufferPlayoutStop->ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT; + f_pBufferPlayoutStop->fStopCleanly = TRUE; + f_pBufferPlayoutStop->pfAlreadyStopped = NULL; + f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = NULL; + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWaitForTime + +Description: Waits for the specified amount of time. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_aulWaitTime[ 2 ] The amout of time to be waited. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWaitForTime( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_aulWaitTime[ 2 ] ) +{ + tOCT6100_GET_TIME StartTime; + tOCT6100_GET_TIME CurrentTime; + UINT32 aulTimeDelta[ 2 ]; + UINT32 ulResult; + UINT16 usTempVar; + BOOL fConditionFlag = TRUE; + + /* Copy the process context. */ + StartTime.pProcessContext = f_pApiInstance->pProcessContext; + CurrentTime.pProcessContext = f_pApiInstance->pProcessContext; + + ulResult = Oct6100UserGetTime( &StartTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + while ( fConditionFlag ) + { + ulResult = Oct6100UserGetTime( &CurrentTime ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = octapi_lm_subtract( + CurrentTime.aulWallTimeUs, 1, + StartTime.aulWallTimeUs, 1, + aulTimeDelta, 1, + &usTempVar ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_37; + + if ( aulTimeDelta[ 1 ] >= f_aulWaitTime[ 1 ] && + aulTimeDelta[ 0 ] >= f_aulWaitTime[ 0 ] ) + fConditionFlag = FALSE; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReserveTsiMemEntry + +Description: Reserves a TSI chariot memory entry. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pusTsiMemIndex Resulting index reserved in the TSI chariot memory. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReserveTsiMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusTsiMemIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pTsiMemAlloc; + UINT32 ulResult; + UINT32 ulIndex; + UINT32 ulNumTsiB4Timestamp; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc ) + + ulResult = OctapiLlmAllocAlloc( pTsiMemAlloc, &ulIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT ) + return cOCT6100_ERR_MEMORY_ALL_TSI_MEM_ENTRY_RESERVED; + else + return cOCT6100_ERR_FATAL_92; + } + + + if ( ulIndex >= cOCT6100_NUM_TSI_B4_PHASING ) + { + /* Evaluate the number of TSI memory before the timestamp TSI. */ + ulNumTsiB4Timestamp = cOCT6100_NUM_TSI_B4_PHASING + cOCT6100_MAX_TSI_B4_TIMESTAMP - pSharedInfo->ChipConfig.usMaxPhasingTssts; + + if ( ulIndex >= ulNumTsiB4Timestamp ) + { + /* + 4 for the timestamp TSI entries.*/ + *f_pusTsiMemIndex = (UINT16)( pSharedInfo->ChipConfig.usMaxPhasingTssts + ulIndex + cOCT6100_TSI_MEM_FOR_TIMESTAMP ); + } + else /* ulIndex < ulNumTsiB4Timestamp */ + { + *f_pusTsiMemIndex = (UINT16)( pSharedInfo->ChipConfig.usMaxPhasingTssts + ulIndex ); + } + } + else /* ulIndex < ulNumTsiB4Timestamp */ + { + *f_pusTsiMemIndex = (UINT16)( ulIndex ); + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReserveConversionMemEntry + +Description: Reserves one of the conversion memory entry + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to + keep the present state of the chip and all its + resources. + +f_pusConversionMemIndex Resulting index reserved in the conversion memory. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReserveConversionMemEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusConversionMemIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pConversionMemAlloc; + UINT32 ulConversionMemIndex; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pConversionMemAlloc ) + + ulResult = OctapiLlmAllocAlloc( pConversionMemAlloc, &ulConversionMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT ) + return cOCT6100_ERR_MEMORY_ALL_CONVERSION_MEM_ENTRY_RESERVED; + else + return cOCT6100_ERR_FATAL_B8; + } + + *f_pusConversionMemIndex = (UINT16)( ulConversionMemIndex & 0xFFFF ); + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ConfBridgeClose + +Description: This function closes a conference bridge. A conference + bridge can only be closed if no participants are present on + the bridge. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pConfBridgeClose Pointer to conference bridge close structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ConfBridgeCloseDef( + tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose ) +{ + f_pConfBridgeClose->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE; + + return cOCT6100_ERR_OK; +} + + +#include "apilib/octapi_largmath.h" + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ +| API UTILITIES +| +| Function: OctApiLmSubtract. +| +| Description: This function subtracts 2 numbers, a and b. Number a is +| (alen + 1) * 32 bits long; b is (blen + 1) * 32 bits long. The result +| is (zlen + 1) * 32 bits long. It the function succeeds it returns +| GENERIC_OK, else GENERIC_ERROR. +| +| ----------------------------------------------------------------------- +| | Variable | Type | Description +| ----------------------------------------------------------------------- +| *a UINT32 The array containing the first number. +| alen USHORT The length of array a, minus 1 (0 - 99). +| *bneg UINT32 The array containing the second number. +| blen USHORT The length of array b, minus 1 (0 - 99). +| *z UINT32 The array containing the resulting number. +| zlen USHORT The length of array z, minus 1 (0 - 99). +| *neg USHORT Indicates if the result is negative +| (TRUE/FALSE). +| +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 OctApiLmSubtract(UINT32 * a,USHORT alen,UINT32 * bneg,USHORT blen,UINT32 * z,USHORT zlen,USHORT * neg) +{ + USHORT i; + UINT32 temp; + UINT32 carry=1; + UINT32 aprim; + UINT32 bprim; + + /* Check for array lengths.*/ + if (alen > zlen || blen > zlen) return(OCTAPI_LM_ARRAY_SIZE_MISMATCH); + + for(i=0;i<=zlen;i++) + { + if (i <= alen) aprim = *(a+i); else aprim = 0; + if (i <= blen) bprim = ~(*(bneg+i)); else bprim = 0xFFFFFFFF; + temp = aprim + bprim + carry; + + /* Calculate carry for next time.*/ + if (carry == 0) + if (temp < aprim) carry = 1; else carry = 0; + else + if (temp <= aprim) carry = 1; else carry = 0; + + /* Write new value.*/ + *(z+i) = temp; + } + + /* Check for overflow, which means negative number!*/ + if (carry == 0) + { + /* Number is not of right neg. Invert and add one to correct neg.*/ + for(i=0;i<=zlen;i++) + *(z+i) = ~(*(z+i)); + + temp = 1; + OctApiLmAdd(&temp,0,z,zlen,z,zlen); + + *neg = TRUE; + return(GENERIC_OK); + } + + /* Result is positive.*/ + *neg = FALSE; + return(GENERIC_OK); +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ +| API UTILITIES +| +| Function: OctApiLmAdd. +| +| Description: This function adds 2 numbers, a and b. Number a is +| (alen + 1) * 32 bits long; b is (blen + 1) * 32 bits long. The +| result is (zlen + 1) * 32 bits long. It the function succeeds it returns +| GENERIC_OK, else GENERIC_ERROR. +| +| ----------------------------------------------------------------------- +| | Variable | Type | Description +| ----------------------------------------------------------------------- +| *a UINT32 The array containing the first number. +| alen USHORT The length of array a, minus 1 (0 - 99). +| *b UINT32 The array containing the second number. +| blen USHORT The length of array b, minus 1 (0 - 99). +| *z UINT32 The array containing the resulting number. +| zlen USHORT The length of array z, minus 1 (0 - 99). +| +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 OctApiLmAdd(UINT32 * a,USHORT alen,UINT32 * b,USHORT blen,UINT32 * z, USHORT zlen) +{ + USHORT i; + UINT32 temp; + UINT32 carry=0; + UINT32 aprim; + UINT32 bprim; + + /* Check for array lengths.*/ + if (alen > zlen || blen > zlen) return(OCTAPI_LM_ARRAY_SIZE_MISMATCH); + + for(i=0;i<=zlen;i++) + { + if (i <= alen) aprim = *(a+i); else aprim = 0; + if (i <= blen) bprim = *(b+i); else bprim = 0; + temp = aprim + bprim + carry; + + /* Calculate carry for next time.*/ + if (carry == 0) + if (temp < aprim) carry = 1; else carry = 0; + else + if (temp <= aprim) carry = 1; else carry = 0; + + /* Write new value.*/ + *(z+i) = temp; + } + + /* Check for overflow.*/ + if (carry == 1) return(OCTAPI_LM_OVERFLOW); + + /* All is well.*/ + return(GENERIC_OK); +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_chip_stats.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to retreive the OCT6100 chip stats. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 85 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_chip_stats_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_chip_stats_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_chip_stats_priv.h" + +/**************************** PUBLIC FUNCTIONS *****************************/ + + +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiChipStatsSwInit + +Description: Initializes portions of API instance associated to chip stats. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiChipStatsSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + + /* Get local pointer to shared portion of API instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Initialize chip stats. */ + pSharedInfo->ErrorStats.fFatalChipError = FALSE; + + pSharedInfo->ErrorStats.ulH100ClkABadCnt = 0; + pSharedInfo->ErrorStats.ulH100ClkBBadCnt = 0; + pSharedInfo->ErrorStats.ulH100FrameABadCnt = 0; + pSharedInfo->ErrorStats.ulH100OutOfSyncCnt = 0; + + pSharedInfo->ErrorStats.ulInternalReadTimeoutCnt = 0; + pSharedInfo->ErrorStats.ulSdramRefreshTooLateCnt = 0; + pSharedInfo->ErrorStats.ulPllJitterErrorCnt = 0; + pSharedInfo->ErrorStats.ulOverflowToneEventsCnt = 0; + + + + pSharedInfo->ErrorStats.ulToneDetectorErrorCnt = 0; + + /* Init the chip stats. */ + pSharedInfo->ChipStats.usNumberChannels = 0; + pSharedInfo->ChipStats.usNumberBiDirChannels = 0; + pSharedInfo->ChipStats.usNumberTsiCncts = 0; + pSharedInfo->ChipStats.usNumberConfBridges = 0; + pSharedInfo->ChipStats.usNumberPlayoutBuffers = 0; + pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts = 0; + pSharedInfo->ChipStats.ulPlayoutMemUsed = 0; + pSharedInfo->ChipStats.usNumEcChanUsingMixer = 0; + + pSharedInfo->ChipStats.usNumberPhasingTssts = 0; + pSharedInfo->ChipStats.usNumberAdpcmChans = 0; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_conf_bridge.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains all functions related to a conference bridge. Procedures + needed to open/close a bridge, add/remove a participant to a conference + bridge, mute/unmute a participant, etc.. are all present in this source + file. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 145 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_mixer_inst.h" +#include "oct6100api/oct6100_conf_bridge_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_mixer_pub.h" +#include "oct6100api/oct6100_conf_bridge_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_tsst_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_mixer_priv.h" +#include "oct6100_conf_bridge_priv.h" + + +/**************************** PUBLIC FUNCTIONS *****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ConfBridgeChanRemove + +Description: This function removes an echo channel (participant) from a + conference bridge. All participants can be removed from + the bridge if a special flag (fRemoveAll) is set to TRUE. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pConfBridgeRemove Pointer to conference bridge channel removal structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ConfBridgeChanRemoveDef( + tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove ) +{ + f_pConfBridgeRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE; + f_pConfBridgeRemove->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE; + f_pConfBridgeRemove->fRemoveAll = FALSE; + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetConfBridgeSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of conference bridges. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetConfBridgeSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Calculate memory needed for conference bridge list. */ + if ( f_pOpenChip->ulMaxConfBridges == 0 && f_pOpenChip->fEnableChannelRecording == TRUE ) + f_pOpenChip->ulMaxConfBridges = 1; + f_pInstSizes->ulConfBridgeList = f_pOpenChip->ulMaxConfBridges * sizeof( tOCT6100_API_CONF_BRIDGE ); + + /* Calculate memory needed for conference bridge allocation software. */ + if ( f_pOpenChip->ulMaxConfBridges > 0 ) + { + /* Get size of bridge allocation memory */ + ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxConfBridges, &f_pInstSizes->ulConfBridgeAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1C; + + /* Check if the user wants to build flexible conference bridges. */ + if ( f_pOpenChip->ulMaxFlexibleConfParticipants > 0 ) + { + /* Allocate the lowest quantity according to what the user requested. */ + if ( f_pOpenChip->ulMaxFlexibleConfParticipants < ( f_pOpenChip->ulMaxConfBridges * cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE ) ) + f_pInstSizes->ulFlexConfParticipantsList = f_pOpenChip->ulMaxFlexibleConfParticipants * sizeof( tOCT6100_API_FLEX_CONF_PARTICIPANT ); + else + { + f_pOpenChip->ulMaxFlexibleConfParticipants = f_pOpenChip->ulMaxConfBridges * cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; + f_pInstSizes->ulFlexConfParticipantsList = f_pOpenChip->ulMaxConfBridges * cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE * sizeof( tOCT6100_API_FLEX_CONF_PARTICIPANT ); + } + + /* Get size of flexible conferencing participants allocation memory */ + ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxFlexibleConfParticipants, &f_pInstSizes->ulFlexConfParticipantsAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1C; + } + else + { + f_pInstSizes->ulFlexConfParticipantsList = 0; + f_pInstSizes->ulFlexConfParticipantsAlloc = 0; + } + } + else + { + f_pInstSizes->ulMixerEventList = 0; + f_pInstSizes->ulMixerEventAlloc = 0; + f_pInstSizes->ulConfBridgeAlloc = 0; + + /* Make sure flexible conferencing is not used. */ + f_pInstSizes->ulFlexConfParticipantsList = 0; + f_pInstSizes->ulFlexConfParticipantsAlloc = 0; + } + + /* Calculate memory needed for list and allocation software serialization. */ + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulConfBridgeList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulConfBridgeAlloc, ulTempVar ) + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulFlexConfParticipantsList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulFlexConfParticipantsAlloc, ulTempVar ) + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiConfBridgeSwInit + +Description: Initializes all elements of the instance structure associated + to conference bridges. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiConfBridgeSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CONF_BRIDGE pConfBridgeList; + tPOCT6100_API_FLEX_CONF_PARTICIPANT pFlexConfParticipantList; + PVOID pFlexConfPartipantsAlloc; + UINT32 ulMaxFlexConfParicipants; + PVOID pConfBridgeAlloc; + UINT32 ulMaxConfBridges; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get the maximum number of conference bridges. */ + ulMaxConfBridges = pSharedInfo->ChipConfig.usMaxConfBridges; + + /*===================================================================*/ + /* Set all entries in the conference bridge list to unused. */ + + mOCT6100_GET_CONF_BRIDGE_LIST_PNT( pSharedInfo, pConfBridgeList ); + + /* Initialize the conference bridge allocation software to "all free". */ + if ( ulMaxConfBridges > 0 ) + { + /* Clear the bridge memory */ + Oct6100UserMemSet( pConfBridgeList, 0x00, ulMaxConfBridges * sizeof( tOCT6100_API_CONF_BRIDGE )); + + mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( pSharedInfo, pConfBridgeAlloc ) + + ulResult = OctapiLlmAllocInit( &pConfBridgeAlloc, ulMaxConfBridges ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1E; + } + /*===================================================================*/ + + + /*===================================================================*/ + /* Set all entries in the flexible conferencing participant list to unused. */ + + /* Get the maximum number of flexible conferencing participants. */ + ulMaxFlexConfParicipants = pSharedInfo->ChipConfig.usMaxFlexibleConfParticipants; + + mOCT6100_GET_FLEX_CONF_PARTICIPANT_LIST_PNT( pSharedInfo, pFlexConfParticipantList ); + + /* Initialize the flexible conferencing allocation software. */ + if ( ulMaxFlexConfParicipants > 0 ) + { + UINT32 i, ulEventIndex; + + /* Clear the participants memory */ + Oct6100UserMemSet( pFlexConfParticipantList, 0x00, ulMaxFlexConfParicipants * sizeof( tOCT6100_API_FLEX_CONF_PARTICIPANT )); + + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( pSharedInfo, pFlexConfPartipantsAlloc ) + + ulResult = OctapiLlmAllocInit( &pFlexConfPartipantsAlloc, ulMaxFlexConfParicipants ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_1E; + + /* Initialize the conferencing indexes. */ + for ( i = 0; i < ulMaxFlexConfParicipants; i ++ ) + { + for ( ulEventIndex = 0; ulEventIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulEventIndex ++ ) + pFlexConfParticipantList[ i ].ausLoadOrAccumulateEventIndex[ ulEventIndex ] = cOCT6100_INVALID_INDEX; + } + } + + /*===================================================================*/ + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ConfBridgeCloseSer + +Description: Closes a conference bridge. Note that no client must be present + on the bridge for the bridge to be closed. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pConfBridgeClose Pointer to conference bridge close structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ConfBridgeCloseSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose ) +{ + UINT16 usBridgeIndex; + UINT32 ulResult; + + /* Verify that all the parameters given match the state of the API. */ + ulResult = Oct6100ApiAssertBridgeParams( f_pApiInstance, f_pConfBridgeClose, &usBridgeIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Release all resources associated to the conference bridge. */ + ulResult = Oct6100ApiReleaseBridgeResources( f_pApiInstance, usBridgeIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Invalidate the handle. */ + f_pConfBridgeClose->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAssertBridgeParams + +Description: Checks the user's conference bridge close configuration for errors. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pConfBridgeClose Pointer to conference bridge close structure. +f_pusBridgeIndex Pointer to API instance conference bridge index. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAssertBridgeParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose, + OUT PUINT16 f_pusBridgeIndex ) +{ + tPOCT6100_API_CONF_BRIDGE pBridgeEntry; + UINT32 ulEntryOpenCnt; + + /* Check the provided handle. */ + if ( (f_pConfBridgeClose->ulConfBridgeHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CONF_BRIDGE ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + *f_pusBridgeIndex = (UINT16)( f_pConfBridgeClose->ulConfBridgeHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusBridgeIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = (f_pConfBridgeClose->ulConfBridgeHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pBridgeEntry->fReserved != TRUE ) + return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN; + if ( pBridgeEntry->usNumClients != 0 ) + return cOCT6100_ERR_CONF_BRIDGE_ACTIVE_DEPENDENCIES; + if ( ulEntryOpenCnt != pBridgeEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseBridgeResources + +Description: Release all resources reserved for the conference bridge. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_usBridgeIndex Allocated external memory block for the conference bridge. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseBridgeResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usBridgeIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CONF_BRIDGE pBridgeEntry; + tPOCT6100_API_CONF_BRIDGE pTempBridgeEntry; + UINT32 ulResult; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Release the entry from the conference bridge list. */ + ulResult = Oct6100ApiReleaseBridgeEntry( f_pApiInstance, f_usBridgeIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_24; + + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex ); + + /* Remove the bridge entry from the bridge list. */ + if ( pSharedInfo->MiscVars.usNumBridgesOpened == 1 ) + { + /* This bridge was the only one opened. */ + pSharedInfo->MiscVars.usFirstBridge = cOCT6100_INVALID_INDEX; + } + else if ( pSharedInfo->MiscVars.usNumBridgesOpened > 1 ) + { + /* There are more then one bridge open, must update the list. */ + if ( pBridgeEntry->usPrevBridgePtr != cOCT6100_INVALID_INDEX ) + { + /* There is a valid entry before this bridge, let's update this entry. */ + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempBridgeEntry, pBridgeEntry->usPrevBridgePtr ); + + pTempBridgeEntry->usNextBridgePtr = pBridgeEntry->usNextBridgePtr; + } + + if ( pBridgeEntry->usNextBridgePtr != cOCT6100_INVALID_INDEX ) + { + /* There is a valid entry after this bridge, let's update this entry. */ + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempBridgeEntry, pBridgeEntry->usNextBridgePtr ); + + pTempBridgeEntry->usPrevBridgePtr = pBridgeEntry->usPrevBridgePtr; + } + + if ( pSharedInfo->MiscVars.usFirstBridge == f_usBridgeIndex ) + { + /* This entry was the first of the list, make the next one be the first now. */ + pSharedInfo->MiscVars.usFirstBridge = pBridgeEntry->usNextBridgePtr; + } + } + else + { + /* Variable has become out of sync. */ + return cOCT6100_ERR_FATAL_25; + } + + /*=============================================================*/ + /* Update the conference bridge's list entry. */ + + /* Mark the bridge as closed. */ + pBridgeEntry->fFlexibleConferencing = FALSE; + pBridgeEntry->fReserved = FALSE; + pBridgeEntry->byEntryOpenCnt++; + + /* Decrement the number of conference bridges opened. */ + pSharedInfo->MiscVars.usNumBridgesOpened--; + pSharedInfo->ChipStats.usNumberConfBridges--; + + /*=============================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ConfBridgeChanRemoveSer + +Description: Removes an echo channel from a conference bridge. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pConfBridgeRemove Pointer to conference bridge channel remove structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ConfBridgeChanRemoveSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove ) +{ + UINT16 usBridgeIndex; + UINT16 usChanIndex=0; + UINT16 usLoadEventIndex; + UINT16 usSubStoreEventIndex; + UINT16 usCopyEventIndex; + UINT32 ulResult; + UINT8 fFlexibleConfBridge; + UINT8 fTap; + + /* Check the validity of the channel and conference bridge given. */ + ulResult = Oct6100ApiCheckChanRemoveParams( + f_pApiInstance, + f_pConfBridgeRemove, + &usBridgeIndex, + &usChanIndex, + &fFlexibleConfBridge, + &fTap, + &usLoadEventIndex, + &usSubStoreEventIndex, + &usCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Release all resources reserved for the conference bridge. */ + ulResult = Oct6100ApiReleaseChanEventResources( + f_pApiInstance, + f_pConfBridgeRemove, + usBridgeIndex, + usChanIndex, + fFlexibleConfBridge, + usLoadEventIndex, + usSubStoreEventIndex, + usCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear the memory entry for this channel within the bridge. */ + ulResult = Oct6100ApiBridgeEventRemove( + f_pApiInstance, + f_pConfBridgeRemove, + usBridgeIndex, + usChanIndex, + fFlexibleConfBridge, + usLoadEventIndex, + usSubStoreEventIndex, + usCopyEventIndex, + fTap ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckChanRemoveParams + +Description: Check the validity of the channel and conference bridge given. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. +f_pConfBridgeRemove Pointer to conference bridge channenl add structure. +f_pusBridgeIndex Pointer to the bridge index. +f_pfFlexibleConfBridge If this is a flexible conference bridge +f_pusChannelIndex Pointer to the channel index to be added to the bridge. +f_pusLoadEventIndex Pointer to the load mixer event. +f_pusSubStoreEventIndex Pointer to the sub-store mixer event. +f_pusCopyEventIndex Pointer to the copy mixer event. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckChanRemoveParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove, + OUT PUINT16 f_pusBridgeIndex, + OUT PUINT16 f_pusChannelIndex, + OUT PUINT8 f_pfFlexibleConfBridge, + OUT PUINT8 f_pfTap, + OUT PUINT16 f_pusLoadEventIndex, + OUT PUINT16 f_pusSubStoreEventIndex, + OUT PUINT16 f_pusCopyEventIndex ) +{ + UINT32 ulEntryOpenCnt; + tPOCT6100_API_CHANNEL pEchoChanEntry; + tPOCT6100_API_CONF_BRIDGE pBridgeEntry; + + /* Verify if the remove all flag is valid. */ + if ( f_pConfBridgeRemove->fRemoveAll != TRUE && + f_pConfBridgeRemove->fRemoveAll != FALSE ) + return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_REMOVE_ALL; + + /* Check the channel handle only if the remove all flag is set to FALSE. */ + if ( f_pConfBridgeRemove->fRemoveAll == FALSE ) + { + /*=====================================================================*/ + /* Check the channel handle. */ + + if ( (f_pConfBridgeRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + *f_pusChannelIndex = (UINT16)( f_pConfBridgeRemove->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, *f_pusChannelIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = (f_pConfBridgeRemove->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pEchoChanEntry->fReserved != TRUE ) + return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN; + if ( ulEntryOpenCnt != pEchoChanEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + if ( pEchoChanEntry->fBeingTapped == TRUE ) + return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY; + + /*=====================================================================*/ + + *f_pusBridgeIndex = pEchoChanEntry->usBridgeIndex; + *f_pusLoadEventIndex = pEchoChanEntry->usLoadEventIndex; + *f_pusSubStoreEventIndex = pEchoChanEntry->usSubStoreEventIndex; + *f_pusCopyEventIndex = pEchoChanEntry->usSinCopyEventIndex; + + /* Check if the channel is really part of the bridge. */ + if ( *f_pusBridgeIndex == cOCT6100_INVALID_INDEX ) + return cOCT6100_ERR_CONF_BRIDGE_CHAN_NOT_ON_BRIDGE; + + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex ) + + /* Return whether this is a flexible bridge or not. */ + *f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing; + + /* Return whether this is a tap or not. */ + *f_pfTap = pEchoChanEntry->fTap; + } + else /* f_pConfBridgeRemove->fRemoveAll == TRUE */ + { + /* Check the provided handle. */ + if ( (f_pConfBridgeRemove->ulConfBridgeHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CONF_BRIDGE ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + *f_pusBridgeIndex = (UINT16)( f_pConfBridgeRemove->ulConfBridgeHndl & cOCT6100_HNDL_INDEX_MASK ); + if ( *f_pusBridgeIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = (f_pConfBridgeRemove->ulConfBridgeHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pBridgeEntry->fReserved != TRUE ) + return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN; + if ( ulEntryOpenCnt != pBridgeEntry->byEntryOpenCnt ) + return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE; + + /* This information is not currently available. */ + *f_pusLoadEventIndex = cOCT6100_INVALID_INDEX; + *f_pusSubStoreEventIndex = cOCT6100_INVALID_INDEX; + *f_pusCopyEventIndex = cOCT6100_INVALID_INDEX; + + /* Return whether this is a flexible bridge or not. */ + *f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing; + + *f_pfTap = FALSE; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseChanEventResources + +Description: Release all resources reserved to the channel part of the + conference bridge. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. +f_pConfBridgeRemove Pointer to conference bridge channel add structure. +f_usBridgeIndex Index of the bridge structure within the API's bridge list. +f_usChanIndex Index of the channel structure within the API's channel list +f_fFlexibleConfBridge If this is a flexible conference bridge. +f_usLoadEventIndex Index of the load mixer event. +f_usSubStoreEventIndex Index of the sub-store mixer event. +f_usCopyEventIndex Index of the copy mixer event. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseChanEventResources( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChanIndex, + IN UINT8 f_fFlexibleConfBridge, + IN UINT16 f_usLoadEventIndex, + IN UINT16 f_usSubStoreEventIndex, + IN UINT16 f_usCopyEventIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pEchoChanEntry; + UINT32 ulResult; + UINT32 i; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + if ( f_fFlexibleConfBridge == TRUE ) + { + tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant; + tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant; + + if ( f_pConfBridgeRemove->fRemoveAll == FALSE ) + { + tPOCT6100_API_CHANNEL pTempEchoChanEntry; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex ); + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex ); + + /* Release an entry for the store event in the mixer memory. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usSubStoreEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /* Release an entry for the Sin copy event in the mixer memory. */ + /* This value can be invalid if the Rin port was used - no need to release. */ + if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* This value can be 0 if the Rin port was used - no need to release. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + /* Release the extra TSI entry.*/ + ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* This value can be 0 if the Sout port was used - no need to release. */ + if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 ) + { + /* Release the extra TSI entry.*/ + ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraRinTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* Must travel all clients of this conference and release the load or accumulate events for */ + /* all participants which can hear us and vice versa. */ + + /* Search through the list of API channel entry for the ones on to this bridge. */ + for ( i = 0; ( i < pSharedInfo->ChipConfig.usMaxChannels ) && ( ulResult == cOCT6100_ERR_OK ); i++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, i ); + + /* Channel reserved? */ + if ( ( i != f_usChanIndex ) && pTempEchoChanEntry->fReserved == TRUE ) + { + /* On current bridge? */ + if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) + { + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex ); + + /* Check if we can hear this participant. */ + if ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 ) + { + /* Must release the allocated mixer event. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX; + } + + /* Check if this participant can hear us. */ + if ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 ) + { + /* Must release the allocated mixer event. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pTempParticipant->ausLoadOrAccumulateEventIndex[ pParticipant->ulListenerMaskIndex ] ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + pTempParticipant->ausLoadOrAccumulateEventIndex[ pParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX; + } + } + } + } + } + else /* f_pConfBridgeRemove->fRemoveAll == TRUE */ + { + UINT32 ulListenerMaskIndex; + + ulResult = cOCT6100_ERR_OK; + + /* Search through the list of API channel entry for the ones on to this bridge.*/ + for ( i = 0; ( i < pSharedInfo->ChipConfig.usMaxChannels ) && ( ulResult == cOCT6100_ERR_OK ); i++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i ); + + /* Channel reserved? */ + if ( pEchoChanEntry->fReserved == TRUE ) + { + /* On current bridge? */ + if ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) + { + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex ); + + /* Release an entry for the Store event in the Mixer memory. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pEchoChanEntry->usSubStoreEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /* Release an entry for the Sin copy event in the Mixer memory. */ + /* This value can be invalid if the Rin port was used - no need to release. */ + if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* This value can be 0 if the Rin port was used - no need to release. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + /* Release the extra TSI entry.*/ + ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* This value can be 0 if the Sout port was used - no need to release. */ + if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 ) + { + /* Release the extra TSI entry.*/ + ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraRinTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* Check if something can be freed. */ + for ( ulListenerMaskIndex = 0; ulListenerMaskIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulListenerMaskIndex ++ ) + { + if ( pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] != cOCT6100_INVALID_INDEX ) + { + /* Must release the allocated mixer event. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX; + } + } + } + } + } + + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else /* if ( f_fFlexibleConfBridge == FALSE ) */ + { + if ( f_pConfBridgeRemove->fRemoveAll == FALSE ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex ); + + /* Release the entry for the load event in the mixer memory. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usLoadEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /* Release an entry for the substract and store event in the mixer memory. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usSubStoreEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /* Release an entry for the Sin copy event in the Mixer memory. */ + /* This value can be invalid if the Rin port was used - no need to release. */ + if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* This value can be 0 if the Rin port was used - no need to release. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + /* Release the extra TSI entry. */ + ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + } + else /* f_pConfBridgeRemove->fRemoveAll == TRUE */ + { + /* Search through the list of API channel entry for the ones on to the specified bridge.*/ + for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i ); + + if ( pEchoChanEntry->fReserved == TRUE ) + { + if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) ) + { + /* Release the entry for the load event in the mixer memory. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, + pEchoChanEntry->usLoadEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /* Release an entry for the substract and store event in the Mixer memory. */ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, + pEchoChanEntry->usSubStoreEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /* Release an entry for the Sin copy event in the Mixer memory. */ + /* This value can be invalid if the Rin port was used - no need to release. */ + if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, + pEchoChanEntry->usSinCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + + /* This value can be 0 if the Rin port was used - no need to release. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + /* Release the extra TSI entry.*/ + ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + } + } + } + } + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiBridgeEventRemove + +Description: Remove the event from the global event list of the chip and + update the bridge and channel structures. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. +f_pConfBridgeRemove Pointer to a conference bridge channel remove structure. +f_usBridgeIndex Index of the current bridge in the API list. +f_usChanIndex Index of the current channel in the API list. +f_fFlexibleConfBridge If this is a flexible conference bridge. +f_usLoadEventIndex Allocated entry for the Load event of the channel. +f_usSubStoreEventIndex Allocated entry for the substract and store event of the channel. +f_usCopyEventIndex Allocated entry for the copy event of the channel. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiBridgeEventRemove ( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usChanIndex, + IN UINT8 f_fFlexibleConfBridge, + IN UINT16 f_usLoadEventIndex, + IN UINT16 f_usSubStoreEventIndex, + IN UINT16 f_usCopyEventIndex, + IN UINT8 f_fTap ) +{ + tPOCT6100_API_CONF_BRIDGE pBridgeEntry; + + tPOCT6100_API_MIXER_EVENT pLoadEventEntry; + tPOCT6100_API_MIXER_EVENT pSubStoreEventEntry; + tPOCT6100_API_MIXER_EVENT pCopyEventEntry = NULL; + tPOCT6100_API_MIXER_EVENT pTempEntry; + + tPOCT6100_API_CHANNEL pEchoChanEntry; + tPOCT6100_API_CHANNEL pTempEchoChanEntry; + + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + + UINT32 ulResult; + UINT16 usPreviousEventIndex; + UINT16 usTempEventIndex; + UINT32 ulLoopCount = 0; + UINT16 usReadData; + UINT16 usChannelIndex; + UINT32 i; + + BOOL fRemoveSinCopy = FALSE; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, f_usBridgeIndex ); + + /* If no client on the bridge, and the remove all option is specified, return here. */ + if ( ( pBridgeEntry->usNumClients == 0 ) && ( f_pConfBridgeRemove->fRemoveAll == TRUE ) ) + return cOCT6100_ERR_OK; + + /* Make sure the dominant speaker feature is disabled first. */ + if ( pBridgeEntry->fDominantSpeakerSet == TRUE ) + { + /* If all channels are to be removed or if the dominant speaker is the current channel to be removed. */ + if ( ( f_pConfBridgeRemove->fRemoveAll == TRUE ) + || ( ( f_pConfBridgeRemove->fRemoveAll == FALSE ) && ( pBridgeEntry->usDominantSpeakerChanIndex == f_usChanIndex ) ) ) + { + /* Disable on all channels part of this conference. */ + + /* Search through the list of API channel entry for the ones on to this bridge. */ + for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex ); + + if ( pTempEchoChanEntry->fReserved == TRUE ) + { + if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) + { + ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, usChannelIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + + /* Save this in the conference bridge structure. */ + pBridgeEntry->fDominantSpeakerSet = FALSE; + pBridgeEntry->usDominantSpeakerChanIndex = cOCT6100_INVALID_INDEX; + } + else + { + /* Only disable this current channel. */ + ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_usChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + if ( f_fFlexibleConfBridge == TRUE ) + { + tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant; + tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant; + UINT16 ausMutePortChannelIndexes[ cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE ]; + UINT32 ulMutePortChannelIndex; + + for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ ) + ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = cOCT6100_INVALID_INDEX; + + if ( f_pConfBridgeRemove->fRemoveAll == FALSE ) + { + /* The channel index is valid. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex ); + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex ); + + /* Search through the list of API channel entry for the ones on to this bridge. */ + for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex ); + + if ( ( usChannelIndex != f_usChanIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) ) + { + if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) + { + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex ); + + /* Check if we can hear this participant. */ + if ( ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 ) + && ( pParticipant->fFlexibleMixerCreated == TRUE ) + && ( pTempEchoChanEntry->fMute == FALSE ) ) + { + /* First update the current channel's mixer. */ + ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel( + f_pApiInstance, + f_usBridgeIndex, + usChannelIndex, + f_usChanIndex, + TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Check if this participant can hear us. */ + if ( ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 ) + && ( pTempParticipant->fFlexibleMixerCreated == TRUE ) + && ( pEchoChanEntry->fMute == FALSE ) ) + { + /* Then update this channel's mixer. */ + ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel( + f_pApiInstance, + f_usBridgeIndex, + f_usChanIndex, + usChannelIndex, + TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Remember to mute the port on this channel. */ + for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ ) + { + if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == usChannelIndex ) + { + break; + } + else if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) + { + ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = usChannelIndex; + break; + } + } + } + } + } + } + + /* Check if must manually clear the Sin copy event. */ + if ( ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) + && ( pEchoChanEntry->fCopyEventCreated == TRUE ) ) + { + /* Transform event into no-operation. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now remove the copy event from the event list. */ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + pEchoChanEntry->fCopyEventCreated = FALSE; + } + + /* Release an entry for the participant. */ + ulResult = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pEchoChanEntry->usFlexConfParticipantIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /*=======================================================================*/ + /* Update the event and channel API structure */ + pEchoChanEntry->usFlexConfParticipantIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX; + + /* Indicate that the extra SIN TSI is not needed anymore by the mixer. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + pEchoChanEntry->usExtraSinTsiDependencyCnt--; + pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; + } + + /* Indicate that the extra RIN TSI is not needed anymore by the mixer. */ + if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 ) + { + pEchoChanEntry->usExtraRinTsiDependencyCnt--; + pEchoChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX; + } + + /* Update the chip stats structure. */ + pSharedInfo->ChipStats.usNumEcChanUsingMixer--; + + pBridgeEntry->usNumClients--; + + /* For sure we have to mute the ports of this channel to be removed. */ + ulResult = Oct6100ApiMutePorts( + f_pApiInstance, + f_usChanIndex, + pEchoChanEntry->usRinTsstIndex, + pEchoChanEntry->usSinTsstIndex, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Travel through the channels that were heard by the participant removed and check if their Rin port must be muted. */ + for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ ) + { + if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] != cOCT6100_INVALID_INDEX ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, ausMutePortChannelIndexes[ ulMutePortChannelIndex ] ); + + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex ); + + if ( pTempParticipant->fFlexibleMixerCreated == FALSE ) + { + /* Check if the Rin port must be muted on this channel. */ + ulResult = Oct6100ApiMutePorts( + f_pApiInstance, + ausMutePortChannelIndexes[ ulMutePortChannelIndex ], + pTempEchoChanEntry->usRinTsstIndex, + pTempEchoChanEntry->usSinTsstIndex, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else /* if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) */ + { + /* No more channels to check for muting. */ + break; + } + } + } + else /* if ( f_pConfBridgeRemove->fRemoveAll == TRUE ) */ + { + UINT16 usMainChannelIndex; + + for ( usMainChannelIndex = 0 ; usMainChannelIndex < pSharedInfo->ChipConfig.usMaxChannels ; usMainChannelIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, usMainChannelIndex ); + + /* If this channel is on the bridge we are closing all the channels. */ + if ( ( pEchoChanEntry->fReserved == TRUE ) && ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) ) + { + /* Remember to mute the port on this channel. */ + for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ ) + { + if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == usMainChannelIndex ) + { + break; + } + else if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) + { + ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = usMainChannelIndex; + break; + } + } + + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex ); + + /* Search through the list of API channel entry for the ones on to this bridge. */ + for ( usChannelIndex = (UINT16)( usMainChannelIndex + 1 ); usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex ); + if ( pTempEchoChanEntry->fReserved == TRUE ) + { + if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) + { + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex ); + + /* Everyone that we can hear must be removed. */ + if ( ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 ) + && ( pParticipant->fFlexibleMixerCreated == TRUE ) + && ( pTempEchoChanEntry->fMute == FALSE ) ) + { + /* First update the current channel's mixer. */ + ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel( + f_pApiInstance, + f_usBridgeIndex, + usChannelIndex, + usMainChannelIndex, + TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Check if this participant can hear us. */ + if ( ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 ) + && ( pTempParticipant->fFlexibleMixerCreated == TRUE ) + && ( pEchoChanEntry->fMute == FALSE ) ) + { + /* Then update this channel's mixer. */ + ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel( + f_pApiInstance, + f_usBridgeIndex, + usMainChannelIndex, + usChannelIndex, + TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + } + + /* Check if must manually clear the Sin copy event. */ + if ( ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) + && ( pEchoChanEntry->fCopyEventCreated == TRUE ) ) + { + /* Transform event into no-operation. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now remove the copy event from the event list. */ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + pEchoChanEntry->fCopyEventCreated = FALSE; + } + + /* Release an entry for the participant. */ + ulResult = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pEchoChanEntry->usFlexConfParticipantIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return ulResult; + } + + /*=======================================================================*/ + /* Update the event and channel API structure */ + + pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX; + + pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX; + + /* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + pEchoChanEntry->usExtraSinTsiDependencyCnt--; + pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; + } + + /* Indicate that the Extra RIN TSI is not needed anymore by the mixer. */ + if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 ) + { + pEchoChanEntry->usExtraRinTsiDependencyCnt--; + pEchoChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX; + } + + /* Update the chip stats structure. */ + pSharedInfo->ChipStats.usNumEcChanUsingMixer--; + } + } + + /* Travel through the channels that were heard by the participant removed and check if their Rin port must be muted. */ + for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ ) + { + if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] != cOCT6100_INVALID_INDEX ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, ausMutePortChannelIndexes[ ulMutePortChannelIndex ] ); + + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex ); + + if ( pTempParticipant->fFlexibleMixerCreated == FALSE ) + { + /* Check if the Rin port must be muted on this channel. */ + ulResult = Oct6100ApiMutePorts( + f_pApiInstance, + ausMutePortChannelIndexes[ ulMutePortChannelIndex ], + pTempEchoChanEntry->usRinTsstIndex, + pTempEchoChanEntry->usSinTsstIndex, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else /* if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) */ + { + /* No more channels to check for muting. */ + break; + } + + /* Clear the flexible conf bridge participant index. */ + pTempEchoChanEntry->usFlexConfParticipantIndex = cOCT6100_INVALID_INDEX; + } + + /* No more clients on bridge. */ + pBridgeEntry->usNumClients = 0; + } + } + else /* if ( f_fFlexibleConfBridge == FALSE ) */ + { + if ( f_pConfBridgeRemove->fRemoveAll == FALSE ) + { + /* The channel index is valid. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex ); + + if ( f_fTap == TRUE ) + { + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, pEchoChanEntry->usTapBridgeIndex ); + } + + /* Get a pointer to the event entry. */ + if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX ) + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, f_usCopyEventIndex ); + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex ); + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, f_usLoadEventIndex ); + + /*=======================================================================*/ + /* Check if have to modify the silence load event. */ + + if ( pBridgeEntry->usNumClients != 1 ) + { + if ( pBridgeEntry->usSilenceLoadEventPtr != cOCT6100_INVALID_INDEX ) + { + if ( pBridgeEntry->usSilenceLoadEventPtr == f_usLoadEventIndex ) + { + /* Make sure the next event becomes the silence event. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pLoadEventEntry->usNextEventPtr * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_LOAD; + WriteParams.usWriteData |= 1534; /* TSI index 1534 reserved for silence */ + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update the software model to remember the silence load. */ + pBridgeEntry->usSilenceLoadEventPtr = pLoadEventEntry->usNextEventPtr; + } + else + { + /* Somebody else is the silence event, no need to worry. */ + } + } + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Clear the Load event. */ + + /* First verify if the event to be removed was a load event. */ + if ( f_usLoadEventIndex == pBridgeEntry->usLoadIndex ) + { + /* Change the next entry if one is present to a load event to keep the bridge alive. */ + if ( pBridgeEntry->usNumClients == 1 ) + { + /* There is no other entry on the bridge, no need to search for an Accumulate event. */ + pBridgeEntry->usLoadIndex = cOCT6100_INVALID_INDEX; + + /* Clear the silence event, for sure it's invalid. */ + pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX; + } + else + { + /* Search for an accumulate event to tranform into a Load event. */ + usTempEventIndex = pLoadEventEntry->usNextEventPtr; + ulLoopCount = 0; + + /* Find the copy entry before the entry to remove. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex ); + + while( pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_SUB_STORE && + pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_STORE ) + { + if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE ) + { + /* Change this entry into a load event. */ + ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + WriteParams.usWriteData = (UINT16)(( usReadData & 0x1FFF ) | cOCT6100_MIXER_CONTROL_MEM_LOAD); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set this entry as the load index. */ + pBridgeEntry->usLoadIndex = usTempEventIndex; + + /* Update the software model. */ + pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD; + + /* Stop searching. */ + break; + } + + /* Go to the next entry into the list. */ + usTempEventIndex = pTempEntry->usNextEventPtr; + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex ); + + ulLoopCount++; + if ( ulLoopCount == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_FATAL_9B; + } + } + } + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Clear the substract and store event. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Clear the Copy event - if needed. */ + + if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX ) + { + /* Transform event into no-operation. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( f_fTap == FALSE ) + { + /* Set remove Sin copy event flag to remove the event from the mixer's list. */ + fRemoveSinCopy = TRUE; + + /* Clear the copy event created flag. */ + pEchoChanEntry->fCopyEventCreated = FALSE; + } + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Now remove the event from the event list. */ + + /* Look for the entry that is pointing at the first entry of our bridge. */ + if ( f_fTap == FALSE ) + { + ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex ); + } + else + { + ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, pEchoChanEntry->usTapBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex ); + } + + if ( ulResult != cOCT6100_ERR_OK ) + { + /* If the entry was not found, we now check for the Sout copy event section/list. */ + if ( ulResult == cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND ) + { + if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX ) + { + /* No Sout copy, it has to be the head node. */ + usPreviousEventIndex = cOCT6100_MIXER_HEAD_NODE; + } + else + { + /* Use the last Sout copy event. */ + usPreviousEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr; + } + } + else + { + return cOCT6100_ERR_FATAL_27; + } + } + + if ( pBridgeEntry->usNumClients == 1 ) + { + /* An entry was found, now, modify it's value. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex ); + + /* Now modify the previous last Sub Store event from another bridge. */ + pTempEntry->usNextEventPtr = pSubStoreEventEntry->usNextEventPtr; + + /*=======================================================================*/ + /* Modify the last node of the previous bridge to point to the next bridge. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + + WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /* Set the event pointer info in the bridge stucture. */ + pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX; + pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX; + pBridgeEntry->usLastSubStoreEventPtr = cOCT6100_INVALID_INDEX; + + /*=======================================================================*/ + /* Update the global mixer pointers. */ + if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex && + pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex ) + { + /* There is no more bridge entry in the mixer link list. */ + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastBridgeEventPtr = cOCT6100_INVALID_INDEX; + } + else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex ) + { + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pSubStoreEventEntry->usNextEventPtr; + } + else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex ) + { + pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex; + } + /*=======================================================================*/ + + if ( f_fTap == TRUE ) + { + /* The channel being tapped is not tapped anymore. */ + /* There is no direct way of finding the tap, so loop through all channels and find the */ + /* tapped channel index. */ + for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex ); + + if ( pTempEchoChanEntry->usTapChanIndex == f_usChanIndex ) + { + tPOCT6100_API_CONF_BRIDGE pTempBridgeEntry; + + pTempEchoChanEntry->fBeingTapped = FALSE; + pTempEchoChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX; + + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pTempBridgeEntry, f_usBridgeIndex ); + + pTempBridgeEntry->usNumTappedClients--; + + /* Re-assign Rin TSST for tapped channel. */ + if ( pTempEchoChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pTempEchoChanEntry->usRinTsstIndex, + pTempEchoChanEntry->usRinRoutTsiMemIndex, + pTempEchoChanEntry->TdmConfig.byRinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + break; + } + } + + /* Check if our model is broken. */ + if ( usChannelIndex == pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_FATAL_D3; + } + } + else /* pBridgeEntry->usNumClients > 1 */ + { + if ( pBridgeEntry->usFirstLoadEventPtr != f_usLoadEventIndex ) + { + /* Now find the load entry of this bridge pointing at this load event */ + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pBridgeEntry->usFirstLoadEventPtr, f_usLoadEventIndex, 0, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Remove the load event to the list. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex ); + + /* Now modify the previous last Sub Store event from another bridge. */ + pTempEntry->usNextEventPtr = pLoadEventEntry->usNextEventPtr; + + /*=======================================================================*/ + /* Modify the previous node. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + + WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /* Now find the last load entry of this bridge ( the one pointing at the first sub-store event ). */ + if ( pBridgeEntry->usFirstSubStoreEventPtr == f_usSubStoreEventIndex ) + { + /* Must start with the first load to get the entry before the first sub store. */ + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pBridgeEntry->usFirstLoadEventPtr, f_usSubStoreEventIndex, 0, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else + { + /* Must start with the first load to get the entry before the first sub store. */ + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pBridgeEntry->usFirstSubStoreEventPtr, f_usSubStoreEventIndex, 0, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex ); + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex ); + + /* Now modify the last load event of the bridge. */ + pTempEntry->usNextEventPtr = pSubStoreEventEntry->usNextEventPtr; + + /*=======================================================================*/ + /* Modify the last node of the other bridge. */ + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + + WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Update the bridge pointers. */ + + if ( pBridgeEntry->usFirstLoadEventPtr == f_usLoadEventIndex ) + pBridgeEntry->usFirstLoadEventPtr = pLoadEventEntry->usNextEventPtr; + + if ( pBridgeEntry->usFirstSubStoreEventPtr == f_usSubStoreEventIndex ) + pBridgeEntry->usFirstSubStoreEventPtr = pSubStoreEventEntry->usNextEventPtr; + + if ( pBridgeEntry->usLastSubStoreEventPtr == f_usSubStoreEventIndex ) + pBridgeEntry->usLastSubStoreEventPtr = usPreviousEventIndex; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Update the global mixer pointers. */ + + if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex ) + { + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pLoadEventEntry->usNextEventPtr; + } + + if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex ) + { + pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex; + } + /*=======================================================================*/ + + } + + /* Check if must remove the Sin copy event from the event list. */ + if ( fRemoveSinCopy == TRUE ) + { + /* Now remove the copy event from the event list. */ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, f_usCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Get the channel. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex ); + + /* Reprogram the TSST entry correctly if the Extra SIN TSI entry was released. */ + if ( ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) && ( f_fTap == FALSE ) ) + { + if ( pEchoChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pEchoChanEntry->usSinTsstIndex, + pEchoChanEntry->usSinSoutTsiMemIndex, + pEchoChanEntry->TdmConfig.bySinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* If the silence TSI is loaded on this port, update with the original sin TSI. */ + if ( pEchoChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) + { + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = pEchoChanEntry->usSinSoutTsiMemIndex; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + /* Set the event entries as free. */ + pLoadEventEntry->fReserved = FALSE; + pLoadEventEntry->usEventType = cOCT6100_INVALID_INDEX; + pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + + pSubStoreEventEntry->fReserved = FALSE; + pSubStoreEventEntry->usEventType = cOCT6100_INVALID_INDEX; + pSubStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + + if ( pCopyEventEntry != NULL ) + { + pCopyEventEntry->fReserved = FALSE; + pCopyEventEntry->usEventType = cOCT6100_INVALID_INDEX; + pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + } + + pBridgeEntry->usNumClients--; + + /*=======================================================================*/ + /* Update the event and channel API structure */ + pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX; + + /* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + pEchoChanEntry->usExtraSinTsiDependencyCnt--; + pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; + } + + /* Update the chip stats structure. */ + pSharedInfo->ChipStats.usNumEcChanUsingMixer--; + + if ( f_fTap == TRUE ) + { + /* Can now close the bridge. */ + tOCT6100_CONF_BRIDGE_CLOSE BridgeClose; + + Oct6100ConfBridgeCloseDef( &BridgeClose ); + + BridgeClose.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pBridgeEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pEchoChanEntry->usTapBridgeIndex; + + ulResult = Oct6100ConfBridgeCloseSer( f_pApiInstance, &BridgeClose ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + pEchoChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->fTap = FALSE; + } + + /* Check if the Rin port must be muted. */ + ulResult = Oct6100ApiMutePorts( + f_pApiInstance, + f_usChanIndex, + pEchoChanEntry->usRinTsstIndex, + pEchoChanEntry->usSinTsstIndex, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + } + else /* f_ulBridgeChanRemove->fRemoveAll == TRUE ) */ + { + UINT16 usNextEventPtr; + + /* Save the next event pointer before invalidating everything. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, pBridgeEntry->usLastSubStoreEventPtr ); + + usNextEventPtr = pSubStoreEventEntry->usNextEventPtr; + + /* Search through the list of API channel entry for the ones on to the specified bridge. */ + for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i ); + + if ( pEchoChanEntry->fReserved == TRUE ) + { + if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) ) + { + /* Check if we are being tapped. If so, remove the channel that taps us from the conference. */ + /* The removal of the channel will make sure the Rin TSST is re-assigned. */ + if ( pEchoChanEntry->fBeingTapped == TRUE ) + { + tOCT6100_CONF_BRIDGE_CHAN_REMOVE ChanRemove; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, pEchoChanEntry->usTapChanIndex ); + + ulResult = Oct6100ConfBridgeChanRemoveDef( &ChanRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pTempEchoChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pEchoChanEntry->usTapChanIndex; + + ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &ChanRemove ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*=======================================================================*/ + /* Clear the Load event. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + /*=======================================================================*/ + /* Clear the Substract and store event. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*=======================================================================*/ + + /*=======================================================================*/ + /* Clear the SIN copy event.*/ + + if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) + { + /* Transform event into no-operation. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Get a pointer to the event entry. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, pEchoChanEntry->usSinCopyEventIndex ); + + /* Update the next event pointer if required. */ + if ( usNextEventPtr == pEchoChanEntry->usSinCopyEventIndex ) + usNextEventPtr = pCopyEventEntry->usNextEventPtr; + + /* Now remove the copy event from the event list. */ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear the copy event created flag. */ + pEchoChanEntry->fCopyEventCreated = FALSE; + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Update the event and channel API structure */ + + /* Reprogram the TSST entry correctly if the Extra SIN TSI entry was released.*/ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + if ( pEchoChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pEchoChanEntry->usSinTsstIndex, + pEchoChanEntry->usSinSoutTsiMemIndex, + pEchoChanEntry->TdmConfig.bySinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* If the silence TSI is loaded on this port, update with the original Sin TSI. */ + if ( pEchoChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) + { + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = pEchoChanEntry->usSinSoutTsiMemIndex; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, pEchoChanEntry->usLoadEventIndex ); + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, pEchoChanEntry->usSubStoreEventIndex ); + + /* Set the event entries as free. */ + pLoadEventEntry->fReserved = FALSE; + pLoadEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + + pSubStoreEventEntry->fReserved = FALSE; + pSubStoreEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pSubStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + + if ( pCopyEventEntry != NULL ) + { + pCopyEventEntry->fReserved = FALSE; + pCopyEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + } + + /* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */ + if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + pEchoChanEntry->usExtraSinTsiDependencyCnt--; + pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; + } + + /* Invalidate the channel entry. */ + pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX; + pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX; + + /* Update the chip stats structure. */ + pSharedInfo->ChipStats.usNumEcChanUsingMixer--; + + /*=======================================================================*/ + } + } + } + + ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND == ulResult ) + { + if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX ) + { + usPreviousEventIndex = cOCT6100_MIXER_HEAD_NODE; + } + else + { + usPreviousEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr; + } + } + else + { + return cOCT6100_ERR_FATAL_28; + } + } + + /* An Entry was found, now, modify it's value. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex ); + + /* Now modify the previous last Sub Store event from another bridge.*/ + /* It will now point at the next bridge, or copy events. */ + pTempEntry->usNextEventPtr = usNextEventPtr; + + /*=======================================================================*/ + /* Modify the last node of the other bridge. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + + WriteParams.usWriteData = pTempEntry->usNextEventPtr; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*=======================================================================*/ + + /*=======================================================================*/ + /* Update the global mixer pointers. */ + if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == pBridgeEntry->usFirstLoadEventPtr && + pSharedInfo->MixerInfo.usLastBridgeEventPtr == pBridgeEntry->usLastSubStoreEventPtr ) + { + /* This bridge was the only one with event in the list. */ + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastBridgeEventPtr = cOCT6100_INVALID_INDEX; + } + else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == pBridgeEntry->usFirstLoadEventPtr ) + { + /* This bridge was the first bridge. */ + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = usNextEventPtr; + } + else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == pBridgeEntry->usLastSubStoreEventPtr ) + { + /* This bridge was the last bridge.*/ + pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex; + } + /*=======================================================================*/ + + /* Set the event pointer info in the bridge stucture. */ + pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX; + pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX; + pBridgeEntry->usLastSubStoreEventPtr = cOCT6100_INVALID_INDEX; + pBridgeEntry->usLoadIndex = cOCT6100_INVALID_INDEX; + + pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX; + + /* Set the number of clients to 0. */ + pBridgeEntry->usNumClients = 0; + + /* Search through the list of API channel entry for the ones on to the specified bridge. */ + for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i ); + + if ( pEchoChanEntry->fReserved == TRUE ) + { + if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) ) + { + pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX; + + /* Check if the Rin port must be muted. */ + ulResult = Oct6100ApiMutePorts( + f_pApiInstance, + (UINT16)( i & 0xFFFF ), + pEchoChanEntry->usRinTsstIndex, + pEchoChanEntry->usSinTsstIndex, + FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiBridgeRemoveParticipantFromChannel + +Description: This will remove a flexible conference participant from + a channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. +f_usBridgeIndex Bridge index where this channel is located. +f_usSourceChannelIndex Source channel to copy voice from. +f_usDestinationChannelIndex Destination channel to store resulting voice to. +f_fRemovePermanently Whether to remove permanently this participant. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiBridgeRemoveParticipantFromChannel( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usSourceChannelIndex, + IN UINT16 f_usDestinationChannelIndex, + IN UINT8 f_fRemovePermanently ) +{ + tPOCT6100_API_CONF_BRIDGE pBridgeEntry; + + tPOCT6100_API_MIXER_EVENT pLoadEventEntry; + tPOCT6100_API_MIXER_EVENT pStoreEventEntry; + tPOCT6100_API_MIXER_EVENT pCopyEventEntry; + tPOCT6100_API_MIXER_EVENT pTempEntry; + tPOCT6100_API_MIXER_EVENT pLoadTempEntry; + tPOCT6100_API_MIXER_EVENT pLastEventEntry; + tPOCT6100_API_MIXER_EVENT pLastLoadOrAccumulateEventEntry; + + tPOCT6100_API_CHANNEL pSourceChanEntry; + tPOCT6100_API_CHANNEL pDestinationChanEntry; + + tPOCT6100_API_FLEX_CONF_PARTICIPANT pSourceParticipant; + tPOCT6100_API_FLEX_CONF_PARTICIPANT pDestinationParticipant; + + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + + UINT32 ulResult; + UINT32 ulLoopCount; + UINT16 usLastLoadEventIndex; + UINT16 usLoadOrAccumulateEventIndex; + UINT16 usTempEventIndex; + UINT16 usPreviousEventIndex; + UINT16 usLastEventIndex; + + UINT16 usReadData; + BOOL fLastEvent = FALSE; + BOOL fSoutCopyEvent = FALSE; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex ); + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pSourceChanEntry, f_usSourceChannelIndex ); + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pSourceParticipant, pSourceChanEntry->usFlexConfParticipantIndex ); + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pDestinationChanEntry, f_usDestinationChannelIndex ); + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pDestinationParticipant, pDestinationChanEntry->usFlexConfParticipantIndex ); + + /* Check if the mixer has been created on this channel. */ + if ( pDestinationParticipant->fFlexibleMixerCreated == TRUE ) + { + /*=======================================================================*/ + /* Clear the Load or Accumulate event.*/ + + usTempEventIndex = pDestinationChanEntry->usLoadEventIndex; + ulLoopCount = 0; + + /* Find the Load or Accumulate event entry. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, usTempEventIndex ); + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pStoreEventEntry, pDestinationChanEntry->usSubStoreEventIndex ); + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex ); + + pLastEventEntry = pLoadEventEntry; + pLastLoadOrAccumulateEventEntry = pLoadEventEntry; + usLastLoadEventIndex = usTempEventIndex; + usLastEventIndex = usTempEventIndex; + + while( pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_SUB_STORE && + pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_STORE ) + { + /* If this is the entry we are looking for. */ + if ( pTempEntry->usSourceChanIndex == f_usSourceChannelIndex ) + { + /* Check if this is a Load or Accumulate event. */ + if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_LOAD ) + { + /* This is the first entry. Check if next entry is an accumulate. */ + pLoadTempEntry = pTempEntry; + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, pTempEntry->usNextEventPtr ); + + if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE ) + { + /* Change this entry into a Load event. */ + ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pLoadTempEntry->usNextEventPtr * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + WriteParams.usWriteData = (UINT16)(( usReadData & 0x1FFF ) | cOCT6100_MIXER_CONTROL_MEM_LOAD); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update the channel information with this new load event. */ + pDestinationChanEntry->usLoadEventIndex = pLoadTempEntry->usNextEventPtr; + + /* Update the software model. */ + pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD; + + /* Get the previous event. */ + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex ); + usLastEventIndex = usPreviousEventIndex; + + /* Stop searching. */ + break; + } + else if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE ) + { + /* Get back the event to remove. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex ); + + /* This is the only event on this channel so we can clear everything up. */ + fLastEvent = TRUE; + + /* Get the previous event. */ + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex ); + usLastEventIndex = usPreviousEventIndex; + + /* Stop searching. */ + break; + } + else + { + /* Software model is broken. */ + return cOCT6100_ERR_FATAL_C5; + } + + } + else if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE ) + { + /* Simply remove the entry. */ + + /* Get the previous event. */ + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex ); + usLastEventIndex = usPreviousEventIndex; + + /* Stop searching. */ + break; + } + else + { + /* Software model is broken. */ + return cOCT6100_ERR_FATAL_C6; + } + } + + pLastLoadOrAccumulateEventEntry = pTempEntry; + usLastLoadEventIndex = usTempEventIndex; + + /* Go to the next entry into the list. */ + usTempEventIndex = pTempEntry->usNextEventPtr; + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex ); + + ulLoopCount++; + if ( ulLoopCount == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_FATAL_C8; + } + + /* Check if we found what we were looking for. */ + if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE + || pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_SUB_STORE ) + { + /* Software model is broken. */ + return cOCT6100_ERR_FATAL_C7; + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Clear the Store event - if needed. */ + + if ( fLastEvent == TRUE ) + { + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pDestinationChanEntry->usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Clear the Load or Accumulate event. */ + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save this event index. It's the Load or Accumulate we want to remove from the list later. */ + usLoadOrAccumulateEventIndex = usTempEventIndex; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Clear the Copy event - if needed. */ + + if ( ( fLastEvent == TRUE ) && ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) && ( f_fRemovePermanently == TRUE ) ) + { + /* Transform event into no-operation. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pDestinationChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* The event remove from the list will be done below. */ + + /* Clear the copy event created flag. */ + pDestinationChanEntry->fCopyEventCreated = FALSE; + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /*=======================================================================*/ + /* Remove the events from the mixer event list.*/ + /*=======================================================================*/ + /*=======================================================================*/ + + /*=======================================================================*/ + /* Remove the Load or Accumulate event from the event list. */ + + if ( fLastEvent == FALSE ) + { + /*=======================================================================*/ + /* Remove the Accumulate event from the event list. */ + + /* We saved the Load or Accumulate event above. We also saved the previous event. Use those. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, usLoadOrAccumulateEventIndex ); + + /* Now modify the previous last event. */ + pLastEventEntry->usNextEventPtr = pLoadEventEntry->usNextEventPtr; + + /* Modify the previous node. */ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + + WriteParams.usWriteData = pLastEventEntry->usNextEventPtr; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if this is the first load event on the bridge. */ + if ( pBridgeEntry->usFirstLoadEventPtr == usLoadOrAccumulateEventIndex ) + { + pBridgeEntry->usFirstLoadEventPtr = pLoadEventEntry->usNextEventPtr; + } + + /* Check if this was the first load of all bridges. */ + if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex ) + { + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pLoadEventEntry->usNextEventPtr; + } + + /*=======================================================================*/ + } + else /* if ( fLastEvent == TRUE ) */ + { + /*=======================================================================*/ + /* Remove the Load event from the event list. */ + + /* Look for the entry that is pointing at the first entry of our mixer. */ + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usLoadOrAccumulateEventIndex, 0, &usPreviousEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* An Entry was found, now, modify it's value. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex ); + + /* Check if this is a Sout copy event. */ + if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_COPY ) + { + /* No more previous bridges. */ + fSoutCopyEvent = TRUE; + } + + /* Now modify the previous last Store or Sub-Store or Head-Node event from another bridge/channel. */ + pTempEntry->usNextEventPtr = pStoreEventEntry->usNextEventPtr; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Modify the last node of the previous bridge/channel to point to the next bridge. */ + + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.ulWriteAddress += 4; + + WriteParams.usWriteData = pTempEntry->usNextEventPtr; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Set the event pointer info in the bridge stucture. */ + + if ( pBridgeEntry->usFirstLoadEventPtr == pDestinationChanEntry->usLoadEventIndex ) + { + UINT16 usChannelIndex; + tPOCT6100_API_CHANNEL pTempEchoChanEntry; + + pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX; + pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX; + + /* Find the next channel in this conference that could give us valid values. */ + for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex ); + + if ( ( usChannelIndex != f_usDestinationChannelIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) ) + { + if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) + { + tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant; + + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex ); + + if ( pTempParticipant->fFlexibleMixerCreated == TRUE ) + { + pBridgeEntry->usFirstSubStoreEventPtr = pTempEchoChanEntry->usSubStoreEventIndex; + pBridgeEntry->usFirstLoadEventPtr = pTempEchoChanEntry->usLoadEventIndex; + break; + } + } + } + } + } + + /* Reprogram the TSST entry correctly if the extra SIN TSI entry was released. */ + if ( ( pDestinationChanEntry->usExtraSinTsiDependencyCnt == 1 ) && ( f_fRemovePermanently == TRUE ) ) + { + if ( pDestinationChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pDestinationChanEntry->usSinTsstIndex, + pDestinationChanEntry->usSinSoutTsiMemIndex, + pDestinationChanEntry->TdmConfig.bySinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* If the silence TSI is loaded on this port, update with the original sin TSI. */ + if ( pDestinationChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) + { + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pDestinationChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = pDestinationChanEntry->usSinSoutTsiMemIndex; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Reprogram the TSST entry correctly if the extra RIN TSI entry was released. */ + if ( ( pDestinationChanEntry->usExtraRinTsiDependencyCnt == 1 ) && ( f_fRemovePermanently == TRUE ) ) + { + if ( pDestinationChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pDestinationChanEntry->usRinTsstIndex, + pDestinationChanEntry->usRinRoutTsiMemIndex, + pDestinationChanEntry->TdmConfig.byRinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /*=======================================================================*/ + /* Update the global mixer pointers. */ + + if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex && + pSharedInfo->MixerInfo.usLastBridgeEventPtr == pDestinationChanEntry->usSubStoreEventIndex ) + { + /* There is no more bridge entry in the mixer link list. */ + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX; + pSharedInfo->MixerInfo.usLastBridgeEventPtr = cOCT6100_INVALID_INDEX; + } + else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex ) + { + pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pStoreEventEntry->usNextEventPtr; + } + else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == pDestinationChanEntry->usSubStoreEventIndex ) + { + pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex; + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Check if must remove the Sin copy event from the list. */ + + if ( ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) && ( f_fRemovePermanently == TRUE ) ) + { + /* Now remove the copy event from the event list. */ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pDestinationChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*=======================================================================*/ + + + + /*=======================================================================*/ + + if ( f_fRemovePermanently == TRUE ) + { + /* Set the event entries as free. */ + pLoadEventEntry->fReserved = FALSE; + pLoadEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + + pStoreEventEntry->fReserved = FALSE; + pStoreEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + + if ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) + { + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, pDestinationChanEntry->usSinCopyEventIndex ); + + pCopyEventEntry->fReserved = FALSE; + pCopyEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + } + } + + /* Flexible mixer for this channel not created anymore. */ + pDestinationParticipant->fFlexibleMixerCreated = FALSE; + + /*=======================================================================*/ + } + + /*=======================================================================*/ + } + else /* if ( pDestinationChanEntry->fFlexibleMixerCreated == FALSE ) */ + { + /* This point should never be reached. */ + return cOCT6100_ERR_FATAL_C9; + } + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseBridgeEntry + +Description: Release an entry from the bridge list. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_usBridgeIndex List entry reserved. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseBridgeEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usBridgeIndex ) +{ + PVOID pBridgeAlloc; + UINT32 ulResult; + + mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBridgeAlloc ) + + ulResult = OctapiLlmAllocDealloc( pBridgeAlloc, f_usBridgeIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_2A; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetPrevLastSubStoreEvent + +Description: This function will search for the first valid LastSubStoreEvent + in a bridge located before the current bridge in the bridge + link list. + + If the function does not find an event before reaching the end + of the mixers list, then the event head node will be used as the + last Store or SubStore event. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pusBridgeEntry Bridge entry. +f_usBridgeFirstLoadEventPtr Load index to check against. +First valid sub store index. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetPrevLastSubStoreEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usBridgeIndex, + IN UINT16 f_usBridgeFirstLoadEventPtr, + OUT PUINT16 f_pusLastSubStoreEventIndex ) +{ + tPOCT6100_API_CONF_BRIDGE pBridgeEntry; + tPOCT6100_API_MIXER_EVENT pTempMixerEntry; + UINT16 usNextEventPtr; + UINT16 usHeadEventPtr; + UINT16 usLastSubStoreEventPtr; + UINT32 ulLoopCount = 0; + UINT16 usCurrentPtr; + UINT32 ulResult = cOCT6100_ERR_OK; + + /* Get current entry to obtain the link to the previous entry.*/ + mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex ); + + /* Since we have flexible bridges, we have to */ + /* run down the list and check for the appropriate event. */ + + /* Travel down the list for the last Store or Sub/Store event before the bridge. */ + + if ( f_pApiInstance->pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX ) + { + /* The only node in the list then is the head node.*/ + usHeadEventPtr = cOCT6100_MIXER_HEAD_NODE; + } + else + { + usHeadEventPtr = f_pApiInstance->pSharedInfo->MixerInfo.usLastSoutCopyEventPtr; + } + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempMixerEntry, usHeadEventPtr ); + usLastSubStoreEventPtr = usHeadEventPtr; + usNextEventPtr = pTempMixerEntry->usNextEventPtr; + usCurrentPtr = usHeadEventPtr; + while( usCurrentPtr != f_usBridgeFirstLoadEventPtr ) + { + if ( ( pTempMixerEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE ) + || ( pTempMixerEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_SUB_STORE ) ) + { + usLastSubStoreEventPtr = usNextEventPtr; + } + + /* Next pointer. */ + usCurrentPtr = usNextEventPtr; + usNextEventPtr = pTempMixerEntry->usNextEventPtr; + + /* Check if next event pointer is valid. */ + if ( ( ( f_usBridgeFirstLoadEventPtr != usCurrentPtr ) + && ( pTempMixerEntry->usNextEventPtr == cOCT6100_INVALID_INDEX ) ) + || ( pTempMixerEntry->usNextEventPtr == cOCT6100_MIXER_HEAD_NODE ) ) + return cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND; + + if ( usNextEventPtr != cOCT6100_INVALID_INDEX ) + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempMixerEntry, usNextEventPtr ); + + ulLoopCount++; + if ( ulLoopCount == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_FATAL_CA; + } + + /* Return the result to the user. */ + *f_pusLastSubStoreEventIndex = usLastSubStoreEventPtr; + + return ulResult; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetPreviousEvent + +Description: This is a recursive function, it requires an entry event index and + will run down the list until it finds the node just before the one + required. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_usEntryIndex Event entry index. +f_pusBridgeEntry Bridge entry. +f_pusPreviousIndex Previous index. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetPreviousEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usEntryIndex, + IN UINT16 f_usSearchedIndex, + IN UINT16 f_usLoopCnt, + OUT PUINT16 f_pusPreviousIndex ) +{ + tPOCT6100_API_MIXER_EVENT pCurrentEntry; + UINT32 ulResult; + + /* Get current entry to obtain the link to the previous entry. */ + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pCurrentEntry, f_usEntryIndex ); + + /* Avoid stack overflows. */ + if ( f_usLoopCnt == cOCT6100_MAX_MIXER_EVENTS ) + return cOCT6100_ERR_FATAL_E3; + + if ( pCurrentEntry->usNextEventPtr == cOCT6100_INVALID_INDEX ) + { + /* Event not found. */ + ulResult = cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND; + } + else if ( pCurrentEntry->usNextEventPtr == f_usSearchedIndex ) + { + /* We found our node. */ + *f_pusPreviousIndex = f_usEntryIndex; + ulResult = cOCT6100_ERR_OK; + } + else + { + /* Keep searching.*/ + f_usLoopCnt++; + ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pCurrentEntry->usNextEventPtr, f_usSearchedIndex, f_usLoopCnt, f_pusPreviousIndex ); + } + + return ulResult; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiBridgeSetDominantSpeaker + +Description: This function will set the index of the dominant speaker + for the channel index specified. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to + keep the present state of the chip and all its + resources. + +f_usChannelIndex Index of the channel where the API must set the + current dominant speaker for the conference. +f_usDominantSpeakerIndex Index of the channel which is the dominant + speaker in the conference. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiBridgeSetDominantSpeaker( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usChannelIndex, + IN UINT16 f_usDominantSpeakerIndex ) +{ + UINT32 ulBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulResult; + UINT32 ulTempData; + UINT32 ulMask; + + tPOCT6100_API_CHANNEL pEchoChanEntry; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, f_usChannelIndex ); + + ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst; + ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst.byBitOffset; + ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst.byFieldSize; + + /* Retrieve the current configuration. */ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + ulTempData |= ( ( f_usDominantSpeakerIndex ) << ulFeatureBitOffset ); + + /* Save the new dominant speaker. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseFlexConfParticipantEntry + +Description: Release an entry from the flexible conferencing participant + list. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_usParticipantIndex List entry reserved. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseFlexConfParticipantEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usParticipantIndex ) +{ + PVOID pParticipantAlloc; + UINT32 ulResult; + + mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pParticipantAlloc ) + + ulResult = OctapiLlmAllocDealloc( pParticipantAlloc, f_usParticipantIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_2A; + + return cOCT6100_ERR_OK; +} +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_debug.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to debug the OCT6100. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 58 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "oct6100api/oct6100_apiud.h" +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_channel_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_debug_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_debug_priv.h" +#include "oct6100_version.h" + + +/**************************** PRIVATE FUNCTIONS ****************************/ + +#ifndef cOCT6100_REMOVE_EVENTS +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_events.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to retrieve tone and playout events. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 79 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_events_inst.h" +#include "oct6100api/oct6100_tone_detection_inst.h" +#include "oct6100api/oct6100_playout_buf_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_events_pub.h" +#include "oct6100api/oct6100_tone_detection_pub.h" +#include "oct6100api/oct6100_playout_buf_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_events_priv.h" +#include "oct6100_tone_detection_priv.h" +#include "oct6100_playout_buf_priv.h" + +/**************************** PUBLIC FUNCTIONS *****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100EventGetTone + +Description: Retreives an array of tone events. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pEventGetTone Pointer to structure used to store the Tone events. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100EventGetToneDef( + tPOCT6100_EVENT_GET_TONE f_pEventGetTone ) +{ + f_pEventGetTone->pToneEvent = NULL; + f_pEventGetTone->ulMaxToneEvent = 1; + f_pEventGetTone->ulNumValidToneEvent = cOCT6100_INVALID_VALUE; + f_pEventGetTone->fMoreEvents = FALSE; + f_pEventGetTone->fResetBufs = FALSE; + + return cOCT6100_ERR_OK; +} + + +static UINT32 Oct6100EventGetTone( + tPOCT6100_INSTANCE_API f_pApiInstance, + tPOCT6100_EVENT_GET_TONE f_pEventGetTone ) +{ + tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; + tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; + UINT32 ulSerRes = cOCT6100_ERR_OK; + UINT32 ulFncRes = cOCT6100_ERR_OK; + + /* Set the process context of the serialize structure. */ + SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; + ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; + + /* Seize all list semaphores needed by this function. */ + SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; + ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); + if ( ulSerRes == cOCT6100_ERR_OK ) + { + /* Call the serialized function. */ + ulFncRes = Oct6100EventGetToneSer( f_pApiInstance, f_pEventGetTone ); + } + else + { + return ulSerRes; + } + + /* Release the seized semaphores. */ + ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); + + /* If an error occured then return the error code. */ + if ( ulSerRes != cOCT6100_ERR_OK ) + return ulSerRes; + if ( ulFncRes != cOCT6100_ERR_OK ) + return ulFncRes; + + return cOCT6100_ERR_OK; +} + + + +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetEventsSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of the tone events and playout events + software buffers. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetEventsSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + + { + UINT32 ulTempVar; + + /* Memory needed by soft tone event buffers. */ + + /* Add 1 to the circular buffer such that all user requested events can fit in the circular queue. */ + f_pInstSizes->ulSoftToneEventsBuffer = ( f_pOpenChip->ulSoftToneEventsBufSize + 1 ) * sizeof( tOCT6100_API_TONE_EVENT ); + + /* Round off the sizes of the soft buffers above. */ + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulSoftToneEventsBuffer, ulTempVar ) + } + + { + UINT32 ulTempVar; + + /* Memory needed by soft playout stop event buffers. */ + if ( f_pOpenChip->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE ) + { + f_pInstSizes->ulSoftBufPlayoutEventsBuffer = ( f_pOpenChip->ulSoftBufferPlayoutEventsBufSize + 1 ) * sizeof( tOCT6100_API_BUFFER_PLAYOUT_EVENT ); + + /* Round off the sizes of the soft buffers above. */ + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulSoftBufPlayoutEventsBuffer, ulTempVar ) + } + else /* if ( f_pInstSizes->ulSoftBufferPlayoutEventsBufSize == cOCT6100_INVALID_VALUE ) */ + { + f_pInstSizes->ulSoftBufPlayoutEventsBuffer = 0; + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100EventGetToneSer + +Description: Retreives an array of tone event from the software event buffer. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pEventGetTone Pointer to structure which will contain the retreived + events. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100EventGetToneSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_EVENT_GET_TONE f_pEventGetTone ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_TONE_EVENT pSoftEvent; + UINT32 ulSoftReadPnt; + UINT32 ulSoftWritePnt; + UINT32 ulSoftBufSize; + UINT32 ulNumEventsReturned; + UINT32 ulResult; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Check the parameters given by the user. */ + if ( f_pEventGetTone->fResetBufs != TRUE && + f_pEventGetTone->fResetBufs != FALSE ) + return cOCT6100_ERR_EVENTS_GET_TONE_RESET_BUFS; + + /* Check max tones. */ + if ( f_pEventGetTone->ulMaxToneEvent > pSharedInfo->ChipConfig.ulSoftToneEventsBufSize ) + return cOCT6100_ERR_EVENTS_MAX_TONES; + + if ( f_pEventGetTone->fResetBufs == FALSE ) + { + /* Check if the events need to be fetched from the chip buffer. */ + ulSoftReadPnt = pSharedInfo->SoftBufs.ulToneEventBufferReadPtr; + ulSoftWritePnt = pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + if ( ulSoftReadPnt == ulSoftWritePnt ) + { + ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, f_pEventGetTone->fResetBufs ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* If there are no events in the soft buffer then there are none in the chip */ + /* either, so return the empty case. Else, return the events in the buffer. */ + ulSoftReadPnt = pSharedInfo->SoftBufs.ulToneEventBufferReadPtr; + ulSoftWritePnt = pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + ulSoftBufSize = pSharedInfo->SoftBufs.ulToneEventBufferSize; + + if ( ulSoftReadPnt != ulSoftWritePnt ) + { + ulNumEventsReturned = 0; + + while( (ulSoftReadPnt != ulSoftWritePnt) && ( ulNumEventsReturned != f_pEventGetTone->ulMaxToneEvent) ) + { + /* Get a pointer to the first event in the buffer. */ + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += ulSoftReadPnt; + + f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulChannelHndl = pSoftEvent->ulChannelHandle; + f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulUserChanId = pSoftEvent->ulUserChanId; + f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulTimestamp = pSoftEvent->ulTimestamp; + f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulEventType = pSoftEvent->ulEventType; + f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulToneDetected = pSoftEvent->ulToneDetected; + f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulExtToneDetectionPort = pSoftEvent->ulExtToneDetectionPort; + + /* Update the pointers of the soft buffer. */ + ulSoftReadPnt++; + if ( ulSoftReadPnt == ulSoftBufSize ) + ulSoftReadPnt = 0; + + ulNumEventsReturned++; + } + + pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = ulSoftReadPnt; + + /* Detemine if there are more events pending in the soft buffer. */ + if ( ulSoftReadPnt != ulSoftWritePnt ) + f_pEventGetTone->fMoreEvents = TRUE; + else /* ( ulSoftReadPnt == ulSoftWritePnt ) */ + { + f_pEventGetTone->fMoreEvents = FALSE; + + /* Remember this state in the interrupt manager. */ + pSharedInfo->IntrptManage.fToneEventsPending = FALSE; + } + + f_pEventGetTone->ulNumValidToneEvent = ulNumEventsReturned; + } + else + { + /* No valid tone.*/ + f_pEventGetTone->ulNumValidToneEvent = 0; + f_pEventGetTone->fMoreEvents = FALSE; + + /* Remember this state in the interrupt manager. */ + pSharedInfo->IntrptManage.fToneEventsPending = FALSE; + + return cOCT6100_ERR_EVENTS_TONE_BUF_EMPTY; + } + } + else /* ( f_pEventGetTone->fResetBufs == TRUE ) */ + { + /* Empty the hardware buffer. */ + ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, f_pEventGetTone->fResetBufs ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* If the buffers are to be reset then update the pointers and full flag. */ + pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = 0; + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + f_pEventGetTone->fMoreEvents = FALSE; + f_pEventGetTone->ulNumValidToneEvent = 0; + + /* Remember this state in the interrupt manager. */ + pSharedInfo->IntrptManage.fToneEventsPending = FALSE; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiTransferToneEvents + +Description: Transfers all tone events from the PGSP event out chip buffer + to the soft buffer. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_ulResetBuf Reset flag. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiTransferToneEvents( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulResetBuf ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_TONE_EVENT pSoftEvent; + tPOCT6100_API_CHANNEL pEchoChannel; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_READ_BURST_PARAMS BurstParams; + UINT32 ulChipBufFill; + UINT32 ulChipWritePtr = 0; + UINT32 ulChipReadPtr = 0; + + UINT32 usChannelIndex; + UINT32 ulBaseTimestamp; + UINT32 ulToneCnt; + UINT32 ulNumWordsToRead; + + UINT32 ulResult; + UINT32 i, j; + UINT16 usReadData; + UINT16 ausReadData[ cOCT6100_NUM_WORDS_PER_TONE_EVENT ]; + + UINT32 ulExtToneDetectionPort; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* If the buffer is to be reset then clear the overflow flag. */ + if ( f_ulResetBuf == TRUE ) + { + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0; + } + + /* Set some parameters of read struct. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Get the current read pointer of the chip buffer. */ + ReadParams.ulReadAddress = cOCT6100_TONE_EVENT_READ_PTR_REG; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulChipReadPtr = usReadData; + + /* Now get the current write pointer. */ + ReadParams.ulReadAddress = cOCT6100_TONE_EVENT_WRITE_PTR_REG; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulChipWritePtr = usReadData; + + ulChipBufFill = (( ulChipWritePtr - ulChipReadPtr ) & ( cOCT6100_NUM_PGSP_EVENT_OUT - 1 )); + + /* Set some parameters of write structs. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + BurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Read in the tone event one at a time. */ + for ( i = 0; i < ulChipBufFill; i++ ) + { + /* Skip the event processing if the buffer is to be reset. */ + if ( f_ulResetBuf == TRUE ) + { + /* Update the control variables of the buffer. */ + ulChipReadPtr++; + if ( cOCT6100_NUM_PGSP_EVENT_OUT == ulChipReadPtr ) + ulChipReadPtr = 0; + } + else + { + /* Read in the event only if there's enough room in the soft buffer, and */ + /* the chip buffer is NOT to be reset. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + { + BurstParams.ulReadAddress = cOCT6100_PGSP_EVENT_OUT_BASE + ( ulChipReadPtr * cOCT6100_PGSP_TONE_EVENT_SIZE ); + BurstParams.pusReadData = ausReadData; + + ulNumWordsToRead = cOCT6100_PGSP_TONE_EVENT_SIZE / 2; + + while ( ulNumWordsToRead > 0 ) + { + if ( ulNumWordsToRead > pSharedInfo->ChipConfig.usMaxRwAccesses ) + { + BurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses; + } + else + { + BurstParams.ulReadLength = ulNumWordsToRead; + } + + mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + BurstParams.pusReadData += BurstParams.ulReadLength; + BurstParams.ulReadAddress += BurstParams.ulReadLength * 2; + + ulNumWordsToRead -= BurstParams.ulReadLength; + } + + /* Verify if the event is valid. */ + if ( ( ausReadData[ 0 ] & cOCT6100_VALID_TONE_EVENT ) == 0x0 ) + return cOCT6100_ERR_FATAL_2D; + + /* First extract the channel number of the tone event. */ + usChannelIndex = ausReadData[ 1 ] & 0x3FF; + + /* Now the timestamp. */ + ulBaseTimestamp = ausReadData[ 2 ] << 16; + ulBaseTimestamp |= ausReadData[ 3 ]; + + /* This timestamp is 256 in adwance, must remove 256 frames. */ + ulBaseTimestamp -= 256; + + /* Fetch the channel stucture to validate which event can be reported. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, usChannelIndex ); + + if ( pEchoChannel->fReserved != TRUE ) + { + /* Update the control variables of the buffer. */ + ulChipReadPtr++; + if ( ulChipReadPtr == cOCT6100_NUM_PGSP_EVENT_OUT ) + ulChipReadPtr = 0; + + /* This channel has been closed since the generation of the event. */ + continue; + } + + /* Extract the extended tone detection port if available. */ + if ( pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_SIN_PORT_MODE ) + { + ulExtToneDetectionPort = cOCT6100_CHANNEL_PORT_SIN; + } + else if ( pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_RIN_PORT_MODE ) + { + ulExtToneDetectionPort = cOCT6100_CHANNEL_PORT_RIN; + + /* Modify the channel index. */ + usChannelIndex = pEchoChannel->usExtToneChanIndex; + + /* Change the channel entry to the original one for statistical purposes. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, usChannelIndex ); + + } + else /* pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_DISABLED */ + { + ulExtToneDetectionPort = cOCT6100_INVALID_VALUE; + } + + ulToneCnt = 0; + /* Verify all the possible events that might have been detected. */ + for ( j = 4; j < cOCT6100_NUM_WORDS_PER_TONE_EVENT; j++ ) + { + if ( (( ausReadData[ j ] >> 8 ) & 0x7 ) != 0x0 ) + { + /* This tone generated an event, now check if event is masked for the channel. */ + if ((( pEchoChannel->aulToneConf[ ulToneCnt / 32 ] >> ( 31 - ( ulToneCnt % 32 ))) & 0x1) == 1 ) + { + /* If enough space. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + { + /* The tone event is not masked, The API can create a soft tone event. */ + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + /* Decode the event type. */ + switch(( ausReadData[ j ] >> 8 ) & 0x7 ) + { + case 1: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + case 2: + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + break; + case 3: + /* This one is a little tricky. We first */ + /* generate the "PRESENT" event and then generate the "STOP" event. */ + + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; + pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; + pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */ + pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1; + pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + /* If enough space for the "STOP" event. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + { + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + + /* We continue in the loop in order to empty the hardware buffer. */ + continue; + } + + break; + case 4: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + default: + pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++; + /* do not process this packet*/ + continue; + } + + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; + pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; + pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); + pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + /* Set the interrupt manager such that the user knows that some tone events */ + /* are pending in the software Q. */ + pSharedInfo->IntrptManage.fToneEventsPending = TRUE; + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + + /* We continue in the loop in order to empty the hardware buffer. */ + } + } + else + { + BOOL fSSTone; + + ulResult = Oct6100ApiIsSSTone( + f_pApiInstance, + pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID, + &fSSTone ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( fSSTone == TRUE ) + { + /* Check if this is a "PRESENT" or "STOP" event */ + switch( ( ( ausReadData[ j ] >> 8 ) & 0x7 ) ) + { + case 1: + /* This is a signaling system present event. Keep this in the instance memory. */ + pEchoChannel->ulLastSSToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + pEchoChannel->ulLastSSToneTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); + break; + case 2: + /* This is the "STOP" event, invalidate the last value. The user does not want to know about this. */ + pEchoChannel->ulLastSSToneDetected = cOCT6100_INVALID_VALUE; + pEchoChannel->ulLastSSToneTimestamp = cOCT6100_INVALID_VALUE; + break; + default: + break; + } + } + } + } + ulToneCnt++; + + /* Check the other tone of this word. */ + if ( ( ausReadData[ j ] & 0x7 ) != 0x0 ) + { + if ((( pEchoChannel->aulToneConf[ ulToneCnt / 32 ] >> ( 31 - ( ulToneCnt % 32 ))) & 0x1) == 1 ) + { + /* If enough space. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + { + /* The tone event is not masked, The API can create a soft tone event. */ + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + /* Decode the event type. */ + switch(( ausReadData[ j ] ) & 0x7 ) + { + case 1: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + case 2: + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + break; + case 3: + /* This one is a little tricky. We first */ + /* generate the "PRESENT" event and then generate the "STOP" event. */ + + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; + pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; + pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */ + pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1; + pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + /* If enough space for the "STOP" event. */ + if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) && + ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) ) + { + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + pSoftEvent->ulEventType = cOCT6100_TONE_STOP; + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + + /* We continue in the loop in order to empty the hardware buffer. */ + continue; + } + + break; + case 4: + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + break; + default: + pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++; + /* Do not process this packet. */ + continue; + } + + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; + pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; + pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); + pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort; + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + /* Set the interrupt manager such that the user knows that some tone events */ + /* are pending in the software Q. */ + pSharedInfo->IntrptManage.fToneEventsPending = TRUE; + + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + + /* We continue in the loop in order to empty the hardware buffer. */ + } + } + else + { + BOOL fSSTone; + + ulResult = Oct6100ApiIsSSTone( + f_pApiInstance, + pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID, + &fSSTone ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( fSSTone == TRUE ) + { + /* Check if this is a "PRESENT" event. */ + switch ( ( ausReadData[ j ] ) & 0x7 ) + { + case 1: + /* This is a signaling system present event. Keep this in the instance memory. */ + pEchoChannel->ulLastSSToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID; + pEchoChannel->ulLastSSToneTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ); + break; + case 2: + /* This is the "STOP" event, invalidate the last value. The user does not want to know about this. */ + pEchoChannel->ulLastSSToneDetected = cOCT6100_INVALID_VALUE; + pEchoChannel->ulLastSSToneTimestamp = cOCT6100_INVALID_VALUE; + break; + default: + break; + } + } + } + } + ulToneCnt++; + } + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + + /* We continue in the loop in order to empty the hardware buffer. */ + } + + /* Update the control variables of the buffer. */ + ulChipReadPtr++; + if ( ulChipReadPtr == cOCT6100_NUM_PGSP_EVENT_OUT ) + ulChipReadPtr = 0; + } + } + + /* Write the value of the new Read pointer.*/ + WriteParams.ulWriteAddress = cOCT6100_TONE_EVENT_READ_PTR_REG; + WriteParams.usWriteData = (UINT16)( ulChipReadPtr ); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100BufferPlayoutTransferEvents + +Description: Check all channels that are currently playing a buffer and + generate an event if a buffer has stopped playing. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_ulResetBuf Reset flag. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100BufferPlayoutTransferEvents( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulResetBuf ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pEchoChannel; + + UINT32 ulChannelIndex; + UINT32 ulResult; + UINT32 ulLastBufPlayoutEventBufferOverflowCnt; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* If the buffer is to be reset then clear the overflow flag. */ + if ( f_ulResetBuf == TRUE ) + { + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt = 0; + /* We are done for now. */ + /* No need to check for new events since the user requested to empty the soft buffer. */ + return cOCT6100_ERR_OK; + } + + /* Check if buffer playout has been activated on some ports. */ + if ( pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts == 0 ) + { + /* Buffer playout has not been activated on any channel, */ + /* let's not waste time here. */ + return cOCT6100_ERR_OK; + } + + /* Save the current overflow count. We want to know if an overflow occured to get out of the loop. */ + ulLastBufPlayoutEventBufferOverflowCnt = pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt; + + /* Search through the list of API channel entry for the ones that need playout event checking. */ + for ( ulChannelIndex = 0; ulChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; ulChannelIndex++ ) + { + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, ulChannelIndex ); + + /* Check if buffer playout is active on this channel, using the optimization flag. */ + /* This flag is redundant of other flags used for playout, but will make the above loop */ + /* much faster. This is needed since this function is called very frequently on systems */ + /* which use buffer playout stop events. */ + if ( pEchoChannel->fBufPlayoutActive == TRUE ) + { + /* Read in the event only if there's enough room in the soft buffer. */ + if ( ulLastBufPlayoutEventBufferOverflowCnt == pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) + { + /* Check Rout buffer playout first. */ + if ( ( pEchoChannel->fRinBufPlayoutNotifyOnStop == TRUE ) + && ( pEchoChannel->fRinBufPlaying == TRUE ) ) + { + ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance, ulChannelIndex, cOCT6100_CHANNEL_PORT_ROUT, TRUE, NULL ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else /* if ( ulLastBufPlayoutEventBufferOverflowCnt != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) */ + { + /* Get out of the loop, no more events can be inserted in the soft buffer. */ + break; + } + + /* An overflow might have been detected in the lower level function. */ + /* Check the overflow count once again to make sure there might be room for a next event. */ + if ( ulLastBufPlayoutEventBufferOverflowCnt == pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) + { + /* Check Sout buffer playout. */ + if ( ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == TRUE ) + && ( pEchoChannel->fSoutBufPlaying == TRUE ) ) + { + ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance, ulChannelIndex, cOCT6100_CHANNEL_PORT_SOUT, TRUE, NULL ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else /* if ( ulLastBufPlayoutEventBufferOverflowCnt != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) */ + { + /* Get out of the loop, no more events can be inserted in the soft buffer. */ + break; + } + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100BufferPlayoutCheckForSpecificEvent + +Description: Check a specific channel/port for playout buffer events. + If asked to, save this event to the software event buffer. + Return a flag specifying whether the event was detected or not. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_ulChannelIndex Index of the channel to be checked. +f_ulChannelPort Port of the channel to be checked. +f_fSaveToSoftBuffer Save event to software buffer. +f_pfEventDetected Whether or not an event was detected. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100BufferPlayoutCheckForSpecificEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulChannelPort, + IN BOOL f_fSaveToSoftBuffer, + OUT PBOOL f_pfEventDetected ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_BUFFER_PLAYOUT_EVENT pSoftEvent; + tPOCT6100_API_CHANNEL pEchoChannel; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_GET_TIME GetTimeParms; + + UINT32 ulResult; + UINT16 usReadData; + UINT32 ulReadPtrBytesOfst; + UINT32 ulReadPtrBitOfst; + UINT32 ulReadPtrFieldSize; + + UINT32 ulWritePtrBytesOfst; + UINT32 ulWritePtrBitOfst; + UINT32 ulWritePtrFieldSize; + + UINT32 ulPlayoutBaseAddress; + UINT32 ulTempData; + UINT32 ulReadPtr; + UINT32 ulMask; + UINT32 ulWritePtr; + UINT32 ulUserEventId; + UINT32 ulEventType; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Compare the read and write pointers for matching. If they matched, playout stopped. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex ); + + /* Set the playout feature base address. */ + ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_ulChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; + + if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + /* Check on the Rout port. */ + ulUserEventId = pEchoChannel->ulRinUserBufPlayoutEventId; + ulEventType = pEchoChannel->byRinPlayoutStopEventType; + + ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4; + ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset; + ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize; + + ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4; + ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset; + ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize; + } + else /* if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_SOUT ) */ + { + /* Check on the Sout port. */ + ulUserEventId = pEchoChannel->ulSoutUserBufPlayoutEventId; + ulEventType = pEchoChannel->bySoutPlayoutStopEventType; + + ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4; + ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset; + ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize; + + ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4; + ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset; + ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize; + } + + /* Retrieve the current write pointer. */ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulPlayoutBaseAddress + ulWritePtrBytesOfst, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask ); + + /* Store the write pointer.*/ + ulWritePtr = ( ulTempData & ulMask ) >> ulWritePtrBitOfst; + + /* Read the read pointer.*/ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst; + + /* Optimize this access by only reading the word we are interested in. */ + if ( ulReadPtrBitOfst < 16 ) + ReadParams.ulReadAddress += 2; + + /* Must read in memory directly since this value is changed by hardware */ + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Move data at correct position according to what was read. */ + if ( ulReadPtrBitOfst < 16 ) + ulTempData = usReadData; + else + ulTempData = usReadData << 16; + + mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask ); + + /* Store the read pointer. */ + ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst; + + /* Playout has finished when the read pointer reaches the write pointer. */ + if ( ulReadPtr != ulWritePtr ) + { + /* Still playing -- do not generate an event. */ + if ( f_pfEventDetected != NULL ) + *f_pfEventDetected = FALSE; + } + else + { + /* Buffer stopped playing, generate an event here, if asked. */ + if ( ( f_fSaveToSoftBuffer == TRUE ) + && ( ( pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr ) + && ( ( pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize || pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr != 0 ) ) + { + /* The API can create a soft buffer playout event. */ + mOCT6100_GET_BUFFER_PLAYOUT_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr; + + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_ulChannelIndex; + pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId; + pSoftEvent->ulUserEventId = ulUserEventId; + pSoftEvent->ulChannelPort = f_ulChannelPort; + /* For now, only this type of event is available. */ + pSoftEvent->ulEventType = ulEventType; + + /* Generate millisecond timestamp. */ + GetTimeParms.pProcessContext = f_pApiInstance->pProcessContext; + ulResult = Oct6100UserGetTime( &GetTimeParms ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + pSoftEvent->ulTimestamp = ( GetTimeParms.aulWallTimeUs[ 0 ] / 1000 ); + pSoftEvent->ulTimestamp += ( GetTimeParms.aulWallTimeUs[ 1 ] ) * ( 0xFFFFFFFF / 1000 ); + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr == pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize ) + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr = 0; + + /* Set the interrupt manager such that the user knows that some playout events */ + /* are pending in the software Q. */ + pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = TRUE; + } + else if ( f_fSaveToSoftBuffer == TRUE ) + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt++; + } + + /* Update the channel entry to set the playing flag to FALSE. */ + + /* Select the port of interest. */ + if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + /* Decrement the number of active buffer playout ports. */ + /* No need to check anything here, it's been done in the calling function. */ + pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--; + + pEchoChannel->fRinBufPlaying = FALSE; + pEchoChannel->fRinBufPlayoutNotifyOnStop = FALSE; + + /* Clear optimization flag if possible. */ + if ( ( pEchoChannel->fSoutBufPlaying == FALSE ) + && ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == FALSE ) ) + { + /* Buffer playout is no more active on this channel. */ + pEchoChannel->fBufPlayoutActive = FALSE; + } + } + else /* f_ulChannelPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + /* Decrement the number of active buffer playout ports. */ + /* No need to check anything here, it's been done in the calling function. */ + pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--; + + pEchoChannel->fSoutBufPlaying = FALSE; + pEchoChannel->fSoutBufPlayoutNotifyOnStop = FALSE; + + /* Clear optimization flag if possible. */ + if ( ( pEchoChannel->fRinBufPlaying == FALSE ) + && ( pEchoChannel->fRinBufPlayoutNotifyOnStop == FALSE ) ) + { + /* Buffer playout is no more active on this channel. */ + pEchoChannel->fBufPlayoutActive = FALSE; + } + } + + /* Return that an event was detected. */ + if ( f_pfEventDetected != NULL ) + *f_pfEventDetected = TRUE; + } + + return cOCT6100_ERR_OK; +} + +#endif /* cOCT6100_REMOVE_EVENTS */ +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_interrupts.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the API's interrupt service routine and all of its + sub-functions. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 71 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_events_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_interrupts_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_events_priv.h" +#include "oct6100_interrupts_priv.h" + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100InterruptServiceRoutine + +Description: The API's interrupt service routine. This function clears all + register ROLs which have generated an interrupt and report the + events in the user supplied structure. Also, the tone event + and/or playout event buffer will be emptied if valid events + are present. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pIntFlags Pointer to structure containing event flags returned + to user. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100InterruptServiceRoutineDef( + tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ) +{ + f_pIntFlags->fFatalGeneral = FALSE; + f_pIntFlags->ulFatalGeneralFlags = 0x0; + f_pIntFlags->fFatalReadTimeout = FALSE; + + f_pIntFlags->fErrorRefreshTooLate = FALSE; + f_pIntFlags->fErrorPllJitter = FALSE; + + f_pIntFlags->fErrorOverflowToneEvents = FALSE; + + f_pIntFlags->fErrorH100OutOfSync = FALSE; + f_pIntFlags->fErrorH100ClkA = FALSE; + f_pIntFlags->fErrorH100ClkB = FALSE; + f_pIntFlags->fErrorH100FrameA = FALSE; + + f_pIntFlags->fToneEventsPending = FALSE; + f_pIntFlags->fBufferPlayoutEventsPending = FALSE; + + f_pIntFlags->fApiSynch = FALSE; + + + + return cOCT6100_ERR_OK; +} + + +static UINT32 Oct6100InterruptServiceRoutine( + tPOCT6100_INSTANCE_API f_pApiInstance, + tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ) +{ + tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; + tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; + UINT32 ulResult; + UINT32 ulFncRes; + + /* Set the process context of the serialize structure. */ + SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; + ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; + + /* Seize the serialization object for the ISR. */ + SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; + ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); + if ( ulResult == cOCT6100_ERR_OK ) + { + /* Call the serialized sub-function. */ + ulFncRes = Oct6100InterruptServiceRoutineSer( f_pApiInstance, f_pIntFlags ); + } + else + { + return ulResult; + } + + /* Release the serialization object. */ + ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check for an error in the sub-function. */ + if ( ulFncRes != cOCT6100_ERR_OK ) + return ulFncRes; + + return cOCT6100_ERR_OK; +} + + +/**************************** PRIVATE FUNCTIONS ****************************/ + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiIsrSwInit + +Description: Initializes portions of API instance associated to the API's + interrupt service routine. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiIsrSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Set the state of each interrupt group to disabled. The state will */ + /* be updated to the true configuration once the configure interrupts function is called. */ + pSharedInfo->IntrptManage.byFatalGeneralState = cOCT6100_INTRPT_DISABLED; + pSharedInfo->IntrptManage.byFatalMemoryState = cOCT6100_INTRPT_DISABLED; + pSharedInfo->IntrptManage.byErrorMemoryState = cOCT6100_INTRPT_DISABLED; + pSharedInfo->IntrptManage.byErrorH100State = cOCT6100_INTRPT_DISABLED; + pSharedInfo->IntrptManage.byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED; + + /* Indicate that the mclk interrupt is not active at the moment. */ + pSharedInfo->IntrptManage.fMclkIntrptActive = FALSE; + + /* Indicate that no buffer playout events are pending for the moment. */ + pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE; + + /* Indicate that no tone events are pending for the moment. */ + pSharedInfo->IntrptManage.fToneEventsPending = FALSE; + + /* The ISR has never been called. */ + pSharedInfo->IntrptManage.fIsrCalled = FALSE; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiIsrHwInit + +Description: Initializes the chip's interrupt registers. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pIntrptConfig Pointer to structure defining how the interrupts + should be configured. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiIsrHwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig ) +{ + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + /* Set some parameters of write struct. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /*==================================================================================*/ + /* Enable all the interrupts */ + + WriteParams.ulWriteAddress = 0x104; + WriteParams.usWriteData = 0x0001; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x204; + WriteParams.usWriteData = 0x1C05; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x304; + WriteParams.usWriteData = 0xFFFF; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x504; + WriteParams.usWriteData = 0x0001; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x704; + WriteParams.usWriteData = 0x0007; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==================================================================================*/ + + /* Calculate the number of mclk cycles in 1 ms. */ + f_pApiInstance->pSharedInfo->IntrptManage.ulNumMclkCyclesIn1Ms = f_pApiInstance->pSharedInfo->MiscVars.ulMclkFreq / 1000; + + /* Configure the interrupt registers as requested by the user. */ + ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100InterruptConfigureSer + +Description: Configure the operation of interrupt groups. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pIntrptConfig Pointer to interrupt configuration structure. +f_fCheckParams Check parameter enable flag. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100InterruptConfigureSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig, + IN BOOL f_fCheckParams ) +{ + tPOCT6100_API_INTRPT_CONFIG pIntrptConfig; + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + UINT32 ulResult; + + /* Check for errors. */ + if ( f_fCheckParams == TRUE ) + { + if ( f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE && + f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT ) + return cOCT6100_ERR_INTRPTS_FATAL_GENERAL_CONFIG; + if ( f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE && + f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT && + f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT ) + return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_CONFIG; + if ( f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE && + f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT && + f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT ) + return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_CONFIG; + if ( f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE && + f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT && + f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT ) + return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_CONFIG; + if ( f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE && + f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT && + f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT ) + return cOCT6100_ERR_INTRPTS_H100_ERROR_CONFIG; + + if ( f_pIntrptConfig->ulFatalMemoryTimeout < 10 || + f_pIntrptConfig->ulFatalMemoryTimeout > 10000 ) + return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_TIMEOUT; + if ( f_pIntrptConfig->ulErrorMemoryTimeout < 10 || + f_pIntrptConfig->ulErrorMemoryTimeout > 10000 ) + return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_TIMEOUT; + if ( f_pIntrptConfig->ulErrorOverflowToneEventsTimeout < 10 || + f_pIntrptConfig->ulErrorOverflowToneEventsTimeout > 10000 ) + return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_TIMEOUT; + if ( f_pIntrptConfig->ulErrorH100Timeout < 10 || + f_pIntrptConfig->ulErrorH100Timeout > 10000 ) + return cOCT6100_ERR_INTRPTS_H100_ERROR_TIMEOUT; + } + + /* Copy the configuration to the API instance. */ + pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig; + pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage; + + pIntrptConfig->byFatalGeneralConfig = (UINT8)( f_pIntrptConfig->ulFatalGeneralConfig & 0xFF ); + pIntrptConfig->byFatalMemoryConfig = (UINT8)( f_pIntrptConfig->ulFatalMemoryConfig & 0xFF ); + pIntrptConfig->byErrorMemoryConfig = (UINT8)( f_pIntrptConfig->ulErrorMemoryConfig & 0xFF ); + pIntrptConfig->byErrorOverflowToneEventsConfig = (UINT8)( f_pIntrptConfig->ulErrorOverflowToneEventsConfig & 0xFF ); + pIntrptConfig->byErrorH100Config = (UINT8)( f_pIntrptConfig->ulErrorH100Config & 0xFF ); + + f_pIntrptConfig->ulFatalMemoryTimeout = ((f_pIntrptConfig->ulFatalMemoryTimeout + 9) / 10) * 10; + pIntrptConfig->ulFatalMemoryTimeoutMclk = f_pIntrptConfig->ulFatalMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms; + + f_pIntrptConfig->ulErrorMemoryTimeout = ((f_pIntrptConfig->ulErrorMemoryTimeout + 9) / 10) * 10; + pIntrptConfig->ulErrorMemoryTimeoutMclk = f_pIntrptConfig->ulErrorMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms; + + f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = ((f_pIntrptConfig->ulErrorOverflowToneEventsTimeout + 9) / 10) * 10; + pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk = f_pIntrptConfig->ulErrorOverflowToneEventsTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms; + + f_pIntrptConfig->ulErrorH100Timeout = ((f_pIntrptConfig->ulErrorH100Timeout + 9) / 10) * 10; + pIntrptConfig->ulErrorH100TimeoutMclk = f_pIntrptConfig->ulErrorH100Timeout * pIntrptManage->ulNumMclkCyclesIn1Ms; + + /* Before writing the new configuration to the chip's registers, make sure that any */ + /* interrupts which are either disabled or have no timeout period are not on the */ + /* disabled interrupt list. */ + + /*==================================================================================*/ + if ( pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_DISABLE ) + pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_DISABLED; + else /* pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_NO_TIMEOUT */ + pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_ACTIVE; + + /*==================================================================================*/ + if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_DISABLE ) + pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_DISABLED; + else if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT ) + pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE; + else /* ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */ + { + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_DISABLED ) + pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE; + } + + /*==================================================================================*/ + if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_DISABLE ) + pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_DISABLED; + else if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT ) + pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE; + else /* (pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */ + { + if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_DISABLED ) + pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE; + } + + /*==================================================================================*/ + if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_DISABLE ) + pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED; + else if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_NO_TIMEOUT ) + pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE; + else /* (pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT ) */ + { + if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_DISABLED ) + pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE; + } + + /*==================================================================================*/ + if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_DISABLE ) + pIntrptManage->byErrorH100State = cOCT6100_INTRPT_DISABLED; + else if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_NO_TIMEOUT ) + pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE; + else /* (pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT ) */ + { + if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_DISABLED ) + pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE; + } + + /* Write to the interrupt registers to update the state of each interrupt group. */ + ulResult = Oct6100ApiWriteIeRegs( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100InterruptServiceRoutineSer + +Description: Serialized sub-function of API's interrupt service routine. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pIntFlags Pointer to structure containing event flags returned + to user. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100InterruptServiceRoutineSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulRegister210h; + UINT32 ulResult; + UINT16 usReadData; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Must update the statistics. Set parameters in read and write structs. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Start by reading registers 210h to determine if any modules have flagged an interrupt. */ + ReadParams.ulReadAddress = 0x210; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + ulRegister210h = usReadData; + + /* Update the extended mclk counter. */ + ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* If the mclk interrupt is active then check which interrupt timeout periods have expired. */ + ReadParams.ulReadAddress = 0x302; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + if ( (usReadData & 0x1) != 0 && pSharedInfo->IntrptManage.fMclkIntrptActive == TRUE ) + { + /* Update timeout periods. */ + ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + f_pIntFlags->fApiSynch = TRUE; + + /* Read registers 210h and 212h again to determine if any modules have flagged an interrupt. */ + ReadParams.ulReadAddress = 0x210; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + ulRegister210h = usReadData; + } + + /* Read the interrupt registers to determine what interrupt conditions have occured. */ + ulResult = Oct6100ApiReadIntrptRegs( f_pApiInstance, f_pIntFlags, ulRegister210h ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Empty the tone buffer if any events are pending. */ + ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the tone events pending flag. */ + f_pIntFlags->fToneEventsPending = pSharedInfo->IntrptManage.fToneEventsPending; + + /* Check for buffer playout events and insert in the software queue -- if activated. */ + if ( pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize != 0 ) + { + ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the buffer playout events pending flag. */ + f_pIntFlags->fBufferPlayoutEventsPending = pSharedInfo->IntrptManage.fBufferPlayoutEventsPending; + } + + /* Update the states of each interrupt group. */ + ulResult = Oct6100ApiUpdateIntrptStates( f_pApiInstance, f_pIntFlags ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check the state of the NLP timestamp if required.*/ + ulResult = Oct6100ApiCheckProcessorState( f_pApiInstance, f_pIntFlags ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write to the necessary IE registers. */ + ulResult = Oct6100ApiWriteIntrptRegs( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Schedule the next mclk interrupt, if one is needed. */ + ulResult = Oct6100ApiScheduleNextMclkIntrptSer( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */ + WriteParams.ulWriteAddress = 0x214; + WriteParams.usWriteData = 0x0000; + if ( pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY ) + WriteParams.usWriteData |= 0x4000; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Indicate that the interrupt ROLs have been treated. */ + WriteParams.ulWriteAddress = 0x212; + WriteParams.usWriteData = 0x8000; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReadIntrptRegs + +Description: Reads the interrupt registers of all modules currently + indicating an interrupt condition. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pIntFlags Pointer to an interrupt flag structure. +f_ulRegister210h Value of register 0x210. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReadIntrptRegs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags, + IN UINT32 f_ulRegister210h ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_ERROR_STATS pErrorStats; + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_WRITE_PARAMS WriteParams; + + UINT32 ulResult; + UINT16 usReadData; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulTempData = 0; + UINT32 ulCounterValue; + UINT32 ulMask; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + pErrorStats = &pSharedInfo->ErrorStats; + pIntrptManage = &pSharedInfo->IntrptManage; + + /* Set some parameters of read struct. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Set some parameters of write struct. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + + + /* CPU registers. */ + if ( (f_ulRegister210h & 0x00001) != 0 ) + { + /*=======================================================================*/ + /* Read registers of this module. */ + ReadParams.ulReadAddress = 0x102; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check which interrupt(s) were set. */ + if ( (usReadData & 0x0001) != 0 ) + { + f_pIntFlags->fFatalReadTimeout = TRUE; + pErrorStats->ulInternalReadTimeoutCnt++; + } + + pIntrptManage->usRegister102h = usReadData; + /*=======================================================================*/ + } + else + { + pIntrptManage->usRegister102h = 0x0; + } + + /* MAIN registers. */ + if ( (f_ulRegister210h & 0x00002) != 0 ) + { + /*=======================================================================*/ + /* Read registers of this module. */ + ReadParams.ulReadAddress = 0x202; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save current value in instance. */ + pIntrptManage->usRegister202h = usReadData; + + /* Check which interrupts were set. */ + if ( (usReadData & 0x0001) != 0 ) + { + f_pIntFlags->fErrorRefreshTooLate = TRUE; + pErrorStats->ulSdramRefreshTooLateCnt++; + } + if ( (usReadData & 0x0800) != 0 ) + { + f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_1; + f_pIntFlags->fFatalGeneral = TRUE; + pErrorStats->fFatalChipError = TRUE; + } + if ( (usReadData & 0x1000) != 0 ) + { + f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_2; + f_pIntFlags->fFatalGeneral = TRUE; + pErrorStats->fFatalChipError = TRUE; + } + if ( (usReadData & 0x0400) != 0 ) + { + f_pIntFlags->fErrorPllJitter = TRUE; + pErrorStats->ulPllJitterErrorCnt++; + + /* Update the PLL jitter error count here. */ + if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize; + + ulResult = Oct6100ApiReadDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + &ulTempData ); + + /* Read previous value set in the feature field. */ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + /* Update counter. */ + ulCounterValue = ulTempData & ulMask; + ulCounterValue = ulCounterValue >> ulFeatureBitOffset; + ulCounterValue ++; + /* Handle wrap around case. */ + ulCounterValue &= ( 1 << ulFeatureFieldLength ) - 1; + + /* Clear old counter value. */ + ulTempData &= (~ulMask); + ulTempData |= ulCounterValue << ulFeatureBitOffset; + + /* Write the DWORD where the field is located.*/ + ulResult = Oct6100ApiWriteDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + ulTempData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /*=======================================================================*/ + } + else + { + pIntrptManage->usRegister202h = 0x0; + } + + /* H.100 registers. */ + if ( (f_ulRegister210h & 0x00004) != 0 ) + { + /*=======================================================================*/ + /* Read registers of this module. */ + ReadParams.ulReadAddress = 0x302; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check which interrupts were set. */ + if ( (usReadData & 0x0100) != 0 ) + { + f_pIntFlags->fErrorH100OutOfSync = TRUE; + pErrorStats->ulH100OutOfSyncCnt++; + } + if ( (usReadData & 0x1000) != 0 ) + { + f_pIntFlags->fErrorH100FrameA = TRUE; + pErrorStats->ulH100FrameABadCnt++; + } + if ( (usReadData & 0x4000) != 0 ) + { + f_pIntFlags->fErrorH100ClkA = TRUE; + pErrorStats->ulH100ClkABadCnt++; + } + if ( (usReadData & 0x8000) != 0 ) + { + if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + { + f_pIntFlags->fErrorH100ClkB = TRUE; + pErrorStats->ulH100ClkBBadCnt++; + } + } + + pIntrptManage->usRegister302h = usReadData; + /*=======================================================================*/ + } + else + { + pIntrptManage->usRegister302h = 0x0; + } + + /* TDMIE registers. */ + if ( (f_ulRegister210h & 0x00010) != 0 ) + { + /*=======================================================================*/ + /* Read register. */ + ReadParams.ulReadAddress = 0x502; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check which interrupts were set. */ + if ( (usReadData & 0x0002) != 0 ) + { + f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_3; + f_pIntFlags->fFatalGeneral = TRUE; + pErrorStats->fFatalChipError = TRUE; + } + + pIntrptManage->usRegister502h = usReadData; + /*=======================================================================*/ + } + else + { + pIntrptManage->usRegister502h = 0x0; + } + + /* PGSP registers. */ + if ( (f_ulRegister210h & 0x00080) != 0 ) + { + /*=======================================================================*/ + /* Read register. */ + ReadParams.ulReadAddress = 0x702; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check which interrupts were set. */ + if ( (usReadData & 0x0002) != 0 ) + { + f_pIntFlags->fErrorOverflowToneEvents = TRUE; + pErrorStats->ulOverflowToneEventsCnt++; + } + + pIntrptManage->usRegister702h = usReadData; + /*=======================================================================*/ + } + else + { + pIntrptManage->usRegister702h = 0x0; + } + + + + /* If this is the first time the ISR is called, clear the ISR is not called bit */ + /* in external memory to signal the remote client that we are called. */ + if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE ) + { + /* Remember that we are being called. */ + pSharedInfo->IntrptManage.fIsrCalled = TRUE; + + if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize; + + ulResult = Oct6100ApiReadDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + &ulTempData ); + + /* Read previous value set in the feature field. */ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + /* Clear the field. */ + ulTempData &= (~ulMask); + + /* Write the DWORD where the field is located.*/ + ulResult = Oct6100ApiWriteDword( f_pApiInstance, + cOCT6100_POUCH_BASE + ulFeatureBytesOffset, + ulTempData ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiUpdateIntrptStates + +Description: Updates the state of all interrupt register groups. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pIntFlags Interrupt flags. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiUpdateIntrptStates( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ) +{ + tPOCT6100_API_INTRPT_CONFIG pIntrptConfig; + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + + pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig; + pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage; + + /*-----------------------------------------------------------------------*/ + if ( ( f_pIntFlags->fFatalReadTimeout == TRUE) && + pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT && + pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE ) + { + pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT; + pIntrptManage->ulFatalMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh; + pIntrptManage->ulFatalMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow; + } + /*-----------------------------------------------------------------------*/ + if ( (f_pIntFlags->fErrorRefreshTooLate == TRUE || + f_pIntFlags->fErrorPllJitter == TRUE ) && + pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT && + pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE ) + { + pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT; + pIntrptManage->ulErrorMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh; + pIntrptManage->ulErrorMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow; + } + /*-----------------------------------------------------------------------*/ + if ( (f_pIntFlags->fErrorOverflowToneEvents == TRUE) && + pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT && + pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE ) + { + pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_WILL_TIMEOUT; + pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh; + pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow = pIntrptManage->ulRegMclkTimeLow; + } + /*-----------------------------------------------------------------------*/ + if ( (f_pIntFlags->fErrorH100OutOfSync == TRUE || + f_pIntFlags->fErrorH100ClkA == TRUE || + f_pIntFlags->fErrorH100ClkB == TRUE || + f_pIntFlags->fErrorH100FrameA == TRUE ) && + pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT && + pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE ) + { + pIntrptManage->byErrorH100State = cOCT6100_INTRPT_WILL_TIMEOUT; + pIntrptManage->ulErrorH100DisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh; + pIntrptManage->ulErrorH100DisableMclkLow = pIntrptManage->ulRegMclkTimeLow; + } + /*-----------------------------------------------------------------------*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteIntrptRegs + +Description: Writes to interrupt registers to clear interrupt condition, and + writes to an interrupt's IE register if interrupt is to time + out. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteIntrptRegs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + tOCT6100_WRITE_PARAMS WriteParams; + + UINT32 ulResult; + + /* Get some local pointers. */ + pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage; + + /* Set some parameters of write struct. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + + + /*===========================================================================*/ + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ) + { + WriteParams.ulWriteAddress = 0x104; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + if ( (pIntrptManage->usRegister102h & cOCT6100_INTRPT_MASK_REG_102H) != 0 ) + { + WriteParams.ulWriteAddress = 0x102; + WriteParams.usWriteData = pIntrptManage->usRegister102h; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /*===========================================================================*/ + + /*===========================================================================*/ + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT || + pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ) + { + WriteParams.ulWriteAddress = 0x204; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x1800; + + if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0401; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + if ( (pIntrptManage->usRegister202h & cOCT6100_INTRPT_MASK_REG_202H) != 0 ) + { + WriteParams.ulWriteAddress = 0x202; + WriteParams.usWriteData = pIntrptManage->usRegister202h; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /*===========================================================================*/ + + /*===========================================================================*/ + if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_WILL_TIMEOUT ) + { + WriteParams.ulWriteAddress = 0x304; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->fMclkIntrptActive == TRUE ) + WriteParams.usWriteData |= 0x0001; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + if ( (pIntrptManage->usRegister302h & cOCT6100_INTRPT_MASK_REG_302H) != 0 ) + { + WriteParams.ulWriteAddress = 0x302; + WriteParams.usWriteData = pIntrptManage->usRegister302h; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /*===========================================================================*/ + + /*===========================================================================*/ + if ( (pIntrptManage->usRegister502h & cOCT6100_INTRPT_MASK_REG_502H) != 0 ) + { + WriteParams.ulWriteAddress = 0x502; + WriteParams.usWriteData = pIntrptManage->usRegister502h; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /*===========================================================================*/ + + /*===========================================================================*/ + if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_WILL_TIMEOUT ) + { + WriteParams.ulWriteAddress = 0x704; + WriteParams.usWriteData = 0x0000; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + if ( (pIntrptManage->usRegister702h & cOCT6100_INTRPT_MASK_REG_702H) != 0 ) + { + WriteParams.ulWriteAddress = 0x702; + WriteParams.usWriteData = pIntrptManage->usRegister702h; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /*===========================================================================*/ + + + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteIeRegs + +Description: Writes the IE field of each interrupt register. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteIeRegs( + tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + + /* Get some local pointers. */ + pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage; + + /* Set some parameters of write struct. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + + /* Set some parameters of read struct. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /*==================================================================================*/ + WriteParams.ulWriteAddress = 0x104; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0001; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*==================================================================================*/ + + /*==================================================================================*/ + WriteParams.ulWriteAddress = 0x204; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x1800; + if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0401; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*==================================================================================*/ + + /*==================================================================================*/ + WriteParams.ulWriteAddress = 0x304; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->fMclkIntrptActive == TRUE ) + WriteParams.usWriteData |= 0x0001; + if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE ) + { + if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + WriteParams.usWriteData |= 0xD100; + else + WriteParams.usWriteData |= 0x5100; + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*==================================================================================*/ + + /*==================================================================================*/ + WriteParams.ulWriteAddress = 0x504; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byFatalGeneralState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0002; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*==================================================================================*/ + + /*==================================================================================*/ + WriteParams.ulWriteAddress = 0x704; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0002; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*==================================================================================*/ + + + /*==================================================================================*/ + /* Enable the GLOBAL IEs for the interrupt pin. */ + WriteParams.ulWriteAddress = 0x218; + WriteParams.usWriteData = 0x00D7; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*==================================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReadChipMclkTime + +Description: Reads the chip's mclk cycle count to construct a chip time. + The time is used to manage interrupts. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReadChipMclkTime( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulCheckData; + UINT32 ulResult; + UINT32 i; + UINT16 usReadData; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + pIntrptManage = &pSharedInfo->IntrptManage; + + /* Assign memory for read data. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Perform reads. */ + for ( i = 0; i < 100; i++ ) + { + ReadParams.ulReadAddress = 0x306; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + pIntrptManage->ulRegMclkTimeHigh = usReadData & 0xFF; + ulCheckData = usReadData; + + ReadParams.ulReadAddress = 0x308; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + pIntrptManage->ulRegMclkTimeLow = (usReadData & 0xFFFF) << 16; + + ReadParams.ulReadAddress = 0x306; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + if ( ulCheckData == usReadData ) + break; + } + + if ( i == 100 ) + return cOCT6100_ERR_FATAL_2F; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiUpdateIntrptTimeouts + +Description: Checks which interrupt groups have finished their timeout + period. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiUpdateIntrptTimeouts( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulRegMclkTimePlus5MsHigh; + UINT32 ulRegMclkTimePlus5MsLow; + UINT32 ulResult; + BOOL fFatalMemoryChange = FALSE; + BOOL fDataErrMemoryChange = FALSE; + BOOL fErrorOverflowToneEventsChange = FALSE; + BOOL fH100ErrorChange = FALSE; + + /* Get local pointer to interrupt management structure. */ + pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage; + + /* Calculate mclk time + 5 ms. */ + ulRegMclkTimePlus5MsLow = pIntrptManage->ulRegMclkTimeLow + (5 * pIntrptManage->ulNumMclkCyclesIn1Ms); + if ( ulRegMclkTimePlus5MsLow < pIntrptManage->ulRegMclkTimeLow ) + ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh + 1; + else /* ( ulRegMclkTimePlus5MsLow >= pIntrptManage->ulRegMclkTimeLow ) */ + ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh; + + /* Check which interrupts are timed out and need to be reenabled now. */ + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_IN_TIMEOUT ) + { + mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulFatalMemoryDisableMclkHigh, pIntrptManage->ulFatalMemoryDisableMclkLow, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptManage->byFatalMemoryState, fFatalMemoryChange ) + } + if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_IN_TIMEOUT ) + { + mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorMemoryDisableMclkHigh, pIntrptManage->ulErrorMemoryDisableMclkLow, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptManage->byErrorMemoryState, fDataErrMemoryChange ) + } + if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_IN_TIMEOUT ) + { + mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptManage->byErrorOverflowToneEventsState, fErrorOverflowToneEventsChange ) + } + if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_IN_TIMEOUT ) + { + mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorH100DisableMclkHigh, pIntrptManage->ulErrorH100DisableMclkLow, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptManage->byErrorH100State, fH100ErrorChange ) + } + + /* Set some parameters of write struct. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /* Write to the IE registers which have changed. */ + + /*==================================================================================*/ + if ( fFatalMemoryChange == TRUE ) + { + WriteParams.ulWriteAddress = 0x104; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0001; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + } + /*==================================================================================*/ + + /*==================================================================================*/ + if ( fFatalMemoryChange == TRUE || + fDataErrMemoryChange == TRUE ) + { + WriteParams.ulWriteAddress = 0x204; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x1800; + if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0401; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + } + /*==================================================================================*/ + + /*==================================================================================*/ + if ( pIntrptManage->fMclkIntrptActive == TRUE || + fH100ErrorChange == TRUE ) + { + WriteParams.ulWriteAddress = 0x304; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->fMclkIntrptActive == TRUE ) + WriteParams.usWriteData |= 0x0001; + + if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE ) + { + if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + WriteParams.usWriteData |= 0xD100; + else + WriteParams.usWriteData |= 0x5100; + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + } + /*==================================================================================*/ + + + /*==================================================================================*/ + if ( fErrorOverflowToneEventsChange == TRUE ) + { + WriteParams.ulWriteAddress = 0x704; + WriteParams.usWriteData = 0x0000; + + if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE ) + WriteParams.usWriteData |= 0x0002; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + } + /*==================================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiScheduleNextMclkIntrptSer + +Description: Serialized sub-function of Oct6100ApiScheduleNextMclkIntrpt. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiScheduleNextMclkIntrptSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_INTRPT_CONFIG pIntrptConfig; + tPOCT6100_API_INTRPT_MANAGE pIntrptManage; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulTimeDiff; + UINT32 ulRegMclkTimeHigh; + UINT32 ulRegMclkTimeLow; + UINT32 ulResult; + BOOL fConditionFlag = TRUE; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Obtain temporary pointers to reduce indirection, thus speeding up processing. */ + pIntrptConfig = &pSharedInfo->IntrptConfig; + pIntrptManage = &pSharedInfo->IntrptManage; + ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh; + ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow; + + /* First, check if any interrupts have just been disabled. If there are any, */ + /* determine the time at which they should be reenabled. */ + pIntrptManage->ulNextMclkIntrptTimeHigh = cOCT6100_INVALID_VALUE; + pIntrptManage->ulNextMclkIntrptTimeLow = cOCT6100_INVALID_VALUE; + + while ( fConditionFlag ) + { + /* Indicate that no mclk interrupt is needed, yet. */ + ulTimeDiff = cOCT6100_INVALID_VALUE; + + /* Check each interrupt category to see if an mclk interrupt is needed to */ + /* reenable an interrupt at a later time. */ + if ( pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_ACTIVE && + pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_DISABLED ) + { + mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byFatalMemoryState, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptConfig->ulFatalMemoryTimeoutMclk, ulTimeDiff ) + } + if ( pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_ACTIVE && + pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED ) + { + mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorMemoryState, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptConfig->ulErrorMemoryTimeoutMclk, ulTimeDiff ) + } + if ( pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_ACTIVE && + pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED ) + { + mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorOverflowToneEventsState, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk, ulTimeDiff ) + } + if ( pIntrptManage->byErrorH100State != cOCT6100_INTRPT_ACTIVE && + pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED ) + { + mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorH100State, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptConfig->ulErrorH100TimeoutMclk, ulTimeDiff ) + } + + /* Set some parameters of write struct. */ + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + /* Schedule next mclk interrupt, if any is needed. */ + if ( ulTimeDiff != cOCT6100_INVALID_VALUE ) + { + UINT32 ulMclkTimeTest; + UINT32 ulAlarmTimeTest; + UINT32 ulTimeDiffTest; + BOOL fAlarmTimePassed; + + /* Indicate that an mclk interrupt is scheduled.*/ + pIntrptManage->fMclkIntrptActive = TRUE; + + pIntrptManage->ulNextMclkIntrptTimeLow = ulRegMclkTimeLow + ulTimeDiff; + if ( pIntrptManage->ulNextMclkIntrptTimeLow < ulRegMclkTimeLow ) + pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh + 1; + else /* ( pIntrptManage->ulNextMclkIntrptTimeLow >= ulRegMclkTimeLow ) */ + pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh; + + WriteParams.ulWriteAddress = 0x30C; + WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 24) & 0xFF ); + WriteParams.usWriteData |= (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeHigh & 0xFF) << 8 ); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x30E; + WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 8) & 0xFFFF ); + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + WriteParams.ulWriteAddress = 0x304; + WriteParams.usWriteData = 0; + + if ( pIntrptManage->fMclkIntrptActive == TRUE ) + WriteParams.usWriteData = 0x0001; + + if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE ) + { + if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + WriteParams.usWriteData |= 0xD100; + else + WriteParams.usWriteData |= 0x5100; + } + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Disable the ROL if previously set. */ + WriteParams.ulWriteAddress = 0x302; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if already passed the next interrupt time. */ + ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulMclkTimeTest = (pIntrptManage->ulRegMclkTimeLow >> 16) & 0xFFFF; + ulAlarmTimeTest = (pIntrptManage->ulNextMclkIntrptTimeLow >> 16) & 0xFFFF; + + /* Update the local Mlck timer values.*/ + ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh; + ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow; + + fAlarmTimePassed = FALSE; + + if ( ulMclkTimeTest > ulAlarmTimeTest ) + { + ulTimeDiffTest = ulMclkTimeTest - ulAlarmTimeTest; + if ( ulTimeDiffTest <= 0x8000 ) + fAlarmTimePassed = TRUE; + } + else /* ( ulMclkTimeTest <= ulAlarmTimeTest ) */ + { + ulTimeDiffTest = ulAlarmTimeTest - ulMclkTimeTest; + if ( ulTimeDiffTest > 0x8000 ) + fAlarmTimePassed = TRUE; + } + + if ( fAlarmTimePassed == TRUE ) + { + /* Passed the interrupt time. Schedule next interrupt (if needed). */ + ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + continue; + } + else + { + fConditionFlag = FALSE; + } + } + else + { + /* Indicate that no mclk interrupt is scheduled. */ + pIntrptManage->fMclkIntrptActive = FALSE; + + /* Insure that the mclk interrupt is not enabled. */ + WriteParams.ulWriteAddress = 0x304; + WriteParams.usWriteData = 0x0000; + if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE ) + { + if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE ) + WriteParams.usWriteData |= 0xD100; + else + WriteParams.usWriteData |= 0x5100; + } + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + fConditionFlag = FALSE; + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckProcessorState + +Description: This function verifies if the NLP and AF processors are operating + correctly. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_pIntFlags Pointer to a tOCT6100_INTERRUPT_FLAGS structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckProcessorState( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_READ_BURST_PARAMS ReadBurstParams; + UINT32 ulNlpTimestamp; + UINT32 ulAfTimestamp; + UINT32 ulTimestampDiff; + + UINT32 ulResult; + UINT32 i; + + UINT16 usReadData; + UINT16 ausReadData[ 2 ]; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Set some parameters of write struct. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Set some parameters of write struct. */ + ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadBurstParams.pusReadData = ausReadData; + + /*-----------------------------------------------------------------------*/ + /* Check if chip is in reset. */ + + /* Read the main control register. */ + ReadParams.ulReadAddress = 0x100; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData == 0x0000 ) + { + /* Chip was resetted. */ + f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_4; + f_pIntFlags->fFatalGeneral = TRUE; + pSharedInfo->ErrorStats.fFatalChipError = TRUE; + } + + /*-----------------------------------------------------------------------*/ + + + /*-----------------------------------------------------------------------*/ + /* Reading the AF timestamp.*/ + + for ( i = 0; i < cOCT6100_MAX_LOOP; i++ ) + { + /* Read the timestamp.*/ + ReadBurstParams.ulReadAddress = 0x082E0008; + ReadBurstParams.ulReadLength = 2; + + mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Read the high part again to make sure it didn't wrap. */ + ReadParams.ulReadAddress = 0x082E0008; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if the low part wrapped. */ + if ( ausReadData[ 0 ] == usReadData ) + break; + } + + if ( i == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT; + + /* Save the AF timestamp. */ + ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ]; + + /*-----------------------------------------------------------------------*/ + + + /*-----------------------------------------------------------------------*/ + /* Reading the NLP timestamp. */ + + for ( i = 0; i < cOCT6100_MAX_LOOP; i++ ) + { + /* Read the timestamp. */ + ReadBurstParams.ulReadAddress = 0x08000008; + ReadBurstParams.ulReadLength = 2; + + mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Read the high part again to make sure it didn't wrap. */ + ReadParams.ulReadAddress = 0x08000008; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if the low part wrapped. */ + if ( ausReadData[ 0 ] == usReadData ) + break; + } + + if ( i == cOCT6100_MAX_LOOP ) + return cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT; + + /* Save the NLP timestamp. */ + ulNlpTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ]; + + /*-----------------------------------------------------------------------*/ + + + /*-----------------------------------------------------------------------*/ + /* Check the validity of the timestamp. */ + + if ( ulAfTimestamp > ulNlpTimestamp ) + { + /* The NLP timestamp wrapped. */ + ulTimestampDiff = 0xFFFFFFFF - ulAfTimestamp + 1; + ulTimestampDiff += ulNlpTimestamp; + } + else + ulTimestampDiff = ulNlpTimestamp - ulAfTimestamp; + + if ( ulTimestampDiff > 0x1000 ) + { + f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_5; + f_pIntFlags->fFatalGeneral = TRUE; + pSharedInfo->ErrorStats.fFatalChipError = TRUE; + } + + /*-----------------------------------------------------------------------*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_memory.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the functions used to manage the allocation of memory + blocks in external memory. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 42 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_apiud.h" +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_playout_buf_inst.h" +#include "oct6100api/oct6100_api_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_memory_priv.h" + + +/**************************** PRIVATE FUNCTIONS ****************************/ + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetMemorySwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of the memories. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetMemorySwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + UINT32 ulNumTsiChariots; + + /*=========================================================================*/ + /* Internal memory */ + + /* Evaluate the number of available TSI memory after reserving the ones used by channels. */ + ulNumTsiChariots = cOCT6100_TOTAL_TSI_CONTROL_MEM_ENTRY - f_pOpenChip->ulMaxPhasingTssts - cOCT6100_TSI_MEM_FOR_TIMESTAMP; + + if ( f_pOpenChip->fEnableExtToneDetection == TRUE ) + ulNumTsiChariots--; + + /* Calculate memory needed for TSI memory allocation. */ + ulResult = OctapiLlmAllocGetSize( ulNumTsiChariots, &f_pInstSizes->ulTsiMemoryAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_94; + + /* Calculate memory needed for conversion memory allocation. */ + ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_CONVERSION_MEMORY_BLOCKS, &f_pInstSizes->ulConversionMemoryAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_B5; + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiMemoryAlloc, ulTempVar ); + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulConversionMemoryAlloc, ulTempVar ); + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiMemorySwInit + +Description: Initializes all elements of the instance structure associated + to memories. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiMemorySwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pTsiMemAlloc; + PVOID pAllocPnt; + UINT32 ulResult; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /*=========================================================================*/ + /* Internal memory */ + + /* Initialize the TSI memory allocation structure. */ + pSharedInfo->MemoryMap.ulNumTsiEntries = cOCT6100_TOTAL_TSI_CONTROL_MEM_ENTRY - pSharedInfo->ChipConfig.usMaxPhasingTssts - cOCT6100_TSI_MEM_FOR_TIMESTAMP; + + if ( pSharedInfo->ChipConfig.fEnableExtToneDetection == TRUE ) + pSharedInfo->MemoryMap.ulNumTsiEntries--; + + mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc ); + + ulResult = OctapiLlmAllocInit( &pTsiMemAlloc, pSharedInfo->MemoryMap.ulNumTsiEntries ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_95; + + /* Initialize the conversion memory allocation structure. */ + mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pAllocPnt ); + + ulResult = OctapiLlmAllocInit( &pAllocPnt, cOCT6100_MAX_CONVERSION_MEMORY_BLOCKS ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_B6; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiBufferPlayoutMemorySwInit + +Description: Initialize the buffer playout memory allocation working + structures. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiBufferPlayoutMemorySwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pNode; + UINT32 i; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Only if buffer playout will be used. */ + if ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers > 0 ) + { + mOCT6100_GET_BUFFER_MEMORY_NODE_LIST_PNT( pSharedInfo, pNode ); + + /* First node contains all free memory at beginning. This node is not used, but represents the memory. */ + pNode->ulSize = ( pSharedInfo->MiscVars.ulTotalMemSize + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) - pSharedInfo->MemoryMap.ulFreeMemBaseAddress; + pNode->ulNext = 0; + pNode->ulPrevious = 0; + pNode->fAllocated = FALSE; + pNode->ulStartAddress = pSharedInfo->MemoryMap.ulFreeMemBaseAddress; + + pNode++; + + /* Now create the first node of the free list, i.e. nodes that can be used later for modeling the memory. */ + pNode->ulSize = 0; + /* Next free. */ + pNode->ulNext = 2; + /* Last. */ + pNode->ulPrevious = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1; + pNode->fAllocated = FALSE; + pNode->ulStartAddress = 0; + + pNode++; + + /* Link all the unused nodes. */ + for( i = 2; i < (UINT32)( ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1 ); i ++ ) + { + pNode->ulNext = i + 1; + pNode->ulPrevious = i - 1; + pNode->ulStartAddress = 0; + pNode->ulSize = 0; + pNode->fAllocated = FALSE; + pNode++; + } + + /* Last node of the unused list. */ + pNode->fAllocated = FALSE; + pNode->ulPrevious = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 2; + /* Free list head. */ + pNode->ulNext = 1; + pNode->ulSize = 0; + pNode->ulStartAddress = 0; + + /* Set roving pointer to first node ( which can be used! ) */ + pSharedInfo->PlayoutInfo.ulRovingNode = 0; + + /* First unused node. */ + pSharedInfo->PlayoutInfo.ulFirstUnusedNode = 1; + + /* Last unused node. */ + pSharedInfo->PlayoutInfo.ulLastUnusedNode = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1; + + /* Number of unused nodes. */ + pSharedInfo->PlayoutInfo.ulUnusedNodeCnt = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1; + } + else + { + pSharedInfo->PlayoutInfo.ulUnusedNodeCnt = 0; + } + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_phasing_tsst.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to open and close phasing TSSTs. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 42 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_phasing_tsst_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_phasing_tsst_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_tsst_priv.h" +#include "oct6100_phasing_tsst_priv.h" + + +/**************************** PUBLIC FUNCTIONS ****************************/ + + +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetPhasingTsstSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of Phasing TSSTs. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetPhasingTsstSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Determine the amount of memory required for the API phasing TSST list. */ + f_pInstSizes->ulPhasingTsstList = f_pOpenChip->ulMaxPhasingTssts * sizeof( tOCT6100_API_PHASING_TSST ); + + if ( f_pOpenChip->ulMaxPhasingTssts > 0 ) + { + /* Calculate memory needed for Phasing TSST API memory allocation */ + ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxPhasingTssts, &f_pInstSizes->ulPhasingTsstAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_38; + } + else + { + f_pInstSizes->ulPhasingTsstAlloc = 0; + } + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPhasingTsstList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPhasingTsstAlloc, ulTempVar ) + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiPhasingTsstSwInit + +Description: Initializes all elements of the instance structure associated + to phasing TSST. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiPhasingTsstSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_PHASING_TSST pPhasingTsstList; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulMaxPhasingTssts; + PVOID pPhasingTsstAlloc; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Initialize the phasing TSST API list. */ + ulMaxPhasingTssts = pSharedInfo->ChipConfig.usMaxPhasingTssts; + + /* Set all entries in the phasing TSST list to unused. */ + mOCT6100_GET_PHASING_TSST_LIST_PNT( pSharedInfo, pPhasingTsstList ) + + /* Clear the memory */ + Oct6100UserMemSet( pPhasingTsstList, 0x00, sizeof(tOCT6100_API_PHASING_TSST) * ulMaxPhasingTssts ); + + /* Initialize the phasing TSST allocation software to "all free". */ + if ( ulMaxPhasingTssts > 0 ) + { + mOCT6100_GET_PHASING_TSST_ALLOC_PNT( pSharedInfo, pPhasingTsstAlloc ) + + ulResult = OctapiLlmAllocInit( &pPhasingTsstAlloc, ulMaxPhasingTssts ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_39; + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_playout_buf.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to manage buffer playout. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 109 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_playout_buf_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_events_pub.h" +#include "oct6100api/oct6100_playout_buf_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_events_priv.h" +#include "oct6100_playout_buf_priv.h" + +/**************************** PUBLIC FUNCTIONS *****************************/ + +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetPlayoutBufferSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of playout buffers. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetPlayoutBufferSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Calculate memory needed for playout buffer list. */ + f_pInstSizes->ulPlayoutBufList = f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER ); + + f_pInstSizes->ulPlayoutBufMemoryNodeList = 0; + + /* Calculate memory needed for playout buffer allocation software. */ + if ( f_pOpenChip->ulMaxPlayoutBuffers > 0 ) + { + ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxPlayoutBuffers, &f_pInstSizes->ulPlayoutBufAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_3C; + + f_pInstSizes->ulPlayoutBufMemoryNodeList = 2 * f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE ); + } + else + { + f_pInstSizes->ulPlayoutBufAlloc = 0; + } + + /* Calculate memory needed for list and allocation software serialization. */ + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufAlloc, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufMemoryNodeList, ulTempVar ) + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiPlayoutBufferSwInit + +Description: Initializes all elements of the instance structure associated + to playout buffers. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiPlayoutBufferSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_BUFFER pBufferList; + PVOID pBufferPlayoutAlloc; + UINT32 ulMaxBufferPlayout; + UINT32 ulResult, i; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Get the maximum number of buffer playout. */ + ulMaxBufferPlayout = pSharedInfo->ChipConfig.usMaxPlayoutBuffers; + + /* Set all entries in the buffer playout list to unused. */ + mOCT6100_GET_BUFFER_LIST_PNT( pSharedInfo, pBufferList ) + + for ( i = 0; i < ulMaxBufferPlayout; i++ ) + { + pBufferList[ i ].fReserved = FALSE; + pBufferList[ i ].ulBufferSize = 0; + pBufferList[ i ].ulBufferBase = cOCT6100_INVALID_VALUE; + pBufferList[ i ].usDependencyCnt = 0; + pBufferList[ i ].byBufferPcmLaw = cOCT6100_PCM_U_LAW; + + } + + /* Initialize the buffer playout allocation software to "all free". */ + if ( ulMaxBufferPlayout > 0 ) + { + mOCT6100_GET_BUFFER_ALLOC_PNT( pSharedInfo, pBufferPlayoutAlloc ) + + ulResult = OctapiLlmAllocInit( &pBufferPlayoutAlloc, ulMaxBufferPlayout ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_3D; + } + + /* Initialize the amount of free memory used by playout. */ + f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed = 0; + + return cOCT6100_ERR_OK; +} + + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100BufferPlayoutStopSer + +Description: Stops buffer playout on a channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pBufferPlayoutStop Pointer to buffer playout stop structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100BufferPlayoutStopSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop ) +{ + UINT32 ulChannelIndex; + UINT16 usEchoMemIndex; + UINT32 ulResult; + + /* Check the user's configuration of the buffer for errors. */ + ulResult = Oct6100ApiAssertPlayoutStopParams( + f_pApiInstance, + f_pBufferPlayoutStop, + &ulChannelIndex, + &usEchoMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write to all resources needed to deactivate buffer playout. */ + ulResult = Oct6100ApiInvalidateChanPlayoutStructs( + f_pApiInstance, + f_pBufferPlayoutStop, + ulChannelIndex, + usEchoMemIndex + + ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAssertPlayoutStopParams + +Description: Check the validity of the channel and buffer requested. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pBufferPlayoutStop Pointer to buffer playout stop structure. +f_pulChannelIndex Pointer to the channel index on which playout is to be stopped. +f_pusEchoMemIndex Pointer to the echo mem index on which playout is to be stopped. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAssertPlayoutStopParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT16 f_pusEchoMemIndex ) +{ + tPOCT6100_API_CHANNEL pEchoChannel; + UINT32 ulEntryOpenCnt; + + /* Check for errors. */ + if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 ) + return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED; + + if ( f_pBufferPlayoutStop->ulChannelHndl == cOCT6100_INVALID_HANDLE ) + return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID; + + if ( f_pBufferPlayoutStop->ulPlayoutPort != cOCT6100_CHANNEL_PORT_ROUT && + f_pBufferPlayoutStop->ulPlayoutPort != cOCT6100_CHANNEL_PORT_SOUT ) + return cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT; + + if ( f_pBufferPlayoutStop->fStopCleanly != TRUE && f_pBufferPlayoutStop->fStopCleanly != FALSE ) + return cOCT6100_ERR_BUFFER_PLAYOUT_STOP_CLEANLY; + + /*=====================================================================*/ + /* Check the channel handle. */ + + if ( (f_pBufferPlayoutStop->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID; + + *f_pulChannelIndex = f_pBufferPlayoutStop->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK; + if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = (f_pBufferPlayoutStop->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pEchoChannel->fReserved != TRUE ) + return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_NOT_OPEN; + if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt ) + return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID; + + /* Return echo memory index. */ + *f_pusEchoMemIndex = pEchoChannel->usEchoMemIndex; + + /* Check if buffer playout is active for the selected port. */ + if ( ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) + && ( pEchoChannel->fRinBufPlaying == FALSE ) + && ( pEchoChannel->fRinBufAdded == FALSE ) ) + return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_STARTED; + + if ( ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) + && ( pEchoChannel->fSoutBufPlaying == FALSE ) + && ( pEchoChannel->fSoutBufAdded == FALSE ) ) + return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_STARTED; + + /*=====================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInvalidateChanPlayoutStructs + +Description: Write the buffer playout event in the channel main structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pBufferPlayoutStop Pointer to buffer playout stop structure. +f_ulChannelIndex Index of the channel within the API's channel list. +f_usEchoMemIndex Index of the echo channel in hardware memory. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInvalidateChanPlayoutStructs( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop, + IN UINT32 f_ulChannelIndex, + IN UINT16 f_usEchoMemIndex + + ) +{ + tPOCT6100_API_CHANNEL pEchoChannel; + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_WRITE_PARAMS WriteParams; + + UINT32 ulResult; + + UINT32 ulWritePtrBytesOfst; + UINT32 ulWritePtrBitOfst; + UINT32 ulWritePtrFieldSize; + UINT32 ulSkipPtrBytesOfst; + UINT32 ulSkipPtrBitOfst; + UINT32 ulSkipPtrFieldSize; + UINT32 ulIgnoreBytesOfst; + UINT32 ulIgnoreBitOfst; + UINT32 ulIgnoreFieldSize; + UINT32 ulHardSkipBytesOfst; + UINT32 ulHardSkipBitOfst; + UINT32 ulHardSkipFieldSize; + UINT32 ulReadPtrBytesOfst; + UINT32 ulReadPtrBitOfst; + UINT32 ulReadPtrFieldSize; + + UINT32 ulSkipPtr; + UINT32 ulWritePtr; + UINT32 ulReadPtr = 0; + UINT32 ulCurrentPtr; + + UINT32 ulPlayoutBaseAddress; + UINT32 ulAddress; + UINT32 ulTempData; + UINT32 ulMask; + UINT32 ulReadData; + + UINT16 usReadData; + BOOL fCheckStop = FALSE; + + UINT32 ulEventBuffer; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex ); + + /* Select the port of interest. */ + if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + ulWritePtr = pEchoChannel->ulRinBufWritePtr; + ulSkipPtr = ulWritePtr; + + ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4; + ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset; + ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize; + + ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.usDwordOffset * 4; + ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byBitOffset; + ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byFieldSize; + + ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.usDwordOffset * 4; + ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byBitOffset; + ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byFieldSize; + + ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.usDwordOffset * 4; + ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byBitOffset; + ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byFieldSize; + + ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4; + ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset; + ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize; + } + else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + ulWritePtr = pEchoChannel->ulSoutBufWritePtr; + ulSkipPtr = ulWritePtr; + + ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4; + ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset; + ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize; + + ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.usDwordOffset * 4; + ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byBitOffset; + ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byFieldSize; + + ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.usDwordOffset * 4; + ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byBitOffset; + ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byFieldSize; + + ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.usDwordOffset * 4; + ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byBitOffset; + ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byFieldSize; + + ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4; + ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset; + ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize; + } + + /* Set the playout feature base address. */ + ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; + + /* Check if something is currently playing. */ + if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + if ( pEchoChannel->fRinBufPlaying == TRUE ) + { + /* Check if we are stopping it or if it stopped by itself. */ + fCheckStop = TRUE; + } + else + { + /* Not playing! */ + if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL ) + *f_pBufferPlayoutStop->pfAlreadyStopped = TRUE; + } + } + else /* if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */ + { + if ( pEchoChannel->fSoutBufPlaying == TRUE ) + { + /* Check if we are stopping it or if it stopped by itself. */ + fCheckStop = TRUE; + } + else + { + /* Not playing! */ + if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL ) + *f_pBufferPlayoutStop->pfAlreadyStopped = TRUE; + } + } + + if ( ( fCheckStop == TRUE ) || ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) ) + { + /* Read the read pointer. */ + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst; + + /* Optimize this access by only reading the word we are interested in. */ + if ( ulReadPtrBitOfst < 16 ) + ReadParams.ulReadAddress += 2; + + /* Must read in memory directly since this value is changed by hardware */ + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Move data at correct position according to what was read. */ + if ( ulReadPtrBitOfst < 16 ) + ulTempData = usReadData; + else + ulTempData = usReadData << 16; + + mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask ); + + /* Store the read pointer. */ + ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst; + + /* Playout has finished when the read pointer reaches the write pointer. */ + if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL ) + { + if ( ulReadPtr != ulWritePtr ) + *f_pBufferPlayoutStop->pfAlreadyStopped = FALSE; + else /* if ( ulReadPtr == ulWritePtr ) */ + *f_pBufferPlayoutStop->pfAlreadyStopped = TRUE; + } + } + + /* If the skip bits are located in the event itself, the playout is stopped by setting the */ + /* skip pointer to the hardware chip write pointer. Read it directly from the NLP configuration. */ + if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) + { + if ( ulReadPtr != ulWritePtr ) + { + /* Get the write pointer in the chip. */ + ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulReadData, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask ); + + /* Store the write pointer. */ + ulWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst; + ulSkipPtr = ulWritePtr; + } + } + + /* Check if must clear repeat bit. */ + if ( ( ( pEchoChannel->fRinBufPlayoutRepeatUsed == TRUE ) && ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) ) + || ( ( pEchoChannel->fSoutBufPlayoutRepeatUsed == TRUE ) && ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) ) ) + { + if ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) + || ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) + && ( ulWritePtr != ulReadPtr ) ) ) + { + if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst; + } + else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst; + } + + /* Set the playout event base address. */ + if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE ) + && ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) ) + { + /* 127 or 31 events image. */ + ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ( ( ulWritePtr - 1 ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 ))); + } + else + { + /* Old 31 events image. */ + ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ( ( ulWritePtr - 1 ) & 0x1F)); + } + + /* EVENT BASE + 4 */ + /* Playout configuration. */ + ulAddress += 4; + + ReadParams.ulReadAddress = ulAddress; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Read-clear-write the new repeat bit. */ + usReadData &= 0x7FFF; + + WriteParams.ulWriteAddress = ulAddress; + WriteParams.usWriteData = usReadData; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /* Write the skip to the value of the write pointer to stop buffer playout. */ + + /*=======================================================================*/ + /* First set the ignore skip clean bit if required. */ + + if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == FALSE ) + || ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == FALSE ) ) + { + ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask ); + + ulTempData &= ( ~ulMask ); + + /* Check if the skip need to be clean or not. */ + if ( f_pBufferPlayoutStop->fStopCleanly == FALSE ) + ulTempData |= 0x1 << ulIgnoreBitOfst; + + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Fetch and modify the write pointer. */ + + ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulTempData, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask ); + + ulTempData &= ( ~ulMask ); + ulTempData |= ulWritePtr << ulWritePtrBitOfst; + + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* Fetch and modify the skip pointer. */ + + ulAddress = ulPlayoutBaseAddress + ulSkipPtrBytesOfst; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_CREATE_FEATURE_MASK( ulSkipPtrFieldSize, ulSkipPtrBitOfst, &ulMask ); + + ulTempData &= ( ~ulMask ); + ulTempData |= ulSkipPtr << ulSkipPtrBitOfst; + + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* If in the new buffer playout case, things are in a different order. */ + + if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) + { + if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE ) + && ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) ) + { + ulAddress = ulPlayoutBaseAddress + ulHardSkipBytesOfst; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_CREATE_FEATURE_MASK( ulHardSkipFieldSize, ulHardSkipBitOfst, &ulMask ); + + ulTempData &= ( ~ulMask ); + + /* Check if the skip need to be clean or not. */ + if ( f_pBufferPlayoutStop->fStopCleanly == FALSE ) + ulTempData |= 0x1 << ulHardSkipBitOfst; + + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Now is the appropriate time to skip! */ + ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask ); + + ulTempData &= ( ~ulMask ); + + /* Set the skip bit. */ + ulTempData |= 0x1 << ulIgnoreBitOfst; + + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pEchoChannel, + ulAddress, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + /*=======================================================================*/ + + + /*=======================================================================*/ + /* The API must set the skip bit in all the events that are queued. */ + + if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) + { + if ( fCheckStop == TRUE ) + { + if ( ulReadPtr != ulWritePtr ) + { + if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst; + } + else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst; + } + + for ( ulCurrentPtr = ulReadPtr; ulCurrentPtr != ulWritePtr; ) + { + /* Set the playout event base address. */ + + /* 127 or 31 events image. */ + ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + ( cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ulCurrentPtr ); + ulCurrentPtr++; + ulCurrentPtr &= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 ); + + /* EVENT BASE + 0 playout configuration. */ + WriteParams.ulWriteAddress = ulAddress; + + /* Set skip bit + hard-skip bit. */ + WriteParams.usWriteData = 0x8000; + if ( f_pBufferPlayoutStop->fStopCleanly == FALSE ) + WriteParams.usWriteData |= 0x4000; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + } + } + + /*=======================================================================*/ + /* If stop immediatly, wait the stop before leaving the function. */ + + if ( f_pBufferPlayoutStop->fStopCleanly == FALSE ) + { + /* Remember that an "hard stop" was used for the next start. */ + if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) + pEchoChannel->fRinHardStop = TRUE; + else /* if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */ + pEchoChannel->fSoutHardStop = TRUE; + } + + /*=======================================================================*/ + /* Update the channel entry to set the playing flag to FALSE. */ + + /* Select the port of interest. */ + if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) + { + /* Check if the global ports active stat must be decremented. */ + if ( pEchoChannel->fRinBufPlaying == TRUE ) + { + /* Decrement the number of active buffer playout ports. */ + pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--; + } + + pEchoChannel->fRinBufPlaying = FALSE; + + /* Return user information. */ + if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL ) + *f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fRinBufPlayoutNotifyOnStop; + + /* Make sure no new event is recorded for this channel/port. */ + pEchoChannel->fRinBufPlayoutNotifyOnStop = FALSE; + if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) + { + pEchoChannel->ulRinBufSkipPtr = ulSkipPtr; + pEchoChannel->ulRinBufWritePtr = ulWritePtr; + } + else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */ + pEchoChannel->ulRinBufSkipPtr = pEchoChannel->ulRinBufWritePtr; + + /* The repeat flag can now be used. */ + pEchoChannel->fRinBufPlayoutRepeatUsed = FALSE; + + /* For sure, all buffers have now been cleared on the Rin port. */ + pEchoChannel->fRinBufAdded = FALSE; + + /* Clear optimization flag if possible. */ + if ( ( pEchoChannel->fSoutBufPlaying == FALSE ) + && ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == FALSE ) ) + { + /* Buffer playout is no more active on this channel. */ + pEchoChannel->fBufPlayoutActive = FALSE; + } + } + else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */ + { + /* Check if the global ports active stat must be decremented. */ + if ( pEchoChannel->fSoutBufPlaying == TRUE ) + { + /* Decrement the number of active buffer playout ports. */ + pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--; + } + + pEchoChannel->fSoutBufPlaying = FALSE; + + /* Return user information. */ + if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL ) + *f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fSoutBufPlayoutNotifyOnStop; + + /* Make sure no new event is recorded for this channel/port. */ + pEchoChannel->fSoutBufPlayoutNotifyOnStop = FALSE; + if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) + { + pEchoChannel->ulSoutBufSkipPtr = ulSkipPtr; + pEchoChannel->ulSoutBufWritePtr = ulWritePtr; + } + else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */ + pEchoChannel->ulSoutBufSkipPtr = pEchoChannel->ulSoutBufWritePtr; + + /* The repeat flag can now be used. */ + pEchoChannel->fSoutBufPlayoutRepeatUsed = FALSE; + + /* For sure, all buffers have now been cleared on the Sout port. */ + pEchoChannel->fSoutBufAdded = FALSE; + + /* Clear optimization flag if possible. */ + if ( ( pEchoChannel->fRinBufPlaying == FALSE ) + && ( pEchoChannel->fRinBufPlayoutNotifyOnStop == FALSE ) ) + { + /* Buffer playout is no more active on this channel. */ + pEchoChannel->fBufPlayoutActive = FALSE; + } + } + + /*=======================================================================*/ + + + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_remote_debug.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the routines used for remote debugging. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 35 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" + +#include "apilib/octapi_bt0.h" +#include "apilib/octapi_largmath.h" + +#include "oct6100api/oct6100_apiud.h" +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_debug_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_remote_debug_pub.h" + +#include "octrpc/rpc_protocol.h" +#include "octrpc/oct6100_rpc_protocol.h" + +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_chip_open_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_debug_priv.h" +#include "oct6100_remote_debug_priv.h" + + +/**************************** PRIVATE FUNCTIONS ****************************/ + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetRemoteDebugSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of remote debugging. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pChipOpen Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetRemoteDebugSwSizes( + IN tPOCT6100_CHIP_OPEN f_pChipOpen, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Memory needed for remote debugging sessions. */ + if ( f_pChipOpen->ulMaxRemoteDebugSessions > 0 ) + { + f_pInstSizes->ulRemoteDebugList = f_pChipOpen->ulMaxRemoteDebugSessions * sizeof( tOCT6100_API_REMOTE_DEBUG_SESSION ); + + ulResult = octapi_bt0_get_size( f_pChipOpen->ulMaxRemoteDebugSessions, 4, 4, &f_pInstSizes->ulRemoteDebugTree ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_41; + + f_pInstSizes->ulRemoteDebugPktCache = cOCTRPC_MAX_PACKET_BYTE_LENGTH * f_pChipOpen->ulMaxRemoteDebugSessions; + f_pInstSizes->ulRemoteDebugDataBuf = cOCTRPC_MAX_PACKET_BYTE_LENGTH * 4; + } + else + { + f_pInstSizes->ulRemoteDebugList = 0; + f_pInstSizes->ulRemoteDebugTree = 0; + f_pInstSizes->ulRemoteDebugPktCache = 0; + f_pInstSizes->ulRemoteDebugDataBuf = 0; + } + + /* Round off the size. */ + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugTree, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugPktCache, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugDataBuf, ulTempVar ) + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiRemoteDebuggingSwInit + +Description: Initializes all portions of the API instance associated to + remote debugging. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiRemoteDebuggingSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pSessionTree; + UINT32 ulResult; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + pSharedInfo->RemoteDebugInfo.ulNumSessionsOpen = 0; + pSharedInfo->RemoteDebugInfo.ulMaxSessionsOpen = pSharedInfo->ChipConfig.usMaxRemoteDebugSessions; + pSharedInfo->RemoteDebugInfo.ulSessionListHead = cOCT6100_INVALID_VALUE; + pSharedInfo->RemoteDebugInfo.ulSessionListTail = cOCT6100_INVALID_VALUE; + + if ( pSharedInfo->ChipConfig.usMaxRemoteDebugSessions > 0 ) + { + mOCT6100_GET_REMOTE_DEBUG_TREE_PNT( pSharedInfo, pSessionTree ) + + ulResult = octapi_bt0_init( ( ( PVOID* )&pSessionTree ), pSharedInfo->ChipConfig.usMaxRemoteDebugSessions, 4, 4 ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_42; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tlv.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the functions used to read information allowing the + API to know where all the features supported by this API version are + located in the chip's external memory. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 109 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" + +#include "oct6100api/oct6100_apiud.h" +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" + +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_tlv_priv.h" + +/**************************** PRIVATE FUNCTIONS ****************************/ + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiProcessTlvRegion + +Description: This function will read and interpret the TLV memory of the chip + to obtain memory offsets and features available of the image + loaded into the chip. + + The API will read this region until it finds a TLV type of 0 with + a length of 0. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiProcessTlvRegion( + tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tOCT6100_READ_PARAMS ReadParams; + UINT16 usReadData; + UINT32 ulResult; + + UINT32 ulTlvTypeField; + UINT32 ulTlvLengthField; + UINT32 ulTlvWritingTimeoutCount = 0; + UINT32 ulConditionFlag = TRUE; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Set the address of the first TLV type. */ + ReadParams.ulReadAddress = cOCT6100_TLV_BASE; + ReadParams.ulReadAddress += 2; + + /* Wait for the TLV configuration to be configured in memory. */ + while ( ulConditionFlag ) + { + /* Read the TLV write done flag. */ + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( usReadData & 0x1 ) + break; + + ulTlvWritingTimeoutCount++; + if ( ulTlvWritingTimeoutCount == 0x100000 ) + return cOCT6100_ERR_TLV_TIMEOUT; + } + + /*======================================================================*/ + /* Read the first 16 bits of the TLV type. */ + + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvTypeField = usReadData << 16; + + /* Read the last word of the TLV type. */ + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvTypeField |= usReadData; + + /*======================================================================*/ + + + /*======================================================================*/ + /* Now, read the TLV field length. */ + + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvLengthField = usReadData << 16; + + /* Read the last word of the TLV length. */ + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvLengthField |= usReadData; + + /* Modify the address to point at the TLV value field. */ + ReadParams.ulReadAddress += 2; + + /*======================================================================*/ + + /* Read the TLV value until the end of TLV region is reached. */ + while( !((ulTlvTypeField == 0) && (ulTlvLengthField == 0)) ) + { + ulResult = Oct6100ApiInterpretTlvEntry( f_pApiInstance, + ulTlvTypeField, + ulTlvLengthField, + ReadParams.ulReadAddress ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Set the address to after the TLV value. */ + ReadParams.ulReadAddress += ulTlvLengthField; + + /*======================================================================*/ + /* Read the first 16 bits of the TLV type. */ + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvTypeField = usReadData << 16; + + /* Read the last word of the TLV type. */ + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvTypeField |= usReadData; + + /*======================================================================*/ + + + /*======================================================================*/ + /* Now, read the TLV field length. */ + + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvLengthField = usReadData << 16; + + /* Read the last word of the TLV length. */ + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulTlvLengthField |= usReadData; + + ReadParams.ulReadAddress += 2; + + /*======================================================================*/ + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiInterpretTlvEntry + +Description: This function will interpret a TLV entry from the chip. All + known TLV types by the API are exhaustively listed here. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_ulTlvFieldType Type of the TLV field to interpret. +f_ulTlvFieldLength Byte length of the TLV field. +f_ulTlvValueAddress Address where the data of the TLV block starts. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiInterpretTlvEntry( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulTlvFieldType, + IN UINT32 f_ulTlvFieldLength, + IN UINT32 f_ulTlvValueAddress ) +{ + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult = cOCT6100_ERR_OK; + UINT16 usReadData; + UINT32 i; + UINT32 ulTempValue = 0; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /* Find out how to interpret the TLV value according to the TLV type. */ + switch( f_ulTlvFieldType ) + { + case cOCT6100_TLV_TYPE_VERSION_NUMBER: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_VERSION_NUMBER, + cOCT6100_TLV_MAX_LENGTH_VERSION_NUMBER ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ReadParams.ulReadAddress = f_ulTlvValueAddress; + + for( i = 0; i < (f_ulTlvFieldLength/2); i++ ) + { + /* Perform the actual read. */ + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + f_pApiInstance->pSharedInfo->ImageInfo.szVersionNumber[ (i * 2) ] = (UINT8)((usReadData >> 8) & 0xFF); + f_pApiInstance->pSharedInfo->ImageInfo.szVersionNumber[ (i * 2) + 1 ] = (UINT8)((usReadData >> 0) & 0xFF); + + /* Modify the address. */ + ReadParams.ulReadAddress += 2; + } + } + break; + + case cOCT6100_TLV_TYPE_CUSTOMER_PROJECT_ID: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CUSTOMER_PROJECT_ID, + cOCT6100_TLV_MAX_LENGTH_CUSTOMER_PROJECT_ID ); + if ( ulResult == cOCT6100_ERR_OK ) + { + /* Perform the actual read. */ + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->ImageInfo.ulBuildId ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH0_MAIN_BASE_ADDRESS: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH0_MAIN_BASE_ADDRESS, + cOCT6100_TLV_MAX_LENGTH_CH0_MAIN_BASE_ADDRESS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase &= 0x0FFFFFFF; + + /* Modify the base address to incorporate the external memory offset. */ + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase += cOCT6100_EXTERNAL_MEM_BASE_ADDRESS; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_SIZE, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_IO_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_IO_OFFSET, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_IO_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_ZCB_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_ZCB_OFFSET, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_ZCB_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_ZCB_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_ZCB_SIZE, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_ZCB_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinCBMemSize ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_XCB_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_XCB_OFFSET, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_XCB_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_XCB_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_XCB_SIZE, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_XCB_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSinCBMemSize ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_YCB_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_YCB_OFFSET, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_YCB_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_MAIN_YCB_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_MAIN_YCB_SIZE, + cOCT6100_TLV_MAX_LENGTH_CH_MAIN_YCB_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutCBMemSize ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_FREE_MEM_BASE_ADDRESS: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_FREE_MEM_BASE_ADDRESS, + cOCT6100_TLV_MAX_LENGTH_FREE_MEM_BASE_ADDRESS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress &= 0x0FFFFFFF; + + } + break; + + case cOCT6100_TLV_TYPE_CHAN_MAIN_IO_STATS_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CHAN_MAIN_IO_STATS_OFFSET, + cOCT6100_TLV_MAX_LENGTH_CHAN_MAIN_IO_STATS_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsOfst ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CHAN_MAIN_IO_STATS_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CHAN_MAIN_IO_STATS_OFFSET, + cOCT6100_TLV_MAX_LENGTH_CHAN_MAIN_IO_STATS_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsSize ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_CH_ROOT_CONF_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CH_ROOT_CONF_OFFSET, + cOCT6100_TLV_MAX_LENGTH_CH_ROOT_CONF_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + + case cOCT6100_TLV_TYPE_POA_CH_MAIN_ZPO_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_ZPO_OFFSET, + cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_ZPO_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_POA_CH_MAIN_ZPO_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_ZPO_SIZE, + cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_ZPO_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemSize ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + break; + + case cOCT6100_TLV_TYPE_POA_CH_MAIN_YPO_OFFSET: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_YPO_OFFSET, + cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_YPO_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_CH_MAIN_YPO_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_YPO_SIZE, + cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_YPO_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemSize ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RW_ZWP: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZWP, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZWP ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RW_ZIS: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZIS, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZIS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RW_ZSP: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZSP, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZSP ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RW_YWP: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YWP, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YWP ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RW_YIS: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YIS, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YIS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RW_YSP: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YSP, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YSP ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RO_ZRP: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RO_ZRP, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RO_ZRP ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst ); + } + break; + + case cOCT6100_TLV_TYPE_POA_BOFF_RO_YRP: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RO_YRP, + cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RO_YRP ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst ); + } + break; + + case cOCT6100_TLV_TYPE_CNR_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CNR_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_CNR_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst ); + } + break; + + case cOCT6100_TLV_TYPE_ANR_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_ANR_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_ANR_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst ); + } + break; + + case cOCT6100_TLV_TYPE_HZ_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_HZ_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_HZ_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst ); + } + /* Set flag indicating that the feature is present.*/ + f_pApiInstance->pSharedInfo->ImageInfo.fRinDcOffsetRemoval = TRUE; + break; + + case cOCT6100_TLV_TYPE_HX_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_HX_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_HX_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst ); + } + /* Set flag indicating that the feature is present.*/ + f_pApiInstance->pSharedInfo->ImageInfo.fSinDcOffsetRemoval = TRUE; + break; + + case cOCT6100_TLV_TYPE_LCA_Z_CONF_BOFF_RW_GAIN: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_LCA_Z_CONF_BOFF_RW_GAIN, + cOCT6100_TLV_MAX_LENGTH_LCA_Z_CONF_BOFF_RW_GAIN ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinLevelControlOfst ); + } + break; + + case cOCT6100_TLV_TYPE_LCA_Y_CONF_BOFF_RW_GAIN: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_LCA_Y_CONF_BOFF_RW_GAIN, + cOCT6100_TLV_MAX_LENGTH_LCA_Y_CONF_BOFF_RW_GAIN ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SoutLevelControlOfst ); + } + break; + + case cOCT6100_TLV_TYPE_CNA_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CNA_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_CNA_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ComfortNoiseModeOfst ); + } + /* Set flag indicating that the feature is present.*/ + f_pApiInstance->pSharedInfo->ImageInfo.fComfortNoise = TRUE; + break; + + case cOCT6100_TLV_TYPE_NOA_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_NOA_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_NOA_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.NlpControlFieldOfst ); + } + /* Set flag indicating that the feature is present.*/ + f_pApiInstance->pSharedInfo->ImageInfo.fNlpControl = TRUE; + break; + + case cOCT6100_TLV_TYPE_VFA_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_VFA_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_VFA_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.VadControlFieldOfst ); + } + /* Set flag indicating that the feature is present.*/ + f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression = TRUE; + break; + + case cOCT6100_TLV_TYPE_TLA_MAIN_IO_BOFF_RW_TAIL_DISP: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_TLA_MAIN_IO_BOFF_RW_TAIL_DISP, + cOCT6100_TLV_MAX_LENGTH_TLA_MAIN_IO_BOFF_RW_TAIL_DISP ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PouchTailDisplOfst ); + } + break; + + case cOCT6100_TLV_TYPE_BOOTA_POUCH_BOFF_RW_BOOT_INST: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_INST, + cOCT6100_TLV_MAX_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_INST ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PouchBootInstructionOfst ); + } + break; + + case cOCT6100_TLV_TYPE_BOOTA_POUCH_BOFF_RW_BOOT_RESULT: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_RESULT, + cOCT6100_TLV_MAX_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_RESULT ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PouchBootResultOfst ); + } + break; + + case cOCT6100_TLV_TYPE_TDM_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_TDM_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_TDM_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ToneDisablerControlOfst ); + } + + f_pApiInstance->pSharedInfo->ImageInfo.fToneDisabler = TRUE; + break; + + case cOCT6100_TLV_TYPE_DIS_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DIS_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_DIS_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.TailDisplEnableOfst ); + } + + f_pApiInstance->pSharedInfo->ImageInfo.fTailDisplacement = TRUE; + break; + + case cOCT6100_TLV_TYPE_NT_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_NT_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_NT_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.NlpTrivialFieldOfst ); + } + + break; + + case cOCT6100_TLV_TYPE_DEBUG_CHAN_INDEX_VALUE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_INDEX_VALUE, + cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_INDEX_VALUE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + } + + f_pApiInstance->pSharedInfo->DebugInfo.usRecordMemIndex = (UINT16)( ulTempValue & 0xFFFF ); + + break; + + case cOCT6100_TLV_TYPE_ADPCM_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_ADPCM_ENABLE, + cOCT6100_TLV_MAX_LENGTH_ADPCM_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + } + + if ( ulTempValue == 0 ) + f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm = FALSE; + else + f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm = TRUE; + + break; + + case cOCT6100_TLV_TYPE_CONFERENCING_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CONFERENCING_ENABLE, + cOCT6100_TLV_MAX_LENGTH_CONFERENCING_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + } + + if ( ulTempValue == 0 ) + f_pApiInstance->pSharedInfo->ImageInfo.fConferencing = FALSE; + else + f_pApiInstance->pSharedInfo->ImageInfo.fConferencing = TRUE; + + break; + + case cOCT6100_TLV_TYPE_TONE_DETECTOR_PROFILE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_TONE_DETECTOR_PROFILE, + cOCT6100_TLV_MIN_LENGTH_TONE_DETECTOR_PROFILE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->ImageInfo.ulToneProfileNumber ); + } + + break; + + case cOCT6100_TLV_TYPE_MAX_TAIL_DISPLACEMENT: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MAX_TAIL_DISPLACEMENT, + cOCT6100_TLV_MAX_LENGTH_MAX_TAIL_DISPLACEMENT ); + if ( ulResult == cOCT6100_ERR_OK ) + { + UINT32 ulTailDispTempValue = 0; + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTailDispTempValue ); + + ulTailDispTempValue += 1; /* Convert the value into milliseconds.*/ + ulTailDispTempValue *= 16; /* value was given in multiple of 16 ms. */ + + if ( ulTailDispTempValue >= 128 ) + f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailDisplacement = (UINT16)( ulTailDispTempValue - 128 ); + else + f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailDisplacement = 0; + + } + + break; + + case cOCT6100_TLV_TYPE_AEC_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_AEC_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_AEC_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AecFieldOfst ); + } + + /* Set the flag. */ + f_pApiInstance->pSharedInfo->ImageInfo.fAecEnabled = TRUE; + + /* Acoustic echo cancellation available! */ + f_pApiInstance->pSharedInfo->ImageInfo.fAcousticEcho = TRUE; + + break; + + case cOCT6100_TLV_TYPE_PCM_LEAK_CONF_BOFF_RW: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_PCM_LEAK_CONF_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_PCM_LEAK_CONF_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PcmLeakFieldOfst ); + } + + f_pApiInstance->pSharedInfo->ImageInfo.fNonLinearityBehaviorA = TRUE; + break; + + case cOCT6100_TLV_TYPE_DEFAULT_ERL_CONF_BOFF_RW: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DEFAULT_ERL_CONF_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_DEFAULT_ERL_CONF_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.DefaultErlFieldOfst ); + } + + /* Set the flag. */ + f_pApiInstance->pSharedInfo->ImageInfo.fDefaultErl = TRUE; + + break; + + case cOCT6100_TLV_TYPE_TONE_REM_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_TONE_REM_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_TONE_REM_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ToneRemovalFieldOfst ); + } + + /* Set the flag. */ + f_pApiInstance->pSharedInfo->ImageInfo.fToneRemoval = TRUE; + + break; + + + + case cOCT6100_TLV_TYPE_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT, + cOCT6100_TLV_MAX_LENGTH_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst ); + } + + /* Set the flag. */ + f_pApiInstance->pSharedInfo->ImageInfo.fMaxEchoPoint = TRUE; + + break; + + case cOCT6100_TLV_TYPE_NLP_CONV_CAP_CONF_BOFF_RW: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_NLP_CONV_CAP_CONF_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_NLP_CONV_CAP_CONF_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.NlpConvCapFieldOfst ); + } + + /* Set the flag. */ + f_pApiInstance->pSharedInfo->ImageInfo.fNonLinearityBehaviorB = TRUE; + + break; + + case cOCT6100_TLV_TYPE_MATRIX_EVENT_SIZE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MATRIX_EVENT_SIZE, + cOCT6100_TLV_MAX_LENGTH_MATRIX_EVENT_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulDebugEventSize ); + } + + break; + + case cOCT6100_TLV_TYPE_CNR_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CNR_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_CNR_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.fConferencingNoiseReduction = (UINT8)( ulTempValue & 0xFF ); + + if ( f_pApiInstance->pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE ) + { + /* Set flag indicating that the dominant speaker feature is present. */ + f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled = TRUE; + } + } + + break; + + case cOCT6100_TLV_TYPE_MAX_TAIL_LENGTH_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MAX_TAIL_LENGTH_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_MAX_TAIL_LENGTH_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength = (UINT16)( ulTempValue & 0xFFFF ); + } + + break; + + case cOCT6100_TLV_TYPE_MAX_NUMBER_OF_CHANNELS: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MAX_NUMBER_OF_CHANNELS, + cOCT6100_TLV_MAX_LENGTH_MAX_NUMBER_OF_CHANNELS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels = (UINT16)( ulTempValue & 0xFFFF ); + } + + break; + + case cOCT6100_TLV_TYPE_PLAYOUT_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_PLAYOUT_ENABLE, + cOCT6100_TLV_MAX_LENGTH_PLAYOUT_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + /* Set flag indicating that the feature is present. */ + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayout = (UINT8)( ulTempValue & 0xFF ); + } + + break; + + case cOCT6100_TLV_TYPE_DOMINANT_SPEAKER_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DOMINANT_SPEAKER_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_DOMINANT_SPEAKER_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst ); + } + + break; + + case cOCT6100_TLV_TYPE_TAIL_DISP_CONF_BOFF_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_TAIL_DISP_CONF_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_TAIL_DISP_CONF_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fPerChannelTailDisplacement = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_ANR_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_ANR_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_ANR_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAdaptiveNoiseReduction = (UINT8)( ulTempValue & 0xFF ); + } + + break; + + case cOCT6100_TLV_TYPE_MUSIC_PROTECTION_RW_ENABLE: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MUSIC_PROTECTION_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_MUSIC_PROTECTION_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.fMusicProtection = (UINT8)( ulTempValue & 0xFF ); + } + + break; + + case cOCT6100_TLV_TYPE_AEC_DEFAULT_ERL_BOFF: + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_AEC_DEFAULT_ERL_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_AEC_DEFAULT_ERL_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AecDefaultErlFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAecDefaultErl = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_Z_ALC_TARGET_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_Z_ALC_TARGET_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_Z_ALC_TARGET_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fRinAutoLevelControl = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_Y_ALC_TARGET_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_Y_ALC_TARGET_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_Y_ALC_TARGET_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fSoutAutoLevelControl = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_Z_HLC_TARGET_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_Z_HLC_TARGET_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_Z_HLC_TARGET_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fRinHighLevelCompensation = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_Y_HLC_TARGET_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_Y_HLC_TARGET_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_Y_HLC_TARGET_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fSoutHighLevelCompensation = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_ALC_HLC_STATUS_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_ALC_HLC_STATUS_BOFF_RW_ENABLE, + cOCT6100_TLV_MAX_LENGTH_ALC_HLC_STATUS_BOFF_RW_ENABLE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AlcHlcStatusOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAlcHlcStatus = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_Z_PLAYOUT_HARD_SKIP_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_Z_PLAYOUT_HARD_SKIP_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_Z_PLAYOUT_HARD_SKIP_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_Y_PLAYOUT_HARD_SKIP_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_Y_PLAYOUT_HARD_SKIP_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_Y_PLAYOUT_HARD_SKIP_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_AFT_FIELD_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_AFT_FIELD_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_AFT_FIELD_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AftControlOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAftControl = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_VOICE_DETECTED_STAT_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_VOICE_DETECTED_STAT_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_VOICE_DETECTED_STAT_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fSinVoiceDetectedStat = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_GAIN_APPLIED_RIN_STAT_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_GAIN_APPLIED_RIN_STAT_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_GAIN_APPLIED_RIN_STAT_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_GAIN_APPLIED_SOUT_STAT_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_GAIN_APPLIED_SOUT_STAT_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_GAIN_APPLIED_SOUT_STAT_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_MAX_ADAPT_ALE_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MAX_ADAPT_ALE_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_MAX_ADAPT_ALE_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AdaptiveAleOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fListenerEnhancement = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_RIN_ANR_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_RIN_ANR_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_RIN_ANR_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinAnrOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fRoutNoiseReduction = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_RIN_MUTE_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_RIN_MUTE_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_RIN_MUTE_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinMuteOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fRinMute = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_SIN_MUTE_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_SIN_MUTE_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_SIN_MUTE_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SinMuteOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fSinMute = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_NUMBER_PLAYOUT_EVENTS: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_NUMBER_PLAYOUT_EVENTS, + cOCT6100_TLV_MAX_LENGTH_NUMBER_PLAYOUT_EVENTS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents = (UINT8)( ulTempValue & 0xFF ); + } + + break; + + case cOCT6100_TLV_TYPE_ANR_SNR_IMPROVEMENT_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_ANR_SNR_IMPROVEMENT_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_ANR_SNR_IMPROVEMENT_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AnrSnrEnhancementOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAnrSnrEnhancement = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_ANR_AGRESSIVITY_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_ANR_AGRESSIVITY_BOFF_RW, + cOCT6100_TLV_MAX_LENGTH_ANR_AGRESSIVITY_BOFF_RW ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_CHAN_TAIL_LENGTH_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CHAN_TAIL_LENGTH_BOFF, + cOCT6100_TLV_MAX_LENGTH_CHAN_TAIL_LENGTH_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fPerChannelTailLength = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_CHAN_VQE_TONE_DISABLING_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_CHAN_VQE_TONE_DIS_BOFF, + cOCT6100_TLV_MAX_LENGTH_CHAN_VQE_TONE_DIS_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_AF_TAIL_DISP_VALUE_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_AF_TAIL_DISP_VALUE_BOFF, + cOCT6100_TLV_MAX_LENGTH_AF_TAIL_DISP_VALUE_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAfTailDisplacement = TRUE; + } + + break; + + + case cOCT6100_TLV_TYPE_POUCH_COUNTER_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_POUCH_COUNTER_BOFF, + cOCT6100_TLV_MAX_LENGTH_POUCH_COUNTER_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.PouchCounterFieldOfst ); + + f_pApiInstance->pSharedInfo->DebugInfo.fPouchCounter = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_AEC_TAIL_LENGTH_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_AEC_TAIL_BOFF, + cOCT6100_TLV_MAX_LENGTH_AEC_TAIL_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.AecTailLengthFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fAecTailLength = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_MATRIX_DWORD_BASE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MATRIX_DWORD_BASE, + cOCT6100_TLV_MAX_LENGTH_MATRIX_DWORD_BASE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress ); + + /* Mask the upper bits set by the firmware. */ + f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress &= 0x0FFFFFFF; + + /* Modify the base address to incorporate the external memory offset. */ + f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress += cOCT6100_EXTERNAL_MEM_BASE_ADDRESS; + } + + break; + + case cOCT6100_TLV_TYPE_DEBUG_CHAN_STATS_BYTE_SIZE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_STATS_BYTE_SIZE, + cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_STATS_BYTE_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ); + } + + break; + + case cOCT6100_TLV_TYPE_DEBUG_CHAN_LITE_STATS_BYTE_SIZE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_LITE_STATS_BYTE_SIZE, + cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_LITE_STATS_BYTE_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize ); + } + + break; + + case cOCT6100_TLV_TYPE_HOT_CHANNEL_SELECT_DWORD_BASE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_HOT_CHANNEL_SELECT_DWORD_BASE, + cOCT6100_TLV_MAX_LENGTH_HOT_CHANNEL_SELECT_DWORD_BASE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress ); + } + + break; + + case cOCT6100_TLV_TYPE_MATRIX_TIMESTAMP_DWORD_BASE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_TIMESTAMP_DWORD_BASE, + cOCT6100_TLV_MAX_LENGTH_TIMESTAMP_DWORD_BASE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress ); + } + + break; + + case cOCT6100_TLV_TYPE_MATRIX_WP_DWORD_BASE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MATRIX_WP_DWORD_BASE, + cOCT6100_TLV_MAX_LENGTH_MATRIX_WP_DWORD_BASE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixWpBaseAddress ); + } + + break; + + case cOCT6100_TLV_TYPE_AF_WRITE_PTR_BYTE_OFFSET: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_AF_WRITE_PTR_BYTE_OFFSET, + cOCT6100_TLV_MAX_LENGTH_AF_WRITE_PTR_BYTE_OFFSET ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulAfWritePtrByteOffset ); + } + + break; + + case cOCT6100_TLV_TYPE_RECORDED_PCM_EVENT_BYTE_SIZE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_RECORDED_PCM_EVENT_BYTE_SIZE, + cOCT6100_TLV_MAX_LENGTH_RECORDED_PCM_EVENT_BYTE_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ); + } + + break; + + case cOCT6100_TLV_TYPE_IS_ISR_CALLED_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_IS_ISR_CALLED_BOFF, + cOCT6100_TLV_MAX_LENGTH_IS_ISR_CALLED_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.IsIsrCalledFieldOfst ); + + f_pApiInstance->pSharedInfo->DebugInfo.fIsIsrCalledField = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_MUSIC_PROTECTION_ENABLE_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MUSIC_PROTECTION_ENABLE_BOFF, + cOCT6100_TLV_MAX_LENGTH_MUSIC_PROTECTION_ENABLE_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.MusicProtectionFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fMusicProtectionConfiguration = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_ENABLE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_IDLE_CODE_DETECTION, + cOCT6100_TLV_MAX_LENGTH_IDLE_CODE_DETECTION ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.fIdleCodeDetection = (UINT8)( ulTempValue & 0xFF ); + } + + break; + + case cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_IDLE_CODE_DETECTION_BOFF, + cOCT6100_TLV_MAX_LENGTH_IDLE_CODE_DETECTION_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_IMAGE_TYPE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_IMAGE_TYPE, + cOCT6100_TLV_MAX_LENGTH_IMAGE_TYPE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + /* Check if read image type value is what's expected. */ + if ( ( ulTempValue != cOCT6100_IMAGE_TYPE_WIRELINE ) + && ( ulTempValue != cOCT6100_IMAGE_TYPE_COMBINED ) ) + return cOCT6100_ERR_FATAL_E9; + + f_pApiInstance->pSharedInfo->ImageInfo.byImageType = (UINT8)( ulTempValue & 0xFF ); + } + + break; + + case cOCT6100_TLV_TYPE_MAX_WIRELINE_CHANNELS: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_MAX_WIRELINE_CHANNELS, + cOCT6100_TLV_MAX_LENGTH_MAX_WIRELINE_CHANNELS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + } + + break; + + case cOCT6100_TLV_TYPE_AF_EVENT_CB_SIZE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_AF_EVENT_CB_BYTE_SIZE, + cOCT6100_TLV_MAX_LENGTH_AF_EVENT_CB_BYTE_SIZE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->DebugInfo.ulAfEventCbByteSize ); + } + + break; + + case cOCT6100_TLV_TYPE_BUFFER_PLAYOUT_SKIP_IN_EVENTS: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_BUFFER_PLAYOUT_SKIP_IN_EVENTS, + cOCT6100_TLV_MAX_LENGTH_BUFFER_PLAYOUT_SKIP_IN_EVENTS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_ZZ_ENERGY_CHAN_STATS_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_ZZ_ENERGY_CHAN_STATS_BOFF, + cOCT6100_TLV_MAX_LENGTH_ZZ_ENERGY_CHAN_STATS_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fRinEnergyStat = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_YY_ENERGY_CHAN_STATS_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_YY_ENERGY_CHAN_STATS_BOFF, + cOCT6100_TLV_MAX_LENGTH_YY_ENERGY_CHAN_STATS_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fSoutEnergyStat = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DOUBLE_TALK_BEH_MODE, + cOCT6100_TLV_MAX_LENGTH_DOUBLE_TALK_BEH_MODE ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + if ( ulTempValue != 0 ) + f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehavior = TRUE; + else + f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehavior = FALSE; + + } + + break; + + case cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE_BOFF: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DOUBLE_TALK_BEH_MODE_BOFF, + cOCT6100_TLV_MAX_LENGTH_DOUBLE_TALK_BEH_MODE_BOFF ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance, + f_ulTlvValueAddress, + &f_pApiInstance->pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst ); + + f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst = TRUE; + } + + break; + + case cOCT6100_TLV_TYPE_SOUT_NOISE_BLEACHING: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_SOUT_NOISE_BLEACHING, + cOCT6100_TLV_MAX_LENGTH_SOUT_NOISE_BLEACHING ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + if ( ulTempValue != 0 ) + f_pApiInstance->pSharedInfo->ImageInfo.fSoutNoiseBleaching = TRUE; + else + f_pApiInstance->pSharedInfo->ImageInfo.fSoutNoiseBleaching = FALSE; + + } + + break; + + case cOCT6100_TLV_TYPE_NLP_STATISTICS: + + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_NLP_STATISTICS, + cOCT6100_TLV_MAX_LENGTH_NLP_STATISTICS ); + if ( ulResult == cOCT6100_ERR_OK ) + { + ulResult = Oct6100ApiReadDword( f_pApiInstance, + f_ulTlvValueAddress, + &ulTempValue ); + + if ( ulTempValue != 0 ) + f_pApiInstance->pSharedInfo->ImageInfo.fSinLevel = TRUE; + else + f_pApiInstance->pSharedInfo->ImageInfo.fSinLevel = FALSE; + + } + + break; + + default: + /* Unknown TLV type field... check default length and nothing else. */ + ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, + cOCT6100_TLV_MIN_LENGTH_DEFAULT, + cOCT6100_TLV_MAX_LENGTH_DEFAULT ); + break; + } + + return ulResult; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiTlvCheckLengthField + +Description: This function validates the TLV length field. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_ulTlvFieldLength Length field read from the TLV. +f_ulMinLengthValue Minimum value supported for the TLV. +f_ulMaxLengthValue Maximum value supported for the TLV. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiTlvCheckLengthField( + IN UINT32 f_ulTlvFieldLength, + IN UINT32 f_ulMinLengthValue, + IN UINT32 f_ulMaxLengthValue ) +{ + /* Check if the value is too small. */ + if ( f_ulTlvFieldLength < f_ulMinLengthValue ) + return ( cOCT6100_ERR_FATAL_59 ); + + /* Check if the value is too big. */ + if ( f_ulTlvFieldLength > f_ulMaxLengthValue ) + return ( cOCT6100_ERR_FATAL_5A ); + + /* Check if the value is dword aligned. */ + if ( ( f_ulTlvFieldLength % 4 ) != 0 ) + return ( cOCT6100_ERR_OPEN_INVALID_TLV_LENGTH ); + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiTlvReadBitOffsetStruct + +Description: This function extracts a bit offset structure from the TLV. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulAddress Address where the read the TLV information. +f_pBitOffsetStruct Pointer to a bit offset stucture. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiTlvReadBitOffsetStruct( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulAddress, + OUT tPOCT6100_TLV_OFFSET f_pBitOffsetStruct ) +{ + tOCT6100_READ_PARAMS ReadParams; + UINT16 usReadData; + + UINT32 ulResult; + UINT32 ulOffsetValue; + UINT32 ulSizeValue; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + /*======================================================================*/ + /* Read the first 16 bits of the TLV field. */ + + ReadParams.ulReadAddress = f_ulAddress; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulOffsetValue = usReadData << 16; + + /* Read the last word of the TLV type. */ + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulOffsetValue |= usReadData; + + /*======================================================================*/ + + + /*======================================================================*/ + /* Read the first 16 bits of the TLV field. */ + + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulSizeValue = usReadData << 16; + + /* Read the last word of the TLV type. */ + ReadParams.ulReadAddress += 2; + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Save data. */ + ulSizeValue |= usReadData; + + /*======================================================================*/ + + /* Set the structure fields. */ + f_pBitOffsetStruct->usDwordOffset = (UINT16)(ulOffsetValue / 32); + f_pBitOffsetStruct->byBitOffset = (UINT8) (32 - (ulOffsetValue % 32) - ulSizeValue); + f_pBitOffsetStruct->byFieldSize = (UINT8) (ulSizeValue); + + return cOCT6100_ERR_OK; +} +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tone_detection.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to enable and disable tone detection on + an echo channel. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 49 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_tone_detection_inst.h" +#include "oct6100api/oct6100_events_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_tone_detection_pub.h" +#include "oct6100api/oct6100_events_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_tone_detection_priv.h" +#include "oct6100_events_priv.h" + + +/**************************** PUBLIC FUNCTIONS *****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ToneDetectionEnable + +Description: This function enables the generation of event for a selected + tone on the specified channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pToneDetectEnable Pointer to tone detection enable structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ToneDetectionEnableDef( + tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable ) +{ + f_pToneDetectEnable->ulChannelHndl = cOCT6100_INVALID_HANDLE; + f_pToneDetectEnable->ulToneNumber = cOCT6100_INVALID_TONE; + + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100ToneDetectionEnable( + tPOCT6100_INSTANCE_API f_pApiInstance, + tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable ) +{ + tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; + tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; + UINT32 ulSerRes = cOCT6100_ERR_OK; + UINT32 ulFncRes = cOCT6100_ERR_OK; + + /* Set the process context of the serialize structure. */ + SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; + ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; + + /* Seize all list semaphores needed by this function. */ + SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; + ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); + if ( ulSerRes == cOCT6100_ERR_OK ) + { + /* Call the serialized function. */ + ulFncRes = Oct6100ToneDetectionEnableSer( f_pApiInstance, f_pToneDetectEnable ); + } + else + { + return ulSerRes; + } + + /* Release the seized semaphores. */ + ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; + ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); + + /* If an error occured then return the error code. */ + if ( ulSerRes != cOCT6100_ERR_OK ) + return ulSerRes; + if ( ulFncRes != cOCT6100_ERR_OK ) + return ulFncRes; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ToneDetectionDisable + +Description: This function disables the detection of a tone for a specific + channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pToneDetectDisable Pointer to tone detection disable structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ToneDetectionDisableDef( + tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable ) +{ + f_pToneDetectDisable->ulChannelHndl = cOCT6100_INVALID_HANDLE; + f_pToneDetectDisable->ulToneNumber = cOCT6100_INVALID_VALUE; + f_pToneDetectDisable->fDisableAll = FALSE; + + return cOCT6100_ERR_OK; +} + + + +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ToneDetectionEnableSer + +Description: Activate the detection of a tone on the specified channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pToneDetectEnable Pointer to tone detect enable structure. This structure + contains, among other things, the tone ID to enable + and the channel handle where detection should be + enabled. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ToneDetectionEnableSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable ) +{ + UINT32 ulChanIndex; + UINT32 ulExtToneChanIndex; + UINT32 ulToneEventNumber=0; + + UINT32 ulResult; + + /* Check the user's configuration of the tone detection for errors. */ + ulResult = Oct6100ApiCheckToneEnableParams( + f_pApiInstance, + f_pToneDetectEnable, + &ulChanIndex, + &ulToneEventNumber, + + &ulExtToneChanIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write to all resources needed to enable tone detection. */ + ulResult = Oct6100ApiWriteToneDetectEvent( + f_pApiInstance, + ulChanIndex, + ulToneEventNumber, + + ulExtToneChanIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update the channel entry to indicate that a new tone has been activated. */ + ulResult = Oct6100ApiUpdateChanToneDetectEntry( + f_pApiInstance, + ulChanIndex, + ulToneEventNumber, + ulExtToneChanIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiCheckToneEnableParams + +Description: Check the validity of the channel and tone requested. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pToneDetectEnable Pointer to tone detection enable structure. +f_pulChannelIndex Pointer to the channel index. +f_pulToneEventNumber Pointer to the Index of the tone associated to the requested tone. +f_pulExtToneChanIndex Pointer to the index of the extended channel index. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiCheckToneEnableParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT32 f_pulToneEventNumber, + + OUT PUINT32 f_pulExtToneChanIndex ) +{ + tPOCT6100_API_CHANNEL pEchoChannel; + UINT32 ulEntryOpenCnt; + UINT32 i; + + /*=====================================================================*/ + /* Check the channel handle. */ + + if ( (f_pToneDetectEnable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; + + *f_pulChannelIndex = f_pToneDetectEnable->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK; + if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = (f_pToneDetectEnable->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pEchoChannel->fReserved != TRUE ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_NOT_OPEN; + if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; + + /* Set the extended tone detection info if it is activated on the channel. */ + *f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex; + + /*=====================================================================*/ + /* Check the tone information. */ + + /* Find out if the tone is present in the build. */ + for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ ) + { + if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectEnable->ulToneNumber ) + { + *f_pulToneEventNumber = i; + break; + } + } + + /* Check if tone is present. */ + if ( i == cOCT6100_MAX_TONE_EVENT ) + return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE; + + /* Check if the requested tone is actually detected. */ + if ((( pEchoChannel->aulToneConf[ *f_pulToneEventNumber / 32 ] >> ( 31 - ( *f_pulToneEventNumber % 32 ))) & 0x1) == 1 ) + return cOCT6100_ERR_TONE_DETECTION_TONE_ACTIVATED; + + + + /*=====================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiWriteToneDetectEvent + +Description: Write the tone detection event in the channel main structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulChannelIndex Index of the channel within the API's channel list. +f_ulToneEventNumber Event number of the tone to be activated. +f_ulExtToneChanIndex Index of the extended tone detection channel. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiWriteToneDetectEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + + IN UINT32 f_ulExtToneChanIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + UINT32 ulResult; + UINT16 usReadData; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /*=======================================================================*/ + /* Read the current event config about to be modified. */ + + ReadParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); + ReadParams.ulReadAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; + ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + /* Set the tone event in the channel main memory for the requested direction. */ + + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + WriteParams.usWriteData = usReadData; + WriteParams.usWriteData |= ( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 ))); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*=======================================================================*/ + /* Also program the extended channel if one is present. */ + + if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) + { + /* Read the current event config about to be modified. */ + ReadParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); + ReadParams.ulReadAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; + ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Write the tone event in the channel main memory for the requested direction. */ + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + WriteParams.usWriteData = usReadData; + WriteParams.usWriteData |= ( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 ))); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*=======================================================================*/ + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiUpdateChanToneDetectEntry + +Description: Update the echo channel entry to store the info about the tone + being configured to generate detection events. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulChannelIndex Index of the channel within the API's channel list. +f_ulToneEventNumber Enabled tone event number. +f_ulExtToneChanIndex Index of the extended tone detection channel. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiUpdateChanToneDetectEntry ( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + IN UINT32 f_ulExtToneChanIndex ) +{ + tPOCT6100_API_CHANNEL pEchoChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulToneEntry; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Update the channel entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex ); + + /* Set the corresponding bit in the channel array. */ + ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; + + /* Modify the entry. */ + ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))); + + /* Copy back the new value. */ + pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; + + /* Configure also the extended channel if necessary. */ + if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) + { + /* Update the channel entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex ); + + /* Set the corresponding bit in the channel array. */ + ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; + + /* Modify the entry. */ + ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))); + + /* Copy back the new value. */ + pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; + } + + /* Check for the SS tone events that could have been generated before. */ + if ( f_ulExtToneChanIndex == cOCT6100_INVALID_INDEX ) + { + BOOL fSSTone; + UINT32 ulResult; + + ulResult = Oct6100ApiIsSSTone( f_pApiInstance, pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID, &fSSTone ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Is this a signaling system tone? */ + if ( fSSTone == TRUE ) + { + /* Check if must generate an event for the last detected SS tone. */ + if ( ( pEchoChanEntry->ulLastSSToneDetected != cOCT6100_INVALID_INDEX ) + && ( pEchoChanEntry->ulLastSSToneDetected == pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID ) ) + { + /* Must write an event for this. */ + tPOCT6100_API_TONE_EVENT pSoftEvent; + + /* If enough space. */ + if ( ( ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr ) && + ( ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0 ) ) + { + /* Form the event for this captured tone. */ + mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) + pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; + + pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_ulChannelIndex; + pSoftEvent->ulUserChanId = pEchoChanEntry->ulUserChanId; + pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID; + pSoftEvent->ulTimestamp = pEchoChanEntry->ulLastSSToneTimestamp; + pSoftEvent->ulExtToneDetectionPort = cOCT6100_INVALID_VALUE; + pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; + + /* Update the control variables of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; + if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) + pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; + + /* Set the interrupt manager such that the user knows that some tone events */ + /* are pending in the software Q. */ + pSharedInfo->IntrptManage.fToneEventsPending = TRUE; + } + else + { + /* Set the overflow flag of the buffer. */ + pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; + } + } + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ToneDetectionDisableSer + +Description: Disable the generation of events for a selected tone on the + specified channel. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pToneDetectDisable Pointer to tOCT6100_TONE_DETECTION_DISABLE structure. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ToneDetectionDisableSer( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable ) +{ + UINT32 ulChanIndex; + UINT32 ulExtToneChanIndex; + UINT32 ulToneEventNumber; + UINT32 ulResult; + BOOL fDisableAll; + + + /* Check the user's configuration of the tone detection disable structure for errors. */ + ulResult = Oct6100ApiAssertToneDetectionParams( + f_pApiInstance, + f_pToneDetectDisable, + &ulChanIndex, + &ulToneEventNumber, + &ulExtToneChanIndex, + + &fDisableAll ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear the event to detect the specified tone. */ + ulResult = Oct6100ApiClearToneDetectionEvent( + f_pApiInstance, + ulChanIndex, + ulToneEventNumber, + ulExtToneChanIndex, + + fDisableAll ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update the channel structure to indicate that the tone is no longer detected. */ + ulResult = Oct6100ApiReleaseToneDetectionEvent( + f_pApiInstance, + ulChanIndex, + ulToneEventNumber, + ulExtToneChanIndex, + fDisableAll ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiAssertToneDetectionParams + +Description: Check the validity of the tone detection disable command. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pToneDetectDisable Pointer to tone detection disable structure. +f_pulChannelIndex Pointer to the channel index +f_pulToneEventNumber Pointer to the tone event number. +f_pulExtToneChanIndex Pointer to the extended channel index. +f_pfDisableAll Pointer to the flag specifying whether all tones + should be disabled. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiAssertToneDetectionParams( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable, + OUT PUINT32 f_pulChannelIndex, + OUT PUINT32 f_pulToneEventNumber, + OUT PUINT32 f_pulExtToneChanIndex, + + OUT PBOOL f_pfDisableAll ) +{ + tPOCT6100_API_CHANNEL pEchoChannel; + UINT32 ulEntryOpenCnt; + UINT32 i; + + /*=====================================================================*/ + /* Check the echo channel handle. */ + + if ( (f_pToneDetectDisable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; + + *f_pulChannelIndex = f_pToneDetectDisable->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK; + if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; + + mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex ) + + /* Extract the entry open count from the provided handle. */ + ulEntryOpenCnt = (f_pToneDetectDisable->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; + + /* Check for errors. */ + if ( pEchoChannel->fReserved != TRUE ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_NOT_OPEN; + if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt ) + return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; + + /* Return the extended channel index. */ + *f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex; + + /* Check the disable all flag. */ + if ( f_pToneDetectDisable->fDisableAll != TRUE && f_pToneDetectDisable->fDisableAll != FALSE ) + return cOCT6100_ERR_TONE_DETECTION_DISABLE_ALL; + + /*=====================================================================*/ + /* Check the tone information. */ + + /* Find out if the tone is present in the build. */ + if ( f_pToneDetectDisable->fDisableAll == FALSE ) + { + for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ ) + { + if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectDisable->ulToneNumber ) + { + *f_pulToneEventNumber = i; + break; + } + } + + /* Check if tone is present. */ + if ( i == cOCT6100_MAX_TONE_EVENT ) + return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE; + + + + /* Check if the requested tone is actually detected. */ + if ((( pEchoChannel->aulToneConf[ *f_pulToneEventNumber / 32 ] >> ( 31 - ( *f_pulToneEventNumber % 32 ))) & 0x1) == 0 ) + return cOCT6100_ERR_TONE_DETECTION_TONE_NOT_ACTIVATED; + } + + + /*=====================================================================*/ + + /* Return the disable all flag as requested. */ + *f_pfDisableAll = f_pToneDetectDisable->fDisableAll; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiClearToneDetectionEvent + +Description: Clear the buffer playout event in the channel main structure. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulChannelIndex Index of the channel within the API's channel list. +f_ulToneEventNumber Tone event number to be deactivated. +f_ulExtToneChanIndex Index of the extended tone detection channel. +f_fDisableAll Clear all activated tones. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiClearToneDetectionEvent( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + IN UINT32 f_ulExtToneChanIndex, + + IN BOOL f_fDisableAll ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_WRITE_PARAMS WriteParams; + tOCT6100_READ_PARAMS ReadParams; + tOCT6100_WRITE_SMEAR_PARAMS SmearParams; + UINT32 ulResult; + UINT32 ulToneEventBaseAddress; + UINT16 usReadData; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + ReadParams.pusReadData = &usReadData; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + SmearParams.pProcessContext = f_pApiInstance->pProcessContext; + + SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /*=======================================================================*/ + /* Read the current event config about to be modified. */ + + ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); + ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; + + /* Check if must disable all tone events or not. */ + if ( f_fDisableAll == FALSE ) + { + ReadParams.ulReadAddress = ulToneEventBaseAddress; + ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear the event in the channel main memory.*/ + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + WriteParams.usWriteData = usReadData; + WriteParams.usWriteData &= (~( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 )))); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else /* if ( f_fDisableAll == TRUE ) */ + { + /* Clear all events in the channel main memory. */ + SmearParams.ulWriteLength = 4; + SmearParams.usWriteData = 0x0000; + SmearParams.ulWriteAddress = ulToneEventBaseAddress; + mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*=======================================================================*/ + /* Also program the extended channel if one is present. */ + + if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) + { + ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); + ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; + + /* Check if must disable all tone events or not. */ + if ( f_fDisableAll == FALSE ) + { + /* Read the current event config about to be modified. */ + ReadParams.ulReadAddress = ulToneEventBaseAddress; + ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear the event in the channel main memory.*/ + WriteParams.ulWriteAddress = ReadParams.ulReadAddress; + WriteParams.usWriteData = usReadData; + WriteParams.usWriteData &= (~( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 )))); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + else /* if ( f_fDisableAll == TRUE ) */ + { + /* Clear all events in the channel main memory.*/ + SmearParams.ulWriteLength = 4; + SmearParams.usWriteData = 0x0000; + SmearParams.ulWriteAddress = ulToneEventBaseAddress; + mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseToneDetectionEvent + +Description: Clear the entry made for this tone in the channel tone + enable array. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulChannelIndex Index of the channel within the API's channel list. +f_ulToneEventNumber Tone event number to be deactivated. +f_ulExtToneChanIndex Index of the extended tone detection channel. +f_fDisableAll Release all activated tones. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseToneDetectionEvent ( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulChannelIndex, + IN UINT32 f_ulToneEventNumber, + IN UINT32 f_ulExtToneChanIndex, + IN BOOL f_fDisableAll ) +{ + tPOCT6100_API_CHANNEL pEchoChanEntry; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulToneEntry; + UINT32 ulResult; + UINT32 ulToneEventNumber; + BOOL fSSTone; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Update the channel entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex ); + + /* Check if must release all tone events. */ + if ( f_fDisableAll == FALSE ) + { + /* Set the corresponding bit in the channel array. */ + ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; + + /* Modify the entry. */ + ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )))); + + /* Copy back the new value. */ + pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; + } + else /* if ( f_fDisableAll == TRUE ) */ + { + /* Clear all events. */ + Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) ); + } + + /* Configure also the extended channel if necessary. */ + if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) + { + /* Update the channel entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex ); + + /* Check if must release all tone events. */ + if ( f_fDisableAll == FALSE ) + { + /* Set the corresponding bit in the channel array. */ + ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; + + /* Modify the entry. */ + ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )))); + + /* Copy back the new value. */ + pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; + } + else /* if ( f_fDisableAll == TRUE ) */ + { + /* Clear all events. */ + Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) ); + } + } + + /* Re-enable the SS7 tones */ + for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ ) + { + /* Check if the current tone is a SS tone. */ + ulResult = Oct6100ApiIsSSTone( + f_pApiInstance, + f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID, + &fSSTone ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + if ( fSSTone == TRUE ) + { + /* Write to all resources needed to activate tone detection on this SS tone. */ + ulResult = Oct6100ApiWriteToneDetectEvent( + f_pApiInstance, + f_ulChannelIndex, + ulToneEventNumber, + + cOCT6100_INVALID_INDEX ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiIsSSTone + +Description: Check if specified tone number is a special signaling + system tone. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_ulToneEventNumber Tone event number to be checked against. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiIsSSTone( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulToneEventNumber, + OUT PBOOL f_fSSTone ) +{ + *f_fSSTone = FALSE; + + switch( f_ulToneEventNumber ) + { + case cOCT6100_TONE_SIN_SYSTEM7_2000: + case cOCT6100_TONE_SIN_SYSTEM7_1780: + *f_fSSTone = TRUE; + break; + default: + break; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tsi_cnct.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains functions used to open and close TSI connections + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 37 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" +#include "oct6100api/oct6100_apiud.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_channel_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_tsi_cnct_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_tsi_cnct_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_miscellaneous_priv.h" +#include "oct6100_memory_priv.h" +#include "oct6100_tsst_priv.h" +#include "oct6100_channel_priv.h" +#include "oct6100_tsi_cnct_priv.h" +/**************************** PRIVATE FUNCTIONS ****************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetTsiCnctSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management the TSI memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pOpenChip Pointer to chip configuration struct. +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetTsiCnctSwSizes( + IN tPOCT6100_CHIP_OPEN f_pOpenChip, + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Determine the amount of memory required for the API TSI connection list. */ + f_pInstSizes->ulTsiCnctList = f_pOpenChip->ulMaxTsiCncts * sizeof( tOCT6100_API_TSI_CNCT ); + + if ( f_pOpenChip->ulMaxTsiCncts > 0 ) + { + /* Calculate memory needed for TSI memory allocation. */ + ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxTsiCncts, &f_pInstSizes->ulTsiCnctAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_48; + } + else + { + f_pInstSizes->ulTsiCnctAlloc = 0; + } + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctList, ulTempVar ) + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctAlloc, ulTempVar ) + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiTsiCnctSwInit + +Description: Initializes all elements of the instance structure associated + to the TSI memory. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiTsiCnctSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_API_TSI_CNCT pChannelsTsiList; + tPOCT6100_SHARED_INFO pSharedInfo; + UINT32 ulMaxTsiChannels; + PVOID pTsiChannelsAlloc; + UINT32 ulResult; + + /* Get local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Initialize the TSI connections API list. */ + ulMaxTsiChannels = pSharedInfo->ChipConfig.usMaxTsiCncts; + + mOCT6100_GET_TSI_CNCT_LIST_PNT( pSharedInfo, pChannelsTsiList ) + + /* Clear the memory. */ + Oct6100UserMemSet( pChannelsTsiList, 0x00, sizeof(tOCT6100_API_TSI_CNCT) * ulMaxTsiChannels ); + + /* Set all entries in the TSI connections list to unused. */ + if ( ulMaxTsiChannels > 0 ) + { + mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChannelsAlloc ) + + ulResult = OctapiLlmAllocInit( &pTsiChannelsAlloc, ulMaxTsiChannels ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_49; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: oct6100_tsst.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + This file contains the functions used to manage the allocation of TSST + control structures in internal memory. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 39 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ + + +/***************************** INCLUDE FILES *******************************/ + +#include "octdef.h" + +#include "oct6100api/oct6100_defines.h" +#include "oct6100api/oct6100_errors.h" + +#include "apilib/octapi_llman.h" + +#include "oct6100api/oct6100_apiud.h" +#include "oct6100api/oct6100_tlv_inst.h" +#include "oct6100api/oct6100_chip_open_inst.h" +#include "oct6100api/oct6100_chip_stats_inst.h" +#include "oct6100api/oct6100_interrupts_inst.h" +#include "oct6100api/oct6100_remote_debug_inst.h" +#include "oct6100api/oct6100_debug_inst.h" +#include "oct6100api/oct6100_api_inst.h" +#include "oct6100api/oct6100_tsst_inst.h" + +#include "oct6100api/oct6100_interrupts_pub.h" +#include "oct6100api/oct6100_channel_pub.h" +#include "oct6100api/oct6100_chip_open_pub.h" + +#include "oct6100_chip_open_priv.h" +#include "oct6100_tsst_priv.h" + + +/**************************** PRIVATE FUNCTIONS ****************************/ + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiGetTsstSwSizes + +Description: Gets the sizes of all portions of the API instance pertinent + to the management of TSSTs. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pInstSizes Pointer to struct containing instance sizes. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiGetTsstSwSizes( + OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) +{ + UINT32 ulTempVar; + UINT32 ulResult; + + /* Determine amount of TSST needed for TSST allocation table. */ + f_pInstSizes->ulTsstAlloc = 4096 / 8; + + /* Calculate the API memory required for the TSST entry list. */ + f_pInstSizes->ulTsstEntryList = cOCT6100_MAX_TSSTS * sizeof( tOCT6100_API_TSST_ENTRY ); + + /* Calculate memory needed for TSST entry allocation. */ + ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_TSSTS, &f_pInstSizes->ulTsstEntryAlloc ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_4D; + + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsstAlloc, ulTempVar ); + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsstEntryList, ulTempVar ); + mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsstEntryAlloc, ulTempVar ); + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiTsstSwInit + +Description: Initializes all elements of the instance structure associated + to the TSST control entries. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This tsst is used to keep + the present state of the chip and all its resources. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiTsstSwInit( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_TSST_ENTRY pTsstList; + PUINT32 pulTsstAlloc; + PVOID pTsstListAlloc; + UINT32 ulResult; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + /* Initialize the TSST allocation table to "all free". */ + mOCT6100_GET_TSST_ALLOC_PNT( pSharedInfo, pulTsstAlloc ); + Oct6100UserMemSet( pulTsstAlloc, 0x00, 512 ); + + /* Initialize all the TSST list entries. */ + mOCT6100_GET_TSST_LIST_PNT( pSharedInfo, pTsstList ); + Oct6100UserMemSet( pTsstList, 0xFF, cOCT6100_MAX_TSSTS * sizeof(tOCT6100_API_TSST_ENTRY) ); + + /* Initialize the allocation list to manage the TSST entries.*/ + mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pTsstListAlloc ) + + ulResult = OctapiLlmAllocInit( &pTsstListAlloc, cOCT6100_MAX_TSSTS ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_4E; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiValidateTsst + +Description: Validates a timeslot, stream combination. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This tsst is used to keep + the present state of the chip and all its resources. + +f_ulTimeslot Timeslot component of the TDM TSST. +f_ulStream Stream component of the TDM TSST. +f_ulNumTssts Number of TSST required. +f_ulDirection Direction of the TSST (Input or Output). + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiValidateTsst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulNumTssts, + IN UINT32 f_ulTimeslot, + IN UINT32 f_ulStream, + IN UINT32 f_ulDirection ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHIP_CONFIG pChipConfig; + PUINT32 pulTsstAlloc; + + /* Obtain local pointer to shared portion of instance. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc ); + + /* Obtain local pointer to chip configuration. */ + pChipConfig = &pSharedInfo->ChipConfig; + + /* Check the TDM streams, timeslots component for errors. */ + if ( f_ulTimeslot == cOCT6100_UNASSIGNED && + f_ulStream != cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_TSST_TIMESLOT; + + if ( f_ulTimeslot != cOCT6100_UNASSIGNED && + f_ulStream == cOCT6100_UNASSIGNED ) + return cOCT6100_ERR_TSST_STREAM; + + if ( f_ulStream >= pChipConfig->byMaxTdmStreams ) + return cOCT6100_ERR_TSST_STREAM; + + /* Check timeslot value based on the frequenccy of the selected stream. */ + switch ( pChipConfig->aulTdmStreamFreqs[ f_ulStream / 4 ] ) + { + case cOCT6100_TDM_STREAM_FREQ_2MHZ: + if ( f_ulTimeslot >= 32 ) + return cOCT6100_ERR_TSST_TIMESLOT; + break; + case cOCT6100_TDM_STREAM_FREQ_4MHZ: + if ( f_ulTimeslot >= 64 ) + return cOCT6100_ERR_TSST_TIMESLOT; + break; + case cOCT6100_TDM_STREAM_FREQ_8MHZ: + if ( f_ulTimeslot >= 128 ) + return cOCT6100_ERR_TSST_TIMESLOT; + break; + case cOCT6100_TDM_STREAM_FREQ_16MHZ: + if ( f_ulTimeslot >= 256 ) + return cOCT6100_ERR_TSST_TIMESLOT; + + /* Check the stream value based on the direction. */ + if ( f_ulDirection == cOCT6100_INPUT_TSST && f_ulStream >= 16 ) + { + return cOCT6100_ERR_TSST_STREAM; + } + else if( f_ulDirection == cOCT6100_OUTPUT_TSST && f_ulStream < 16 ) + { + return cOCT6100_ERR_TSST_STREAM; + } + + break; + default: + return cOCT6100_ERR_FATAL_DC; + } + + /* Stream must be odd if two TSSTs are required. */ + if ( f_ulNumTssts == 2 && ( ( f_ulStream & 0x1) != 0x1 ) ) + return cOCT6100_ERR_TSST_STREAM; + + return cOCT6100_ERR_OK; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReserveTsst + +Description: Reserves a TSST, only one TSI entry can access a TSST at any one + time. + If the pointer f_pulTsstListIndex is set to NULL, no TSST list + entry will be reserved. + + The index in TSST control memory returned is based on the frequency + of the streams where the TSST is located and on the direction of + the TSST ( input or output ). + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This tsst is used to keep + the present state of the chip and all its resources. + +f_ulTimeslot Timeslot component of the TDM TSST. +f_ulNumTssts Number of TSSTs required. +f_ulStream Stream component of the TDM TSST. +f_ulDirection Whether the TSST in and input TSST or output TSST. +f_pusTsstMemIndex Index of the resulting TSST in the TSST control memory. +f_pusTsstListIndex Index in the TSST list of the current entry. +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReserveTsst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulTimeslot, + IN UINT32 f_ulStream, + IN UINT32 f_ulNumTsst, + IN UINT32 f_ulDirection, + OUT PUINT16 f_pusTsstMemIndex, + OUT PUINT16 f_pusTsstListIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PVOID pTsstListAlloc; + PUINT32 pulTsstAlloc; + UINT32 ulResult = cOCT6100_ERR_OK; + UINT32 ulStream; + UINT32 ulTimeslot; + + /* Get local pointer to shared portion of API instance structure. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc ); + + /*==================================================================================*/ + /* Now make the proper conversion to obtain the TSST value. */ + + /* Save the timeslot and stream value received. */ + ulStream = f_ulStream; + ulTimeslot = f_ulTimeslot; + + /* Set the TSST index associated to this stream, timeslot combination. */ + switch ( f_pApiInstance->pSharedInfo->ChipConfig.aulTdmStreamFreqs[ f_ulStream / 4 ] ) + { + case cOCT6100_TDM_STREAM_FREQ_16MHZ: + if ( f_ulDirection == cOCT6100_INPUT_TSST ) + { + ulStream = f_ulStream + ( f_ulTimeslot % 2 ) * 16; + ulTimeslot = f_ulTimeslot / 2; + } + else /* f_ulDirection == cOCT6100_OUTPUT_TSST */ + { + ulStream = ( f_ulStream - 16 ) + ( f_ulTimeslot % 2 ) * 16; + + if ( f_ulStream < 28 && ((f_ulTimeslot % 2) == 1) ) + { + ulTimeslot = ((f_ulTimeslot / 2) + 4) % 128; + } + else + { + ulTimeslot = f_ulTimeslot / 2 ; + } + } + + *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 + ulStream ); + break; + + case cOCT6100_TDM_STREAM_FREQ_8MHZ: + *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 + ulStream ); + break; + + case cOCT6100_TDM_STREAM_FREQ_4MHZ: + *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 * 2 ); + if ( f_ulDirection == cOCT6100_OUTPUT_TSST ) + { + *f_pusTsstMemIndex = (UINT16)( *f_pusTsstMemIndex + ulStream ); + } + else /* if ( f_ulDirection == cOCT6100_INPUT_TSST ) */ + { + *f_pusTsstMemIndex = (UINT16)( ( 1 * 32 + ulStream ) + *f_pusTsstMemIndex ); + } + break; + + case cOCT6100_TDM_STREAM_FREQ_2MHZ: + *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 * 4 ); + if ( f_ulDirection == cOCT6100_OUTPUT_TSST ) + { + *f_pusTsstMemIndex = (UINT16)( ulStream + *f_pusTsstMemIndex ); + } + else /* if ( f_ulDirection == cOCT6100_INPUT_TSST ) */ + { + *f_pusTsstMemIndex = (UINT16)( ( 3 * 32 + ulStream ) + *f_pusTsstMemIndex ); + } + break; + + default: + ulResult = cOCT6100_ERR_FATAL_8B; + } + /*======================================================================*/ + + + /*======================================================================*/ + /* First reserve the TSST. */ + + /* Get local pointer to TSST's entry in allocation table. */ + switch ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ ulStream / 4 ] ) + { + case cOCT6100_TDM_STREAM_FREQ_2MHZ: + ulTimeslot *= 4; + break; + case cOCT6100_TDM_STREAM_FREQ_4MHZ: + ulTimeslot *= 2; + break; + case cOCT6100_TDM_STREAM_FREQ_8MHZ: + ulTimeslot *= 1; + break; + case cOCT6100_TDM_STREAM_FREQ_16MHZ: + ulTimeslot *= 1; + break; + default: + return cOCT6100_ERR_FATAL_DD; + } + + /* Check if entry is already reserved. */ + if ( ((pulTsstAlloc[ ulTimeslot ] >> ulStream) & 0x1) == 0x1 ) + return cOCT6100_ERR_TSST_TSST_RESERVED; + + /* Check and reserve the associated TSST if required. */ + if ( f_ulNumTsst == 2 ) + { + /* Check if entry is already reserved. */ + if ( ((pulTsstAlloc[ ulTimeslot ] >> (ulStream - 1) ) & 0x1) == 0x1 ) + return cOCT6100_ERR_TSST_ASSOCIATED_TSST_RESERVED; + + /* The entry is free, it won't anymore. */ + pulTsstAlloc[ ulTimeslot ] |= (0x1 << (ulStream - 1)); + } + + /* The entry is free, it won't anymore.*/ + pulTsstAlloc[ ulTimeslot ] |= (0x1 << ulStream); + + /*======================================================================*/ + + + /*======================================================================*/ + /* Now reserve a TSST entry if requested. */ + + if ( f_pusTsstListIndex != NULL && ulResult == cOCT6100_ERR_OK ) + { + UINT32 ulTsstListIndex; + + /* Reserve a TSST entry in the API TSST list. */ + mOCT6100_GET_TSST_LIST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pTsstListAlloc ); + + ulResult = OctapiLlmAllocAlloc( pTsstListAlloc, &ulTsstListIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT ) + ulResult = cOCT6100_ERR_TSST_ALL_TSSTS_ARE_OPENED; + else + ulResult = cOCT6100_ERR_FATAL_52; + } + + *f_pusTsstListIndex = (UINT16)( ulTsstListIndex & 0xFFFF ); + } + /*======================================================================*/ + + + /*======================================================================*/ + /* Check the result of the TSST list reservation. */ + + if ( ulResult != cOCT6100_ERR_OK ) + { + /* Release the previously reserved TSST. */ + if ( f_ulNumTsst == 2 ) + { + /* Clear the entry. */ + pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << (ulStream - 1) ); + + } + + /* Clear the entry. */ + pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << ulStream); + } + + /*======================================================================*/ + + return ulResult; +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiReleaseTsst + +Description: Releases a TSST. + + If f_usTsstListIndex is set to cOCT6100_INVALID_INDEX, the API + will assume that no TSST list entry was reserved for this TSST. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This tsst is used to keep + the present state of the chip and all its resources. + +f_ulNumTssts Number of TSSTs to be released. +f_ulStream Stream component of the TDM TSST. +f_ulTimeslot Timeslot component of the TDM TSST. +f_ulDirection Whether the TSST is an input TSST or output TSST. +f_usTsstListIndex Index in the TSST list of the current entry. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 Oct6100ApiReleaseTsst( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT32 f_ulTimeslot, + IN UINT32 f_ulStream, + IN UINT32 f_ulNumTsst, + IN UINT32 f_ulDirection, + IN UINT16 f_usTsstListIndex) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + PUINT32 pulTsstAlloc; + PVOID pTsstListAlloc; + UINT32 ulResult; + UINT32 ulStream; + UINT32 ulTimeslot; + + /* Get local pointer to shared portion of API instance structure. */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + if ( f_usTsstListIndex != cOCT6100_INVALID_INDEX ) + { + mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pTsstListAlloc ) + + ulResult = OctapiLlmAllocDealloc( pTsstListAlloc, f_usTsstListIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + { + return cOCT6100_ERR_FATAL_53; + } + } + + mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc ); + + /*==================================================================================*/ + /* Now make the proper conversion to obtain the TSST value. */ + + /* Save the timeslot and stream value received. */ + ulStream = f_ulStream; + ulTimeslot = f_ulTimeslot; + + /* Set the TSST index associated to this stream, timeslot combination. */ + if ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ f_ulStream / 4 ] == cOCT6100_TDM_STREAM_FREQ_16MHZ ) + { + if ( f_ulDirection == cOCT6100_INPUT_TSST ) + { + ulStream = f_ulStream + ( f_ulTimeslot % 2 ) * 16; + ulTimeslot = f_ulTimeslot / 2; + } + else /* f_ulDirection == cOCT6100_OUTPUT_TSST */ + { + ulStream = ( f_ulStream - 16 ) + ( f_ulTimeslot % 2 ) * 16; + + if ( f_ulStream < 28 && ((f_ulTimeslot % 2) == 1) ) + { + ulTimeslot = ((f_ulTimeslot / 2) + 4) % 128; + } + else + { + ulTimeslot = f_ulTimeslot / 2 ; + } + } + } + + /* Get local pointer to TSST's entry in allocation table. */ + switch ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ ulStream / 4 ] ) + { + case cOCT6100_TDM_STREAM_FREQ_2MHZ: + ulTimeslot *= 4; + break; + case cOCT6100_TDM_STREAM_FREQ_4MHZ: + ulTimeslot *= 2; + break; + case cOCT6100_TDM_STREAM_FREQ_8MHZ: + ulTimeslot *= 1; + break; + case cOCT6100_TDM_STREAM_FREQ_16MHZ: + ulTimeslot *= 1; + break; + default: + return cOCT6100_ERR_FATAL_DE; + } + + /* Check if entry is actualy reserved. */ + if ( ((pulTsstAlloc[ ulTimeslot ] >> ulStream) & 0x1) != 0x1 ) + return cOCT6100_ERR_FATAL_55; + + /*==================================================================================*/ + + /* Clear the entry. */ + pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << ulStream); + + /* Check and release the associated TSST if required. */ + if ( f_ulNumTsst == 2 ) + { + /* Check if entry is actualy reserved. */ + if ( ((pulTsstAlloc[ ulTimeslot ] >> ( ulStream - 1)) & 0x1) != 0x1 ) + return cOCT6100_ERR_FATAL_54; + + /* Clear the entry. */ + pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << (ulStream - 1)); + + } + + return cOCT6100_ERR_OK; +} +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_llman.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + Library used to manage allocation tables and linked lists. The library is + made such that only a block of contiguous memory is needed for the + management of the linked list/allocation table. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 21 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#include "octapi_llman_private.h" +#include "apilib/octapi_llman.h" +#include "apilib/octapi_largmath.h" + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ +| API UTILITIES +| +| Function: OctapiLlmAllocGetSize. +| +| Description: This function determines the amount of memory needed to +| manage the allocation of a fixed amount of resources. +| The memory is measured in bytes. +| +| ----------------------------------------------------------------------- +| | Variable | Type | Description +| ----------------------------------------------------------------------- +| number_of_items UINT32 The number of resources to be allocated. +| *l_size UINT32 UINT32 The amount of memory needed, returned. +| +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 OctapiLlmAllocGetSize(UINT32 number_of_items,UINT32 * l_size) +{ + if (number_of_items == 0) return(GENERIC_BAD_PARAM); + + *l_size = (sizeof(LLM_ALLOC)) + (number_of_items * sizeof(UINT32)); + + return(GENERIC_OK); +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ +| API UTILITIES +| +| Function: OctapiLlmAllocInit. +| +| Description: This function intializes the LLM_ALLOC structure. +| +| ----------------------------------------------------------------------- +| | Variable | Type | Description +| ----------------------------------------------------------------------- +| **l void The memory used by the LLM_ALLOC structure. +| number_of_items UINT32 The number of resources to be allocated. +| +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 OctapiLlmAllocInit(void ** l,UINT32 number_of_items) +{ + LLM_ALLOC* ls; + UINT32 i; + + /* Check the number of items required.*/ + if (number_of_items == 0) return(GENERIC_BAD_PARAM); + + /* If no memory has been allocated yet:*/ + if (*l == NULL) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED); + + /* Build the structure before starting.*/ + ls = (LLM_ALLOC *)(*l); + ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC)); + + ls->number_of_items = number_of_items; + + /* Linked list links all structures in ascending order.*/ + for(i=0;i<number_of_items;i++) + { + ls->linked_list[i] = i+1; + } + + ls->linked_list[number_of_items - 1] = 0xFFFFFFFF; /* Invalid link.*/ + + /* Next avail is 0.*/ + ls->next_avail_num = 0; + + /* Number of allocated items is null.*/ + ls->allocated_items = 0; + + return(GENERIC_OK); +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ +| API UTILITIES +| +| Function: OctapiLlmAllocInfo. +| +| Description: This function returns the number of free and allocated +| block in the LLMAN list. +| +| ----------------------------------------------------------------------- +| | Variable | Type | Description +| ----------------------------------------------------------------------- +| *l void The memory used by the LLM_ALLOC structure. +| *allocated_items UINT32 Number of allocated items. +| *available_items UINT32 Number of available items. +| +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 OctapiLlmAllocInfo(void * l,UINT32 * allocated_items,UINT32 * available_items) +{ + LLM_ALLOC* ls; + + /* Build the structure before starting.*/ + ls = (LLM_ALLOC *)l; + ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC)); + + *allocated_items = ls->allocated_items; + *available_items = ls->number_of_items - ls->allocated_items; + return(GENERIC_OK); +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ +| API UTILITIES +| +| Function: OctapiLlmAllocInfo. +| +| Description: This function allocates the resource indicated by blocknum. +| If the resource can be allocated then GENERIC_OK is returned. +| Else an error. +| +| ----------------------------------------------------------------------- +| | Variable | Type | Description +| ----------------------------------------------------------------------- +| *l void The memory used by the LLM_ALLOC structure. +| *block_num UINT32 The resource to be allocated. +| +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 OctapiLlmAllocAlloc(void * l,UINT32 * blocknum) +{ + LLM_ALLOC* ls; + UINT32 allocated_block; + UINT32* node; + + /* Build the structure before starting.*/ + ls = (LLM_ALLOC *)l; + ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC)); + + /* Get next available block number.*/ + allocated_block = ls->next_avail_num; + + /* Check if block is invalid.*/ + if (allocated_block == 0xFFFFFFFF) + { + /* Make blocknum NULL.*/ + *blocknum = 0xFFFFFFFF; + + return(OCTAPI_LLM_NO_STRUCTURES_LEFT); + } + + node = &ls->linked_list[allocated_block]; + + /* Copy next block number.*/ + ls->next_avail_num = *node; + + /* Tag as used the current block number.*/ + *node = 0xFFFFFFFE; + + /* Return proper block number.*/ + *blocknum = allocated_block; + + /* Update block usage number.*/ + ls->allocated_items++; + + return(GENERIC_OK); +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ +| API UTILITIES +| +| Function: OctapiLlmAllocDealloc. +| +| Description: This function deallocates the resource indicated by blocknum. +| If the resource is not already allocated an error is returned. +| Else GENERIC_OK is returned. +| +| ----------------------------------------------------------------------- +| | Variable | Type | Description +| ----------------------------------------------------------------------- +| *l void The memory used by the LLM_ALLOC structure. +| block_num UINT32 The resource to be deallocated. +| +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +static UINT32 OctapiLlmAllocDealloc(void * l,UINT32 blocknum) +{ + LLM_ALLOC* ls; + UINT32* node; + + /* Build the structure before starting.*/ + ls = (LLM_ALLOC *)l; + ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC)); + + /* Check for null item pointer.*/ + if (blocknum == 0xFFFFFFFF) return(GENERIC_OK); + + /* Check if blocknum is within specified item range.*/ + if (blocknum >= ls->number_of_items) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE); + + node = &ls->linked_list[blocknum]; + + /* Check if block is really used as of now.*/ + if (*node != 0xFFFFFFFE) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED); + + /* Add link to list.*/ + *node = ls->next_avail_num; + + /* Point to returned block.*/ + ls->next_avail_num = blocknum; + + /* Update block usage number.*/ + ls->allocated_items--; + + return(GENERIC_OK); +} + +/**************************************** llm_list section **********************************************/ + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_bt0.c + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + Library used to manage a binary tree of variable max size. Library is + made to use one block of contiguous memory to manage the tree. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 18 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#include "apilib/octapi_bt0.h" +#include "octapi_bt0_private.h" + + + +static UINT32 OctApiBt0GetSize(UINT32 number_of_items,UINT32 key_size, UINT32 data_size, UINT32 * b_size) +{ + if ((key_size % 4) != 0) return(OCTAPI_BT0_KEY_SIZE_NOT_MUTLIPLE_OF_UINT32); + if ((data_size % 4) != 0) return(OCTAPI_BT0_DATA_SIZE_NOT_MUTLIPLE_OF_UINT32); + + *b_size = 0; + *b_size += sizeof(OCTAPI_BT0); + *b_size += sizeof(OCTAPI_BT0_NODE) * number_of_items; + *b_size += key_size * number_of_items; + *b_size += data_size * number_of_items; + + return(GENERIC_OK); +} + +static UINT32 OctApiBt0Init(void ** b,UINT32 number_of_items,UINT32 key_size, UINT32 data_size) +{ + UINT32 i; + OCTAPI_BT0 * bb; + + /* Check input parameters.*/ + if ((key_size % 4) != 0) return(OCTAPI_BT0_KEY_SIZE_NOT_MUTLIPLE_OF_UINT32); + if ((data_size % 4) != 0) return(OCTAPI_BT0_DATA_SIZE_NOT_MUTLIPLE_OF_UINT32); + + /* If b is not already allocated.*/ + if (*b == NULL) return(OCTAPI_BT0_MALLOC_FAILED); + + bb = (OCTAPI_BT0 *)(*b); + + /* Initialize the tree to an empty one!*/ + bb->root_link.node_number = 0xFFFFFFFF; + bb->root_link.depth = 0; + + /* Initialize tree parameters.*/ + bb->number_of_items = number_of_items; + bb->key_size = key_size / 4; + bb->data_size = data_size / 4; + + /* Initialize the next free node pointer.*/ + if (number_of_items != 0) + bb->next_free_node = 0; + else + bb->next_free_node = 0xFFFFFFFF; + + /* Setup the arrays.*/ + OctApiBt0CorrectPointers(bb); + + /* Initialize the Nodes to unused!*/ + for(i=0;i<number_of_items;i++) + { + bb->node[i].next_free_node = i + 1; + } + + /* Last empty node points to invalid node.*/ + bb->node[number_of_items-1].next_free_node = 0xFFFFFFFF; + + bb->invalid_value = 0xFFFFFFFF; + bb->no_smaller_key = OCTAPI_BT0_NO_SMALLER_KEY; + + return(GENERIC_OK); +} + + +void OctApiBt0CorrectPointers(OCTAPI_BT0 * bb) +{ + bb->node = (OCTAPI_BT0_NODE *)(((BYTE *)bb) + sizeof(OCTAPI_BT0)); + bb->key = (UINT32 *)(((BYTE *)bb->node) + (sizeof(OCTAPI_BT0_NODE) * bb->number_of_items)); + bb->data = (UINT32 *)(((BYTE *)bb->key) + (sizeof(UINT32) * bb->number_of_items * bb->key_size)); +} + + +static UINT32 OctApiBt0AddNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 new_node_number) +{ + UINT32 result; + + if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/ + { + bb->node[new_node_number].l[0].node_number = 0xFFFFFFFF; + bb->node[new_node_number].l[0].depth = 0; + bb->node[new_node_number].l[1].node_number = 0xFFFFFFFF; + bb->node[new_node_number].l[1].depth = 0; + + /* OCTAPI_BT0_LINK to parent!*/ + link->node_number = new_node_number; + link->depth = 1; /* We are a leaf, last OCTAPI_BT0_LINK depth is 1.*/ + + return(GENERIC_OK); + } + else /* Current node is used, check for a match and a direction.*/ + { + OCTAPI_BT0_NODE * this_node; + UINT32 compare; + + /* Get a pointer to this node.*/ + this_node = &(bb->node[link->node_number]); + + /* Compare this node to the lkey.*/ + compare = OctApiBt0KeyCompare(bb,link,lkey); + + if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/ + { + result = OctApiBt0AddNode2(bb,&(this_node->l[0]), lkey, new_node_number); + if (result != GENERIC_OK) return(result); + } + else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/ + { + result = OctApiBt0AddNode2(bb,&(this_node->l[1]), lkey, new_node_number); + if (result != GENERIC_OK) return(result); + } + else + { + return(OCTAPI_BT0_KEY_ALREADY_IN_TREE); + } + + /* Check if this node is unbalanced by 2. If so, rebalance it:*/ + if (this_node->l[0].depth > (this_node->l[1].depth + 1) || + this_node->l[1].depth > (this_node->l[0].depth + 1)) + { + OctApiBt0Rebalance(bb,link); + } + + /* Always update the OCTAPI_BT0_LINK depth before exiting.*/ + OctApiBt0UpdateLinkDepth(bb,link); + + return(GENERIC_OK); + } +} + + +static UINT32 OctApiBt0AddNode3(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 *p_new_node_number) +{ + UINT32 result; + + if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/ + { + if ( *p_new_node_number == 0xFFFFFFFF ) + return(OCTAPI_BT0_NO_NODES_AVAILABLE); + + bb->node[*p_new_node_number].l[0].node_number = 0xFFFFFFFF; + bb->node[*p_new_node_number].l[0].depth = 0; + bb->node[*p_new_node_number].l[1].node_number = 0xFFFFFFFF; + bb->node[*p_new_node_number].l[1].depth = 0; + + /* OCTAPI_BT0_LINK to parent!*/ + link->node_number = *p_new_node_number; + link->depth = 1; /* We are a leaf, last OCTAPI_BT0_LINK depth is 1.*/ + + return(GENERIC_OK); + } + else /* Current node is used, check for a match and a direction.*/ + { + OCTAPI_BT0_NODE * this_node; + UINT32 compare; + + /* Get a pointer to this node.*/ + this_node = &(bb->node[link->node_number]); + + /* Compare this node to the lkey.*/ + compare = OctApiBt0KeyCompare(bb,link,lkey); + + if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/ + { + result = OctApiBt0AddNode3(bb,&(this_node->l[0]), lkey, p_new_node_number); + if (result != GENERIC_OK) return(result); + } + else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/ + { + result = OctApiBt0AddNode3(bb,&(this_node->l[1]), lkey, p_new_node_number); + if (result != GENERIC_OK) return(result); + } + else + { + *p_new_node_number = link->node_number; + return(OCTAPI_BT0_KEY_ALREADY_IN_TREE); + } + + /* Check if this node is unbalanced by 2. If so, rebalance it:*/ + if (this_node->l[0].depth > (this_node->l[1].depth + 1) || + this_node->l[1].depth > (this_node->l[0].depth + 1)) + { + OctApiBt0Rebalance(bb,link); + } + + /* Always update the OCTAPI_BT0_LINK depth before exiting.*/ + OctApiBt0UpdateLinkDepth(bb,link); + + return(GENERIC_OK); + } +} + +/* state +0 -> first call to the function. +1 -> recursive call.*/ +static UINT32 OctApiBt0AddNode4(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 *p_new_node_number, UINT32 *p_prev_node_number, UINT32 state ) +{ + UINT32 result; + UINT32 *nkey; + UINT32 *okey; + + if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/ + { + bb->node[*p_new_node_number].l[0].node_number = 0xFFFFFFFF; + bb->node[*p_new_node_number].l[0].depth = 0; + bb->node[*p_new_node_number].l[1].node_number = 0xFFFFFFFF; + bb->node[*p_new_node_number].l[1].depth = 0; + + /* OCTAPI_BT0_LINK to parent!*/ + link->node_number = *p_new_node_number; + link->depth = 1; /* We are a leaf, last OCTAPI_BT0_LINK depth is 1.*/ + + if ( state == 0 ) + *p_prev_node_number = 0xFFFFFFFF; + + return(GENERIC_OK); + } + else /* Current node is used, check for a match and a direction.*/ + { + OCTAPI_BT0_NODE * this_node; + UINT32 compare; + + /* Get a pointer to this node.*/ + this_node = &(bb->node[link->node_number]); + + /* Compare this node to the lkey.*/ + compare = OctApiBt0KeyCompare(bb,link,lkey); + + if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/ + { + if ( state == 0 ) + *p_prev_node_number = OCTAPI_BT0_NO_SMALLER_KEY; + + if ( *p_prev_node_number != OCTAPI_BT0_NO_SMALLER_KEY ) + { + /* Check if the key is the smallest one encountered yet.*/ + okey = &(bb->key[bb->key_size * (*p_prev_node_number)]); + nkey = &(bb->key[bb->key_size * link->node_number]); + /* If the node is key smaller then the old small one, change the value.*/ + if ( *nkey > *okey ) + { + if ( *nkey < *lkey ) + *p_prev_node_number = link->node_number; + } + } + + result = OctApiBt0AddNode4(bb,&(this_node->l[0]), lkey, p_new_node_number, p_prev_node_number, 1); + if (result != GENERIC_OK) return(result); + } + else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/ + { + if ( state == 0 ) + *p_prev_node_number = link->node_number; + else + { + if ( *p_prev_node_number == OCTAPI_BT0_NO_SMALLER_KEY ) + *p_prev_node_number = link->node_number; + else + { + /* Check if the key is the smallest one encountered yet.*/ + okey = &(bb->key[bb->key_size * (*p_prev_node_number)]); + nkey = &(bb->key[bb->key_size * link->node_number]); + /* If the node is key smaller then the old small one, change the value.*/ + if ( *nkey > *okey ) + { + if ( *nkey < *lkey ) + *p_prev_node_number = link->node_number; + } + } + } + + result = OctApiBt0AddNode4(bb,&(this_node->l[1]), lkey, p_new_node_number, p_prev_node_number, 1); + if (result != GENERIC_OK) return(result); + } + else + { + *p_new_node_number = link->node_number; + return(OCTAPI_BT0_KEY_ALREADY_IN_TREE); + } + + /* Check if this node is unbalanced by 2. If so, rebalance it:*/ + if (this_node->l[0].depth > (this_node->l[1].depth + 1) || + this_node->l[1].depth > (this_node->l[0].depth + 1)) + { + OctApiBt0Rebalance(bb,link); + } + + /* Always update the OCTAPI_BT0_LINK depth before exiting.*/ + OctApiBt0UpdateLinkDepth(bb,link); + + return(GENERIC_OK); + } +} + +static UINT32 OctApiBt0KeyCompare(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link, UINT32 * lkey) +{ + UINT32 * nkey; + UINT32 i; + + /* Find the first UINT32 of the key.*/ + nkey = &(bb->key[bb->key_size * link->node_number]); + + for(i=0;i<bb->key_size;i++) + { + if (lkey[i] < nkey[i]) + return(OCTAPI_BT0_LKEY_SMALLER); + else if (lkey[i] > nkey[i]) + return(OCTAPI_BT0_LKEY_LARGER); + } + + return(OCTAPI_BT0_LKEY_EQUAL); +} + + +void OctApiBt0UpdateLinkDepth(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link) +{ + OCTAPI_BT0_NODE * this_node; + + /* Get a pointer to this node.*/ + this_node = &(bb->node[link->node_number]); + + if (this_node->l[0].depth > this_node->l[1].depth) + link->depth = this_node->l[0].depth + 1; + else + link->depth = this_node->l[1].depth + 1; +} + +void OctApiBt0Rebalance(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * root_link) +{ + if (bb->node[root_link->node_number].l[0].depth > (bb->node[root_link->node_number].l[1].depth + 1)) /* Heavy to the left.*/ + { + /* Check if the right child of the heavy child node is causing a problem.*/ + /* If so, do a left rotate in order to make the left most child the longer one.*/ + { + OCTAPI_BT0_LINK * heavy_link; + heavy_link = &(bb->node[root_link->node_number].l[0]); + + if (bb->node[heavy_link->node_number].l[1].depth > bb->node[heavy_link->node_number].l[0].depth) + { + OctApiBt0ExternalHeavy(bb,heavy_link); + } + } + + /* Ready to do super rotation!*/ + { + OCTAPI_BT0_LINK init_root_link; + OCTAPI_BT0_LINK init_heavy_link; + OCTAPI_BT0_LINK init_leaf_tree[3]; + + /* Save pertinent initial OCTAPI_BT0_LINK information.*/ + init_root_link = *root_link; + init_heavy_link = bb->node[root_link->node_number].l[0]; + init_leaf_tree[2] = bb->node[root_link->node_number].l[1]; + init_leaf_tree[0] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[0]; + init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[1]; + + /* Restructure the tree.*/ + *root_link = init_heavy_link; + bb->node[init_heavy_link.node_number].l[1] = init_root_link; + bb->node[init_root_link.node_number].l[0] = init_leaf_tree[1]; + + /* Reconstruct the depth of the branches.*/ + OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[1])); + OctApiBt0UpdateLinkDepth(bb,root_link); + } + } + else if (bb->node[root_link->node_number].l[1].depth > (bb->node[root_link->node_number].l[0].depth + 1)) /* Heavy to the right.*/ + { + /* Check if the right child of the heavy child node is causing a problem.*/ + /* If so, do a left rotate in order to make the left most child the longer one.*/ + { + OCTAPI_BT0_LINK * heavy_link; + heavy_link = &(bb->node[root_link->node_number].l[1]); + + if (bb->node[heavy_link->node_number].l[0].depth > bb->node[heavy_link->node_number].l[1].depth) + { + OctApiBt0ExternalHeavy(bb,heavy_link); + } + } + + /* Ready to do super rotation!*/ + { + OCTAPI_BT0_LINK init_root_link; + OCTAPI_BT0_LINK init_heavy_link; + OCTAPI_BT0_LINK init_leaf_tree[3]; + + /* Save pertinent initial OCTAPI_BT0_LINK information.*/ + init_root_link = *root_link; + init_heavy_link = bb->node[root_link->node_number].l[1]; + init_leaf_tree[2] = bb->node[root_link->node_number].l[0]; + init_leaf_tree[0] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[1]; + init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[0]; + + /* Restructure the tree.*/ + *root_link = init_heavy_link; + bb->node[init_heavy_link.node_number].l[0] = init_root_link; + bb->node[init_root_link.node_number].l[1] = init_leaf_tree[1]; + + /* Reconstruct the depth of the branches.*/ + OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[0])); + OctApiBt0UpdateLinkDepth(bb,root_link); + } + } +} + +/* This function does a rotation towards the outside of the tree*/ +/* in order to keep the heavy branches towards the outside.*/ +void OctApiBt0ExternalHeavy(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * root_link) +{ + if (bb->node[root_link->node_number].l[1].depth > bb->node[root_link->node_number].l[0].depth) /* Exterior of tree is towards the left.*/ + { + OCTAPI_BT0_LINK init_root_link; + OCTAPI_BT0_LINK init_heavy_link; + OCTAPI_BT0_LINK init_leaf_tree[3]; + + /* Save pertinent initial OCTAPI_BT0_LINK information.*/ + init_root_link = *root_link; + init_leaf_tree[0] = bb->node[root_link->node_number].l[0]; + init_heavy_link = bb->node[root_link->node_number].l[1]; + init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[0]; + init_leaf_tree[2] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[1]; + + /* Restructure the tree.*/ + *root_link = init_heavy_link; + bb->node[init_heavy_link.node_number].l[0] = init_root_link; + bb->node[init_root_link.node_number].l[1] = init_leaf_tree[1]; + + /* Reconstruct the depth of the branches.*/ + OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[0])); + OctApiBt0UpdateLinkDepth(bb,root_link); + } + else if (bb->node[root_link->node_number].l[0].depth > bb->node[root_link->node_number].l[1].depth) /* Exterior of tree is towards the right.*/ + { + OCTAPI_BT0_LINK init_root_link; + OCTAPI_BT0_LINK init_heavy_link; + OCTAPI_BT0_LINK init_leaf_tree[3]; + + /* Save pertinent initial OCTAPI_BT0_LINK information.*/ + init_root_link = *root_link; + init_leaf_tree[0] = bb->node[root_link->node_number].l[1]; + init_heavy_link = bb->node[root_link->node_number].l[0]; + init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[1]; + init_leaf_tree[2] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[0]; + + /* Restructure the tree.*/ + *root_link = init_heavy_link; + bb->node[init_heavy_link.node_number].l[1] = init_root_link; + bb->node[init_root_link.node_number].l[0] = init_leaf_tree[1]; + + /* Reconstruct the depth of the branches.*/ + OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[1])); + OctApiBt0UpdateLinkDepth(bb,root_link); + } +} + + +/* State:*/ +/* 0 = seeking node to be removed.*/ +/* 1 = node found, left branch taken.*/ +/* 2 = node found, right branch taken.*/ +static UINT32 OctApiBt0RemoveNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link, UINT32 * lkey, OCTAPI_BT0_LINK * link_to_removed_node, UINT32 state, OCTAPI_BT0_LINK * volatile_grandparent_link) +{ + UINT32 result; + OCTAPI_BT0_NODE * this_node; + + /* Get a pointer to this node.*/ + this_node = &(bb->node[link->node_number]); + + if (state == 0) + { + if (link->node_number == 0xFFFFFFFF) /* We have an empty node. The node we were looking for does not exist.*/ + { + return(OCTAPI_BT0_KEY_NOT_IN_TREE); + } + else /* Current node is used, check for a match and a direction.*/ + { + UINT32 compare; + + /* Compare this node to the lkey.*/ + compare = OctApiBt0KeyCompare(bb,link,lkey); + + if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/ + { + result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[0]), lkey, link_to_removed_node, 0, NULL); + if (result != GENERIC_OK) return(result); + } + else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/ + { + result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[1]), lkey, link_to_removed_node, 0, NULL); + if (result != GENERIC_OK) return(result); + } + else + { + link_to_removed_node = link; + + /* Keep on going down to find a replacement node.*/ + if (bb->node[link->node_number].l[0].node_number == 0xFFFFFFFF && bb->node[link->node_number].l[1].node_number == 0xFFFFFFFF) + { + /* Doe! No tree left! WHAT TO DO? */ + /* Just delete the current node. That's it.*/ + + /* Release the current node (restore free node link-list)*/ + bb->node[link->node_number].next_free_node = bb->next_free_node; + bb->next_free_node = link->node_number; + + link->node_number = 0xFFFFFFFF; + link->depth = 0; + + return(GENERIC_OK); + } + else if (bb->node[link->node_number].l[0].node_number != 0xFFFFFFFF) /* Left node is present. Go left, then permanently right.*/ + { + OCTAPI_BT0_NODE * removed_node_pnt; + removed_node_pnt = &(bb->node[link->node_number]); + + result = OctApiBt0RemoveNode2(bb,&(removed_node_pnt->l[0]), lkey, link_to_removed_node, 1, link); + if (result != GENERIC_OK) return(result); + + /* Caution! Once we are here, the link->node_pnt->l[0] has been modified,*/ + /* but is about to be discarded! Save it quickly!*/ + /* bb->node[link->node_number].l[0] = removed_node_pnt->l[0];*/ + } + else /* Right node is present. Go right, then permanently left.*/ + { + OCTAPI_BT0_NODE * removed_node_pnt; + removed_node_pnt = &(bb->node[link->node_number]); + + result = OctApiBt0RemoveNode2(bb,&(removed_node_pnt->l[1]), lkey, link_to_removed_node, 2, link); + if (result != GENERIC_OK) return(result); + + /* Caution! Once we are here, the link->node_pnt->l[0] has been modified,*/ + /* but is about to be discarded! Save it quickly!*/ + /* bb->node[link->node_number].l[1] = removed_node_pnt->l[1];*/ + } + } + } + } + else + { + /* Left side, Right-most node found! OR*/ + /* Right side, Left-most node found!*/ + if ((state == 1 && bb->node[link->node_number].l[1].node_number == 0xFFFFFFFF) || + (state == 2 && bb->node[link->node_number].l[0].node_number == 0xFFFFFFFF)) + { + OCTAPI_BT0_LINK init_chosen_link; + + /* Release the current node (restore free node link-list)*/ + bb->node[link_to_removed_node->node_number].next_free_node = bb->next_free_node; + bb->next_free_node = link_to_removed_node->node_number; + + /* Save the link to the chosen node, because it is about to be deleted.*/ + init_chosen_link = *link; + + /* Remove this node, and allow the tree to go on:*/ + { + OCTAPI_BT0_LINK init_child_link[2]; + + init_child_link[0] = bb->node[link->node_number].l[0]; + init_child_link[1] = bb->node[link->node_number].l[1]; + + if (state == 1) + *link = init_child_link[0]; + else + *link = init_child_link[1]; + } + + /* Replace the removed node by this node.*/ + { + OCTAPI_BT0_LINK init_removed_child_link[2]; + + init_removed_child_link[0] = bb->node[link_to_removed_node->node_number].l[0]; + init_removed_child_link[1] = bb->node[link_to_removed_node->node_number].l[1]; + + *link_to_removed_node = init_chosen_link; + bb->node[init_chosen_link.node_number].l[0] = init_removed_child_link[0]; + bb->node[init_chosen_link.node_number].l[1] = init_removed_child_link[1]; + } + + return(GENERIC_OK); + } + else + { + /* Keep on going, we have not found the center most node yet!*/ + if (state == 1) + { + result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[1]), lkey, link_to_removed_node, state, NULL); + if (result != GENERIC_OK) return(result); + + /* Refresh the link if our link is volatile.*/ + if (volatile_grandparent_link != NULL) + { + link = &(bb->node[volatile_grandparent_link->node_number].l[0]); + } + } + else + { + result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[0]), lkey, link_to_removed_node, state, NULL); + if (result != GENERIC_OK) return(result); + + /* Refresh the link if our link is volatile.*/ + if (volatile_grandparent_link != NULL) + { + link = &(bb->node[volatile_grandparent_link->node_number].l[1]); + } + } + } + } + + /* We may have messed up the tree. So patch it!*/ + /* Check if this node is unbalanced by 2. If so, rebalance it:*/ + if (this_node->l[0].depth > (this_node->l[1].depth + 1) || + this_node->l[1].depth > (this_node->l[0].depth + 1)) + { + OctApiBt0Rebalance(bb,link); + } + + /* Always update the OCTAPI_BT0_LINK depth before exiting.*/ + OctApiBt0UpdateLinkDepth(bb,link); + + return(GENERIC_OK); +} + +static UINT32 OctApiBt0QueryNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 * node_number) +{ + UINT32 result; + + if (link->node_number == 0xFFFFFFFF) /* We have an empty node. The node we were looking for does not exist.*/ + { + return(OCTAPI_BT0_KEY_NOT_IN_TREE); + } + else /* Current node is used, check for a match and a direction.*/ + { + UINT32 compare; + + /* Compare this node to the lkey.*/ + compare = OctApiBt0KeyCompare(bb,link,lkey); + + if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/ + { + result = OctApiBt0QueryNode2(bb,&(bb->node[link->node_number].l[0]), lkey, node_number); + if (result != GENERIC_OK) return(result); + } + else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/ + { + result = OctApiBt0QueryNode2(bb,&(bb->node[link->node_number].l[1]), lkey, node_number); + if (result != GENERIC_OK) return(result); + } + else + { + /* A match!*/ + *node_number = link->node_number; + } + } + + return(GENERIC_OK); +} + + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +File: octapi_largmath.h + + Copyright (c) 2001-2005 Octasic Inc. + +Description: + + Library used to perform arithmetic on integer values of an integer multiple + of 32-bits. + +This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is +free software; you can redistribute it and/or modify it under the terms of +the GNU General Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later version. + +The OCT6100 GPL API is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with the OCT6100 GPL API; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +$Octasic_Release: OCT612xAPI-01.00-PR38 $ + +$Octasic_Revision: 10 $ + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +#include "apilib/octapi_largmath.h" + + +/* + * Copyright (C) 2005-2006 Digium, Inc. + * + * Mark Spencer <markster@digium.com> + * + * All Rights Reserved + */ + +#include "oct6100_api.h" +#include <linux/string.h> +#include <linux/time.h> +//#include <linux/slab.h> +//#include <linux/vmalloc.h> +#include "vpm450m.h" + +/* API for Octasic access */ +static UINT32 Oct6100UserGetTime(tPOCT6100_GET_TIME f_pTime) +{ + /* Why couldn't they just take a timeval like everyone else? */ + struct timeval tv; + unsigned long long total_usecs; + unsigned int mask = ~0; + + do_gettimeofday(&tv); + total_usecs = (((unsigned long long)(tv.tv_sec)) * 1000000) + + (((unsigned long long)(tv.tv_usec))); + f_pTime->aulWallTimeUs[0] = (total_usecs & mask); + f_pTime->aulWallTimeUs[1] = (total_usecs >> 32); + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserMemSet(PVOID f_pAddress, UINT32 f_ulPattern, UINT32 f_ulLength) +{ + memset(f_pAddress, f_ulPattern, f_ulLength); + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserMemCopy(PVOID f_pDestination, PVOID f_pSource, UINT32 f_ulLength) +{ + memcpy(f_pDestination, f_pSource, f_ulLength); + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserCreateSerializeObject(tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate) +{ + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserDestroySerializeObject(tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy) +{ +#ifdef OCTASIC_DEBUG + printk("I should never be called! (destroy serialize object)\n"); +#endif + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserSeizeSerializeObject(tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize) +{ + /* Not needed */ + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserReleaseSerializeObject(tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease) +{ + /* Not needed */ + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams) +{ + oct_set_reg(f_pWriteParams->pProcessContext, f_pWriteParams->ulWriteAddress, f_pWriteParams->usWriteData); + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams) +{ + unsigned int x; + for (x=0;x<f_pSmearParams->ulWriteLength;x++) { + oct_set_reg(f_pSmearParams->pProcessContext, f_pSmearParams->ulWriteAddress + (x << 1), f_pSmearParams->usWriteData); + } + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserDriverWriteBurstApi(tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams) +{ + unsigned int x; + for (x=0;x<f_pBurstParams->ulWriteLength;x++) { + oct_set_reg(f_pBurstParams->pProcessContext, f_pBurstParams->ulWriteAddress + (x << 1), f_pBurstParams->pusWriteData[x]); + } + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams) +{ + *(f_pReadParams->pusReadData) = oct_get_reg(f_pReadParams->pProcessContext, f_pReadParams->ulReadAddress); + return cOCT6100_ERR_OK; +} + +static UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams) +{ + unsigned int x; + for (x=0;x<f_pBurstParams->ulReadLength;x++) { + f_pBurstParams->pusReadData[x] = oct_get_reg(f_pBurstParams->pProcessContext, f_pBurstParams->ulReadAddress + (x << 1)); + } + return cOCT6100_ERR_OK; +} + +#include "vpm450m_fw.h" + +#define SOUT_G168_1100GB_ON 0x40000004 +#define SOUT_DTMF_1 0x40000011 +#define SOUT_DTMF_2 0x40000012 +#define SOUT_DTMF_3 0x40000013 +#define SOUT_DTMF_A 0x4000001A +#define SOUT_DTMF_4 0x40000014 +#define SOUT_DTMF_5 0x40000015 +#define SOUT_DTMF_6 0x40000016 +#define SOUT_DTMF_B 0x4000001B +#define SOUT_DTMF_7 0x40000017 +#define SOUT_DTMF_8 0x40000018 +#define SOUT_DTMF_9 0x40000019 +#define SOUT_DTMF_C 0x4000001C +#define SOUT_DTMF_STAR 0x4000001E +#define SOUT_DTMF_0 0x40000010 +#define SOUT_DTMF_POUND 0x4000001F +#define SOUT_DTMF_D 0x4000001D + +#define ROUT_G168_2100GB_ON 0x10000000 +#define ROUT_G168_2100GB_WSPR 0x10000002 +#define ROUT_SOUT_G168_2100HB_END 0x50000003 +#define ROUT_G168_1100GB_ON 0x10000004 + +#define ROUT_DTMF_1 0x10000011 +#define ROUT_DTMF_2 0x10000012 +#define ROUT_DTMF_3 0x10000013 +#define ROUT_DTMF_A 0x1000001A +#define ROUT_DTMF_4 0x10000014 +#define ROUT_DTMF_5 0x10000015 +#define ROUT_DTMF_6 0x10000016 +#define ROUT_DTMF_B 0x1000001B +#define ROUT_DTMF_7 0x10000017 +#define ROUT_DTMF_8 0x10000018 +#define ROUT_DTMF_9 0x10000019 +#define ROUT_DTMF_C 0x1000001C +#define ROUT_DTMF_STAR 0x1000001E +#define ROUT_DTMF_0 0x10000010 +#define ROUT_DTMF_POUND 0x1000001F +#define ROUT_DTMF_D 0x1000001D + +#if 0 +#define cOCT6100_ECHO_OP_MODE_DIGITAL cOCT6100_ECHO_OP_MODE_HT_FREEZE +#else +#define cOCT6100_ECHO_OP_MODE_DIGITAL cOCT6100_ECHO_OP_MODE_POWER_DOWN +#endif + +struct vpm450m { + tPOCT6100_INSTANCE_API pApiInstance; + UINT32 aulEchoChanHndl[ 128 ]; + int chanflags[128]; + int ecmode[128]; +}; + +#define FLAG_DTMF (1 << 0) +#define FLAG_MUTE (1 << 1) +#define FLAG_ECHO (1 << 2) + +static unsigned int tones[] = { + SOUT_DTMF_1, + SOUT_DTMF_2, + SOUT_DTMF_3, + SOUT_DTMF_A, + SOUT_DTMF_4, + SOUT_DTMF_5, + SOUT_DTMF_6, + SOUT_DTMF_B, + SOUT_DTMF_7, + SOUT_DTMF_8, + SOUT_DTMF_9, + SOUT_DTMF_C, + SOUT_DTMF_STAR, + SOUT_DTMF_0, + SOUT_DTMF_POUND, + SOUT_DTMF_D, + SOUT_G168_1100GB_ON, + + ROUT_DTMF_1, + ROUT_DTMF_2, + ROUT_DTMF_3, + ROUT_DTMF_A, + ROUT_DTMF_4, + ROUT_DTMF_5, + ROUT_DTMF_6, + ROUT_DTMF_B, + ROUT_DTMF_7, + ROUT_DTMF_8, + ROUT_DTMF_9, + ROUT_DTMF_C, + ROUT_DTMF_STAR, + ROUT_DTMF_0, + ROUT_DTMF_POUND, + ROUT_DTMF_D, + ROUT_G168_1100GB_ON, +}; + +static void vpm450m_setecmode(struct vpm450m *vpm450m, int channel, int mode) +{ + tOCT6100_CHANNEL_MODIFY modify; + UINT32 ulResult; + + if (vpm450m->ecmode[channel] == mode) + return; + Oct6100ChannelModifyDef(&modify); + modify.ulEchoOperationMode = mode; + modify.ulChannelHndl = vpm450m->aulEchoChanHndl[channel]; + ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, &modify); + if (ulResult != GENERIC_OK) { + printk("Failed to apply echo can changes on channel %d!\n", channel); + } else { +#ifdef OCTASIC_DEBUG + printk("Echo can on channel %d set to %d\n", channel, mode); +#endif + vpm450m->ecmode[channel] = mode; + } +} + +void vpm450m_setdtmf(struct vpm450m *vpm450m, int channel, int detect, int mute) +{ + tOCT6100_CHANNEL_MODIFY modify; + UINT32 ulResult; + + Oct6100ChannelModifyDef(&modify); + modify.ulChannelHndl = vpm450m->aulEchoChanHndl[channel]; + if (mute) { + vpm450m->chanflags[channel] |= FLAG_MUTE; + modify.VqeConfig.fDtmfToneRemoval = TRUE; + } else { + vpm450m->chanflags[channel] &= ~FLAG_MUTE; + modify.VqeConfig.fDtmfToneRemoval = FALSE; + } + if (detect) + vpm450m->chanflags[channel] |= FLAG_DTMF; + else + vpm450m->chanflags[channel] &= ~FLAG_DTMF; + if (vpm450m->chanflags[channel] & (FLAG_DTMF|FLAG_MUTE)) { + if (!(vpm450m->chanflags[channel] & FLAG_ECHO)) { + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_RESET); + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_FREEZE); + } + } else { + if (!(vpm450m->chanflags[channel] & FLAG_ECHO)) + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_DIGITAL); + } + + ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, &modify); + if (ulResult != GENERIC_OK) { + printk("Failed to apply dtmf mute changes on channel %d!\n", channel); + } +/* printk("VPM450m: Setting DTMF on channel %d: %s / %s\n", channel, (detect ? "DETECT" : "NO DETECT"), (mute ? "MUTE" : "NO MUTE")); */ +} + +void vpm450m_setec(struct vpm450m *vpm450m, int channel, int eclen) +{ + if (eclen) { + vpm450m->chanflags[channel] |= FLAG_ECHO; + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_RESET); + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_NORMAL); + } else { + vpm450m->chanflags[channel] &= ~FLAG_ECHO; + if (vpm450m->chanflags[channel] & (FLAG_DTMF | FLAG_MUTE)) { + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_RESET); + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_FREEZE); + } else + vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_DIGITAL); + } +/* printk("VPM450m: Setting EC on channel %d to %d\n", channel, eclen); */ +} + +int vpm450m_checkirq(struct vpm450m *vpm450m) +{ + tOCT6100_INTERRUPT_FLAGS InterruptFlags; + + Oct6100InterruptServiceRoutineDef(&InterruptFlags); + Oct6100InterruptServiceRoutine(vpm450m->pApiInstance, &InterruptFlags); + if (InterruptFlags.fToneEventsPending) { + printk("VPM450M: Tone events pending!\n"); + return 1; + } + return 0; +} + +int vpm450m_getdtmf(struct vpm450m *vpm450m, int *channel, int *tone, int *start) +{ + tOCT6100_TONE_EVENT tonefound; + tOCT6100_EVENT_GET_TONE tonesearch; + UINT32 ulResult; + + Oct6100EventGetToneDef(&tonesearch); + tonesearch.pToneEvent = &tonefound; + tonesearch.ulMaxToneEvent = 1; + ulResult = Oct6100EventGetTone(vpm450m->pApiInstance, &tonesearch); + if (tonesearch.ulNumValidToneEvent) { + if (channel) + *channel = tonefound.ulUserChanId; + if (tone) { + switch(tonefound.ulToneDetected) { + case SOUT_DTMF_1: + *tone = '1'; + break; + case SOUT_DTMF_2: + *tone = '2'; + break; + case SOUT_DTMF_3: + *tone = '3'; + break; + case SOUT_DTMF_A: + *tone = 'A'; + break; + case SOUT_DTMF_4: + *tone = '4'; + break; + case SOUT_DTMF_5: + *tone = '5'; + break; + case SOUT_DTMF_6: + *tone = '6'; + break; + case SOUT_DTMF_B: + *tone = 'B'; + break; + case SOUT_DTMF_7: + *tone = '7'; + break; + case SOUT_DTMF_8: + *tone = '8'; + break; + case SOUT_DTMF_9: + *tone = '9'; + break; + case SOUT_DTMF_C: + *tone = 'C'; + break; + case SOUT_DTMF_STAR: + *tone = '*'; + break; + case SOUT_DTMF_0: + *tone = '0'; + break; + case SOUT_DTMF_POUND: + *tone = '#'; + break; + case SOUT_DTMF_D: + *tone = 'D'; + break; + case SOUT_G168_1100GB_ON: + *tone = 'f'; + break; + default: + printk("Unknown tone value %08x\n", tonefound.ulToneDetected); + *tone = 'u'; + break; + } + } + if (start) + *start = (tonefound.ulEventType == cOCT6100_TONE_PRESENT); + return 1; + } + return 0; +} + +struct vpm450m *init_vpm450m(void *wc, int *isalaw) +{ + tOCT6100_CHIP_OPEN ChipOpen; + tOCT6100_GET_INSTANCE_SIZE InstanceSize; + tOCT6100_CHANNEL_OPEN ChannelOpen; + UINT32 ulResult; + struct vpm450m *vpm450m; + int x,y,law; + + vpm450m = kmalloc(sizeof(struct vpm450m), GFP_KERNEL); + if (!vpm450m) + return NULL; + memset(vpm450m, 0, sizeof(struct vpm450m)); + for (x=0;x<128;x++) + vpm450m->ecmode[x] = -1; + + Oct6100ChipOpenDef(&ChipOpen); + + /* Setup Chip Open Parameters */ + ChipOpen.ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ; + Oct6100GetInstanceSizeDef(&InstanceSize); + + ChipOpen.pbyImageFile = vpm450m_fw; + ChipOpen.pProcessContext = wc; + ChipOpen.ulImageSize = sizeof(vpm450m_fw); + ChipOpen.fEnableMemClkOut = TRUE; + ChipOpen.ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ; + ChipOpen.ulMaxChannels = 128; + ChipOpen.ulMemoryType = cOCT6100_MEM_TYPE_DDR; + ChipOpen.ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_32MB; + ChipOpen.ulNumMemoryChips = 1; + ChipOpen.ulMaxTdmStreams = 4; + ChipOpen.aulTdmStreamFreqs[0] = cOCT6100_TDM_STREAM_FREQ_8MHZ; + ChipOpen.ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE; +#if 0 + ChipOpen.fEnableAcousticEcho = TRUE; +#endif + + ulResult = Oct6100GetInstanceSize(&ChipOpen, &InstanceSize); + if (ulResult != cOCT6100_ERR_OK) { + printk("Failed to get instance size, code %08x!\n", ulResult); + kfree(vpm450m); + return NULL; + } + + + vpm450m->pApiInstance = vmalloc(InstanceSize.ulApiInstanceSize); + if (!vpm450m->pApiInstance) { + printk("Out of memory (can't allocate %d bytes)!\n", InstanceSize.ulApiInstanceSize); + kfree(vpm450m); + return NULL; + } + + printk("Before chip open!\n"); + ulResult = Oct6100ChipOpen(vpm450m->pApiInstance, &ChipOpen); + printk("After chip open!\n"); + if (ulResult != cOCT6100_ERR_OK) { + printk("Failed to open chip, code %08x!\n", ulResult); + kfree(vpm450m); + return NULL; + } + for (x=0;x<128;x++) { + if (isalaw[x >> 5]) + law = cOCT6100_PCM_A_LAW; + else + law = cOCT6100_PCM_U_LAW; + Oct6100ChannelOpenDef(&ChannelOpen); + ChannelOpen.pulChannelHndl = &vpm450m->aulEchoChanHndl[x]; + ChannelOpen.ulUserChanId = x; + ChannelOpen.TdmConfig.ulRinPcmLaw = law; + ChannelOpen.TdmConfig.ulRinStream = 0; + ChannelOpen.TdmConfig.ulRinTimeslot = x; + ChannelOpen.TdmConfig.ulSinPcmLaw = law; + ChannelOpen.TdmConfig.ulSinStream = 1; + ChannelOpen.TdmConfig.ulSinTimeslot = x; + ChannelOpen.TdmConfig.ulSoutPcmLaw = law; + ChannelOpen.TdmConfig.ulSoutStream = 2; + ChannelOpen.TdmConfig.ulSoutTimeslot = x; + ChannelOpen.TdmConfig.ulRoutPcmLaw = law; + ChannelOpen.TdmConfig.ulRoutStream = 3; + ChannelOpen.TdmConfig.ulRoutTimeslot = x; + ChannelOpen.VqeConfig.fEnableNlp = TRUE; + ChannelOpen.VqeConfig.fRinDcOffsetRemoval = TRUE; + ChannelOpen.VqeConfig.fSinDcOffsetRemoval = TRUE; + + ChannelOpen.fEnableToneDisabler = TRUE; + ChannelOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_DIGITAL; + + ulResult = Oct6100ChannelOpen(vpm450m->pApiInstance, &ChannelOpen); + if (ulResult != GENERIC_OK) { + printk("Failed to open channel %d!\n", x); + } + for (y=0;y<sizeof(tones) / sizeof(tones[0]); y++) { + tOCT6100_TONE_DETECTION_ENABLE enable; + Oct6100ToneDetectionEnableDef(&enable); + enable.ulChannelHndl = vpm450m->aulEchoChanHndl[x]; + enable.ulToneNumber = tones[y]; + if (Oct6100ToneDetectionEnable(vpm450m->pApiInstance, &enable) != GENERIC_OK) + printk("Failed to enable tone detection on channel %d for tone %d!\n", x, y); + } + } + return vpm450m; +} + +void release_vpm450m(struct vpm450m *vpm450m) +{ + UINT32 ulResult; + tOCT6100_CHIP_CLOSE ChipClose; + Oct6100ChipCloseDef(&ChipClose); + ulResult = Oct6100ChipClose(vpm450m->pApiInstance, &ChipClose); + if (ulResult != cOCT6100_ERR_OK) { + printk("Failed to close chip, code %08x!\n", ulResult); + } + vfree(vpm450m->pApiInstance); + kfree(vpm450m); +} diff --git a/vpm450m.h b/vpm450m.h new file mode 100644 index 0000000..4365b65 --- /dev/null +++ b/vpm450m.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2006 Digium, Inc. + * + * Mark Spencer <markster@digium.com> + * + * All Rights Reserved + */ + +#ifndef _VPM450M_H +#define _VPM450M_H + + +struct vpm450m; + + +/* From driver */ +extern unsigned int oct_get_reg(void *data, unsigned int reg); +extern void oct_set_reg(void *data, unsigned int reg, unsigned int val); + +/* From vpm450m2 */ +extern struct vpm450m *init_vpm450m(void *wc, int *isalaw); +extern void vpm450m_setec(struct vpm450m *instance, int channel, int eclen); +extern void vpm450m_setdtmf(struct vpm450m *instance, int channel, int dtmfdetect, int dtmfmute); +extern int vpm450m_checkirq(struct vpm450m *vpm450m); +extern int vpm450m_getdtmf(struct vpm450m *vpm450m, int *channel, int *tone, int *start); +extern void release_vpm450m(struct vpm450m *instance); +#endif diff --git a/wct4xxp.c b/wct4xxp_base.c index a09ef6c..a060cb7 100644 --- a/wct4xxp.c +++ b/wct4xxp_base.c @@ -42,6 +42,7 @@ #include <linux/moduleparam.h> #endif #include "wct4xxp.h" +#include "vpm450m.h" /* * Tasklets provide better system interactive response at the cost of the @@ -174,7 +175,7 @@ static int loopback = 0; static int alarmdebounce = 0; #ifdef VPM_SUPPORT static int vpmsupport = 1; -static int vpmdtmfsupport = 1; +static int vpmdtmfsupport = 0; static int vpmspans = 4; #define VPM_DEFAULT_DTMFTHRESHOLD 1000 static int dtmfthreshold = VPM_DEFAULT_DTMFTHRESHOLD; @@ -208,6 +209,8 @@ static int altab[] = { #define FLAG_2NDGEN (1 << 3) #define FLAG_2PORT (1 << 4) #define FLAG_VPM2GEN (1 << 5) +#define FLAG_OCTOPT (1 << 6) +#define FLAG_3RDGEN (1 << 7) #define CANARY 0xc0de @@ -217,8 +220,12 @@ struct devtype { }; static struct devtype wct4xxp = { "Wildcard TE410P/TE405P (1st Gen)", 0 }; +static struct devtype wct410p3 = { "Wildcard TE410P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN }; +static struct devtype wct405p3 = { "Wildcard TE405P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN }; static struct devtype wct410p2 = { "Wildcard TE410P (2nd Gen)", FLAG_2NDGEN }; static struct devtype wct405p2 = { "Wildcard TE405P (2nd Gen)", FLAG_2NDGEN }; +static struct devtype wct205p3 = { "Wildcard TE205P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT }; +static struct devtype wct210p3 = { "Wildcard TE210P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT }; static struct devtype wct205 = { "Wildcard TE205P ", FLAG_2NDGEN | FLAG_2PORT }; static struct devtype wct210 = { "Wildcard TE210P ", FLAG_2NDGEN | FLAG_2PORT }; @@ -288,6 +295,8 @@ struct t4 { int flags; /* Device flags */ int master; /* Are we master */ int ledreg; /* LED Register */ + unsigned int gpio; + unsigned int gpioctl; int stopdma; /* Set to stop DMA */ unsigned int dmactrl; int e1recover; /* E1 recovery timer */ @@ -319,13 +328,15 @@ struct t4 { char *variety; int last0; /* for detecting double-missed IRQ */ int checktiming; /* Set >0 to cause the timing source to be checked */ + struct vpm450m *vpm450m; }; #define T4_VPM_PRESENT (1 << 28) #ifdef VPM_SUPPORT -static void t4_vpm_init(struct t4 *wc); +static void t4_vpm400_init(struct t4 *wc); +static void t4_vpm450_init(struct t4 *wc); static void t4_vpm_set_dtmf_threshold(struct t4 *wc, unsigned int threshold); #endif static void __set_clear(struct t4 *wc, int span); @@ -356,6 +367,9 @@ static void __t4_check_sigbits(struct t4 *wc, int span); #define WC_GPIO 9 #define WC_LADDR 10 #define WC_LDATA 11 +#define WC_LCS (1 << 11) +#define WC_LCS2 (1 << 12) +#define WC_LALE (1 << 13) #define WC_LREAD (1 << 15) #define WC_LWRITE (1 << 16) @@ -396,6 +410,44 @@ static inline unsigned int __t4_pci_in(struct t4 *wc, const unsigned int addr) return le32_to_cpu(wc->membase[addr]); } +static inline void __t4_gpio_set(struct t4 *wc, unsigned bits, unsigned int val) +{ + unsigned int newgpio; + newgpio = wc->gpio & (~bits); + newgpio |= val; + if (newgpio != wc->gpio) { + wc->gpio = newgpio; + __t4_pci_out(wc, WC_GPIO, wc->gpio); + } +} + +static inline void __t4_gpio_setdir(struct t4 *wc, unsigned int bits, unsigned int val) +{ + unsigned int newgpioctl; + newgpioctl = wc->gpioctl & (~bits); + newgpioctl |= val; + if (newgpioctl != wc->gpioctl) { + wc->gpioctl = newgpioctl; + __t4_pci_out(wc, WC_GPIOCTL, wc->gpioctl); + } +} + +static inline void t4_gpio_setdir(struct t4 *wc, unsigned int bits, unsigned int val) +{ + unsigned long flags; + spin_lock_irqsave(&wc->reglock, flags); + __t4_gpio_setdir(wc, bits, val); + spin_unlock_irqrestore(&wc->reglock, flags); +} + +static inline void t4_gpio_set(struct t4 *wc, unsigned int bits, unsigned int val) +{ + unsigned long flags; + spin_lock_irqsave(&wc->reglock, flags); + __t4_gpio_set(wc, bits, val); + spin_unlock_irqrestore(&wc->reglock, flags); +} + static inline void t4_pci_out(struct t4 *wc, const unsigned int addr, const unsigned int value) { unsigned long flags; @@ -502,6 +554,80 @@ static inline unsigned int __t4_vpm_in(struct t4 *wc, int unit, const unsigned i return ret & 0xff; } +static inline void __t4_raw_oct_out(struct t4 *wc, const unsigned int addr, const unsigned int value) +{ + int octopt = wc->tspans[0]->spanflags & FLAG_OCTOPT; + if (!octopt) + __t4_gpio_set(wc, 0xff, (addr >> 8)); + __t4_pci_out(wc, WC_LDATA, 0x10000 | (addr & 0xffff)); + if (!octopt) + __t4_pci_out(wc, WC_LADDR, (WC_LWRITE)); + __t4_pci_out(wc, WC_LADDR, (WC_LWRITE | WC_LALE)); + if (!octopt) + __t4_gpio_set(wc, 0xff, (value >> 8)); + __t4_pci_out(wc, WC_LDATA, (value & 0xffff)); + __t4_pci_out(wc, WC_LADDR, (WC_LWRITE | WC_LALE | WC_LCS)); + __t4_pci_out(wc, WC_LADDR, (0)); +} + +static inline unsigned int __t4_raw_oct_in(struct t4 *wc, const unsigned int addr) +{ + unsigned int ret; + int octopt = wc->tspans[0]->spanflags & FLAG_OCTOPT; + if (!octopt) + __t4_gpio_set(wc, 0xff, (addr >> 8)); + __t4_pci_out(wc, WC_LDATA, 0x10000 | (addr & 0xffff)); + if (!octopt) + __t4_pci_out(wc, WC_LADDR, (WC_LWRITE)); + __t4_pci_out(wc, WC_LADDR, (WC_LWRITE | WC_LALE)); +#ifdef PEDANTIC_OCTASIC_CHECKING + __t4_pci_out(wc, WC_LADDR, (WC_LALE)); +#endif + if (!octopt) { + __t4_gpio_setdir(wc, 0xff, 0x00); + __t4_gpio_set(wc, 0xff, 0x00); + } + __t4_pci_out(wc, WC_LADDR, (WC_LREAD | WC_LALE | WC_LCS)); + if (octopt) { + ret = __t4_pci_in(wc, WC_LDATA) & 0xffff; + } else { + ret = __t4_pci_in(wc, WC_LDATA) & 0xff; + ret |= (__t4_pci_in(wc, WC_GPIO) & 0xff) << 8; + } + __t4_pci_out(wc, WC_LADDR, (0)); + if (!octopt) + __t4_gpio_setdir(wc, 0xff, 0xff); + return ret & 0xffff; +} + +static inline unsigned int __t4_oct_in(struct t4 *wc, unsigned int addr) +{ +#ifdef PEDANTIC_OCTASIC_CHECKING + int count = 1000; +#endif + __t4_raw_oct_out(wc, 0x0008, (addr >> 20)); + __t4_raw_oct_out(wc, 0x000a, (addr >> 4) & ((1 << 16) - 1)); + __t4_raw_oct_out(wc, 0x0000, (((addr >> 1) & 0x7) << 9) | (1 << 8) | (1)); +#ifdef PEDANTIC_OCTASIC_CHECKING + while((__t4_raw_oct_in(wc, 0x0000) & (1 << 8)) && --count); + if (count != 1000) + printk("Yah, read can be slow...\n"); + if (!count) + printk("Read timed out!\n"); +#endif + return __t4_raw_oct_in(wc, 0x0004); +} + +static inline unsigned int t4_oct_in(struct t4 *wc, const unsigned int addr) +{ + unsigned long flags; + unsigned int ret; + spin_lock_irqsave(&wc->reglock, flags); + ret = __t4_oct_in(wc, addr); + spin_unlock_irqrestore(&wc->reglock, flags); + return ret; +} + static inline unsigned int t4_vpm_in(struct t4 *wc, int unit, const unsigned int addr) { unsigned long flags; @@ -536,6 +662,32 @@ static inline void __t4_vpm_out(struct t4 *wc, int unit, const unsigned int addr #endif } +static inline void __t4_oct_out(struct t4 *wc, unsigned int addr, unsigned int value) +{ +#ifdef PEDANTIC_OCTASIC_CHECKING + int count = 1000; +#endif + __t4_raw_oct_out(wc, 0x0008, (addr >> 20)); + __t4_raw_oct_out(wc, 0x000a, (addr >> 4) & ((1 << 16) - 1)); + __t4_raw_oct_out(wc, 0x0004, value); + __t4_raw_oct_out(wc, 0x0000, (((addr >> 1) & 0x7) << 9) | (1 << 8) | (3 << 12) | 1); +#ifdef PEDANTIC_OCTASIC_CHECKING + while((__t4_raw_oct_in(wc, 0x0000) & (1 << 8)) && --count); + if (count != 1000) + printk("Yah, write can be slow\n"); + if (!count) + printk("Write timed out!\n"); +#endif +} + +static inline void t4_oct_out(struct t4 *wc, const unsigned int addr, const unsigned int value) +{ + unsigned long flags; + spin_lock_irqsave(&wc->reglock, flags); + __t4_oct_out(wc, addr, value); + spin_unlock_irqrestore(&wc->reglock, flags); +} + static inline void t4_vpm_out(struct t4 *wc, int unit, const unsigned int addr, const unsigned int value) { unsigned long flags; @@ -546,7 +698,46 @@ static inline void t4_vpm_out(struct t4 *wc, int unit, const unsigned int addr, static const char vpm_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', '*', '#'}; -static void __t4_check_vpm(struct t4 *wc, unsigned int newio) +static void t4_check_vpm450(struct t4 *wc) +{ + int channel, tone, start, span; +#if 0 + /* There's no point checking the interrupt, it's pointless. */ + vpm450m_checkirq(wc->vpm450m); +#endif + while(vpm450m_getdtmf(wc->vpm450m, &channel, &tone, &start)) { + span = channel & 0x3; + channel >>= 2; + if (!wc->t1e1)channel -= 5; + else + channel -= 1; + if (debug) + printk("Got tone %s of '%c' on channel %d of span %d\n",(start ? "START" : "STOP"), tone, channel, span + 1); + if ((wc->tspans[span]->dtmfmask & (1 << channel)) && (tone != 'u')) { + if (start) { + /* The octasic is supposed to mute us, but... Yah, you guessed it. */ + if (wc->tspans[span]->dtmfmutemask & (1 << channel)) { + unsigned long flags; + struct zt_chan *chan = &wc->tspans[span]->span.chans[channel]; + int y; + spin_lock_irqsave(&chan->lock, flags); + for (y=0;y<chan->numbufs;y++) { + if ((chan->inreadbuf > -1) && (chan->readidx[y])) + memset(chan->readbuf[chan->inreadbuf], ZT_XLAW(0, chan), chan->readidx[y]); + } + spin_unlock_irqrestore(&chan->lock, flags); + } + wc->tspans[span]->dtmfactive |= (1 << channel); + zt_qevent_lock(&wc->tspans[span]->span.chans[channel], (ZT_EVENT_DTMFDOWN | tone)); + } else { + wc->tspans[span]->dtmfactive &= ~(1 << channel); + zt_qevent_lock(&wc->tspans[span]->span.chans[channel], (ZT_EVENT_DTMFUP | tone)); + } + } + } +} + +static void __t4_check_vpm400(struct t4 *wc, unsigned int newio) { unsigned int digit, regval = 0; unsigned int regbyte; @@ -734,6 +925,20 @@ static int t4_dacs(struct zt_chan *dst, struct zt_chan *src) #ifdef VPM_SUPPORT +void oct_set_reg(void *data, unsigned int reg, unsigned int val) +{ + struct t4 *wc = data; + t4_oct_out(wc, reg, val); +} + +unsigned int oct_get_reg(void *data, unsigned int reg) +{ + struct t4 *wc = data; + unsigned int ret; + ret = t4_oct_in(wc, reg); + return ret; +} + static int t4_vpm_unit(int span, int channel) { int unit = 0; @@ -758,6 +963,7 @@ static int t4_echocan(struct zt_chan *chan, int eclen) struct t4 *wc = chan->pvt; int channel; int unit; + if (!wc->vpm) return -ENODEV; @@ -768,14 +974,23 @@ static int t4_echocan(struct zt_chan *chan, int eclen) channel = chan->chanpos; else channel = chan->chanpos + 4; - unit = t4_vpm_unit(chan->span->offset, channel); - if(debug & DEBUG_ECHOCAN) - printk("echocan: Card is %d, Channel is %d, Span is %d, unit is %d, unit offset is %d length %d\n", - wc->num, chan->chanpos, chan->span->offset, unit, channel, eclen); - if (eclen) - t4_vpm_out(wc,unit,channel,0x3e); - else - t4_vpm_out(wc,unit,channel,0x01); + if (wc->vpm450m) { + channel = channel << 2; + channel |= chan->span->offset; + if(debug & DEBUG_ECHOCAN) + printk("echocan: Card is %d, Channel is %d, Span is %d, offset is %d length %d\n", wc->num, chan->chanpos, chan->span->offset, channel, eclen); + vpm450m_setec(wc->vpm450m, channel, eclen); + // Mark msleep(10); + // // msleep(100); // longer test + } else { + unit = t4_vpm_unit(chan->span->offset, channel); + if(debug & DEBUG_ECHOCAN) + printk("echocan: Card is %d, Channel is %d, Span is %d, unit is %d, unit offset is %d length %d\n", wc->num, chan->chanpos, chan->span->offset, unit, channel, eclen); + if (eclen) + t4_vpm_out(wc,unit,channel,0x3e); + else + t4_vpm_out(wc,unit,channel,0x01); + } return 0; } #endif @@ -787,6 +1002,7 @@ static int t4_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long data) struct t4 *wc = chan->pvt; #ifdef VPM_SUPPORT int j; + int channel; struct t4_span *ts = wc->tspans[chan->span->offset]; #endif @@ -824,6 +1040,13 @@ static int t4_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long data) ts->dtmfmutemask |= (1 << (chan->chanpos - 1)); else ts->dtmfmutemask &= ~(1 << (chan->chanpos - 1)); + if (wc->vpm450m) { + channel = (chan->chanpos) << 2; + if (!wc->t1e1) + channel += (4 << 2); + channel |= chan->span->offset; + vpm450m_setdtmf(wc->vpm450m, channel, j & ZT_TONEDETECT_ON, j & ZT_TONEDETECT_MUTE); + } return 0; #endif default: @@ -1483,7 +1706,9 @@ static int t4_startup(struct zt_span *span) #ifdef VPM_SUPPORT if (!alreadyrunning && !wc->vpm) { wait_a_little(); - t4_vpm_init(wc); + t4_vpm400_init(wc); + if (!wc->vpm) + t4_vpm450_init(wc); wc->dmactrl |= wc->vpm; t4_pci_out(wc, WC_DMACTRL, wc->dmactrl); } @@ -1611,11 +1836,12 @@ static inline void __receive_span(struct t4_span *ts) #ifdef VPM_SUPPORT int y; unsigned int merged; - if ((merged = ts->dtmfactive & ts->dtmfmutemask)) { - for (y=0;y<ts->span.channels;y++) { + merged = ts->dtmfactive & ts->dtmfmutemask; + if (merged) { + for (y=0;y<ts->span.channels;y++) { /* Mute any DTMFs which are supposed to be muted */ - if (merged & (1 << y)) - memset(ts->span.chans[y].readchunk, ZT_XLAW(0, (ts->span.chans + y)), ZT_CHUNKSIZE); + if (merged & (1 << y)) { + memset(ts->span.chans[y].readchunk, ZT_XLAW(0, (ts->span.chans + y)), ZT_CHUNKSIZE); } } } #endif @@ -2173,6 +2399,7 @@ static void t4_interrupt_gen2(int irq, void *dev_id, struct pt_regs *regs) unsigned long flags; unsigned char cis; int x; + int needcheckvpm450=0; unsigned int status; #if 0 @@ -2192,13 +2419,13 @@ static void t4_interrupt_gen2(int irq, void *dev_id, struct pt_regs *regs) #endif /* Ignore if it's not for us */ - if (!(status & 0x7)) + if (!(status & 0x7)) { #ifdef LINUX26 return IRQ_NONE; #else return; #endif - + } if (!wc->spansstarted) { printk("Not prepped yet!\n"); #ifdef LINUX26 @@ -2210,7 +2437,7 @@ static void t4_interrupt_gen2(int irq, void *dev_id, struct pt_regs *regs) wc->intcount++; #if 1 - if (wc->intcount < 20) + if ((wc->intcount < 20) && debug) printk("2G: Got interrupt, status = %08x, GIS = %04x\n", status, __t4_framer_in(wc, 0, 0x6f)); #endif @@ -2275,8 +2502,8 @@ static void t4_interrupt_gen2(int irq, void *dev_id, struct pt_regs *regs) } #ifdef VPM_SUPPORT if (wc->vpm) { - if (!(wc->intcount % 16) && !(wc->tspans[0]->spanflags & FLAG_VPM2GEN)) { - /* Check DTMF events */ + if (!wc->vpm450m && !(wc->intcount % 16) && !(wc->tspans[0]->spanflags & FLAG_VPM2GEN)) { + /* Check DTMF events */ int span = (wc->intcount >> 4) & 0x3; int y; short energy; @@ -2312,8 +2539,14 @@ static void t4_interrupt_gen2(int irq, void *dev_id, struct pt_regs *regs) } } } + } + if (wc->vpm450m) { + /* How stupid is it that the octasic can't generate an interrupt when there's a tone, in spite of what their documentation says? */ + if (!(wc->intcount & 0xf)) { + needcheckvpm450 = 1; + } } else if ((status & 0xff00) != 0xff00) - __t4_check_vpm(wc, (status & 0xff00) >> 8); + __t4_check_vpm400(wc, (status & 0xff00) >> 8); } #endif @@ -2333,7 +2566,12 @@ static void t4_interrupt_gen2(int irq, void *dev_id, struct pt_regs *regs) wc->stopdma = 0x0; } spin_unlock_irqrestore(&wc->reglock, flags); - + + if (needcheckvpm450 && vpmdtmfsupport) { + t4_check_vpm450(wc); + needcheckvpm450 = 0; + } + #ifndef ENABLE_WORKQUEUES t4_pci_out(wc, WC_INTR, 0); #endif @@ -2428,7 +2666,41 @@ static int t4_vpm_echotail(void) return echotail; } -static void t4_vpm_init(struct t4 *wc) +static void t4_vpm450_init(struct t4 *wc) +{ + unsigned int check1, check2; + int laws[4] = { 0, }; + int x; + if (!vpmsupport) { + printk("VPM450M: Support Disabled\n"); + return; + } + /* Turn on GPIO/DATA mux if supported */ + t4_gpio_setdir(wc, (1 << 24), (1 << 24)); + __t4_raw_oct_out(wc, 0x000a, 0x5678); + __t4_raw_oct_out(wc, 0x0004, 0x1234); + check1 = __t4_raw_oct_in(wc, 0x0004); + check2 = __t4_raw_oct_in(wc, 0x000a); + if (1 || debug) + printk("OCT Result: %04x/%04x\n", __t4_raw_oct_in(wc, 0x0004), __t4_raw_oct_in(wc, 0x000a)); + if (__t4_raw_oct_in(wc, 0x0004) != 0x1234) { + printk("VPM450: Not Present\n"); + return; + } + /* Setup alaw vs ulaw rules */ + for (x=0;x<wc->numspans;x++) { + if (wc->tspans[x]->span.channels > 24) + laws[x] = 1; + } + if (!(wc->vpm450m = init_vpm450m(wc, laws))) { + printk("VPM450: Failed to initialize\n"); + return; + } + wc->vpm = T4_VPM_PRESENT; + printk("VPM450: Present and operational servicing %d span(s)\n", vpmspans); +} + +static void t4_vpm400_init(struct t4 *wc) { unsigned char reg; unsigned int mask; @@ -2436,7 +2708,7 @@ static void t4_vpm_init(struct t4 *wc) unsigned int i, x, y, gen2vpm=0; if (!vpmsupport) { - printk("VPM: Support Disabled\n"); + printk("VPM400M: Support Disabled\n"); return; } @@ -2457,18 +2729,18 @@ static void t4_vpm_init(struct t4 *wc) ver = t4_vpm_in(wc, x, 0x1a0); /* revision */ if ((ver != 0x26) && (ver != 0x33)) { - printk("VPM: %s\n", x ? "Inoperable" : "Not Present"); + printk("VPM400: %s\n", x ? "Inoperable" : "Not Present"); return; } if (ver == 0x33) { if (x && !gen2vpm) { - printk("VPM: Inconsistent\n"); + printk("VPM400: Inconsistent\n"); return; } ts->spanflags |= FLAG_VPM2GEN; gen2vpm++; } else if (gen2vpm) { - printk("VPM: Inconsistent\n"); + printk("VPM400: Inconsistent\n"); return; } @@ -2501,11 +2773,11 @@ static void t4_vpm_init(struct t4 *wc) reg &= 0xE0; if (ts->spantype == TYPE_E1) { if (x < vpmspans) - printk("VPM: Span %d A-law mode\n", spanno); + printk("VPM400: Span %d A-law mode\n", spanno); reg |= 0x01; } else { if (x < vpmspans) - printk("VPM: Span %d U-law mode\n", spanno); + printk("VPM400: Span %d U-law mode\n", spanno); reg &= ~0x01; } t4_vpm_out(wc,x,0x20,(reg | 0x20)); @@ -2560,7 +2832,7 @@ static void t4_vpm_init(struct t4 *wc) t4_vpm_out(wc, x, i, (x < 4) ? 0x55 : 0xAA); } - printk("VPM%s: Present and operational servicing %d span(s)\n", (gen2vpm ? "(2nd Gen)" : ""), vpmspans); + printk("VPM400%s: Present and operational servicing %d span(s)\n", (gen2vpm ? "(2nd Gen)" : ""), vpmspans); wc->vpm = T4_VPM_PRESENT; } @@ -2895,6 +3167,20 @@ static int __devinit t4_init_one(struct pci_dev *pdev, const struct pci_device_i } printk("Found a Wildcard: %s\n", wc->variety); + wc->gpio = 0x00000000; + t4_pci_out(wc, WC_GPIO, wc->gpio); + t4_gpio_setdir(wc, (1 << 17), (1 << 17)); + t4_gpio_setdir(wc, (0xff), (0xff)); +#if 0 + for (x=0;x<0x10000;x++) { + __t4_raw_oct_out(wc, 0x0004, x); + __t4_raw_oct_out(wc, 0x000a, x ^ 0xffff); + if (__t4_raw_oct_in(wc, 0x0004) != x) + printk("Register 4 failed %04x\n", x); + if (__t4_raw_oct_in(wc, 0x000a) != (x ^ 0xffff)) + printk("Register 10 failed %04x\n", x); + } +#endif res = 0; } else res = -ENOMEM; @@ -2919,7 +3205,8 @@ static int t4_hardware_stop(struct t4 *wc) } t4_pci_out(wc, WC_RDADDR, 0x0000000); t4_pci_out(wc, WC_WRADDR, 0x0000000); - t4_pci_out(wc, WC_GPIO, 0x0000000); + wc->gpio = 0x00000000; + t4_pci_out(wc, WC_GPIO, wc->gpio); t4_pci_out(wc, WC_LEDS, 0x00000000); printk("\nStopped TE%dXXP, Turned off DMA\n", wc->numspans); @@ -2934,6 +3221,11 @@ static void __devexit t4_remove_one(struct pci_dev *pdev) /* Stop hardware */ t4_hardware_stop(wc); + /* Release vpm450m */ + if (wc->vpm450m) + release_vpm450m(wc->vpm450m); + wc->vpm450m = NULL; + /* Unregister spans */ if (wc->tspans[0]->span.flags & ZT_FLAG_REGISTERED) zt_unregister(&wc->tspans[0]->span); @@ -2989,8 +3281,12 @@ static void __devexit t4_remove_one(struct pci_dev *pdev) static struct pci_device_id t4_pci_tbl[] __devinitdata = { { 0x10ee, 0x0314, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct4xxp }, + { 0xd161, 0x0410, 0x0003, PCI_ANY_ID, 0, 0, (unsigned long)&wct410p3 }, + { 0xd161, 0x0405, 0x0003, PCI_ANY_ID, 0, 0, (unsigned long)&wct405p3 }, { 0xd161, 0x0410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct410p2 }, { 0xd161, 0x0405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct405p2 }, + { 0xd161, 0x0205, 0x0003, PCI_ANY_ID, 0, 0, (unsigned long)&wct205p3 }, + { 0xd161, 0x0210, 0x0003, PCI_ANY_ID, 0, 0, (unsigned long)&wct210p3 }, { 0xd161, 0x0205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct205 }, { 0xd161, 0x0210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct210 }, { 0, } |