summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOctasic Inc <support@octasic.com>2005-11-23 15:07:18 +0200
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-02-27 21:07:40 +0200
commit3d61697e688c99ff9265238b2eab474f7f1bcfc8 (patch)
tree480768bf5c49f489b6af92d3416f1e5f48954dc1
importing OCT612x-01.00-PR38
-rw-r--r--GNU General Public Licence.txt340
-rw-r--r--ReleaseNotes.txt1892
-rw-r--r--doc/oct612Xas5000-029.pdfbin0 -> 688512 bytes
-rw-r--r--software/apilib/bt/octapi_bt0.c1179
-rw-r--r--software/apilib/bt/octapi_bt0_private.h93
-rw-r--r--software/apilib/largmath/octapi_largmath.c612
-rw-r--r--software/apilib/llman/octapi_llman.c2715
-rw-r--r--software/apilib/llman/octapi_llman_private.h206
-rw-r--r--software/include/apilib/octapi_bt0.h75
-rw-r--r--software/include/apilib/octapi_largmath.h69
-rw-r--r--software/include/apilib/octapi_llman.h142
-rw-r--r--software/include/oct6100api/oct6100_adpcm_chan_inst.h74
-rw-r--r--software/include/oct6100api/oct6100_adpcm_chan_pub.h90
-rw-r--r--software/include/oct6100api/oct6100_api.h84
-rw-r--r--software/include/oct6100api/oct6100_api_inst.h138
-rw-r--r--software/include/oct6100api/oct6100_apimi.h69
-rw-r--r--software/include/oct6100api/oct6100_apiud.h309
-rw-r--r--software/include/oct6100api/oct6100_channel_inst.h386
-rw-r--r--software/include/oct6100api/oct6100_channel_pub.h542
-rw-r--r--software/include/oct6100api/oct6100_chip_open_inst.h511
-rw-r--r--software/include/oct6100api/oct6100_chip_open_pub.h222
-rw-r--r--software/include/oct6100api/oct6100_chip_stats_inst.h84
-rw-r--r--software/include/oct6100api/oct6100_chip_stats_pub.h149
-rw-r--r--software/include/oct6100api/oct6100_conf_bridge_inst.h104
-rw-r--r--software/include/oct6100api/oct6100_conf_bridge_pub.h169
-rw-r--r--software/include/oct6100api/oct6100_debug_inst.h121
-rw-r--r--software/include/oct6100api/oct6100_debug_pub.h75
-rw-r--r--software/include/oct6100api/oct6100_defines.h642
-rw-r--r--software/include/oct6100api/oct6100_errors.h816
-rw-r--r--software/include/oct6100api/oct6100_events_inst.h69
-rw-r--r--software/include/oct6100api/oct6100_events_pub.h112
-rw-r--r--software/include/oct6100api/oct6100_interrupts_inst.h134
-rw-r--r--software/include/oct6100api/oct6100_interrupts_pub.h102
-rw-r--r--software/include/oct6100api/oct6100_mixer_inst.h86
-rw-r--r--software/include/oct6100api/oct6100_mixer_pub.h77
-rw-r--r--software/include/oct6100api/oct6100_phasing_tsst_inst.h68
-rw-r--r--software/include/oct6100api/oct6100_phasing_tsst_pub.h77
-rw-r--r--software/include/oct6100api/oct6100_playout_buf_inst.h88
-rw-r--r--software/include/oct6100api/oct6100_playout_buf_pub.h183
-rw-r--r--software/include/oct6100api/oct6100_remote_debug_inst.h73
-rw-r--r--software/include/oct6100api/oct6100_remote_debug_pub.h64
-rw-r--r--software/include/oct6100api/oct6100_tlv_inst.h72
-rw-r--r--software/include/oct6100api/oct6100_tone_detection_inst.h46
-rw-r--r--software/include/oct6100api/oct6100_tone_detection_pub.h74
-rw-r--r--software/include/oct6100api/oct6100_tsi_cnct_inst.h70
-rw-r--r--software/include/oct6100api/oct6100_tsi_cnct_pub.h77
-rw-r--r--software/include/oct6100api/oct6100_tsst_inst.h55
-rw-r--r--software/include/octdef.h113
-rw-r--r--software/include/octmac.h98
-rw-r--r--software/include/octosdependant.h155
-rw-r--r--software/include/octrpc/oct6100_rpc_protocol.h348
-rw-r--r--software/include/octrpc/rpc_protocol.h115
-rw-r--r--software/include/octtype.h152
-rw-r--r--software/include/octtypevx.h129
-rw-r--r--software/include/octtypewin.h92
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_adpcm_chan_priv.h131
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_adpcm_chan.c1204
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c13431
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c6097
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_stats.c425
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_conf_bridge.c7518
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c1100
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c1326
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.c1816
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_memory.c809
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_miscellaneous.c620
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_mixer.c1542
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_phasing_tsst.c888
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_playout_buf.c3275
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_remote_debug.c1560
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_tlv.c2033
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_tone_detection.c1002
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsi_cnct.c989
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsst.c565
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_user.c474
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_apimi/oct6100_mask_interrupts.c116
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_channel_priv.h517
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_chip_open_priv.h242
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_chip_stats_priv.h55
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_conf_bridge_priv.h318
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_debug_priv.h58
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_events_priv.h84
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_interrupts_priv.h155
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_memory_priv.h97
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_miscellaneous_priv.h431
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_mixer_priv.h150
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_phasing_tsst_priv.h114
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_playout_buf_priv.h201
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_remote_debug_priv.h144
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_tlv_priv.h510
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_tone_detection_priv.h106
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_tsi_cnct_priv.h126
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_tsst_priv.h89
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_version.h39
94 files changed, 64994 insertions, 0 deletions
diff --git a/GNU General Public Licence.txt b/GNU General Public Licence.txt
new file mode 100644
index 0000000..3912109
--- /dev/null
+++ b/GNU General Public Licence.txt
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
new file mode 100644
index 0000000..eba0f32
--- /dev/null
+++ b/ReleaseNotes.txt
@@ -0,0 +1,1892 @@
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR38
+
+Date: November 21, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-3848 : Fixed all comments + formatting for GPL release.
+PR-3758 : ulToneDisablerVqeActivationDelay check must be added
+PR-3750 : Oct6100ApiInitToneInfo is too slow because of StrStr seach.
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-3842 : Bug in Oct6100ApiModifyChannelResources function when reserving Rout TSST.
+PR-3793 : TLV length field parsing might be dangerous, not checked carefully.
+PR-3779 : Remote debugging disconnect command does not work correctly.
+PR-3749 : OCT6100 Tone enable does not work for certain firmwares.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR37
+
+Date: August 30, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameters: fIdleCodeDetection
+ fSinLevel
+
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameter: fIdleCodeDetection
+
+ NOTE: With this release, it is not possible to enable
+ fSoutAdaptiveNoiseReduction and fSoutConferencingNoiseReduction
+ simultaneously
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-3701 : Added support of Idle Code Detection feature
+PR-3702 : lSinLevel and ERLE stats are no more supported in certain firmwares.
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-3688 : Error should be returned if ulMaxChannels is too big
+PR-3711 : Bug when setting NLE and music protection simultaneously.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR36
+
+Date: July 20, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameters: fSoutNoiseBleaching
+ fDoubleTalkBehavior
+
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameters: fSoutNoiseBleaching
+ ulDoubleTalkBehavior
+
+ NOTE: With this release, it is not possible to enable
+ fSoutAdaptiveNoiseReduction and fSoutConferencingNoiseReduction
+ simultaneously
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-3610 : Added support of Noise Bleaching VQE
+PR-3561 : Added support of double talk behavior
+PR-3548 : The default value for ulNonLinearityBehaviorA should be 1 and not 0
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-3554 : Clipping if AEC is enable in NO ECHO mode and SPEECH mode
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR35
+
+Date: July 04, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-3368 : Caller ID allerting signal not played out correctly.
+PR-3382 : Law not set correctly in dump files for channel numbers with bit 2
+ set to 1.
+PR-3487 : Glitch when adding a participant to a conference
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay does not work correctly.
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR34
+
+Date: March 31, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-3336 : Tail displacement not configured correctly in ChannelOpen function
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay does not work correctly.
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR33
+
+Date: March 04, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-3226 : Improved performance of Oct6100BufferPlayoutStart function
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay does not work correctly.
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR32
+
+Date: February 28, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-3184 : Change free mixer event count check for a more precise one in
+ channel open and modify functions.
+PR-3226 : NLP tail not set correctly in LEC with Tail Displacement.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay does not work correctly.
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR31
+
+Date: February 7, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-3136 : The lDefaultErlDb parameter should also support other values -9, -12.
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-3120 : Oct6100DebugGetData does not work correctly on big endian
+ architecture.
+PR-3165 : F003_FPGA: SCN-PLC FPGA cannot be put into PASS_THRU.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay does not work correctly.
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR30
+
+Date: January 24, 2005
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ New functions: Oct6100ProductionBist
+ Oct6100DebugSelectChannel
+ Oct6100DebugGetData
+
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelGetStats
+ Added parameters: ulAecTailLength
+ ulToneDisablerVqeActivationDelay
+ fEnableMusicProtection
+
+ Modified function: Oct6100ChannelModify
+ Added parameter: ulTailLength
+
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameters: fAecTailLength
+ fPerChannelTailLength
+ fToneDisablerVqeActivationDelay
+ ulImageType
+
+ Modified function: Oct6100ChipOpen
+ Added parameters: fEnableProductionBist
+ ulNumProductionBistLoops
+
+ Modified define: cOCT6100_MAX_TAIL_DISPLACEMENT
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2748 : Added new echo operation mode for speech recognition purposes.
+PR-2885 : Added ulTailLength parameter to the ChannelOpen function
+PR-2926 : Added ulToneDisablerVqeActivationDelay to the ChannelOpen function
+PR-2951 : Added hardware PLL jitter counter for debugging.
+PR-2966 : Added acoustic echo tail length parameter to ChannelOpen function
+PR-2978 : Added functionnality in the API to dump memory.
+PR-3001 : Added production BIST of the external memory support to the API
+PR-3013 : Added support of the Octasic Music Protection feature
+PR-3017 : Added reset of the ulNumEchoPathChanges channel stat
+PR-3057 : Added ulImageType parameter to Oct6100ChipGetImageInfo.
+PR-3061 : Improved performance of Oct6100BufferPlayoutGetEvent function
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2670 : fEnableToneDisabler description not completely clear
+PR-2928 : Default values missing in function Oct6100ChannelGetStatsDef
+PR-2940 : BiDir mode does not work correctly when a channel is modified.
+PR-2954 : Default value for ulMaxPlayoutEvents is incorrect
+PR-2971 : Problems when doing law conversion while in a bridge
+PR-2973 : Some instance resources might be lost if mixer events run out in the
+ MutePorts function.
+PR-2995 : Conference bridge gets corrupted while un-muting and muting
+ participants
+PR-2999 : After several open-close of channels, output signal gets corrupted
+ when muting the input.
+PR-3003 : Wrong level control setting after close/open channel
+PR-3048 : Code cleanup, redundant code must be removed.
+PR-3058 : F003_FPGA: Bad check for PLC SCN FPGA channel ID.
+PR-3079 : F003_FPGA: Put FPGA in pass-through when doing playout and change back
+ when playout if finished.
+PR-3087 : cOCT6100_MAX_TAIL_DISPLACEMENT must be changed from 912 to 896ms.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay does not work correctly.
+PR-3004 : Compiling OCT6100 on 64-bit processor platform causes warnings
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR29
+
+Date: December 10, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2918 : Add possibility to retrieve more than 32 buffer playout events with
+ Oct6100BufferPlayoutGetEvent()
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+
+PR-2920 : cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL when trying to add
+ buffer on a new opened channel.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay not working correctly.
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR28
+
+Date: November 12, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameters: lAnrSnrEnhancementDb
+ ulAnrVoiceNoiseSegregation
+ ulSoutNaturalListenerEnhancementGainDb
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameters: fAnrSnrEnhancement
+ fAnrVoiceNoiseSegregation
+ Modified function: Oct6100ChannelModify
+ fApplyToAllChannels
+
+ 1.2 PRODUCT OCT6110
+
+ Modified function: Oct6100ChannelModify
+ fDisableToneDetection
+ fStopBufferPlayout
+ fRemoveConfBridgeParticipant
+ fRemoveBroadcastTssts
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2669 : Removed unused internal functions
+PR-2675 : Added new parameters to control the ANR behavior
+PR-2676 : fUseSynchTimestamp is no more supported
+PR-2747 : ulSoutAutomaticListenerEnhancementGainDb should be limited to maximum
+ 30 instead of 60.
+PR-2749 : New parameter must be added to configure NLE.
+PR-2759 : Implemented fApplyToAllChannels, fDisableToneDetection,
+ fStopBufferPlayout and fRemoveConfBridgeParticipant features
+PR-2805 : Playout start function should return an error if the buffer list is
+ empty.
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2677 : lAecDefaultErlDb and lDefaultErlDb are not updated correctly since
+ the ChannelModify function optimizations.
+PR-2746 : Channel stats are not correct when channel is in bypass or reset
+PR-2803 : Define for cOCT6100_KEEP_PREVIOUS_SETTING is too large for INT32
+PR-2842 : Level control must not be called in mixer function
+PR-2845 : F003_FPGA: Kappa coefficient not initialized when opening a PLC/SCN
+ FPGA channel.
+PR-2846 : F029_FPGA: Tone detection event type not set correctly.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2645 : Caller ID pre-transmit delay not working correctly.
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00.00.01
+
+Date: October 08, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+First General Availability release. Internal Release.
+
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameters: lAnrSnrEnhancementDb
+ ulAnrVoiceNoiseSegregation
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameters: fAnrSnrEnhancement
+ fAnrVoiceNoiseSegregation
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2675 : Added new parameters to control the ANR behavior
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR27
+
+Date: September 27, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2621 : The Oct6100CallerIdTransmit function should check that enough playout
+ events are available before adding them.
+PR-2630 : Increased performance of the ChannelModify function
+PR-2656 : The buffer playout events should be differentiated between regular
+ playout events and caller ID events
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2614 : Caller ID cleanup not done correctly in resource free function
+PR-2616 : Tone ports not initialized when tone detection not supported
+PR-2620 : In the caller id init function, check that the image loaded into the
+ device supports 127 events.
+PR-2633 : Playout event must be check in the OCT6100 instead of a define
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR26
+
+Date: August 31, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified function: Oct6100ChannelOpen
+ Oct6100ChannelModify
+ Oct6100ChannelGetStats
+ Added parameters: ulSoutAutomaticListenerEnhancementGainDb
+ fSoutNaturalListenerEnhancement
+ fRoutNoiseReduction
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameters: fListenerEnhancement
+ fRoutNoiseReduction
+ ulMaxPlayoutEvents
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2478 : Added support of ALE and NLE features
+PR-2479 : Added support of the Rout Noise Reduction feature
+PR-2581 : Added flexibility to support 31 or 127 buffers in the list
+PR-2576 : F029_FPGA: Add Channel enable Memory clear
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2515 : Mute mode that allow tone detection on SIN is not working.
+PR-2550 : Tail displacement offset bug
+PR-2558 : Wrong max tail displacement value.
+PR-2597 : Mixer events lost when modifying a channel in a bridge
+PR-2604 : SDR 32-bit must be configured as 2 SDR 16-bit
+PR-2609 : Data is modified when the operation mode is set to NO_ECHO
+PR-2612 : Some of the playout buffers for ETSI Caller ID are not loaded.
+PR-2526 : F029_FPGA: Bug of Oct6100ApiConvertToToneDetectionFpgaTsst for ROUT
+ TSSTs
+PR-2582 : F029_FPGA: API fix for ConvertTsst functions + others
+PR-2584 : F029_FPGA: OCT6100 API Oct6100ApiWriteToneDetectEvent bug
+PR-2601 : F029_FPGA: Oct6100TransferToneDetectionFpgaEvents: Reorder events
+ when getting two events at a time.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR25
+
+Date: August 05, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 PRODUCT OCT6120
+
+ Added function: Oct6100ChannelMute
+ Oct6100ChannelUnMute
+ Modified function: Oct6100ChannelModify
+ Added parameters: ulRinNumTssts
+ ulSinNumTssts
+ ulRoutNumTssts
+ ulSoutNumTssts
+ Modified function: Oct6100ChannelGetStats
+ Added parameters: ulMutePortsMask
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2455 : Allow modification of NumTssts parameters in function
+ Oct6100ChannelModify
+PR-2465 : Added Channel Mute and UnMute functions
+PR-2468 : Re-enable SS7 tone detection upon tone event disabling
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2439 : Noise when no input TSST assigned
+PR-2440 : Conference signal attenuated when no input TSST
+PR-2454 : F029_FPGA: For MFR1 and MFR2, we can enable a tone OF MFR1 group
+ (or MFR2) and disable an other tone of the same group.
+PR-2469: Check missing for Extended tone detection
+PR-2457 : Tone events sometimes not generated
+PR-2473 : F003_FPGA: ulPlcScnOperationMode not behaving properly in
+ Oct6100ModifyChannel
+PR-2474 : F003_FPGA: PLC/SCN FPGA law configuration bug.
+PR-2475 : F003_FPGA: Channel Modify for the PLC/SCN is not working
+PR-2477 : Law conversion should work when ADPCM is not supported
+PR-2501 : F003_FPGA: Law written in the PLC/SCN FPGA not correct
+PR-2512 : Error cOCT6100_ERR_CONF_BRIDGE_CHAN_NOT_ON_BRIDGE sometimes returned
+ when removing all channels from a bridge with taps.
+PR-2513 : Eliminate the compiler warnings.
+PR-2514 : F029_FPGA: Wrong TDM mapping.
+PR-2516 : cOCT6100_ERR_OPEN_EGO_TIMEOUT generated on some devices
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2515 : Mute mode that allows tone detection on SIN is not working.
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR24
+
+Date: July 16, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+None
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2452 : Added SS7 tone events capture before tone detection enabling
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2392 : In Oct6100ChannelModify, Adpcm resource not reserve when
+ ulEncoderPort or ulDecoderPort set to Keep previous.
+PR-2421 : F029_FPGA: The calcul of TSST for Tone Detect FPGA is not corect in
+ the function OCT6100ApiWriteToneDetectEvent
+PR-2441 : F029_FPGA: Using wrong addresses in oct6100_interrupts.c
+PR-2442 : F029_FPGA: The SOct6100InterruptServiceRoutine doesn't clear the bit
+ ToneDetectionFpgaOverflowToneEvents.
+PR-2453 : F029_FPGA: Syntaxe bug: In the oct6100_events.c file, at the line 815
+ and the line 990.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2439 : Noise when no input TSST assigned
+PR-2440 : Conference signal attenuated when no input TSST
+PR-2454 : F029_FPGA: For MFR1 and MFR2, we can enable a tone OF MFR1 group
+ (or MFR2) and disable an other tone of the same group.
+PR-2457 : Tone events sometimes not generated
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR23
+
+Date: June 23, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+None
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2393 : Removed requirement for setting ulRinStream and ulRinTimeslot to
+ cOCT6100_UNASSIGNED for the tapping feature
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2394 : Error if doing remove all bridge participants but no participant
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+None
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR22
+
+Date: June 21, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 PRODUCTS OCT6110 and OCT6120
+
+ Modified function: Oct6100ConfBridgeChanAdd
+ Added parameter: ulTappedChannelHndl
+ Modified function: Oct6100ConfBridgeGetStats
+ Added parameter: ulNumTappedChannels
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2381 : Added tapping feature to simple conferencing.
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2378 : pulPlayoutFreeMemSize not completly accurate
+PR-2385 : When opening many flexible conferences we get an access violation
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+none
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR21
+
+Date: June 15, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameter: fDominantSpeaker
+ Modified function: Oct6100ChannelGetStats
+ Added parameters: sRinAppliedGain
+ sSoutAppliedGain
+
+ 1.2 PRODUCTS OCT6110 and OCT6120
+
+ Added functions: Oct6100ConfBridgeDominantSpeakerSetDef,
+ Oct6100ConfBridgeDominantSpeakerSet
+ Modified function: Oct6100ChipOpen
+ Added parameter: ulMaxFlexibleConfParticipants
+ Modified function: Oct6100ConfBridgeOpen
+ Added parameter: fFlexibleConferencing
+ Modified function: Oct6100ConfBridgeChanAdd
+ Added parameters: ulListenerMask,
+ ulListenerMaskIndex
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameters: fSoutAdaptiveNoiseReduction,
+ fSoutConferencingNoiseReduction,
+ fDtmfToneRemoval
+ Modified function: Oct6100ChannelGetStats
+ Added parameter: fSinVoiceDetected
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2368 : OCT6116 and OCT6126 features must not be removed from the API
+PR-2369 : Added fDominantSpeaker parameter in GetImageInfo function
+PR-2372 : Added lRinAppliedGain and lSoutAppliedGain stats in ChannelGetStats
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2356 : Playout never stop if repeat infinitly and stop clean is used with
+ buffer not modulo 64
+PR-2370 : No error returned when enabling dominant speaker while not available
+PR-2374 : Error returned when unmuting from flexible conference
+PR-2375 : Problem when unmuting the first participant of a flexible bridge
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2378 : pulPlayoutFreeMemSize not completly accurate
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-2379 : Problem with the cOCT6100_MIXING_0_DB mode
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR20
+
+Date: June 02, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameters: fHighLevelCompensation,
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameters: fRinAutomaticLevelControl,
+ lRinAutomaticLevelControlTargetDb
+ fSoutAutomaticLevelControl,
+ lSoutAutomaticLevelControlTargetDb
+ fRinHighLevelCompensation,
+ lRinHighLevelCompensationThresholdDb
+
+ 1.2 PRODUCTS OCT6116 and OCT6126
+
+ Added function: Oct6100ConfBridgeMaskChange
+ Modified function: Oct6100ConfBridgeGetStats
+ Added parameter: fFlexibleConferencing
+ Modified function: Oct6100ChannelGetStats
+ Added parameter: fSinVoiceDetected
+
+ 1.3 PRODUCTS OCT6110 and OCT6120
+
+ Removed functions: Oct6100ConfBridgeDominantSpeakerSetDef,
+ Oct6100ConfBridgeDominantSpeakerSet
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Removed parameter: fSoutConferencingNoiseReduction
+ Modified function: Oct6100ChipOpen
+ Removed parameter: ulMaxFlexibleConfParticipants
+ Modified function: Oct6100ConfBridgeOpen
+ Removed parameter: fFlexibleConferencing
+ Modified function: Oct6100ConfBridgeChanAdd
+ Removed parameters: ulListenerMask,
+ ulListenerMaskIndex
+
+ 1.4 PRODUCTS OCT6100, OCT6110 and OCT6120
+
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Removed parameter: fDtmfToneRemoval
+
+ 1.5 PRODUCTS OCT611X and OCT612X
+
+ Modified function: Oct6100BufferPlayoutAdd
+ Added parameter: lGainDb
+ Modified function: Oct6100BufferPlayoutStop
+ Added parameters: pfAlreadyStopped,
+ pfNotifyOnPlayoutStop
+
+ 1.6 Many error code names have been modified
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-1911 : Increased number of buffer playout from 31 to 127
+PR-2225 : Added support of gain control on buffer playout
+PR-2261 : Improved the CPU register BIST
+PR-2285 : Renamed cOCT6100_ECHO_OP_MODE_G169_ALC as cOCT6100_ECHO_OP_MODE_NO_VQE
+PR-2322 : Renamed cOCT6100_ECHO_OP_MODE_NO_VQE as cOCT6100_ECHO_OP_MODE_NO_ECHO
+PR-2289 : Added support of mixing mode 0db in playout
+PR-2310 : Implemented new conference bridge function to change the participant's
+ mask for flexible conferencing
+PR-2314 : Implemented fSinVoiceDetected in channel stats for OCT61x6 products
+PR-2316 : Implemented Automatic level control
+PR-2317 : Implemented High Level Compensation
+PR-2318 : Changed all feature_unsupported error coded to use the same error base
+ code
+PR-2328 : Added pfAlreadyStopped and pfNotifyOnPlayoutStop parameters to
+ Oct6100BufferPlayoutStop function
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2251 : Playout not always stopping when changing mode from normal to power
+ down to normal
+PR-2256 : Flexible conferencing does not work on the ROUT port
+PR-2267 : Removing a muted channel from a flexible conference gives a fatal
+ error
+PR-2268 : Can add two channels with the same index in flexible conferencing
+PR-2280 : Remove all feature is causing bridge corruption
+PR-2301 : Memory chip size of 8 megabytes must be allowed with SDR
+PR-2307 : Remote client not working with OCT610x products
+PR-2312 : fFlexibleConferencing is not implemented in function
+ Oct6100ConfBridgeGetStats
+PR-2332 : Dominant speaker always active
+PR-2333 : Muting all participants of a bridge is causing bad behaviors
+PR-2335 : Buffer Playout duration not working properly
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR19
+
+Date: April 30, 2004
+
+-------------------------------------------------------------------------------
+Please note that caller ID is still not supported.
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameter: ulMaxChannels
+ Removed parameters: fRinDcOffsetRemoval,
+ fSinDcOffsetRemoval,
+ fNlpControl,
+ fToneDisabler,
+ fComfortNoise
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameters: lAecDefaultErlDb
+
+ 1.2 PRODUCTS OCT611X and OCT612X
+
+ Modified function: Oct6100ChipOpen
+ Added parameter: ulMaxFlexibleConfParticipants
+ Modified function: Oct6100ConfBridgeOpen
+ Added parameter: fFlexibleConferencing
+ Modified function: Oct6100ConfBridgeChanAdd
+ Added parameters: ulListenerMask,
+ ulListenerMaskIndex
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-1909 : Add support of flexible conferencing feature
+PR-2226 : Remove unnecessary parameters from image info and add ulMaxChannel
+ parameter
+PR-2238 : Playout no longer supported in HT freeze mode
+PR-2237 : Improvements to AEC
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2224 : Playout not working in G.169 ALC Mode
+PR-2241 : F029_FPGA: Wrong TDM mapping.
+PR-2242 : F029_FPGA: ulUserChipId should be between 1 and 6 instead of 0 and 5.
+PR-2243 : F029_FPGA: Tone FPGA memory mapping has changed. Base addresses have
+ changed.
+PR-2244 : PLI Comment in API code
+PR-2250 : Bridge empty list causing fatal errors
+PR-2252 : F029_FPGA: F029 FPGA should not be accessed when not enabled.
+PR-2257 : F003_FPGA: Open channel does not set all SCN-PLC fields.
+PR-2259 : Buffer playout minimum buffer size can be downsized to 64 bytes.
+PR-2260 : memcpy should not be used in OctApi llman library.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2256 : Flexible conferencing does not work on the ROUT port
+PR-2251 : Playout not always stopping when changing mode to power down
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR18
+
+Date: April 22, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 PRODUCTS OCT611X and OCT612X
+
+ Added files: oct6100_caller_id.c
+ oct6100_caller_id_priv.h
+ oct6100_caller_id_pub.h
+ oct6100_caller_id_inst.h
+ Added functions: Oct6100CallerIdInitDef,
+ Oct6100CallerIdInit,
+ Oct6100CallerIdTransmitDef,
+ Oct6100CallerIdTransmit,
+ Oct6100CallerIdTransmitAsDef,
+ Oct6100CallerIdTransmitAs,
+ Oct6100CallerIdAbortDef,
+ Oct6100CallerIdAbort
+ Modified function: Oct6100ChipOpen
+ Added parameter: fEnableCallerId
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameter: fSoutConferencingNoiseReduction
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-1964 : Implement caller ID. Please note that this features is not supported
+ yet but files have been added to the API.
+PR-2206 : Allow support of both noise reduction features.
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2221 : 32 first bytes sometimes corrupted with buffer playout
+PR-2222 : Error when removing a channel from a RIN bridge
+PR-2223 : F003_FPGA: SCN/PLC requires a parameter to disable HDLC output
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR17
+
+Date: April 20, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 PRODUCT OCT610X
+
+ Added files: oct6100_tsi_cnct.c,
+ oct6100_tsi_cnct_priv.h
+ oct6100_tsi_cnct_pub.h
+ oct6100_tsi_cnct_inst.h
+ Added functions: Oct6100TsiCnctOpenDef,
+ Oct6100TsiCnctOpen,
+ Oct6100TsiCnctCloseDef,
+ Oct6100TsiCnctClose
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2207 : Need to reduce the API code size and the API instance size
+PR-2208 : TSI connection functions should be available to OCT610x products
+PR-2217 : F029_FPGA: OCTF029 API code needs modifications to support MFR2
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2202 : Chariot interval wrong for chips with 512 channels
+PR-2210 : Modification of the per channel tail displacement is not working
+PR-2214 : Debug channel corrupted when opening too many channels
+PR-2215 : Acoustic echo not working properly
+PR-2218 : Oct6100ApiReserveBufferPlayoutMemory sometimes returns
+ cOCT6100_ERR_BUFFER_PLAYOUT_NO_MEMORY but there are still a lot of
+ memory available.
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR16
+
+Date: April 16, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Added functions: Oct6100FreeResourcesDef,
+ Oct6100FreeResources
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameter: ulTailDisplacement
+ Modified functions: Oct6100ChipGetImageInfo
+ Added parameter: fPerChannelTailDisplacement
+
+ 1.2 PRODUCT OCT611X and OCT612X
+
+ Modified function: Oct6100BufferPlayoutAdd
+ Added parameters: ulRepeatCount,
+ ulDuration
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2160 : Add ulRepeatCount and ulDuration to the Oct6100BufferPlayoutAdd
+ function
+PR-2166 : Need to add function that closes all open channels and frees all used
+ ressources.
+PR-2172 : Add support of the tail displacement lentgh per channel
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2190 : Cleanup old extra code.
+PR-2191 : Image info parameters are confusing for level control
+PR-2205 : Phasing error when reusing same TSST
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-2210 : Modification of the per channel tail displacement is not working
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR15
+
+Date: April 02, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 PRODUCT OCT611X and OCT612X
+
+ Modified function: Oct6100BufferPlayoutLoad
+ Added parameter: pusBufferPattern
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2075 : Increase number of TSI connections supported
+PR-2113 : Current malloc function is too slow for playout buffer loading.
+PR-2115 : CPU bandwidth too small when loading buffers
+PR-2120 : Buffer playout copies PUINT8 array into PUINT16 array. Inefficient.
+PR-2149 : F029_FPGA: Add API code to support new OCTF029 tone detection FPGA.
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-1972 : Memory allocation is causing fragmentation when loading buffers
+PR-2093 : Oct6100ChipOpen should return an error when the firmware image loaded
+ requires more external memory then the user specified.
+PR-2123 : Create Bi-dir bad behavior when ulMaxBiDirChannels=0
+PR-2128 : ImageInfo.fAcousticEcho return TRUE even when not supported
+PR-2129 : Wrong TSST released in 16MHz mode. Causing fatal_55
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR14
+
+Date: March 19, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2088 : Change value written into hardware for ulNonLinearityBehaviorA of 0
+PR-2117 : Mem Refresh too fast
+
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-1972 : Memory allocation is causing fragmentation when loading buffers
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR13
+
+Date: March 03, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified function: Oct6100InterruptServiceRoutine
+ Added parameter: ulFatalGeneralFlags
+ Modified function: Oct6100ChannelGetStats
+ Added parameter: fEchoCancellerConverged
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-2016 : Add new ISR parameter to get info about fatal errors
+PR-2027 : Increase the number of supported TSI connections
+PR-2034 : Buffer Playout no more supported if NLP OFF
+PR-2035 : Implement fEchoCancellerConverged channel stats
+PR-2041 : ulMaxRwAccesses smaller than 8 should be valid
+PR-2049 : Create smaller API with less supported functions
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-2018 : Timestamps checks not good
+PR-2031 : Unset of the dominant speaker is causing a fatal error
+PR-2038 : AF CPU Timeout delay too small
+PR-2039 : Tone Disabler stays active when channel is closed
+PR-2040 : F003_FPGA: PLC FPGA channel energy not set properly.
+PR-2051 : Remove all conference participants is not working properly
+PR-2065 : ulSoftOverflowBufferPlayoutEventsCount not initialized
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-1972 : Memory allocation is causing fragmentation when loading buffers
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR12
+
+Date: Feb. 09, 2004
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Added function: Oct6100UserSleep
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameter: ulNonLinearityBehaviorB
+
+ 1.2 PRODUCT OCT611X and OCT612X
+
+ Added functions: Oct6100BufferPlayoutGetEventDef,
+ Oct6100BufferPlayoutGetEvent,
+ Oct6100BufferPlayoutLoadBlockInitDef,
+ Oct6100BufferPlayoutLoadBlockInit,
+ Oct6100BufferPlayoutLoadBlockDef,
+ Oct6100BufferPlayoutLoadBlock,
+ Oct6100ConfBridgeDominantSpeakerSetDef,
+ Oct6100ConfBridgeDominantSpeakerSet
+
+ Modified function: Oct6100ChipOpen
+ Added parameter: ulSoftBufferPlayoutEventsBufSize
+ Modified function: Oct6100ChipGetStats
+ Added parameters: ulPlayoutFreeMemSize,
+ ulSoftOverflowBufferPlayoutEventsCount
+ Modified function: Oct6100BufferPlayoutLoad
+ Added parameter: pulPlayoutFreeMemSize
+ Modified function: Oct6100BufferPlayoutAdd
+ Added parameter: ulBufferLength
+ Modified function: Oct6100BufferPlayoutStart
+ Added parameters: fNotifyOnPlayoutStop,
+ ulUserEventId,
+ fAllowStartWhileActive
+ Modified function: Oct6100InterruptServiceRoutine
+ Added parameter: fBufferPlayoutEventsPending
+ Modified function: Oct6100ConfBridgeChanAdd
+ Added parameter: ulInputPort
+ Modified function: Oct6100ToneDetectionDisable
+ Added parameter: fDisableAll
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-1870 : Implement ulNonLinearityBehaviorB in Oct6100ChannelOpen
+PR-1896 : Give size of memory available for buffer playout to the user
+PR-1908 : Add support of conferencing on RIN ports
+PR-1910 : Add new functions to allow loading of the buffer playout in multiple
+ blocks
+PR-1912 : Add new parameter to specify the length of the buffer that must be
+ played
+PR-1931 : Fatal error cOCT6100_ERR_FATAL_14 should be replaced by
+ cOCT6100_ERR_OPEN_INVALID_FIRMWARE_OR_CAPACITY_PINS
+PR-1942 : Implement End of Playout Event in the API
+PR-1946 : Add TLV fields for buffer playout enable and dominant conference
+ speaker.
+PR-1953 : Implement the dominant speaker feature for conferencing.
+PR-1970 : Add UserSleep function in the API
+PR-1990 : Add support of acoustic echo cancellation
+PR-1991 : Add disabling of all tone detection with one command
+PR-1996 : F003_FPGA: Add parameter to set the SCN/PLC operation mode
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-1872 : Law conversion not working for OCT610X and OCT611X products
+PR-1882 : F003_FPGA: Tsst configuration not correct in SCN/PLC
+PR-1886 : Buffer Playout size must be limited to modulo 16
+PR-1887 : F003_FPGA: Precedence Bug with SCN/PLC
+PR-1897 : F003_FPGA: Tsst Phasing mapping bug with SCN/PLC
+PR-1915 : Write Access Errors in external memories
+PR-1917 : API spec does not match API code with respect to the buffer playout
+ load function.
+PR-1919 : Playout pointers not reset properly in Oct6100ChannelOpen
+PR-1920 : Too many reads done in the buffer playout functions
+PR-1926 : F003_FPGA: User must specified the compression rate when using the
+ PLC/SCN FPGA.
+PR-1941 : The API must not allowed ulMaxChannels to be greater than the
+ capacity of the chip
+PR-1952 : ANR enable check not good
+PR-1969 : ulFirstEmptyIndex not set properly in Oct6100ApiRetrieveNlpConfDword.
+PR-1976 : fToneEventsPending not working
+PR-1980 : Tone Event Overflow may cause error cOCT6100_ERR_FATAL_2D
+PR-1981 : Capacity pins are not always in tri-state
+PR-1982 : Bidirectionnal channels in a conference erroneously permitted, and
+ vice versa.
+PR-2001 : F003_FPGA: fEnableScnPlcFpga check not good
+PR-2006 : Internal memory register not set properly
+PR-2012 : Customer ID no more used and replaced by Build ID
+PR-2015 : Channel 0 corruption when closing/opening other channels
+PR-2021 : TSI index for closed channels are not good
+PR-2022 : Conversion structures not cleared properly
+PR-2023 : NLP structure not cleared when closing a channel
+PR-2024 : F003_FPGA: Phase type for SCN_PLC not set properly
+PR-2025 : Channel resources closure order not good
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+NONE
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-1972 : Memory allocation is causing fragmentation when loading buffers
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+ RELEASE NOTES
+
+Version: OCT6100API-01.00-PR11
+
+Date: Dec. 09, 2003
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+1.0 BACKWARD COMPATIBILITY NOTICE
+
+ 1.1 ALL PRODUCTS
+
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Added parameters: lDefaultErlDb,
+ fDtmfToneRemoval,
+ fAcousticEcho,
+ ulNonLinearityBehaviorA,
+ Modified function: Oct6100ChipGetImageInfo
+ Added parameter: ulNumToneDetectors
+ Removed functions: Oct6100DebugGetRecordInfo,
+ Oct6100DebugGetEvent
+ Oct6100DebugSelectDebugChannel
+
+ 1.2 PRODUCTS OCT611X and OCT612X
+
+ Modified function: Oct6100ChipOpen
+ Added parameter: fEnableExtToneDetection
+ Modified functions: Oct6100ChannelOpen,
+ Oct6100ChannelModify,
+ Oct6100ChannelGetStats
+ Removed parameter: ulTailLength
+ Added parameter: fEnableExtToneDetection
+
+-------------------------------------------------------------------------------
+
+2.0 MODIFICATIONS DONE SINCE LAST RELEASE
+
+PR-1704 : Add detection of the 1100Hz tone
+PR-1716 : Replace all cOCT6100_TONE_REFRESH ulEventType by
+ cOCT6100_TONE_PRESENT in Oct6100EventGetTone
+PR-1719 : Implement lDefaultErlDb, fDtmfToneRemoval, ulNonLinearityBehaviorA
+ and fAcousticEcho in Oct6100ChannelOpen
+PR-1745 : Add ulNumToneDetectors parameter to Oct6100ChipGetImageInfo
+PR-1795 : Add new extended Tone detection mode when opening a channel.
+PR-1797 : Remove Oct6100DebugSelectDebugChannel, Oct6100DebugGetEvent,
+ Oct6100DebugGetRecordInfo functions
+PR-1798 : Give access to the remote debug functions
+PR-1868 : The parameter ulTailLength must be removed from Oct6100ChannelOpen
+ since it is not supported
+
+-------------------------------------------------------------------------------
+
+3.0 BUGS FIXED IN THIS RELEASE
+
+PR-1707 : Misc errors found during the code inspection
+PR-1713 : The Oct6100ChipOpen function must limit ulMaxConfBridges to 448
+PR-1720 : The ulTimestamp parameter is not set properly in Oct6100EventGetTone
+PR-1724 : The output data is not good when there is no input
+PR-1729 : Multiple calls to Oct6100ConfBridgeChanAdd with the same
+ ulChannelHndl must return an error
+PR-1730 : Wrong defaults values for ulMaxConfBridges, ulMaxPlayoutBuffers and
+ ulMaxPhasingTssts in Oct6100ChipOpen
+PR-1731 : Oct6100ConfBridgeClose does not release all resources
+PR-1732 : Oct6100ConfBridgeChanRemove does not release all ressources.
+PR-1733 : Not all read burst accesses are using the ulMaxRwAccesses parameter
+PR-1734 : Wrong check on ulEncoderPort in Oct6100ChannelOpen
+PR-1736 : Wrong check on ulPhasingTsstHndl in Oct6100ChannelModify
+PR-1741 : The Oct6100InterruptServiceRoutine should report an error when the
+ device reset
+PR-1742 : Default values for fSinDcOffsetRemoval, fRinDcOffsetRemoval and
+ ulComfortNoiseMode in Oct6100ChannelOpen are not correct
+PR-1743 : Stats not correct when fResetChipStats=TRUE in Oct6100ChipGetStats
+PR-1744 : ulMaxTailDisplacement is not set properly in Oct6100ChipGetImageInfo
+PR-1748 : Call to Oct6100ChannelClose is causing a failure of the conferencing
+ feature
+PR-1749 : The API must return an error if fEnableNlp=FALSE and
+ fEnableSilenceSuppression=TRUE
+PR-1751 : The interrupt scheduling is not accurate in
+ Oct6100InterruptServiceRoutine
+PR-1752 : Array used in function Oct6100ApiRandomMemoryWrite is too big for
+ certain compilers
+PR-1821 : Buffer Playout not working after a call to Oct6100ChannelModify
+PR-1871 : Code not compiling for OCT610X and OCT611X
+
+-------------------------------------------------------------------------------
+
+4.0 KNOWN BUGS PRESENT IN THIS RELEASE
+
+PR-1872 : Law conversion not working for OCT610X and OCT611X products
+
+-------------------------------------------------------------------------------
+
+5.0 KNOWN ISSUES PRESENT IN THIS RELEASE
+
+PR-1702: The user can call Oct6100BufferPlayoutUnload while the buffer is
+ playing
+
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
diff --git a/doc/oct612Xas5000-029.pdf b/doc/oct612Xas5000-029.pdf
new file mode 100644
index 0000000..34c28bf
--- /dev/null
+++ b/doc/oct612Xas5000-029.pdf
Binary files differ
diff --git a/software/apilib/bt/octapi_bt0.c b/software/apilib/bt/octapi_bt0.c
new file mode 100644
index 0000000..600eaac
--- /dev/null
+++ b/software/apilib/bt/octapi_bt0.c
@@ -0,0 +1,1179 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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"
+
+
+
+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);
+}
+
+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));
+}
+
+
+UINT32 OctApiBt0AddNode(void * b,void * key,void ** data)
+{
+ OCTAPI_BT0 * bb;
+ OCTAPI_BT0_NODE * new_node;
+ UINT32 * lkey;
+ UINT32 * nkey;
+ UINT32 i;
+ UINT32 new_node_number;
+ UINT32 result;
+
+ /* Load all!*/
+ bb = (OCTAPI_BT0 *)(b);
+ OctApiBt0CorrectPointers(bb);
+
+ /* Check that there is at least one block left.*/
+ if (bb->next_free_node == 0xFFFFFFFF) return(OCTAPI_BT0_NO_NODES_AVAILABLE);
+
+ /* Seize the node!*/
+ new_node_number = bb->next_free_node;
+ new_node = &(bb->node[new_node_number]);
+ bb->next_free_node = new_node->next_free_node;
+
+ /* Register in the key and the data.*/
+ lkey = ((UINT32 *)key);
+
+ /* Find the first UINT32 of the key.*/
+ nkey = &(bb->key[bb->key_size * new_node_number]);
+
+ /* Copy the key.*/
+ for(i=0;i<bb->key_size;i++)
+ nkey[i] = lkey[i];
+
+ /* Attempt to place the node. Only a "multiple hit" will cause an error.*/
+ result = OctApiBt0AddNode2(bb,&(bb->root_link), lkey, new_node_number);
+ if (result != GENERIC_OK)
+ {
+ /* This attempt failed. Refree the node!*/
+ bb->next_free_node = new_node_number;
+
+ /* Return the error code.*/
+ return(result);
+ }
+
+ /* Return the address of the data to the user.*/
+ if ( bb->data_size > 0 )
+ *data = (void *)(&(bb->data[bb->data_size * new_node_number]));
+
+ return(GENERIC_OK);
+}
+
+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);
+ }
+}
+
+
+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.*/
+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);
+ }
+}
+
+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.*/
+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);
+}
+
+
+/* State:*/
+/* 0 = seeking node to be removed.*/
+/* 1 = node found, left branch taken.*/
+/* 2 = node found, right branch taken.*/
+UINT32 OctApiBt0RemoveNode3(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 *p_prev_node_number )
+{
+ UINT32 result;
+ UINT32 *nkey;
+ UINT32 *okey;
+ 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.*/
+ {
+ /* Check if the key is the biggest 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 bigger then the old one, change the value.*/
+ if ( *nkey > *okey )
+ {
+ if ( *nkey < *lkey )
+ *p_prev_node_number = link->node_number;
+ }
+
+ 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.*/
+ {
+ /* Check if the key is the biggest 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 bigger then the old one, change the value.*/
+ if ( *nkey > *okey )
+ {
+ if ( *nkey < *lkey )
+ *p_prev_node_number = link->node_number;
+ }
+
+ 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
+ {
+ /* Check if the key is the biggest 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 bigger then the old one, change the value.*/
+ if ( *nkey > *okey )
+ {
+ if ( *nkey < *lkey )
+ *p_prev_node_number = link->node_number;
+ }
+
+ /* 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);
+}
+
+UINT32 OctApiBt0RemoveNode(void * b,void * key)
+{
+ OCTAPI_BT0 * bb;
+ UINT32 result;
+ UINT32 * lkey;
+
+ /* Load all!*/
+ bb = (OCTAPI_BT0 *)(b);
+ OctApiBt0CorrectPointers(bb);
+
+ /* Register in the key and the data.*/
+ lkey = ((UINT32 *)key);
+
+ /* Attempt to remove the node. Only a "no hit" will cause an error.*/
+ result = OctApiBt0RemoveNode2(bb,&(bb->root_link), lkey, NULL, 0, NULL);
+ if (result != GENERIC_OK) return(result);
+
+ return(GENERIC_OK);
+}
+
+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);
+}
+
+
+UINT32 OctApiBt0QueryNode(void * b,void * key,void ** data)
+{
+ OCTAPI_BT0 * bb;
+ UINT32 node_number;
+ UINT32 result;
+ UINT32 * lkey;
+
+ /* Load all!*/
+ bb = (OCTAPI_BT0 *)(b);
+ OctApiBt0CorrectPointers(bb);
+
+ /* Register in the key and the data.*/
+ lkey = ((UINT32 *)key);
+
+ /* Get the node number.*/
+ result = OctApiBt0QueryNode2(bb,&(bb->root_link),lkey,&node_number);
+ if (result != GENERIC_OK) return(result);
+
+ /* Return the address of the data to the user.*/
+ if ( bb->data_size > 0 )
+ *data = (void *)(&(bb->data[bb->data_size * node_number]));
+
+ return(GENERIC_OK);
+}
+
+UINT32 OctApiBt0GetFirstNode(void * b,void ** key, void ** data)
+{
+ OCTAPI_BT0 * bb;
+ OCTAPI_BT0_NODE * node;
+ UINT32 node_number;
+ UINT32 * lkey;
+
+ /* Load all!*/
+ bb = (OCTAPI_BT0 *)(b);
+ OctApiBt0CorrectPointers(bb);
+
+ /* Register in the key and the data.*/
+ lkey = ((UINT32 *)key);
+
+ /* Check if there are any keys present in the tree. */
+ if (bb->root_link.node_number == 0xFFFFFFFF) return OCTAPI_BT0_NO_NODES_AVAILABLE;
+
+ node_number = bb->root_link.node_number;
+ node = &bb->node[node_number];
+
+ /* Make our way down to the left-most node. */
+ while (node->l[0].node_number != 0xFFFFFFFF)
+ {
+ node_number = node->l[0].node_number;
+ node = &bb->node[node_number];
+ }
+
+ /* Return the address of the data to the user.*/
+ if ( bb->key_size > 0 )
+ *key = (void *)(&(bb->key[bb->key_size * node_number]));
+
+ if ( bb->data_size > 0 )
+ *data = (void *)(&(bb->data[bb->data_size * node_number]));
+
+ return(GENERIC_OK);
+}
+
+UINT32 OctApiBt0FindOrAddNode(void * b,void * key,void ** data, UINT32 *fnct_result)
+{
+ OCTAPI_BT0 * bb;
+ OCTAPI_BT0_NODE * new_node;
+ UINT32 * lkey;
+ UINT32 * nkey;
+ UINT32 i;
+ UINT32 new_node_number;
+ UINT32 temp_node_number = 0;
+ UINT32 result;
+ UINT32 tree_already_full = FALSE;
+
+ /* Load all!*/
+ bb = (OCTAPI_BT0 *)(b);
+ OctApiBt0CorrectPointers(bb);
+
+ /* Seize the node!*/
+ new_node_number = bb->next_free_node;
+ /* Register in the key and the data.*/
+ lkey = ((UINT32 *)key);
+
+ /* Check that there is at least one block left.*/
+ if (bb->next_free_node != 0xFFFFFFFF)
+ {
+
+ temp_node_number = new_node_number;
+ new_node = &(bb->node[new_node_number]);
+ bb->next_free_node = new_node->next_free_node;
+
+ /* Find the first UINT32 of the key.*/
+ nkey = &(bb->key[bb->key_size * new_node_number]);
+
+ /* Copy the key.*/
+ for(i=0;i<bb->key_size;i++)
+ nkey[i] = lkey[i];
+ }
+ else
+ tree_already_full = TRUE; /* Signal that the tree was already full when the function was called.*/
+
+ /* Attempt to place the node. Only a "multiple hit" will cause an error.*/
+ result = OctApiBt0AddNode3(bb,&(bb->root_link), lkey, &new_node_number);
+ switch( result )
+ {
+ case GENERIC_OK:
+ *fnct_result = OCTAPI0_BT0_NODE_ADDDED;
+ break;
+ case OCTAPI_BT0_KEY_ALREADY_IN_TREE:
+ *fnct_result = OCTAPI0_BT0_NODE_FOUND;
+ /* This attempt did not add a new node. Refree the node!*/
+ if ( tree_already_full == FALSE )
+ bb->next_free_node = temp_node_number;
+ result = GENERIC_OK;
+ break;
+ default:
+ break;
+ }
+
+ if (result != GENERIC_OK)
+ {
+ /* This attempt failed. Refree the node!*/
+ if ( tree_already_full == FALSE )
+ bb->next_free_node = new_node_number;
+
+ /* Return the error code.*/
+ return(result);
+ }
+
+ /* Return the address of the data to the user.*/
+ if ( bb->data_size > 0 )
+ *data = (void *)(&(bb->data[bb->data_size * new_node_number]));
+
+ return(GENERIC_OK);
+}
+
+
+UINT32 OctApiBt0AddNodeReportPrevNodeData(void * b,void * key,void ** data, void ** prev_data, PUINT32 fnct_result )
+{
+ OCTAPI_BT0 * bb;
+ OCTAPI_BT0_NODE * new_node;
+ UINT32 * lkey;
+ UINT32 * nkey;
+ UINT32 i;
+ UINT32 new_node_number;
+ UINT32 temp_node_number;
+ UINT32 prev_node_number;
+ UINT32 result;
+
+ /* Load all!*/
+ bb = (OCTAPI_BT0 *)(b);
+ OctApiBt0CorrectPointers(bb);
+
+ /* Check that there is at least one block left.*/
+ if (bb->next_free_node == 0xFFFFFFFF) return(OCTAPI_BT0_NO_NODES_AVAILABLE);
+
+ /* Seize the node!*/
+ new_node_number = bb->next_free_node;
+ temp_node_number = new_node_number;
+ new_node = &(bb->node[new_node_number]);
+ bb->next_free_node = new_node->next_free_node;
+
+ /* Set the previous node value */
+ prev_node_number = 0xFFFFFFFF;
+
+ /* Register in the key and the data.*/
+ lkey = ((UINT32 *)key);
+
+ /* Find the first UINT32 of the key.*/
+ nkey = &(bb->key[bb->key_size * new_node_number]);
+
+ /* Copy the key.*/
+ for(i=0;i<bb->key_size;i++)
+ nkey[i] = lkey[i];
+
+ /* Attempt to place the node. Only a "multiple hit" will cause an error.*/
+ result = OctApiBt0AddNode4(bb,&(bb->root_link), lkey, &new_node_number, &prev_node_number, 0);
+ switch( result )
+ {
+ case GENERIC_OK:
+ *fnct_result = OCTAPI0_BT0_NODE_ADDDED;
+ break;
+ case OCTAPI_BT0_KEY_ALREADY_IN_TREE:
+ *fnct_result = OCTAPI0_BT0_NODE_FOUND;
+ /* This attempt did not add a new node. Refree the node!*/
+ bb->next_free_node = temp_node_number;
+ result = GENERIC_OK;
+ break;
+ default:
+ break;
+ }
+
+ if (result != GENERIC_OK)
+ {
+ /* This attempt failed. Refree the node!*/
+ bb->next_free_node = new_node_number;
+
+ /* Return the error code.*/
+ return(result);
+ }
+
+ /* Return the address of the data to the user.*/
+ if ( bb->data_size > 0 )
+ *data = (void *)(&(bb->data[bb->data_size * new_node_number]));
+
+ if ( bb->data_size > 0 )
+ {
+ if ( (prev_node_number != 0xFFFFFFFF) &&
+ (prev_node_number != OCTAPI_BT0_NO_SMALLER_KEY) &&
+ (*fnct_result == OCTAPI0_BT0_NODE_ADDDED))
+ *prev_data = ( void* )(&(bb->data[bb->data_size * prev_node_number]));
+ else if ( prev_node_number == 0xFFFFFFFF )
+ *prev_data = ( void* )(&bb->invalid_value);
+ else if ( prev_node_number == OCTAPI_BT0_NO_SMALLER_KEY )
+ *prev_data = ( void* )(&bb->no_smaller_key);
+ }
+
+ return(GENERIC_OK);
+}
+
diff --git a/software/apilib/bt/octapi_bt0_private.h b/software/apilib/bt/octapi_bt0_private.h
new file mode 100644
index 0000000..feabb8e
--- /dev/null
+++ b/software/apilib/bt/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;
+
+void OctApiBt0CorrectPointers( OCTAPI_BT0 * bb );
+UINT32 OctApiBt0AddNode2( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link, UINT32 * lkey, UINT32 new_node_number );
+UINT32 OctApiBt0AddNode3( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link, UINT32 * lkey, UINT32 *p_new_node_number );
+UINT32 OctApiBt0AddNode4(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 *p_new_node_number, UINT32 *p_prev_node_number, UINT32 state );
+UINT32 OctApiBt0KeyCompare( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link, UINT32 * lkey );
+void OctApiBt0UpdateLinkDepth( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * link );
+void OctApiBt0Rebalance( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * root_link );
+void OctApiBt0ExternalHeavy( OCTAPI_BT0 * bb, OCTAPI_BT0_LINK * root_link );
+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/software/apilib/largmath/octapi_largmath.c b/software/apilib/largmath/octapi_largmath.c
new file mode 100644
index 0000000..c2823a3
--- /dev/null
+++ b/software/apilib/largmath/octapi_largmath.c
@@ -0,0 +1,612 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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"
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| 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).
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| 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).
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: OctApiLmCompare.
+|
+| Description: This function compares two numbers (arrays) of equal lengths.
+| Number a is (alen + 1) * 32 bits long; b is (blen + 1) * 32 bits long. The result
+|
+| -----------------------------------------------------------------------
+| | 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).
+| *neg USHORT Result of compare.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLmCompare(UINT32 * a,USHORT alen,UINT32 * bneg,USHORT blen,USHORT * neg)
+{
+ USHORT i;
+ UINT32 temp;
+ UINT32 carry=1;
+ UINT32 aprim;
+ UINT32 bprim;
+ UINT32 zlen;
+
+ /* Set zlen to alen or blen (which ever is longer)*/
+ if (alen < blen)
+ zlen = blen;
+ else
+ zlen = alen;
+
+ 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;
+ }
+
+ /* Check for overflow, which means negative number!*/
+ if (carry == 0)
+ {
+ *neg = TRUE;
+ return(GENERIC_OK);
+ }
+
+ /* Result is positive.*/
+ *neg = FALSE;
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLmSubtract.
+|
+| Description: This function multiplies 2 numbers, a and b. Number a and
+| b are both (ablen + 1) * 32 bits long. The result is twice as
+| long. If the functions succeeds if returns GENERIC_OK,
+| else GENERIC_ERROR.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *a UINT32 The array containing the first number.
+| *b UINT32 The array containing the second number.
+| ablen USHORT The length of arrays a and b, minus 1 (0 - 99).
+| *z UINT32 The array containing the resulting number.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLmMultiply(UINT32 * a,UINT32 * b,USHORT ablen,UINT32 * z)
+{
+ USHORT i,j,k;
+ USHORT nos;
+ UINT32 lownum;
+ UINT32 highnum;
+ USHORT longnumi;
+ USHORT longnumj;
+ USHORT indentw,indentl;
+
+
+ /* Caculate number of shorts in a and b.*/
+ nos = (USHORT)((ablen+1) * 2);
+
+ /* Clear answer word.*/
+ for(i=0;i<nos;i++)
+ *(z+i) = 0;
+
+ {
+ USHORT optimizea, optimizeb;
+ USHORT l;
+ optimizea = TRUE;
+ optimizeb = TRUE;
+ for(l = 1; l < ablen+1; l++)
+ {
+ if(*(a+l) != 0)
+ optimizea = FALSE;
+ if(*(b+l) != 0)
+ optimizeb = FALSE;
+ }
+ if(*a > OCTAPI_LM_MAX_OPTIMIZE_MUL)
+ optimizea = FALSE;
+ if(*b > OCTAPI_LM_MAX_OPTIMIZE_MUL)
+ optimizeb = FALSE;
+
+ if(optimizea == TRUE)
+ {
+ for(l = 0; l < *a; l++)
+ OctApiLmAdd(z, (USHORT)(nos-1), b, ablen, z, (USHORT)(nos-1));
+ return(GENERIC_OK);
+ }
+
+ if(optimizeb == TRUE)
+ {
+ for(l = 0; l < *b; l++)
+ OctApiLmAdd(z, (USHORT)(nos-1), a, ablen, z, (USHORT)(nos-1));
+ return(GENERIC_OK);
+ }
+ }
+
+ for(i=0;i<nos;i++)
+ {
+ longnumi = (USHORT)( i/2 );
+ /* One iteration per short in a.*/
+ if ((i%2) == 0)
+ lownum = *(a+longnumi) & 0xFFFF; /* Even word. Lower part of long.*/
+ else
+ lownum = *(a+longnumi)>>16; /* Odd word. Upper part of long.*/
+
+ for(j=0;j<nos;j++)
+ {
+ UINT32 product;
+
+ longnumj = (USHORT)( j/2 );
+ /* One iteration per short in a.*/
+ if ((j%2) == 0)
+ highnum = *(b+longnumj) & 0xFFFF; /* Even word. Lower part of long.*/
+ else
+ highnum = *(b+longnumj)>>16; /* Odd word. Upper part of long.*/
+
+ /* Find the word indent of the answer. 0 = no indent. 1 = one word indent.*/
+ indentw = (USHORT)( j+i );
+ indentl = (USHORT)( indentw / 2 );
+
+ /* Multiply both numbers.*/
+ product = highnum * lownum;
+
+ /* After multiplying both numbers, add result to end result.*/
+ if ((indentw % 2) == 0) /* Even word boundary, addition in one shot!*/
+ {
+ UINT32 carry=0;
+ UINT32 temp;
+ UINT32 addme;
+
+ for(k=indentl;k<nos;k++)
+ {
+ if (k==indentl) addme = product; else addme = 0;
+
+ temp = *(z+k) + addme + carry;
+
+ /* Calculate carry for next time.*/
+ if (carry == 0)
+ if (temp < addme) carry = 1; else carry = 0;
+ else
+ if (temp <= addme) carry = 1; else carry = 0;
+
+ /* Set value.*/
+ *(z+k) = temp;
+ }
+
+ /* Carry should always be 0.*/
+ if (carry == 1) return(GENERIC_ERROR);
+ }
+ else /* Odd word boundary, addition in two shots.*/
+ {
+ UINT32 carry=0;
+ UINT32 temp;
+ UINT32 addme;
+
+ for(k=indentl;k<nos;k++)
+ {
+ if (k==indentl) addme = product<<16;
+ else if (k==(indentl+1)) addme = product>>16;
+ else addme = 0;
+
+ temp = *(z+k) + addme + carry;
+
+ /* Calculate carry for next time.*/
+ if (carry == 0)
+ if (temp < addme) carry = 1; else carry = 0;
+ else
+ if (temp <= addme) carry = 1; else carry = 0;
+
+ /* Set value.*/
+ *(z+k) = temp;
+ }
+
+ /* Carry should always be 0.*/
+ if (carry == 1) return(GENERIC_ERROR);
+ }
+ }
+ }
+
+ return(GENERIC_OK);
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLmDivide.
+|
+| Description: This function divides the number n by the number d. The
+| quotient is placed in q and the remainder in r. The arrays
+| n, d, q and r are all of the same length, namely (ndqrlen + 1).
+| If the functions succeeds if returns GENERIC_OK, else
+| GENERIC_ERROR.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *a UINT32 The array containing the first number.
+| *b UINT32 The array containing the second number.
+| ablen USHORT The length of arrays a and b, minus 1 (0 - 99).
+| *z UINT32 The array containing the resulting number.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLmDivide(UINT32 * n,UINT32 * d,UINT32 * q,UINT32 * r,USHORT ndqrlen)
+{
+ /* Proceedure for division:*/
+ /* r = n*/
+ /* q = 0*/
+ /* shift = initial_denominator_shift (for upper '1's to be in same bit position).*/
+ /* d <<= shift;*/
+ /* Start loop:*/
+ /* compare r and d*/
+ /* if r > d then*/
+ /* r -= d;*/
+ /* write a '1' to bit "shift" of array q.*/
+ /* end if;*/
+ /* if shift == 0 then*/
+ /* return;*/
+ /* else*/
+ /* shift--;*/
+ /* d>>=1;*/
+ /* goto "Start loop:"*/
+ /* end if;*/
+
+ UINT32 i;
+ UINT32 result;
+ USHORT shift,n_msb,d_msb;
+ USHORT neg;
+ USHORT ConditionFlag = TRUE;
+
+ /* r = n*/
+ for(i=0;i<=ndqrlen;i++)
+ *(r+i) = *(n+i);
+
+ /* q = 0*/
+ for(i=0;i<=ndqrlen;i++)
+ *(q+i) = 0;
+
+ /* shift = initial_denominator_shift (for upper '1's to be in same bit position).*/
+ result = OctApiLmGetMsb(d,ndqrlen,&d_msb);
+ if (result != GENERIC_OK) return(result);
+
+ result = OctApiLmGetMsb(n,ndqrlen,&n_msb);
+ if (result != GENERIC_OK) return(result);
+
+ if (d_msb == 0xFFFF) /* Division by 0.*/
+ return(OCTAPI_LM_DIVISION_BY_ZERO);
+
+ if (n_msb == 0xFFFF) /* 0/n, returns 0 R 0.*/
+ return(GENERIC_OK);
+
+ if (n_msb < d_msb) /* x/y, where x is smaller than y, returns 0 R x.*/
+ return(GENERIC_OK);
+
+ shift = (USHORT)( n_msb - d_msb );
+
+ /* Shift d to match n highest bit position.*/
+ result = OctApiLmShiftn(d,ndqrlen,TRUE,shift);
+ if (result != GENERIC_OK) return(result);
+
+ /* Start loop:*/
+ while( ConditionFlag == TRUE )
+ {
+ /* compare r and d*/
+ result = OctApiLmCompare(r,ndqrlen,d,ndqrlen,&neg);
+ if (result != GENERIC_OK) return(result);
+
+ if (neg == FALSE) /* Subtraction can be done(do it).*/
+ {
+ /* r -= d;*/
+ result = OctApiLmSubtract(r,ndqrlen,d,ndqrlen,r,ndqrlen,&neg);
+ if (result != GENERIC_OK) return(result);
+
+ /* write a '1' to bit "shift" of array q.*/
+ *(q+(shift/32)) |= (UINT32)0x1 << (shift%32);
+ }
+
+ /* if shift == 0 then*/
+ /* return;*/
+ if (shift == 0) return(GENERIC_OK);
+
+ /* shift--;*/
+ /* d>>=1;*/
+ /* goto "Start loop:"*/
+ shift--;
+ OctApiLmShiftRight1(d,ndqrlen);
+ }
+
+ return(GENERIC_OK);
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: octapi_lm_shifright1.
+|
+| Description: The function is for internal use only.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| N/A.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLmShiftRight1(UINT32 * a,USHORT alen)
+{
+ UINT32 i;
+
+ /* Start with lower long and move up by one long each time,*/
+ /* shifting each long to the right by one bit. The upper bit*/
+ /* of the next long will have to be concatenated each time a*/
+ /* loop is executed. For the last long, leave the highest bit*/
+ /* intact.*/
+ for(i=0;i<alen;i++)
+ {
+ *(a+i)>>=1; /* Shift long by one to the right.*/
+ *(a+i)|=*(a+i+1)<<31;
+ }
+ *(a+alen)>>=1; /* Shift last long, leaving it's highest bit at 0.*/
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLmShiftn.
+|
+| Description: The function is for internal use only.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| N/A.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLmShiftn(UINT32 * a,USHORT alen,USHORT shiftleft,USHORT shiftn)
+{
+ UINT32 i;
+ USHORT long_offset;
+ USHORT bit_offset;
+
+ long_offset = (USHORT)( shiftn / 32 );
+ bit_offset = (USHORT)( shiftn % 32 );
+
+ if (shiftleft == TRUE) /* Shift left.*/
+ {
+ for(i=alen;i<=alen;i--)
+ {
+ /* Fill upper bits of long.*/
+ if (i >= long_offset)
+ *(a+i) = *(a+i-long_offset) << bit_offset;
+ else
+ *(a+i) = 0;
+
+ /* Fill lower bits of long.*/
+ if (i > long_offset && bit_offset != 0)
+ *(a+i) |= *(a+i-long_offset-1) >> (32-bit_offset);
+ }
+ }
+ else /* Shift right.*/
+ {
+ for(i=0;i<=alen;i++)
+ {
+ /* Fill lower bits of long.*/
+ if ((alen-i) >= long_offset)
+ *(a+i) = *(a+i+long_offset) >> bit_offset;
+ else
+ *(a+i) = 0;
+
+ /* Fill upper bits of long.*/
+ if ((alen-i) > long_offset && bit_offset != 0)
+ *(a+i) |= *(a+i+long_offset+1) << (32-bit_offset);
+
+ }
+ }
+
+ return(GENERIC_OK);
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLmGetMsb.
+|
+| Description: The function is for internal use only.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| N/A.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLmGetMsb(UINT32 * a,USHORT alen,USHORT * msb_pos)
+{
+ UINT32 i,j;
+ UINT32 x;
+
+ for(i=alen;i<=alen;i--)
+ {
+ if (*(a+i) == 0) continue;
+
+ x = *(a+i);
+ for(j=31;j<=31;j--)
+ {
+ /* Test for bit being '1'.*/
+ if ((x & 0x80000000) != 0)
+ {
+ *msb_pos=(USHORT)(j+(32*i));
+ return(GENERIC_OK);
+ }
+
+ /* Shift bit one bit position, and try again.*/
+ x<<=1;
+ }
+ }
+
+ /* MSB not found.*/
+ *msb_pos = 0xFFFF;
+
+ return(GENERIC_OK);
+}
diff --git a/software/apilib/llman/octapi_llman.c b/software/apilib/llman/octapi_llman.c
new file mode 100644
index 0000000..13c68eb
--- /dev/null
+++ b/software/apilib/llman/octapi_llman.c
@@ -0,0 +1,2715 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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);
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiTllmAllocGetSize.
+|
+| 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.
+|
+| This version is a time manage version of llman.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| number_of_items UINT32 The number of resources to be allocated.
+| *l_size UINT32 UINT32 The amount of memory needed, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiTllmAllocGetSize(UINT32 number_of_items,UINT32 * l_size)
+{
+ if (number_of_items == 0) return(GENERIC_BAD_PARAM);
+
+ *l_size = (sizeof(TLLM_ALLOC)) + (number_of_items * sizeof(TLLM_ALLOC_NODE));
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiTllmAllocInit.
+|
+| Description: This function intializes the TLLM_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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiTllmAllocInit(void ** l,UINT32 number_of_items)
+{
+ TLLM_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 = (TLLM_ALLOC *)(*l);
+ ls->linked_list = (TLLM_ALLOC_NODE *)((BYTE *)ls + sizeof(TLLM_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].value = i+1;
+ }
+
+ ls->linked_list[number_of_items - 1].value = 0xFFFFFFFF; /* Invalid link.*/
+
+ /* Next avail is 0.*/
+ ls->next_avail_num = 0;
+
+ /* Number of allocated items is null.*/
+ ls->allocated_items = 0;
+
+ /* Set the number of timeout entry.*/
+ ls->number_of_timeout = 0;
+
+ /* Next timeout is 0.*/
+ ls->next_timeout_num = 0xFFFFFFFF;
+ ls->last_timeout_num = 0xFFFFFFFF;
+
+ /* Set the known time to 0.*/
+ ls->last_known_time[ 0 ] = 0;
+ ls->last_known_time[ 1 ] = 0;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiTllmAllocInfo.
+|
+| Description: This function returns the number of free and allocated
+| block in the TLLMAN 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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiTllmAllocInfo(void * l,UINT32 * allocated_items,UINT32 * available_items)
+{
+ TLLM_ALLOC* ls;
+
+ /* Build the structure before starting.*/
+ ls = (TLLM_ALLOC *)l;
+ *allocated_items = ls->allocated_items;
+ *available_items = ls->number_of_items - ls->allocated_items;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiTllmAllocAlloc.
+|
+| 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.
+| *current_time UINT32
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiTllmAllocAlloc(void * l,UINT32 * blocknum, UINT32 *current_time)
+{
+ TLLM_ALLOC* ls;
+ UINT32 allocated_block;
+ TLLM_ALLOC_NODE* node;
+
+ /* Build the structure before starting.*/
+ ls = (TLLM_ALLOC *)l;
+ ls->linked_list = (TLLM_ALLOC_NODE *)((BYTE *)ls + sizeof(TLLM_ALLOC));
+
+ if ( ls->allocated_items == ls->number_of_items &&
+ ls->next_timeout_num != 0xFFFFFFFF )
+ {
+ UINT32 l_ulResult;
+ l_ulResult = OctApiTllmCheckTimeoutList( ls, current_time );
+ if ( l_ulResult != GENERIC_OK )
+ return l_ulResult;
+ }
+
+ /* 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->value;
+
+ /* Tag as used the current block number.*/
+ node->value = 0xFFFFFFFE;
+
+ /* Return proper block number.*/
+ *blocknum = allocated_block;
+
+ /* Update block usage number.*/
+ ls->allocated_items++;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiTllmAllocDealloc.
+|
+| 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.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiTllmAllocDealloc(void * l,UINT32 blocknum, UINT32 timeout_value, UINT32 current_time[2])
+{
+ TLLM_ALLOC* ls;
+ TLLM_ALLOC_NODE* node;
+ UINT32 l_ulResult;
+
+ /* Build the structure before starting.*/
+ ls = (TLLM_ALLOC *)l;
+ ls->linked_list = (TLLM_ALLOC_NODE *)((BYTE *)ls + sizeof(TLLM_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);
+
+ if ( ls->next_timeout_num != 0xFFFFFFFF )
+ {
+ l_ulResult = OctApiTllmCheckTimeoutList( ls, current_time );
+ if ( l_ulResult != GENERIC_OK )
+ return l_ulResult;
+ }
+
+ node = &ls->linked_list[blocknum];
+
+ /* Check if block is really used as of now.*/
+ if (node->value != 0xFFFFFFFE) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED);
+
+ /* Add link to timeout list.*/
+ if ( ls->last_timeout_num != 0xFFFFFFFF )
+ {
+ TLLM_ALLOC_NODE* last_node;
+
+ /* insert the node at the end of the list.*/
+ node->value = 0xFFFFFFFF;
+ last_node = &ls->linked_list[ ls->last_timeout_num ];
+ last_node->value = blocknum;
+ }
+ else
+ {
+ /* The node is alone in the list.*/
+ node->value = 0xFFFFFFFF;
+ ls->next_timeout_num = blocknum;
+ }
+
+ ls->last_timeout_num = blocknum;
+ ls->number_of_timeout++;
+
+ /* Set the timeout time of the node.*/
+ l_ulResult = OctApiLmAdd( current_time, 1, &timeout_value, 0, node->timeout, 1 );
+ if (l_ulResult != GENERIC_OK)
+ return(l_ulResult);
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiTllmCheckTimeoutList.
+|
+| Description: This function will verify if the timeout time
+| of all the node present in the timeout list are bigger
+| then the current time. If so the node will be returned
+| ot the free node list.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *ls TLLM_ALLOC The memory used by the TLLM_ALLOC structure.
+| current_time UINT32[2] The current time in msec.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiTllmCheckTimeoutList(TLLM_ALLOC *ls, UINT32 current_time[2])
+{
+ UINT32 result;
+ UINT32 fConditionFlag = TRUE;
+
+ /* Free-up any pending memory before trying the allocation:*/
+ if ((ls->last_known_time[0] != current_time[0] ||
+ ls->last_known_time[1] != current_time[1]) &&
+ (current_time[1] != 0 || current_time[0] != 0)) /* Time has changed.*/
+ {
+ TLLM_ALLOC_NODE *pcurrent_node;
+ UINT32 current_num;
+ USHORT neg;
+
+ /* Remember time for next time!*/
+ ls->last_known_time[0] = current_time[0];
+ ls->last_known_time[1] = current_time[1];
+
+
+ while ( fConditionFlag == TRUE )
+ {
+ /* Get a node from the timeout list.*/
+ pcurrent_node = &ls->linked_list[ ls->next_timeout_num ];
+ current_num = ls->next_timeout_num;
+
+ /* Check if first node has timeout.*/
+ result = OctApiLmCompare(current_time,1,pcurrent_node->timeout ,1,&neg);
+ if (result != GENERIC_OK) return(result);
+
+ /* if the timeout tiem was exceeded, set the block as free.*/
+ if ( neg == FALSE )
+ {
+ /* set the next node pointer.*/
+ ls->next_timeout_num = pcurrent_node->value;
+ ls->number_of_timeout--;
+
+ /* reset the last pointer of the timeout list.*/
+ if ( ls->number_of_timeout == 0 )
+ ls->last_timeout_num = 0xFFFFFFFF;
+
+ /* return the node the free list.*/
+ pcurrent_node->value = ls->next_avail_num;
+ ls->next_avail_num = current_num;
+ ls->allocated_items--;
+ }
+ else /* node not in timeout */
+ {
+ fConditionFlag = FALSE;
+ break;
+ }
+
+ if ( ls->next_timeout_num == 0xFFFFFFFF )
+ {
+ fConditionFlag = FALSE;
+ break; /* end of timeout list.*/
+ }
+ }
+ }
+
+ return(GENERIC_OK);
+}
+/**************************************** llm_alloc section **********************************************/
+
+
+
+
+
+
+
+/**************************************** llm_list section **********************************************/
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListGetSize
+|
+| Description: This function determines the amount of memory needed by
+| the LLM_LIST structure to manage the allocation of
+| number_of_items number of resources. The memory is
+| measured in bytes.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| number_of_items UINT32 The number of resources to be allocated
+| amongst all linked-lists.
+| number_of_lists UINT32 The maximum number of linked-lists that
+| can be allocated.
+| *l_size UINT32 UINT32 The amount of memory needed, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListGetSize(UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size,UINT32 * l_size)
+{
+ UINT32 head_alloc_size;
+ UINT32 result;
+ UINT32 user_info_size_roundup;
+
+ if (number_of_items == 0) return(GENERIC_BAD_PARAM);
+ if (number_of_lists == 0) return(GENERIC_BAD_PARAM);
+ if (user_info_size == 0) return(GENERIC_BAD_PARAM);
+
+ user_info_size_roundup = ((user_info_size + 3) / 4) * 4;
+
+ result = OctapiLlmAllocGetSize(number_of_lists,&head_alloc_size);
+ if(result != GENERIC_OK) return(result);
+
+ *l_size = sizeof(LLM_LIST) + (number_of_lists * sizeof(LLM_LIST_HEAD)) + head_alloc_size + (number_of_items * (sizeof(LLM_LIST_ITEM) + user_info_size_roundup - 4));
+
+ return(GENERIC_OK);
+}
+
+LLM_LIST_ITEM * OctApiLlmListGetItemPointer(LLM_LIST * ls, UINT32 item_number)
+{
+ return (LLM_LIST_ITEM *) (((BYTE *)ls->li) + (ls->item_size * item_number)) ;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListInit.
+|
+| Description: This function intializes the LLM_TALLOC structure.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| number_of_items UINT32 The number of resources to be allocated
+| amongst all linked-lists.
+| number_of_lists UINT32 The maximum number of linked-lists that
+| can be allocated.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListInit(void ** l,UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size)
+{
+ LLM_LIST* ls;
+ LLM_LIST_ITEM* item;
+ UINT32 i;
+ UINT32 head_alloc_size;
+ UINT32 result;
+ UINT32 user_info_size_roundup;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+
+
+ if (number_of_items == 0) return(GENERIC_BAD_PARAM);
+ if (number_of_lists == 0) return(GENERIC_BAD_PARAM);
+ if (user_info_size == 0) return(GENERIC_BAD_PARAM);
+
+ user_info_size_roundup = ((user_info_size + 3) / 4) * 4;
+
+ /* Get the size of the Alloc structure used to manage head of list structures.*/
+ result = OctapiLlmAllocGetSize(number_of_lists,&head_alloc_size);
+ if(result != GENERIC_OK) return(result);
+
+ if (*l == NULL) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED);
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)(*l);
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ /* Initialize parameters in the structure.*/
+ ls->head_alloc_size = head_alloc_size;
+ ls->user_info_bytes = user_info_size;
+ ls->user_info_size = user_info_size_roundup;
+ ls->total_items = number_of_items;
+ ls->assigned_items = 0;
+ ls->total_lists = number_of_lists;
+ ls->assigned_lists = 0;
+ ls->next_empty_item = 0;
+ ls->item_size = sizeof(LLM_LIST_ITEM) + user_info_size_roundup - 4;
+
+ /* Complete the build!*/
+ ls = (LLM_LIST *)(*l);
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ /* Initialize the head of queue Alloc structure.*/
+ result = OctapiLlmAllocInit(&(ls->list_head_alloc),number_of_lists);
+ if(result != GENERIC_OK) return(result);
+
+ /* Initialize the linked list of the items:*/
+ for(i=0; i<number_of_items; i++)
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * i);
+
+ if (i == (number_of_items - 1))
+ item->forward_link = 0xFFFFFFFF;
+ else
+ item->forward_link = i + 1;
+ }
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListInfo.
+|
+| Description: This function returns the status of the LLM_LIST structure.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| *allocated_lists UINT32 The number of linked_lists allocated.
+| *free_lists UINT32 The number of linked_lists still free.
+| *allocated_items UINT32 The number of items allocated to lists.
+| *free_items UINT32 The number of items still free.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListInfo(void * l,UINT32 * allocated_lists,UINT32 * allocated_items,
+ UINT32 * free_lists,UINT32 * free_items)
+{
+ LLM_LIST* ls;
+ BYTE* lsbyte;
+ UINT32 total_lists;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ *allocated_items = ls->assigned_items;
+ *free_items = ls->total_items - ls->assigned_items;
+
+ *allocated_lists = ls->assigned_lists;
+ *free_lists = ls->total_lists - ls->assigned_lists;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListCreate.
+|
+| Description: This function creates a linked list. The target which is
+| allocated the newly created list can request additions
+| or removals from the list later on. To target identifies
+| its list with the returned list handle.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| *list_handle UINT32 The handle to the new list, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListCreate(void * l,UINT32 * list_handle)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ UINT32 blocknum;
+ UINT32 total_lists;
+ UINT32 result;
+ BYTE* lsbyte;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ /* Get a list using the list head alloc structure.*/
+ result = OctapiLlmAllocAlloc(ls->list_head_alloc, &blocknum);
+ if (result != GENERIC_OK) return(result);
+
+ /* The handle is the block number.*/
+ *list_handle = blocknum;
+
+ /* Initialize the list head structure.*/
+ lh = &ls->lh[blocknum];
+ lh->list_length = 0;
+ lh->head_pointer = 0xFFFFFFFF;
+ lh->tail_pointer = 0xFFFFFFFF;
+ lh->cache_item_number = 0xFFFFFFFF;
+ lh->cache_item_pointer = 0xFFFFFFFF;
+
+ ls->assigned_lists++;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListDelete.
+|
+| Description: This function deletes the linked list indicated by the
+| handle list_handle. Any items which are still allocated
+| to the list are first deallocated.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| *list_handle UINT32 The handle to the list.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListDelete(void * l,UINT32 list_handle)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ UINT32 total_lists;
+ UINT32 result;
+ BYTE* lsbyte;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
+ if (ls->lh[list_handle].list_length == 0xFFFFFFFF) return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+
+ /* Release internal list header handle...*/
+ result = OctapiLlmAllocDealloc(ls->list_head_alloc,list_handle);
+ if (result != GENERIC_OK) return(result);
+
+ lh = &ls->lh[list_handle];
+
+ /* Deallocate all items in the list!*/
+ if (lh->list_length != 0)
+ {
+ LLM_LIST_ITEM * item;
+
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * lh->tail_pointer);
+
+ /* Release the items using only the links.*/
+ item->forward_link = ls->next_empty_item;
+ ls->next_empty_item = lh->head_pointer;
+
+ /* Remove items from item counter.*/
+ ls->assigned_items -= lh->list_length;
+ }
+
+ lh->list_length = 0xFFFFFFFF;
+ lh->head_pointer = 0xFFFFFFFF;
+ lh->tail_pointer = 0xFFFFFFFF;
+ lh->cache_item_number = 0xFFFFFFFF;
+ lh->cache_item_pointer = 0xFFFFFFFF;
+
+ ls->assigned_lists--;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListLength.
+|
+| Description: This function returns the number of items allocated to the
+| list indicated by the handle list_handle.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| list_handle UINT32 The handle to the list.
+| *number_of_items UINT32 The number of items in the list, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListLength(void * l,UINT32 list_handle, UINT32 * number_of_items_in_list)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
+ if (lh->list_length == 0xFFFFFFFF) return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+
+ *number_of_items_in_list = lh->list_length;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListItemData
+|
+| Description: This function returns a pointer to the user data associated
+| with an item.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| list_handle UINT32 The handle to the list.
+| item_number UINT32 The number of the list node in question.
+| **item_data_pnt void The pointer to the user data, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListItemData(void * l,UINT32 list_handle,UINT32 item_number,void ** item_data_pnt)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ LLM_LIST_ITEM* item;
+ UINT32 cur_list_pnt;
+ UINT32 cur_list_num;
+ UINT32 total_lists;
+ UINT32 list_length;
+ BYTE* lsbyte;
+ UINT32 fConditionFlag = TRUE;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+ list_length = lh->list_length;
+
+ *item_data_pnt = NULL;
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
+ if (list_length == 0xFFFFFFFF) return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+ if (list_length <= item_number) return(OCTAPI_LLM_ELEMENT_NOT_FOUND);
+
+ /* Determine where the search will start.*/
+ if (list_length == (item_number + 1)) /* Last item in list:*/
+ {
+ cur_list_pnt = lh->tail_pointer;
+ cur_list_num = item_number;
+ }
+ else if (lh->cache_item_number <= item_number) /* Start at cache:*/
+ {
+ cur_list_pnt = lh->cache_item_pointer;
+ cur_list_num = lh->cache_item_number;
+ }
+ else /* Start at beginning:*/
+ {
+ cur_list_pnt = lh->head_pointer;
+ cur_list_num = 0;
+ }
+
+ /* Start search from cur_list_pnt and cur_list_num.*/
+ while ( fConditionFlag == TRUE )
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+
+ if (cur_list_num == item_number) /* Item number found.*/
+ {
+ /* Write new cache entry.*/
+ lh->cache_item_pointer = cur_list_pnt;
+ lh->cache_item_number = cur_list_num;
+
+ /* Get item info.*/
+ *item_data_pnt = (void *)item->user_info;
+
+ return(GENERIC_OK);
+ }
+ else if(item->forward_link == 0xFFFFFFFF) /* End of list found?!?*/
+ {
+ return(OCTAPI_LLM_INTERNAL_ERROR0);
+ }
+ else /* Item was not found, but continue searching.*/
+ {
+ cur_list_pnt = item->forward_link;
+ }
+
+ cur_list_num++;
+ }
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListInsertItem.
+|
+| Description: This function allocates a node to the linked list specified
+| by the handle list_handle. The position of the new item
+| can be specified. A position of 0xFFFFFFFF means append to the
+| list( use the OCTAPI_LLM_LIST_APPEND define for clarity);
+| a position of 0 mean insert at the begining of the list.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| *list_handle UINT32 The handle to the list.
+| **item_data void Address of the user data space for this item.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListInsertItem(void * l,UINT32 list_handle,UINT32 item_number,void ** item_data_pnt)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ LLM_LIST_ITEM* free_item;
+ UINT32 free_item_pnt;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+ UINT32 fConditionFlag = TRUE;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+
+ *item_data_pnt = NULL;
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
+ if (lh->list_length == 0xFFFFFFFF) return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+ if (lh->list_length < item_number && item_number != 0xFFFFFFFF)
+ return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
+ if (ls->next_empty_item == 0xFFFFFFFF) return(OCTAPI_LLM_NO_STRUCTURES_LEFT);
+
+ /* Get a free item from the free item list!*/
+ free_item_pnt = ls->next_empty_item;
+ free_item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * free_item_pnt);
+ ls->next_empty_item = free_item->forward_link;
+
+ if (item_number == 0xFFFFFFFF)
+ item_number = lh->list_length;
+
+ if (lh->list_length == 0) /* First item and only item:*/
+ {
+ free_item->forward_link = 0xFFFFFFFF;
+ lh->tail_pointer = free_item_pnt;
+ lh->head_pointer = free_item_pnt;
+ }
+ else if (item_number == 0) /* First item and but list not empty:*/
+ {
+ free_item->forward_link = lh->head_pointer;
+ lh->head_pointer = free_item_pnt;
+ }
+ else if (item_number == lh->list_length) /* Append:*/
+ {
+ LLM_LIST_ITEM * last_item;
+ last_item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * lh->tail_pointer);
+
+ last_item->forward_link = free_item_pnt;
+ free_item->forward_link = 0xFFFFFFFF;
+ lh->tail_pointer = free_item_pnt;
+ }
+ else /* Insert:*/
+ {
+ LLM_LIST_ITEM * last_item = NULL;
+ LLM_LIST_ITEM * item;
+ UINT32 last_list_pnt;
+ UINT32 cur_list_pnt;
+ UINT32 cur_list_num;
+
+ if (lh->cache_item_number < item_number) /* Start at cache:*/
+ {
+ cur_list_pnt = lh->cache_item_pointer;
+ cur_list_num = lh->cache_item_number;
+ }
+ else /* Start at beginning:*/
+ {
+ cur_list_pnt = lh->head_pointer;
+ cur_list_num = 0;
+ }
+
+ last_list_pnt = 0xFFFFFFFF;
+
+ /* Start search from cur_list_pnt and cur_list_num.*/
+ while ( fConditionFlag == TRUE )
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+
+ if (cur_list_num == item_number) /* Item number found.*/
+ {
+ if (last_list_pnt == 0xFFFFFFFF) return(OCTAPI_LLM_INTERNAL_ERROR1);
+
+ free_item->forward_link = cur_list_pnt;
+ last_item->forward_link = free_item_pnt;
+
+ fConditionFlag = FALSE;
+ break;
+ }
+ else if (item->forward_link == 0xFFFFFFFF) /* End of list found?!?*/
+ {
+ return(OCTAPI_LLM_INTERNAL_ERROR0);
+ }
+ else /* Item was not found, but continue searching.*/
+ {
+ last_item = item;
+ last_list_pnt = cur_list_pnt;
+ cur_list_pnt = item->forward_link;
+ }
+
+ cur_list_num++;
+ }
+ }
+
+ /* Increase the list length.*/
+ lh->list_length++;
+ ls->assigned_items++;
+ *item_data_pnt = (void *)free_item->user_info;
+
+ /* Write new cache entry.*/
+ lh->cache_item_pointer = free_item_pnt;
+ lh->cache_item_number = item_number;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListCreateFull.
+|
+| Description: This function allocates the desired number of nodes to
+| the linked list specified by the handle list_handle.
+| The position of the new item can be specified. A
+| position of 0xFFFFFFFF means append to the list (use the
+| OCTAPI_LLM_LIST_APPEND define for clarity); a position
+| of 0 means insert at the begining of the list.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| *list_handle UINT32 The handle to the list.
+| **item_data void Address of the user data space for this item.
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListCreateFull(void* l, UINT32 list_length, UINT32* plist_handle)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ LLM_LIST_ITEM* free_item;
+ LLM_LIST_ITEM* last_item = NULL;
+ UINT32 free_item_pnt = 0xFFFFFFFF;
+ UINT32 total_lists;
+ UINT32 list_handle;
+ UINT32 list_length_m1;
+ UINT32 next_empty_item;
+ UINT32 result;
+ UINT32 i;
+ BYTE* lsbyte;
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Build the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Make sure another list can be created.*/
+ if (ls->assigned_lists == ls->total_lists)
+ return(OCTAPI_LLM_ELEMENT_ALREADY_ASSIGNED);
+
+ /* Make sure there are enough free nodes to fill the new list.*/
+ if (list_length > (ls->total_items - ls->assigned_items))
+ return(OCTAPI_LLM_ELEMENT_ALREADY_ASSIGNED);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Create list (i.e. get a list using the list head alloc structure.*/
+ result = OctapiLlmAllocAlloc(ls->list_head_alloc, &list_handle);
+ if (result != GENERIC_OK) return(result);
+
+ /* Initialize the list head structure.*/
+ lh = &ls->lh[list_handle];
+ lh->list_length = 0;
+ lh->head_pointer = 0xFFFFFFFF;
+ lh->tail_pointer = 0xFFFFFFFF;
+ lh->cache_item_number = 0xFFFFFFFF;
+ lh->cache_item_pointer = 0xFFFFFFFF;
+
+ ls->assigned_lists++;
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Add the number of requested nodes to the list.*/
+ lh = &ls->lh[list_handle];
+ list_length_m1 = list_length - 1;
+ next_empty_item = ls->next_empty_item;
+
+ for (i=0; i<list_length; i++)
+ {
+ /* Get a free item from the free item list!*/
+ free_item_pnt = next_empty_item;
+ free_item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * free_item_pnt);
+ next_empty_item = free_item->forward_link;
+
+ /* Branch according to whether the node is the first in list, last, or in
+ the middle.*/
+ if (i == 0)
+ {
+ /* First item.*/
+ free_item->forward_link = 0xFFFFFFFF;
+ lh->head_pointer = free_item_pnt;
+ lh->tail_pointer = free_item_pnt;
+ }
+ else if (i == list_length_m1)
+ {
+ /* Last item.*/
+ last_item->forward_link = free_item_pnt;
+ free_item->forward_link = 0xFFFFFFFF;
+ lh->tail_pointer = free_item_pnt;
+ }
+ else
+ {
+ /* Node somewhere in the middle.*/
+ last_item->forward_link = free_item_pnt;
+ }
+
+ /* Store pointer to free item as pointer to last item (for next iteration).*/
+ last_item = free_item;
+ }
+
+ /* Store new value of next_empty_item.*/
+ ls->next_empty_item = next_empty_item;
+
+ /* Write new cache entry.*/
+ lh->cache_item_pointer = free_item_pnt;
+ lh->cache_item_number = list_length_m1;
+
+ /* Set the list length.*/
+ lh->list_length = list_length;
+ ls->assigned_items += list_length;
+
+ /* Return pointer to new list.*/
+ *plist_handle = list_handle;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListAppendItems.
+|
+| Description: This function allocates the desired number of nodes to
+| the linked list specified by the handle list_handle.
+| The position of the new item can be specified. A
+| position of 0xFFFFFFFF means append to the list (use the
+| OCTAPI_LLM_LIST_APPEND define for clarity); a position
+| of 0 means insert at the begining of the list.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| *list_handle UINT32 The handle to the list.
+| **item_data void Address of the user data space for this item.
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListAppendItems(void* l, UINT32 list_handle, UINT32 num_items)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ LLM_LIST_ITEM* item_list;
+ LLM_LIST_ITEM* curr_item = NULL;
+ LLM_LIST_ITEM* free_item;
+ UINT32 curr_item_pnt = 0xFFFFFFFF;
+ UINT32 total_lists;
+ UINT32 next_empty_item;
+ UINT32 item_size;
+ UINT32 i;
+ BYTE* lsbyte;
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Build the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Make sure list handle is valid.*/
+ if (list_handle >= ls->total_lists)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+
+ /* Make sure there is at least one item.*/
+ if (num_items == 0)
+ return(OCTAPI_LLM_INVALID_PARAMETER);
+
+ /* Make sure there are enough free nodes.*/
+ if (num_items > (ls->total_items - ls->assigned_items))
+ return(OCTAPI_LLM_NO_STRUCTURES_LEFT);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Get pointer to list structure.*/
+ lh = &ls->lh[list_handle];
+ if (lh->list_length == 0xFFFFFFFF)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Add the number of requested nodes to the list.*/
+ item_list = ls->li;
+ item_size = ls->item_size;
+ next_empty_item = ls->next_empty_item;
+
+ for (i=0; i<num_items; i++)
+ {
+ if (i == 0)
+ {
+ if (lh->head_pointer == 0xFFFFFFFF)
+ {
+ /* Current and next items are one and the same!*/
+ curr_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * next_empty_item);
+
+ /* Set new head and tail pointers.*/
+ lh->head_pointer = next_empty_item;
+ lh->tail_pointer = next_empty_item;
+
+ /* Update current item pnt.*/
+ curr_item_pnt = next_empty_item;
+
+ /* Update next item.*/
+ next_empty_item = curr_item->forward_link;
+
+ /* Set first item to be only item in list.*/
+ curr_item->forward_link = 0xFFFFFFFF;
+ }
+ else
+ {
+ /* Get a free item from the free item list!*/
+ curr_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * lh->tail_pointer);
+ free_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * next_empty_item);
+
+ /* Have current item point to next empty item.*/
+ curr_item->forward_link = next_empty_item;
+
+ /* Update current item pnt.*/
+ curr_item_pnt = next_empty_item;
+
+ /* Update next_empty_item.*/
+ next_empty_item = free_item->forward_link;
+
+ /* Update pointers to current item and free item.*/
+ curr_item = free_item;
+ }
+ }
+ else
+ {
+ /* Update pointers to current item and free item.*/
+ free_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * next_empty_item);
+
+ /* Have current item point to next empty item.*/
+ curr_item->forward_link = next_empty_item;
+
+ /* Update current item pnt.*/
+ curr_item_pnt = next_empty_item;
+
+ /* Update next_empty_item.*/
+ next_empty_item = free_item->forward_link;
+
+ /* Update pointers to current item and free item.*/
+ curr_item = free_item;
+ }
+ }
+
+ /* Terminate list.*/
+ if ( curr_item != NULL )
+ curr_item->forward_link = 0xFFFFFFFF;
+
+ /* Update llman structure variables.*/
+ ls->next_empty_item = next_empty_item;
+ ls->assigned_items += num_items;
+
+ /* Update list variables.*/
+ lh->list_length += num_items;
+ lh->cache_item_pointer = curr_item_pnt;
+ lh->cache_item_number = lh->list_length - 1;
+ lh->tail_pointer = curr_item_pnt;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListAppendAndSetItems.
+|
+| Description:
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListAppendAndSetItems(void* l, UINT32 list_handle, UINT32 num_items, void* data_list)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ LLM_LIST_ITEM* item_list;
+ LLM_LIST_ITEM* curr_item = NULL;
+ LLM_LIST_ITEM* free_item;
+ UINT32 curr_item_pnt = 0xFFFFFFFF;
+ UINT32 total_lists;
+ UINT32 next_empty_item;
+ UINT32 user_info_bytes;
+ UINT32 item_size;
+ UINT32 i;
+ BYTE* lsbyte;
+ void* data_item;
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Build the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Make sure list handle is valid.*/
+ if (list_handle >= ls->total_lists)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+
+ /* Make sure there is at least one item.*/
+ if (num_items == 0)
+ return(OCTAPI_LLM_INVALID_PARAMETER);
+
+ /* Make sure there are enough free nodes.*/
+ if (num_items > (ls->total_items - ls->assigned_items))
+ return(OCTAPI_LLM_NO_STRUCTURES_LEFT);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Get pointer to list structure.*/
+ lh = &ls->lh[list_handle];
+ if (lh->list_length == 0xFFFFFFFF)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Add the number of requested nodes to the list.*/
+ item_list = ls->li;
+ user_info_bytes = ls->user_info_bytes;
+ item_size = ls->item_size;
+ next_empty_item = ls->next_empty_item;
+ data_item = data_list;
+
+ for (i=0; i<num_items; i++)
+ {
+ if (i == 0)
+ {
+ if (lh->head_pointer == 0xFFFFFFFF)
+ {
+ /* Current and next items are one and the same!*/
+ curr_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * next_empty_item);
+
+ /* Set new head and tail pointers.*/
+ lh->head_pointer = next_empty_item;
+ lh->tail_pointer = next_empty_item;
+
+ /* Update current item pnt.*/
+ curr_item_pnt = next_empty_item;
+
+ /* Update next item.*/
+ next_empty_item = curr_item->forward_link;
+
+ /* Set first item to be only item in list.*/
+ curr_item->forward_link = 0xFFFFFFFF;
+ }
+ else
+ {
+ /* Get a free item from the free item list!*/
+ curr_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * lh->tail_pointer);
+ free_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * next_empty_item);
+
+ /* Have current item point to next empty item.*/
+ curr_item->forward_link = next_empty_item;
+
+ /* Update current item pnt.*/
+ curr_item_pnt = next_empty_item;
+
+ /* Update next_empty_item.*/
+ next_empty_item = free_item->forward_link;
+
+ /* Update pointers to current item and free item.*/
+ curr_item = free_item;
+ }
+ }
+ else
+ {
+ /* Update pointers to current item and free item.*/
+ free_item = (LLM_LIST_ITEM *)((BYTE *)item_list + item_size * next_empty_item);
+
+ /* Have current item point to next empty item.*/
+ curr_item->forward_link = next_empty_item;
+
+ /* Update current item pnt.*/
+ curr_item_pnt = next_empty_item;
+
+ /* Update next_empty_item.*/
+ next_empty_item = free_item->forward_link;
+
+ /* Update pointers to current item and free item.*/
+ curr_item = free_item;
+ }
+
+ /* Copy data to new item.*/
+ OctApiLlmMemCpy(curr_item->user_info, data_item, user_info_bytes);
+
+ /* Update data_item pointer for next iteration (item).*/
+ data_item = (void *)((BYTE *)data_item + user_info_bytes);
+ }
+
+
+ /* Terminate list.*/
+ if ( curr_item != NULL )
+ curr_item->forward_link = 0xFFFFFFFF;
+
+ /* Update llman structure variables.*/
+ ls->next_empty_item = next_empty_item;
+ ls->assigned_items += num_items;
+
+ /* Update list variables.*/
+ lh->list_length += num_items;
+ lh->cache_item_pointer = curr_item_pnt;
+ lh->cache_item_number = lh->list_length - 1;
+ lh->tail_pointer = curr_item_pnt;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListSetItems.
+|
+| Description: This function takes a start entry (0 to length - 1),
+| a pointer to a list of data (each item of list is the
+| size of one data unit, specified at init), and the
+| length of the data list. From this, the data will be
+| copied from the data list to the linked list, from
+| entry start_entry to (start_entry + data_length - 1).
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListSetItems(void* l, UINT32 list_handle, UINT32 start_item, UINT32 data_length, void* pdata_list)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ LLM_LIST_ITEM* item = NULL;
+ UINT32 total_lists;
+ UINT32 item_pnt = 0xFFFFFFFF;
+ UINT32 i, j;
+ BYTE* lsbyte;
+ void* pdata_item = NULL;
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Build the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Make sure list handle is valid.*/
+ if (list_handle >= ls->total_lists)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+ lh = &ls->lh[list_handle];
+ if (lh->list_length == 0xFFFFFFFF)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+
+ /* Make sure the start_entry is within limits.*/
+ if (start_item >= lh->list_length)
+ return(OCTAPI_LLM_INVALID_PARAMETER);
+
+ /* Make sure the end_entry is within limits.*/
+ lh = &ls->lh[list_handle];
+ if ((start_item + data_length) > lh->list_length)
+ return(OCTAPI_LLM_INVALID_PARAMETER);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Set the data of each node.*/
+ for (i=0; i<data_length; i++)
+ {
+ /* Obtain pointer to current item.*/
+ if (i == 0)
+ {
+ /* Check if location of start item is already cached. If not, must search
+ for it manually.*/
+ if (start_item == (lh->cache_item_number + 1))
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * lh->cache_item_pointer);
+ item_pnt = item->forward_link;
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * item_pnt);
+ }
+ else
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * lh->head_pointer);
+ item_pnt = lh->head_pointer;
+ for (j=0; j<start_item; j++)
+ {
+ item_pnt = item->forward_link;
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * item_pnt);
+ }
+ }
+
+ pdata_item = (void *)((BYTE *)pdata_list + (i * ls->user_info_bytes));
+ }
+ else
+ {
+ item_pnt = item->forward_link;
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * item_pnt);
+
+ pdata_item = (void *)((BYTE *)pdata_item + ls->user_info_bytes);
+ }
+
+ /* Set the value of the item's user data.*/
+ OctApiLlmMemCpy(item->user_info, pdata_item, ls->user_info_bytes);
+ }
+
+ /* Write new cache entry.*/
+ lh->cache_item_pointer = item_pnt;
+ lh->cache_item_number = start_item + data_length - 1;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListCopyData.
+|
+| Description: This function takes a start entry (0 to length - 1),
+| a pointer to a list of data (each item of list is the
+| size of one data unit, specified at init), and the
+| length of the data list. From this, the data will be
+| copied from the linked list to the data list, from
+| entry start_entry of the linked list to
+| (start_entry + data_length - 1).
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListCopyData(void* l, UINT32 list_handle, UINT32 start_item, UINT32 data_length, void* pdata_list)
+{
+ LLM_LIST* ls;
+ LLM_LIST_HEAD* lh;
+ LLM_LIST_ITEM* item = NULL;
+ UINT32 item_pnt = 0xFFFFFFFF;
+ UINT32 total_lists;
+ UINT32 i, j;
+ BYTE* lsbyte;
+ void* pdata_item = NULL;
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Build the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Make sure list handle is valid.*/
+ if (list_handle >= ls->total_lists)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+ lh = &ls->lh[list_handle];
+ if (lh->list_length == 0xFFFFFFFF)
+ return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+
+ /* Make sure the start_entry is within limits.*/
+ if (start_item >= lh->list_length)
+ return(OCTAPI_LLM_INVALID_PARAMETER);
+
+ /* Make sure the end_entry is within limits.*/
+ lh = &ls->lh[list_handle];
+ if ((start_item + data_length) > lh->list_length)
+ return(OCTAPI_LLM_INVALID_PARAMETER);
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+
+ /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+ /* Set the data of each node.*/
+ for (i=0; i<data_length; i++)
+ {
+ /* Obtain pointer to current item.*/
+ if (i == 0)
+ {
+ /* Check if location of start item is already cached. If not, must search
+ for it manually.*/
+ if (start_item == (lh->cache_item_number + 1))
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * lh->cache_item_pointer);
+ item_pnt = item->forward_link;
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * item_pnt);
+ }
+ else
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * lh->head_pointer);
+ for (j=0; j<start_item; j++)
+ {
+ item_pnt = item->forward_link;
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * item_pnt);
+ }
+ }
+
+ pdata_item = (void *)((BYTE *)pdata_list + (i * ls->user_info_bytes));
+ }
+ else
+ {
+ item_pnt = item->forward_link;
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * item_pnt);
+
+ pdata_item = (void *)((BYTE *)pdata_item + ls->user_info_bytes);
+ }
+
+ /* Set the value of the item's user data.*/
+ OctApiLlmMemCpy(pdata_item, item->user_info, ls->user_info_bytes);
+ }
+
+ /* Write new cache entry.*/
+ lh->cache_item_pointer = item_pnt;
+ lh->cache_item_number = start_item + data_length - 1;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListRemoveItem.
+|
+| Description: This function deallocates a node of the linked list specified
+| by the handle list_handle.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| list_handle UINT32 The handle to the list.
+| item_number UINT32 The number of the item to be removed.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlmListRemoveItem(void * l,UINT32 list_handle,UINT32 item_number)
+{
+ LLM_LIST* ls;
+ LLM_LIST_ITEM* freed_item = NULL;
+ LLM_LIST_HEAD* lh;
+ UINT32 freed_item_pnt = 0xFFFFFFFF;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+ UINT32 fConditionFlag = TRUE;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM_LIST_HEAD *)(lsbyte + sizeof(LLM_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)));
+ ls->li = (LLM_LIST_ITEM *)(lsbyte + sizeof(LLM_LIST) + (total_lists * sizeof(LLM_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
+ if (lh->list_length == 0xFFFFFFFF) return(OCTAPI_LLM_INVALID_LIST_HANDLE);
+ if (lh->list_length <= item_number) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
+
+ if (item_number == 0 && lh->list_length == 1)/* First item and only item:*/
+ {
+ freed_item_pnt = lh->head_pointer;
+ freed_item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * freed_item_pnt);
+
+ lh->head_pointer = 0xFFFFFFFF;
+ lh->tail_pointer = 0xFFFFFFFF;
+
+ lh->cache_item_number = 0xFFFFFFFF;
+ lh->cache_item_pointer = 0xFFFFFFFF;
+ }
+ else if (item_number == 0) /* First item and but list not empty:*/
+ {
+ freed_item_pnt = ls->lh[list_handle].head_pointer;
+ freed_item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * freed_item_pnt);
+
+ lh->head_pointer = freed_item->forward_link;
+
+ lh->cache_item_number = 0;
+ lh->cache_item_pointer = freed_item->forward_link;
+ }
+ else /* Discard non-first item! (Caution: this could be the last item!)*/
+ {
+ LLM_LIST_ITEM * last_item = NULL;
+ LLM_LIST_ITEM * item;
+ UINT32 last_list_pnt;
+ UINT32 cur_list_pnt;
+ UINT32 cur_list_num;
+
+ if (lh->cache_item_number < item_number) /* Start at cache:*/
+ {
+ cur_list_pnt = lh->cache_item_pointer;
+ cur_list_num = lh->cache_item_number;
+ }
+ else /* Start at beginning:*/
+ {
+ cur_list_pnt = lh->head_pointer;
+ cur_list_num = 0;
+ }
+
+ last_list_pnt = 0xFFFFFFFF;
+
+ /* Start search from cur_list_pnt and cur_list_num.*/
+ while( fConditionFlag == TRUE )
+ {
+ item = (LLM_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+
+ if (cur_list_num == item_number) /* Item number found.*/
+ {
+ if (last_list_pnt == 0xFFFFFFFF) return(OCTAPI_LLM_INTERNAL_ERROR1);
+
+ if ((item_number + 1) == lh->list_length)
+ {
+ lh->tail_pointer = last_list_pnt;
+ last_item->forward_link = 0xFFFFFFFF;
+ }
+ else
+ {
+ last_item->forward_link = item->forward_link;
+ }
+ freed_item_pnt = cur_list_pnt;
+ freed_item = item;
+
+ /* Reset cache entry.*/
+ lh->cache_item_pointer = last_list_pnt;
+ lh->cache_item_number = cur_list_num - 1;
+
+ fConditionFlag = FALSE;
+ break;
+ }
+ else if (item->forward_link == 0xFFFFFFFF) /* End of list found?!?*/
+ {
+ return(OCTAPI_LLM_INTERNAL_ERROR0);
+ }
+ else /* Item was not found, but continue searching.*/
+ {
+ last_item = item;
+ last_list_pnt = cur_list_pnt;
+ cur_list_pnt = item->forward_link;
+ }
+
+ cur_list_num++;
+ }
+ }
+
+ /* Decrease the list length.*/
+ lh->list_length--;
+ ls->assigned_items--;
+
+ /* Return free block to free block list:*/
+ freed_item->forward_link = ls->next_empty_item;
+ ls->next_empty_item = freed_item_pnt;
+
+ return(GENERIC_OK);
+}
+
+/**************************************** llm2 function section *****************************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlm2ListGetSize
+|
+| Description: This function determines the amount of memory needed by
+| the LLM2_LIST structure to manage the allocation of
+| number_of_items number of resources. The memory is
+| measured in bytes.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| number_of_items UINT32 The number of resources to be allocated
+| amongst all linked-lists.
+| number_of_lists UINT32 The maximum number of linked-lists that
+| can be allocated.
+| *l_size UINT32 UINT32 The amount of memory needed, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlm2ListGetSize(UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size,UINT32 * l_size)
+{
+ UINT32 head_alloc_size;
+ UINT32 result;
+ UINT32 user_info_size_roundup;
+
+ if (number_of_items == 0) return(GENERIC_BAD_PARAM);
+ if (number_of_lists == 0) return(GENERIC_BAD_PARAM);
+ if (user_info_size == 0) return(GENERIC_BAD_PARAM);
+
+ user_info_size_roundup = ((user_info_size + 3) / 4) * 4;
+
+ result = OctapiLlmAllocGetSize(number_of_lists,&head_alloc_size);
+ if(result != GENERIC_OK) return(result);
+
+ *l_size = sizeof(LLM2_LIST) + (number_of_lists * sizeof(LLM2_LIST_HEAD)) + head_alloc_size + (number_of_items * (sizeof(LLM2_LIST_ITEM) + user_info_size_roundup - 4));
+
+ return(GENERIC_OK);
+}
+
+LLM2_LIST_ITEM * OctApiLlm2ListGetItemPointer(LLM2_LIST * ls, UINT32 item_number)
+{
+ return (LLM2_LIST_ITEM *) (((BYTE *)ls->li) + (ls->item_size * item_number)) ;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlm2ListInit.
+|
+| Description: This function intializes the LLM2_TALLOC structure.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM2_LIST structure.
+| number_of_items UINT32 The number of resources to be allocated
+| amongst all linked-lists.
+| number_of_lists UINT32 The maximum number of linked-lists that
+| can be allocated.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlm2ListInit(void ** l,UINT32 number_of_items,UINT32 number_of_lists,UINT32 user_info_size)
+{
+ LLM2_LIST* ls;
+ LLM2_LIST_ITEM* item;
+ UINT32 i;
+ UINT32 head_alloc_size;
+ UINT32 result;
+ UINT32 user_info_size_roundup;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+
+
+ if (number_of_items == 0) return(GENERIC_BAD_PARAM);
+ if (number_of_lists == 0) return(GENERIC_BAD_PARAM);
+ if (user_info_size == 0) return(GENERIC_BAD_PARAM);
+
+ user_info_size_roundup = ((user_info_size + 3) / 4) * 4;
+
+ /* Get the size of the Alloc structure used to manage head of list structures.*/
+ result = OctapiLlmAllocGetSize(number_of_lists,&head_alloc_size);
+ if(result != GENERIC_OK) return(result);
+
+ if (*l == NULL) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED);
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM2_LIST *)(*l);
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+ /* Initialize parameters in the structure.*/
+ ls->head_alloc_size = head_alloc_size;
+ ls->user_info_bytes = user_info_size;
+ ls->user_info_size = user_info_size_roundup;
+ ls->total_items = number_of_items;
+ ls->assigned_items = 0;
+ ls->total_lists = number_of_lists;
+ ls->assigned_lists = 0;
+ ls->next_empty_item = 0;
+ ls->item_size = sizeof(LLM2_LIST_ITEM) + user_info_size_roundup - 4;
+
+ /* Complete the build!*/
+ ls = (LLM2_LIST *)(*l);
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+ /* Initialize the head of queue Alloc structure.*/
+ result = OctapiLlmAllocInit(&(ls->list_head_alloc),number_of_lists);
+ if(result != GENERIC_OK) return(result);
+
+ /* Initialize the linked list of the items:*/
+ for(i=0; i<number_of_items; i++)
+ {
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * i);
+
+ if (i == (number_of_items - 1))
+ item->forward_link = 0xFFFFFFFF;
+ else
+ item->forward_link = i + 1;
+ }
+
+ return(GENERIC_OK);
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlm2ListCreate.
+|
+| Description: This function creates a linked list. The target which is
+| allocated the newly created list can request additions
+| or removals from the list later on. To target identifies
+| its list with the returned list handle.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM_LIST structure.
+| *list_handle UINT32 The handle to the new list, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlm2ListCreate(void * l,UINT32 * list_handle)
+{
+ LLM2_LIST* ls;
+ LLM2_LIST_HEAD* lh;
+ UINT32 blocknum;
+ UINT32 total_lists;
+ UINT32 result;
+ BYTE* lsbyte;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM2_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+ /* Get a list using the list head alloc structure.*/
+ result = OctapiLlmAllocAlloc(ls->list_head_alloc, &blocknum);
+ if (result != GENERIC_OK) return(result);
+
+ /* The handle is the block number.*/
+ *list_handle = blocknum;
+
+ /* Initialize the list head structure.*/
+ lh = &ls->lh[blocknum];
+ lh->list_length = 0;
+ lh->head_pointer = 0xFFFFFFFF;
+ lh->tail_pointer = 0xFFFFFFFF;
+
+ ls->assigned_lists++;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListDelete.
+|
+| Description: This function deletes the linked list indicated by the
+| handle list_handle. Any items which are still allocated
+| to the list are first deallocated.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM2_LIST structure.
+| *list_handle UINT32 The handle to the list.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlm2ListDelete(void * l,UINT32 list_handle)
+{
+ LLM2_LIST* ls;
+ LLM2_LIST_HEAD* lh;
+ UINT32 total_lists;
+ UINT32 result;
+ BYTE* lsbyte;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM2_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM2_BLOCKNUM_OUT_OF_RANGE);
+ if (ls->lh[list_handle].list_length == 0xFFFFFFFF) return(OCTAPI_LLM2_INVALID_LIST_HANDLE);
+
+ /* Release internal list header handle...*/
+ result = OctapiLlmAllocDealloc(ls->list_head_alloc,list_handle);
+ if (result != GENERIC_OK) return(result);
+
+ lh = &ls->lh[list_handle];
+
+ /* Deallocate all items in the list!*/
+ if (lh->list_length != 0)
+ {
+ LLM2_LIST_ITEM * item;
+
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * lh->tail_pointer);
+
+ /* Release the items using only the links.*/
+ item->forward_link = ls->next_empty_item;
+ ls->next_empty_item = lh->head_pointer;
+
+ /* Remove items from item counter.*/
+ ls->assigned_items -= lh->list_length;
+ }
+
+ lh->list_length = 0xFFFFFFFF;
+ lh->head_pointer = 0xFFFFFFFF;
+ lh->tail_pointer = 0xFFFFFFFF;
+
+ ls->assigned_lists--;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmListLength.
+|
+| Description: This function returns the number of items allocated to the
+| list indicated by the handle list_handle.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM2_LIST structure.
+| list_handle UINT32 The handle to the list.
+| *number_of_items UINT32 The number of items in the list, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlm2ListLength(void * l,UINT32 list_handle, UINT32 * number_of_items_in_list)
+{
+ LLM2_LIST* ls;
+ LLM2_LIST_HEAD* lh;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM2_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM2_BLOCKNUM_OUT_OF_RANGE);
+ if (lh->list_length == 0xFFFFFFFF) return(OCTAPI_LLM2_INVALID_LIST_HANDLE);
+
+ *number_of_items_in_list = lh->list_length;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlm2ListItemData
+|
+| Description: This function returns a pointer to the user data associated
+| with an item.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM2_LIST structure.
+| list_handle UINT32 The handle to the list.
+| item_number UINT32 The number of the list node in question.
+| **item_data_pnt void The pointer to the user data, returned.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 OctApiLlm2ListItemData(void * l,UINT32 list_handle,UINT32 item_key,void ** item_data_pnt, PUINT32 item_number_pnt)
+{
+ LLM2_LIST* ls;
+ LLM2_LIST_HEAD* lh;
+ LLM2_LIST_ITEM* item;
+ UINT32 cur_list_pnt;
+ UINT32 cur_list_key = 0xFFFFFFFF;
+ UINT32 total_lists;
+ UINT32 list_length;
+ BYTE* lsbyte;
+ UINT32 fConditionFlag = TRUE;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM2_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+ list_length = lh->list_length;
+
+ *item_data_pnt = NULL;
+ *item_number_pnt = 0;
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM2_BLOCKNUM_OUT_OF_RANGE);
+ if (list_length == 0xFFFFFFFF) return(OCTAPI_LLM2_INVALID_LIST_HANDLE);
+
+ /* Determine where the search will start.*/
+ /* Start at beginning:*/
+ cur_list_pnt = lh->head_pointer;
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+ cur_list_key = item->key;
+
+ /* Start search from cur_list_pnt and cur_list_num.*/
+ while ( fConditionFlag == TRUE )
+ {
+ if (cur_list_key == item_key) /* Item key found.*/
+ {
+ /* Get item info.*/
+ *item_data_pnt = (void *)item->user_info;
+
+ return(GENERIC_OK);
+ }
+ else if(item->forward_link == 0xFFFFFFFF) /* End of list found?!?*/
+ {
+ return(OCTAPI_LLM2_INTERNAL_ERROR0);
+ }
+ else /* Item was not found, but continue searching.*/
+ {
+ cur_list_pnt = item->forward_link;
+ }
+
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+ cur_list_key = item->key;
+ (*item_number_pnt)++;
+ }
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlm2ListInsertItem.
+|
+| Description: This function allocates a node to the linked list specified
+| by the handle list_handle. The position of the new item
+| will be defined based on the key value. All entry are inserted
+| in the list in incremental Key value.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM2_LIST structure.
+| *list_handle UINT32 The handle to the list.
+| **item_data void Address of the user data space for this item.
+| **prev_item_data void Address of the user data space for the previous item.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ LLM2_LIST* ls;
+ LLM2_LIST_HEAD* lh;
+ LLM2_LIST_ITEM* free_item;
+ UINT32 free_item_pnt;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+ UINT32 ulPassCount = 0;
+ UINT32 fConditionFlag = TRUE;
+
+ /* Set the status of the insertion.*/
+ *insert_status_pnt = OCTAPI_LLM2_INSERT_ERROR;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM2_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+
+ *item_data_pnt = NULL;
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM2_BLOCKNUM_OUT_OF_RANGE);
+ if (lh->list_length == 0xFFFFFFFF) return(OCTAPI_LLM2_INVALID_LIST_HANDLE);
+ if (ls->next_empty_item == 0xFFFFFFFF) return(OCTAPI_LLM2_NO_STRUCTURES_LEFT);
+
+ /* Get a free item from the free item list!*/
+ free_item_pnt = ls->next_empty_item;
+ free_item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * free_item_pnt);
+ free_item->key = item_key;
+ ls->next_empty_item = free_item->forward_link;
+
+ if (lh->list_length == 0) /* First item and only item:*/
+ {
+ free_item->forward_link = 0xFFFFFFFF;
+ lh->tail_pointer = free_item_pnt;
+ lh->head_pointer = free_item_pnt;
+ *insert_status_pnt = OCTAPI_LLM2_INSERT_FIRST_NODE;
+
+ /* There is no previous node information to return.*/
+ *prev_item_data_pnt = NULL;
+ *prev_prev_item_data_pnt = NULL;
+ }
+ else /* Insert:*/
+ {
+ LLM2_LIST_ITEM * last_last_item = NULL;
+ LLM2_LIST_ITEM * last_item = NULL;
+ LLM2_LIST_ITEM * item;
+ UINT32 last_list_pnt;
+ UINT32 cur_list_pnt;
+ UINT32 cur_list_key = 0xFFFFFFFF;
+
+ /* Start at beginning:*/
+ cur_list_pnt = lh->head_pointer;
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+ cur_list_key = item->key;
+
+ last_list_pnt = 0xFFFFFFFF;
+
+ /* Start search from cur_list_pnt and cur_list_num.*/
+ while ( fConditionFlag == TRUE )
+ {
+ /* Increment the pass count to determine if the addition will happen next to last.*/
+ ulPassCount++;
+
+ if (cur_list_key >= item_key) /* Item new node between the last and the curent. */
+ {
+ if (last_list_pnt == 0xFFFFFFFF) /* Must insert at the head of the list.*/
+ {
+ free_item->forward_link = cur_list_pnt;
+ lh->head_pointer = free_item_pnt;
+ }
+ else /* Standard insertion.*/
+ {
+ free_item->forward_link = cur_list_pnt;
+ last_item->forward_link = free_item_pnt;
+ }
+
+ /* Check if the entry was made before the last one.*/
+ if ( ulPassCount == lh->list_length )
+ *insert_status_pnt = OCTAPI_LLM2_INSERT_BEFORE_LAST_NODE;
+ else
+ *insert_status_pnt = OCTAPI_LLM2_INSERT_LIST_NODE;
+
+ fConditionFlag = FALSE;
+ break;
+ }
+ else if (item->forward_link == 0xFFFFFFFF) /* End of list found, must insert at the end.*/
+ {
+ free_item->forward_link = 0xFFFFFFFF;
+ item->forward_link = free_item_pnt;
+ lh->tail_pointer = free_item_pnt;
+
+ *insert_status_pnt = OCTAPI_LLM2_INSERT_LAST_NODE;
+
+ fConditionFlag = FALSE;
+ break;
+ }
+ else /* Item was not found, but continue searching.*/
+ {
+ last_last_item = last_item;
+ last_item = item;
+ last_list_pnt = cur_list_pnt;
+ cur_list_pnt = item->forward_link;
+ }
+
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+ cur_list_key = item->key;
+
+ }
+
+ /* Return the previous node if possible.*/
+ if ( *insert_status_pnt == OCTAPI_LLM2_INSERT_LIST_NODE ||
+ *insert_status_pnt == OCTAPI_LLM2_INSERT_BEFORE_LAST_NODE )
+ {
+ if ( last_item != NULL )
+ *prev_item_data_pnt = (void *)last_item->user_info;
+
+ if ( last_last_item != NULL )
+ *prev_prev_item_data_pnt = (void *)last_last_item->user_info;
+ else
+ *prev_prev_item_data_pnt = NULL;
+ }
+ else
+ {
+ *prev_item_data_pnt = (void *)item->user_info;
+
+ if ( ( last_last_item != NULL ) && ( last_item != NULL ) )
+ *prev_prev_item_data_pnt = (void *)last_item->user_info;
+ else
+ *prev_prev_item_data_pnt = NULL;
+ }
+ }
+
+ /* Increase the list length.*/
+ lh->list_length++;
+ ls->assigned_items++;
+ *item_data_pnt = (void *)free_item->user_info;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlm2ListRemoveItem.
+|
+| Description: This function deallocates a node of the linked list specified
+| by the handle list_handle.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *l void The memory used by the LLM2_LIST structure.
+| list_handle UINT32 The handle to the list.
+| item_key UINT32 The key of the item to be removed.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ LLM2_LIST* ls;
+ LLM2_LIST_ITEM* freed_item = NULL;
+ LLM2_LIST_HEAD* lh;
+ UINT32 freed_item_pnt = 0xFFFFFFFF;
+ UINT32 total_lists;
+ BYTE* lsbyte;
+ UINT32 fConditionFlag = TRUE;
+ UINT32 ulPassCount = 0;
+
+ /* Built the structure based on the base address:*/
+ ls = (LLM2_LIST *)l;
+ lsbyte = (BYTE *)ls;
+ total_lists = ls->total_lists;
+
+ /* Set the status of the removal to error as a default value.*/
+ *remove_status_pnt = OCTAPI_LLM2_REMOVE_ERROR;
+
+ ls->lh = (LLM2_LIST_HEAD *)(lsbyte + sizeof(LLM2_LIST));
+ ls->list_head_alloc = (void *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)));
+ ls->li = (LLM2_LIST_ITEM *)(lsbyte + sizeof(LLM2_LIST) + (total_lists * sizeof(LLM2_LIST_HEAD)) + ls->head_alloc_size);
+
+ lh = &ls->lh[list_handle];
+
+ if (list_handle >= ls->total_lists) return(OCTAPI_LLM2_BLOCKNUM_OUT_OF_RANGE);
+ if (lh->list_length == 0xFFFFFFFF) return(OCTAPI_LLM2_INVALID_LIST_HANDLE);
+
+ if (lh->list_length == 1)/* First item and only item if he matches.*/
+ {
+ freed_item_pnt = lh->head_pointer;
+ freed_item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * freed_item_pnt);
+
+ if ( freed_item->key == item_key )
+ {
+ lh->head_pointer = 0xFFFFFFFF;
+ lh->tail_pointer = 0xFFFFFFFF;
+ }
+ else
+ return(OCTAPI_LLM2_INTERNAL_ERROR1);
+
+ /* Indicate that there was no node prior to the one removed.*/
+ *prev_item_key_pnt = 0xFFFFFFFF;
+ *prev_prev_item_key_pnt = 0xFFFFFFFF;
+ *remove_status_pnt = OCTAPI_LLM2_REMOVE_FIRST_NODE;
+ }
+ else /* Discard non-first item! (Caution: this could be the last item!)*/
+ {
+ LLM2_LIST_ITEM * last_last_item = NULL;
+ LLM2_LIST_ITEM * last_item = NULL;
+ LLM2_LIST_ITEM * item;
+ UINT32 last_list_pnt;
+ UINT32 cur_list_pnt;
+ UINT32 cur_list_key;
+
+ /* Start at beginning:*/
+ cur_list_pnt = lh->head_pointer;
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+ cur_list_key = item->key;
+
+ last_list_pnt = 0xFFFFFFFF;
+
+ /* Start search from cur_list_pnt and cur_list_num.*/
+ while( fConditionFlag == TRUE )
+ {
+ ulPassCount++;
+ if (cur_list_key == item_key) /* Item number found.*/
+ {
+ if (last_list_pnt == 0xFFFFFFFF) /* First item in the list.*/
+ {
+ lh->head_pointer = item->forward_link;
+ *remove_status_pnt = OCTAPI_LLM2_REMOVE_FIRST_NODE;
+ }
+ else if ( item->forward_link == 0xFFFFFFFF) /* Last item of the list.*/
+ {
+ last_item->forward_link = 0xFFFFFFFF;
+ lh->tail_pointer = last_list_pnt;
+ *remove_status_pnt = OCTAPI_LLM2_REMOVE_LAST_NODE;
+ }
+ else
+ {
+ last_item->forward_link = item->forward_link;
+
+ if ( ulPassCount == ( lh->list_length - 1 ) )
+ *remove_status_pnt = OCTAPI_LLM2_REMOVE_BEFORE_LAST_NODE;
+ else
+ *remove_status_pnt = OCTAPI_LLM2_REMOVE_LIST_NODE;
+ }
+
+ freed_item_pnt = cur_list_pnt;
+ freed_item = item;
+
+ fConditionFlag = FALSE;
+ break;
+ }
+ else if (item->forward_link == 0xFFFFFFFF) /* End of list found?!?*/
+ {
+ return(OCTAPI_LLM2_INTERNAL_ERROR0);
+ }
+ else /* Item was not found, but continue searching.*/
+ {
+ last_last_item = last_item;
+ last_item = item;
+ last_list_pnt = cur_list_pnt;
+ cur_list_pnt = item->forward_link;
+ }
+
+ item = (LLM2_LIST_ITEM *)((BYTE *)ls->li + ls->item_size * cur_list_pnt);
+ cur_list_key = item->key;
+ }
+
+ /* Return the key of the node before the node removed if possible.*/
+ if ( last_list_pnt == 0xFFFFFFFF )
+ *prev_item_key_pnt = 0xFFFFFFFF;
+ else if ( last_item != NULL )
+ *prev_item_key_pnt = last_item->key;
+
+ /* Return the key of the node before before the node removed if possible.*/
+ if ( last_last_item == NULL )
+ *prev_prev_item_key_pnt = 0xFFFFFFFF;
+ else
+ *prev_prev_item_key_pnt = last_last_item->key;
+
+ }
+
+ /* Decrease the list length.*/
+ lh->list_length--;
+ ls->assigned_items--;
+
+ /* Return free block to free block list:*/
+ freed_item->forward_link = ls->next_empty_item;
+ ls->next_empty_item = freed_item_pnt;
+
+ return(GENERIC_OK);
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+| API UTILITIES
+|
+| Function: OctApiLlmMemCpy.
+|
+| Description: This function copies data from a source to a destination.
+|
+| -----------------------------------------------------------------------
+| | Variable | Type | Description
+| -----------------------------------------------------------------------
+| *f_pvDestination VOID The destination where to copy the data.
+| *f_pvSource VOID The source where to copy the data from.
+| f_ulSize UINT32 The number of bytes to copy.
+|
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID * OctApiLlmMemCpy( VOID *f_pvDestination, const VOID * f_pvSource, UINT32 f_ulSize )
+{
+ CHAR * pbyDst;
+ const CHAR * pbySrc;
+ UINT32 * f_pulAlignedDst;
+ const UINT32 * f_pulAlignedSrc;
+
+ pbyDst = (CHAR *)f_pvDestination;
+ pbySrc = (const CHAR *)f_pvSource;
+
+ /*
+ * If the size is small, or either SRC or DST is unaligned,
+ * then punt into the byte copy loop. This should be rare.
+ */
+ if ( ( f_ulSize < sizeof(UINT32) )
+ || ( ( (UINT32)( pbySrc ) & ( sizeof(UINT32) - 1 ) ) | ( (UINT32)( pbyDst ) & ( sizeof(UINT32) - 1 ) ) ) )
+ {
+ while ( f_ulSize-- )
+ *pbyDst++ = *pbySrc++;
+ return f_pvDestination;
+ }
+
+ f_pulAlignedDst = (UINT32 *)pbyDst;
+ f_pulAlignedSrc = (const UINT32 *)pbySrc;
+
+ /* Copy 4X long words at a time if possible. */
+ while ( f_ulSize >= 4 * sizeof(UINT32) )
+ {
+ *f_pulAlignedDst++ = *f_pulAlignedSrc++;
+ *f_pulAlignedDst++ = *f_pulAlignedSrc++;
+ *f_pulAlignedDst++ = *f_pulAlignedSrc++;
+ *f_pulAlignedDst++ = *f_pulAlignedSrc++;
+ f_ulSize -= 4 * sizeof(UINT32);
+ }
+
+ /* Copy one long word at a time if possible. */
+ while ( f_ulSize >= sizeof(UINT32) )
+ {
+ *f_pulAlignedDst++ = *f_pulAlignedSrc++;
+ f_ulSize -= sizeof(UINT32);
+ }
+
+ /* Pick up any residual with a byte copier. */
+ pbyDst = (CHAR *)f_pulAlignedDst;
+ pbySrc = (const CHAR *)f_pulAlignedSrc;
+ while ( f_ulSize-- )
+ *pbyDst++ = *pbySrc++;
+
+ return f_pvDestination;
+}
+
+/**************************************** llm_list section **********************************************/
+
diff --git a/software/apilib/llman/octapi_llman_private.h b/software/apilib/llman/octapi_llman_private.h
new file mode 100644
index 0000000..f182cf1
--- /dev/null
+++ b/software/apilib/llman/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/software/include/apilib/octapi_bt0.h b/software/include/apilib/octapi_bt0.h
new file mode 100644
index 0000000..d130c8b
--- /dev/null
+++ b/software/include/apilib/octapi_bt0.h
@@ -0,0 +1,75 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octapi_bt0.h
+
+ 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: 11 $
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#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 )
+
+UINT32 OctApiBt0GetSize( UINT32 number_of_items, UINT32 key_size, UINT32 data_size, UINT32 * b_size );
+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/software/include/apilib/octapi_largmath.h b/software/include/apilib/octapi_largmath.h
new file mode 100644
index 0000000..cbbfc12
--- /dev/null
+++ b/software/include/apilib/octapi_largmath.h
@@ -0,0 +1,69 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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: 6 $
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#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 )
+
+
+UINT32 OctApiLmAdd( PUINT32 a, USHORT alen, PUINT32 b, USHORT blen, PUINT32 z, USHORT zlen );
+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/software/include/apilib/octapi_llman.h b/software/include/apilib/octapi_llman.h
new file mode 100644
index 0000000..131281c
--- /dev/null
+++ b/software/include/apilib/octapi_llman.h
@@ -0,0 +1,142 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octapi_llman.h
+
+ 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: 8 $
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#ifndef __OCTAPI_LLMAN_H__
+#define __OCTAPI_LLMAN_H__
+
+#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. */
+UINT32 OctapiLlmAllocGetSize( UINT32 number_of_items,PUINT32 l_size );
+UINT32 OctapiLlmAllocInit( PVOID* l,UINT32 number_of_items );
+UINT32 OctapiLlmAllocInfo( PVOID l, PUINT32 allocated_items, PUINT32 available_items );
+UINT32 OctapiLlmAllocAlloc( PVOID l, PUINT32 blocknum );
+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 */
+
+#endif /* __OCTAPI_LLMAN_H__ */
diff --git a/software/include/oct6100api/oct6100_adpcm_chan_inst.h b/software/include/oct6100api/oct6100_adpcm_chan_inst.h
new file mode 100644
index 0000000..b74ce9e
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_adpcm_chan_pub.h b/software/include/oct6100api/oct6100_adpcm_chan_pub.h
new file mode 100644
index 0000000..f0c32d9
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_api.h b/software/include/oct6100api/oct6100_api.h
new file mode 100644
index 0000000..5652375
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_api_inst.h b/software/include/oct6100api/oct6100_api_inst.h
new file mode 100644
index 0000000..679d9e6
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_apimi.h b/software/include/oct6100api/oct6100_apimi.h
new file mode 100644
index 0000000..abcad76
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_apiud.h b/software/include/oct6100api/oct6100_apiud.h
new file mode 100644
index 0000000..053a36c
--- /dev/null
+++ b/software/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. */
+UINT32 Oct6100UserGetTime(
+ IN OUT tPOCT6100_GET_TIME f_pTime );
+
+
+
+/* Memory management functions. */
+UINT32 Oct6100UserMemSet(
+ IN PVOID f_pAddress,
+ IN UINT32 f_ulPattern,
+ IN UINT32 f_ulLength );
+
+UINT32 Oct6100UserMemCopy(
+ IN PVOID f_pDestination,
+ IN PVOID f_pSource,
+ IN UINT32 f_ulLength );
+
+/* Serialization functions. */
+UINT32 Oct6100UserCreateSerializeObject(
+ IN OUT tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate);
+
+UINT32 Oct6100UserDestroySerializeObject(
+ IN tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy);
+
+UINT32 Oct6100UserSeizeSerializeObject(
+ IN tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize);
+
+UINT32 Oct6100UserReleaseSerializeObject(
+ IN tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease);
+
+/* Read/Write functions.*/
+UINT32 Oct6100UserDriverWriteApi(
+ IN tPOCT6100_WRITE_PARAMS f_pWriteParams );
+
+UINT32 Oct6100UserDriverWriteOs(
+ IN tPOCT6100_WRITE_PARAMS f_pWriteParams );
+
+UINT32 Oct6100UserDriverWriteSmearApi(
+ IN tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams );
+
+UINT32 Oct6100UserDriverWriteSmearOs(
+ IN tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams );
+
+UINT32 Oct6100UserDriverWriteBurstApi(
+ IN tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams );
+
+UINT32 Oct6100UserDriverWriteBurstOs(
+ IN tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams );
+
+UINT32 Oct6100UserDriverReadApi(
+ IN OUT tPOCT6100_READ_PARAMS f_pReadParams );
+
+UINT32 Oct6100UserDriverReadOs(
+ IN OUT tPOCT6100_READ_PARAMS f_pReadParams );
+
+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/software/include/oct6100api/oct6100_channel_inst.h b/software/include/oct6100api/oct6100_channel_inst.h
new file mode 100644
index 0000000..8480c98
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_channel_pub.h b/software/include/oct6100api/oct6100_channel_pub.h
new file mode 100644
index 0000000..792edcd
--- /dev/null
+++ b/software/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 *****************************/
+
+
+UINT32 Oct6100ChannelOpenDef(
+ OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen );
+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 );
+
+UINT32 Oct6100ChannelModifyDef(
+ OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify );
+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 );
+
+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/software/include/oct6100api/oct6100_chip_open_inst.h b/software/include/oct6100api/oct6100_chip_open_inst.h
new file mode 100644
index 0000000..f1ee150
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_chip_open_pub.h b/software/include/oct6100api/oct6100_chip_open_pub.h
new file mode 100644
index 0000000..4554ccc
--- /dev/null
+++ b/software/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 *****************************/
+
+UINT32 Oct6100ChipOpenDef(
+ OUT tPOCT6100_CHIP_OPEN f_pChipOpen );
+UINT32 Oct6100ChipOpen(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHIP_OPEN f_pChipOpen );
+
+UINT32 Oct6100ChipCloseDef(
+ OUT tPOCT6100_CHIP_CLOSE f_pChipClose );
+UINT32 Oct6100ChipClose(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHIP_CLOSE f_pChipClose );
+
+UINT32 Oct6100GetInstanceSizeDef(
+ OUT tPOCT6100_GET_INSTANCE_SIZE f_pInstanceSize );
+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/software/include/oct6100api/oct6100_chip_stats_inst.h b/software/include/oct6100api/oct6100_chip_stats_inst.h
new file mode 100644
index 0000000..1c4156b
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_chip_stats_pub.h b/software/include/oct6100api/oct6100_chip_stats_pub.h
new file mode 100644
index 0000000..57add0e
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_conf_bridge_inst.h b/software/include/oct6100api/oct6100_conf_bridge_inst.h
new file mode 100644
index 0000000..ebe2da3
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_conf_bridge_pub.h b/software/include/oct6100api/oct6100_conf_bridge_pub.h
new file mode 100644
index 0000000..a751cd3
--- /dev/null
+++ b/software/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 );
+
+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 );
+
+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/software/include/oct6100api/oct6100_debug_inst.h b/software/include/oct6100api/oct6100_debug_inst.h
new file mode 100644
index 0000000..7635411
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_debug_pub.h b/software/include/oct6100api/oct6100_debug_pub.h
new file mode 100644
index 0000000..fe61a5f
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_defines.h b/software/include/oct6100api/oct6100_defines.h
new file mode 100644
index 0000000..67e8d2e
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_errors.h b/software/include/oct6100api/oct6100_errors.h
new file mode 100644
index 0000000..787965c
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_events_inst.h b/software/include/oct6100api/oct6100_events_inst.h
new file mode 100644
index 0000000..8d0a049
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_events_pub.h b/software/include/oct6100api/oct6100_events_pub.h
new file mode 100644
index 0000000..837df71
--- /dev/null
+++ b/software/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 *****************************/
+
+UINT32 Oct6100EventGetToneDef(
+ OUT tPOCT6100_EVENT_GET_TONE f_pEventGetTone );
+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/software/include/oct6100api/oct6100_interrupts_inst.h b/software/include/oct6100api/oct6100_interrupts_inst.h
new file mode 100644
index 0000000..00bfd4c
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_interrupts_pub.h b/software/include/oct6100api/oct6100_interrupts_pub.h
new file mode 100644
index 0000000..620d0fc
--- /dev/null
+++ b/software/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 );
+
+UINT32 Oct6100InterruptServiceRoutineDef(
+ OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags );
+UINT32 Oct6100InterruptServiceRoutine(
+ IN tPOCT6100_INSTANCE_API f_pApiInst,
+ IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags );
+
+#endif /* __OCT6100_INTERRUPTS_PUB_H__ */
+
diff --git a/software/include/oct6100api/oct6100_mixer_inst.h b/software/include/oct6100api/oct6100_mixer_inst.h
new file mode 100644
index 0000000..2c7707f
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_mixer_pub.h b/software/include/oct6100api/oct6100_mixer_pub.h
new file mode 100644
index 0000000..004d1e5
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_phasing_tsst_inst.h b/software/include/oct6100api/oct6100_phasing_tsst_inst.h
new file mode 100644
index 0000000..5624238
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_phasing_tsst_pub.h b/software/include/oct6100api/oct6100_phasing_tsst_pub.h
new file mode 100644
index 0000000..b5f5e8e
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_playout_buf_inst.h b/software/include/oct6100api/oct6100_playout_buf_inst.h
new file mode 100644
index 0000000..4dce9cb
--- /dev/null
+++ b/software/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulPlayoutBufMemoryNodeListOfst );
+
+#define mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE )(( UINT32 )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/software/include/oct6100api/oct6100_playout_buf_pub.h b/software/include/oct6100api/oct6100_playout_buf_pub.h
new file mode 100644
index 0000000..88abaca
--- /dev/null
+++ b/software/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 );
+
+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/software/include/oct6100api/oct6100_remote_debug_inst.h b/software/include/oct6100api/oct6100_remote_debug_inst.h
new file mode 100644
index 0000000..d12415a
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_remote_debug_pub.h b/software/include/oct6100api/oct6100_remote_debug_pub.h
new file mode 100644
index 0000000..967011d
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_tlv_inst.h b/software/include/oct6100api/oct6100_tlv_inst.h
new file mode 100644
index 0000000..d4d670b
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_tone_detection_inst.h b/software/include/oct6100api/oct6100_tone_detection_inst.h
new file mode 100644
index 0000000..3e1b72e
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_tone_detection_pub.h b/software/include/oct6100api/oct6100_tone_detection_pub.h
new file mode 100644
index 0000000..5d49579
--- /dev/null
+++ b/software/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 *****************************/
+
+UINT32 Oct6100ToneDetectionEnableDef(
+ OUT tPOCT6100_TONE_DETECTION_ENABLE f_pBufferLoad );
+UINT32 Oct6100ToneDetectionEnable(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_TONE_DETECTION_ENABLE f_pBufferLoad );
+
+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/software/include/oct6100api/oct6100_tsi_cnct_inst.h b/software/include/oct6100api/oct6100_tsi_cnct_inst.h
new file mode 100644
index 0000000..31f9be3
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_tsi_cnct_pub.h b/software/include/oct6100api/oct6100_tsi_cnct_pub.h
new file mode 100644
index 0000000..9a8ae50
--- /dev/null
+++ b/software/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/software/include/oct6100api/oct6100_tsst_inst.h b/software/include/oct6100api/oct6100_tsst_inst.h
new file mode 100644
index 0000000..34bb022
--- /dev/null
+++ b/software/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/software/include/octdef.h b/software/include/octdef.h
new file mode 100644
index 0000000..3330048
--- /dev/null
+++ b/software/include/octdef.h
@@ -0,0 +1,113 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octdef.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ Common system definitions.
+
+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 __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/software/include/octmac.h b/software/include/octmac.h
new file mode 100644
index 0000000..53804c7
--- /dev/null
+++ b/software/include/octmac.h
@@ -0,0 +1,98 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octmac.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ Common macro definitions.
+
+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: 14 $
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#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/software/include/octosdependant.h b/software/include/octosdependant.h
new file mode 100644
index 0000000..c3982a8
--- /dev/null
+++ b/software/include/octosdependant.h
@@ -0,0 +1,155 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octosdependant.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ This file is included to set target-specific constants.
+
+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 __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/software/include/octrpc/oct6100_rpc_protocol.h b/software/include/octrpc/oct6100_rpc_protocol.h
new file mode 100644
index 0000000..d8f9ce9
--- /dev/null
+++ b/software/include/octrpc/oct6100_rpc_protocol.h
@@ -0,0 +1,348 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: oct6100_rpc_protocol.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ File containing all defines and prototypes related to the OCT6100 RPC
+ protocol for exchanging debug commands.
+
+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_RPC_PROTOCOL_H__
+#define __OCT6100_RPC_PROTOCOL_H__
+
+/***************************** 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;
+
+#endif /* __OCT6100_RPC_PROTOCOL_H__ */
diff --git a/software/include/octrpc/rpc_protocol.h b/software/include/octrpc/rpc_protocol.h
new file mode 100644
index 0000000..52a66f1
--- /dev/null
+++ b/software/include/octrpc/rpc_protocol.h
@@ -0,0 +1,115 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: rpc_protocol.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+This file contains RPC related definitions and prototypes.
+
+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 __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/software/include/octtype.h b/software/include/octtype.h
new file mode 100644
index 0000000..0d8f4c5
--- /dev/null
+++ b/software/include/octtype.h
@@ -0,0 +1,152 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octtype.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ This file defines the base storage types.
+
+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 __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/software/include/octtypevx.h b/software/include/octtypevx.h
new file mode 100644
index 0000000..4efec81
--- /dev/null
+++ b/software/include/octtypevx.h
@@ -0,0 +1,129 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octtypevx.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ This file defines the base storage types for the VxWorks environment.
+
+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 __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/software/include/octtypewin.h b/software/include/octtypewin.h
new file mode 100644
index 0000000..afe3cd3
--- /dev/null
+++ b/software/include/octtypewin.h
@@ -0,0 +1,92 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: octtypewin.h
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ This file defines the base storage types for the Windows environment.
+ Includes the Windows definition file and add the missing ones here.
+
+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 __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/software/octdeviceapi/oct6100api/oct6100_adpcm_chan_priv.h b/software/octdeviceapi/oct6100api/oct6100_adpcm_chan_priv.h
new file mode 100644
index 0000000..47c9403
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulAdpcmChanListOfst );
+
+#define mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_ADPCM_CHAN )(( UINT32 )pSharedInfo + pSharedInfo->ulAdpcmChanListOfst)) + ulIndex;
+
+#define mOCT6100_GET_ADPCM_CHAN_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulAdpcmChanAllocOfst);
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetAdpcmChanSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+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/software/octdeviceapi/oct6100api/oct6100_api/oct6100_adpcm_chan.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_adpcm_chan.c
new file mode 100644
index 0000000..ab39a52
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_adpcm_chan.c
@@ -0,0 +1,1204 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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 "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"
+
+/**************************** PUBLIC FUNCTIONS ****************************/
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100AdpcmChanOpen
+
+Description: This function opens an ADPCM channel between two TDM timeslots.
+ This channel will perform ADPCM compression or decompression
+ depending on the channel mode.
+
+-------------------------------------------------------------------------------
+| 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_pAdpcmChanOpen Pointer to ADPCM channel open structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100AdpcmChanOpenDef(
+ tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen )
+{
+ f_pAdpcmChanOpen->pulChanHndl = NULL;
+
+ f_pAdpcmChanOpen->ulInputTimeslot = cOCT6100_INVALID_TIMESLOT;
+ f_pAdpcmChanOpen->ulInputStream = cOCT6100_INVALID_STREAM;
+ f_pAdpcmChanOpen->ulInputNumTssts = 1;
+ f_pAdpcmChanOpen->ulInputPcmLaw = cOCT6100_PCM_U_LAW;
+
+ f_pAdpcmChanOpen->ulOutputTimeslot = cOCT6100_INVALID_TIMESLOT;
+ f_pAdpcmChanOpen->ulOutputStream = cOCT6100_INVALID_STREAM;
+ f_pAdpcmChanOpen->ulOutputPcmLaw = cOCT6100_PCM_U_LAW;
+ f_pAdpcmChanOpen->ulOutputNumTssts = 1;
+
+ f_pAdpcmChanOpen->ulChanMode = cOCT6100_ADPCM_ENCODING;
+ f_pAdpcmChanOpen->ulEncodingRate = cOCT6100_G726_32KBPS;
+ f_pAdpcmChanOpen->ulDecodingRate = cOCT6100_G726_32KBPS;
+
+ f_pAdpcmChanOpen->ulAdpcmNibblePosition = cOCT6100_ADPCM_IN_LOW_BITS;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100AdpcmChanOpen(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen )
+{
+ 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 = Oct6100AdpcmChanOpenSer( f_pApiInstance, f_pAdpcmChanOpen );
+ }
+ 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: Oct6100AdpcmChanClose
+
+Description: This function closes an opened ADPCM 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_pAdpcmChanClose Pointer to ADPCM channel close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100AdpcmChanCloseDef(
+ tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose )
+{
+ f_pAdpcmChanClose->ulChanHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100AdpcmChanClose(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose )
+{
+ 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 = Oct6100AdpcmChanCloseSer( f_pApiInstance, f_pAdpcmChanClose );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100AdpcmChanOpenSer
+
+Description: Opens an ADPCM 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_pAdpcmChanOpen Pointer to an ADPCM channel open structure
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100AdpcmChanOpenSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen )
+{
+ UINT16 usAdpcmChanIndex;
+ UINT16 usTsiMemIndex;
+ UINT16 usAdpcmMemIndex;
+ UINT16 usInputTsstIndex;
+ UINT16 usOutputTsstIndex;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the ADPCM channel open structure for errors. */
+ ulResult = Oct6100ApiCheckAdpcmChanParams( f_pApiInstance, f_pAdpcmChanOpen );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the ADPCM channel. */
+ ulResult = Oct6100ApiReserveAdpcmChanResources( f_pApiInstance, f_pAdpcmChanOpen, &usAdpcmChanIndex, &usAdpcmMemIndex, &usTsiMemIndex, &usInputTsstIndex, &usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write all necessary structures to activate the ADPCM channel. */
+ ulResult = Oct6100ApiWriteAdpcmChanStructs( f_pApiInstance, f_pAdpcmChanOpen, usAdpcmMemIndex, usTsiMemIndex, usInputTsstIndex, usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the ADPCM channel entry in the API list. */
+ ulResult = Oct6100ApiUpdateAdpcmChanEntry( f_pApiInstance, f_pAdpcmChanOpen, usAdpcmChanIndex, usAdpcmMemIndex, usTsiMemIndex, usInputTsstIndex, usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckAdpcmChanParams
+
+Description: Checks the user's ADPCM 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_pAdpcmChanOpen Pointer to ADPCM channel open configuration structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckAdpcmChanParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen )
+{
+ UINT32 ulResult;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxAdpcmChannels == 0 )
+ return cOCT6100_ERR_ADPCM_CHAN_DISABLED;
+
+ if ( f_pAdpcmChanOpen->pulChanHndl == NULL )
+ return cOCT6100_ERR_ADPCM_CHAN_INVALID_HANDLE;
+
+ /* Check the input TDM streams, timeslots component for errors. */
+ if ( f_pAdpcmChanOpen->ulInputNumTssts != 1 &&
+ f_pAdpcmChanOpen->ulInputNumTssts != 2 )
+ return cOCT6100_ERR_ADPCM_CHAN_INPUT_NUM_TSSTS;
+
+ ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
+ f_pAdpcmChanOpen->ulInputNumTssts,
+ f_pAdpcmChanOpen->ulInputTimeslot,
+ f_pAdpcmChanOpen->ulInputStream,
+ cOCT6100_INPUT_TSST );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
+ {
+ return cOCT6100_ERR_ADPCM_CHAN_INPUT_TIMESLOT;
+ }
+ else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
+ {
+ return cOCT6100_ERR_ADPCM_CHAN_INPUT_STREAM;
+ }
+ else
+ {
+ return ulResult;
+ }
+ }
+
+ if( f_pAdpcmChanOpen->ulInputPcmLaw != cOCT6100_PCM_U_LAW &&
+ f_pAdpcmChanOpen->ulInputPcmLaw != cOCT6100_PCM_A_LAW )
+ return cOCT6100_ERR_ADPCM_CHAN_INPUT_PCM_LAW;
+
+ /* Check the output TDM streams, timeslots component for errors. */
+ if ( f_pAdpcmChanOpen->ulOutputNumTssts != 1 &&
+ f_pAdpcmChanOpen->ulOutputNumTssts != 2 )
+ return cOCT6100_ERR_ADPCM_CHAN_OUTPUT_NUM_TSSTS;
+
+ ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
+ f_pAdpcmChanOpen->ulOutputNumTssts,
+ f_pAdpcmChanOpen->ulOutputTimeslot,
+ f_pAdpcmChanOpen->ulOutputStream,
+ cOCT6100_OUTPUT_TSST );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
+ {
+ return cOCT6100_ERR_ADPCM_CHAN_OUTPUT_TIMESLOT;
+ }
+ else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
+ {
+ return cOCT6100_ERR_ADPCM_CHAN_OUTPUT_STREAM;
+ }
+ else
+ {
+ return ulResult;
+ }
+ }
+ if( f_pAdpcmChanOpen->ulOutputPcmLaw != cOCT6100_PCM_U_LAW &&
+ f_pAdpcmChanOpen->ulOutputPcmLaw != cOCT6100_PCM_A_LAW )
+ return cOCT6100_ERR_ADPCM_CHAN_OUTPUT_PCM_LAW;
+
+ /* Now, check the channel mode. */
+ if ( f_pAdpcmChanOpen->ulChanMode != cOCT6100_ADPCM_ENCODING &&
+ f_pAdpcmChanOpen->ulChanMode != cOCT6100_ADPCM_DECODING )
+ return cOCT6100_ERR_ADPCM_CHAN_MODE;
+
+ if ( f_pAdpcmChanOpen->ulChanMode == cOCT6100_ADPCM_ENCODING )
+ {
+ /* Check the encoding rate. */
+ if ( ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G711_64KBPS ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G726_40KBPS ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G726_32KBPS ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G726_24KBPS ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G726_16KBPS ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_40KBPS_4_1 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_40KBPS_3_2 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_40KBPS_2_3 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_32KBPS_4_0 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_32KBPS_3_1 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_32KBPS_2_2 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_24KBPS_3_0 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_24KBPS_2_1 ) &&
+ ( f_pAdpcmChanOpen->ulEncodingRate != cOCT6100_G727_16KBPS_2_0 ) )
+ return cOCT6100_ERR_ADPCM_CHAN_ENCODING_RATE;
+ }
+ else /* if ( f_pAdpcmChanOpen->ulChanMode != cOCT6100_ADPCM_DECODING ) */
+ {
+ /* Check the decoding rate. */
+ if ( f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G711_64KBPS &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G726_40KBPS &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G726_32KBPS &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G726_24KBPS &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G726_16KBPS &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G726_ENCODED &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G711_G726_ENCODED &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G727_2C_ENCODED &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G727_3C_ENCODED &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G727_4C_ENCODED &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G711_G727_2C_ENCODED &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G711_G727_3C_ENCODED &&
+ f_pAdpcmChanOpen->ulDecodingRate != cOCT6100_G711_G727_4C_ENCODED )
+ return cOCT6100_ERR_ADPCM_CHAN_DECODING_RATE;
+
+ /* Make sure that two timeslots are allocated if PCM-ECHO encoded is selected. */
+ if ( (f_pAdpcmChanOpen->ulDecodingRate == cOCT6100_G711_G726_ENCODED ||
+ f_pAdpcmChanOpen->ulDecodingRate == cOCT6100_G711_G727_2C_ENCODED ||
+ f_pAdpcmChanOpen->ulDecodingRate == cOCT6100_G711_G727_3C_ENCODED ||
+ f_pAdpcmChanOpen->ulDecodingRate == cOCT6100_G711_G727_4C_ENCODED ) &&
+ f_pAdpcmChanOpen->ulInputNumTssts != 2 )
+ return cOCT6100_ERR_ADPCM_CHAN_INCOMPATIBLE_NUM_TSSTS;
+ }
+
+ /* Check the nibble position. */
+ if ( f_pAdpcmChanOpen->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_LOW_BITS &&
+ f_pAdpcmChanOpen->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_HIGH_BITS )
+ return cOCT6100_ERR_ADPCM_CHAN_ADPCM_NIBBLE_POSITION;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveAdpcmChanResources
+
+Description: Reserves all resources needed for the new ADPCM 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_pAdpcmChanOpen Pointer to ADPCM channel configuration structure.
+f_pusAdpcmChanIndex Allocated entry in ADPCM channel list.
+f_pusAdpcmMemIndex Allocated entry in the ADPCM control memory.
+f_pusTsiMemIndex Allocated entry in the TSI chariot memory.
+f_pusInputTsstIndex TSST memory index of the input samples.
+f_pusOutputTsstIndex TSST memory index of the output samples.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveAdpcmChanResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen,
+ OUT PUINT16 f_pusAdpcmChanIndex,
+ OUT PUINT16 f_pusAdpcmMemIndex,
+ OUT PUINT16 f_pusTsiMemIndex,
+ OUT PUINT16 f_pusInputTsstIndex,
+ OUT PUINT16 f_pusOutputTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT32 ulResult;
+ UINT32 ulTempVar;
+ BOOL fAdpcmChanEntry = FALSE;
+ BOOL fAdpcmMemEntry = FALSE;
+ BOOL fTsiMemEntry = FALSE;
+ BOOL fInputTsst = FALSE;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Reserve an entry in the ADPCM channel list. */
+ ulResult = Oct6100ApiReserveAdpcmChanEntry( f_pApiInstance, f_pusAdpcmChanIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fAdpcmChanEntry = TRUE;
+
+ /* Find a TSI memory entry.*/
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, f_pusTsiMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fTsiMemEntry = TRUE;
+
+ /* Find a conversion memory entry. */
+ ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, f_pusAdpcmMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fAdpcmMemEntry = TRUE;
+
+ /* Reserve the input TSST entry. */
+ ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
+ f_pAdpcmChanOpen->ulInputTimeslot,
+ f_pAdpcmChanOpen->ulInputStream,
+ f_pAdpcmChanOpen->ulInputNumTssts,
+ cOCT6100_INPUT_TSST,
+ f_pusInputTsstIndex,
+ NULL );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fInputTsst = TRUE;
+
+ /* Reserve the output TSST entry. */
+ ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
+ f_pAdpcmChanOpen->ulOutputTimeslot,
+ f_pAdpcmChanOpen->ulOutputStream,
+ f_pAdpcmChanOpen->ulOutputNumTssts,
+ cOCT6100_OUTPUT_TSST,
+ f_pusOutputTsstIndex,
+ NULL );
+ }
+ }
+ }
+ else
+ {
+ /* Return an error other than a fatal error. */
+ ulResult = cOCT6100_ERR_ADPCM_CHAN_NO_MORE_TSI_AVAILABLE;
+ }
+ }
+
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if( fAdpcmChanEntry == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseAdpcmChanEntry( f_pApiInstance, *f_pusAdpcmChanIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if( fTsiMemEntry == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, *f_pusTsiMemIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if( fAdpcmMemEntry == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, *f_pusAdpcmMemIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if( fInputTsst == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
+ f_pAdpcmChanOpen->ulInputTimeslot,
+ f_pAdpcmChanOpen->ulInputStream,
+ f_pAdpcmChanOpen->ulInputNumTssts,
+ cOCT6100_INPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ return ulResult;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteAdpcmChanStructs
+
+Description: Performs all the required structure writes to configure the
+ new ADPCM 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_pAdpcmChanOpen Pointer to ADPCM channel configuration structure.
+f_pusAdpcmChanIndex Allocated entry in ADPCM channel list.
+f_pusAdpcmMemIndex Allocated entry in the ADPCM control memory.
+f_pusTsiMemIndex Allocated entry in the TSI chariot memory.
+f_pusInputTsstIndex TSST memory index of the input samples.
+f_pusOutputTsstIndex TSST memory index of the output samples.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiWriteAdpcmChanStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen,
+ IN UINT16 f_usAdpcmMemIndex,
+ IN UINT16 f_usTsiMemIndex,
+ IN UINT16 f_usInputTsstIndex,
+ IN UINT16 f_usOutputTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+ UINT32 ulCompType = 0;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*------------------------------------------------------------------------------*/
+ /* Configure the TSST control memory. */
+
+ /* Set the input TSST control entry. */
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ f_usInputTsstIndex,
+ f_usTsiMemIndex,
+ f_pAdpcmChanOpen->ulInputPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Set the output TSST control entry. */
+ ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
+ f_usOutputTsstIndex,
+ f_pAdpcmChanOpen->ulAdpcmNibblePosition,
+ f_pAdpcmChanOpen->ulOutputNumTssts,
+ f_usTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+
+ /*------------------------------------------------------------------------------*/
+ /* Configure the ADPCM memory. */
+
+ if ( f_pAdpcmChanOpen->ulChanMode == cOCT6100_ADPCM_ENCODING )
+ {
+ switch( f_pAdpcmChanOpen->ulEncodingRate )
+ {
+ case cOCT6100_G711_64KBPS:
+
+ if ( f_pAdpcmChanOpen->ulOutputPcmLaw == cOCT6100_PCM_U_LAW )
+ ulCompType = 0x4;
+ else /* if ( f_pAdpcmChanOpen->ulOutputPcmLaw != cOCT6100_PCM_U_LAW ) */
+ ulCompType = 0x5;
+ break;
+ case cOCT6100_G726_40KBPS: ulCompType = 0x3; break;
+ case cOCT6100_G726_32KBPS: ulCompType = 0x2; break;
+ case cOCT6100_G726_24KBPS: ulCompType = 0x1; break;
+ case cOCT6100_G726_16KBPS: ulCompType = 0x0; break;
+ case cOCT6100_G727_40KBPS_4_1: ulCompType = 0xD; break;
+ case cOCT6100_G727_40KBPS_3_2: ulCompType = 0xA; break;
+ case cOCT6100_G727_40KBPS_2_3: ulCompType = 0x6; break;
+ case cOCT6100_G727_32KBPS_4_0: ulCompType = 0xE; break;
+ case cOCT6100_G727_32KBPS_3_1: ulCompType = 0xB; break;
+ case cOCT6100_G727_32KBPS_2_2: ulCompType = 0x7; break;
+ case cOCT6100_G727_24KBPS_3_0: ulCompType = 0xC; break;
+ case cOCT6100_G727_24KBPS_2_1: ulCompType = 0x8; break;
+ case cOCT6100_G727_16KBPS_2_0: ulCompType = 0x9; break;
+ }
+
+ ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
+ f_usAdpcmMemIndex,
+ ulCompType,
+ f_usTsiMemIndex,
+ FALSE,
+ f_pAdpcmChanOpen->ulAdpcmNibblePosition,
+ cOCT6100_INVALID_INDEX,
+ cOCT6100_INVALID_VALUE,
+ cOCT6100_INVALID_VALUE );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ else /* if ( f_pAdpcmChanOpen->ulChanMode != cOCT6100_ADPCM_DECODING ) */
+ {
+ switch( f_pAdpcmChanOpen->ulDecodingRate )
+ {
+ case cOCT6100_G711_64KBPS: ulCompType = 0x8; break;
+ case cOCT6100_G726_40KBPS: ulCompType = 0x3; break;
+ case cOCT6100_G726_32KBPS: ulCompType = 0x2; break;
+ case cOCT6100_G726_24KBPS: ulCompType = 0x1; break;
+ case cOCT6100_G726_16KBPS: ulCompType = 0x0; break;
+ case cOCT6100_G727_2C_ENCODED: ulCompType = 0x4; break;
+ case cOCT6100_G727_3C_ENCODED: ulCompType = 0x5; break;
+ case cOCT6100_G727_4C_ENCODED: ulCompType = 0x6; break;
+ case cOCT6100_G726_ENCODED: ulCompType = 0x9; break;
+ case cOCT6100_G711_G726_ENCODED: ulCompType = 0xA; break;
+ case cOCT6100_G711_G727_2C_ENCODED: ulCompType = 0xC; break;
+ case cOCT6100_G711_G727_3C_ENCODED: ulCompType = 0xD; break;
+ case cOCT6100_G711_G727_4C_ENCODED: ulCompType = 0xE; break;
+ }
+
+ ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
+ f_usAdpcmMemIndex,
+ ulCompType,
+ f_usTsiMemIndex,
+ f_pAdpcmChanOpen->ulOutputPcmLaw,
+ f_pAdpcmChanOpen->ulAdpcmNibblePosition );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateAdpcmChanEntry
+
+Description: Updates the new ADPCM channel in the ADPCM 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_pAdpcmChanOpen Pointer to ADPCM channel open configuration structure.
+f_usAdpcmChanIndex Allocated entry in the ADPCM channel list.
+f_usAdpcmMemIndex Allocated entry in ADPCM memory.
+f_usTsiMemIndex Allocated entry in TSI chariot memory.
+f_usInputTsstIndex TSST control memory index of the input TSST.
+f_usOutputTsstIndex TSST control memory index of the output TSST.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateAdpcmChanEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_ADPCM_CHAN_OPEN f_pAdpcmChanOpen,
+ IN UINT16 f_usAdpcmChanIndex,
+ IN UINT16 f_usAdpcmMemIndex,
+ IN UINT16 f_usTsiMemIndex,
+ IN UINT16 f_usInputTsstIndex,
+ IN UINT16 f_usOutputTsstIndex )
+{
+ tPOCT6100_API_ADPCM_CHAN pAdpcmChanEntry;
+
+ /*------------------------------------------------------------------------------*/
+ /* Obtain a pointer to the new ADPCM channel's list entry. */
+
+ mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( f_pApiInstance->pSharedInfo, pAdpcmChanEntry, f_usAdpcmChanIndex )
+
+ /* Copy the buffer's configuration and allocated resources. */
+ pAdpcmChanEntry->usInputTimeslot = (UINT16)( f_pAdpcmChanOpen->ulInputTimeslot & 0xFFFF );
+ pAdpcmChanEntry->usInputStream = (UINT16)( f_pAdpcmChanOpen->ulInputStream & 0xFFFF );
+ pAdpcmChanEntry->byInputNumTssts = (UINT8)( f_pAdpcmChanOpen->ulInputNumTssts & 0xFF );
+ pAdpcmChanEntry->byInputPcmLaw = (UINT8)( f_pAdpcmChanOpen->ulInputPcmLaw & 0xFF );
+
+ pAdpcmChanEntry->usOutputTimeslot = (UINT16)( f_pAdpcmChanOpen->ulOutputTimeslot & 0xFFFF );
+ pAdpcmChanEntry->usOutputStream = (UINT16)( f_pAdpcmChanOpen->ulOutputStream & 0xFFFF );
+ pAdpcmChanEntry->byOutputNumTssts = (UINT8)( f_pAdpcmChanOpen->ulOutputNumTssts & 0xFF );
+ pAdpcmChanEntry->byOutputPcmLaw = (UINT8)( f_pAdpcmChanOpen->ulOutputPcmLaw & 0xFF );
+
+ /* Store hardware related information. */
+ pAdpcmChanEntry->usTsiMemIndex = f_usTsiMemIndex;
+ pAdpcmChanEntry->usAdpcmMemIndex = f_usAdpcmMemIndex;
+ pAdpcmChanEntry->usInputTsstIndex = f_usInputTsstIndex;
+ pAdpcmChanEntry->usOutputTsstIndex = f_usOutputTsstIndex;
+
+ /* Form handle returned to user. */
+ *f_pAdpcmChanOpen->pulChanHndl = cOCT6100_HNDL_TAG_ADPCM_CHANNEL | (pAdpcmChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usAdpcmChanIndex;
+
+ /* Finally, mark the ADPCM channel as opened. */
+ pAdpcmChanEntry->fReserved = TRUE;
+
+ /* Increment the number of ADPCM channel opened. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberAdpcmChans++;
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100AdpcmChanCloseSer
+
+Description: Closes an ADPCM 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_pAdpcmChanClose Pointer to ADPCM channel close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100AdpcmChanCloseSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose )
+{
+ UINT16 usAdpcmChanIndex;
+ UINT16 usTsiMemIndex;
+ UINT16 usAdpcmMemIndex;
+ UINT16 usInputTsstIndex;
+ UINT16 usOutputTsstIndex;
+ UINT32 ulResult;
+
+ /* Verify that all the parameters given match the state of the API. */
+ ulResult = Oct6100ApiAssertAdpcmChanParams( f_pApiInstance, f_pAdpcmChanClose, &usAdpcmChanIndex, &usAdpcmMemIndex, &usTsiMemIndex, &usInputTsstIndex, &usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the ADPCM channel. */
+ ulResult = Oct6100ApiInvalidateAdpcmChanStructs( f_pApiInstance, usAdpcmMemIndex, usInputTsstIndex, usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the ADPCM channel. */
+ ulResult = Oct6100ApiReleaseAdpcmChanResources( f_pApiInstance, usAdpcmChanIndex, usAdpcmMemIndex, usTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Invalidate the handle. */
+ f_pAdpcmChanClose->ulChanHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiAssertAdpcmChanParams
+
+Description: Validate the handle given by the user and verify the state of
+ the ADPCM channel about to be closed.
+ Also return all required information to deactivate 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_pAdpcmChanClose Pointer to ADPCM channel close structure.
+f_pusAdpcmChanIndex Index of the ADPCM channel structure in the API list.
+f_pusAdpcmMemIndex Index of the ADPCM memory structure in the API list.
+f_pusTsiMemIndex Index of the TSI chariot memory used for this channel.
+f_pusInputTsstIndex Index of the input entry in the TSST control memory.
+f_pusOutputTsstIndex Index of the output entry in the TSST control memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiAssertAdpcmChanParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_ADPCM_CHAN_CLOSE f_pAdpcmChanClose,
+ OUT PUINT16 f_pusAdpcmChanIndex,
+ OUT PUINT16 f_pusAdpcmMemIndex,
+ OUT PUINT16 f_pusTsiMemIndex,
+ OUT PUINT16 f_pusInputTsstIndex,
+ OUT PUINT16 f_pusOutputTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_ADPCM_CHAN pAdpcmChanEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check the provided handle. */
+ if ( (f_pAdpcmChanClose->ulChanHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_ADPCM_CHANNEL )
+ return cOCT6100_ERR_ADPCM_CHAN_INVALID_HANDLE;
+
+ *f_pusAdpcmChanIndex = (UINT16)( f_pAdpcmChanClose->ulChanHndl & cOCT6100_HNDL_INDEX_MASK );
+
+ if ( *f_pusAdpcmChanIndex >= pSharedInfo->ChipConfig.usMaxAdpcmChannels )
+ return cOCT6100_ERR_ADPCM_CHAN_INVALID_HANDLE;
+
+ /*------------------------------------------------------------------------------*/
+ /* Get a pointer to the channel's list entry. */
+
+ mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( pSharedInfo, pAdpcmChanEntry, *f_pusAdpcmChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = (f_pAdpcmChanClose->ulChanHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pAdpcmChanEntry->fReserved != TRUE )
+ return cOCT6100_ERR_ADPCM_CHAN_NOT_OPEN;
+ if ( ulEntryOpenCnt != pAdpcmChanEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_ADPCM_CHAN_INVALID_HANDLE;
+
+ /* Return info needed to close the channel and release all resources. */
+ *f_pusInputTsstIndex = pAdpcmChanEntry->usInputTsstIndex;
+ *f_pusOutputTsstIndex = pAdpcmChanEntry->usOutputTsstIndex;
+ *f_pusTsiMemIndex = pAdpcmChanEntry->usTsiMemIndex;
+ *f_pusAdpcmMemIndex = pAdpcmChanEntry->usAdpcmMemIndex;
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiInvalidateAdpcmChanStructs
+
+Description: Closes an ADPCM 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_usAdpcmMemIndex Index of the ADPCM memory.
+f_usInputTsstIndex Index of the input entry in the TSST control memory.
+f_usOutputTsstIndex Index of the output entry in the TSST control memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiInvalidateAdpcmChanStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usAdpcmMemIndex,
+ IN UINT16 f_usInputTsstIndex,
+ IN UINT16 f_usOutputTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*------------------------------------------------------------------------------*/
+ /* Deactivate the TSST control memory. */
+
+ /* Set the input TSST control entry to unused. */
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usInputTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = 0x0000;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Set the output TSST control entry to unused. */
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usOutputTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = 0x0000;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+
+ /*------------------------------------------------------------------------------*/
+ /* Clear the ADPCM memory. */
+
+ ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, f_usAdpcmMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseAdpcmChanResources
+
+Description: Release and clear the API entry associated to the ADPCM 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_ulAdpcmChanIndex Index of the ADPCM channel in the API list.
+f_usAdpcmMemIndex Index of the ADPCM memory used.
+f_usTsiMemIndex Index of the TSI memory used.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseAdpcmChanResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usAdpcmChanIndex,
+ IN UINT16 f_usAdpcmMemIndex,
+ IN UINT16 f_usTsiMemIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_ADPCM_CHAN pAdpcmChanEntry;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( pSharedInfo, pAdpcmChanEntry, f_usAdpcmChanIndex );
+
+ /*------------------------------------------------------------------------------*/
+ /* Release all resources associated with ADPCM channel. */
+
+ /* Release the entry in the ADPCM channel list. */
+ ulResult = Oct6100ApiReleaseAdpcmChanEntry( f_pApiInstance, f_usAdpcmChanIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, f_usAdpcmMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, f_usTsiMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Release the input TSST entry. */
+ ulResult = Oct6100ApiReleaseTsst(
+ f_pApiInstance,
+ pAdpcmChanEntry->usInputTimeslot,
+ pAdpcmChanEntry->usInputStream,
+ pAdpcmChanEntry->byInputNumTssts,
+ cOCT6100_INPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Release the output TSST entry. */
+ ulResult = Oct6100ApiReleaseTsst(
+ f_pApiInstance,
+ pAdpcmChanEntry->usOutputTimeslot,
+ pAdpcmChanEntry->usOutputStream,
+ pAdpcmChanEntry->byOutputNumTssts,
+ cOCT6100_OUTPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ }
+ }
+ }
+ }
+
+ /* Check if an error occured while releasing the reserved resources. */
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult >= cOCT6100_ERR_FATAL )
+ return ulResult;
+ else
+ return cOCT6100_ERR_FATAL_4A;
+ }
+
+ /*------------------------------------------------------------------------------*/
+
+
+ /*------------------------------------------------------------------------------*/
+ /* Update the ADPCM channel's list entry. */
+
+ /* Mark the channel as closed. */
+ pAdpcmChanEntry->fReserved = FALSE;
+ pAdpcmChanEntry->byEntryOpenCnt++;
+
+ /* Decrement the number of ADPCM channels opened. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberAdpcmChans--;
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveAdpcmChanEntry
+
+Description: Reserves one of the ADPCM 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_pusAdpcmChanIndex Resulting index reserved in the ADPCM channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveAdpcmChanEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusAdpcmChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pAdpcmChanAlloc;
+ UINT32 ulResult;
+ UINT32 ulAdpcmChanIndex;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_ADPCM_CHAN_ALLOC_PNT( pSharedInfo, pAdpcmChanAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pAdpcmChanAlloc, &ulAdpcmChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_ADPCM_CHAN_ALL_ADPCM_CHAN_ARE_OPENED;
+ else
+ return cOCT6100_ERR_FATAL_BE;
+ }
+
+ *f_pusAdpcmChanIndex = (UINT16)( ulAdpcmChanIndex & 0xFFFF );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseAdpcmChanEntry
+
+Description: Releases the specified ADPCM 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_usAdpcmChanIndex Index reserved in the ADPCM channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseAdpcmChanEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usAdpcmChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pAdpcmChanAlloc;
+ UINT32 ulResult;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_ADPCM_CHAN_ALLOC_PNT( pSharedInfo, pAdpcmChanAlloc )
+
+ ulResult = OctapiLlmAllocDealloc( pAdpcmChanAlloc, f_usAdpcmChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ return cOCT6100_ERR_FATAL_BF;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c
new file mode 100644
index 0000000..b51ebfd
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c
@@ -0,0 +1,13431 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+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: Oct6100ChannelClose
+
+Description: This function closes an echo canceller 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_pChannelClose Pointer to channel close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelCloseDef(
+ IN OUT tPOCT6100_CHANNEL_CLOSE f_pChannelClose )
+{
+ f_pChannelClose->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100ChannelClose(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose )
+{
+ 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 = Oct6100ChannelCloseSer( f_pApiInstance, f_pChannelClose );
+ }
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+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: Oct6100ChannelCreateBiDir
+
+Description: This function creates a bidirectional channel using two standard
+ 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_pChannelCreateBiDir Pointer to channel create BiDir structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelCreateBiDirDef(
+ IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir )
+{
+ f_pChannelCreateBiDir->pulBiDirChannelHndl = NULL;
+
+ f_pChannelCreateBiDir->ulFirstChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pChannelCreateBiDir->ulSecondChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100ChannelCreateBiDir(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir )
+{
+ 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 = Oct6100ChannelCreateBiDirSer( f_pApiInstance, f_pChannelCreateBiDir );
+ }
+ 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: Oct6100ChannelDestroyBiDir
+
+Description: This function destroys a bidirectional 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_pChannelDestroyBiDir Pointer to channel destroy BiDir structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelDestroyBiDirDef(
+ IN OUT tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir )
+{
+ f_pChannelDestroyBiDir->ulBiDirChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100ChannelDestroyBiDir(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir )
+{
+ 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 = Oct6100ChannelDestroyBiDirSer( f_pApiInstance, f_pChannelDestroyBiDir );
+ }
+ 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: Oct6100ChannelBroadcastTsstAdd
+
+Description: This function adds a TSST to one of the two output ports of a channel.
+ This TSST can never be modified by a call to Oct6100ChannelModify.
+
+-------------------------------------------------------------------------------
+| 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_pChannelBroadcastTsstAdd Pointer to the an Add Broadcast TSST structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelBroadcastTsstAddDef(
+ tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelBroadcastTsstAdd )
+{
+ f_pChannelBroadcastTsstAdd->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ f_pChannelBroadcastTsstAdd->ulPort = cOCT6100_INVALID_PORT;
+ f_pChannelBroadcastTsstAdd->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
+ f_pChannelBroadcastTsstAdd->ulStream = cOCT6100_INVALID_STREAM;
+
+ return cOCT6100_ERR_OK;
+
+}
+
+UINT32 Oct6100ChannelBroadcastTsstAdd(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelBroadcastTsstAdd )
+{
+ 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 = Oct6100ChannelBroadcastTsstAddSer( f_pApiInstance, f_pChannelBroadcastTsstAdd );
+ }
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+UINT32 Oct6100ChannelBroadcastTsstRemove(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelBroadcastTsstRemove )
+{
+ 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 = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, f_pChannelBroadcastTsstRemove );
+ }
+ 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: Oct6100ChannelGetStats
+
+Description: This function retrieves all the config and stats related to the channel
+ 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_pChannelStats Pointer to a tOCT6100_CHANNEL_STATS structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelGetStatsDef(
+ IN OUT tPOCT6100_CHANNEL_STATS f_pChannelStats )
+{
+ f_pChannelStats->fResetStats = FALSE;
+
+ f_pChannelStats->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pChannelStats->ulUserChanId = cOCT6100_INVALID_STAT;
+ f_pChannelStats->ulEchoOperationMode = cOCT6100_INVALID_STAT;
+ f_pChannelStats->fEnableToneDisabler = FALSE;
+ f_pChannelStats->ulMutePortsMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
+ f_pChannelStats->fEnableExtToneDetection = FALSE;
+
+ /* VQE configuration.*/
+ f_pChannelStats->VqeConfig.fEnableNlp = FALSE;
+ f_pChannelStats->VqeConfig.fEnableTailDisplacement = FALSE;
+ f_pChannelStats->VqeConfig.ulTailDisplacement = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.ulTailLength = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->VqeConfig.fSinDcOffsetRemoval = FALSE;
+ f_pChannelStats->VqeConfig.fRinDcOffsetRemoval = FALSE;
+ f_pChannelStats->VqeConfig.fRinLevelControl = FALSE;
+ f_pChannelStats->VqeConfig.fSoutLevelControl = FALSE;
+ f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = FALSE;
+ f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = FALSE;
+ f_pChannelStats->VqeConfig.fRinHighLevelCompensation = FALSE;
+ f_pChannelStats->VqeConfig.fAcousticEcho = FALSE;
+ f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE;
+ f_pChannelStats->VqeConfig.fDtmfToneRemoval = FALSE;
+
+ f_pChannelStats->VqeConfig.fSoutNoiseBleaching = FALSE;
+ f_pChannelStats->VqeConfig.fSoutConferencingNoiseReduction = FALSE;
+
+ f_pChannelStats->VqeConfig.ulComfortNoiseMode = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.ulNonLinearityBehaviorA = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.ulNonLinearityBehaviorB = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.ulDoubleTalkBehavior = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.lRinLevelControlGainDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.lSoutLevelControlGainDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.lRinAutomaticLevelControlTargetDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.lSoutAutomaticLevelControlTargetDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.lRinHighLevelCompensationThresholdDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.lDefaultErlDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.lAecDefaultErlDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.ulAecTailLength = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.fSoutNaturalListenerEnhancement = FALSE;
+ f_pChannelStats->VqeConfig.fRoutNoiseReduction = FALSE;
+ f_pChannelStats->VqeConfig.lAnrSnrEnhancementDb = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->VqeConfig.ulAnrVoiceNoiseSegregation = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_INVALID_STAT;
+ f_pChannelStats->VqeConfig.fEnableMusicProtection = FALSE;
+ f_pChannelStats->VqeConfig.fIdleCodeDetection = FALSE;
+
+
+
+ /* TDM configuration.*/
+ f_pChannelStats->TdmConfig.ulMaxBroadcastTssts = 0;
+ f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = FALSE;
+ f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = FALSE;
+
+ f_pChannelStats->TdmConfig.ulNumRoutBroadcastTssts = 0;
+ f_pChannelStats->TdmConfig.ulNumSoutBroadcastTssts = 0;
+
+ f_pChannelStats->TdmConfig.ulRinNumTssts = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulSinNumTssts = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulRoutNumTssts = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulSoutNumTssts = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->TdmConfig.ulRinTimeslot = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulRinStream = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulRinPcmLaw = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->TdmConfig.ulSinTimeslot = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulSinStream = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulSinPcmLaw = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->TdmConfig.ulRoutTimeslot = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulRoutStream = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulRoutPcmLaw = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->TdmConfig.pulRoutBroadcastTimeslot = NULL;
+ f_pChannelStats->TdmConfig.pulRoutBroadcastStream = NULL;
+
+ f_pChannelStats->TdmConfig.ulSoutTimeslot = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulSoutStream = cOCT6100_INVALID_STAT;
+ f_pChannelStats->TdmConfig.ulSoutPcmLaw = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->TdmConfig.pulSoutBroadcastTimeslot = NULL;
+ f_pChannelStats->TdmConfig.pulSoutBroadcastStream = NULL;
+
+
+ /* CODEC configuration.*/
+ f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->CodecConfig.ulEncoderPort = cOCT6100_INVALID_STAT;
+ f_pChannelStats->CodecConfig.ulEncodingRate = cOCT6100_INVALID_STAT;
+ f_pChannelStats->CodecConfig.ulDecoderPort = cOCT6100_INVALID_STAT;
+ f_pChannelStats->CodecConfig.ulDecodingRate = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->CodecConfig.fEnableSilenceSuppression = FALSE;
+ f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_STAT;
+ f_pChannelStats->CodecConfig.ulPhase = cOCT6100_INVALID_STAT;
+ f_pChannelStats->CodecConfig.ulPhasingType = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->ulNumEchoPathChanges = cOCT6100_INVALID_STAT;
+ f_pChannelStats->ulToneDisablerStatus = cOCT6100_INVALID_STAT;
+ f_pChannelStats->fEchoCancellerConverged = FALSE;
+ f_pChannelStats->fSinVoiceDetected = FALSE;
+ f_pChannelStats->lCurrentERL = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->ulCurrentEchoDelay = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->lMaxERL = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->ulMaxEchoDelay = cOCT6100_INVALID_STAT;
+
+ f_pChannelStats->lRinLevel = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->lRinAppliedGain = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->lSoutAppliedGain = cOCT6100_INVALID_SIGNED_STAT;
+ f_pChannelStats->lComfortNoiseLevel = cOCT6100_INVALID_SIGNED_STAT;
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100ChannelGetStats(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHANNEL_STATS f_pChannelStats )
+{
+ 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 = Oct6100ApiChannelGetStatsSer( f_pApiInstance, f_pChannelStats );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+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;
+}
+
+/**************************** 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ChannelCloseSer
+
+Description: Closes 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_pChannelClose Pointer to echo cancellation channel close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelCloseSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose )
+{
+ UINT16 usChannelIndex;
+
+
+ UINT32 ulResult;
+
+ /* Verify that all the parameters given match the state of the API. */
+ ulResult = Oct6100ApiAssertChannelParams( f_pApiInstance,
+ f_pChannelClose,
+
+ &usChannelIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the echo cancellation channel. */
+ ulResult = Oct6100ApiInvalidateChannelStructs( f_pApiInstance,
+
+ usChannelIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the echo cancellation channel. */
+ ulResult = Oct6100ApiReleaseChannelResources( f_pApiInstance, usChannelIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Invalidate the handle.*/
+ f_pChannelClose->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiAssertChannelParams
+
+Description: Validate the handle given by the user and verify the state of
+ the channel about 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_pChannelClose Pointer to echo cancellation channel close structure.
+f_pulFpgaChanIndex Pointer to the FPGA channel index associated to this channel.
+f_pusChanIndex Pointer to the index of the channel within the API instance.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiAssertChannelParams(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose,
+
+ IN OUT PUINT16 f_pusChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pChanEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check the provided handle. */
+ if ( (f_pChannelClose->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
+
+ *f_pusChanIndex = (UINT16)( f_pChannelClose->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_pChannelClose->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 if the channel is bound to a bridge. */
+ if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CHANNEL_ACTIVE_DEPENDENCIES;
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiInvalidateChannelStructs
+
+Description: Closes 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_ulFpgaChanIndex Index of the channel within the SCN_PLC FPGA.
+f_usChanIndex Index of the channel within the API instance.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiInvalidateChannelStructs(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+
+ IN UINT16 f_usChanIndex )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tPOCT6100_API_CHANNEL_TDM pTdmConfig;
+ tPOCT6100_API_TSST_ENTRY pTsstEntry;
+ tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
+ UINT32 ulResult;
+ UINT16 usCurrentEntry;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
+
+ /* Obtain local pointer to the TDM configuration of the channel */
+ pTdmConfig = &pChanEntry->TdmConfig;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Deactivate the TSST control memory if used. */
+
+ /* RIN port.*/
+ if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED )
+ {
+ /* Deactivate the TSST entry.*/
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRinTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.usWriteData = 0x0000;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* SIN port.*/
+ if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED )
+ {
+ /* Deactivate the TSST entry.*/
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSinTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.usWriteData = 0x0000;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /*=======================================================================*/
+ /* ROUT port.*/
+
+ if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED )
+ {
+ /* 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;
+ }
+
+ /* Now the broadcast TSST.*/
+ usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
+ while( usCurrentEntry != cOCT6100_INVALID_INDEX )
+ {
+ mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
+
+ /* Deactivate the TSST entry.*/
+ 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;
+
+ /* Move to the next entry.*/
+ usCurrentEntry = pTsstEntry->usNextEntry;
+ }
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* SOUT port.*/
+
+ if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED )
+ {
+ /* 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;
+ }
+
+ /* Now the broadcast TSST.*/
+ usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
+ while( usCurrentEntry != cOCT6100_INVALID_INDEX )
+ {
+ mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
+
+ /* Deactivate the TSST entry.*/
+ 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;
+
+ /* Move to the next entry.*/
+ usCurrentEntry = pTsstEntry->usNextEntry;
+ }
+ /*=======================================================================*/
+
+
+ /*------------------------------------------------------------------------------*/
+ /* Deactivate the ECHO control memory entry.*/
+
+ /* Set the input Echo control entry to unused.*/
+ WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
+ 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 += 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;
+ /*------------------------------------------------------------------------------*/
+
+ /*------------------------------------------------------------------------------*/
+ /* Deactivate the conversion control memories if used. */
+
+ if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Rin/Rout stream conversion memory was used */
+ ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Sin/Sout stream conversion memory was used */
+ ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /*------------------------------------------------------------------------------*/
+
+
+ /*------------------------------------------------------------------------------*/
+ /* Clear the silence copy events if they were created. */
+
+ /* Unmute the Rin port if it was muted. */
+ if ( 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_DF;
+
+ pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ /* Unmute the Sin port if it was muted. */
+ if ( 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_E0;
+
+ pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ /*------------------------------------------------------------------------------*/
+
+ /* Synch all the buffer playout field.*/
+ if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE )
+ {
+ Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
+
+ BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ 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;
+ }
+
+
+
+
+
+ /* Free all resources reserved for extended tone detection.*/
+ if ( pChanEntry->fEnableExtToneDetection == TRUE )
+ {
+ /*------------------------------------------------------------------------------*/
+ /* Deactivate the ECHO control memory entry of the extended channel.*/
+
+ /* Set the input Echo control entry to unused.*/
+ WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usExtToneChanIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
+ 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 += 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;
+ /*------------------------------------------------------------------------------*/
+
+ /*------------------------------------------------------------------------------*/
+ /* Remove the mixer event used to copy the RIN signal to the SIN port of the extended
+ channel.*/
+
+ /* Clear the Copy event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usExtToneMixerIndex * 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;
+
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pChanEntry->usExtToneMixerIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ }
+
+ /*------------------------------------------------------------------------------*/
+ /* Reset PGSP */
+
+ WriteParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
+ WriteParams.usWriteData = 0x0800;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ /*------------------------------------------------------------------------------*/
+ /* Clear the VQE memory. */
+
+ SmearParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst + 0x20;
+ SmearParams.usWriteData = 0x0000;
+ SmearParams.ulWriteLength = 2;
+
+ mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ /*------------------------------------------------------------------------------*/
+ /* Clear the AF information memory. */
+
+ SmearParams.ulWriteAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( pChanEntry->usEchoMemIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
+ SmearParams.usWriteData = 0x0000;
+ SmearParams.ulWriteLength = 12;
+
+ mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseChannelResources
+
+Description: Release and clear the API entry associated to the 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_usChannelIndex Index of the echo cancellation channel in the API list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseChannelResources(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usChannelIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tPOCT6100_API_CHANNEL_TDM pTdmConfig;
+ tPOCT6100_API_TSST_ENTRY pTsstEntry;
+ UINT32 ulResult;
+ UINT16 usCurrentEntry;
+ UINT32 ulTimeslot;
+ UINT32 ulStream;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChannelIndex );
+
+ /* Obtain local pointer to the TDM configurationof the channel */
+ pTdmConfig = &pChanEntry->TdmConfig;
+
+ /* Release the two TSI chariot memory entries.*/
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usRinRoutTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_2;
+
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usSinSoutTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_3;
+
+ /* Now release the ECHO channel and control memory entries.*/
+ ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, f_usChannelIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_4;
+
+ /* Release the conversion resources.*/
+ if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_B9;
+
+ pChanEntry->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_BA;
+
+ pChanEntry->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ /*=========================================================================*/
+ /* Release the TSST control memory entries if any were reserved.*/
+ if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED)
+ {
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ pTdmConfig->usRinTimeslot,
+ pTdmConfig->usRinStream,
+ pTdmConfig->byRinNumTssts,
+ cOCT6100_INPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_5;
+ }
+
+ if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED)
+ {
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ pTdmConfig->usSinTimeslot,
+ pTdmConfig->usSinStream,
+ pTdmConfig->bySinNumTssts,
+ cOCT6100_INPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_6;
+ }
+
+ /*=======================================================================*/
+ /* Release all the TSSTs associated to the ROUT port of this channel. */
+ if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED)
+ {
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ pTdmConfig->usRoutTimeslot,
+ pTdmConfig->usRoutStream,
+ pTdmConfig->byRoutNumTssts,
+ cOCT6100_OUTPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_7;
+ }
+
+ /* Now release the Broadcast TSSTs. */
+ usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
+ while( usCurrentEntry != cOCT6100_INVALID_INDEX )
+ {
+ mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
+
+ ulTimeslot = pTsstEntry->usTsstValue >> 5;
+ ulStream = pTsstEntry->usTsstValue & 0x1F;
+
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ ulTimeslot,
+ ulStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_OUTPUT_TSST,
+ usCurrentEntry );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_8;
+
+ /* Move to the next entry.*/
+ usCurrentEntry = pTsstEntry->usNextEntry;
+
+ /* Invalidate the current entry.*/
+ pTsstEntry->usTsstMemoryIndex = 0xFFFF;
+ pTsstEntry->usTsstValue = 0xFFFF;
+ pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
+ }
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Release all the TSSTs associated to the SOUT port of this channel. */
+ if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED)
+ {
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ pTdmConfig->usSoutTimeslot,
+ pTdmConfig->usSoutStream,
+ pTdmConfig->bySoutNumTssts,
+ cOCT6100_OUTPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_9;
+ }
+
+ /* Now release the Broadcast TSSTs. */
+ usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
+ while( usCurrentEntry != cOCT6100_INVALID_INDEX )
+ {
+ mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
+
+ ulTimeslot = pTsstEntry->usTsstValue >> 5;
+ ulStream = pTsstEntry->usTsstValue & 0x1F;
+
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ ulTimeslot,
+ ulStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_OUTPUT_TSST,
+ usCurrentEntry );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_A;
+
+ /* Move to the next entry.*/
+ usCurrentEntry = pTsstEntry->usNextEntry;
+
+ /* Invalidate the current entry.*/
+ pTsstEntry->usTsstMemoryIndex = 0xFFFF;
+ pTsstEntry->usTsstValue = 0xFFFF;
+ pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
+ }
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
+
+ if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ tPOCT6100_API_PHASING_TSST pPhasingEntry;
+
+ mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, pChanEntry->usPhasingTsstIndex );
+
+ pPhasingEntry->usDependencyCnt--;
+ }
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Release any resources reserved for the extended tone detection.*/
+
+ if ( pChanEntry->fEnableExtToneDetection == TRUE )
+ {
+ tPOCT6100_API_CHANNEL pExtToneChanEntry;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pExtToneChanEntry, pChanEntry->usExtToneChanIndex );
+
+ /* Release the ECHO channel and control memory entries.*/
+ ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, pChanEntry->usExtToneChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_C1;
+
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usExtToneTsiIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_C2;
+
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usExtToneMixerIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_C3;
+
+ /* Now release the channel entry */
+ pExtToneChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
+ pExtToneChanEntry->fReserved = FALSE;
+
+ /* Set the current entry to disable, just in case.*/
+ pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
+ }
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Update the channel's list entry. */
+
+ /* Clear the NLP dword array. */
+ Oct6100UserMemSet( pChanEntry->aulNlpConfDword, 0, sizeof( pChanEntry->aulNlpConfDword ) );
+
+ /* Clear the echo operation mode. */
+ pChanEntry->byEchoOperationMode = cOCT6100_ECHO_OP_MODE_POWER_DOWN;
+
+ /* Mark the channel as closed. */
+ pChanEntry->fReserved = FALSE;
+ pChanEntry->byEntryOpenCnt++;
+
+ /* Decrement 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 TempChanOpen;
+
+ /* Check the user's configuration of the echo cancellation channel for errors. */
+ ulResult = Oct6100ApiCheckChannelModify( f_pApiInstance,
+ f_pChannelModify,
+ &TempChanOpen,
+ &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,
+ &TempChanOpen,
+ 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,
+ &TempChanOpen,
+ usChanIndex,
+ usNewPhasingTsstIndex,
+ fSinSoutCodecActive,
+ fRinRoutCodecActive,
+ usNewRinTsstIndex,
+ usNewSinTsstIndex,
+ usNewRoutTsstIndex,
+ usNewSoutTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ 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
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ChannelBroadcastTsstAddSer
+
+Description: Assign a TSST to one of the 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_pChannelTsstAdd Pointer to TSST assign structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelBroadcastTsstAddSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd )
+{
+ UINT16 usChanIndex;
+ UINT16 usNewTsstIndex;
+ UINT16 usNewTsstEntry;
+ UINT32 ulResult;
+
+ ulResult = Oct6100ApiCheckChanTsstAddParams( f_pApiInstance, f_pChannelTsstAdd, &usChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiReserveTsstAddResources( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, &usNewTsstIndex, &usNewTsstEntry );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiWriteTsstAddStructs( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiUpdateTsstAddChanEntry( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex, usNewTsstEntry );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckChanTsstAddParams
+
+Description: Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_ADD
+ 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_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
+f_pusChanIndex Pointer to a structure used to store the multiple resources indexes.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckChanTsstAddParams(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
+ OUT PUINT16 f_pusChanIndex )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ UINT32 ulResult;
+ UINT32 ulNumTssts = 1;
+ UINT32 ulEntryOpenCnt;
+
+ /* Check the provided handle. */
+ if ( (f_pChannelTsstAdd->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
+
+ *f_pusChanIndex = (UINT16)( f_pChannelTsstAdd->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_pChannelTsstAdd->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_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
+ f_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
+ return cOCT6100_ERR_CHANNEL_TSST_ADD_PORT;
+
+ /* Get the required number of TSST based on the port.*/
+ switch( f_pChannelTsstAdd->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_B;
+ }
+
+ /* Check the validity of the timeslot and stream. */
+ ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
+ ulNumTssts,
+ f_pChannelTsstAdd->ulTimeslot,
+ f_pChannelTsstAdd->ulStream,
+ cOCT6100_OUTPUT_TSST );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
+ {
+ return cOCT6100_ERR_CHANNEL_TSST_ADD_TIMESLOT;
+ }
+ else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
+ {
+ return cOCT6100_ERR_CHANNEL_TSST_ADD_STREAM;
+ }
+ else
+ {
+ return ulResult;
+ }
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveTsstAddResources
+
+Description: Reserve the entry for the new 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_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
+f_usChanIndex Channel index within the API's channel list.
+f_pusNewTsstIndex Pointer to the new TSST index within the API's TSST memory.
+f_pusNewTsstEntry Pointer to the new TSST entry within the API's TSST list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveTsstAddResources(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
+ IN UINT16 f_usChanIndex,
+ OUT PUINT16 f_pusNewTsstIndex,
+ OUT PUINT16 f_pusNewTsstEntry )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ UINT32 ulResult;
+ UINT32 ulNumTssts = 1;
+
+ /*=======================================================================*/
+ /* Get a pointer to the channel's list entry. */
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
+
+ switch( f_pChannelTsstAdd->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_C;
+ }
+
+ /* Reserve the new entry.*/
+ ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
+ f_pChannelTsstAdd->ulTimeslot,
+ f_pChannelTsstAdd->ulStream,
+ ulNumTssts,
+ cOCT6100_OUTPUT_TSST,
+ f_pusNewTsstIndex,
+ f_pusNewTsstEntry );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteTsstAddStructs
+
+Description: Configure the TSST control memory for the new TSST 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_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
+f_usChanIndex Channel index.
+f_usNewTsstIndex Tsst index in the TSST control memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiWriteTsstAddStructs(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
+ IN UINT16 f_usChanIndex,
+ IN UINT16 f_usNewTsstIndex )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult = cOCT6100_ERR_OK;
+ UINT16 usTsiMemIndex;
+ UINT32 ulNumTssts = 1;
+
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*=======================================================================*/
+ /* Get a pointer to the channel's list entry. */
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
+
+ switch( f_pChannelTsstAdd->ulPort )
+ {
+ case cOCT6100_CHANNEL_PORT_ROUT:
+ usTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
+ ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
+ break;
+ case cOCT6100_CHANNEL_PORT_SOUT:
+ usTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
+ ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
+ break;
+ default:
+ return cOCT6100_ERR_FATAL_D;
+ }
+
+
+ /* Write the new entry now.*/
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usNewTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
+ WriteParams.usWriteData |= (UINT16)( pChanEntry->CodecConfig.byAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET );
+ WriteParams.usWriteData |= (UINT16)( (ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET );
+ WriteParams.usWriteData |= (UINT16)( 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: Oct6100ApiUpdateTsstAddChanEntry
+
+Description: Update the associated channel API entry to add the new broacast 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_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
+f_usChanIndex Channel index.
+f_usNewTsstIndex TSST index within the TSST control memory.
+f_usNewTsstEntry TSST entry within the API TSST list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateTsstAddChanEntry(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
+ IN UINT16 f_usChanIndex,
+ IN UINT16 f_usNewTsstIndex,
+ IN UINT16 f_usNewTsstEntry )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tPOCT6100_API_TSST_ENTRY pTsstEntry;
+
+ /*=======================================================================*/
+ /* Get a pointer to the channel's list entry. */
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
+ mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usNewTsstEntry );
+
+ /* Update the channel entry.*/
+ if ( f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
+ {
+ /* Add the new TSST entry to the broadcast list.*/
+ pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
+ pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
+ pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
+
+ /* Modify the first entry pointer.*/
+ pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
+
+ /* Increment the number of broadcast TSST. */
+ pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry++;
+
+ }
+ else /* f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
+ {
+ /* Add the new TSST entry to the broadcast list.*/
+ pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
+ pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
+ pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
+
+ /* Modify the first entry pointer.*/
+ pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
+
+ /* Increment the number of broadcast TSST. */
+ pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry++;
+ }
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ApiChannelGetStatsSer
+
+Description: Serialized function that returns all the stats of 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_pChannelStats Pointer to a channel stats structure.
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiChannelGetStatsSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_STATS f_pChannelStats )
+{
+ tOCT6100_READ_PARAMS ReadParams;
+ tOCT6100_READ_BURST_PARAMS BurstParams;
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_TSST_ENTRY pTsstEntry;
+ UINT32 ulEntryOpenCnt;
+ UINT16 usCurrentEntry;
+ UINT16 usTsstCount;
+ UINT32 ulBaseAddress;
+ UINT32 ulFeatureBytesOffset;
+ UINT32 ulFeatureBitOffset;
+ UINT32 ulFeatureFieldLength;
+ UINT32 ulTempData;
+ UINT32 ulMask;
+ UINT16 usChanIndex;
+ UINT16 ausReadData[ 32 ];
+
+ BYTE byRinEnergyRaw;
+ BYTE bySinEnergyRaw;
+ BYTE bySoutEnergyRaw;
+ INT32 lSoutEnergyIndB;
+ BYTE byCnEnergyRaw;
+ UINT16 usEchoDelayInFrames;
+ UINT16 usErlRaw;
+
+ UINT32 ulResult;
+ UINT16 usReadData;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+ BurstParams.pusReadData = ausReadData;
+
+ ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+ ReadParams.pusReadData = &usReadData;
+
+ /* Check the reset stats flag.*/
+ if ( f_pChannelStats->fResetStats != TRUE && f_pChannelStats->fResetStats != FALSE )
+ return cOCT6100_ERR_CHANNEL_STATS_RESET;
+
+ /* Check the provided handle. */
+ if ( cOCT6100_HNDL_TAG_CHANNEL != (f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) )
+ return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
+
+ usChanIndex = (UINT16)( f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( usChanIndex >= 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, usChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pChannelStats->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 value of the max broadcast tsst.*/
+ if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts > cOCT6100_MAX_TSSTS )
+ return cOCT6100_ERR_CHANNEL_GET_STATS_MAX_BROADCAST_TSST;
+
+ if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts != 0 )
+ {
+ /* Check if memory was allocated by the user for the stream and timeslot values.*/
+ if ( f_pChannelStats->TdmConfig.pulRoutBroadcastTimeslot == NULL )
+ return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_TIMESLOT;
+
+ if ( f_pChannelStats->TdmConfig.pulRoutBroadcastStream == NULL )
+ return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_STREAM;
+
+ if ( f_pChannelStats->TdmConfig.pulSoutBroadcastTimeslot == NULL )
+ return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_TIMESLOT;
+
+ if ( f_pChannelStats->TdmConfig.pulSoutBroadcastStream == NULL )
+ return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_STREAM;
+ }
+
+ /* Copy the general configuration.*/
+ f_pChannelStats->ulUserChanId = pChanEntry->ulUserChanId;
+ f_pChannelStats->ulEchoOperationMode = pChanEntry->byEchoOperationMode;
+ f_pChannelStats->fEnableToneDisabler = pChanEntry->fEnableToneDisabler;
+ f_pChannelStats->ulMutePortsMask = pChanEntry->usMutedPorts;
+ f_pChannelStats->fEnableExtToneDetection = pChanEntry->fEnableExtToneDetection;
+
+
+
+ /* Copy the TDM configuration.*/
+ f_pChannelStats->TdmConfig.ulNumRoutBroadcastTssts = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
+ f_pChannelStats->TdmConfig.ulNumSoutBroadcastTssts = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
+
+ f_pChannelStats->TdmConfig.ulSinNumTssts = pChanEntry->TdmConfig.bySinNumTssts;
+ f_pChannelStats->TdmConfig.ulSinTimeslot = pChanEntry->TdmConfig.usSinTimeslot;
+ f_pChannelStats->TdmConfig.ulSinStream = pChanEntry->TdmConfig.usSinStream;
+ f_pChannelStats->TdmConfig.ulSinPcmLaw = pChanEntry->TdmConfig.bySinPcmLaw;
+
+ f_pChannelStats->TdmConfig.ulSoutNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
+ f_pChannelStats->TdmConfig.ulSoutTimeslot = pChanEntry->TdmConfig.usSoutTimeslot;
+ f_pChannelStats->TdmConfig.ulSoutStream = pChanEntry->TdmConfig.usSoutStream;
+ f_pChannelStats->TdmConfig.ulSoutPcmLaw = pChanEntry->TdmConfig.bySoutPcmLaw;
+
+ /* Copy the SOUT Broadcast TSST into the Stream and timeslot array.*/
+ usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
+ for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
+ {
+ if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_FATAL_F;
+
+ mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
+
+ f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
+ f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
+
+ /* Obtain the index of the next entry.*/
+ usCurrentEntry = pTsstEntry->usNextEntry;
+ }
+
+ /* Check if all Sout Broadcast TSST were returned.*/
+ if ( usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry )
+ {
+ f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = TRUE;
+ }
+ else /* usTsstCount >= pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry */
+ {
+ f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = FALSE;
+ }
+
+ f_pChannelStats->TdmConfig.ulRinNumTssts = pChanEntry->TdmConfig.byRinNumTssts;
+ f_pChannelStats->TdmConfig.ulRinTimeslot = pChanEntry->TdmConfig.usRinTimeslot;
+ f_pChannelStats->TdmConfig.ulRinStream = pChanEntry->TdmConfig.usRinStream;
+ f_pChannelStats->TdmConfig.ulRinPcmLaw = pChanEntry->TdmConfig.byRinPcmLaw;
+
+ f_pChannelStats->TdmConfig.ulRoutNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
+ f_pChannelStats->TdmConfig.ulRoutTimeslot = pChanEntry->TdmConfig.usRoutTimeslot;
+ f_pChannelStats->TdmConfig.ulRoutStream = pChanEntry->TdmConfig.usRoutStream;
+ f_pChannelStats->TdmConfig.ulRoutPcmLaw = pChanEntry->TdmConfig.byRoutPcmLaw;
+
+
+ /* Copy the ROUT Broadcast TSST into the Stream and timeslot array.*/
+ usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
+ for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
+ {
+ if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_FATAL_10;
+
+ mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
+
+ f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
+ f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
+
+ /* Obtain the index of the next entry.*/
+ usCurrentEntry = pTsstEntry->usNextEntry;
+ }
+
+ /* Check if all Rout Broadcast TSST were returned.*/
+ if ( usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry )
+ {
+ f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = TRUE;
+ }
+ else /* usTsstCount >= pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry */
+ {
+ f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = FALSE;
+ }
+
+ /* Copy the VQE configuration.*/
+ f_pChannelStats->VqeConfig.fEnableNlp = pChanEntry->VqeConfig.fEnableNlp;
+ f_pChannelStats->VqeConfig.ulComfortNoiseMode = pChanEntry->VqeConfig.byComfortNoiseMode;
+ f_pChannelStats->VqeConfig.fEnableTailDisplacement = pChanEntry->VqeConfig.fEnableTailDisplacement;
+ if ( pChanEntry->VqeConfig.usTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
+ f_pChannelStats->VqeConfig.ulTailDisplacement = pChanEntry->VqeConfig.usTailDisplacement;
+ else
+ f_pChannelStats->VqeConfig.ulTailDisplacement = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
+
+ if ( pChanEntry->VqeConfig.usTailLength != cOCT6100_AUTO_SELECT_TAIL )
+ f_pChannelStats->VqeConfig.ulTailLength = pChanEntry->VqeConfig.usTailLength;
+ else
+ f_pChannelStats->VqeConfig.ulTailLength = f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
+
+
+
+ f_pChannelStats->VqeConfig.fSinDcOffsetRemoval = pChanEntry->VqeConfig.fSinDcOffsetRemoval;
+ f_pChannelStats->VqeConfig.fRinDcOffsetRemoval = pChanEntry->VqeConfig.fRinDcOffsetRemoval;
+ f_pChannelStats->VqeConfig.fRinLevelControl = pChanEntry->VqeConfig.fRinLevelControl;
+ f_pChannelStats->VqeConfig.fSoutLevelControl = pChanEntry->VqeConfig.fSoutLevelControl;
+ f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = pChanEntry->VqeConfig.fRinAutomaticLevelControl;
+ f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
+ f_pChannelStats->VqeConfig.fRinHighLevelCompensation = pChanEntry->VqeConfig.fRinHighLevelCompensation;
+ f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
+ f_pChannelStats->VqeConfig.fSoutNoiseBleaching = pChanEntry->VqeConfig.fSoutNoiseBleaching;
+ f_pChannelStats->VqeConfig.fSoutConferencingNoiseReduction = pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
+ f_pChannelStats->VqeConfig.lRinLevelControlGainDb = pChanEntry->VqeConfig.chRinLevelControlGainDb;
+ f_pChannelStats->VqeConfig.lSoutLevelControlGainDb = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
+ f_pChannelStats->VqeConfig.lRinAutomaticLevelControlTargetDb = pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
+ f_pChannelStats->VqeConfig.lSoutAutomaticLevelControlTargetDb = pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
+ f_pChannelStats->VqeConfig.lRinHighLevelCompensationThresholdDb = pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
+ f_pChannelStats->VqeConfig.fAcousticEcho = pChanEntry->VqeConfig.fAcousticEcho;
+ f_pChannelStats->VqeConfig.fDtmfToneRemoval = pChanEntry->VqeConfig.fDtmfToneRemoval;
+
+ f_pChannelStats->VqeConfig.lDefaultErlDb = pChanEntry->VqeConfig.chDefaultErlDb;
+ f_pChannelStats->VqeConfig.lAecDefaultErlDb = pChanEntry->VqeConfig.chAecDefaultErlDb;
+ f_pChannelStats->VqeConfig.ulAecTailLength = pChanEntry->VqeConfig.usAecTailLength;
+ f_pChannelStats->VqeConfig.lAnrSnrEnhancementDb = pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
+ f_pChannelStats->VqeConfig.ulAnrVoiceNoiseSegregation = pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
+ f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay = pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
+ f_pChannelStats->VqeConfig.ulNonLinearityBehaviorA = pChanEntry->VqeConfig.byNonLinearityBehaviorA;
+ f_pChannelStats->VqeConfig.ulNonLinearityBehaviorB = pChanEntry->VqeConfig.byNonLinearityBehaviorB;
+ f_pChannelStats->VqeConfig.ulDoubleTalkBehavior = pChanEntry->VqeConfig.byDoubleTalkBehavior;
+ f_pChannelStats->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
+ f_pChannelStats->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
+ f_pChannelStats->VqeConfig.fSoutNaturalListenerEnhancement = pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
+ f_pChannelStats->VqeConfig.fRoutNoiseReduction = pChanEntry->VqeConfig.fRoutNoiseReduction;
+ f_pChannelStats->VqeConfig.fEnableMusicProtection = pChanEntry->VqeConfig.fEnableMusicProtection;
+ f_pChannelStats->VqeConfig.fIdleCodeDetection = pChanEntry->VqeConfig.fIdleCodeDetection;
+
+ /* Copy the CODEC configuration.*/
+ f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = pChanEntry->CodecConfig.byAdpcmNibblePosition;
+
+ f_pChannelStats->CodecConfig.ulEncoderPort = pChanEntry->CodecConfig.byEncoderPort;
+ f_pChannelStats->CodecConfig.ulEncodingRate = pChanEntry->CodecConfig.byEncodingRate;
+
+ f_pChannelStats->CodecConfig.ulDecoderPort = pChanEntry->CodecConfig.byDecoderPort;
+ f_pChannelStats->CodecConfig.ulDecodingRate = pChanEntry->CodecConfig.byDecodingRate;
+
+ f_pChannelStats->CodecConfig.fEnableSilenceSuppression = pChanEntry->CodecConfig.fEnableSilenceSuppression;
+ f_pChannelStats->CodecConfig.ulPhase = pChanEntry->CodecConfig.byPhase;
+ f_pChannelStats->CodecConfig.ulPhasingType = pChanEntry->CodecConfig.byPhasingType;
+
+ if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ tPOCT6100_API_PHASING_TSST pPhasingTsstEntry;
+
+ mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingTsstEntry, pChanEntry->usPhasingTsstIndex );
+
+ f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsstEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pChanEntry->usPhasingTsstIndex;
+ }
+ else
+ {
+ f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
+ }
+
+
+ /* Reset the stats and exit if the reset flag is set.*/
+ if ( f_pChannelStats->fResetStats == TRUE )
+ {
+ pChanEntry->sMaxERLE = cOCT6100_INVALID_SIGNED_STAT_W;
+ pChanEntry->sMaxERL = cOCT6100_INVALID_SIGNED_STAT_W;
+ pChanEntry->usMaxEchoDelay = cOCT6100_INVALID_STAT_W;
+ }
+
+ /*---------------------------------------------------------------------*/
+ /* Update the API internal stats.*/
+
+ BurstParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
+ BurstParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsOfst;
+ BurstParams.ulReadLength = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsSize / 2; /* Length in words.*/
+
+ mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Check if the energy stat are found in the new memory location. */
+ if ( ( pSharedInfo->ImageInfo.fRinEnergyStat == TRUE )
+ && ( pSharedInfo->ImageInfo.fSoutEnergyStat == TRUE ) )
+ {
+ ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.usDwordOffset * 4;
+ ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byBitOffset;
+ ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byFieldSize;
+
+ ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
+ ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
+
+ /* Optimize this access by only reading the word we are interested in. */
+ if ( ulFeatureBitOffset < 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 ( ulFeatureBitOffset < 16 )
+ ulTempData = usReadData;
+ else
+ ulTempData = usReadData << 16;
+
+ /* Clear previous value set in the feature field. */
+ mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
+
+ ulTempData &= ulMask;
+
+ /* Shift to get value. */
+ ulTempData = ulTempData >> ulFeatureBitOffset;
+
+ /* Overwrite value read the old way. */
+ ausReadData[ 0 ] &= 0x00FF;
+ ausReadData[ 0 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
+
+ ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.usDwordOffset * 4;
+ ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byBitOffset;
+ ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byFieldSize;
+
+ ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
+ ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
+
+ /* Optimize this access by only reading the word we are interested in. */
+ if ( ulFeatureBitOffset < 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 ( ulFeatureBitOffset < 16 )
+ ulTempData = usReadData;
+ else
+ ulTempData = usReadData << 16;
+
+ /* Clear previous value set in the feature field. */
+ mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
+
+ ulTempData &= ulMask;
+
+ /* Shift to get value. */
+ ulTempData = ulTempData >> ulFeatureBitOffset;
+
+ /* Overwrite value read the old way. */
+ ausReadData[ 1 ] &= 0x00FF;
+ ausReadData[ 1 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
+ }
+
+ byRinEnergyRaw = (BYTE)(( ausReadData[ 0 ] >> 8 ) & 0xFF);
+ bySinEnergyRaw = (BYTE)(( ausReadData[ 0 ] >> 0 ) & 0xFF);
+ bySoutEnergyRaw = (BYTE)(( ausReadData[ 1 ] >> 8 ) & 0xFF);
+ byCnEnergyRaw = (BYTE)(( ausReadData[ 5 ] >> 8 ) & 0xFF);
+
+ usEchoDelayInFrames = (UINT16)(ausReadData[ 4 ]);
+ usErlRaw = ausReadData[ 2 ];
+
+ pChanEntry->byToneDisablerStatus = (UINT8)(( ausReadData[ 5 ] >> 0 ) & 0xFF);
+ if ( f_pChannelStats->fResetStats == TRUE )
+ {
+ pChanEntry->usNumEchoPathChangesOfst = (UINT16)(ausReadData[ 3 ]);
+ pChanEntry->usNumEchoPathChanges = 0;
+ }
+ else /* if ( f_pChannelStats->fResetStats == FALSE ) */
+ {
+ pChanEntry->usNumEchoPathChanges = (UINT16)( ausReadData[ 3 ] - pChanEntry->usNumEchoPathChangesOfst );
+ }
+
+ pChanEntry->sComfortNoiseLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byCnEnergyRaw ) & 0xFFFF );
+ pChanEntry->sComfortNoiseLevel -= 12;
+ pChanEntry->sRinLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byRinEnergyRaw ) & 0xFFFF );
+ pChanEntry->sRinLevel -= 12;
+ pChanEntry->sSinLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( bySinEnergyRaw ) & 0xFFFF );
+ pChanEntry->sSinLevel -= 12;
+ lSoutEnergyIndB = Oct6100ApiOctFloatToDbEnergyByte( bySoutEnergyRaw );
+ lSoutEnergyIndB -= 12;
+
+ /* Process some stats only if the channel is converged.*/
+ if ( ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY )
+ && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN )
+ && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET ) )
+ {
+ /* Update the current ERL. */
+ pChanEntry->sCurrentERL = (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( usErlRaw ) & 0xFFFF );
+ pChanEntry->sCurrentERLE = (INT16)( ( lSoutEnergyIndB - pChanEntry->sSinLevel ) & 0xFFFF );
+ pChanEntry->usCurrentEchoDelay = (UINT16)( usEchoDelayInFrames / 8 ); /* To convert in msec.*/
+
+ /* Update the max value if required.*/
+ if ( pChanEntry->usCurrentEchoDelay > pChanEntry->usMaxEchoDelay ||
+ pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
+ {
+ pChanEntry->usMaxEchoDelay = pChanEntry->usCurrentEchoDelay;
+ }
+
+ if ( pChanEntry->sCurrentERL > pChanEntry->sMaxERL ||
+ pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
+ {
+ pChanEntry->sMaxERL = pChanEntry->sCurrentERL;
+ }
+
+ if ( pChanEntry->sCurrentERLE > pChanEntry->sMaxERLE ||
+ pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
+ {
+ pChanEntry->sMaxERLE = pChanEntry->sCurrentERLE;
+ }
+ }
+ else
+ {
+ pChanEntry->sCurrentERLE = cOCT6100_INVALID_SIGNED_STAT_W;
+ pChanEntry->sCurrentERL = cOCT6100_INVALID_SIGNED_STAT_W;
+ pChanEntry->usCurrentEchoDelay = cOCT6100_INVALID_STAT_W;
+ }
+
+ if ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
+ {
+ /* Calculate base address for auto level control + high level compensation configuration. */
+ ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
+
+ ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.usDwordOffset * 4;
+ ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byBitOffset;
+ ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byFieldSize;
+
+ ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
+
+ /* Optimize this access by only reading the word we are interested in. */
+ if ( ulFeatureBitOffset < 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 ( ulFeatureBitOffset < 16 )
+ ulTempData = usReadData;
+ else
+ ulTempData = usReadData << 16;
+
+ /* Clear previous value set in the feature field.*/
+ mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
+
+ ulTempData &= ulMask;
+
+ /* Shift to get value. */
+ ulTempData = ulTempData >> ulFeatureBitOffset;
+
+ pChanEntry->sRinAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
+ }
+
+ if ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
+ {
+ /* Calculate base address for auto level control + high level compensation configuration. */
+ ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
+
+ ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.usDwordOffset * 4;
+ ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byBitOffset;
+ ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byFieldSize;
+
+ ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
+
+ /* Optimize this access by only reading the word we are interested in. */
+ if ( ulFeatureBitOffset < 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 ( ulFeatureBitOffset < 16 )
+ ulTempData = usReadData;
+ else
+ ulTempData = usReadData << 16;
+
+ /* Clear previous value set in the feature field. */
+ mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
+
+ ulTempData &= ulMask;
+
+ /* Shift to get value. */
+ ulTempData = ulTempData >> ulFeatureBitOffset;
+
+ pChanEntry->sSoutAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
+ }
+
+ /*---------------------------------------------------------------------*/
+ /* Return the real stats.*/
+
+ f_pChannelStats->ulNumEchoPathChanges = pChanEntry->usNumEchoPathChanges;
+ if ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY )
+ {
+ f_pChannelStats->fEchoCancellerConverged = TRUE;
+ }
+ else
+ {
+ f_pChannelStats->fEchoCancellerConverged = FALSE;
+ }
+ if ( pChanEntry->sCurrentERL == cOCT6100_INVALID_SIGNED_STAT_W )
+ f_pChannelStats->lCurrentERL = cOCT6100_INVALID_SIGNED_STAT;
+ else
+ f_pChannelStats->lCurrentERL = pChanEntry->sCurrentERL;
+
+ if ( pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
+ f_pChannelStats->lMaxERL = cOCT6100_INVALID_SIGNED_STAT;
+ else
+ f_pChannelStats->lMaxERL = pChanEntry->sMaxERL;
+
+ if ( pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
+ f_pChannelStats->ulMaxEchoDelay = cOCT6100_INVALID_STAT;
+ else
+ f_pChannelStats->ulMaxEchoDelay = pChanEntry->usMaxEchoDelay;
+
+ if ( pChanEntry->sRinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
+ f_pChannelStats->lRinLevel = cOCT6100_INVALID_SIGNED_STAT;
+ else
+ f_pChannelStats->lRinLevel = pChanEntry->sRinLevel;
+
+ if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
+ {
+ if ( pChanEntry->sSinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
+ f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
+ else
+ f_pChannelStats->lSinLevel = pChanEntry->sSinLevel;
+ }
+ else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
+ {
+ /* SIN level is not supported in this image. */
+ f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
+ }
+
+ f_pChannelStats->lRinAppliedGain = pChanEntry->VqeConfig.chRinLevelControlGainDb;
+ if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
+ && ( ( pChanEntry->VqeConfig.fRinAutomaticLevelControl == TRUE )
+ || ( pChanEntry->VqeConfig.fRinHighLevelCompensation == TRUE ) ) )
+ {
+ f_pChannelStats->lRinAppliedGain = pChanEntry->sRinAppliedGain;
+ }
+
+ f_pChannelStats->lSoutAppliedGain = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
+ if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
+ && ( pChanEntry->VqeConfig.fSoutAutomaticLevelControl == TRUE ) )
+ {
+ f_pChannelStats->lSoutAppliedGain = pChanEntry->sSoutAppliedGain;
+ }
+
+ if ( pChanEntry->usCurrentEchoDelay == cOCT6100_INVALID_STAT_W )
+ f_pChannelStats->ulCurrentEchoDelay = cOCT6100_INVALID_STAT;
+ else
+ f_pChannelStats->ulCurrentEchoDelay = pChanEntry->usCurrentEchoDelay;
+
+ if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
+ {
+ if ( pChanEntry->sCurrentERLE == cOCT6100_INVALID_SIGNED_STAT_W )
+ f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
+ else
+ f_pChannelStats->lCurrentERLE = pChanEntry->sCurrentERLE;
+ }
+ else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
+ {
+ f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
+ }
+
+ if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
+ {
+ if ( pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
+ f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
+ else
+ f_pChannelStats->lMaxERLE = pChanEntry->sMaxERLE;
+ }
+ else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
+ {
+ f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
+ }
+
+ f_pChannelStats->lComfortNoiseLevel = pChanEntry->sComfortNoiseLevel;
+ f_pChannelStats->ulToneDisablerStatus = pChanEntry->byToneDisablerStatus;
+
+ if ( f_pApiInstance->pSharedInfo->ImageInfo.fSinVoiceDetectedStat == TRUE )
+ {
+ UINT32 ulVoiceDetectedBytesOfst = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.usDwordOffset * 4;
+ UINT32 ulVoiceDetectedBitOfst = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byBitOffset;
+ UINT32 ulVoiceDetectedFieldSize = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byFieldSize;
+
+ /* Set the channel root base address.*/
+ UINT32 ulChannelRootBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( usChanIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst;
+
+ ReadParams.ulReadAddress = ulChannelRootBaseAddress + ulVoiceDetectedBytesOfst;
+
+ /* Optimize this access by only reading the word we are interested in. */
+ if ( ulVoiceDetectedBitOfst < 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 ( ulVoiceDetectedBitOfst < 16 )
+ ulTempData = usReadData;
+ else
+ ulTempData = usReadData << 16;
+
+ mOCT6100_CREATE_FEATURE_MASK( ulVoiceDetectedFieldSize, ulVoiceDetectedBitOfst, &ulMask );
+
+ if ( ( ulTempData & ulMask ) != 0x0 )
+ f_pChannelStats->fSinVoiceDetected = TRUE;
+ else
+ f_pChannelStats->fSinVoiceDetected = FALSE;
+ }
+
+ /*---------------------------------------------------------------------*/
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ApiReserveBiDirChanEntry
+
+Description: Reserves one of the bidirectional 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_pusBiDirChanIndex Resulting index reserved in the bidir channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveBiDirChanEntry(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusBiDirChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pChanAlloc;
+ UINT32 ulResult;
+ UINT32 ulBiDirChanIndex;
+
+ /* Get local pointer to shared portion of the API instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pChanAlloc, &ulBiDirChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_CHANNEL_ALL_BIDIR_CHANNELS_ARE_OPENED;
+ else
+ return cOCT6100_ERR_FATAL_9F;
+ }
+
+ *f_pusBiDirChanIndex = (UINT16)( ulBiDirChanIndex & 0xFFFF );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseBiDirChanEntry
+
+Description: Releases the specified bidirectional 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_ulBiDirChanIndex Bidirectional channel index within the API's Bidir channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseBiDirChanEntry(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulBiDirChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pChanAlloc;
+ UINT32 ulResult;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
+
+ ulResult = OctapiLlmAllocDealloc( pChanAlloc, f_ulBiDirChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ return cOCT6100_ERR_FATAL_A0;
+ }
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+
+
+
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRetrieveNlpConfDword
+
+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
+-------------------------------------------------------------------------------
+f_pApiInstance Pointer to API instance. This memory is used to keep
+ the present state of the chip and all its resources.
+
+f_pChanEntry Pointer to an API channel structure..
+f_ulAddress Address that needs to be modified..
+f_pulConfigDword Pointer to the content stored in the API located at the
+ desired address.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiRetrieveNlpConfDword(
+
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_API_CHANNEL f_pChanEntry,
+ IN UINT32 f_ulAddress,
+ OUT PUINT32 f_pulConfigDword )
+{
+ UINT32 ulResult;
+ UINT32 ulFirstEmptyIndex = 0xFFFFFFFF;
+ UINT32 i;
+
+ /* 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 ];
+ return cOCT6100_ERR_OK;
+ }
+ }
+
+ if ( i == cOCT6100_MAX_NLP_CONF_DWORD && ulFirstEmptyIndex == 0xFFFFFFFF )
+ return cOCT6100_ERR_FATAL_8E;
+
+ /* We did not found any entry, let's create a new entry.*/
+ f_pChanEntry->aulNlpConfDword[ ulFirstEmptyIndex ][ 0 ] = f_ulAddress;
+
+
+ /* Read the DWORD where the field is located.*/
+ ulResult = Oct6100ApiReadDword( f_pApiInstance,
+ f_ulAddress,
+ f_pulConfigDword );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiSaveNlpConfDword
+
+Description: This function stores a configuration Dword within an API channel
+ structure and then writes it into 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.
+
+f_pChanEntry Pointer to an API channel structure..
+f_ulAddress Address that needs to be modified..
+f_pulConfigDword content to be stored in the API located at the
+ desired address.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiSaveNlpConfDword(
+
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_API_CHANNEL f_pChanEntry,
+ IN UINT32 f_ulAddress,
+ IN UINT32 f_ulConfigDword )
+{
+ UINT32 ulResult;
+ UINT32 i;
+
+ /* 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.*/
+ f_pChanEntry->aulNlpConfDword[ i ][ 1 ] = f_ulConfigDword;
+ break;
+ }
+ }
+
+ if ( i == cOCT6100_MAX_NLP_CONF_DWORD )
+ return cOCT6100_ERR_FATAL_8F;
+
+
+ /* Write the config DWORD.*/
+ ulResult = Oct6100ApiWriteDword( f_pApiInstance,
+ f_ulAddress,
+ f_ulConfigDword );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ChannelCreateBiDirSer
+
+Description: Creates a bidirectional 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_pChannelCreateBiDir Pointer to a create bidirectionnal channel structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelCreateBiDirSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir )
+{
+ UINT16 usFirstChanIndex;
+ UINT16 usFirstChanExtraTsiIndex;
+ UINT16 usFirstChanSinCopyEventIndex;
+ UINT16 usFirstChanSoutCopyEventIndex;
+ UINT16 usSecondChanIndex;
+ UINT16 usSecondChanExtraTsiIndex;
+ UINT16 usSecondChanSinCopyEventIndex;
+ UINT16 usSecondChanSoutCopyEventIndex;
+ UINT16 usBiDirChanIndex;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the bidir channel for errors. */
+ ulResult = Oct6100ApiCheckChannelCreateBiDirParams( f_pApiInstance,
+ f_pChannelCreateBiDir,
+ &usFirstChanIndex,
+ &usFirstChanExtraTsiIndex,
+ &usFirstChanSinCopyEventIndex,
+ &usSecondChanIndex,
+ &usSecondChanExtraTsiIndex,
+ &usSecondChanSinCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the bidir channel. */
+ ulResult = Oct6100ApiReserveChannelCreateBiDirResources(f_pApiInstance,
+ &usBiDirChanIndex,
+ &usFirstChanExtraTsiIndex,
+ &usFirstChanSinCopyEventIndex,
+ &usFirstChanSoutCopyEventIndex,
+ &usSecondChanExtraTsiIndex,
+ &usSecondChanSinCopyEventIndex,
+ &usSecondChanSoutCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write all necessary structures to activate the echo cancellation channel. */
+ ulResult = Oct6100ApiWriteChannelCreateBiDirStructs( f_pApiInstance,
+ usFirstChanIndex,
+ usFirstChanExtraTsiIndex,
+ usFirstChanSinCopyEventIndex,
+ usFirstChanSoutCopyEventIndex,
+ usSecondChanIndex,
+ usSecondChanExtraTsiIndex,
+ usSecondChanSinCopyEventIndex,
+ usSecondChanSoutCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the new echo cancellation channels's entry in the ECHO channel list. */
+ ulResult = Oct6100ApiUpdateBiDirChannelEntry( f_pApiInstance,
+ f_pChannelCreateBiDir,
+ usBiDirChanIndex,
+ usFirstChanIndex,
+ usFirstChanExtraTsiIndex,
+ usFirstChanSinCopyEventIndex,
+ usFirstChanSoutCopyEventIndex,
+ usSecondChanIndex,
+ usSecondChanExtraTsiIndex,
+ usSecondChanSinCopyEventIndex,
+ usSecondChanSoutCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckChannelCreateBiDirParams
+
+Description: Checks the user's parameter passed to the create bidirectional channel
+ 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_pChannelCreateBiDir Pointer to a create bidirectionnal channel structure.
+f_pusFirstChanIndex Pointer to the first channel index.
+f_pusFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
+f_pusFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
+f_pusSecondChanIndex Pointer to the second channel index.
+f_pusSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
+f_pusSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckChannelCreateBiDirParams(
+ IN 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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pFirstChanEntry;
+ tPOCT6100_API_CHANNEL pSecondChanEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Obtain shared resources pointer.*/
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* validate the bidirectional channel handle memory.*/
+ if ( f_pChannelCreateBiDir->pulBiDirChannelHndl == NULL )
+ return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
+
+ /* Check if bi-dir channels are activated. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxBiDirChannels == 0 )
+ return cOCT6100_ERR_CHANNEL_BIDIR_DISABLED;
+
+ /*=======================================================================*/
+ /* Verify the first channel handle. */
+
+ if ( (f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
+
+ *f_pusFirstChanIndex = (UINT16)( f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusFirstChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
+ return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
+
+ /* Get a pointer to the channel's list entry. */
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, *f_pusFirstChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulFirstChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pFirstChanEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CHANNEL_NOT_OPEN;
+ if ( ulEntryOpenCnt != pFirstChanEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
+
+ /* Check the specific state of the channel.*/
+ if ( pFirstChanEntry->fRinRoutCodecActive == TRUE || pFirstChanEntry->fSinSoutCodecActive == TRUE )
+ return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
+ if ( pFirstChanEntry->fBiDirChannel == TRUE )
+ return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
+
+ if ( pFirstChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CHANNEL_FIRST_CHAN_IN_CONFERENCE;
+
+ if ( pFirstChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CHANNEL_FIRST_CHAN_SOUT_PORT;
+ if ( pFirstChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CHANNEL_FIRST_CHAN_RIN_PORT;
+
+ /* Return the desired info.*/
+ *f_pusFirstChanExtraTsiIndex = pFirstChanEntry->usExtraSinTsiMemIndex;
+ *f_pusFirstChanSinCopyEventIndex = pFirstChanEntry->usSinCopyEventIndex;
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Verify the second channel handle. */
+
+ if ( (f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
+
+ *f_pusSecondChanIndex = (UINT16)( f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusSecondChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
+ return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
+
+ /* Get a pointer to the channel's list entry. */
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, *f_pusSecondChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulSecondChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pSecondChanEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CHANNEL_NOT_OPEN;
+ if ( ulEntryOpenCnt != pSecondChanEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
+
+ /* Check the specific state of the channel.*/
+ if ( pSecondChanEntry->fRinRoutCodecActive == TRUE || pSecondChanEntry->fSinSoutCodecActive == TRUE )
+ return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
+ if ( pSecondChanEntry->fBiDirChannel == TRUE )
+ return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
+
+ if ( pSecondChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CHANNEL_SECOND_CHAN_SOUT_PORT;
+ if ( pSecondChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CHANNEL_SECOND_CHAN_RIN_PORT;
+
+ if ( pSecondChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CHANNEL_SECOND_CHAN_IN_CONFERENCE;
+
+ /* Return the desired info.*/
+ *f_pusSecondChanExtraTsiIndex = pSecondChanEntry->usExtraSinTsiMemIndex;
+ *f_pusSecondChanSinCopyEventIndex = pSecondChanEntry->usSinCopyEventIndex;
+ /*=======================================================================*/
+
+ /* Check the law compatibility.*/
+ if ( pFirstChanEntry->TdmConfig.bySoutPcmLaw != pSecondChanEntry->TdmConfig.byRinPcmLaw ||
+ pFirstChanEntry->TdmConfig.byRinPcmLaw != pSecondChanEntry->TdmConfig.bySoutPcmLaw )
+ return cOCT6100_ERR_CHANNEL_BIDIR_PCM_LAW;
+
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveChannelCreateBiDirResources
+
+Description: Reserves all resources needed for the new bidirectional 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_pusBiDirChanIndex Pointer to the index of the bidirectionnal channel within the API instance.
+f_pusFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
+f_pusFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
+f_pusFirstChanSoutCopyEventIndex Pointer to the first channel Sout copy event index.
+f_pusSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
+f_pusSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
+f_pusSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event index.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveChannelCreateBiDirResources(
+ IN 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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT32 ulResult = cOCT6100_ERR_OK;
+ UINT32 ulTempVar;
+
+ BOOL fBiDirChanIndex = FALSE;
+ BOOL fFirstExtraTsi = FALSE;
+ BOOL fSecondExtraTsi = FALSE;
+ BOOL fFirstSinCopyEvent = FALSE;
+ BOOL fSecondSinCopyEvent = FALSE;
+ BOOL fFirstSoutCopyEvent = FALSE;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /*===============================================================================*/
+ /* Verify and reserve the resources that might already by allocated. */
+
+ if ( *f_pusFirstChanExtraTsiIndex == cOCT6100_INVALID_INDEX )
+ {
+ /* Reserve the first Extra TSI memory entry */
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
+ f_pusFirstChanExtraTsiIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ fFirstExtraTsi = TRUE;
+ }
+
+ if ( *f_pusFirstChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
+ {
+ /* Reserve the Sin copy event for the first channel.*/
+ ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
+ f_pusFirstChanSinCopyEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ fFirstSinCopyEvent = TRUE;
+ }
+
+ if ( *f_pusSecondChanExtraTsiIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
+ {
+ /* Reserve the second Extra TSI memory entry */
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
+ f_pusSecondChanExtraTsiIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ fSecondExtraTsi = TRUE;
+ }
+
+ if ( *f_pusSecondChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
+ {
+ /* Reserve the Sin copy event for the second channel.*/
+ ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
+ f_pusSecondChanSinCopyEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ fSecondSinCopyEvent = TRUE;
+ }
+ /*===============================================================================*/
+
+
+ /*===============================================================================*/
+ /* Now reserve all the resources specific to bidirectional channels */
+
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ ulResult = Oct6100ApiReserveBiDirChanEntry( f_pApiInstance,
+ f_pusBiDirChanIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fBiDirChanIndex = TRUE;
+
+ /* Reserve the first channel Sout copy mixer event.*/
+ ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
+ f_pusFirstChanSoutCopyEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fFirstSoutCopyEvent = TRUE;
+
+ /* Reserve the second channel Sout copy mixer event.*/
+ ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
+ f_pusSecondChanSoutCopyEventIndex );
+ }
+ }
+ }
+
+ /*===============================================================================*/
+
+
+ /*===============================================================================*/
+ /* Release the resources if something went wrong */
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /*===============================================================================*/
+ /* Release the previously reserved echo resources .*/
+ if ( fBiDirChanIndex == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance,
+ *f_pusBiDirChanIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fFirstExtraTsi == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
+ *f_pusFirstChanExtraTsiIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fSecondExtraTsi == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
+ *f_pusSecondChanExtraTsiIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fFirstSinCopyEvent == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
+ *f_pusFirstChanSinCopyEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fSecondSinCopyEvent == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
+ *f_pusSecondChanSinCopyEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fFirstSoutCopyEvent == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
+ *f_pusFirstChanSoutCopyEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ /*===============================================================================*/
+
+ return ulResult;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteChannelCreateBiDirStructs
+
+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_usFirstChanIndex Pointer to the first channel index.
+f_usFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
+f_usFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
+f_usFirstChanSoutCopyEventIndex Pointer to the first channel Sout copy event index.
+f_usFirstChanIndex Pointer to the second channel index.
+f_usSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
+f_usSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
+f_usSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event index.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiWriteChannelCreateBiDirStructs(
+ IN 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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pFirstChanEntry;
+ tPOCT6100_API_CHANNEL pSecondChanEntry;
+
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+
+ /* 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 two channel entry.*/
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
+
+ /*==============================================================================*/
+ /* Configure the Tsst control memory and add the Sin copy event if necessary.*/
+
+ /*=======================================================================*/
+ /* Program the Sin Copy event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ WriteParams.usWriteData |= f_usFirstChanExtraTsiIndex;
+ WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = (UINT16)( pFirstChanEntry->usSinSoutTsiMemIndex );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+ /* Configure the TSST memory.*/
+ if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pFirstChanEntry->usSinTsstIndex,
+ f_usFirstChanExtraTsiIndex,
+ pFirstChanEntry->TdmConfig.bySinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Now insert the event into the event list.*/
+ ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
+ f_usFirstChanSinCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY,
+ f_usFirstChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*==============================================================================*/
+
+
+
+ /*==============================================================================*/
+ /* Configure the Tsst control memory and add the Sin copy event if necessary.*/
+
+ /*=======================================================================*/
+ /* Program the Sin Copy event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ WriteParams.usWriteData |= f_usSecondChanExtraTsiIndex;
+ WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = (UINT16)( pSecondChanEntry->usSinSoutTsiMemIndex );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+ /* Configure the TSST memory.*/
+ if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pSecondChanEntry->usSinTsstIndex,
+ f_usSecondChanExtraTsiIndex,
+ pSecondChanEntry->TdmConfig.bySinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Now insert the event into the event list.*/
+ ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
+ f_usSecondChanSinCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY,
+ f_usSecondChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*==============================================================================*/
+
+
+
+ /*==============================================================================*/
+ /* Now, let's configure the two Sout copy events.*/
+
+ /* First event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ WriteParams.usWriteData |= pFirstChanEntry->usSinSoutTsiMemIndex;
+ WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pSecondChanEntry->usRinRoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
+ f_usFirstChanSoutCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY,
+ f_usFirstChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+
+ /* Second event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ WriteParams.usWriteData |= pSecondChanEntry->usSinSoutTsiMemIndex;
+ WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pFirstChanEntry->usRinRoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+
+ ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
+ f_usSecondChanSoutCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY,
+ f_usSecondChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*==============================================================================*/
+
+
+ /*==============================================================================*/
+ /* Clear + release the silence events if they were created. */
+
+ if ( pFirstChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pFirstChanEntry->usRinSilenceEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usRinSilenceEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_E0;
+
+ pFirstChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ if ( pSecondChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pSecondChanEntry->usRinSilenceEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usRinSilenceEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_E0;
+
+ pSecondChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ /*==============================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateBiDirChannelEntry
+
+Description: Updates the new bidir channel and the channel used to create that 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateBiDirChannelEntry(
+ IN 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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pFirstChanEntry;
+ tPOCT6100_API_CHANNEL pSecondChanEntry;
+ tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Obtain a pointer to the new buffer's list entry. */
+ mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
+
+ /*=======================================================================*/
+ /* Copy the channel's configuration and allocated resources. */
+
+ pFirstChanEntry->usExtraSinTsiMemIndex = f_usFirstChanExtraTsiIndex;
+ pFirstChanEntry->usSinCopyEventIndex = f_usFirstChanSinCopyEventIndex;
+ pFirstChanEntry->usSoutCopyEventIndex = f_usFirstChanSoutCopyEventIndex;
+
+ pSecondChanEntry->usExtraSinTsiMemIndex = f_usSecondChanExtraTsiIndex;
+ pSecondChanEntry->usSinCopyEventIndex = f_usSecondChanSinCopyEventIndex;
+ pSecondChanEntry->usSoutCopyEventIndex = f_usSecondChanSoutCopyEventIndex;
+
+ /* Save the channel info in the bidir channel.*/
+ pBiDirChanEntry->usFirstChanIndex = f_usFirstChanIndex;
+ pBiDirChanEntry->usSecondChanIndex = f_usSecondChanIndex;
+
+ /* Increment the extra TSI memory dependency count.*/
+ pFirstChanEntry->usExtraSinTsiDependencyCnt++;
+ pSecondChanEntry->usExtraSinTsiDependencyCnt++;
+
+ /* Set the bidir flag in the channel structure.*/
+ pFirstChanEntry->fBiDirChannel = TRUE;
+ pSecondChanEntry->fBiDirChannel = TRUE;
+
+ /*=======================================================================*/
+
+ /* Form handle returned to user. */
+ *f_pChannelCreateBiDir->pulBiDirChannelHndl = cOCT6100_HNDL_TAG_BIDIR_CHANNEL | (pBiDirChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usBiDirChanIndex;
+
+ /* Finally, mark the channel as open. */
+ pBiDirChanEntry->fReserved = TRUE;
+
+ /* Increment the number of channel open.*/
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels++;
+
+ /*=======================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ChannelDestroyBiDirSer
+
+Description: Closes a bidirectional 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_pChannelDestroyBiDir Pointer to a destroy bidirectionnal channel structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChannelDestroyBiDirSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir )
+{
+ UINT16 usBiDirChanIndex;
+ UINT16 usFirstChanIndex;
+ UINT16 usSecondChanIndex;
+
+ UINT32 ulResult;
+
+ /* Verify that all the parameters given match the state of the API. */
+ ulResult = Oct6100ApiAssertDestroyBiDirChanParams( f_pApiInstance,
+ f_pChannelDestroyBiDir,
+ &usBiDirChanIndex,
+ &usFirstChanIndex,
+ &usSecondChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the echo cancellation channel. */
+ ulResult = Oct6100ApiInvalidateBiDirChannelStructs( f_pApiInstance,
+ usFirstChanIndex,
+ usSecondChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the echo cancellation channel. */
+ ulResult = Oct6100ApiReleaseBiDirChannelResources( f_pApiInstance,
+ usBiDirChanIndex,
+ usFirstChanIndex,
+ usSecondChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Invalidate the handle.*/
+ f_pChannelDestroyBiDir->ulBiDirChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiAssertDestroyBiDirChanParams
+
+Description: Validate the handle given by the user and verify the state of
+ the channel about 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_pChannelDestroyBiDir Pointer to a destroy bidirectional channel structure.
+f_pusBiDirChanIndex Pointer to the bidir channel entry within the API's list.
+f_pusFirstChanIndex Pointer to the first channel index part of the bidir channel.
+f_pusFirstChanIndex Pointer to the second channel index part of the bidir channel.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiAssertDestroyBiDirChanParams(
+ IN 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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check the provided handle. */
+ if ( (f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_BIDIR_CHANNEL )
+ return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
+
+ *f_pusBiDirChanIndex = (UINT16)( f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusBiDirChanIndex >= pSharedInfo->ChipConfig.usMaxBiDirChannels )
+ return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
+
+ /*=======================================================================*/
+ /* Get a pointer to the bidir channel's list entry. */
+
+ mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, *f_pusBiDirChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pChannelDestroyBiDir->ulBiDirChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pBiDirChanEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CHANNEL_BIDIR_CHAN_NOT_OPEN;
+ if ( ulEntryOpenCnt != pBiDirChanEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
+
+ /*=======================================================================*/
+
+ /* Return the index of the channel used to create this bidirectional channel.*/
+ *f_pusFirstChanIndex = pBiDirChanEntry->usFirstChanIndex;
+ *f_pusSecondChanIndex = pBiDirChanEntry->usSecondChanIndex;
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiInvalidateBiDirChannelStructs
+
+Description: Destroy the link between the two channels.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pApiInstance Pointer to API instance. This memory is used to keep the
+ present state of the chip and all its resources.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiInvalidateBiDirChannelStructs(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usFirstChanIndex,
+ IN UINT16 f_usSecondChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pFirstChanEntry;
+ tPOCT6100_API_CHANNEL pSecondChanEntry;
+
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Get pointers to the API entry of the two channel used to create the bidir channel.*/
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
+
+ /* Clear the SIN copy event of the first channel and release the Extra TSI memory if
+ this feature was the only one using it. */
+ if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
+ {
+ /*=======================================================================*/
+ /* Clear the Sin Copy event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->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;
+
+ /*=======================================================================*/
+
+ /* Configure the TSST memory.*/
+ if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pFirstChanEntry->usSinTsstIndex,
+ pFirstChanEntry->usSinSoutTsiMemIndex,
+ pFirstChanEntry->TdmConfig.bySinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pFirstChanEntry->usSinCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ }
+
+ /* Clear the SIN copy event of the first channel and release the Extra TSI memory if
+ this feature was the only one using it. */
+ if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
+ {
+ /*=======================================================================*/
+ /* Clear the Sin Copy event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->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;
+
+ /*=======================================================================*/
+
+ /* Configure the TSST memory.*/
+ if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pSecondChanEntry->usSinTsstIndex,
+ pSecondChanEntry->usSinSoutTsiMemIndex,
+ pSecondChanEntry->TdmConfig.bySinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pSecondChanEntry->usSinCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ }
+
+ /* Now remove the sout copy of the first channel.*/
+
+ /*=======================================================================*/
+ /* Clear the Sout Copy event of the first channel.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSoutCopyEventIndex * 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;
+ /*=======================================================================*/
+
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pFirstChanEntry->usSoutCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+
+ /* Now remove the sout copy of the second channel.*/
+
+ /*=======================================================================*/
+ /* Clear the Sout Copy event of the second channel.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->usSoutCopyEventIndex * 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;
+ /*=======================================================================*/
+
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pSecondChanEntry->usSoutCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseBiDirChannelResources
+
+Description: Release and clear the API entry associated to the bidirectional 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_usBiDirChanIndex Index of the bidirectionnal channel in the API's bidir channel list.
+f_usFirstChanIndex Index of the first channel used to create the bidir channel.
+f_usSecondChanIndex Index of the second channel used to create the bidir channel.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseBiDirChannelResources(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usBiDirChanIndex,
+ IN UINT16 f_usFirstChanIndex,
+ IN UINT16 f_usSecondChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
+ tPOCT6100_API_CHANNEL pFirstChanEntry;
+ tPOCT6100_API_CHANNEL pSecondChanEntry;
+ tPOCT6100_API_MIXER_EVENT pTempEventEntry;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
+
+ /* Release the bidir entry.*/
+ ulResult = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance, f_usBiDirChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_AC;
+
+ /* Release the Extra TSI memory and the SIN copy event if required.*/
+ if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
+ {
+ /* Release the two TSI chariot memory entries.*/
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pFirstChanEntry->usExtraSinTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_A3;
+
+ /* Relese the SIN copy event.*/
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSinCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_A4;
+
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSinCopyEventIndex );
+
+ /* Invalidate the entry.*/
+ pTempEventEntry->fReserved = FALSE;
+ pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
+ pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
+
+ pFirstChanEntry->usExtraSinTsiDependencyCnt--;
+ pFirstChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
+ pFirstChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
+ }
+ else
+ {
+ pFirstChanEntry->usExtraSinTsiDependencyCnt--;
+ }
+
+ if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
+ {
+ /* Release the two TSI chariot memory entries.*/
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pSecondChanEntry->usExtraSinTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_A5;
+
+ /* Relese the SIN copy event.*/
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSinCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_A6;
+
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSinCopyEventIndex );
+ /* Invalidate the entry.*/
+ pTempEventEntry->fReserved = FALSE;
+ pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
+ pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
+
+ pSecondChanEntry->usExtraSinTsiDependencyCnt--;
+ pSecondChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
+ pSecondChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
+ }
+ else
+ {
+ pSecondChanEntry->usExtraSinTsiDependencyCnt--;
+ }
+
+ /* Release the SOUT copy event of the first channel.*/
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSoutCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_A7;
+
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSoutCopyEventIndex );
+ /* Invalidate the entry.*/
+ pTempEventEntry->fReserved = FALSE;
+ pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
+ pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
+
+
+ /* Release the SOUT copy event of the second channel.*/
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSoutCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_A8;
+
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSoutCopyEventIndex );
+ /* Invalidate the entry.*/
+ pTempEventEntry->fReserved = FALSE;
+ pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
+ pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
+
+
+ /*=======================================================================*/
+ /* Update the first channel's list entry. */
+
+ /* Mark the channel as closed. */
+ pFirstChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
+ pFirstChanEntry->fBiDirChannel = FALSE;
+
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Update the second channel's list entry. */
+
+ /* Mark the channel as closed. */
+ pSecondChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
+ pSecondChanEntry->fBiDirChannel = FALSE;
+
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Update the bidirectional channel's list entry. */
+
+ /* Mark the channel as closed. */
+ pBiDirChanEntry->fReserved = FALSE;
+ pBiDirChanEntry->byEntryOpenCnt++;
+
+ pBiDirChanEntry->usFirstChanIndex = cOCT6100_INVALID_INDEX;
+ pBiDirChanEntry->usSecondChanIndex = cOCT6100_INVALID_INDEX;
+
+ /* Decrement the number of channel open.*/
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels--;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Check if some of the ports must be muted back. */
+
+ ulResult = Oct6100ApiMutePorts( f_pApiInstance,
+ f_usFirstChanIndex,
+ pFirstChanEntry->usRinTsstIndex,
+ pFirstChanEntry->usSinTsstIndex,
+ FALSE );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiMutePorts( f_pApiInstance,
+ f_usSecondChanIndex,
+ pSecondChanEntry->usRinTsstIndex,
+ pSecondChanEntry->usSinTsstIndex,
+ FALSE );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+INT32 Oct6100ApiOctFloatToDbEnergyByte(UINT8 x)
+{
+ INT32 lResult;
+
+ lResult = Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)(x << 8) );
+ return lResult;
+}
+
+INT32 Oct6100ApiOctFloatToDbEnergyHalf(UINT16 x)
+{
+ INT32 y;
+ UINT16 m;
+
+ y = (((x >> 8) & 0x7F) - 0x41) * 3;
+
+ m = (UINT16)((x & 0x00E0) >> 5);
+ if (m < 2) y += 0;
+ else if (m < 5) y += 1;
+ else y += 2;
+
+ return y;
+}
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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?
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c
new file mode 100644
index 0000000..48987c0
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c
@@ -0,0 +1,6097 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100GetInstanceSizeDef(
+ tPOCT6100_GET_INSTANCE_SIZE f_pGetSize )
+{
+ return cOCT6100_ERR_OK;
+}
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )(( UINT32 )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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChipCloseDef(
+ tPOCT6100_CHIP_CLOSE f_pChipClose )
+{
+ f_pChipClose->ulDummyVariable = 0;
+
+ return cOCT6100_ERR_OK;
+}
+
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100CreateLocalInstance
+
+Description: Creates a local instance for a process in a multi-process
+ host system.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pCreateLocal Structure used to create process' local instance.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100CreateLocalInstanceDef(
+ tPOCT6100_CREATE_LOCAL_INSTANCE f_pCreateLocal )
+{
+ f_pCreateLocal->pApiInstShared = NULL;
+ f_pCreateLocal->pApiInstLocal = NULL;
+ f_pCreateLocal->pProcessContext = NULL;
+ f_pCreateLocal->ulUserChipId = 0;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100CreateLocalInstance(
+ tPOCT6100_CREATE_LOCAL_INSTANCE f_pCreateLocal )
+{
+ tPOCT6100_INSTANCE_API pApiInstLocal;
+ UINT32 ulApiInstSize;
+ UINT32 ulTempVar;
+ UINT32 ulResult;
+
+ /* Check user's structure for errors. */
+ if ( f_pCreateLocal->pApiInstShared == NULL )
+ return cOCT6100_ERR_MULTIPROC_API_INST_SHARED;
+
+ if ( f_pCreateLocal->pApiInstLocal == NULL )
+ return cOCT6100_ERR_MULTIPROC_API_INST_LOCAL;
+
+ /* Get local pointer to local instance. */
+ pApiInstLocal = f_pCreateLocal->pApiInstLocal;
+
+ /* Assign pointers to local structure. */
+ ulApiInstSize = sizeof( tOCT6100_INSTANCE_API );
+ mOCT6100_ROUND_MEMORY_SIZE( ulApiInstSize, ulTempVar )
+
+ pApiInstLocal->pSharedInfo = ( tPOCT6100_SHARED_INFO )(( UINT32 )f_pCreateLocal->pApiInstShared + ulApiInstSize);
+ pApiInstLocal->pProcessContext = f_pCreateLocal->pProcessContext;
+
+ /* Create serialization object handles needed. */
+ ulResult = Oct6100ApiCreateSerializeObjects( pApiInstLocal, f_pCreateLocal->ulUserChipId );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100DestroyLocalInstance
+
+Description: Release local instance for a process in a multi-process
+ host system.
+
+-------------------------------------------------------------------------------
+| 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_pDestroyLocal Structure used to destroy the process' local instance.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100DestroyLocalInstanceDef(
+ tPOCT6100_DESTROY_LOCAL_INSTANCE f_pDestroyLocal )
+{
+ f_pDestroyLocal->ulDummy = 0;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100DestroyLocalInstance(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_DESTROY_LOCAL_INSTANCE f_pDestroyLocal )
+{
+ UINT32 ulResult;
+
+ /* Destroy the allocated ressources used for serialization. */
+ ulResult = Oct6100ApiDestroySerializeObjects( f_pApiInstance );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100GetHwRevision
+
+Description: Gets the hardware revision number of the chip.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pGetHwRev Pointer to user structure in which to return revision
+ number.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100GetHwRevisionDef(
+ tPOCT6100_GET_HW_REVISION f_pGetHwRev )
+{
+ f_pGetHwRev->ulUserChipId = cOCT6100_INVALID_CHIP_ID;
+ f_pGetHwRev->pProcessContext = NULL;
+ f_pGetHwRev->ulRevisionNum = cOCT6100_INVALID_VALUE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100GetHwRevision(
+ tPOCT6100_GET_HW_REVISION f_pGetHwRev )
+{
+ tOCT6100_READ_PARAMS ReadParams;
+ UINT32 ulResult;
+ UINT16 usReadData;
+
+ /* Read the hardware revision register. */
+ ReadParams.pProcessContext = f_pGetHwRev->pProcessContext;
+
+ ReadParams.ulUserChipId = f_pGetHwRev->ulUserChipId;
+ ReadParams.pusReadData = &usReadData;
+ ReadParams.ulReadAddress = 0x17E;
+ mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ f_pGetHwRev->ulRevisionNum = ( usReadData >> 8 ) & 0xFF;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100FreeResources
+
+Description: This function closes all opened channels and frees all
+ specified global resources used by 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.
+
+f_pFreeResources Pointer to user structure in which to choose what
+ to free.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100FreeResourcesDef(
+ tPOCT6100_FREE_RESOURCES f_pFreeResources )
+{
+ f_pFreeResources->fFreeTsiConnections = FALSE;
+ f_pFreeResources->fFreeConferenceBridges = FALSE;
+ f_pFreeResources->fFreePlayoutBuffers = FALSE;
+ f_pFreeResources->fFreePhasingTssts = FALSE;
+ f_pFreeResources->fFreeAdpcmChannels = FALSE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100FreeResources(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_FREE_RESOURCES f_pFreeResources )
+{
+ 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 = Oct6100FreeResourcesSer( f_pApiInstance, f_pFreeResources );
+ }
+ 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: Oct6100ProductionBist
+
+Description: This function retrieves the current BIST status of the
+ firmware.
+
+-------------------------------------------------------------------------------
+| 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_pProductionBist Pointer to user structure where the bist information
+ will be returned.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ProductionBistDef(
+ tPOCT6100_PRODUCTION_BIST f_pProductionBist )
+{
+ f_pProductionBist->ulCurrentAddress = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulCurrentLoop = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulFailedAddress = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulReadValue = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulExpectedValue = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulBistStatus = cOCT6100_BIST_IN_PROGRESS;
+ f_pProductionBist->ulCurrentTest = cOCT6100_INVALID_VALUE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ProductionBist(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_PRODUCTION_BIST f_pProductionBist )
+{
+ 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 = Oct6100ProductionBistSer( f_pApiInstance, f_pProductionBist );
+ }
+ 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: Oct6100ApiGetVersion
+
+Description: Retrieves the API version.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+
+f_pApiGetVersion Pointer to structure that will receive version information.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiGetVersionDef(
+ tPOCT6100_API_GET_VERSION f_pApiGetVersion )
+{
+ UINT32 i;
+
+ /* Initialize the string. */
+ for ( i = 0; i < cOCT6100_API_VERSION_STRING_LENGTH; i++ )
+ f_pApiGetVersion->achApiVersion[ i ] = 0;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100ApiGetVersion(
+ tPOCT6100_API_GET_VERSION f_pApiGetVersion )
+{
+ /* Copy API version information to user. */
+ Oct6100UserMemCopy( f_pApiGetVersion->achApiVersion, cOCT6100_API_VERSION, sizeof(cOCT6100_API_VERSION) );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*************************** PRIVATE FUNCTIONS *****************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckChipConfiguration
+
+Description: Checks the user chip configuration structure for errors.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+
+f_pChipOpen Pointer to chip configuration structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCreateSerializeObjects(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulUserChipId )
+{
+ tOCT6100_CREATE_SERIALIZE_OBJECT CreateSerObj;
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100FreeResourcesSer
+
+Description: This function closes all opened channels and frees all
+ specified global resources used by 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.
+
+f_pFreeResources Pointer to user structure in which to choose what
+ to free.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100FreeResourcesSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_FREE_RESOURCES f_pFreeResources )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pChanEntry;
+
+ UINT32 ulResult;
+ UINT32 i;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Close all bidirectional channels. */
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxBiDirChannels; i ++ )
+ {
+ tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
+
+ mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, i );
+
+ if ( pBiDirChanEntry->fReserved == TRUE )
+ {
+ tOCT6100_CHANNEL_DESTROY_BIDIR DestroyBidir;
+
+ Oct6100ChannelDestroyBiDirDef( &DestroyBidir );
+
+ DestroyBidir.ulBiDirChannelHndl = cOCT6100_HNDL_TAG_BIDIR_CHANNEL | (pBiDirChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
+
+ ulResult = Oct6100ChannelDestroyBiDirSer( f_pApiInstance, &DestroyBidir );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* Close all bridge participants. */
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i ++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, i );
+ if ( pChanEntry->fReserved == TRUE && pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* This channel is on a bridge. */
+ tOCT6100_CONF_BRIDGE_CHAN_REMOVE BridgeChanRemove;
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+
+ Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
+
+ /* Obtain a pointer to the conference bridge's list entry. */
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, pChanEntry->usBridgeIndex );
+
+ BridgeChanRemove.fRemoveAll = TRUE;
+ BridgeChanRemove.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pBridgeEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pChanEntry->usBridgeIndex;
+
+ ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* Close all opened channels. This will bring the broadcast TSSTs with it. */
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i ++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, i );
+
+ if ( pChanEntry->fReserved == TRUE )
+ {
+ tOCT6100_CHANNEL_CLOSE ChannelClose;
+
+ /* Generate handle. */
+ ChannelClose.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
+
+ /* Call serialized close channel function. */
+ ulResult = Oct6100ChannelCloseSer( f_pApiInstance, &ChannelClose );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* Close all TSI connections. */
+ if ( f_pFreeResources->fFreeTsiConnections == TRUE )
+ {
+ tPOCT6100_API_TSI_CNCT pTsiCnct;
+ tOCT6100_TSI_CNCT_CLOSE TsiCnctClose;
+
+ Oct6100TsiCnctCloseDef( &TsiCnctClose );
+
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxTsiCncts; i ++ )
+ {
+ /* Obtain a pointer to the TSI connection list entry. */
+ mOCT6100_GET_TSI_CNCT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsiCnct, i );
+
+ if ( pTsiCnct->fReserved == TRUE )
+ {
+ TsiCnctClose.ulTsiCnctHndl = cOCT6100_HNDL_TAG_TSI_CNCT | (pTsiCnct->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
+
+ ulResult = Oct6100TsiCnctCloseSer( f_pApiInstance, &TsiCnctClose );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+
+ /* Close all conference bridges. */
+ if ( f_pFreeResources->fFreeConferenceBridges == TRUE )
+ {
+ tPOCT6100_API_CONF_BRIDGE pConfBridge;
+ tOCT6100_CONF_BRIDGE_CLOSE ConfBridgeClose;
+
+ Oct6100ConfBridgeCloseDef( &ConfBridgeClose );
+
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxConfBridges; i ++ )
+ {
+ /* Obtain a pointer to the conference bridge's list entry. */
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pConfBridge, i );
+
+ if ( pConfBridge->fReserved == TRUE )
+ {
+ ConfBridgeClose.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pConfBridge->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
+
+ ulResult = Oct6100ConfBridgeCloseSer( f_pApiInstance, &ConfBridgeClose );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+
+ /* Free all playout buffers loaded in external memory. */
+ if ( f_pFreeResources->fFreePlayoutBuffers == TRUE )
+ {
+ tPOCT6100_API_BUFFER pBuffer;
+ tOCT6100_BUFFER_UNLOAD BufferUnload;
+
+ Oct6100BufferPlayoutUnloadDef( &BufferUnload );
+
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxPlayoutBuffers; i ++ )
+ {
+
+
+ /* Obtain a pointer to the buffer list entry. */
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBuffer, i );
+
+ if ( pBuffer->fReserved == TRUE )
+ {
+ BufferUnload.ulBufferIndex = i;
+ ulResult = Oct6100BufferUnloadSer( f_pApiInstance, &BufferUnload, TRUE );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+
+
+ /* Close all phasing TSSTs. */
+ if ( f_pFreeResources->fFreePhasingTssts == TRUE )
+ {
+ tPOCT6100_API_PHASING_TSST pPhasingTsst;
+ tOCT6100_PHASING_TSST_CLOSE PhasingTsstClose;
+
+ Oct6100PhasingTsstCloseDef( &PhasingTsstClose );
+
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxPhasingTssts; i ++ )
+ {
+ mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, i );
+
+ if ( pPhasingTsst->fReserved == TRUE )
+ {
+ PhasingTsstClose.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsst->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
+
+ ulResult = Oct6100PhasingTsstCloseSer( f_pApiInstance, &PhasingTsstClose );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+
+ /* Close all ADPCM channels. */
+ if ( f_pFreeResources->fFreeAdpcmChannels == TRUE )
+ {
+ tPOCT6100_API_ADPCM_CHAN pAdpcmChannel;
+ tOCT6100_ADPCM_CHAN_CLOSE AdpcmChanClose;
+
+ Oct6100AdpcmChanCloseDef( &AdpcmChanClose );
+
+ for ( i = 0; i < pSharedInfo->ChipConfig.usMaxAdpcmChannels; i ++ )
+ {
+ mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( pSharedInfo, pAdpcmChannel, i );
+ if ( pAdpcmChannel->fReserved == TRUE )
+ {
+ AdpcmChanClose.ulChanHndl = cOCT6100_HNDL_TAG_ADPCM_CHANNEL | (pAdpcmChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
+
+ ulResult = Oct6100AdpcmChanCloseSer( f_pApiInstance, &AdpcmChanClose );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ProductionBistSer
+
+Description: This function returns the instantaneous production BIST status.
+
+-------------------------------------------------------------------------------
+| 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_pProductionBist Pointer to user structure in which BIST status will
+ be returned.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ProductionBistSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_PRODUCTION_BIST f_pProductionBist )
+{
+ UINT32 ulCalculatedCrc = cOCT6100_INVALID_VALUE;
+ UINT32 ulResult;
+ UINT32 ulLoopCnt = 0x0;
+ UINT32 i = 1;
+ UINT32 ulTotalElements = 4;
+ UINT32 ulReadAddress = cOCT6100_POUCH_BASE;
+ UINT32 aulMessage[ 5 ];
+
+ /* Check if the production bist has been activated. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableProductionBist == FALSE )
+ return cOCT6100_ERR_PRODUCTION_BIST_DISABLED;
+
+ f_pProductionBist->ulCurrentAddress = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulCurrentLoop = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulCurrentTest = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulFailedAddress = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulReadValue = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulExpectedValue = cOCT6100_INVALID_VALUE;
+ f_pProductionBist->ulBistStatus = cOCT6100_BIST_IN_PROGRESS;
+
+ /* The API knows that the firmware might be writing a status event. */
+ /* The firmware does write a status event every 200ms (approximately). */
+ /* So the status is read a couple of times to make sure an event was not read while */
+ /* it was written. */
+ while ( ulLoopCnt != 2 )
+ {
+ /* Read the BIST status in the external memory. */
+ for ( i = 0; i < ulTotalElements + 1; i ++ )
+ {
+ ulResult = Oct6100ApiReadDword( f_pApiInstance, ulReadAddress + i * 4, &aulMessage[ i ] );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Calculate the CRC of this message. */
+ ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCalculatedCrc );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* If the CRCs do match, break off the while. We have a valid status event. */
+ if ( aulMessage[ i - 1 ] == ulCalculatedCrc )
+ break;
+
+ ulLoopCnt++;
+ }
+
+ /* Check if the CRC matches */
+ if ( aulMessage[ i - 1 ] != ulCalculatedCrc )
+ {
+ /* Well, the exchange memory at the base of the external memory is corrupted. */
+ /* Something very basic is not working correctly with this chip! */
+ f_pProductionBist->ulBistStatus = cOCT6100_BIST_STATUS_CRC_FAILED;
+ }
+ else
+ {
+ /* Check for problems. */
+ switch ( aulMessage[ 0 ] & 0xFFFF )
+ {
+ case ( 0x2 ):
+
+ /* The initial configuration failed. */
+ f_pProductionBist->ulBistStatus = cOCT6100_BIST_CONFIGURATION_FAILED;
+ break;
+
+ case ( 0x1 ):
+
+ /* A memory location failed. Return useful information to the user. */
+ f_pProductionBist->ulBistStatus = cOCT6100_BIST_MEMORY_FAILED;
+
+ f_pProductionBist->ulFailedAddress = ( aulMessage[ 1 ] & ( ~0x80000000 ) ) + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
+ f_pProductionBist->ulReadValue = aulMessage[ 2 ];
+ f_pProductionBist->ulExpectedValue = aulMessage[ 3 ];
+ break;
+
+ case ( 0xFFFF ):
+
+ /* Bist is completed! */
+ f_pProductionBist->ulBistStatus = cOCT6100_BIST_SUCCESS;
+ break;
+
+ default:
+ /* Bist is in progress. All seems to be working fine up to now. */
+
+ /* Return progress status. */
+ f_pProductionBist->ulCurrentAddress = ( aulMessage[ 1 ] & ( ~0x80000000 ) ) + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
+ f_pProductionBist->ulCurrentTest = aulMessage[ 2 ];
+ f_pProductionBist->ulCurrentLoop = aulMessage[ 3 ];
+ break;
+ }
+ }
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_stats.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_stats.c
new file mode 100644
index 0000000..5b606d8
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_stats.c
@@ -0,0 +1,425 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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 *****************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ChipGetStats
+
+Description: Retreives the chip statistics and 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_pChipStats Pointer to a tOCT6100_CHIP_STATS structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChipGetStatsDef(
+ tPOCT6100_CHIP_STATS f_pChipStats )
+{
+ f_pChipStats->fResetChipStats = FALSE;
+
+ f_pChipStats->ulNumberChannels = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulNumberTsiCncts = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulNumberConfBridges = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulNumberPlayoutBuffers = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulPlayoutFreeMemSize = cOCT6100_INVALID_STAT;
+
+ f_pChipStats->ulNumberPhasingTssts = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulNumberAdpcmChannels = cOCT6100_INVALID_STAT;
+
+ f_pChipStats->ulH100OutOfSynchCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulH100ClockABadCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulH100FrameABadCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulH100ClockBBadCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulInternalReadTimeoutCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulSdramRefreshTooLateCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulPllJitterErrorCount = cOCT6100_INVALID_STAT;
+
+ f_pChipStats->ulOverflowToneEventsCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulSoftOverflowToneEventsCount = cOCT6100_INVALID_STAT;
+ f_pChipStats->ulSoftOverflowBufferPlayoutEventsCount = cOCT6100_INVALID_STAT;
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ChipGetStats(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CHIP_STATS f_pChipStats )
+{
+ 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 = Oct6100ChipGetStatsSer( f_pApiInstance, f_pChipStats );
+ }
+ 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: Oct6100ChipGetImageInfo
+
+Description: Retrieves the chip image information indicating the supported
+ features and tones.
+
+-------------------------------------------------------------------------------
+| 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_pChipImageInfo Pointer to a tPOCT6100_CHIP_IMAGE_INFO structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChipGetImageInfoDef(
+ tPOCT6100_CHIP_IMAGE_INFO f_pChipImageInfo )
+{
+ UINT32 i;
+
+ Oct6100UserMemSet( f_pChipImageInfo->szVersionNumber, 0x0, cOCT6100_VERSION_NUMBER_MAX_SIZE );
+
+ f_pChipImageInfo->fBufferPlayout = FALSE;
+ f_pChipImageInfo->fAdaptiveNoiseReduction = FALSE;
+ f_pChipImageInfo->fSoutNoiseBleaching = FALSE;
+ f_pChipImageInfo->fConferencingNoiseReduction = FALSE;
+ f_pChipImageInfo->fAutoLevelControl = FALSE;
+ f_pChipImageInfo->fHighLevelCompensation = FALSE;
+ f_pChipImageInfo->fSilenceSuppression = FALSE;
+
+ f_pChipImageInfo->fAdpcm = FALSE;
+ f_pChipImageInfo->fConferencing = FALSE;
+ f_pChipImageInfo->fDominantSpeaker = FALSE;
+ f_pChipImageInfo->ulMaxChannels = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulNumTonesAvailable = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulToneProfileNumber = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulMaxTailDisplacement = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulBuildId = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulMaxTailLength = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulDebugEventSize = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulMaxPlayoutEvents = cOCT6100_INVALID_VALUE;
+ f_pChipImageInfo->ulImageType = cOCT6100_INVALID_VALUE;
+
+ f_pChipImageInfo->fAcousticEcho = FALSE;
+ f_pChipImageInfo->fAecTailLength = FALSE;
+ f_pChipImageInfo->fToneRemoval = FALSE;
+
+ f_pChipImageInfo->fDefaultErl = FALSE;
+ f_pChipImageInfo->fNonLinearityBehaviorA = FALSE;
+ f_pChipImageInfo->fNonLinearityBehaviorB = FALSE;
+ f_pChipImageInfo->fPerChannelTailDisplacement = FALSE;
+ f_pChipImageInfo->fPerChannelTailLength = FALSE;
+ f_pChipImageInfo->fListenerEnhancement = FALSE;
+ f_pChipImageInfo->fRoutNoiseReduction = FALSE;
+ f_pChipImageInfo->fAnrSnrEnhancement = FALSE;
+ f_pChipImageInfo->fAnrVoiceNoiseSegregation = FALSE;
+ f_pChipImageInfo->fToneDisablerVqeActivationDelay = FALSE;
+ f_pChipImageInfo->fMusicProtection = FALSE;
+ f_pChipImageInfo->fDoubleTalkBehavior = FALSE;
+ f_pChipImageInfo->fIdleCodeDetection = TRUE;
+ f_pChipImageInfo->fSinLevel = TRUE;
+
+ for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
+ {
+ Oct6100UserMemSet( f_pChipImageInfo->aToneInfo[ i ].aszToneName, 0x00, cOCT6100_TLV_MAX_TONE_NAME_SIZE );
+ f_pChipImageInfo->aToneInfo[ i ].ulDetectionPort = cOCT6100_INVALID_PORT;
+ f_pChipImageInfo->aToneInfo[ i ].ulToneID = cOCT6100_INVALID_VALUE;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ChipGetImageInfo(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CHIP_IMAGE_INFO f_pChipImageInfo )
+{
+ tPOCT6100_API_IMAGE_INFO pImageInfo;
+ UINT32 i;
+
+ /* Get local pointer(s). */
+ pImageInfo = &f_pApiInstance->pSharedInfo->ImageInfo;
+
+ Oct6100UserMemCopy( f_pChipImageInfo->szVersionNumber, pImageInfo->szVersionNumber, cOCT6100_VERSION_NUMBER_MAX_SIZE );
+
+ /* Copy the customer info. */
+ f_pChipImageInfo->ulBuildId = pImageInfo->ulBuildId;
+
+ /* Copy the features list. */
+ f_pChipImageInfo->fBufferPlayout = pImageInfo->fBufferPlayout;
+ f_pChipImageInfo->fAdaptiveNoiseReduction = pImageInfo->fAdaptiveNoiseReduction;
+ f_pChipImageInfo->fSoutNoiseBleaching = pImageInfo->fSoutNoiseBleaching;
+ f_pChipImageInfo->fSilenceSuppression = pImageInfo->fSilenceSuppression;
+
+ f_pChipImageInfo->fAdpcm = pImageInfo->fAdpcm;
+ f_pChipImageInfo->fConferencing = pImageInfo->fConferencing;
+ f_pChipImageInfo->fDominantSpeaker = pImageInfo->fDominantSpeakerEnabled;
+ f_pChipImageInfo->fConferencingNoiseReduction = pImageInfo->fConferencingNoiseReduction;
+ f_pChipImageInfo->fAcousticEcho = pImageInfo->fAcousticEcho;
+ f_pChipImageInfo->fAecTailLength = pImageInfo->fAecTailLength;
+ f_pChipImageInfo->fDefaultErl = pImageInfo->fDefaultErl;
+ f_pChipImageInfo->fToneRemoval = pImageInfo->fToneRemoval;
+
+ f_pChipImageInfo->fNonLinearityBehaviorA = pImageInfo->fNonLinearityBehaviorA;
+ f_pChipImageInfo->fNonLinearityBehaviorB = pImageInfo->fNonLinearityBehaviorB;
+ f_pChipImageInfo->fPerChannelTailDisplacement = pImageInfo->fPerChannelTailDisplacement;
+ f_pChipImageInfo->fListenerEnhancement = pImageInfo->fListenerEnhancement;
+ f_pChipImageInfo->fRoutNoiseReduction = pImageInfo->fRoutNoiseReduction;
+ f_pChipImageInfo->fAnrSnrEnhancement = pImageInfo->fAnrSnrEnhancement;
+ f_pChipImageInfo->fAnrVoiceNoiseSegregation = pImageInfo->fAnrVoiceNoiseSegregation;
+ f_pChipImageInfo->fMusicProtection = pImageInfo->fMusicProtection;
+ f_pChipImageInfo->fIdleCodeDetection = pImageInfo->fIdleCodeDetection;
+ f_pChipImageInfo->fSinLevel = pImageInfo->fSinLevel;
+ f_pChipImageInfo->fDoubleTalkBehavior = pImageInfo->fDoubleTalkBehavior;
+ if ( ( pImageInfo->fRinAutoLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == TRUE ) )
+ f_pChipImageInfo->fAutoLevelControl = TRUE;
+ else
+ f_pChipImageInfo->fAutoLevelControl = FALSE;
+ f_pChipImageInfo->fHighLevelCompensation = pImageInfo->fRinHighLevelCompensation;
+
+ f_pChipImageInfo->ulMaxChannels = pImageInfo->usMaxNumberOfChannels;
+ f_pChipImageInfo->ulNumTonesAvailable = pImageInfo->byNumToneDetectors;
+ f_pChipImageInfo->ulToneProfileNumber = pImageInfo->ulToneProfileNumber;
+ f_pChipImageInfo->ulMaxTailDisplacement = pImageInfo->usMaxTailDisplacement;
+ f_pChipImageInfo->ulMaxTailLength = pImageInfo->usMaxTailLength;
+ f_pChipImageInfo->fPerChannelTailLength = pImageInfo->fPerChannelTailLength;
+ f_pChipImageInfo->ulDebugEventSize = f_pApiInstance->pSharedInfo->DebugInfo.ulDebugEventSize;
+ f_pChipImageInfo->fToneDisablerVqeActivationDelay = pImageInfo->fToneDisablerVqeActivationDelay;
+ f_pChipImageInfo->ulMaxPlayoutEvents = pImageInfo->byMaxNumberPlayoutEvents - 1; /* 127 or 31 */
+ f_pChipImageInfo->ulImageType = pImageInfo->byImageType;
+
+ for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
+ {
+ Oct6100UserMemCopy( f_pChipImageInfo->aToneInfo[ i ].aszToneName, pImageInfo->aToneInfo[ i ].aszToneName, cOCT6100_TLV_MAX_TONE_NAME_SIZE );
+ f_pChipImageInfo->aToneInfo[ i ].ulDetectionPort = pImageInfo->aToneInfo[ i ].ulDetectionPort;
+ f_pChipImageInfo->aToneInfo[ i ].ulToneID = pImageInfo->aToneInfo[ i ].ulToneID;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/**************************** 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ChipGetStatsSer
+
+Description: Serialized function retreiving the chip statistics.
+
+-------------------------------------------------------------------------------
+| 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_pChipStats Pointer to master mode configuration structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ChipGetStatsSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT tPOCT6100_CHIP_STATS f_pChipStats )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ f_pChipStats->ulNumberChannels = pSharedInfo->ChipStats.usNumberChannels;
+ f_pChipStats->ulNumberTsiCncts = pSharedInfo->ChipStats.usNumberTsiCncts;
+ f_pChipStats->ulNumberConfBridges = pSharedInfo->ChipStats.usNumberConfBridges;
+ f_pChipStats->ulNumberPlayoutBuffers = pSharedInfo->ChipStats.usNumberPlayoutBuffers;
+ f_pChipStats->ulPlayoutFreeMemSize = ( f_pApiInstance->pSharedInfo->MiscVars.ulTotalMemSize - ( f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress - cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) ) - ( pSharedInfo->ChipStats.ulPlayoutMemUsed );
+
+ f_pChipStats->ulNumberPhasingTssts = pSharedInfo->ChipStats.usNumberPhasingTssts;
+ f_pChipStats->ulNumberAdpcmChannels = pSharedInfo->ChipStats.usNumberAdpcmChans;
+
+ /* Check the input parameters. */
+ if ( f_pChipStats->fResetChipStats != TRUE &&
+ f_pChipStats->fResetChipStats != FALSE )
+ return cOCT6100_ERR_CHIP_STATS_RESET;
+
+ if ( f_pChipStats->fResetChipStats == TRUE )
+ {
+ pSharedInfo->ErrorStats.ulH100OutOfSyncCnt = 0;
+ pSharedInfo->ErrorStats.ulH100ClkABadCnt = 0;
+ pSharedInfo->ErrorStats.ulH100FrameABadCnt = 0;
+ pSharedInfo->ErrorStats.ulH100ClkBBadCnt = 0;
+
+ pSharedInfo->ErrorStats.ulInternalReadTimeoutCnt = 0;
+ pSharedInfo->ErrorStats.ulPllJitterErrorCnt = 0;
+ pSharedInfo->ErrorStats.ulSdramRefreshTooLateCnt = 0;
+
+ pSharedInfo->ErrorStats.ulOverflowToneEventsCnt = 0;
+ pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0;
+ pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt = 0;
+
+
+ }
+
+ f_pChipStats->ulH100OutOfSynchCount = pSharedInfo->ErrorStats.ulH100OutOfSyncCnt;
+ f_pChipStats->ulH100ClockABadCount = pSharedInfo->ErrorStats.ulH100ClkABadCnt;
+ f_pChipStats->ulH100FrameABadCount = pSharedInfo->ErrorStats.ulH100FrameABadCnt;
+ f_pChipStats->ulH100ClockBBadCount = pSharedInfo->ErrorStats.ulH100ClkBBadCnt;
+
+ f_pChipStats->ulInternalReadTimeoutCount = pSharedInfo->ErrorStats.ulInternalReadTimeoutCnt;
+ f_pChipStats->ulPllJitterErrorCount = pSharedInfo->ErrorStats.ulPllJitterErrorCnt;
+ f_pChipStats->ulSdramRefreshTooLateCount = pSharedInfo->ErrorStats.ulSdramRefreshTooLateCnt;
+
+ f_pChipStats->ulOverflowToneEventsCount = pSharedInfo->ErrorStats.ulOverflowToneEventsCnt;
+ f_pChipStats->ulSoftOverflowToneEventsCount = pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt;
+ f_pChipStats->ulSoftOverflowBufferPlayoutEventsCount = pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt;
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_conf_bridge.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_conf_bridge.c
new file mode 100644
index 0000000..43e57c8
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_conf_bridge.c
@@ -0,0 +1,7518 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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: Oct6100ConfBridgeOpen
+
+Description: This function opens 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_pConfBridgeOpen Pointer to conference bridge open structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeOpenDef(
+ tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen )
+{
+ f_pConfBridgeOpen->pulConfBridgeHndl = NULL;
+ f_pConfBridgeOpen->fFlexibleConferencing = FALSE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ConfBridgeOpen(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen )
+{
+ 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 = Oct6100ConfBridgeOpenSer( f_pApiInstance, f_pConfBridgeOpen );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeCloseDef(
+ tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose )
+{
+ f_pConfBridgeClose->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ConfBridgeClose(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose )
+{
+ 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 = Oct6100ConfBridgeCloseSer( f_pApiInstance, f_pConfBridgeClose );
+ }
+ 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: Oct6100ConfBridgeChanAdd
+
+Description: This function adds an echo channel (participant) to 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_pConfBridgeAdd Pointer to conference bridge channel addition structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeChanAddDef(
+ tPOCT6100_CONF_BRIDGE_CHAN_ADD f_pConfBridgeAdd )
+{
+ f_pConfBridgeAdd->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
+ f_pConfBridgeAdd->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pConfBridgeAdd->ulInputPort = cOCT6100_CHANNEL_PORT_SOUT;
+ f_pConfBridgeAdd->ulListenerMaskIndex = cOCT6100_INVALID_VALUE;
+ f_pConfBridgeAdd->ulListenerMask = 0;
+ f_pConfBridgeAdd->fMute = FALSE;
+ f_pConfBridgeAdd->ulTappedChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ConfBridgeChanAdd(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_CHAN_ADD f_pConfBridgeAdd )
+{
+ 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 = Oct6100ConfBridgeChanAddSer( f_pApiInstance, f_pConfBridgeAdd );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+UINT32 Oct6100ConfBridgeChanRemove(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove )
+{
+ 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 = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, f_pConfBridgeRemove );
+ }
+ 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: Oct6100ConfBridgeChanMute
+
+Description: This function mutes a participant present on 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_pConfBridgeMute Pointer to conference bridge channel mute structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeChanMuteDef(
+ tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute )
+{
+ f_pConfBridgeMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ConfBridgeChanMute(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute )
+{
+ 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 = Oct6100ConfBridgeChanMuteSer( f_pApiInstance, f_pConfBridgeMute );
+ }
+ 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: Oct6100ConfBridgeChanUnMute
+
+Description: This function unmutes a channel on a bridge. The other member
+ of the conference will start to hear this participant again.
+
+-------------------------------------------------------------------------------
+| 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_pConfBridgeUnMute Pointer to conference bridge channel unmute structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeChanUnMuteDef(
+ tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute )
+{
+ f_pConfBridgeUnMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100ConfBridgeChanUnMute(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute )
+{
+ 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 = Oct6100ConfBridgeChanUnMuteSer( f_pApiInstance, f_pConfBridgeUnMute );
+ }
+ 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: Oct6100ConfBridgeDominantSpeakerSet
+
+Description: This function sets a participant present on a conference
+ bridge as the dominant speaker.
+
+-------------------------------------------------------------------------------
+| 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_pConfBridgeDominant Pointer to conference bridge dominant speaker
+ structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeDominantSpeakerSetDef(
+ tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker )
+{
+ f_pConfBridgeDominantSpeaker->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pConfBridgeDominantSpeaker->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ConfBridgeDominantSpeakerSet(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker )
+{
+ 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 = Oct6100ConfBridgeDominantSpeakerSetSer( f_pApiInstance, f_pConfBridgeDominantSpeaker );
+ }
+ 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: Oct6100ConfBridgeMaskChange
+
+Description: This function changes the mask of a flexible bridge participant.
+
+-------------------------------------------------------------------------------
+| 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_pConfBridgeMaskChange Pointer to conference bridge change of mask
+ structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeMaskChangeDef(
+ tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange )
+{
+ f_pConfBridgeMaskChange->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pConfBridgeMaskChange->ulNewListenerMask = 0x0;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ConfBridgeMaskChange(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange )
+{
+ 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 = Oct6100ConfBridgeMaskChangeSer( f_pApiInstance, f_pConfBridgeMaskChange );
+ }
+ 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: Oct6100ConfBridgeGetStats
+
+Description: This function returns the stats for 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_pConfBridgeStats Pointer to conference bridge channel stats structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeGetStatsDef(
+ tPOCT6100_CONF_BRIDGE_STATS f_pConfBridgeStats )
+{
+ f_pConfBridgeStats->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
+ f_pConfBridgeStats->ulNumChannels = cOCT6100_INVALID_STAT;
+ f_pConfBridgeStats->ulNumTappedChannels = cOCT6100_INVALID_STAT;
+ f_pConfBridgeStats->fFlexibleConferencing = cOCT6100_INVALID_STAT;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100ConfBridgeGetStats(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_CONF_BRIDGE_STATS f_pConfBridgeStats )
+{
+ 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 = Oct6100ConfBridgeGetStatsSer( f_pApiInstance, f_pConfBridgeStats );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ConfBridgeOpenSer
+
+Description: Open a conference bridge. Note that no chip resources are
+ allocated until a channel is added to 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_pConfBridgeOpen Pointer to conference bridge configuration structure.
+ The handle identifying the conference bridge in all
+ future function calls is returned in this structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeOpenSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen )
+{
+ UINT16 usBridgeIndex;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the conference bridge for errors. */
+ ulResult = Oct6100ApiCheckBridgeParams( f_pApiInstance, f_pConfBridgeOpen );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the conference bridge. */
+ ulResult = Oct6100ApiReserveBridgeResources( f_pApiInstance, &usBridgeIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the new conference bridge's entry in the conference bridge list. */
+ ulResult = Oct6100ApiUpdateBridgeEntry( f_pApiInstance, f_pConfBridgeOpen, usBridgeIndex);
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBridgeParams
+
+Description: Checks the user's conference bridge 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_pConfBridgeOpen Pointer to conference bridge configuration structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBridgeParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen )
+{
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ if ( f_pConfBridgeOpen->pulConfBridgeHndl == NULL )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ if ( f_pApiInstance->pSharedInfo->ImageInfo.fConferencing == FALSE )
+ return cOCT6100_ERR_NOT_SUPPORTED_CONF_BRIDGE;
+
+ if ( f_pConfBridgeOpen->fFlexibleConferencing != FALSE
+ && f_pConfBridgeOpen->fFlexibleConferencing != TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveBridgeResources
+
+Description: Reserves all resources needed for the new 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_pusBridgeIndex Allocated entry in the API conference bridge list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveBridgeResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusBridgeIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Reserve an entry in the conference bridge list. */
+ ulResult = Oct6100ApiReserveBridgeEntry( f_pApiInstance, f_pusBridgeIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateBridgeEntry
+
+Description: Updates the new conference bridge's entry in the conference
+ 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_pConfBridgeOpen Pointer to conference bridge configuration structure.
+f_usBridgeIndex Allocated entry in API conference bridge list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateBridgeEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CONF_BRIDGE_OPEN f_pConfBridgeOpen,
+ IN UINT16 f_usBridgeIndex )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ tPOCT6100_API_CONF_BRIDGE pTempBridgeEntry;
+
+ /*================================================================================*/
+ /* Obtain a pointer to the new conference bridge's list entry. */
+
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex )
+
+ /* No clients are currently connected to the bridge. */
+ pBridgeEntry->usNumClients = 0;
+ /* Nobody is tapped for now. */
+ pBridgeEntry->usNumTappedClients = 0;
+ pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX;
+ pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX;
+ pBridgeEntry->usLastSubStoreEventPtr = cOCT6100_INVALID_INDEX;
+
+ pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX;
+
+ pBridgeEntry->usLoadIndex = cOCT6100_INVALID_INDEX;
+
+ /* Now update the bridge pointer. */
+ if ( f_pApiInstance->pSharedInfo->MiscVars.usNumBridgesOpened == 0 )
+ {
+ pBridgeEntry->usNextBridgePtr = cOCT6100_INVALID_INDEX;
+ pBridgeEntry->usPrevBridgePtr = cOCT6100_INVALID_INDEX;
+
+ /* Set the global first bridge to this bridge. */
+ f_pApiInstance->pSharedInfo->MiscVars.usFirstBridge = f_usBridgeIndex;
+ }
+ else /* Insert this bridge at the head of the bridge list.*/
+ {
+ if ( f_pApiInstance->pSharedInfo->MiscVars.usFirstBridge == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_FATAL_22;
+
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempBridgeEntry, f_pApiInstance->pSharedInfo->MiscVars.usFirstBridge )
+
+ if ( pTempBridgeEntry->fReserved != TRUE )
+ return cOCT6100_ERR_FATAL_23;
+
+ /* Modify the old first entry. */
+ pTempBridgeEntry->usPrevBridgePtr = f_usBridgeIndex;
+
+ /* Modify current pointer. */
+ pBridgeEntry->usPrevBridgePtr = cOCT6100_INVALID_INDEX;
+ pBridgeEntry->usNextBridgePtr = f_pApiInstance->pSharedInfo->MiscVars.usFirstBridge;
+
+ /* Set the new first bridge of the list. */
+ f_pApiInstance->pSharedInfo->MiscVars.usFirstBridge = f_usBridgeIndex;
+ }
+
+ /* Form handle returned to user. */
+ *f_pConfBridgeOpen->pulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pBridgeEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usBridgeIndex;
+
+ /* Remember whether or not we are a flexible conference bridge. */
+ pBridgeEntry->fFlexibleConferencing = (UINT8)( f_pConfBridgeOpen->fFlexibleConferencing & 0xFF );
+
+ /* Finally, mark the conference bridge as opened. */
+ pBridgeEntry->fReserved = TRUE;
+
+ /* Increment the number of conference bridge opened. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberConfBridges++;
+ f_pApiInstance->pSharedInfo->MiscVars.usNumBridgesOpened++;
+
+ /*================================================================================*/
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ConfBridgeChanAddSer
+
+Description: Adds an echo channel (participant) to 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_pConfBridgeAdd Pointer to conference bridge channel add structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeChanAddSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_CHAN_ADD f_pConfBridgeAdd )
+{
+ UINT16 usBridgeIndex;
+ UINT16 usChanIndex;
+ UINT16 usLoadEventIndex;
+ UINT16 usSubStoreEventIndex;
+ UINT16 usCopyEventIndex;
+ UINT32 ulInputPort;
+ UINT8 fFlexibleConfBridge;
+ UINT32 ulListenerMaskIndex;
+ UINT32 ulListenerMask;
+ UINT16 usTapChanIndex;
+ UINT16 usTapBridgeIndex;
+ UINT8 fMute;
+ UINT8 fTap;
+ UINT32 ulResult;
+
+ /* Check the validity of the channel and conference bridge given. */
+ ulResult = Oct6100ApiCheckBridgeAddParams(
+ f_pApiInstance,
+ f_pConfBridgeAdd,
+ &usBridgeIndex,
+ &usChanIndex,
+ &fMute,
+ &ulInputPort,
+ &fFlexibleConfBridge,
+ &ulListenerMaskIndex,
+ &ulListenerMask,
+ &fTap,
+ &usTapChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the conference bridge. */
+ ulResult = Oct6100ApiReserveBridgeAddResources(
+ f_pApiInstance,
+ usBridgeIndex,
+ usChanIndex,
+ ulInputPort,
+ fFlexibleConfBridge,
+ ulListenerMaskIndex,
+ ulListenerMask,
+ fTap,
+ &usLoadEventIndex,
+ &usSubStoreEventIndex,
+ &usCopyEventIndex,
+ &usTapBridgeIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the conference bridge. */
+ ulResult = Oct6100ApiBridgeEventAdd(
+ f_pApiInstance,
+ usBridgeIndex,
+ usChanIndex,
+ fFlexibleConfBridge,
+ usLoadEventIndex,
+ usSubStoreEventIndex,
+ usCopyEventIndex,
+ ulInputPort,
+ fMute,
+ ulListenerMaskIndex,
+ ulListenerMask,
+ fTap,
+ usTapBridgeIndex,
+ usTapChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBridgeAddParams
+
+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_pConfBridgeAdd Pointer to conference bridge channenl add structure.
+f_pusBridgeIndex Extracted bridge index where this channel should be
+ added.
+f_pusChannelIndex Extracted channel index related to the channel handle
+ to be added to the bridge.
+f_pfMute Whether to mute this channel in the bridge or not.
+f_pulInputPort Input port where the channel signal should be
+ copied from.
+f_pfFlexibleConfBridge If this is a flexible conference bridge.
+f_pulListenerMaskIndex Index of the listener in this flexible conference bridge.
+f_pulListenerMask Mask of listeners in this flexible conference bridge.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBridgeAddParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ 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 )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ UINT32 ulEntryOpenCnt;
+ UINT8 byTapChannelLaw;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 1 &&
+ f_pApiInstance->pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ if ( f_pConfBridgeAdd->ulConfBridgeHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ if ( f_pConfBridgeAdd->ulChannelHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_HANDLE;
+
+ if( f_pConfBridgeAdd->ulInputPort != cOCT6100_CHANNEL_PORT_SOUT
+ && f_pConfBridgeAdd->ulInputPort != cOCT6100_CHANNEL_PORT_RIN )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_INPUT_PORT;
+
+ if ( f_pConfBridgeAdd->fMute != TRUE && f_pConfBridgeAdd->fMute != FALSE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_MUTE;
+
+ /*=====================================================================*/
+ /* Check the conference bridge handle. */
+
+ if ( (f_pConfBridgeAdd->ulConfBridgeHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CONF_BRIDGE )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ *f_pusBridgeIndex = (UINT16)( f_pConfBridgeAdd->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_pConfBridgeAdd->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;
+
+ /* When we a flexible conference bridge, more things need to be checked. */
+ if ( pBridgeEntry->fFlexibleConferencing == TRUE )
+ {
+ /* Check if flexible conferencing has been activated. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxFlexibleConfParticipants == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_DISABLED;
+
+ /* Check the number of clients on the bridge. */
+ if ( pBridgeEntry->usNumClients >= cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE )
+ return cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_PARTICIPANT_CNT;
+
+ /* Check if the listener index in a flexible bridge is valid. */
+ if ( f_pConfBridgeAdd->ulListenerMaskIndex == cOCT6100_INVALID_VALUE
+ || f_pConfBridgeAdd->ulListenerMaskIndex >= cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE )
+ return cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_LISTENER_MASK_INDEX;
+ }
+
+ if ( f_pConfBridgeAdd->ulTappedChannelHndl != cOCT6100_INVALID_HANDLE )
+ {
+ if ( pBridgeEntry->fFlexibleConferencing == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_TAP_NOT_SUPPORTED;
+ }
+
+ /*=====================================================================*/
+
+
+ /*=====================================================================*/
+ /* Check the channel handle. */
+
+ if ( (f_pConfBridgeAdd->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_HANDLE;
+
+ *f_pusChannelIndex = (UINT16)( f_pConfBridgeAdd->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_HANDLE;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, *f_pusChannelIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = (f_pConfBridgeAdd->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->usBridgeIndex != cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ALREADY_ON_BRIDGE;
+ if ( pEchoChanEntry->fBiDirChannel == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_BIDIR;
+ /* Law conversion is not allowed on a conference bridge. */
+ if ( ( pEchoChanEntry->TdmConfig.usRinTimeslot != cOCT6100_UNASSIGNED )
+ && ( pEchoChanEntry->TdmConfig.usRoutTimeslot != cOCT6100_UNASSIGNED ) )
+ {
+ if ( pEchoChanEntry->TdmConfig.byRinPcmLaw != pEchoChanEntry->TdmConfig.byRoutPcmLaw )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_LAW_CONVERSION;
+ }
+ if ( ( pEchoChanEntry->TdmConfig.usSinTimeslot != cOCT6100_UNASSIGNED )
+ && ( pEchoChanEntry->TdmConfig.usSoutTimeslot != cOCT6100_UNASSIGNED ) )
+ {
+ if ( pEchoChanEntry->TdmConfig.bySinPcmLaw != pEchoChanEntry->TdmConfig.bySoutPcmLaw )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_LAW_CONVERSION;
+ }
+ if ( pEchoChanEntry->fRinRoutCodecActive == TRUE || pEchoChanEntry->fSinSoutCodecActive == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_CODEC_ACTIVE;
+ if ( pEchoChanEntry->fEnableExtToneDetection == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_EXT_TONE_ENABLED;
+ if ( pEchoChanEntry->usCopyEventCnt != 0x0 )
+ return cOCT6100_ERR_CONF_BRIDGE_COPY_EVENTS;
+
+ /* If the bridge is flexible, few more things need to be checked. */
+ if ( pBridgeEntry->fFlexibleConferencing == TRUE )
+ {
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT16 usChannelIndex;
+ UINT32 ulResult = cOCT6100_ERR_OK;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check if the listener index has been used by another channel in the specified bridge. */
+ for ( usChannelIndex = 0; ( usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels ) && ( ulResult == cOCT6100_ERR_OK ) ; usChannelIndex++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, usChannelIndex );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != ( *f_pusChannelIndex ) ) && ( pEchoChanEntry->fReserved == TRUE ) )
+ {
+ /* On current bridge? */
+ if ( pEchoChanEntry->usBridgeIndex == ( *f_pusBridgeIndex ) )
+ {
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pCurrentParticipant;
+
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pCurrentParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Check if this participant has the same listener index. */
+ if ( f_pConfBridgeAdd->ulListenerMaskIndex == pCurrentParticipant->ulListenerMaskIndex )
+ return cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_LISTENER_INDEX_USED;
+ }
+ }
+ }
+ }
+
+ if ( f_pConfBridgeAdd->ulTappedChannelHndl != cOCT6100_INVALID_HANDLE )
+ {
+ /* For internal logic, make sure the mute flag is set to false. */
+ f_pConfBridgeAdd->fMute = FALSE;
+
+ /* Force input port to Sout for logic below. */
+ f_pConfBridgeAdd->ulInputPort = cOCT6100_CHANNEL_PORT_SOUT;
+
+ /* Keep law to check for conversion. */
+ /* Check if the same law. */
+ byTapChannelLaw = pEchoChanEntry->TdmConfig.bySoutPcmLaw;
+
+ /* Check the tap handle. */
+ if ( (f_pConfBridgeAdd->ulTappedChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_TAP_HANDLE;
+
+ *f_pusTapChannelIndex = (UINT16)( f_pConfBridgeAdd->ulTappedChannelHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusTapChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_TAP_HANDLE;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, *f_pusTapChannelIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = (f_pConfBridgeAdd->ulTappedChannelHndl >> 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_CHANNEL_ADD_INVALID_TAP_HANDLE;
+ if ( pEchoChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_NOT_ON_BRIDGE;
+ if ( pEchoChanEntry->usBridgeIndex != *f_pusBridgeIndex )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_NOT_ON_SAME_BRIDGE;
+
+ /* We can only tap a channel added on the Sout port. */
+ if ( pEchoChanEntry->usSinCopyEventIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_TAP_SOUT_ONLY;
+
+ /* Check if already tapped. */
+ if ( pEchoChanEntry->fBeingTapped == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_ALREADY_TAPPED;
+ }
+
+ /*=====================================================================*/
+
+ /* Return the tap flag. */
+ if ( f_pConfBridgeAdd->ulTappedChannelHndl != cOCT6100_INVALID_HANDLE )
+ {
+ *f_pfTap = TRUE;
+ }
+ else
+ {
+ *f_pfTap = FALSE;
+ }
+
+ /* Return the mute config specified. */
+ *f_pfMute = (UINT8)( f_pConfBridgeAdd->fMute & 0xFF );
+
+ /* Return the input port specified. */
+ *f_pulInputPort = f_pConfBridgeAdd->ulInputPort;
+
+ /* Return whether we are in the flexible conference bridge case. */
+ *f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing;
+
+ /* Return the listener mask index as specified. */
+ *f_pulListenerMaskIndex = f_pConfBridgeAdd->ulListenerMaskIndex;
+
+ /* Return the listener mask as specified. */
+ *f_pulListenerMask = f_pConfBridgeAdd->ulListenerMask;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveBridgeAddResources
+
+Description: Reserves all resources needed for the addition of a channel to
+ 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 Bridge index of the bridge where this channel is added.
+f_usChanIndex Channel index of the channel to be added to the bridge.
+f_ulInputPort Input port where to copy samples from.
+f_fFlexibleConfBridge If this is a flexible conference bridge.
+f_ulListenerMaskIndex Index of the listener in this flexible conference bridge.
+f_ulListenerMask Mask of listeners in this flexible conference bridge.
+f_pusLoadEventIndex Load event index within the API's list of mixer event.
+f_pusSubStoreEventIndex Sub-Store event index within the API's list of mixer event.
+f_pusCopyEventIndex Copy event index within the API's list of mixer event.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveBridgeAddResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ 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 )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pTempEchoChanEntry;
+ UINT32 ulResult;
+ UINT32 ulTempVar;
+ UINT16 usChannelIndex;
+ BOOL fLoadEventReserved = FALSE;
+ BOOL fStoreEventReserved = FALSE;
+ BOOL fCopyEventReserved = FALSE;
+ BOOL fExtraSinTsiReserved = FALSE;
+ BOOL fExtraRinTsiReserved = FALSE;
+
+ /* 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 )
+
+ /* Resources must be reserved according to the type of bridge we are adding to. */
+ if ( f_fFlexibleConfBridge == TRUE )
+ {
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pNewParticipant;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pCurrentParticipant;
+
+ /*========================================================================*/
+ /* If we are in the flexible conferencing case, things are a little */
+ /* different. We create a mixer for every participant instead of the */
+ /* usual same mixer for everyone. For example, if we have 3 participants */
+ /* of type client - agent - coach, we build the mixers as follows: */
+ /* */
+ /* Client: - Load Agent */
+ /* - Store */
+ /* */
+ /* Agent: - Load Client */
+ /* - Accumulate Coach */
+ /* - Store */
+ /* */
+ /* Coach: - Load Client */
+ /* - Accumulate Agent */
+ /* - Store */
+ /* */
+ /*========================================================================*/
+
+ /* First reserve a flexible conferencing participant entry. */
+ ulResult = Oct6100ApiReserveFlexConfParticipantEntry( f_pApiInstance, &pChanEntry->usFlexConfParticipantIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pNewParticipant, pChanEntry->usFlexConfParticipantIndex );
+
+ /* Reserve an entry for the store event in the mixer memory. */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, f_pusSubStoreEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* If using the SOUT port, we must copy this entry */
+ if( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ /* Reserve an entry for the copy event in the Mixer memory. */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, f_pusCopyEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fCopyEventReserved = TRUE;
+
+ /* Reserve a SIN copy entry if none were reserved before.*/
+ if ( pChanEntry->usExtraSinTsiMemIndex == cOCT6100_INVALID_INDEX )
+ {
+ /* Reserve an entry for the extra tsi chariot memory. */
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
+ &pChanEntry->usExtraSinTsiMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ fExtraSinTsiReserved = TRUE;
+ }
+ }
+ }
+ else /* if( f_ulInputPort == cOCT6100_CHANNEL_PORT_RIN ) */
+ {
+ /* Reserve a RIN copy entry if none were reserved before.*/
+ if ( pChanEntry->usExtraRinTsiMemIndex == cOCT6100_INVALID_INDEX )
+ {
+ /* Reserve an entry for the extra tsi chariot memory. */
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
+ &pChanEntry->usExtraRinTsiMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ fExtraRinTsiReserved = TRUE;
+ }
+ }
+
+ /* Must travel all clients of this conference and reserve a load or accumulate event for */
+ /* all participants which can hear us. */
+
+ /* Search through the list of API channel entry for the ones on to this bridge.*/
+ for ( usChannelIndex = 0; ( usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels ) && ( ulResult == cOCT6100_ERR_OK ) ; usChannelIndex++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != f_usChanIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
+ {
+ /* On current bridge? */
+ if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
+ {
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pCurrentParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Check if we can hear this participant. */
+ if ( ( f_ulListenerMask & ( 0x1 << pCurrentParticipant->ulListenerMaskIndex ) ) == 0x0 )
+ {
+ /* Must reserve a load or accumulate entry mixer event here! */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, &pNewParticipant->ausLoadOrAccumulateEventIndex[ pCurrentParticipant->ulListenerMaskIndex ] );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* Most probably, the hardware is out of mixer events. */
+ break;
+ }
+ }
+
+ /* Check if this participant can hear us. */
+ if ( ( pCurrentParticipant->ulListenerMask & ( 0x1 << f_ulListenerMaskIndex ) ) == 0x0 )
+ {
+ /* Must reserve a load or accumulate entry mixer event here! */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, &pCurrentParticipant->ausLoadOrAccumulateEventIndex[ f_ulListenerMaskIndex ] );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* Most probably, the hardware is out of mixer events. */
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* If an error is returned, make sure everything is cleaned up properly. */
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* Release the flexible conferencing participant entry. */
+ ulTempVar = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pChanEntry->usFlexConfParticipantIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pChanEntry->usFlexConfParticipantIndex = cOCT6100_INVALID_INDEX;
+
+ /* Release the substore event in the mixer memory. */
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, *f_pusSubStoreEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ if ( fCopyEventReserved == TRUE )
+ {
+ /* Release the copy event in the mixer memory. */
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, *f_pusCopyEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fExtraSinTsiReserved == TRUE )
+ {
+ /* Release the extra Sin TSI in TSI memory. */
+ ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usExtraSinTsiMemIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ if ( fExtraRinTsiReserved == TRUE )
+ {
+ /* Release the extra Rin TSI in TSI memory. */
+ ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usExtraRinTsiMemIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ /* 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 );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != f_usChanIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
+ {
+ /* On current bridge? */
+ if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
+ {
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pCurrentParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Check if we can hear this participant. */
+ if ( ( f_ulListenerMask & ( 0x1 << pCurrentParticipant->ulListenerMaskIndex ) ) == 0x0 )
+ {
+ /* If the load or event entry in the mixer memory was reserved. */
+ if ( pNewParticipant->ausLoadOrAccumulateEventIndex[ pCurrentParticipant->ulListenerMaskIndex ] != cOCT6100_INVALID_INDEX )
+ {
+ /* Must release the load or accumulate entry mixer event. */
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pNewParticipant->ausLoadOrAccumulateEventIndex[ pCurrentParticipant->ulListenerMaskIndex ] );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pNewParticipant->ausLoadOrAccumulateEventIndex[ pCurrentParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
+ }
+ }
+
+ /* Check this participant can hear us. */
+ if ( ( pCurrentParticipant->ulListenerMask & ( 0x1 << f_ulListenerMaskIndex ) ) == 0x0 )
+ {
+ /* If the load or event entry in the mixer memory was reserved. */
+ if ( pCurrentParticipant->ausLoadOrAccumulateEventIndex[ f_ulListenerMaskIndex ] != cOCT6100_INVALID_INDEX )
+ {
+ /* Must release the load or accumulate entry mixer event. */
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pCurrentParticipant->ausLoadOrAccumulateEventIndex[ f_ulListenerMaskIndex ] );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pCurrentParticipant->ausLoadOrAccumulateEventIndex[ f_ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
+ }
+ }
+ }
+ }
+ }
+
+ return ulResult;
+ }
+ }
+ else /* if ( ulResult != cOCT6100_ERR_OK ) */
+ {
+ ulTempVar = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pChanEntry->usFlexConfParticipantIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pChanEntry->usFlexConfParticipantIndex = cOCT6100_INVALID_INDEX;
+
+ /* Return the error code to the user. The mixer event allocation failed. */
+ return ulResult;
+ }
+
+ /*=======================================================================*/
+ }
+ else /* if ( f_fFlexibleConfBridge == FALSE ) */
+ {
+ /*=======================================================================*/
+ /* Normal conferencing. */
+
+ /* Reserve an entry for the load event in the mixer memory. */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, f_pusLoadEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fLoadEventReserved = TRUE;
+ /* Reserve an entry for the substract and store event in the mixer memory. */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, f_pusSubStoreEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fStoreEventReserved = TRUE;
+
+ /* If using the SOUT port, we must copy this entry */
+ if( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ /* Reserve an entry for the copy event in the mixer memory. */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, f_pusCopyEventIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fCopyEventReserved = TRUE;
+
+ /* Reserve a SIN copy entry if none were reserved before. */
+ if ( pChanEntry->usExtraSinTsiMemIndex == cOCT6100_INVALID_INDEX )
+ {
+ /* Reserve an entry for the extra tsi chariot memory. */
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
+ &pChanEntry->usExtraSinTsiMemIndex );
+
+ if ( ulResult == cOCT6100_ERR_OK )
+ fExtraSinTsiReserved = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if ( ( ulResult == cOCT6100_ERR_OK ) && ( f_fTap == TRUE ) )
+ {
+ /* Reserve a "tap" bridge. */
+ tOCT6100_CONF_BRIDGE_OPEN ConfBridgeOpen;
+ UINT32 ulTapBridgeHndl;
+
+ Oct6100ConfBridgeOpenDef( &ConfBridgeOpen );
+
+ ConfBridgeOpen.pulConfBridgeHndl = &ulTapBridgeHndl;
+
+ ulResult = Oct6100ConfBridgeOpenSer( f_pApiInstance, &ConfBridgeOpen );
+
+ *f_pusTapBridgeIndex = (UINT16)( ulTapBridgeHndl & cOCT6100_HNDL_INDEX_MASK );
+ }
+
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( fLoadEventReserved == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, *f_pusLoadEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fStoreEventReserved == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, *f_pusSubStoreEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fCopyEventReserved == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, *f_pusCopyEventIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if ( fExtraSinTsiReserved == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usExtraSinTsiMemIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ return ulResult;
+ }
+
+ /*=======================================================================*/
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiBridgeEventAdd
+
+Description: Add the event into 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_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.
+f_ulInputPort Input port where to copy samples from.
+f_fMute Mute flag indicating if the channel is added in
+ a mute state.
+f_ulListenerMaskIndex Index of the listener in this flexible conference bridge.
+f_ulListenerMask Mask of listeners in this flexible conference bridge.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiBridgeEventAdd(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ 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 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 )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+
+ tPOCT6100_API_MIXER_EVENT pLoadEventEntry;
+ tPOCT6100_API_MIXER_EVENT pSubStoreEventEntry;
+ tPOCT6100_API_MIXER_EVENT pTempEntry;
+
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ tPOCT6100_API_CHANNEL pTapEchoChanEntry = NULL;
+ tPOCT6100_API_CHANNEL pTempEchoChanEntry;
+
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+
+ UINT32 ulResult;
+ UINT16 usChannelIndex;
+ UINT16 usLastSubStoreEventIndex;
+ UINT16 usLastLoadEventIndex;
+
+ BOOL fAddSinCopy = FALSE;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Get the bridge and channel entries of interest. */
+ if ( f_fTap == FALSE )
+ {
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, f_usBridgeIndex );
+ }
+ else
+ {
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, f_usTapBridgeIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTapEchoChanEntry, f_usTapChanIndex );
+ }
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
+
+ /* Configure the SIN copy mixer entry and memory - if using the SOUT port. */
+ if ( ( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( f_fTap == FALSE ) )
+ {
+ if ( pEchoChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pEchoChanEntry->usSinTsstIndex,
+ pEchoChanEntry->usExtraSinTsiMemIndex,
+ pEchoChanEntry->TdmConfig.bySinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* If the silence TSI is loaded on this port, update with the extra 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->usExtraSinTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ if ( f_fFlexibleConfBridge == TRUE )
+ {
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pNewParticipant;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pCurrentParticipant;
+
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pNewParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Search through the list of API channel entry for the ones onto this bridge. */
+ for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != f_usChanIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
+ {
+ /* On current bridge? */
+ if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
+ {
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pCurrentParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Check if we can hear this participant. */
+ if ( ( pTempEchoChanEntry->fMute == FALSE ) && ( ( f_ulListenerMask & ( 0x1 << pCurrentParticipant->ulListenerMaskIndex ) ) == 0x0 ) )
+ {
+ /* First create/update the current channel's mixer. */
+ ulResult = Oct6100ApiBridgeAddParticipantToChannel(
+ f_pApiInstance,
+ f_usBridgeIndex,
+ usChannelIndex,
+ f_usChanIndex,
+ pNewParticipant->ausLoadOrAccumulateEventIndex[ pCurrentParticipant->ulListenerMaskIndex ],
+ f_usSubStoreEventIndex,
+ f_usCopyEventIndex,
+ pCurrentParticipant->ulInputPort,
+ f_ulInputPort );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Check if this participant can hear us. */
+ if ( ( f_fMute == FALSE ) && ( ( pCurrentParticipant->ulListenerMask & ( 0x1 << f_ulListenerMaskIndex ) ) == 0x0 ) )
+ {
+ /* Then create/update this channel's mixer. */
+ ulResult = Oct6100ApiBridgeAddParticipantToChannel(
+ f_pApiInstance,
+ f_usBridgeIndex,
+ f_usChanIndex,
+ usChannelIndex,
+ pCurrentParticipant->ausLoadOrAccumulateEventIndex[ f_ulListenerMaskIndex ],
+ pTempEchoChanEntry->usSubStoreEventIndex,
+ pTempEchoChanEntry->usSinCopyEventIndex,
+ f_ulInputPort,
+ pCurrentParticipant->ulInputPort );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Check if the Rin silence event can be cleared now that the */
+ /* channel has been added to a conference. */
+ if ( ( pCurrentParticipant->fFlexibleMixerCreated == TRUE )
+ && ( pTempEchoChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
+ {
+ /* Remove the event from the list. */
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pTempEchoChanEntry->usRinSilenceEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pTempEchoChanEntry->usRinSilenceEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_DF;
+
+ pTempEchoChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+ }
+ }
+ }
+ }
+
+ /* Check if the mixer for the destination channel has been created. */
+ if ( pNewParticipant->fFlexibleMixerCreated == FALSE )
+ {
+ /* Save store event index that might be used for next channel added. */
+ pEchoChanEntry->usSubStoreEventIndex = f_usSubStoreEventIndex;
+ }
+ else
+ {
+ /* Check if the Rin silence event can be cleared now that the */
+ /* channel has been added to a conference. */
+ if ( pEchoChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Remove the event from the list.*/
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pEchoChanEntry->usRinSilenceEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pEchoChanEntry->usRinSilenceEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_DF;
+
+ pEchoChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+ }
+
+ pNewParticipant->ulListenerMaskIndex = f_ulListenerMaskIndex;
+ pNewParticipant->ulListenerMask = f_ulListenerMask;
+
+ /* Remember this channel's input port. */
+ pNewParticipant->ulInputPort = f_ulInputPort;
+
+ /*=======================================================================*/
+ }
+ else /* if ( f_fFlexibleConfBridge == FALSE ) */
+ {
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, f_usLoadEventIndex );
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex );
+
+ /*=======================================================================*/
+ /* Program the Load event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ if ( ( f_fMute == FALSE ) || ( f_fTap == TRUE ) )
+ {
+ if ( pBridgeEntry->usLoadIndex != cOCT6100_INVALID_INDEX )
+ {
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+
+ /* Set the event type. */
+ pLoadEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+
+ if ( f_fTap == TRUE )
+ return cOCT6100_ERR_FATAL_D1;
+ }
+ else /* pBridgeEntry->usLoadIndex == cOCT6100_INVALID_INDEX */
+ {
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+
+ /* Modify the bridge entry to show store the new load index.*/
+ pBridgeEntry->usLoadIndex = f_usLoadEventIndex;
+
+ /* Set the event type.*/
+ pLoadEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+ }
+
+ /* Select the TSI memory index according to the source port. */
+ if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ if ( f_fTap == FALSE )
+ {
+ WriteParams.usWriteData |= pEchoChanEntry->usSinSoutTsiMemIndex;
+ }
+ else
+ {
+ tPOCT6100_API_CONF_BRIDGE pTempBridgeEntry;
+ UINT16 usTempWriteData;
+ UINT32 ulTempWriteAddress;
+
+ /* Save temp write data before trying to clear the Rin TSST. */
+ usTempWriteData = WriteParams.usWriteData;
+ ulTempWriteAddress = WriteParams.ulWriteAddress;
+
+ /* Clear the Rin TSST if used. */
+ if ( pTapEchoChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Deactivate the TSST entry.*/
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pTapEchoChanEntry->usRinTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.usWriteData = 0x0000;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Reassign write data that might have been cleared by write above. */
+ WriteParams.usWriteData = usTempWriteData;
+ WriteParams.ulWriteAddress = ulTempWriteAddress;
+ WriteParams.usWriteData |= pTapEchoChanEntry->usRinRoutTsiMemIndex;
+
+ /* Remember that this channel is being tapped by us. */
+ pTapEchoChanEntry->fBeingTapped = TRUE;
+ pTapEchoChanEntry->usTapChanIndex = f_usChanIndex;
+
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pTempBridgeEntry, f_usBridgeIndex );
+
+ pTempBridgeEntry->usNumTappedClients++;
+ }
+ }
+ else /* if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_RIN ) */
+ {
+ WriteParams.usWriteData |= pEchoChanEntry->usRinRoutTsiMemIndex;
+ }
+ }
+ else /* f_fMute == TRUE */
+ {
+ /* Do not load the sample if the channel is muted. */
+ if ( pBridgeEntry->usNumClients == 0 )
+ {
+ /* If the participant to be added is muted, and it would cause the conference to */
+ /* be completely muted, load the silence TSI. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+ WriteParams.usWriteData |= 1534; /* TSI index 1534 reserved for silence */
+
+ /* We know for sure that the load of the bridge will be the silence one. */
+ pBridgeEntry->usSilenceLoadEventPtr = f_usLoadEventIndex;
+ }
+ else
+ {
+ /* Do nothing! */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
+ }
+
+ /* Set the event type. */
+ pLoadEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Program the Substract and store event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ if ( ( f_fMute == FALSE ) && ( f_fTap == FALSE ) )
+ {
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_SUB_STORE;
+ /* Select the TSI memory index and PCM law according to the source port. */
+ if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ WriteParams.usWriteData |= pEchoChanEntry->usSinSoutTsiMemIndex;
+ }
+ else /* if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_RIN ) */
+ {
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.byRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ WriteParams.usWriteData |= pEchoChanEntry->usRinRoutTsiMemIndex;
+ }
+
+ /* Set the event type. */
+ pSubStoreEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_SUB_STORE;
+ }
+ else /* f_fMute == TRUE */
+ {
+ /* Do not substore the sample if the channel is muted. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_STORE;
+
+ /* Select the PCM law according to the source port. */
+ if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ }
+ else /* if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_RIN ) */
+ {
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.byRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ }
+ /* Set the event type. */
+ pSubStoreEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_STORE;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pEchoChanEntry->usRinRoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Program the Copy event - if using the SOUT port */
+ if ( ( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( f_fTap == FALSE ) )
+ {
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ WriteParams.usWriteData |= pEchoChanEntry->usExtraSinTsiMemIndex;
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pEchoChanEntry->usSinSoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Set add copy event flag. */
+ fAddSinCopy = TRUE;
+
+ /* For sure. */
+ pEchoChanEntry->fCopyEventCreated = TRUE;
+ }
+ else if ( f_fTap == TRUE )
+ {
+ /* Accumulate the tapped channel's voice instead of building a copy event. */
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+ WriteParams.usWriteData |= pTapEchoChanEntry->usSinSoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Link to next operation. */
+ WriteParams.ulWriteAddress += 4;
+ WriteParams.usWriteData = f_usSubStoreEventIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the software model. */
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, f_usCopyEventIndex );
+
+ pTempEntry->usSourceChanIndex = f_usTapChanIndex;
+ pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+ pTempEntry->usNextEventPtr = f_usSubStoreEventIndex;
+ pTempEntry->usDestinationChanIndex = cOCT6100_INVALID_INDEX;
+ pTempEntry->fReserved = TRUE;
+ }
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Now insert the event into the list.*/
+ if ( pBridgeEntry->usNumClients == 0 )
+ {
+ /* This is the first entry for this bridge. Insert the two events at the head
+ of the list just after the last sub-store event.*/
+ if ( f_fTap == FALSE )
+ {
+ ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usLastSubStoreEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND )
+ {
+ if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
+ {
+ usLastSubStoreEventIndex = cOCT6100_MIXER_HEAD_NODE;
+ }
+ else
+ {
+ usLastSubStoreEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
+ }
+ }
+ else
+ {
+ return cOCT6100_ERR_FATAL_26;
+ }
+ }
+ }
+ else
+ {
+ if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
+ {
+ usLastSubStoreEventIndex = cOCT6100_MIXER_HEAD_NODE;
+ }
+ else
+ {
+ usLastSubStoreEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
+ }
+ }
+
+ /* An Entry was found, now, modify it's value.*/
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usLastSubStoreEventIndex );
+
+ /* Set the Sub-Store event first.*/
+ pSubStoreEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_SUB_STORE;
+ pSubStoreEventEntry->usNextEventPtr = pTempEntry->usNextEventPtr;
+
+ /*=======================================================================*/
+ /* Program the Sub-Store event. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.ulWriteAddress += 4;
+ WriteParams.usWriteData = (UINT16)( pSubStoreEventEntry->usNextEventPtr );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+ /* Set the load/accumulate event now.*/
+ if ( f_fTap == FALSE )
+ {
+ pLoadEventEntry->usNextEventPtr = f_usSubStoreEventIndex;
+ }
+ else
+ {
+ /* This is a little tricky, we use the copy event index for accumulating the tapped channel's voice. */
+ pLoadEventEntry->usNextEventPtr = f_usCopyEventIndex;
+ }
+
+ /*=======================================================================*/
+ /* Program the load/accumulate event. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.ulWriteAddress += 4;
+
+ WriteParams.usWriteData = (UINT16)( pLoadEventEntry->usNextEventPtr );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+ /* Now modify the previous last Sub Store event from another bridge. */
+ pTempEntry->usNextEventPtr = f_usLoadEventIndex;
+
+ /*=======================================================================*/
+ /* Modify the last node of the other bridge. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastSubStoreEventIndex * 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 = f_usLoadEventIndex;
+ pBridgeEntry->usFirstSubStoreEventPtr = f_usSubStoreEventIndex;
+ pBridgeEntry->usLastSubStoreEventPtr = f_usSubStoreEventIndex;
+
+ /* Update the global mixer pointers. */
+ if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == cOCT6100_INVALID_INDEX )
+ {
+ /* This bridge is the first to generate mixer event. */
+ pSharedInfo->MixerInfo.usFirstBridgeEventPtr = f_usLoadEventIndex;
+ pSharedInfo->MixerInfo.usLastBridgeEventPtr = f_usSubStoreEventIndex;
+ }
+ else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == usLastSubStoreEventIndex )
+ {
+ /* The two entries were added at the end of the bridge section, */
+ /* change only the last pointer. */
+ pSharedInfo->MixerInfo.usLastBridgeEventPtr = f_usSubStoreEventIndex;
+ }
+ else if ( usLastSubStoreEventIndex == cOCT6100_MIXER_HEAD_NODE ||
+ usLastSubStoreEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
+ {
+ /* The two entries were added at the start of the bridge section, */
+ /* change only the first pointer. */
+ pSharedInfo->MixerInfo.usFirstBridgeEventPtr = f_usLoadEventIndex;
+ }
+ }
+ else /* pBridgeEntry->usNumClients != 0 */
+ {
+ /* For sanity. */
+ if ( f_fTap == TRUE )
+ return cOCT6100_ERR_FATAL_D2;
+
+ /*=======================================================================*/
+ /* Program the Load event. */
+
+ /* Now find the last load entry of this bridge. */
+ ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pBridgeEntry->usFirstLoadEventPtr, pBridgeEntry->usFirstSubStoreEventPtr, 0, &usLastLoadEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Add the load/accumulate event to the list. */
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usLastLoadEventIndex );
+
+ /* Set the load event now. */
+ pLoadEventEntry->usNextEventPtr = pTempEntry->usNextEventPtr;
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.ulWriteAddress += 4;
+
+ WriteParams.usWriteData = (UINT16)( pLoadEventEntry->usNextEventPtr );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Modify the previous last load event. */
+
+ /* Now modify the previous last load event. */
+ pTempEntry->usNextEventPtr = f_usLoadEventIndex;
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastLoadEventIndex * 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;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Program the Sub-Store event. */
+
+ usLastSubStoreEventIndex = pBridgeEntry->usLastSubStoreEventPtr;
+
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usLastSubStoreEventIndex );
+
+ /* Set the Sub-Store event first. */
+ pSubStoreEventEntry->usNextEventPtr = pTempEntry->usNextEventPtr;
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.ulWriteAddress += 4;
+
+ WriteParams.usWriteData = (UINT16)( pSubStoreEventEntry->usNextEventPtr );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Modify the previous last sub store event of the bridge. */
+
+ /* Now modify the last Load event of the bridge. */
+ pTempEntry->usNextEventPtr = f_usSubStoreEventIndex;
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastSubStoreEventIndex * 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. */
+ pBridgeEntry->usLastSubStoreEventPtr = f_usSubStoreEventIndex;
+
+ /* Check if modification to the global mixer pointer are required. */
+ if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == usLastSubStoreEventIndex )
+ {
+ /* We have a new last bridge pointer. */
+ pSharedInfo->MixerInfo.usLastBridgeEventPtr = f_usSubStoreEventIndex;
+ }
+ }
+
+ if ( f_fTap == TRUE )
+ {
+ if ( pEchoChanEntry->usRinTsstIndex == cOCT6100_INVALID_INDEX )
+ {
+ /* Remove the mute on the Rin port. */
+
+ UINT32 ulTempData;
+ UINT32 ulMask;
+ UINT32 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usChanIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
+
+ /* Configure the level control. */
+
+ UINT32 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.usDwordOffset * 4;
+ UINT32 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.byBitOffset;
+ UINT32 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinLevelControlOfst.byFieldSize;
+
+ 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);
+
+ /* Set the DC filter to pass through.*/
+ ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
+
+ /* First read the DWORD where the field is located. */
+ mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
+ pEchoChanEntry,
+ ulBaseAddress + ulFeatureBytesOffset,
+ ulTempData,
+ ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* Set the event entries as reserved. */
+ pLoadEventEntry->fReserved = TRUE;
+ pSubStoreEventEntry->fReserved = TRUE;
+
+ /* Store the event indexes into the channel structure. */
+ pEchoChanEntry->usLoadEventIndex = f_usLoadEventIndex;
+ pEchoChanEntry->usSubStoreEventIndex = f_usSubStoreEventIndex;
+
+ /* Check if must insert the Sin copy event in the list. */
+ if ( fAddSinCopy == TRUE )
+ {
+ /* Now insert the Sin copy event into the list. */
+ ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
+ f_usCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY,
+ f_usChanIndex );
+ }
+
+ /* Check if the Rin silence event can be cleared now that the */
+ /* channel has been added to a conference. */
+ if ( ( f_fTap == FALSE ) && ( pEchoChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
+ {
+ /* Remove the event from the list. */
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pEchoChanEntry->usRinSilenceEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pEchoChanEntry->usRinSilenceEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_DF;
+
+ pEchoChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+ }
+
+ /* Configure the RIN copy mixer entry and memory - if using the RIN port. */
+ if ( ( f_fFlexibleConfBridge == TRUE ) && ( f_ulInputPort == cOCT6100_CHANNEL_PORT_RIN ) )
+ {
+ if ( pEchoChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pEchoChanEntry->usRinTsstIndex,
+ pEchoChanEntry->usExtraRinTsiMemIndex,
+ pEchoChanEntry->TdmConfig.byRinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ if ( pBridgeEntry->fDominantSpeakerSet == TRUE )
+ {
+ /* Dominant speaker is another channel. Set accordingly for this new conference channel. */
+ ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_usChanIndex, pBridgeEntry->usDominantSpeakerChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ else
+ {
+ /* No dominant speaker set on this bridge yet. */
+ ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_usChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Update the bridge entry. */
+ pBridgeEntry->usNumClients++;
+
+ /* Store the bridge index into the channel structure. */
+ pEchoChanEntry->usBridgeIndex = f_usBridgeIndex;
+
+ /* Store the copy event index into the channel structure. */
+ if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ pEchoChanEntry->usSinCopyEventIndex = f_usCopyEventIndex;
+ }
+ else
+ {
+ pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ /* Remember if the channel is muted in the conference. */
+ pEchoChanEntry->fMute = f_fMute;
+
+ /* Remember if the channel is a tap in a conference. */
+ pEchoChanEntry->fTap = f_fTap;
+
+ /* We start by not being tapped. */
+ pEchoChanEntry->fBeingTapped = FALSE;
+ pEchoChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
+
+ /* Remember the tap bridge index if necessary. */
+ if ( pEchoChanEntry->fTap == TRUE )
+ {
+ pEchoChanEntry->usTapBridgeIndex = f_usTapBridgeIndex;
+ }
+ else
+ {
+ pEchoChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ /* Indicate that the extra SIN TSI is currently in used by the conference bridge. */
+ if ( f_ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ pEchoChanEntry->usExtraSinTsiDependencyCnt++;
+ }
+
+ /* Indicate that the extra RIN TSI is currently in used by the conference bridge. */
+ if ( ( f_fFlexibleConfBridge == TRUE ) && ( f_ulInputPort == cOCT6100_CHANNEL_PORT_RIN ) )
+ {
+ pEchoChanEntry->usExtraRinTsiDependencyCnt++;
+ }
+
+ /* Update the chip stats structure. */
+ pSharedInfo->ChipStats.usNumEcChanUsingMixer++;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiBridgeAddParticipantToChannel
+
+Description: Used for the flexible conference bridges. Insert a participant
+ onto a channel that is on a conference.
+
+-------------------------------------------------------------------------------
+| 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_usLoadOrAccumulateEventIndex Load or Accumulate allocated event index.
+f_usStoreEventIndex Store allocated event index.
+f_usCopyEventIndex Copy allocated event index.
+f_ulSourceInputPort Source input port of the conference for this channel.
+f_ulDestinationInputPort Destination input port of the conference for this channel.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiBridgeAddParticipantToChannel(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ 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 )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+
+ tPOCT6100_API_MIXER_EVENT pLoadEventEntry;
+ tPOCT6100_API_MIXER_EVENT pStoreEventEntry;
+ tPOCT6100_API_MIXER_EVENT pTempEntry;
+
+ 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;
+
+ UINT32 ulResult;
+ UINT16 usLastSubStoreEventIndex;
+ UINT16 usLastLoadEventIndex;
+ BOOL fInsertCopy = FALSE;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ 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 );
+
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, f_usLoadOrAccumulateEventIndex );
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pStoreEventEntry, f_usStoreEventIndex );
+
+ /* Check if we are creating the first event for this channel. */
+ if ( pDestinationParticipant->fFlexibleMixerCreated == FALSE )
+ {
+ /*=======================================================================*/
+ /* Program the load event. This is the first event for this new destination channel. */
+
+ /* First set the TSI buffer where the resulting stream should be written to. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadOrAccumulateEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ /* For sure, we are loading. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+
+ /* Select the TSI memory index according to the source port. */
+ if ( f_ulSourceInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ WriteParams.usWriteData |= pSourceChanEntry->usSinSoutTsiMemIndex;
+ }
+ else /* if ( f_ulSourceInputPort == cOCT6100_CHANNEL_PORT_RIN ) */
+ {
+ WriteParams.usWriteData |= pSourceChanEntry->usExtraRinTsiMemIndex;
+ }
+
+ /* Set the event type. */
+ pLoadEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+
+ /* Set the source channel index. */
+ pLoadEventEntry->usSourceChanIndex = f_usSourceChannelIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+
+ /*=======================================================================*/
+ /* Program the store event. */
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_STORE;
+
+ /* Select the TSI memory index and PCM law according to the source port. */
+ if ( f_ulDestinationInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ WriteParams.usWriteData |= pDestinationChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ WriteParams.usWriteData |= pDestinationChanEntry->usSinSoutTsiMemIndex;
+ }
+ else /* if ( f_ulDestinationInputPort == cOCT6100_CHANNEL_PORT_RIN ) */
+ {
+ WriteParams.usWriteData |= pDestinationChanEntry->TdmConfig.byRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ WriteParams.usWriteData |= pDestinationChanEntry->usRinRoutTsiMemIndex;
+ }
+
+ /* Set the event type. */
+ pStoreEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_STORE;
+
+ /* Set the destination channel index. */
+ pStoreEventEntry->usDestinationChanIndex = f_usDestinationChannelIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pDestinationChanEntry->usRinRoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+
+ /*=======================================================================*/
+ /* Program the Copy event - if using the SOUT port */
+
+ if ( ( f_ulDestinationInputPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pDestinationChanEntry->fCopyEventCreated == FALSE ) )
+ {
+ /* The copy event has not been created, create it once for the life of the participant on the bridge. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ WriteParams.usWriteData |= pDestinationChanEntry->usExtraSinTsiMemIndex;
+ WriteParams.usWriteData |= pDestinationChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pDestinationChanEntry->usSinSoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ pDestinationChanEntry->fCopyEventCreated = TRUE;
+
+ /* Set insert copy flag. */
+ fInsertCopy = TRUE;
+ }
+
+ /*=======================================================================*/
+
+
+
+ /*=======================================================================*/
+ /*=======================================================================*/
+ /* Now, insert the events into the current list. */
+ /*=======================================================================*/
+ /*=======================================================================*/
+
+ /* This is the first entry for this channel. Insert the two events at the head */
+ /* of the list just after the last Sub-Store or Store event. */
+ ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, f_usLoadOrAccumulateEventIndex, &usLastSubStoreEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND )
+ {
+ if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
+ {
+ usLastSubStoreEventIndex = cOCT6100_MIXER_HEAD_NODE;
+ }
+ else
+ {
+ usLastSubStoreEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
+ }
+ }
+ else
+ {
+ return cOCT6100_ERR_FATAL_26;
+ }
+ }
+
+ /* An entry was found, now, modify it's value. */
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usLastSubStoreEventIndex );
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Link the store event first. */
+
+ pStoreEventEntry->usNextEventPtr = pTempEntry->usNextEventPtr;
+
+ /* Link the store event. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.ulWriteAddress += 4;
+ WriteParams.usWriteData = (UINT16)( pStoreEventEntry->usNextEventPtr );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Link the load event now.*/
+
+ pLoadEventEntry->usNextEventPtr = f_usStoreEventIndex;
+
+ /* Link the load event.*/
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadOrAccumulateEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.ulWriteAddress += 4;
+
+ WriteParams.usWriteData = (UINT16)( pLoadEventEntry->usNextEventPtr );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Now modify the previous last Sub-Store or Store event from another bridge, */
+ /* such that it links to us. */
+
+ pTempEntry->usNextEventPtr = f_usLoadOrAccumulateEventIndex;
+
+ /* Modify the last node of the other bridge. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastSubStoreEventIndex * 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. */
+
+ if ( pBridgeEntry->usFirstLoadEventPtr == cOCT6100_INVALID_INDEX )
+ {
+ /* We only do this once in case of the flexible conference bridges. */
+ pBridgeEntry->usFirstLoadEventPtr = f_usLoadOrAccumulateEventIndex;
+ pBridgeEntry->usFirstSubStoreEventPtr = f_usStoreEventIndex;
+ }
+
+ pBridgeEntry->usLastSubStoreEventPtr = f_usStoreEventIndex;
+
+ /* Update the global mixer pointers. */
+ if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == cOCT6100_INVALID_INDEX )
+ {
+ /* This bridge is the first to generate mixer event. */
+ pSharedInfo->MixerInfo.usFirstBridgeEventPtr = f_usLoadOrAccumulateEventIndex;
+ pSharedInfo->MixerInfo.usLastBridgeEventPtr = f_usStoreEventIndex;
+ }
+ else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == usLastSubStoreEventIndex )
+ {
+ /* The two entries were added at the end of the bridge section, */
+ /* change only the last pointer. */
+ pSharedInfo->MixerInfo.usLastBridgeEventPtr = f_usStoreEventIndex;
+ }
+ else if ( usLastSubStoreEventIndex == cOCT6100_MIXER_HEAD_NODE ||
+ usLastSubStoreEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
+ {
+ /* The two entries were added at the start of the bridge section, */
+ /* change only the first pointer.*/
+ pSharedInfo->MixerInfo.usFirstBridgeEventPtr = f_usLoadOrAccumulateEventIndex;
+ }
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Insert the copy event if needed in the mixer's list. */
+
+ if ( fInsertCopy == TRUE )
+ {
+ /* Now insert the Sin copy event into the list. */
+ ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
+ f_usCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY,
+ f_usDestinationChannelIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Update the status of the instance structures. */
+
+ pDestinationParticipant->fFlexibleMixerCreated = TRUE;
+
+ /* Set the event entries as reserved. */
+ pLoadEventEntry->fReserved = TRUE;
+ pStoreEventEntry->fReserved = TRUE;
+
+ /* Store the event indexes into the channel structure. */
+ pDestinationChanEntry->usLoadEventIndex = f_usLoadOrAccumulateEventIndex;
+ pDestinationChanEntry->usSubStoreEventIndex = f_usStoreEventIndex;
+
+ /*=======================================================================*/
+ }
+ else /* if ( pDestinationChanEntry->fFlexibleMixerCreated == TRUE ) */
+ {
+ /*=======================================================================*/
+ /* Program the Accumulate event. */
+
+ /* First set the TSI buffer where the resulting stream should be written to. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadOrAccumulateEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ /* For sure, we are accumulating. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+
+ /* Select the TSI memory index according to the source port. */
+ if ( f_ulSourceInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ WriteParams.usWriteData |= pSourceChanEntry->usSinSoutTsiMemIndex;
+ }
+ else /* if ( f_ulSourceInputPort == cOCT6100_CHANNEL_PORT_RIN ) */
+ {
+ WriteParams.usWriteData |= pSourceChanEntry->usExtraRinTsiMemIndex;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+
+ /*=======================================================================*/
+ /*=======================================================================*/
+ /* Now, insert the Accumulate event into the current list. */
+ /*=======================================================================*/
+ /*=======================================================================*/
+
+ /* Use the Load entry of this channel. */
+ usLastLoadEventIndex = pDestinationChanEntry->usLoadEventIndex;
+
+ /* Add the Accumulate event to the list. */
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usLastLoadEventIndex );
+
+ /* Set the accumulate event now. */
+ pLoadEventEntry->usNextEventPtr = pTempEntry->usNextEventPtr;
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadOrAccumulateEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ WriteParams.ulWriteAddress += 4;
+
+ WriteParams.usWriteData = (UINT16)( pLoadEventEntry->usNextEventPtr );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+
+
+ /*=======================================================================*/
+ /* Modify the previous Load event. */
+
+ /* Now modify the previous Load event. */
+ pTempEntry->usNextEventPtr = f_usLoadOrAccumulateEventIndex;
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastLoadEventIndex * 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 status of the instance structures. */
+
+ /* Set the Accumulate event entry as reserved. */
+ pLoadEventEntry->fReserved = TRUE;
+ /* Set the Event type. */
+ pLoadEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+ /* Set the source channel index. */
+ pLoadEventEntry->usSourceChanIndex = f_usSourceChannelIndex;
+
+ /*=======================================================================*/
+ }
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeChanRemoveSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove )
+{
+ UINT16 usBridgeIndex;
+ UINT16 usChanIndex;
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ConfBridgeChanMuteSer
+
+Description: Mute an echo channel present on 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_pConfBridgeMute Pointer to conference bridge mute structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeChanMuteSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute )
+{
+ UINT16 usChanIndex;
+ UINT16 usLoadEventIndex;
+ UINT16 usSubStoreEventIndex;
+ UINT32 ulResult;
+ UINT8 fFlexibleConferencing;
+
+ /* Check the validity of the channel and conference bridge given. */
+ ulResult = Oct6100ApiCheckBridgeMuteParams(
+ f_pApiInstance,
+ f_pConfBridgeMute,
+ &usChanIndex,
+ &usLoadEventIndex,
+ &usSubStoreEventIndex,
+ &fFlexibleConferencing );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Modify all resources needed by the conference bridge. */
+ ulResult = Oct6100ApiUpdateBridgeMuteResources(
+ f_pApiInstance,
+ usChanIndex,
+ usLoadEventIndex,
+ usSubStoreEventIndex,
+ fFlexibleConferencing );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBridgeMuteParams
+
+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_pConfBridgeMute Pointer to conference bridge channel mute structure.
+f_pusChannelIndex Pointer to a channel index.
+f_pusLoadEventIndex Pointer to a load mixer event index.
+f_pusSubStoreEventIndex Pointer to a sub-store mixer event index.
+f_pfFlexibleConfBridge If this is a flexible conference bridge.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBridgeMuteParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_CHAN_MUTE f_pConfBridgeMute,
+ OUT PUINT16 f_pusChannelIndex,
+ OUT PUINT16 f_pusLoadEventIndex,
+ OUT PUINT16 f_pusSubStoreEventIndex,
+ OUT PUINT8 f_pfFlexibleConfBridge )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ if ( f_pConfBridgeMute->ulChannelHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_HANDLE;
+
+ /*=====================================================================*/
+ /* Check the channel handle.*/
+
+ if ( (f_pConfBridgeMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ *f_pusChannelIndex = (UINT16)( f_pConfBridgeMute->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_pConfBridgeMute->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;
+
+ /* Check if the channel is bound to a conference bridge. */
+ if ( pEchoChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_INVALID_HANDLE;
+
+ /* Check if channel is already muted. */
+ if ( pEchoChanEntry->fMute == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_ALREADY_MUTED;
+
+ /* Check if this is a tap channel, which is always mute. */
+ if ( pEchoChanEntry->fTap == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_ALWAYS_MUTE;
+
+ /*=====================================================================*/
+
+ /*=====================================================================*/
+ /* Check the conference bridge handle. */
+
+ if ( pEchoChanEntry->usBridgeIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, pEchoChanEntry->usBridgeIndex )
+
+ /* Check for errors. */
+ if ( pBridgeEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN;
+
+ if ( pBridgeEntry->fFlexibleConferencing == FALSE )
+ {
+ /* Check the event entries.*/
+ if ( pEchoChanEntry->usLoadEventIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_INVALID_HANDLE;
+
+ if ( pEchoChanEntry->usSubStoreEventIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_INVALID_HANDLE;
+ }
+
+ /*=====================================================================*/
+
+ /* Return the config of the channel and all other important information. */
+ *f_pusSubStoreEventIndex = pEchoChanEntry->usSubStoreEventIndex;
+ *f_pusLoadEventIndex = pEchoChanEntry->usLoadEventIndex;
+ *f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateBridgeMuteResources
+
+Description: Modify the conference bridge entry for this channel in order
+ to mute 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_usChanIndex Index of the channel to be muted.
+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_fFlexibleConfBridge If this is a flexible conference bridge.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateBridgeMuteResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usChanIndex,
+ IN UINT16 f_usLoadEventIndex,
+ IN UINT16 f_usSubStoreEventIndex,
+ IN UINT8 f_fFlexibleConfBridge )
+{
+ tOCT6100_WRITE_PARAMS WriteParams;
+ tOCT6100_READ_PARAMS ReadParams;
+
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+
+ tPOCT6100_API_MIXER_EVENT pLoadEventEntry;
+ tPOCT6100_API_MIXER_EVENT pSubStoreEventEntry;
+ tPOCT6100_API_MIXER_EVENT pTempEntry;
+ UINT32 ulResult;
+ UINT16 usTempEventIndex;
+ UINT32 ulLoopCount;
+ UINT16 usReadData;
+
+ BOOL fCreateSilenceLoad = 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_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, pEchoChanEntry->usBridgeIndex )
+
+ if ( f_fFlexibleConfBridge == TRUE )
+ {
+ tPOCT6100_API_CHANNEL pTempEchoChanEntry;
+ UINT16 usChannelIndex;
+ 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;
+
+ 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 == pEchoChanEntry->usBridgeIndex )
+ {
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Check if this participant can hear us. */
+ if ( ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
+ && ( pTempParticipant->fFlexibleMixerCreated == TRUE ) )
+ {
+ /* Then update this channel's mixer. */
+ ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
+ f_pApiInstance,
+ pEchoChanEntry->usBridgeIndex,
+ f_usChanIndex,
+ usChannelIndex,
+ FALSE );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ if ( pTempParticipant->fFlexibleMixerCreated == FALSE )
+ {
+ /* 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;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* 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 )
+ {
+ if ( ulResult == cOCT6100_ERR_MIXER_ALL_MIXER_EVENT_ENTRY_OPENED )
+ {
+ UINT32 ulTempResult;
+
+ /* Cleanup resources, unmute channel... */
+ ulTempResult = Oct6100ApiUpdateBridgeUnMuteResources(
+ f_pApiInstance,
+ f_usChanIndex,
+ f_usLoadEventIndex,
+ f_usSubStoreEventIndex,
+ TRUE );
+ if ( ulTempResult != cOCT6100_ERR_OK )
+ return ulTempResult;
+ else
+ return ulResult;
+ }
+ else
+ {
+ return ulResult;
+ }
+ }
+ }
+ }
+ else /* if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) */
+ {
+ /* No more channels to check for muting. */
+ break;
+ }
+ }
+ }
+ else /* if ( f_fFlexibleConfBridge == FALSE ) */
+ {
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, f_usLoadEventIndex );
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex );
+
+ /*=======================================================================*/
+ /* Program the Load event. */
+
+ /* Create silence load if this is the first event of the bridge. */
+ if ( f_usLoadEventIndex == pBridgeEntry->usFirstLoadEventPtr )
+ fCreateSilenceLoad = TRUE;
+
+ /* First check if this event was a load or an accumulate event, if it's a load */
+ /* we need to find a new load. */
+ 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;
+ }
+ 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 );
+
+ /* Do not load the sample if the channel is muted. */
+ if ( fCreateSilenceLoad == TRUE )
+ {
+ if ( pBridgeEntry->usSilenceLoadEventPtr == cOCT6100_INVALID_INDEX )
+ {
+ /* Instead of No-oping, load the silence TSI, to make sure the other conferences before us are not heard. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+ WriteParams.usWriteData |= 1534; /* TSI index 1534 reserved for silence */
+
+ /* Remember the silence load event. */
+ pBridgeEntry->usSilenceLoadEventPtr = f_usLoadEventIndex;
+ }
+ else
+ {
+ /* Do nothing. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
+ }
+ }
+ else
+ {
+ /* Do nothing. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the software model. */
+ pLoadEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
+
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Program the Substract and store event. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ /* Do not load the sample if the channel is muted. */
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_STORE;
+
+ /* If we have an extra Sin copy event, we know we are using the Sout port as a source. */
+ if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Sout input. */
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ }
+ else /* if ( pEchoChanEntry->usSinCopyEventIndex == cOCT6100_INVALID_INDEX ) */
+ {
+ /* Rin input. */
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.byRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the software model. */
+ pSubStoreEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_STORE;
+
+ /*=======================================================================*/
+ }
+
+ /* Update the channel entry API structure */
+ pEchoChanEntry->fMute = TRUE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ConfBridgeChanUnMuteSer
+
+Description: UnMute an echo channel present on 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_pConfBridgeUnMute Pointer to conference bridge channel unmute structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeChanUnMuteSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute )
+{
+ UINT16 usChanIndex;
+ UINT16 usLoadEventIndex;
+ UINT16 usSubStoreEventIndex;
+ UINT8 fFlexibleConfBridge;
+ UINT32 ulResult;
+
+ /* Check the validity of the channel and conference bridge given. */
+ ulResult = Oct6100ApiCheckBridgeUnMuteParams(
+ f_pApiInstance,
+ f_pConfBridgeUnMute,
+ &usChanIndex,
+ &usLoadEventIndex,
+ &usSubStoreEventIndex,
+ &fFlexibleConfBridge );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Modify all resources needed by the conference bridge. */
+ ulResult = Oct6100ApiUpdateBridgeUnMuteResources(
+ f_pApiInstance,
+ usChanIndex,
+ usLoadEventIndex,
+ usSubStoreEventIndex,
+ fFlexibleConfBridge );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBridgeUnMuteParams
+
+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_pConfBridgeUnMute Pointer to conference bridge channel unmute structure.
+f_pusChannelIndex Pointer to the channel index fo the channel to be unmuted.
+f_pusLoadEventIndex Pointer to the load index of the channel.
+f_pusSubStoreEventIndex Pointer to the sub-store event of the channel.
+f_pfFlexibleConfBridge If this is a flexible conference bridge.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBridgeUnMuteParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_CHAN_UNMUTE f_pConfBridgeUnMute,
+ OUT PUINT16 f_pusChannelIndex,
+ OUT PUINT16 f_pusLoadEventIndex,
+ OUT PUINT16 f_pusSubStoreEventIndex,
+ OUT PUINT8 f_pfFlexibleConfBridge )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ if ( f_pConfBridgeUnMute->ulChannelHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_ADD_INVALID_HANDLE;
+
+ /*=====================================================================*/
+ /* Check the channel handle.*/
+
+ if ( (f_pConfBridgeUnMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ *f_pusChannelIndex = (UINT16)( f_pConfBridgeUnMute->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_pConfBridgeUnMute->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;
+
+ /* Check if the channel is bound to a conference bridge.*/
+ if ( pEchoChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_INVALID_HANDLE;
+
+ /* Check if channel is already muted.*/
+ if ( pEchoChanEntry->fMute == FALSE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_NOT_MUTED;
+
+ /*=====================================================================*/
+
+ /*=====================================================================*/
+ /* Check the conference bridge handle. */
+
+ if ( pEchoChanEntry->usBridgeIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, pEchoChanEntry->usBridgeIndex )
+
+ /* Check for errors. */
+ if ( pBridgeEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN;
+
+ /* Check the event entries.*/
+ if ( pBridgeEntry->fFlexibleConferencing == FALSE )
+ {
+ if ( pEchoChanEntry->usLoadEventIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_INVALID_HANDLE;
+
+ /* Check the event entries.*/
+ if ( pEchoChanEntry->usSubStoreEventIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_MUTE_INVALID_HANDLE;
+ }
+
+ /*=====================================================================*/
+
+ /* Return the config of the channel and all other important information.*/
+ *f_pusSubStoreEventIndex = pEchoChanEntry->usSubStoreEventIndex;
+ *f_pusLoadEventIndex = pEchoChanEntry->usLoadEventIndex;
+ *f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateBridgeUnMuteResources
+
+Description: Modify the conference bridge entry for this channel in order
+ to un-mute 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_usChanIndex Index of the channel to be unmuted.
+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_fFlexibleConfBridge If this is a flexible conference bridge.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateBridgeUnMuteResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usChanIndex,
+ IN UINT16 f_usLoadEventIndex,
+ IN UINT16 f_usSubStoreEventIndex,
+ IN UINT8 f_fFlexibleConfBridge )
+{
+ tOCT6100_WRITE_PARAMS WriteParams;
+ tOCT6100_READ_PARAMS ReadParams;
+
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+
+ tPOCT6100_API_MIXER_EVENT pLoadEventEntry;
+ tPOCT6100_API_MIXER_EVENT pSubStoreEventEntry;
+ tPOCT6100_API_MIXER_EVENT pTempEntry;
+ UINT32 ulResult;
+ UINT16 usTempEventIndex;
+ UINT32 ulLoopCount;
+ UINT16 usReadData;
+
+ UINT16 usLoadEventType = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+ UINT16 usPreviousLoadIndex = cOCT6100_INVALID_INDEX;
+
+ /* 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_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, pEchoChanEntry->usBridgeIndex )
+
+ if ( f_fFlexibleConfBridge == TRUE )
+ {
+ tPOCT6100_API_CHANNEL pTempEchoChanEntry;
+ UINT16 usChannelIndex;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant;
+
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Before doing anything, check if the copy events must be created. */
+ if ( ( pParticipant->ulInputPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pEchoChanEntry->fCopyEventCreated == FALSE ) )
+ {
+ /* The copy event has not been created, create it once for the life of the participant on the bridge. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ WriteParams.usWriteData |= pEchoChanEntry->usExtraSinTsiMemIndex;
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pEchoChanEntry->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,
+ pEchoChanEntry->usSinCopyEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY,
+ f_usChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ pEchoChanEntry->fCopyEventCreated = TRUE;
+ }
+
+ /* Search through the list of API channel entry for the ones onto this bridge. */
+ for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != f_usChanIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
+ {
+ /* On current bridge? */
+ if ( pTempEchoChanEntry->usBridgeIndex == pEchoChanEntry->usBridgeIndex )
+ {
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
+
+ /* Check if this participant can hear us. */
+ if ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
+ {
+ /* Then create/update this channel's mixer. */
+ ulResult = Oct6100ApiBridgeAddParticipantToChannel(
+ f_pApiInstance,
+ pEchoChanEntry->usBridgeIndex,
+ f_usChanIndex,
+ usChannelIndex,
+ pTempParticipant->ausLoadOrAccumulateEventIndex[ pParticipant->ulListenerMaskIndex ],
+ pTempEchoChanEntry->usSubStoreEventIndex,
+ pTempEchoChanEntry->usSinCopyEventIndex,
+ pParticipant->ulInputPort,
+ pTempParticipant->ulInputPort );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Check if the Rin silence event can be cleared now that the */
+ /* channel has unmuted. */
+ if ( ( pTempParticipant->fFlexibleMixerCreated == TRUE )
+ && ( pTempEchoChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
+ {
+ /* Remove the event from the list. */
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ pTempEchoChanEntry->usRinSilenceEventIndex,
+ cOCT6100_EVENT_TYPE_SOUT_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pTempEchoChanEntry->usRinSilenceEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_DF;
+
+ pTempEchoChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+ }
+ }
+ }
+ }
+ }
+ else /* if ( f_fFlexibleConfBridge == FALSE ) */
+ {
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, f_usLoadEventIndex );
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex );
+
+ /*=======================================================================*/
+ /* Program the Load event. */
+
+ /* Before reactivating this event, check what type of event this event must be. */
+ if ( f_usLoadEventIndex == pBridgeEntry->usFirstLoadEventPtr ||
+ pBridgeEntry->usLoadIndex == cOCT6100_INVALID_INDEX )
+ {
+ /* This event must become a Load event. */
+ usLoadEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+ pBridgeEntry->usLoadIndex = f_usLoadEventIndex;
+ }
+
+ usTempEventIndex = pBridgeEntry->usFirstLoadEventPtr;
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
+
+ ulLoopCount = 0;
+
+ while( pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_SUB_STORE &&
+ pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_STORE )
+ {
+ if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_LOAD )
+ {
+ usPreviousLoadIndex = usTempEventIndex;
+ }
+
+ /* Check if the previous load event is before or after the event about to be unmuted. */
+ if ( pTempEntry->usNextEventPtr == f_usLoadEventIndex )
+ {
+ if ( usPreviousLoadIndex == cOCT6100_INVALID_INDEX )
+ {
+ /* We did not find a load event before our node, this mean this one */
+ /* is about to become the new load event. */
+ usLoadEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
+ }
+ }
+
+ /* 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;
+ }
+
+ /* Now program the current event node. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = usLoadEventType;
+
+ /* If we have an extra Sin copy event, we know we are using the Sout port as a source. */
+ if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Sout source */
+ WriteParams.usWriteData |= pEchoChanEntry->usSinSoutTsiMemIndex;
+ }
+ else
+ {
+ /* Rin source */
+ WriteParams.usWriteData |= pEchoChanEntry->usRinRoutTsiMemIndex;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the software event to reflect the hardware. */
+ pLoadEventEntry->usEventType = usLoadEventType;
+
+ /* Check if we need to change another node. */
+ if ( usLoadEventType == cOCT6100_MIXER_CONTROL_MEM_LOAD )
+ {
+ if ( usPreviousLoadIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Now program the old load event. */
+ ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousLoadIndex * 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_ACCUMULATE );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the software event to reflect the hardware. */
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousLoadIndex );
+ pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE;
+ }
+ }
+
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Program 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_SUB_STORE;
+ /* If we have an extra Sin copy event, we know we are using the Sout port as a source. */
+ if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
+ {
+ /* Sout port source */
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ WriteParams.usWriteData |= pEchoChanEntry->usSinSoutTsiMemIndex;
+ }
+ else
+ {
+ /* Rin port source */
+ WriteParams.usWriteData |= pEchoChanEntry->TdmConfig.byRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ WriteParams.usWriteData |= pEchoChanEntry->usRinRoutTsiMemIndex;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pEchoChanEntry->usRinRoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the software event to reflect the hardware. */
+ pSubStoreEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_SUB_STORE;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Check if have to remove silence load event. */
+
+ if ( pBridgeEntry->usSilenceLoadEventPtr != cOCT6100_INVALID_INDEX )
+ {
+ if ( pBridgeEntry->usSilenceLoadEventPtr == f_usLoadEventIndex )
+ {
+ /* Clear the silence load event ptr. */
+ pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX;
+ }
+ }
+ }
+
+ /* Update the channel entry API structure */
+ pEchoChanEntry->fMute = FALSE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ConfBridgeDominantSpeakerSetSer
+
+Description: This function sets the dominant speaker of a 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_pConfBridgeDominant Pointer to conference bridge dominant speaker
+ structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeDominantSpeakerSetSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker )
+{
+ UINT16 usChanIndex;
+ UINT16 usBridgeIndex;
+ UINT32 ulResult;
+
+ /* Check the validity of the channel handle given. */
+ ulResult = Oct6100ApiCheckBridgeDominantSpeakerParams( f_pApiInstance, f_pConfBridgeDominantSpeaker, &usChanIndex, &usBridgeIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Modify all resources needed by the conference bridge. */
+ ulResult = Oct6100ApiUpdateBridgeDominantSpeakerResources( f_pApiInstance, usChanIndex, usBridgeIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBridgeDominantSpeakerParams
+
+Description: Check the validity of the channel given for setting the
+ dominant speaker.
+
+-------------------------------------------------------------------------------
+| 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_pConfBridgeDominant Pointer to conference bridge channel dominant speaker structure.
+f_pusChannelIndex Pointer to a channel index.
+f_pusChannelIndex Pointer to a bridge index.
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBridgeDominantSpeakerParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_DOMINANT_SPEAKER_SET f_pConfBridgeDominantSpeaker,
+ OUT PUINT16 f_pusChannelIndex,
+ OUT PUINT16 f_pusBridgeIndex )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ UINT32 ulEntryOpenCnt;
+ BOOL fCheckEntryOpenCnt = FALSE;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ if ( f_pConfBridgeDominantSpeaker->ulChannelHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ /*=====================================================================*/
+ /* Check the channel handle. */
+
+ if ( f_pConfBridgeDominantSpeaker->ulChannelHndl != cOCT6100_CONF_NO_DOMINANT_SPEAKER_HNDL )
+ {
+ if ( (f_pConfBridgeDominantSpeaker->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ *f_pusChannelIndex = (UINT16)( f_pConfBridgeDominantSpeaker->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_pConfBridgeDominantSpeaker->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;
+
+ /* Check if the channel is bound to a conference bridge. */
+ if ( pEchoChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHAN_NOT_ON_BRIDGE;
+
+ /* Check if the NLP is enabled on this channel. */
+ if ( pEchoChanEntry->VqeConfig.fEnableNlp == FALSE )
+ return cOCT6100_ERR_CONF_BRIDGE_NLP_MUST_BE_ENABLED;
+
+ /* Check if conferencing noise reduction is enabled on this channel. */
+ if ( pEchoChanEntry->VqeConfig.fSoutConferencingNoiseReduction == FALSE )
+ return cOCT6100_ERR_CONF_BRIDGE_CNR_MUST_BE_ENABLED;
+
+ /* Check if this is a tap channel. If it is, it will never be the dominant speaker! */
+ if ( pEchoChanEntry->fTap == TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_ALWAYS_MUTE;
+
+ /* Set the bridge index. */
+ *f_pusBridgeIndex = pEchoChanEntry->usBridgeIndex;
+ }
+ else
+ {
+ /* Set this such that there is no dominant speaker on this conference bridge. */
+ *f_pusChannelIndex = cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED;
+
+ /* Check the conference bridge handle. */
+ if ( (f_pConfBridgeDominantSpeaker->ulConfBridgeHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CONF_BRIDGE )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ /* Set the bridge index. */
+ *f_pusBridgeIndex = (UINT16)( f_pConfBridgeDominantSpeaker->ulConfBridgeHndl & cOCT6100_HNDL_INDEX_MASK );
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = (f_pConfBridgeDominantSpeaker->ulConfBridgeHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+ fCheckEntryOpenCnt = TRUE;
+ }
+
+ /*=====================================================================*/
+
+ /*=====================================================================*/
+
+ 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 )
+
+ /* Check for errors. */
+ if ( pBridgeEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN;
+ if ( fCheckEntryOpenCnt == TRUE )
+ {
+ if ( ulEntryOpenCnt != pBridgeEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+ }
+
+ /*=====================================================================*/
+ /* Check if dominant speaker is supported in this firmware version. */
+
+ if ( f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled == FALSE )
+ return cOCT6100_ERR_NOT_SUPPORTED_DOMINANT_SPEAKER;
+
+ /*=====================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateBridgeDominantSpeakerResources
+
+Description: Modify the conference bridge such that the new dominant
+ speaker is the one specified by the index.
+
+-------------------------------------------------------------------------------
+| 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 Index of the channel to be set as the dominant speaker.
+f_usBridgeIndex Index of the bridge where this channel is on.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateBridgeDominantSpeakerResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usChanIndex,
+ IN UINT16 f_usBridgeIndex )
+{
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+
+ UINT16 usChannelIndex;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Get the bridge entry for this channel. */
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex )
+
+ /* Set the dominant speaker index for all channels in 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, pEchoChanEntry, usChannelIndex );
+
+ if ( pEchoChanEntry->fReserved == TRUE )
+ {
+ if ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
+ {
+ /* If we are unsetting the dominant speaker, of if it is not our channel index. */
+ if ( ( f_usChanIndex == cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED )
+ || ( f_usChanIndex != usChannelIndex ) )
+ {
+ ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, usChannelIndex, f_usChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+ }
+
+ /* Make sure this channel is disabled. */
+ if ( f_usChanIndex != cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED )
+ {
+ ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_usChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Save this in the conference bridge structure. */
+ /* This will be needed later when removing the channel. */
+ pBridgeEntry->fDominantSpeakerSet = TRUE;
+ pBridgeEntry->usDominantSpeakerChanIndex = f_usChanIndex;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ConfBridgeMaskChangeSer
+
+Description: This function changes the mask of flexible bridge
+ participant.
+
+-------------------------------------------------------------------------------
+| 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_pConfBridgeMaskChange Pointer to conference bridge participant mask
+ change structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeMaskChangeSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange )
+{
+ UINT16 usChanIndex;
+ UINT16 usBridgeIndex;
+ UINT32 ulResult;
+ UINT32 ulNewParticipantMask;
+
+ /* Check the validity of the channel handle given. */
+ ulResult = Oct6100ApiCheckBridgeMaskChangeParams( f_pApiInstance, f_pConfBridgeMaskChange, &usChanIndex, &usBridgeIndex, &ulNewParticipantMask );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update all resources needed by the new mask. */
+ ulResult = Oct6100ApiUpdateMaskModifyResources( f_pApiInstance, usBridgeIndex, usChanIndex, ulNewParticipantMask );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Commit the changes to the chip's internal memories. */
+ ulResult = Oct6100ApiBridgeUpdateMask( f_pApiInstance, usBridgeIndex, usChanIndex, ulNewParticipantMask );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBridgeMaskChangeParams
+
+Description: Check the validity of the channel given for setting 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_pConfBridgeMaskChange Pointer to conference bridge channel mask change structure.
+f_pusChannelIndex Pointer to a channel index.
+f_pusBridgeIndex Pointer to a bridge index.
+f_pulNewParticipantMask New mask to apply for this participant.
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBridgeMaskChangeParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CONF_BRIDGE_MASK_CHANGE f_pConfBridgeMaskChange,
+ OUT PUINT16 f_pusChannelIndex,
+ OUT PUINT16 f_pusBridgeIndex,
+ OUT PUINT32 f_pulNewParticipantMask )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ tPOCT6100_API_CHANNEL pEchoChanEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ if ( f_pConfBridgeMaskChange->ulChannelHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ /*=====================================================================*/
+ /* Check the channel handle.*/
+
+ if ( (f_pConfBridgeMaskChange->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ *f_pusChannelIndex = (UINT16)( f_pConfBridgeMaskChange->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_pConfBridgeMaskChange->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;
+
+ /* Check if the channel is bound to a conference bridge. */
+ if ( pEchoChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_CONF_BRIDGE_CHAN_NOT_ON_BRIDGE;
+
+ /* Set the bridge index. */
+ *f_pusBridgeIndex = pEchoChanEntry->usBridgeIndex;
+
+ /*=====================================================================*/
+
+ /*=====================================================================*/
+
+ if ( ( *f_pusBridgeIndex == cOCT6100_INVALID_INDEX )
+ || ( *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 )
+
+ /* Check for errors. */
+ if ( pBridgeEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN;
+
+ /* Check if this is bridge is a flexible conference bridge. */
+ if ( pBridgeEntry->fFlexibleConferencing == FALSE )
+ return cOCT6100_ERR_CONF_BRIDGE_SIMPLE_BRIDGE;
+
+ /*=====================================================================*/
+
+ /* Return new mask to apply. */
+ *f_pulNewParticipantMask = f_pConfBridgeMaskChange->ulNewListenerMask;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateMaskModifyResources
+
+Description: Modify/reserve all resources needed for the modification of
+ the participant's 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_usBridgeIndex Bridge index of the bridge where this channel is residing.
+f_usChanIndex Channel index of the channel to be modified.
+f_ulNewListenerMask New mask to apply to the selected participant.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateMaskModifyResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usBridgeIndex,
+ IN UINT16 f_usChanIndex,
+ IN UINT32 f_ulNewListenerMask )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tPOCT6100_API_CHANNEL pTempEchoChanEntry;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant;
+
+ UINT32 ulResult = cOCT6100_ERR_OK;
+ UINT32 ulTempVar;
+ UINT32 ulOldListenerMask;
+ UINT16 usChannelIndex;
+
+ /* 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 )
+
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pChanEntry->usFlexConfParticipantIndex );
+
+ /* Must travel all clients of this conference and reserve a load or accumulate event for */
+ /* all participants which could not hear us but now can. While at it, check for events that */
+ /* could be released, for example a participant that we cannot hear anymore. */
+
+ ulOldListenerMask = pParticipant->ulListenerMask;
+
+ /* Search through the list of API channel entry for the ones on to this bridge.*/
+ for ( usChannelIndex = 0; ( usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels ) && ( ulResult == cOCT6100_ERR_OK ) ; usChannelIndex++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != 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 now hear this participant, but could not before. */
+ if ( ( ( f_ulNewListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
+ && ( ( ulOldListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) != 0x0 ) )
+ {
+ /* Must reserve a load or accumulate entry mixer event here! */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, &pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* Most probably, the hardware is out of mixer events. */
+ break;
+ }
+ }
+
+ /* Check if we can now NOT hear this participant, but could before. */
+ if ( ( ( f_ulNewListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) != 0x0 )
+ && ( ( ulOldListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 ) )
+ {
+ /* Must release the load or accumulate entry mixer event. */
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* If an error is returned, make sure everything is cleaned up properly. */
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* 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 );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != 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 now hear this participant, but could not before. */
+ if ( ( ( f_ulNewListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
+ && ( ( ulOldListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) != 0x0 ) )
+ {
+ /* If the load or event entry in the mixer memory was reserved. */
+ if ( pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] != cOCT6100_INVALID_INDEX )
+ {
+ /* Must release the load or accumulate entry mixer event. */
+ ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
+ }
+ }
+
+ /* Check if we can now NOT hear this participant, but could before. */
+ if ( ( ( f_ulNewListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) != 0x0 )
+ && ( ( ulOldListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 ) )
+ {
+ /* If the load or event entry in the mixer memory was reserved. */
+ if ( pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] == cOCT6100_INVALID_INDEX )
+ {
+ /* Must release the load or accumulate entry mixer event. */
+ ulTempVar = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, &( pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] ) );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+ }
+ }
+ }
+ }
+
+ return ulResult;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiBridgeUpdateMask
+
+Description: Update the participant's 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_usBridgeIndex Bridge index of the bridge where this channel is residing.
+f_usChanIndex Channel index of the channel to be modified.
+f_ulNewListenerMask New mask to apply to the selected participant.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiBridgeUpdateMask(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usBridgeIndex,
+ IN UINT16 f_usChanIndex,
+ IN UINT32 f_ulNewListenerMask )
+{
+ tPOCT6100_API_CHANNEL pChanEntry;
+ tPOCT6100_API_CHANNEL pTempEchoChanEntry;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant;
+ tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant;
+ tOCT6100_WRITE_PARAMS WriteParams;
+
+ UINT32 ulResult;
+ UINT32 ulOldListenerMask;
+ UINT16 usChannelIndex;
+
+ 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;
+
+ /* 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 channel's list entry. */
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
+
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pChanEntry->usFlexConfParticipantIndex );
+
+ ulOldListenerMask = pParticipant->ulListenerMask;
+
+ /* Search through the list of API channel entry for the ones onto this bridge. */
+ for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
+ {
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
+
+ /* Channel reserved? */
+ if ( ( usChannelIndex != 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 now hear this participant, but could not before. */
+ if ( ( pTempEchoChanEntry->fMute == FALSE )
+ && ( ( f_ulNewListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
+ && ( ( ulOldListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) != 0x0 ) )
+ {
+ /* First create/update the current channel's mixer. */
+ ulResult = Oct6100ApiBridgeAddParticipantToChannel(
+ f_pApiInstance,
+ f_usBridgeIndex,
+ usChannelIndex,
+ f_usChanIndex,
+ pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ],
+ pChanEntry->usSubStoreEventIndex,
+ pChanEntry->usSinCopyEventIndex,
+ pTempParticipant->ulInputPort,
+ pParticipant->ulInputPort );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ if ( pParticipant->fFlexibleMixerCreated == TRUE )
+ {
+ /* Check if the Rin silence event can be cleared now that the */
+ /* channel has been added to a conference. */
+ if ( 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_DF;
+
+ pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
+ }
+ }
+ }
+
+ /* Check if we can now NOT hear this participant, but could before. */
+ if ( ( ( f_ulNewListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) != 0x0 )
+ && ( ( ulOldListenerMask & ( 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;
+
+ if ( pParticipant->fFlexibleMixerCreated == FALSE )
+ {
+ /* Remember to mute the port on this channel. */
+ for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
+ {
+ if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == f_usChanIndex )
+ {
+ break;
+ }
+ else if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX )
+ {
+ ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = f_usChanIndex;
+ break;
+ }
+ }
+ }
+ }
+
+ /* Clear the load or accumulate event index for this participant. */
+ if ( ( ( f_ulNewListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) != 0x0 )
+ && ( ( ulOldListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 ) )
+ {
+ pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
+ }
+ }
+ }
+
+ /* 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;
+ }
+ }
+ }
+
+ /* Configure the SIN copy mixer entry and memory - if using the SOUT port. */
+ if ( pParticipant->ulInputPort == cOCT6100_CHANNEL_PORT_SOUT )
+ {
+ if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pChanEntry->usSinTsstIndex,
+ pChanEntry->usExtraSinTsiMemIndex,
+ pChanEntry->TdmConfig.bySinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* If the silence TSI is loaded on this port, update with the extra sin TSI. */
+ if ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
+ {
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.ulWriteAddress += 2;
+ WriteParams.usWriteData = pChanEntry->usExtraSinTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* Configure the RIN copy mixer entry and memory - if using the RIN port. */
+ if ( pParticipant->ulInputPort == cOCT6100_CHANNEL_PORT_RIN )
+ {
+ if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pChanEntry->usRinTsstIndex,
+ pChanEntry->usExtraRinTsiMemIndex,
+ pChanEntry->TdmConfig.byRinPcmLaw );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* Save the new mask permanently in the API instance. */
+ pParticipant->ulListenerMask = f_ulNewListenerMask;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ConfBridgeGetStatsSer
+
+Description: This function returns the statistics from the specified 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_pConfBridgeStats Pointer to conference bridge stats structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ConfBridgeGetStatsSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CONF_BRIDGE_STATS f_pConfBridgeStats )
+{
+ tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
+ UINT16 usConfBridgeIndex;
+ UINT32 ulEntryOpenCnt;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges == 0 )
+ return cOCT6100_ERR_CONF_BRIDGE_DISABLED;
+
+ /*=====================================================================*/
+ /* Check the conference bridge handle. */
+
+ /* Check the provided handle. */
+ if ( (f_pConfBridgeStats->ulConfBridgeHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CONF_BRIDGE )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ usConfBridgeIndex = (UINT16)( f_pConfBridgeStats->ulConfBridgeHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( usConfBridgeIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges )
+ return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
+
+ mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, usConfBridgeIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = (f_pConfBridgeStats->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;
+
+ /*=====================================================================*/
+
+ /* Return the stats.*/
+ f_pConfBridgeStats->ulNumChannels = pBridgeEntry->usNumClients;
+ f_pConfBridgeStats->ulNumTappedChannels = pBridgeEntry->usNumTappedClients;
+ f_pConfBridgeStats->fFlexibleConferencing = pBridgeEntry->fFlexibleConferencing;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveBridgeEntry
+
+Description: Reserves a free entry in 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_pusBridgeIndex List entry reserved.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveBridgeEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusBridgeIndex )
+{
+ PVOID pBridgeAlloc;
+ UINT32 ulResult;
+ UINT32 ulBridgeIndex;
+
+ mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBridgeAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pBridgeAlloc, &ulBridgeIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_CONF_BRIDGE_ALL_BUFFERS_OPEN;
+ else
+ return cOCT6100_ERR_FATAL_29;
+ }
+
+ *f_pusBridgeIndex = (UINT16)( ulBridgeIndex & 0xFFFF );
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ApiReserveFlexConfParticipantEntry
+
+Description: Reserves a free entry in the 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_pusParticipantIndex List entry reserved.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveFlexConfParticipantEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusParticipantIndex )
+{
+ PVOID pParticipantAlloc;
+ UINT32 ulResult;
+ UINT32 ulParticipantIndex;
+
+ mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pParticipantAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pParticipantAlloc, &ulParticipantIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_CONF_BRIDGE_FLEX_CONF_ALL_BUFFERS_OPEN;
+ else
+ return cOCT6100_ERR_FATAL_29;
+ }
+
+ *f_pusParticipantIndex = (UINT16)( ulParticipantIndex & 0xFFFF );
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c
new file mode 100644
index 0000000..3573cc0
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c
@@ -0,0 +1,1100 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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"
+
+
+/**************************** PUBLIC FUNCTIONS ****************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100DebugSelectChannel
+
+Description: This function sets the current 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.
+
+f_pSelectDebugChan Pointer to select debug channel structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100DebugSelectChannelDef(
+ tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan )
+{
+ f_pSelectDebugChan->ulChannelHndl = cOCT6100_INVALID_VALUE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100DebugSelectChannel(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan )
+{
+ 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 = Oct6100DebugSelectChannelSer( f_pApiInstance, f_pSelectDebugChan, TRUE );
+ }
+ 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: Oct6100DebugGetData
+
+Description: This function retrieves the last recorded debug data.
+
+-------------------------------------------------------------------------------
+| 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_pGetData Pointer to debug get data structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100DebugGetDataDef(
+ tPOCT6100_DEBUG_GET_DATA f_pGetData )
+{
+ f_pGetData->ulGetDataMode = cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE;
+ f_pGetData->ulRemainingNumBytes = cOCT6100_INVALID_VALUE;
+ f_pGetData->ulTotalNumBytes = cOCT6100_INVALID_VALUE;
+ f_pGetData->ulMaxBytes = cOCT6100_INVALID_VALUE;
+ f_pGetData->ulValidNumBytes = cOCT6100_INVALID_VALUE;
+ f_pGetData->pbyData = NULL;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100DebugGetData(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_DEBUG_GET_DATA f_pGetData )
+{
+ 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 = Oct6100DebugGetDataSer( f_pApiInstance, f_pGetData );
+ }
+ 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: Oct6100DebugSelectChannelSer
+
+Description: This function sets the 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.
+
+f_pSelectDebugChan Pointer to a tOCT6100_DEBUG_SELECT_CHANNEL structure.
+f_fCheckChannelRecording Check if channel recording is enabled or not.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100DebugSelectChannelSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan,
+ IN BOOL f_fCheckChannelRecording )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pChanEntry = NULL;
+ tPOCT6100_API_CHANNEL pTempChanEntry;
+ tOCT6100_CHANNEL_OPEN TempChanOpen;
+ UINT16 usChanIndex = 0;
+ UINT32 ulEntryOpenCnt;
+
+ tOCT6100_WRITE_BURST_PARAMS BurstParams;
+ UINT16 ausWriteData[ 2 ];
+ UINT32 ulResult;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+ BurstParams.pusWriteData = ausWriteData;
+
+ /* First release the resources reserved for the channel that was previously debugged. */
+ if ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex != cOCT6100_INVALID_INDEX &&
+ pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
+ {
+ /*=======================================================================*/
+ /* Get a pointer to the channel's list entry. */
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempChanEntry, pSharedInfo->DebugInfo.usCurrentDebugChanIndex )
+
+ /* Release the extra TSI memory entry and reprogram the TSST control memory if required. */
+ if ( pTempChanEntry->usExtraSinTsiDependencyCnt == 1 )
+ {
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pTempChanEntry->usExtraSinTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ if ( pTempChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pTempChanEntry->usSinTsstIndex,
+ pTempChanEntry->usSinSoutTsiMemIndex,
+ pTempChanEntry->TdmConfig.bySinPcmLaw );
+ }
+
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ pTempChanEntry->usExtraSinTsiDependencyCnt--;
+ pTempChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
+ }
+ }
+
+ /* Set the new parameters. */
+ if ( f_pSelectDebugChan->ulChannelHndl != cOCT6100_INVALID_HANDLE )
+ {
+ /* Check the provided handle. */
+ if ( (f_pSelectDebugChan->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_DEBUG_CHANNEL_INVALID_HANDLE;
+
+ usChanIndex = (UINT16)( f_pSelectDebugChan->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( usChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
+ return cOCT6100_ERR_DEBUG_CHANNEL_INVALID_HANDLE;
+
+ if ( f_fCheckChannelRecording == TRUE )
+ {
+ if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
+ return cOCT6100_ERR_DEBUG_CHANNEL_RECORDING_DISABLED;
+ }
+
+ /*=======================================================================*/
+ /* Get a pointer to the channel's list entry. */
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, usChanIndex );
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pSelectDebugChan->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;
+
+ /*=======================================================================*/
+
+ /* First program the mixer entry if the user wants to record. */
+ /* Check if the API needs to reserve an extra TSI memory to load the SIN signal. */
+ if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
+ {
+ if ( pChanEntry->usExtraSinTsiMemIndex == cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pChanEntry->usExtraSinTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
+ {
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ pChanEntry->usSinTsstIndex,
+ pChanEntry->usExtraSinTsiMemIndex,
+ pChanEntry->TdmConfig.bySinPcmLaw );
+ 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 = 2;
+
+ ausWriteData[ 0 ] = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ ausWriteData[ 0 ] |= pChanEntry->usSinSoutTsiMemIndex;
+ ausWriteData[ 0 ] |= pChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ ausWriteData[ 1 ] = (UINT16)( pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex );
+
+ mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Program the Sin copy event. */
+ BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordSinEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+ BurstParams.ulWriteLength = 2;
+
+ ausWriteData[ 0 ] = cOCT6100_MIXER_CONTROL_MEM_COPY;
+ ausWriteData[ 0 ] |= pChanEntry->usExtraSinTsiMemIndex;
+ ausWriteData[ 0 ] |= pChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ ausWriteData[ 1 ] = pChanEntry->usSinSoutTsiMemIndex;
+
+ mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ /*=======================================================================*/
+
+ pChanEntry->usExtraSinTsiDependencyCnt++;
+ }
+ }
+ else
+ {
+ /* Set the index to invalid to deactivate the recording. */
+ usChanIndex = cOCT6100_INVALID_INDEX;
+ }
+
+ if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
+ {
+ /* Set the PCM law of the debug channel. */
+ /* Let's program the channel memory. */
+ Oct6100ChannelOpenDef( &TempChanOpen );
+
+ TempChanOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_HT_RESET; /* Activate the channel. */
+ TempChanOpen.VqeConfig.fEnableNlp = FALSE;
+ TempChanOpen.VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
+ TempChanOpen.VqeConfig.fSinDcOffsetRemoval = FALSE;
+ TempChanOpen.VqeConfig.fRinDcOffsetRemoval = FALSE;
+ TempChanOpen.VqeConfig.lDefaultErlDb = 0;
+
+ if ( ( f_pSelectDebugChan->ulChannelHndl != cOCT6100_INVALID_HANDLE )
+ && ( pChanEntry != NULL ) )
+ {
+ /* Use the law of the channel being recorded. */
+ TempChanOpen.TdmConfig.ulRinPcmLaw = pChanEntry->TdmConfig.byRinPcmLaw;
+ TempChanOpen.TdmConfig.ulSinPcmLaw = pChanEntry->TdmConfig.bySinPcmLaw;
+ TempChanOpen.TdmConfig.ulRoutPcmLaw = pChanEntry->TdmConfig.byRoutPcmLaw;
+ TempChanOpen.TdmConfig.ulSoutPcmLaw = pChanEntry->TdmConfig.bySoutPcmLaw;
+ }
+ else
+ {
+ /* Hard-code this to u-Law. */
+ TempChanOpen.TdmConfig.ulRinPcmLaw = cOCT6100_PCM_U_LAW;
+ TempChanOpen.TdmConfig.ulSinPcmLaw = cOCT6100_PCM_U_LAW;
+ TempChanOpen.TdmConfig.ulRoutPcmLaw = cOCT6100_PCM_U_LAW;
+ TempChanOpen.TdmConfig.ulSoutPcmLaw = cOCT6100_PCM_U_LAW;
+ }
+
+ 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;
+ }
+
+ ausWriteData[ 0 ] = 0x0;
+ ausWriteData[ 1 ] = (UINT16)(( usChanIndex >> 0) & 0xFFFF);
+
+ /* Write the channel number into the Matrix hot channel field.*/
+ BurstParams.ulWriteAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
+ BurstParams.pusWriteData = ausWriteData;
+ BurstParams.ulWriteLength = 2;
+
+ mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ pSharedInfo->DebugInfo.usCurrentDebugChanIndex = usChanIndex;
+
+ /* Cancel data dump request, if there was one. */
+ pSharedInfo->DebugInfo.fDebugDataBeingDumped = FALSE;
+
+ /* Call from remote client. */
+ if ( f_fCheckChannelRecording == FALSE )
+ {
+ /* If the user has not activated recording, let the remote client know. */
+ if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
+ return cOCT6100_ERR_DEBUG_RC_CHANNEL_RECORDING_DISABLED;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100DebugGetDataSer
+
+Description: This function retrieves the latest recorded debug data.
+
+-------------------------------------------------------------------------------
+| 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_pGetData Pointer to a tOCT6100_DEBUG_GET_DATA structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100DebugGetDataSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_DEBUG_GET_DATA f_pGetData )
+{
+
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pChanEntry = NULL;
+ tOCT6100_READ_PARAMS ReadParams;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ tOCT6100_READ_BURST_PARAMS ReadBurstParams;
+ tOCT6100_WRITE_BURST_PARAMS WriteBurstParams;
+
+ UINT16 ausWriteData[ 2 ];
+ UINT16 usReadData;
+ UINT16 usDebugEventReadPtr;
+
+ UINT32 ulResult;
+ UINT32 ulToneEventIndex;
+ UINT32 ulReadPointer;
+ UINT32 ulUserBufWriteIndex = 0;
+ UINT32 ulTimestamp;
+ UINT32 ulDebugEventIndex;
+ UINT32 ulStreamIndex;
+ UINT32 ulPcmSampleIndex;
+ UINT32 ulNumAfEvents;
+ UINT32 ulNumReads = 0;
+ UINT32 ulTempIndex;
+ UINT32 ulCopyIndex;
+ UINT32 ulFeatureBytesOffset;
+ UINT32 ulFeatureBitOffset;
+ UINT32 ulFeatureFieldLength;
+ UINT32 ulTempData;
+ UINT32 ulMask;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ WriteBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Check all user parameters. */
+
+ /* Check if channel recording is enabled. */
+ if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
+ return cOCT6100_ERR_DEBUG_CHANNEL_RECORDING_DISABLED;
+
+ /* Check if a current debugging channel has been selected. */
+ /* If not, the user has not yet called Oct6100DebugSelectChannel. */
+ if ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex == cOCT6100_INVALID_INDEX )
+ return cOCT6100_ERR_DEBUG_RECORD_NO_CHAN_SELECTED;
+
+ /* Check that the user supplied a valid max bytes value. */
+ if ( f_pGetData->ulMaxBytes == cOCT6100_INVALID_VALUE )
+ return cOCT6100_ERR_DEBUG_GET_DATA_MAX_BYTES;
+
+ /* Data buffer must be aligned on 1024 bytes. */
+ if ( ( f_pGetData->ulMaxBytes % 1024 ) != 0 )
+ return cOCT6100_ERR_DEBUG_GET_DATA_MAX_BYTES;
+
+ /* Check that the user provided the required memory to transfer the information. */
+ if ( f_pGetData->pbyData == NULL )
+ return cOCT6100_ERR_DEBUG_GET_DATA_PTR_INVALID;
+
+ /* Check dump type. */
+ if ( ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE )
+ && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE )
+ && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_16S )
+ && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
+ return cOCT6100_ERR_DEBUG_GET_DATA_MODE;
+
+ /* Check if can accomodate the 120 seconds dump. */
+ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
+ {
+ if ( pSharedInfo->DebugInfo.ulDebugEventSize != 0x100 )
+ return cOCT6100_ERR_NOT_SUPPORTED_DEBUG_DATA_MODE_120S;
+ }
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, pSharedInfo->DebugInfo.usCurrentDebugChanIndex )
+
+ /* Lets go dump the requested data. */
+
+ usDebugEventReadPtr = 0;
+
+ /* Check if this is the first time this function is called since the hot channel was set. */
+ if ( pSharedInfo->DebugInfo.fDebugDataBeingDumped == FALSE )
+ {
+ pSharedInfo->DebugInfo.fDebugDataBeingDumped = TRUE;
+
+ /* Flag the hot channel that it must stop recording. The data is being transfered. */
+ /* This also tells the remote client not to do anything right now. */
+
+ ReadBurstParams.ulReadAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
+ ReadBurstParams.ulReadLength = 2;
+ ReadBurstParams.pusReadData = pSharedInfo->DebugInfo.ausHotChannelData;
+
+ mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteBurstParams.pusWriteData = ausWriteData;
+ WriteBurstParams.ulWriteAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
+ WriteBurstParams.ulWriteLength = 2;
+
+ WriteBurstParams.pusWriteData[ 0 ] = 0xFFFF;
+ WriteBurstParams.pusWriteData[ 1 ] = 0xFFFF;
+
+ mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Get the maximum number of events this firmware supports from the TLVs. */
+ pSharedInfo->DebugInfo.usMatrixCBMask = (UINT16)( pSharedInfo->DebugInfo.ulDebugEventSize & 0xFFFF );
+ pSharedInfo->DebugInfo.usMatrixCBMask -= 1;
+
+ /* Find out the chip log write pointer. */
+
+ /* Now get the current write pointer for matrix events. */
+ ReadParams.pusReadData = &pSharedInfo->DebugInfo.usChipDebugEventWritePtr;
+ ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixWpBaseAddress + 2;
+
+ mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ReadParams.pusReadData = &usReadData;
+
+ /* This write pointer might have wrapped, but we don't know for sure. */
+ /* To be confident, the chip frame timestamp is read. */
+ ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress;
+
+ mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulTimestamp = usReadData << 16;
+
+ ReadParams.ulReadAddress += 2;
+
+ mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ ulTimestamp |= usReadData;
+
+ ulTimestamp >>= 12;
+ if ( ulTimestamp < (UINT32)( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) )
+ {
+ if ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr >= 2 )
+ {
+ /* Must trash the first 2 events. The chip is not yet ready. */
+ pSharedInfo->DebugInfo.usNumEvents = (UINT16)( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - 2 );
+ }
+ else
+ {
+ pSharedInfo->DebugInfo.usNumEvents = 0x0;
+ }
+ }
+ else
+ {
+ pSharedInfo->DebugInfo.usNumEvents = (UINT16)( pSharedInfo->DebugInfo.usMatrixCBMask + 1 );
+
+ /* Account for event being created right now while the chip is running. */
+ /* The event at the write pointer will be discarded. */
+ if ( pSharedInfo->DebugInfo.usNumEvents > 0 )
+ pSharedInfo->DebugInfo.usNumEvents--;
+ }
+
+ /* If the user only requested the last 16 seconds, cap the number of events. */
+ if ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S
+ || f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE )
+ {
+ /* x events to get the last 16 seconds. */
+ if ( pSharedInfo->DebugInfo.usNumEvents > ( 16000 / ( pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize / 8 ) ) )
+ pSharedInfo->DebugInfo.usNumEvents = (UINT16)( ( 16000 / ( pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize / 8 ) ) & 0xFFFF );
+ }
+
+ /* In heavy mode, the AF log pointer is retrieved. */
+ if ( ( pSharedInfo->DebugInfo.usNumEvents >= 2 )
+ && ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) )
+ {
+ /* The latest AF log write pointer is at the latest matrix event. */
+ ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixBaseAddress + ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr & pSharedInfo->DebugInfo.usMatrixCBMask ) * 1024 );
+
+ /* To get the AF log write pointer, which is at offset pSharedInfo->ImageInfo.ulAfWritePtrByteOffset. */
+ ReadParams.ulReadAddress += pSharedInfo->DebugInfo.ulAfWritePtrByteOffset;
+ mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ pSharedInfo->DebugInfo.usAfLogWritePtr = usReadData;
+
+ /* The AF event read pointer is the AF write pointer +4096 */
+ /* This will make sure we do not get mixed up and fetch events that have */
+ /* just been written, but we think are old. */
+
+ /* To get the exact AF log pointer, the API would have to wait 512 milliseconds to make */
+ /* sure logging had stopped. This is not required since missing a few last events is not */
+ /* important at this point (the user knows that valid data has already been recorded). */
+ pSharedInfo->DebugInfo.usLastAfLogReadPtr = (UINT16)( ( pSharedInfo->DebugInfo.usAfLogWritePtr + 4096 ) & 0xFFFF );
+
+ /* Note that if the chip has just been booted, some of the AF events might not be initialized. */
+ }
+ else
+ {
+ pSharedInfo->DebugInfo.usLastAfLogReadPtr = 0;
+ pSharedInfo->DebugInfo.usAfLogWritePtr = 0;
+ }
+
+ /* To be aligned correctly for the bursts. */
+ while ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) != 0 )
+ pSharedInfo->DebugInfo.usLastAfLogReadPtr++;
+
+ /* Remember first AF Event Read Pointer. */
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr >> 8 ) & 0xFF );
+
+ /* Remember the AF Event Write Pointer. */
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usAfLogWritePtr ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usAfLogWritePtr >> 8 ) & 0xFF );
+
+ /* Remember law and hot channel */
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( pChanEntry->TdmConfig.bySinPcmLaw | ( ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex >> 2 ) & 0xFE ) );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( pChanEntry->TdmConfig.bySoutPcmLaw );
+
+ /* Insert light or heavy mode in array. */
+ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE ) )
+ {
+ f_pGetData->pbyData[ ulUserBufWriteIndex - 1 ] |= 0x80;
+ }
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( pChanEntry->TdmConfig.byRinPcmLaw | ( ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex & 0x1F ) << 3 ) );
+
+ /* Remember usNumEvents */
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usNumEvents ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usNumEvents >> 8 ) & 0xFF );
+
+ /* Last indexes set to '0'! */
+ pSharedInfo->DebugInfo.usLastDebugEventIndex = 0;
+ pSharedInfo->DebugInfo.ulLastPcmSampleIndex = 0;
+
+ /* No tone event has been retrieved. */
+ pSharedInfo->DebugInfo.usLastToneEventIndex = 0;
+
+ /* The version strings have not yet been copied. */
+ pSharedInfo->DebugInfo.fImageVersionCopied = FALSE;
+ pSharedInfo->DebugInfo.fApiVersionCopied = FALSE;
+
+ /* Estimate the total size of the buffer that will be returned. */
+ f_pGetData->ulTotalNumBytes = ulUserBufWriteIndex;
+
+ /* Add the matrix events. */
+ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
+ {
+ /* Heavy mode! Grab everything! */
+ f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize;
+ }
+ else
+ {
+ /* Lite mode! Only the most important stuff. */
+ f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize;
+ }
+
+ /* Add the PCM samples. */
+ f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize * 3;
+
+ /* If requested, add the AF log events. */
+ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
+ {
+ f_pGetData->ulTotalNumBytes += (UINT32)( ( pSharedInfo->DebugInfo.usAfLogWritePtr - pSharedInfo->DebugInfo.usLastAfLogReadPtr ) & 0xFFFF ) * 16;
+ }
+
+ /* Add the tone events strings. */
+ f_pGetData->ulTotalNumBytes += cOCT6100_TLV_MAX_TONE_NAME_SIZE * pSharedInfo->ImageInfo.byNumToneDetectors;
+
+ /* Add the image version string. */
+ f_pGetData->ulTotalNumBytes += 512;
+
+ /* Add the API version string. */
+ f_pGetData->ulTotalNumBytes += sizeof( cOCT6100_API_VERSION );
+
+ /* Save this in the instance for further calls. */
+ pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes = f_pGetData->ulTotalNumBytes;
+
+ /* Calculate remaining bytes. All the bytes for now! */
+ f_pGetData->ulRemainingNumBytes = f_pGetData->ulTotalNumBytes;
+
+ /* Save this in the instance for the next calls. */
+ pSharedInfo->DebugInfo.ulDebugDataRemainingNumBytes = f_pGetData->ulRemainingNumBytes;
+ }
+ else
+ {
+ f_pGetData->ulTotalNumBytes = pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes;
+ }
+
+ /* Calculate the event read pointer. */
+ ulReadPointer = ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - pSharedInfo->DebugInfo.usNumEvents ) & pSharedInfo->DebugInfo.usMatrixCBMask ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize;
+
+ ulReadPointer += pSharedInfo->DebugInfo.ulDebugChanStatsByteSize * pSharedInfo->DebugInfo.usLastDebugEventIndex;
+ ulReadPointer %= ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
+
+ /* Copy the debug events in the user buffer. */
+ for( ulDebugEventIndex = pSharedInfo->DebugInfo.usLastDebugEventIndex; ulDebugEventIndex < pSharedInfo->DebugInfo.usNumEvents; ulDebugEventIndex ++ )
+ {
+ ReadBurstParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixBaseAddress + ulReadPointer;
+
+ /* Check if we are in light or heavy mode. The burst size is not the same. */
+ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
+ {
+ if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= pSharedInfo->DebugInfo.ulDebugChanStatsByteSize )
+ ulNumReads = pSharedInfo->DebugInfo.ulDebugChanStatsByteSize / 2;
+ else
+ break;
+ }
+ else
+ {
+ if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize )
+ ulNumReads = pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize / 2;
+ else
+ break;
+ }
+
+ ulTempIndex = 0;
+ while ( ulNumReads != 0 )
+ {
+ if ( ulNumReads >= pSharedInfo->ChipConfig.usMaxRwAccesses )
+ ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
+ else
+ ReadBurstParams.ulReadLength = ulNumReads;
+
+ /* Set pointer where to write data. */
+ ReadBurstParams.pusReadData = pSharedInfo->MiscVars.ausSuperArray;
+
+ mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Copy data byte per byte to avoid endianess problems. */
+ for ( ulCopyIndex = 0; ulCopyIndex < ReadBurstParams.ulReadLength; ulCopyIndex ++ )
+ {
+ f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex + ( 2 * ulCopyIndex ) ] = (UINT8)( ReadBurstParams.pusReadData[ ulCopyIndex ] & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex + ( 2 * ulCopyIndex ) + 1 ] = (UINT8)( ( ReadBurstParams.pusReadData[ ulCopyIndex ] >> 8 ) & 0xFF );
+ }
+
+ /* Update indexes, temp variables, addresses. */
+ ulNumReads -= ReadBurstParams.ulReadLength;
+ ulTempIndex += ReadBurstParams.ulReadLength * 2;
+ ReadBurstParams.ulReadAddress += ReadBurstParams.ulReadLength * 2;
+ }
+
+ /* Store register 0x202 in the event structure. */
+ f_pGetData->pbyData[ ulUserBufWriteIndex + 255 ] = (UINT8)( pSharedInfo->IntrptManage.usRegister202h & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex + 256 ] = (UINT8)( ( pSharedInfo->IntrptManage.usRegister202h >> 8 ) & 0xFF );
+
+ /* Increment index. */
+ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
+ {
+ ulUserBufWriteIndex += pSharedInfo->DebugInfo.ulDebugChanStatsByteSize;
+ }
+ else
+ {
+ ulUserBufWriteIndex += pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize;
+ }
+
+ /* Increment read pointer to get next event. */
+ ulReadPointer = ( ulReadPointer + pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ) % ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
+
+ /* Save in the instance that one of the events was dumped. */
+ pSharedInfo->DebugInfo.usLastDebugEventIndex ++;
+ }
+
+ /* Check if all debug events have been transfered. */
+ if ( ulDebugEventIndex == pSharedInfo->DebugInfo.usNumEvents )
+ {
+ /* Fetch all streams per event. */
+ for ( ulPcmSampleIndex = pSharedInfo->DebugInfo.ulLastPcmSampleIndex; ulPcmSampleIndex < ( (UINT32)pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ); ulPcmSampleIndex ++ )
+ {
+ /* Check if enough room for this sample. */
+ if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) < 3 )
+ break;
+
+ /* Check if must retrieve data from external memory. */
+ if ( ( ulPcmSampleIndex % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE * 2 ) ) == 0x0 )
+ {
+ ulReadPointer = ( ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - pSharedInfo->DebugInfo.usNumEvents ) * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) & ( pSharedInfo->DebugInfo.usMatrixCBMask * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) );
+ ulReadPointer += ( ulPcmSampleIndex / pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize;
+ ulReadPointer &= ( pSharedInfo->DebugInfo.usMatrixCBMask * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize );
+ ulReadPointer += ulPcmSampleIndex % pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize;
+
+ /* Retrieve more data from external memory. */
+ for ( ulStreamIndex = 0; ulStreamIndex < 3; ulStreamIndex ++ )
+ {
+ ReadBurstParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase;
+ /* To get right channel information. */
+ ReadBurstParams.ulReadAddress += ( ( pSharedInfo->DebugInfo.usRecordMemIndex + 2 ) * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->DebugInfo.ulAfEventCbByteSize;
+ /* To get correct stream. */
+ ReadBurstParams.ulReadAddress += ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize * ulStreamIndex );
+ /* PCM sample pointer in that stream. */
+ ReadBurstParams.ulReadAddress += ulReadPointer;
+
+ /* As much as we can for the burst. */
+ ulTempIndex = 0;
+ ulNumReads = cOCT6100_INTERNAL_SUPER_ARRAY_SIZE;
+ while ( ulNumReads != 0 )
+ {
+ if ( ulNumReads >= pSharedInfo->ChipConfig.usMaxRwAccesses )
+ ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
+ else
+ ReadBurstParams.ulReadLength = ulNumReads;
+
+ /* Set pointer where to write data. */
+ if ( ulStreamIndex == 0 )
+ ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray[ ulTempIndex ];
+ else if ( ulStreamIndex == 1 )
+ ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray1[ ulTempIndex ];
+ else /* if ( ulStreamIndex == 2 ) */
+ ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray2[ ulTempIndex ];
+
+ mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update indexes, temp variables, addresses. */
+ ulNumReads -= ReadBurstParams.ulReadLength;
+ ulTempIndex += ReadBurstParams.ulReadLength;
+ ReadBurstParams.ulReadAddress += ReadBurstParams.ulReadLength * 2;
+ }
+ }
+ }
+
+ /* We now have the stream data for all streams for 1 event. */
+ /* Return what we can to the user. */
+ if ( ulPcmSampleIndex % 2 == 0 )
+ {
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 8 ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray1[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 8 ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray2[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 8 ) & 0xFF );
+ }
+ else /* if ( ulPcmSampleIndex % 2 == 1 ) */
+ {
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 0 ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray1[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 0 ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray2[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 0 ) & 0xFF );
+ }
+
+ pSharedInfo->DebugInfo.ulLastPcmSampleIndex++;
+ }
+
+ /* Check if we are done dumping the PCM samples! */
+ if ( pSharedInfo->DebugInfo.ulLastPcmSampleIndex == ( (UINT32)pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) )
+ {
+ /* Go for the AF events. The AF events are only copied in heavy mode. */
+ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
+ || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
+ {
+ while ( pSharedInfo->DebugInfo.usLastAfLogReadPtr != pSharedInfo->DebugInfo.usAfLogWritePtr )
+ {
+ /* Check if enough room for an event. */
+ if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) < 16 )
+ break;
+
+ /* Check if must fill our buffer. */
+ if ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) == 0x0 )
+ {
+ ulNumAfEvents = ( pSharedInfo->DebugInfo.usAfLogWritePtr - pSharedInfo->DebugInfo.usLastAfLogReadPtr ) & 0xFFFF;
+
+ /* Check for the size of the available buffer. */
+ if ( ulNumAfEvents > ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) )
+ ulNumAfEvents = ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 );
+
+ /* Start at channel main base address. */
+ ReadBurstParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase;
+ /* To get right channel information. */
+ ReadBurstParams.ulReadAddress += ( ( pSharedInfo->DebugInfo.usRecordMemIndex + 2 ) * pSharedInfo->MemoryMap.ulChanMainMemSize );
+ /* To get the right AF log. */
+ ReadBurstParams.ulReadAddress += ( pSharedInfo->DebugInfo.usLastAfLogReadPtr * 16 );
+
+ ulTempIndex = 0;
+ ulNumReads = ulNumAfEvents * 8;
+
+ while ( ulNumReads != 0 )
+ {
+ if ( ulNumReads >= pSharedInfo->ChipConfig.usMaxRwAccesses )
+ ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
+ else
+ ReadBurstParams.ulReadLength = ulNumReads;
+
+ /* Set pointer where to write data. */
+ ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray[ ulTempIndex ];
+
+ mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update indexes, temp variables, addresses. */
+ ulNumReads -= ReadBurstParams.ulReadLength;
+ ulTempIndex += ReadBurstParams.ulReadLength;
+ ReadBurstParams.ulReadAddress += ReadBurstParams.ulReadLength * 2;
+ }
+ }
+
+ /* Copy data byte per byte to avoid endianess problems. */
+ for ( ulCopyIndex = 0; ulCopyIndex < 8; ulCopyIndex ++ )
+ {
+ f_pGetData->pbyData[ ulUserBufWriteIndex + ( 2 * ulCopyIndex ) ] = (UINT8)( pSharedInfo->MiscVars.ausSuperArray[ ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) * 8 ) + ulCopyIndex ] & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex + ( 2 * ulCopyIndex ) + 1 ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) * 8 ) + ulCopyIndex ] >> 8 ) & 0xFF );
+ }
+
+ ulUserBufWriteIndex += 16;
+
+ /* Increment AF log read ptr. */
+ pSharedInfo->DebugInfo.usLastAfLogReadPtr = (UINT16)(( pSharedInfo->DebugInfo.usLastAfLogReadPtr + 1 ) & 0xFFFF );
+ }
+ }
+
+ /* Check if we are done with the AF events. */
+ if ( pSharedInfo->DebugInfo.usLastAfLogReadPtr == pSharedInfo->DebugInfo.usAfLogWritePtr )
+ {
+ /* Insert the tone event information. */
+ for ( ulToneEventIndex = pSharedInfo->DebugInfo.usLastToneEventIndex; ulToneEventIndex < pSharedInfo->ImageInfo.byNumToneDetectors; ulToneEventIndex++ )
+ {
+ if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) < cOCT6100_TLV_MAX_TONE_NAME_SIZE )
+ break;
+
+ Oct6100UserMemCopy( &f_pGetData->pbyData[ ulUserBufWriteIndex ], pSharedInfo->ImageInfo.aToneInfo[ ulToneEventIndex ].aszToneName, cOCT6100_TLV_MAX_TONE_NAME_SIZE );
+
+ ulUserBufWriteIndex += cOCT6100_TLV_MAX_TONE_NAME_SIZE;
+
+ pSharedInfo->DebugInfo.usLastToneEventIndex++;
+ }
+
+ /* If all the tone information has been copied. */
+ if ( ulToneEventIndex == pSharedInfo->ImageInfo.byNumToneDetectors )
+ {
+ /* Copy the image version. */
+ if ( pSharedInfo->DebugInfo.fImageVersionCopied == FALSE )
+ {
+ if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= 512 )
+ {
+ Oct6100UserMemCopy( &f_pGetData->pbyData[ ulUserBufWriteIndex ], pSharedInfo->ImageInfo.szVersionNumber, 512 );
+
+ /* Get PLL jitter count from external memory. */
+ 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 );
+
+ /* Create the mask to retrieve the appropriate value. */
+ mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
+
+ /* Mask data. */
+ ulTempData &= ulMask;
+ /* Move to right position. */
+ ulTempData = ulTempData >> ulFeatureBitOffset;
+
+ f_pGetData->pbyData[ ulUserBufWriteIndex + 510 ] = (UINT8)( ( ulTempData >> 8 ) & 0xFF );
+ f_pGetData->pbyData[ ulUserBufWriteIndex + 511 ] = (UINT8)( ( ulTempData >> 0 ) & 0xFF );
+ }
+
+ /* Add "ISR is not called" bit. */
+ if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE )
+ {
+ f_pGetData->pbyData[ ulUserBufWriteIndex + 510 ] |= 0x80;
+ }
+
+ ulUserBufWriteIndex += 512;
+
+ /* The version has been copied. */
+ pSharedInfo->DebugInfo.fImageVersionCopied = TRUE;
+ }
+ }
+
+ /* If the image version has been copied, proceed with the API version. */
+ if ( pSharedInfo->DebugInfo.fImageVersionCopied == TRUE )
+ {
+ if ( pSharedInfo->DebugInfo.fApiVersionCopied == FALSE )
+ {
+ if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= sizeof(cOCT6100_API_VERSION) )
+ {
+ Oct6100UserMemCopy( &f_pGetData->pbyData[ ulUserBufWriteIndex ], cOCT6100_API_VERSION, sizeof(cOCT6100_API_VERSION) );
+ ulUserBufWriteIndex += sizeof(cOCT6100_API_VERSION);
+
+ /* The API version has been copied. */
+ pSharedInfo->DebugInfo.fApiVersionCopied = TRUE;
+ }
+ }
+ }
+ }
+
+ /* Check if we are done! */
+ if ( pSharedInfo->DebugInfo.fApiVersionCopied == TRUE )
+ {
+ /* Done dumping. */
+
+ /* Reset data being dumpped flag. */
+ pSharedInfo->DebugInfo.fDebugDataBeingDumped = FALSE;
+
+ /* Reset data recording in the chip. */
+ WriteBurstParams.ulWriteAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
+ WriteBurstParams.ulWriteLength = 2;
+ WriteBurstParams.pusWriteData = pSharedInfo->DebugInfo.ausHotChannelData;
+
+ mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+ }
+
+ /* Return number of valid bytes in buffer to user. */
+ f_pGetData->ulValidNumBytes = ulUserBufWriteIndex;
+
+ /* Update remaining bytes. */
+ pSharedInfo->DebugInfo.ulDebugDataRemainingNumBytes -= ulUserBufWriteIndex;
+
+ /* Return remaining bytes. */
+ f_pGetData->ulRemainingNumBytes = pSharedInfo->DebugInfo.ulDebugDataRemainingNumBytes;
+
+ /* Return total number of bytes. */
+ f_pGetData->ulTotalNumBytes = pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes;
+
+ return cOCT6100_ERR_OK;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c
new file mode 100644
index 0000000..6a672cf
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_events.c
@@ -0,0 +1,1326 @@
+#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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100BufferPlayoutGetEvent
+
+Description: Retrieves an array of playout stop 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_pBufPlayoutGetEvent Pointer to structure used to store the playout events.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutGetEventDef(
+ tPOCT6100_BUFFER_PLAYOUT_GET_EVENT f_pBufPlayoutGetEvent )
+{
+ f_pBufPlayoutGetEvent->pBufferPlayoutEvent = NULL;
+ f_pBufPlayoutGetEvent->ulMaxEvent = 1;
+ f_pBufPlayoutGetEvent->ulNumValidEvent = cOCT6100_INVALID_VALUE;
+ f_pBufPlayoutGetEvent->fMoreEvents = FALSE;
+ f_pBufPlayoutGetEvent->fResetBufs = FALSE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100BufferPlayoutGetEvent(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_PLAYOUT_GET_EVENT f_pBufPlayoutGetEvent )
+{
+ 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 = Oct6100BufferPlayoutGetEventSer( f_pApiInstance, f_pBufPlayoutGetEvent );
+ }
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100BufferPlayoutGetEventSer
+
+Description: Retreives an array of buffer playout 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_pEventGetPlayoutStop Pointer to structure which will contain the retreived
+ events.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutGetEventSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_PLAYOUT_GET_EVENT f_pBufPlayoutGetEvent )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BUFFER_PLAYOUT_EVENT pSoftEvent;
+ UINT32 ulSoftReadPnt;
+ UINT32 ulSoftWritePnt;
+ UINT32 ulSoftBufSize;
+ UINT32 ulNumEventsReturned;
+ UINT32 ulResult;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check the parameters past by the user. */
+ if ( f_pBufPlayoutGetEvent->fResetBufs != TRUE &&
+ f_pBufPlayoutGetEvent->fResetBufs != FALSE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_RESET;
+
+ /* Check if software buffer has been allocated and thus enabled. */
+ if ( pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize == 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_DISABLED;
+
+ /* Checking max playout events. */
+ if ( f_pBufPlayoutGetEvent->ulMaxEvent > pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_MAX_EVENT;
+
+ if ( f_pBufPlayoutGetEvent->fResetBufs == FALSE )
+ {
+ /* Check if events need to be fetched from the chip. */
+ ulSoftReadPnt = pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr;
+ ulSoftWritePnt = pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr;
+
+ if ( ulSoftReadPnt == ulSoftWritePnt )
+ {
+ ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, f_pBufPlayoutGetEvent->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.ulBufPlayoutEventBufferReadPtr;
+ ulSoftWritePnt = pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr;
+ ulSoftBufSize = pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize;
+
+ if ( ulSoftReadPnt != ulSoftWritePnt )
+ {
+ ulNumEventsReturned = 0;
+
+ while( (ulSoftReadPnt != ulSoftWritePnt) && ( ulNumEventsReturned != f_pBufPlayoutGetEvent->ulMaxEvent) )
+ {
+ /* Get a pointer to the first event in the buffer. */
+ mOCT6100_GET_BUFFER_PLAYOUT_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
+ pSoftEvent += ulSoftReadPnt;
+
+ f_pBufPlayoutGetEvent->pBufferPlayoutEvent[ ulNumEventsReturned ].ulChannelHndl = pSoftEvent->ulChannelHandle;
+ f_pBufPlayoutGetEvent->pBufferPlayoutEvent[ ulNumEventsReturned ].ulUserChanId = pSoftEvent->ulUserChanId;
+ f_pBufPlayoutGetEvent->pBufferPlayoutEvent[ ulNumEventsReturned ].ulChannelPort = pSoftEvent->ulChannelPort;
+ f_pBufPlayoutGetEvent->pBufferPlayoutEvent[ ulNumEventsReturned ].ulUserEventId = pSoftEvent->ulUserEventId;
+ f_pBufPlayoutGetEvent->pBufferPlayoutEvent[ ulNumEventsReturned ].ulEventType = pSoftEvent->ulEventType;
+ f_pBufPlayoutGetEvent->pBufferPlayoutEvent[ ulNumEventsReturned ].ulTimestamp = pSoftEvent->ulTimestamp;
+
+ /* Update the pointers of the soft buffer. */
+ ulSoftReadPnt++;
+ if ( ulSoftReadPnt == ulSoftBufSize )
+ ulSoftReadPnt = 0;
+
+ ulNumEventsReturned++;
+ }
+
+ pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr = ulSoftReadPnt;
+
+ /* Detemine if there are more events pending in the soft buffer. */
+ if ( ulSoftReadPnt != ulSoftWritePnt )
+ f_pBufPlayoutGetEvent->fMoreEvents = TRUE;
+ else /* ( ulSoftReadPnt == ulSoftWritePnt ) */
+ {
+ f_pBufPlayoutGetEvent->fMoreEvents = FALSE;
+
+ /* Remember this state in the interrupt manager. */
+ pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
+ }
+
+ f_pBufPlayoutGetEvent->ulNumValidEvent = ulNumEventsReturned;
+ }
+ else /* if ( ulSoftReadPnt == ulSoftWritePnt ) */
+ {
+ /* No valid buffer playout events. */
+ f_pBufPlayoutGetEvent->ulNumValidEvent = 0;
+ f_pBufPlayoutGetEvent->fMoreEvents = FALSE;
+
+ /* Remember this state in the interrupt manager. */
+ pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
+
+ return cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_BUF_EMPTY;
+ }
+ }
+ else /* ( f_pEventGetPlayoutStop->fResetBufs == TRUE ) */
+ {
+ /* Check with the hardware first. */
+ ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, f_pBufPlayoutGetEvent->fResetBufs );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* If the buffers are to be reset, then update the pointers and full flag. */
+ pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr = 0;
+ pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr = 0;
+
+ f_pBufPlayoutGetEvent->fMoreEvents = FALSE;
+ f_pBufPlayoutGetEvent->ulNumValidEvent = 0;
+
+ /* Remember this state in the interrupt manager. */
+ pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
+ }
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 */
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.c
new file mode 100644
index 0000000..c96ebcc
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.c
@@ -0,0 +1,1816 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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"
+
+/**************************** PUBLIC FUNCTIONS *****************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100InterruptConfigure
+
+Description: Configure the operation of all possible interrupt sources.
+
+-------------------------------------------------------------------------------
+| 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100InterruptConfigureDef(
+ tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
+{
+ f_pIntrptConfig->ulFatalGeneralConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
+ f_pIntrptConfig->ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
+
+ f_pIntrptConfig->ulErrorMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
+ f_pIntrptConfig->ulErrorOverflowToneEventsConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
+ f_pIntrptConfig->ulErrorH100Config = cOCT6100_INTERRUPT_NO_TIMEOUT;
+
+ f_pIntrptConfig->ulFatalMemoryTimeout = 100;
+
+ f_pIntrptConfig->ulErrorMemoryTimeout = 100;
+ f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = 100;
+ f_pIntrptConfig->ulErrorH100Timeout = 100;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100InterruptConfigure(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
+{
+ 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;
+
+ /* Create serialization object for ISR. */
+ SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
+ SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
+ ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Call serialized sub-function. */
+ ulFncRes = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
+ /* Release serialization object. */
+ ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
+ ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Check if an error occured in sub-function. */
+ if ( ulFncRes != cOCT6100_ERR_OK )
+ return ulFncRes;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_memory.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_memory.c
new file mode 100644
index 0000000..b2690b1
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_memory.c
@@ -0,0 +1,809 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveBufferPlayoutMemoryNode
+
+Description: Get a free node from the unused buffer playout node 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_pulNewNode The index of the node.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveBufferPlayoutMemoryNode(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT32 f_pulNewNode )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pNode;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check if a free block is left. */
+ if ( pSharedInfo->PlayoutInfo.ulUnusedNodeCnt == 0 )
+ {
+ /* This should not happen according to the allocated list from the beginning. */
+ return cOCT6100_ERR_FATAL_CC;
+ }
+
+ /* The new node is the first in the unused list. */
+ *f_pulNewNode = pSharedInfo->PlayoutInfo.ulFirstUnusedNode;
+
+ /* Unlink this new node from the unused list. */
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pNode, *f_pulNewNode );
+
+ pSharedInfo->PlayoutInfo.ulFirstUnusedNode = pNode->ulNext;
+
+ pNode->ulPrevious = pSharedInfo->PlayoutInfo.ulLastUnusedNode;
+
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pNode, pSharedInfo->PlayoutInfo.ulLastUnusedNode );
+
+ pNode->ulNext = pSharedInfo->PlayoutInfo.ulFirstUnusedNode;
+
+ /* Update unused node count. */
+ pSharedInfo->PlayoutInfo.ulUnusedNodeCnt--;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseBufferPlayoutMemoryNode
+
+Description: Release a node that is not used anymore. Insert this node
+ into the unused 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_ulOldNode The index of the node.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseBufferPlayoutMemoryNode(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulOldNode )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pNode;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Get the last unused node. Insert this old node at the end of the unused list. */
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pNode, pSharedInfo->PlayoutInfo.ulLastUnusedNode );
+
+ /* Last node points to old node. */
+ pNode->ulNext = f_ulOldNode;
+
+ /* Update old node. */
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pNode, f_ulOldNode );
+
+ pNode->ulPrevious = pSharedInfo->PlayoutInfo.ulLastUnusedNode;
+ pNode->ulNext = pSharedInfo->PlayoutInfo.ulFirstUnusedNode;
+ pSharedInfo->PlayoutInfo.ulLastUnusedNode = f_ulOldNode;
+
+ /* Keep unused node count. */
+ pSharedInfo->PlayoutInfo.ulUnusedNodeCnt++;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveBufferPlayoutMemory
+
+Description: Try to allocate requested size.
+ Returns an error if malloc point could not be found.
+
+-------------------------------------------------------------------------------
+| 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_ulSize Needed size.
+f_pulMallocAddress Alloc point. This memory can now be used.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveBufferPlayoutMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulSize,
+ OUT PUINT32 f_pulMallocAddress )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pCurrentNode;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pTempNode;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pNewNode;
+
+ UINT32 ulCurrentBufferPlayoutMallocNode;
+ UINT32 ulNewNode;
+ BOOL fFoundMemory = FALSE;
+ UINT32 ulResult;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Requested size must be divisible by 64. */
+ if ( f_ulSize % 64 )
+ {
+ f_ulSize = f_ulSize + ( 64 - ( f_ulSize % 64 ) );
+ }
+
+ /* Start with roving pointer. */
+ ulCurrentBufferPlayoutMallocNode = pSharedInfo->PlayoutInfo.ulRovingNode;
+
+ *f_pulMallocAddress = 0;
+
+ /* Return an error if size requested is zero. */
+ if ( f_ulSize == 0 )
+ {
+ return cOCT6100_ERR_BUFFER_PLAYOUT_MALLOC_ZERO;
+ }
+
+ do
+ {
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pCurrentNode, ulCurrentBufferPlayoutMallocNode );
+
+ /* Look for a free node big enough to fulfill user requested size. */
+ if ( ( pCurrentNode->fAllocated == FALSE ) && ( pCurrentNode->ulSize >= f_ulSize ) )
+ {
+ /* Use this node! */
+ pCurrentNode->fAllocated = TRUE;
+
+ if ( pCurrentNode->ulNext != 0 )
+ {
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pTempNode, pCurrentNode->ulNext );
+
+ if( ( pTempNode->fAllocated == TRUE ) && ( pCurrentNode->ulSize > f_ulSize ) )
+ {
+ /* Fragmentation NOW! */
+
+ /* Allocate new node that will contain free size. */
+ ulResult = Oct6100ApiReserveBufferPlayoutMemoryNode( f_pApiInstance, &ulNewNode );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pNewNode, ulNewNode );
+
+ /* Can use this free node. */
+ pNewNode->ulSize = pCurrentNode->ulSize - f_ulSize;
+ pNewNode->ulStartAddress = pCurrentNode->ulStartAddress + f_ulSize;
+
+ /* Link new node into the list. */
+ pNewNode->ulNext = pCurrentNode->ulNext;
+ pNewNode->ulPrevious = ulCurrentBufferPlayoutMallocNode;
+ pNewNode->fAllocated = FALSE;
+ pTempNode->ulPrevious = ulNewNode;
+ pCurrentNode->ulNext = ulNewNode;
+ }
+ }
+ else if ( pCurrentNode->ulSize > f_ulSize )
+ {
+ /* Must allocate a new free node for the rest of the space. */
+ ulResult = Oct6100ApiReserveBufferPlayoutMemoryNode( f_pApiInstance, &ulNewNode );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pNewNode, ulNewNode );
+
+ pNewNode->ulNext = pCurrentNode->ulNext;
+ pCurrentNode->ulNext = ulNewNode;
+ pNewNode->ulPrevious = ulCurrentBufferPlayoutMallocNode;
+ pNewNode->fAllocated = FALSE;
+ pNewNode->ulSize = pCurrentNode->ulSize - f_ulSize;
+ pNewNode->ulStartAddress = pCurrentNode->ulStartAddress + f_ulSize;
+
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pTempNode, 0 );
+
+ /* Check for the head node that would have to be updated. */
+ if ( ( ulCurrentBufferPlayoutMallocNode == 0 ) && ( pTempNode->ulPrevious == 0 ) )
+ pTempNode->ulPrevious = ulNewNode;
+ }
+ else
+ {
+ /* Perfect fit. */
+ }
+ pCurrentNode->ulSize = f_ulSize;
+
+ /* Update roving pointer. */
+ pSharedInfo->PlayoutInfo.ulRovingNode = ulCurrentBufferPlayoutMallocNode;
+ *f_pulMallocAddress = pCurrentNode->ulStartAddress;
+ fFoundMemory = TRUE;
+ break;
+ }
+
+ /* Next block! */
+ ulCurrentBufferPlayoutMallocNode = pCurrentNode->ulNext;
+
+ } while ( pSharedInfo->PlayoutInfo.ulRovingNode != ulCurrentBufferPlayoutMallocNode );
+
+ if ( fFoundMemory == FALSE )
+ {
+ return cOCT6100_ERR_BUFFER_PLAYOUT_NO_MEMORY;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseBufferPlayoutMemory
+
+Description: Free what was allocated at address. Free is somewhat slower
+ then Malloc. O(n), must travel through the list looking for
+ the malloc point. Return an error if alloc point was not found.
+
+-------------------------------------------------------------------------------
+| 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_ulMallocAddress Alloc point. The memory at address will be freed.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseBufferPlayoutMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulMallocAddress )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pCurrentNode;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pTempNode;
+ tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pOldNode;
+
+ UINT32 ulResult = cOCT6100_ERR_BUFFER_PLAYOUT_MALLOC_POINT_NOT_FOUND;
+ UINT32 ulNodeToMerge;
+ UINT32 ulNodeToRemove;
+ UINT32 ulCurrentBufferPlayoutMallocNode;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Start from the beginning and find the alloc node. */
+ ulCurrentBufferPlayoutMallocNode = 0;
+
+ do
+ {
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pCurrentNode, ulCurrentBufferPlayoutMallocNode );
+
+ if ( ( pCurrentNode->ulStartAddress == f_ulMallocAddress ) && ( pCurrentNode->fAllocated == TRUE ) )
+ {
+ /* We found the block! */
+ pCurrentNode->fAllocated = FALSE;
+
+ /* Check if the next node can be merged. */
+ if ( pCurrentNode->ulNext != 0 )
+ {
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pTempNode, pCurrentNode->ulNext );
+
+ if ( pTempNode->fAllocated == FALSE )
+ {
+ /* Can merge this block to us. */
+ pCurrentNode->ulSize += pTempNode->ulSize;
+ pTempNode->ulSize = 0;
+
+ /* Unlink unused node. */
+ ulNodeToRemove = pCurrentNode->ulNext;
+ pCurrentNode->ulNext = pTempNode->ulNext;
+
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pTempNode, pCurrentNode->ulNext );
+
+ pTempNode->ulPrevious = ulCurrentBufferPlayoutMallocNode;
+
+ ulResult = Oct6100ApiReleaseBufferPlayoutMemoryNode( f_pApiInstance, ulNodeToRemove );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Move roving pointer if have to. */
+ if ( pSharedInfo->PlayoutInfo.ulRovingNode == ulNodeToRemove )
+ pSharedInfo->PlayoutInfo.ulRovingNode = ulCurrentBufferPlayoutMallocNode;
+ }
+ }
+
+ /* Check if previous node can merge. */
+ if ( ulCurrentBufferPlayoutMallocNode != 0 )
+ {
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pTempNode, pCurrentNode->ulPrevious );
+
+ if ( pTempNode->fAllocated == FALSE )
+ {
+ ulNodeToMerge = pCurrentNode->ulPrevious;
+
+ /* Can merge us to this node. */
+ pTempNode->ulSize += pCurrentNode->ulSize;
+ pCurrentNode->ulSize = 0;
+
+ /* Unlink unused node. */
+ ulNodeToRemove = ulCurrentBufferPlayoutMallocNode;
+
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pOldNode, ulNodeToRemove );
+
+ pTempNode->ulNext = pOldNode->ulNext;
+
+ mOCT6100_GET_BUFFER_MEMORY_NODE_ENTRY_PNT( pSharedInfo, pTempNode, pTempNode->ulNext );
+
+ pTempNode->ulPrevious = ulNodeToMerge;
+
+ pOldNode->fAllocated = FALSE;
+ pOldNode->ulSize = 0;
+ pOldNode->ulStartAddress = 0;
+
+ /* Move roving pointer if have to. */
+ if ( pSharedInfo->PlayoutInfo.ulRovingNode == ulNodeToRemove )
+ pSharedInfo->PlayoutInfo.ulRovingNode = ulNodeToMerge;
+
+ /* Release this unused node. */
+ ulResult = Oct6100ApiReleaseBufferPlayoutMemoryNode( f_pApiInstance, ulNodeToRemove );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* All's good! */
+ ulResult = 0;
+ break;
+ }
+
+ /* Next node. */
+ ulCurrentBufferPlayoutMallocNode = pCurrentNode->ulNext;
+
+ } while( ulCurrentBufferPlayoutMallocNode != 0 );
+
+ return ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_miscellaneous.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_miscellaneous.c
new file mode 100644
index 0000000..30034c5
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_miscellaneous.c
@@ -0,0 +1,620 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: oct6100_miscellaneous.c
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ This file contains miscellaneous functions used in various files.
+
+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: 34 $
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+
+
+/***************************** INCLUDE FILES *******************************/
+
+#include "octdef.h"
+
+#include "oct6100api/oct6100_defines.h"
+#include "oct6100api/oct6100_errors.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_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 "oct6100_chip_open_priv.h"
+#include "oct6100_channel_priv.h"
+#include "oct6100_miscellaneous_priv.h"
+
+
+/**************************** PRIVATE FUNCTIONS ****************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWaitForTime
+
+Description: Waits for the specified amount of time.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_aulWaitTime[ 2 ] The amout of time to be waited.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ApiCreateFeatureMask
+
+Description:
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+
+f_ulFieldSize Size of the field, in bits.
+f_ulFieldBitOffset Bit offset, from the least significant bit.
+f_pulFieldMask Resulting mask.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiCreateFeatureMask(
+ IN UINT32 f_ulFieldSize,
+ IN UINT32 f_ulFieldBitOffset,
+ OUT PUINT32 f_pulFieldMask )
+{
+ UINT32 ulMask;
+ UINT32 i;
+
+ ulMask = 0;
+
+ /* Create the mask based on the field size. */
+ for ( i = 0; i < f_ulFieldSize; i++ )
+ {
+ ulMask <<= 1;
+ ulMask |= 1;
+ }
+
+ /* Once the mask is of the desired size, offset it to fit the field */
+ /* within the DWORD read. */
+ ulMask <<= f_ulFieldBitOffset;
+
+ /* Return the mask. */
+ *f_pulFieldMask = ulMask;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_mixer.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_mixer.c
new file mode 100644
index 0000000..680bf7e
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_mixer.c
@@ -0,0 +1,1542 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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"
+
+/**************************** PUBLIC FUNCTIONS ****************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100MixerCopyEventCreate
+
+Description: This function creates a mixer copy event used to copy
+ information from one channel port to another channel port.
+
+-------------------------------------------------------------------------------
+| 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_pCopyEventCreate Pointer to a mixer copy event structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100MixerCopyEventCreateDef(
+ tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate )
+{
+ f_pCopyEventCreate->pulCopyEventHndl = NULL;
+
+ f_pCopyEventCreate->ulSourceChanHndl = cOCT6100_INVALID_HANDLE;
+ f_pCopyEventCreate->ulSourcePort = cOCT6100_INVALID_PORT;
+
+ f_pCopyEventCreate->ulDestinationChanHndl = cOCT6100_INVALID_HANDLE;
+ f_pCopyEventCreate->ulDestinationPort = cOCT6100_INVALID_PORT;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100MixerCopyEventCreate(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate )
+{
+ 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 = Oct6100MixerCopyEventCreateSer( f_pApiInstance, f_pCopyEventCreate );
+ }
+ 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: Oct6100MixerCopyEventDestroy
+
+Description: This function destroys a mixer copy event used to copy
+ information from one channel port to another.
+
+-------------------------------------------------------------------------------
+| 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_pCopyEventDestroy Pointer to a destroy copy event structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100MixerCopyEventDestroyDef(
+ tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy )
+{
+ f_pCopyEventDestroy->ulCopyEventHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100MixerCopyEventDestroy(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy )
+{
+ 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 = Oct6100MixerCopyEventDestroySer( f_pApiInstance, f_pCopyEventDestroy );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100MixerCopyEventCreateSer
+
+-------------------------------------------------------------------------------
+| 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_pCopyEventCreate Pointer to a create copy event structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100MixerCopyEventCreateSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate )
+{
+ UINT16 usCopyEventIndex;
+ UINT16 usMixerEventIndex;
+ UINT16 usSourceChanIndex;
+ UINT16 usDestinationChanIndex;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the copy event for errors. */
+ ulResult = Oct6100ApiCheckCopyEventCreateParams( f_pApiInstance,
+ f_pCopyEventCreate,
+ &usSourceChanIndex,
+ &usDestinationChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the copy event. */
+ ulResult = Oct6100ApiReserveCopyEventCreateResources( f_pApiInstance,
+ &usCopyEventIndex,
+ &usMixerEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write all necessary structures to activate the echo cancellation channel. */
+ ulResult = Oct6100ApiWriteCopyEventCreateStructs( f_pApiInstance,
+ f_pCopyEventCreate,
+ usMixerEventIndex,
+ usSourceChanIndex,
+ usDestinationChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the new echo cancellation channels's entry in the ECHO channel list. */
+ ulResult = Oct6100ApiUpdateCopyEventCreateEntry( f_pApiInstance,
+ f_pCopyEventCreate,
+ usCopyEventIndex,
+ usMixerEventIndex,
+ usSourceChanIndex,
+ usDestinationChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckCopyEventCreateParams
+
+Description: Checks the user's parameter passed to the create
+ copy event 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_pCopyEventCreate Pointer to a create copy event structure.
+f_pusSourceChanIndex Pointer to the index of the input channel.
+f_pusDestinationChanIndex Pointer to the index of the output channel.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckCopyEventCreateParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate,
+ OUT PUINT16 f_pusSourceChanIndex,
+ OUT PUINT16 f_pusDestinationChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pSourceEntry;
+ tPOCT6100_API_CHANNEL pDestinationEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Obtain shared resources pointer. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ if ( f_pCopyEventCreate->pulCopyEventHndl == NULL )
+ return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
+
+ if ( f_pCopyEventCreate->ulSourceChanHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
+ if ( f_pCopyEventCreate->ulDestinationChanHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
+
+ if ( f_pCopyEventCreate->ulSourcePort != cOCT6100_CHANNEL_PORT_RIN &&
+ f_pCopyEventCreate->ulSourcePort != cOCT6100_CHANNEL_PORT_SIN )
+ return cOCT6100_ERR_MIXER_SOURCE_PORT;
+
+ if ( f_pCopyEventCreate->ulDestinationPort != cOCT6100_CHANNEL_PORT_RIN &&
+ f_pCopyEventCreate->ulDestinationPort != cOCT6100_CHANNEL_PORT_SIN )
+ return cOCT6100_ERR_MIXER_DESTINATION_PORT;
+
+ /*=======================================================================*/
+ /* Verify the first channel handle. */
+
+ if ( (f_pCopyEventCreate->ulSourceChanHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
+
+ *f_pusSourceChanIndex = (UINT16)( f_pCopyEventCreate->ulSourceChanHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusSourceChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
+ return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
+
+ /* Get a pointer to the channel's list entry. */
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSourceEntry, *f_pusSourceChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pCopyEventCreate->ulSourceChanHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pSourceEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CHANNEL_NOT_OPEN;
+ if ( ulEntryOpenCnt != pSourceEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_MIXER_SOURCE_CHAN_HANDLE;
+ if ( pSourceEntry->CodecConfig.byDecoderPort == f_pCopyEventCreate->ulSourcePort )
+ return cOCT6100_ERR_MIXER_SOURCE_ADPCM_RESOURCES_ACTIVATED;
+
+ /*=======================================================================*/
+
+ /*=======================================================================*/
+ /* Verify the second channel handle. */
+
+ if ( (f_pCopyEventCreate->ulDestinationChanHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
+
+ *f_pusDestinationChanIndex = (UINT16)( f_pCopyEventCreate->ulDestinationChanHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusDestinationChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
+ return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
+
+ /* Get a pointer to the channel's list entry. */
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, *f_pusDestinationChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pCopyEventCreate->ulDestinationChanHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pDestinationEntry->fReserved != TRUE )
+ return cOCT6100_ERR_CHANNEL_NOT_OPEN;
+ if ( ulEntryOpenCnt != pDestinationEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_MIXER_DESTINATION_CHAN_HANDLE;
+ if ( pDestinationEntry->CodecConfig.byDecoderPort == f_pCopyEventCreate->ulDestinationPort )
+ return cOCT6100_ERR_MIXER_DEST_ADPCM_RESOURCES_ACTIVATED;
+
+ /*=======================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveCopyEventCreateResources
+
+-------------------------------------------------------------------------------
+| 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_pusCopyEntryIndex Pointer to the index of the copy entry within the API's list.
+f_pusCopyEventIndex Pointer to the index of the mixer copy event.
+.
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveCopyEventCreateResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusCopyEntryIndex,
+ IN OUT PUINT16 f_pusCopyEventIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT32 ulResult = cOCT6100_ERR_OK;
+ UINT32 ulTempVar;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /*===============================================================================*/
+ /* Verify and reserve the resources that might already be allocated. */
+
+ ulResult = Oct6100ApiReserveCopyEventEntry( f_pApiInstance,
+ f_pusCopyEntryIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Reserve the source copy event for the first channel. */
+ ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
+ f_pusCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* Reserve the Sin copy event for the first channel. */
+ ulTempVar = Oct6100ApiReleaseCopyEventEntry ( f_pApiInstance,
+ *f_pusCopyEntryIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteCopyEventCreateStructs
+
+Description: Performs all the required structure writes to configure the
+ new copy 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_pCopyEventCreate Pointer to a create copy event structure.
+f_usMixerEventIndex Index of the copy event within the mixer memory.
+f_usSourceChanIndex Index of the source channel within the API's channel list.
+f_usDestinationChanIndex Index of the destination channel within the API's channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiWriteCopyEventCreateStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_COPY_EVENT_CREATE f_pCopyEventCreate,
+ IN UINT16 f_usMixerEventIndex,
+ IN UINT16 f_usSourceChanIndex,
+ IN UINT16 f_usDestinationChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pSourceEntry;
+ tPOCT6100_API_CHANNEL pDestinationEntry;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* 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 two channel entry. */
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSourceEntry, f_usSourceChanIndex );
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, f_usDestinationChanIndex );
+
+ /*==============================================================================*/
+ /* Configure the TSST control memory and add the Sin copy event if necessary. */
+
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usMixerEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
+
+ if ( f_pCopyEventCreate->ulSourcePort == cOCT6100_CHANNEL_PORT_RIN )
+ {
+ WriteParams.usWriteData |= pSourceEntry->usRinRoutTsiMemIndex;
+ WriteParams.usWriteData |= pSourceEntry->TdmConfig.byRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ }
+ else /* f_pCopyEventCreate->ulSourcePort == cOCT6100_CHANNEL_PORT_SIN */
+ {
+ if ( pSourceEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
+ {
+ WriteParams.usWriteData |= pSourceEntry->usExtraSinTsiMemIndex;
+ }
+ else
+ {
+ WriteParams.usWriteData |= pSourceEntry->usSinSoutTsiMemIndex;
+ }
+
+ WriteParams.usWriteData |= pSourceEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ WriteParams.ulWriteAddress += 2;
+
+ if ( f_pCopyEventCreate->ulDestinationPort == cOCT6100_CHANNEL_PORT_RIN )
+ {
+ WriteParams.usWriteData = (UINT16)( pDestinationEntry->usRinRoutTsiMemIndex );
+ }
+ else /* f_pCopyEventCreate->ulDestinationPort == cOCT6100_CHANNEL_PORT_SIN */
+ {
+ WriteParams.usWriteData = (UINT16)( pDestinationEntry->usSinSoutTsiMemIndex );
+ }
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*=======================================================================*/
+
+ /* Now insert the event into the event list. */
+ ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
+ f_usMixerEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY,
+ f_usDestinationChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Increment the copy event count on this channel. */
+ pDestinationEntry->usCopyEventCnt++;
+
+ /*==============================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateCopyEventCreateEntry
+
+-------------------------------------------------------------------------------
+| 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_pCopyEventCreate Pointer to a create copy event structure.
+f_usCopyEventIndex Index of the copy event within the API's event list.
+f_usMixerEventIndex Index of the copy event within the mixer memory.
+f_usSourceChanIndex Index of the source channel within the API's channel list.
+f_usDestinationChanIndex Index of the destination channel within the API's channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_COPY_EVENT pCopyEventEntry;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Obtain a pointer to the new buffer's list entry. */
+ mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, f_usCopyEventIndex );
+
+ /*=======================================================================*/
+ /* Copy the channel's configuration and allocated resources. */
+
+ /* Save the channel info in the copy event. */
+ pCopyEventEntry->usSourceChanIndex = f_usSourceChanIndex;
+ pCopyEventEntry->bySourcePort = (UINT8)( f_pCopyEventCreate->ulSourcePort & 0xFF );
+
+ pCopyEventEntry->usDestinationChanIndex = f_usDestinationChanIndex;
+ pCopyEventEntry->byDestinationPort = (UINT8)( f_pCopyEventCreate->ulDestinationPort & 0xFF );
+
+ pCopyEventEntry->usMixerEventIndex = f_usMixerEventIndex;
+
+ /*=======================================================================*/
+
+ /* Form handle returned to user. */
+ *f_pCopyEventCreate->pulCopyEventHndl = cOCT6100_HNDL_TAG_COPY_EVENT | (pCopyEventEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usCopyEventIndex;
+
+ /* Finally, mark the event as used. */
+ pCopyEventEntry->fReserved = TRUE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100MixerCopyEventDestroySer
+
+-------------------------------------------------------------------------------
+| 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_pCopyEventDestroy Pointer to a destroy copy event structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100MixerCopyEventDestroySer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_COPY_EVENT_DESTROY f_pCopyEventDestroy )
+{
+ UINT16 usCopyEventIndex;
+ UINT16 usMixerEventIndex;
+ UINT32 ulResult;
+
+ /* Verify that all the parameters given match the state of the API. */
+ ulResult = Oct6100ApiAssertCopyEventDestroyParams( f_pApiInstance,
+ f_pCopyEventDestroy,
+ &usCopyEventIndex,
+ &usMixerEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the echo cancellation channel. */
+ ulResult = Oct6100ApiInvalidateCopyEventStructs( f_pApiInstance,
+ usCopyEventIndex,
+ usMixerEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the echo cancellation channel. */
+ ulResult = Oct6100ApiReleaseCopyEventResources( f_pApiInstance,
+ usCopyEventIndex,
+ usMixerEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Invalidate the handle. */
+ f_pCopyEventDestroy->ulCopyEventHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiAssertCopyEventDestroyParams
+
+Description:
+
+-------------------------------------------------------------------------------
+| 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_pCopyEventDestroy Pointer to a destroy copy event structure.
+f_pusCopyEventIndex Pointer to the index of the copy event in the API.
+f_pusMixerEventIndex Pointer to the index of the copy event in the mixer memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_COPY_EVENT pCopyEventEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check the provided handle. */
+ if ( (f_pCopyEventDestroy->ulCopyEventHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_COPY_EVENT )
+ return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
+
+ *f_pusCopyEventIndex = (UINT16)( f_pCopyEventDestroy->ulCopyEventHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusCopyEventIndex >= cOCT6100_MAX_MIXER_EVENTS )
+ return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
+
+ /*=======================================================================*/
+
+ mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, *f_pusCopyEventIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = ( f_pCopyEventDestroy->ulCopyEventHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pCopyEventEntry->fReserved != TRUE )
+ return cOCT6100_ERR_MIXER_EVENT_NOT_OPEN;
+ if ( ulEntryOpenCnt != pCopyEventEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_MIXER_COPY_EVENT_HANDLE;
+
+ /*=======================================================================*/
+
+ /* Return the index of the associated event. */
+ *f_pusMixerEventIndex = pCopyEventEntry->usMixerEventIndex;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiInvalidateCopyEventStructs
+
+Description: Destroy the link between the two channels.
+
+-------------------------------------------------------------------------------
+| 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_usCopyEventIndex Index of the copy event in the API.
+f_usMixerEventIndex Index of the copy event in the mixer memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiInvalidateCopyEventStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usCopyEventIndex,
+ IN UINT16 f_usMixerEventIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*=======================================================================*/
+ /* Clear the Copy event. */
+ WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usMixerEventIndex * 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;
+
+ /*=======================================================================*/
+
+ /* Remove the event from the list. */
+ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
+ f_usMixerEventIndex,
+ cOCT6100_EVENT_TYPE_SIN_COPY );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseCopyEventResources
+
+-------------------------------------------------------------------------------
+| 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_usCopyEventIndex Index of the copy event in the API.
+f_usMixerEventIndex Index of the copy event in the mixer memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseCopyEventResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usCopyEventIndex,
+ IN UINT16 f_usMixerEventIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_CHANNEL pDestinationEntry;
+ tPOCT6100_API_COPY_EVENT pCopyEventEntry;
+ tPOCT6100_API_MIXER_EVENT pTempEventEntry;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, f_usCopyEventIndex );
+
+ ulResult = Oct6100ApiReleaseCopyEventEntry( f_pApiInstance, f_usCopyEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_AC;
+
+ /* Relese the SIN copy event. */
+ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usMixerEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_B3;
+
+ mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, f_usMixerEventIndex );
+
+ /* Invalidate the entry. */
+ pTempEventEntry->fReserved = FALSE;
+ pTempEventEntry->usEventType = cOCT6100_INVALID_INDEX;
+ pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, pCopyEventEntry->usDestinationChanIndex );
+
+ /* Decrement the copy event count on this channel. */
+ pDestinationEntry->usCopyEventCnt--;
+
+ /*=======================================================================*/
+
+ /* Mark the event entry as unused. */
+ pCopyEventEntry->fReserved = FALSE;
+ pCopyEventEntry->byEntryOpenCnt++;
+
+ /*=======================================================================*/
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100ApiReserveCopyEventEntry
+
+Description: Reserves a free entry in the copy 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveCopyEventEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusEventIndex )
+{
+ PVOID pCopyEventAlloc;
+ UINT32 ulResult;
+ UINT32 ulEventIndex;
+
+ mOCT6100_GET_COPY_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pCopyEventAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pCopyEventAlloc, &ulEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_MIXER_ALL_COPY_EVENT_ENTRY_OPENED;
+ else
+ return cOCT6100_ERR_FATAL_AD;
+ }
+
+ *f_pusEventIndex = (UINT16)( ulEventIndex & 0xFFFF );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseCopyEventEntry
+
+Description: Release an entry from the copy 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseCopyEventEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usEventIndex )
+{
+ PVOID pCopyEventAlloc;
+ UINT32 ulResult;
+
+ mOCT6100_GET_COPY_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pCopyEventAlloc )
+
+ ulResult = OctapiLlmAllocDealloc( pCopyEventAlloc, f_usEventIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_AE;
+
+ return cOCT6100_ERR_OK;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_phasing_tsst.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_phasing_tsst.c
new file mode 100644
index 0000000..bf70f31
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_phasing_tsst.c
@@ -0,0 +1,888 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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 ****************************/
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100PhasingTsstOpen
+
+Description: This function opens a 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.
+
+f_pPhasingTsstOpen Pointer to phasing TSST open structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100PhasingTsstOpenDef(
+ tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen )
+{
+ f_pPhasingTsstOpen->pulPhasingTsstHndl = NULL;
+
+ f_pPhasingTsstOpen->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
+ f_pPhasingTsstOpen->ulStream = cOCT6100_INVALID_STREAM;
+
+ f_pPhasingTsstOpen->ulPhasingLength = 88;
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100PhasingTsstOpen(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen )
+{
+ 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 = Oct6100PhasingTsstOpenSer( f_pApiInstance, f_pPhasingTsstOpen );
+ }
+ 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: Oct6100PhasingTsstClose
+
+Description: This function closes a 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.
+
+f_pPhasingTsstClose Pointer to phasing TSST close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100PhasingTsstCloseDef(
+ tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose )
+{
+ f_pPhasingTsstClose->ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+UINT32 Oct6100PhasingTsstClose(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose )
+{
+ 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 = Oct6100PhasingTsstCloseSer( f_pApiInstance, f_pPhasingTsstClose );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100PhasingTsstOpenSer
+
+Description: Opens a 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.
+
+f_pPhasingTsstOpen Pointer to phasing TSST open configuration structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100PhasingTsstOpenSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen )
+{
+ UINT16 usPhasingIndex;
+ UINT16 usTsstIndex;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the phasing TSST for errors. */
+ ulResult = Oct6100ApiCheckPhasingParams( f_pApiInstance, f_pPhasingTsstOpen );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the phasing TSST. */
+ ulResult = Oct6100ApiReservePhasingResources( f_pApiInstance, f_pPhasingTsstOpen, &usPhasingIndex, &usTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write all necessary structures to activate the phasing TSST. */
+ ulResult = Oct6100ApiWritePhasingStructs( f_pApiInstance, f_pPhasingTsstOpen, usPhasingIndex, usTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the new phasing TSST entry in the API list. */
+ ulResult = Oct6100ApiUpdatePhasingEntry( f_pApiInstance, f_pPhasingTsstOpen, usPhasingIndex, usTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckPhasingParams
+
+Description: Checks the user's phasing TSST 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_pPhasingTsstOpen Pointer to phasing TSST open configuration structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckPhasingParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen )
+{
+ UINT32 ulResult;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPhasingTssts == 0 )
+ return cOCT6100_ERR_PHASING_TSST_DISABLED;
+
+ if ( f_pPhasingTsstOpen->pulPhasingTsstHndl == NULL )
+ return cOCT6100_ERR_PHASING_TSST_INVALID_HANDLE;
+
+ /* Check the phasing length. */
+ if ( f_pPhasingTsstOpen->ulPhasingLength > 240 ||
+ f_pPhasingTsstOpen->ulPhasingLength == 0 )
+ return cOCT6100_ERR_PHASING_TSST_PHASING_LENGTH;
+
+
+
+ /* Check the input TDM streams, timeslots component for errors. */
+ ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
+ cOCT6100_NUMBER_TSSTS_1,
+ f_pPhasingTsstOpen->ulTimeslot,
+ f_pPhasingTsstOpen->ulStream,
+ cOCT6100_INPUT_TSST );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
+ {
+ return cOCT6100_ERR_PHASING_TSST_TIMESLOT;
+ }
+ else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
+ {
+ return cOCT6100_ERR_PHASING_TSST_STREAM;
+ }
+ else
+ {
+ return ulResult;
+ }
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReservePhasingResources
+
+Description: Reserves all resources needed for the new 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.
+
+f_pPhasingTsstOpen Pointer to phasing TSST configuration structure.
+f_pusPhasingIndex Allocated entry in Phasing TSST API list.
+f_pusTsstIndex TSST memory index of the counter.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReservePhasingResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen,
+ OUT PUINT16 f_pusPhasingIndex,
+ OUT PUINT16 f_pusTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT32 ulResult;
+ UINT32 ulTempVar;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Reserve an entry in the phasing TSST list. */
+ ulResult = Oct6100ApiReservePhasingEntry( f_pApiInstance,
+ f_pusPhasingIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Reserve the input TSST entry. */
+ ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
+ f_pPhasingTsstOpen->ulTimeslot,
+ f_pPhasingTsstOpen->ulStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_INPUT_TSST,
+ f_pusTsstIndex,
+ NULL );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* Release the previously reserved entries. */
+ ulTempVar = Oct6100ApiReleasePhasingEntry( f_pApiInstance, *f_pusPhasingIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+
+ return ulResult;
+ }
+ }
+ else
+ {
+ return ulResult;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWritePhasingStructs
+
+Description: Performs all the required structure writes to configure the
+ new 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.
+
+f_pPhasingTsstOpen Pointer to phasing TSST configuration structure.
+f_usPhasingIndex Allocated entry in phasing TSST API list.
+f_usTsstIndex TSST memory index of the counter.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiWritePhasingStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_PHASING_TSST_OPEN f_pPhasingTsstOpen,
+ IN UINT16 f_usPhasingIndex,
+ IN UINT16 f_usTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulPhasingTsstChariotMemIndex;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*------------------------------------------------------------------------------*/
+ /* Configure the TSST control memory of the phasing TSST. */
+
+ /* Find the asociated entry in the chariot memory for the phasing TSST. */
+ ulPhasingTsstChariotMemIndex = cOCT6100_TSST_CONTROL_PHASING_TSST_BASE_ENTRY + f_usPhasingIndex;
+
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_INPUT_TSST;
+ WriteParams.usWriteData |= ulPhasingTsstChariotMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ /*------------------------------------------------------------------------------*/
+ /* Write the phasing length of the TSST in the ADPCM / MIXER memory. */
+
+ WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_PHASE_SIZE_BASE_ADD + ( f_usPhasingIndex * 2 );
+ WriteParams.usWriteData = (UINT16)( f_pPhasingTsstOpen->ulPhasingLength );
+
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdatePhasingEntry
+
+Description: Updates the new phasing TSST in the API phasing TSST 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_pPhasingTsstOpen Pointer to phasing TSST open structure.
+f_usPhasingIndex Allocated entry in phasing TSST API list.
+f_usTsstIndex TSST memory index of the counter.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_API_PHASING_TSST pPhasingTsstEntry;
+
+ /*================================================================================*/
+ /* Obtain a pointer to the new buffer's list entry. */
+ mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingTsstEntry, f_usPhasingIndex )
+
+ /* Copy the phasing TSST's configuration and allocated resources. */
+ pPhasingTsstEntry->usTimeslot = (UINT16)( f_pPhasingTsstOpen->ulTimeslot & 0xFFFF );
+ pPhasingTsstEntry->usStream = (UINT16)( f_pPhasingTsstOpen->ulStream & 0xFFFF );
+
+ pPhasingTsstEntry->usPhasingLength = (UINT16)( f_pPhasingTsstOpen->ulPhasingLength & 0xFFFF );
+
+ /* Store hardware related information. */
+ pPhasingTsstEntry->usPhasingTsstIndex = f_usTsstIndex;
+
+ /* Form handle returned to user. */
+ *f_pPhasingTsstOpen->pulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsstEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usPhasingIndex;
+ pPhasingTsstEntry->usDependencyCnt = 0; /* Nobody is using the phasing TSST.*/
+
+ /* Finally, mark the phasing TSST as open. */
+ pPhasingTsstEntry->fReserved = TRUE;
+
+ /* Increment the number of phasing TSSTs opened. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberPhasingTssts++;
+
+ /*================================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100PhasingTsstCloseSer
+
+Description: Closes a 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.
+
+f_pPhasingTsstClose Pointer to phasing TSST close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100PhasingTsstCloseSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose )
+{
+ UINT16 usPhasingIndex;
+ UINT16 usTsstIndex;
+ UINT32 ulResult;
+
+ /* Verify that all the parameters given match the state of the API. */
+ ulResult = Oct6100ApiAssertPhasingParams( f_pApiInstance, f_pPhasingTsstClose, &usPhasingIndex, &usTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the phasing TSST. */
+ ulResult = Oct6100ApiInvalidatePhasingStructs( f_pApiInstance, usTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the phasing TSST. */
+ ulResult = Oct6100ApiReleasePhasingResources( f_pApiInstance, usPhasingIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ f_pPhasingTsstClose->ulPhasingTsstHndl = cOCT6100_INVALID_VALUE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiAssertPhasingParams
+
+Description: Validate the handle given by the user and verify the state of
+ the phasing TSST about to be closed. Also returns all
+ required information to deactivate the 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.
+
+f_pPhasingTsstClose Pointer to phasing TSST close structure.
+f_pusPhasingIndex Index of the phasing TSST structure in the API list.
+f_pusTsstIndex Index of the entry in the TSST control memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiAssertPhasingParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_PHASING_TSST_CLOSE f_pPhasingTsstClose,
+ OUT PUINT16 f_pusPhasingIndex,
+ OUT PUINT16 f_pusTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_PHASING_TSST pPhasingEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check the provided handle. */
+ if ( (f_pPhasingTsstClose->ulPhasingTsstHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_PHASING_TSST )
+ return cOCT6100_ERR_PHASING_TSST_INVALID_HANDLE;
+
+ *f_pusPhasingIndex = (UINT16)( f_pPhasingTsstClose->ulPhasingTsstHndl & cOCT6100_HNDL_INDEX_MASK );
+ if ( *f_pusPhasingIndex >= pSharedInfo->ChipConfig.usMaxPhasingTssts )
+ return cOCT6100_ERR_PHASING_TSST_INVALID_HANDLE;
+
+ /*=======================================================================*/
+ /* Get a pointer to the phasing TSST's list entry. */
+
+ mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingEntry, *f_pusPhasingIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = (f_pPhasingTsstClose->ulPhasingTsstHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pPhasingEntry->fReserved != TRUE )
+ return cOCT6100_ERR_PHASING_TSST_NOT_OPEN;
+ if ( pPhasingEntry->usDependencyCnt != 0 )
+ return cOCT6100_ERR_PHASING_TSST_ACTIVE_DEPENDENCIES;
+ if ( ulEntryOpenCnt != pPhasingEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_PHASING_TSST_INVALID_HANDLE;
+
+ /* Return info needed to close the phasing TSST and release all resources. */
+ *f_pusTsstIndex = pPhasingEntry->usPhasingTsstIndex;
+
+ /*=======================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiInvalidatePhasingStructs
+
+Description: Closes a 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.
+
+f_usTsstIndex Index of the entry in the TSST control memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiInvalidatePhasingStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*------------------------------------------------------------------------------*/
+ /* Deactivate the TSST control memory. */
+
+ /* Set the input TSST control entry to unused. */
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = 0x0000;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*------------------------------------------------------------------------------*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleasePhasingResources
+
+Description: Release and clear the API entry associated to the 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.
+
+f_usPhasingIndex Index of the phasing TSST in the API list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleasePhasingResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usPhasingIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_PHASING_TSST pPhasingEntry;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingEntry, f_usPhasingIndex );
+
+ /* Release the entry in the phasing TSST list. */
+ ulResult = Oct6100ApiReleasePhasingEntry( f_pApiInstance, f_usPhasingIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Release the entry. */
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ pPhasingEntry->usTimeslot,
+ pPhasingEntry->usStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_INPUT_TSST,
+ cOCT6100_INVALID_INDEX ); /* Release the TSST entry */
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ return cOCT6100_ERR_FATAL;
+ }
+ }
+ else
+ {
+ return ulResult;
+ }
+
+ /*=============================================================*/
+ /* Update the phasing TSST's list entry. */
+
+ /* Mark the entry as closed. */
+ pPhasingEntry->fReserved = FALSE;
+ pPhasingEntry->byEntryOpenCnt++;
+
+ /* Decrement the number of phasing TSSTs opened. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberPhasingTssts--;
+
+ /*=============================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReservePhasingEntry
+
+Description: Reserves a phasing TSST 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_pusPhasingIndex Resulting index reserved in the phasing TSST list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReservePhasingEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusPhasingIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pPhasingAlloc;
+ UINT32 ulResult;
+ UINT32 ulPhasingIndex;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_PHASING_TSST_ALLOC_PNT( pSharedInfo, pPhasingAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pPhasingAlloc, &ulPhasingIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_PHASING_TSST_ALL_ENTRIES_ARE_OPENED;
+ else
+ return cOCT6100_ERR_FATAL_3A;
+ }
+
+ *f_pusPhasingIndex = (UINT16)( ulPhasingIndex & 0xFFFF );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleasePhasingEntry
+
+Description: Releases the specified phasing TSST 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_usPhasingIndex Index reserved in the phasing TSST API list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleasePhasingEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usPhasingIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pPhasingAlloc;
+ UINT32 ulResult;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_PHASING_TSST_ALLOC_PNT( pSharedInfo, pPhasingAlloc )
+
+ ulResult = OctapiLlmAllocDealloc( pPhasingAlloc, f_usPhasingIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ return cOCT6100_ERR_FATAL_3B;
+ }
+
+ return cOCT6100_ERR_OK;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_playout_buf.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_playout_buf.c
new file mode 100644
index 0000000..c815095
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_playout_buf.c
@@ -0,0 +1,3275 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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 *****************************/
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100BufferPlayoutLoad
+
+Description: This function loads a playout buffer into 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_pBufferLoad Pointer to buffer playout load structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutLoadDef(
+ tPOCT6100_BUFFER_LOAD f_pBufferLoad )
+{
+ f_pBufferLoad->pbyBufferPattern = NULL;
+ f_pBufferLoad->ulBufferSize = 128;
+ f_pBufferLoad->ulBufferPcmLaw = cOCT6100_PCM_U_LAW;
+
+ f_pBufferLoad->pulBufferIndex = NULL;
+ f_pBufferLoad->pulPlayoutFreeMemSize = NULL;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100BufferPlayoutLoad(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_LOAD f_pBufferLoad )
+{
+ 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 = Oct6100BufferLoadSer( f_pApiInstance, f_pBufferLoad, TRUE, cOCT6100_INVALID_INDEX );
+ }
+ 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: Oct6100BufferPlayoutLoadBlockInit
+
+Description: This function allows the user to initialize loading a buffer
+ into external memory using blocks.
+
+-------------------------------------------------------------------------------
+| 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_pBufferLoadBlockInit Pointer to buffer playout load block init structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutLoadBlockInitDef(
+ tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit )
+{
+ f_pBufferLoadBlockInit->ulBufferSize = 128;
+ f_pBufferLoadBlockInit->ulBufferPcmLaw = cOCT6100_PCM_U_LAW;
+
+ f_pBufferLoadBlockInit->pulBufferIndex = NULL;
+ f_pBufferLoadBlockInit->pulPlayoutFreeMemSize = NULL;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100BufferPlayoutLoadBlockInit(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit )
+{
+ 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 = Oct6100BufferLoadBlockInitSer( f_pApiInstance, f_pBufferLoadBlockInit );
+ }
+ 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: Oct6100BufferPlayoutLoadBlock
+
+Description: This function allows the user to load a buffer block into
+ 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_pBufferLoadBlock Pointer to buffer playout load block structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutLoadBlockDef(
+ tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock )
+{
+ f_pBufferLoadBlock->ulBufferIndex = cOCT6100_INVALID_VALUE;
+ f_pBufferLoadBlock->ulBlockLength = cOCT6100_INVALID_VALUE;
+ f_pBufferLoadBlock->ulBlockOffset = cOCT6100_INVALID_VALUE;
+
+ f_pBufferLoadBlock->pbyBufferPattern = NULL;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100BufferPlayoutLoadBlock(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock )
+{
+ 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 = Oct6100BufferLoadBlockSer( f_pApiInstance, f_pBufferLoadBlock );
+ }
+ 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: Oct6100BufferPlayoutUnload
+
+Description: This function unloads a playout buffer from 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_pBufferUnload Pointer to buffer playout unload structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutUnloadDef(
+ tPOCT6100_BUFFER_UNLOAD f_pBufferUnload )
+{
+ f_pBufferUnload->ulBufferIndex = cOCT6100_INVALID_VALUE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100BufferPlayoutUnload(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_UNLOAD f_pBufferUnload )
+{
+ 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 = Oct6100BufferUnloadSer( f_pApiInstance, f_pBufferUnload, TRUE );
+ }
+ 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: Oct6100BufferPlayoutAdd
+
+Description: This function adds a buffer to a port's playout list on the
+ selected 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_pBufferPlayoutAdd Pointer to buffer playout add structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutAddDef(
+ tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd )
+{
+ f_pBufferPlayoutAdd->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pBufferPlayoutAdd->ulBufferIndex = cOCT6100_INVALID_VALUE;
+
+ f_pBufferPlayoutAdd->ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
+ f_pBufferPlayoutAdd->ulMixingMode = cOCT6100_MIXING_MINUS_6_DB;
+ f_pBufferPlayoutAdd->lGainDb = 0;
+
+ f_pBufferPlayoutAdd->fRepeat = FALSE;
+ f_pBufferPlayoutAdd->ulRepeatCount = cOCT6100_REPEAT_INFINITELY;
+
+ f_pBufferPlayoutAdd->ulDuration = cOCT6100_INVALID_VALUE;
+
+ f_pBufferPlayoutAdd->ulBufferLength = cOCT6100_AUTO_SELECT;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100BufferPlayoutAdd(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd )
+{
+ 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 = Oct6100BufferPlayoutAddSer( f_pApiInstance, f_pBufferPlayoutAdd );
+ }
+ 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: Oct6100BufferPlayoutStart
+
+Description: This function enables playout of the specified buffer on the
+ requested 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_pBufferPlayoutStart Pointer to buffer playout start structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutStartDef(
+ tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart )
+{
+ f_pBufferPlayoutStart->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pBufferPlayoutStart->ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
+ f_pBufferPlayoutStart->fNotifyOnPlayoutStop = FALSE;
+ f_pBufferPlayoutStart->ulUserEventId = cOCT6100_INVALID_VALUE;
+ f_pBufferPlayoutStart->fAllowStartWhileActive = FALSE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100BufferPlayoutStart(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart )
+{
+ 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 = Oct6100BufferPlayoutStartSer( f_pApiInstance, f_pBufferPlayoutStart, cOCT6100_BUFFER_PLAYOUT_EVENT_STOP );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+UINT32 Oct6100BufferPlayoutStop(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop )
+{
+ 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 = Oct6100BufferPlayoutStopSer( f_pApiInstance, f_pBufferPlayoutStop );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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: Oct6100BufferLoadSer
+
+Description: Loads a buffer 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_pBufferLoad Pointer to buffer configuration structure. The handle
+ identifying the buffer in all future function calls is
+ returned in this structure.
+
+f_fReserveListStruct Flag indicating if a list structure should be reserved
+ or if the structure has been reserved before. If this
+ is set, the f_ulBufIndex variable must also be set.
+
+f_ulBufIndex If the f_fReserveListStruct flag is set, this index
+ will identify the buffer playout list structure
+ that must be used to load the specified buffer.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 ulBufferIndex;
+ UINT32 ulBufferBase;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the buffer for errors. */
+ ulResult = Oct6100ApiCheckBufferParams( f_pApiInstance, f_pBufferLoad, TRUE );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the buffer. */
+ ulResult = Oct6100ApiReserveBufferResources( f_pApiInstance, f_pBufferLoad, f_fReserveListStruct, f_ulBufIndex, &ulBufferIndex, &ulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write the buffer in external memory. */
+ ulResult = Oct6100ApiWriteBufferInMemory( f_pApiInstance, ulBufferBase, f_pBufferLoad->ulBufferSize, f_pBufferLoad->pbyBufferPattern );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the new buffer's entry in the buffer list. */
+ ulResult = Oct6100ApiUpdateBufferEntry( f_pApiInstance, f_pBufferLoad, ulBufferIndex, ulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100BufferLoadBlockInitSer
+
+Description: Reserve resources for loading a buffer into 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_pBufferLoadBlockInit Pointer to buffer configuration structure. The
+ handle identifying the buffer in all future
+ function calls is returned in this structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferLoadBlockInitSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_LOAD_BLOCK_INIT f_pBufferLoadBlockInit )
+{
+ UINT32 ulBufferIndex;
+ UINT32 ulBufferBase;
+ UINT32 ulResult;
+ tOCT6100_BUFFER_LOAD BufferLoad;
+
+ Oct6100BufferPlayoutLoadDef( &BufferLoad );
+
+ /* Not to replicate the code, we use the BufferLoad functions directly. */
+ BufferLoad.pulBufferIndex = f_pBufferLoadBlockInit->pulBufferIndex;
+ BufferLoad.pulPlayoutFreeMemSize = f_pBufferLoadBlockInit->pulPlayoutFreeMemSize;
+ BufferLoad.ulBufferPcmLaw = f_pBufferLoadBlockInit->ulBufferPcmLaw;
+ BufferLoad.ulBufferSize = f_pBufferLoadBlockInit->ulBufferSize;
+ BufferLoad.pbyBufferPattern = NULL; /* Must not check this for now */
+
+ /* Check the user's configuration of the buffer for errors, but do */
+ /* not check if the buffer pointer is NULL. It is NULL for sure! */
+ ulResult = Oct6100ApiCheckBufferParams( f_pApiInstance, &BufferLoad, FALSE );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the buffer. */
+ ulResult = Oct6100ApiReserveBufferResources( f_pApiInstance, &BufferLoad, TRUE, cOCT6100_INVALID_INDEX, &ulBufferIndex, &ulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the new buffer's entry in the buffer list. */
+ ulResult = Oct6100ApiUpdateBufferEntry( f_pApiInstance, &BufferLoad, ulBufferIndex, ulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100BufferLoadBlockSer
+
+Description: Loads a buffer in external memory using blocks.
+
+-------------------------------------------------------------------------------
+| 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_pBufferLoadBlock Pointer to buffer block to be loaded into external
+ memory descriptor.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferLoadBlockSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock )
+{
+ UINT32 ulBufferBase;
+ UINT32 ulResult;
+
+ /* Check the user's configuration for errors. */
+ ulResult = Oct6100ApiCheckBufferLoadBlockParams( f_pApiInstance, f_pBufferLoadBlock, &ulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write the buffer in external memory at the appropriate offset - must do some pointer arithmetic. */
+ ulResult = Oct6100ApiWriteBufferInMemory( f_pApiInstance, ulBufferBase + f_pBufferLoadBlock->ulBlockOffset,
+ f_pBufferLoadBlock->ulBlockLength, f_pBufferLoadBlock->pbyBufferPattern + f_pBufferLoadBlock->ulBlockOffset );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBufferParams
+
+Description: Checks the user's buffer playout load 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_pBufferLoad Pointer to buffer configuration structure.
+f_fCheckBufferPtr Check if the buffer pointer is NULL or not.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBufferParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad,
+ IN BOOL f_fCheckBufferPtr )
+{
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
+
+ if ( f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayout == FALSE )
+ return cOCT6100_ERR_NOT_SUPPORTED_BUFFER_PLAYOUT;
+
+ if ( f_pBufferLoad->pulBufferIndex == NULL )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
+
+ if( f_fCheckBufferPtr )
+ {
+ if ( f_pBufferLoad->pbyBufferPattern == NULL )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_PATTERN;
+ }
+
+ if ( f_pBufferLoad->ulBufferSize < cOCT6100_MINIMUM_BUFFER_SIZE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_TOO_SMALL;
+
+ if ( ( f_pBufferLoad->ulBufferSize % cOCT6100_BUFFER_SIZE_GRANULARITY ) != 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
+
+ if ( f_pBufferLoad->ulBufferPcmLaw != cOCT6100_PCM_U_LAW &&
+ f_pBufferLoad->ulBufferPcmLaw != cOCT6100_PCM_A_LAW )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_PCM_LAW;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckBufferLoadBlockParams
+
+Description: Checks the user's buffer playout load block 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_pBufferLoadBlock Pointer to buffer block descriptor.
+f_pulBufferBase Pointer to the base address of the buffer in external
+ memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckBufferLoadBlockParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_BUFFER_LOAD_BLOCK f_pBufferLoadBlock,
+ OUT PUINT32 f_pulBufferBase )
+{
+ /* Check for errors. */
+ tPOCT6100_API_BUFFER pBufEntry;
+
+ if ( f_pBufferLoadBlock->ulBufferIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
+
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, f_pBufferLoadBlock->ulBufferIndex )
+
+ if ( pBufEntry->fReserved != TRUE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_OPEN;
+
+ if ( ( f_pBufferLoadBlock->ulBlockLength % 2 ) != 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BLOCK_LENGTH_INVALID;
+
+ if ( ( f_pBufferLoadBlock->ulBlockOffset % 2 ) != 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BLOCK_OFFSET_INVALID;
+
+ if ( f_pBufferLoadBlock->pbyBufferPattern == NULL )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_PATTERN;
+
+ /* Check boundaries */
+ if ( ( f_pBufferLoadBlock->ulBlockLength + f_pBufferLoadBlock->ulBlockOffset ) > pBufEntry->ulBufferSize )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
+
+ *f_pulBufferBase = pBufEntry->ulBufferBase;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveBufferResources
+
+Description: Reserves all resources needed for the new 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_pBufferLoad Pointer to buffer configuration structure.
+
+f_fReserveListStruct Flag indicating if a list structure should be reserved
+ or if the structure has been reserved before.
+
+f_ulBufIndex If the f_fReserveListStruct flag is set, this index
+ will identifying the buffer playout list structure
+ that must be used to load the specified buffer.
+
+f_pulBufferIndex Allocated entry in buffer playout list.
+
+f_pulBufferBase Allocated external memory block for the buffer.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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_pulBufferIndex,
+ OUT PUINT32 f_pulBufferBase )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT32 ulResult = cOCT6100_ERR_OK;
+ UINT32 ulTempVar;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Reserve an entry in the buffer list. */
+ if ( f_fReserveListStruct == TRUE )
+ {
+ ulResult = Oct6100ApiReserveBufPlayoutListEntry( f_pApiInstance, f_pulBufferIndex );
+ }
+ else
+ {
+ *f_pulBufferIndex = f_ulBufIndex;
+ }
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Find a free block to store the buffer. */
+ ulResult = Oct6100ApiReserveBufferPlayoutMemory( f_pApiInstance, f_pBufferLoad->ulBufferSize, f_pulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ /* Release the list entry. */
+ if ( f_fReserveListStruct == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseBufPlayoutListEntry( f_pApiInstance, *f_pulBufferIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+ }
+ }
+
+ return ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteBufferInMemory
+
+Description: Writes the buffer 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_ulBufferBase Allocated external memory address for the buffer.
+
+f_ulBufferLength Length in bytes of the buffer to be copied in memory.
+
+f_pbyBuffer Address where the buffer should be copied from.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiWriteBufferInMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulBufferBase,
+ IN UINT32 f_ulBufferLength,
+ IN PUINT8 f_pbyBuffer )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_BURST_PARAMS BurstParams;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+ UINT32 ulNumWrites;
+ PUINT16 pusSuperArray;
+ PUINT8 pbyPlayoutBuffer;
+ UINT32 ulByteCount = 0;
+ 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;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Write the buffer in external memory. */
+ ulNumWrites = f_ulBufferLength / 2;
+
+ BurstParams.ulWriteAddress = f_ulBufferBase;
+ BurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
+
+ pusSuperArray = pSharedInfo->MiscVars.ausSuperArray;
+ pbyPlayoutBuffer = f_pbyBuffer;
+
+ /* Check if we can maximize the bandwidth through the CPU port. */
+ if ( f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels == 0 )
+ {
+ WriteParams.ulWriteAddress = 0x234;
+ WriteParams.usWriteData = 0x08ff;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ 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 )(( pbyPlayoutBuffer [ ulByteCount++ ]) << 8);
+ pusSuperArray[ i ] |= ( UINT16 )pbyPlayoutBuffer [ ulByteCount++ ];
+ }
+
+ mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ BurstParams.ulWriteAddress += 2 * BurstParams.ulWriteLength;
+ ulNumWrites -= BurstParams.ulWriteLength;
+
+ }
+
+ /* Make sure we revert back the changes made to the CPU bandwidth register. */
+ if ( f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels == 0 )
+ {
+ WriteParams.ulWriteAddress = 0x234;
+ WriteParams.usWriteData = 0x0804;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateBufferEntry
+
+Description: Updates the new buffer's entry in the buffer playout 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_pBufferLoad Pointer to buffer configuration structure.
+f_ulBufferIndex Allocated entry in buffer playout list.
+f_ulBufferBase Allocated external memory block for the buffer.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiUpdateBufferEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_LOAD f_pBufferLoad,
+ IN UINT32 f_ulBufferIndex,
+ IN UINT32 f_ulBufferBase )
+{
+ tPOCT6100_API_BUFFER pBufEntry;
+ UINT32 ulBufferSize = f_pBufferLoad->ulBufferSize;
+
+ /* Obtain a pointer to the new buffer's list entry. */
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, f_ulBufferIndex )
+
+ /* Copy the buffer's configuration and allocated resources. */
+ pBufEntry->ulBufferSize = f_pBufferLoad->ulBufferSize;
+ pBufEntry->byBufferPcmLaw = (UINT8)( f_pBufferLoad->ulBufferPcmLaw & 0xFF );
+ pBufEntry->ulBufferBase = f_ulBufferBase;
+
+ /* Update the entries flags. */
+ pBufEntry->usDependencyCnt = 0;
+
+ /* Mark the buffer as opened. */
+ pBufEntry->fReserved = TRUE;
+
+ /* Increment the number of buffer loaded into the chip.*/
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberPlayoutBuffers++;
+
+ /* Refresh the amount of memory used by buffer playout. */
+
+ /* Reserved size is divisible by 64. */
+ if ( ulBufferSize % 64 )
+ ulBufferSize = ulBufferSize + ( 64 - ( ulBufferSize % 64 ) );
+ f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed += ulBufferSize;
+
+ /* Return the buffer index to the user. */
+ *f_pBufferLoad->pulBufferIndex = f_ulBufferIndex;
+
+ /* Return the amount of free memory left in the chip. */
+ /* Note that this value does not give the "fragmentation" state of the available memory. */
+ /* This value only gives the amount of free memory */
+ if( f_pBufferLoad->pulPlayoutFreeMemSize )
+ *f_pBufferLoad->pulPlayoutFreeMemSize = ( f_pApiInstance->pSharedInfo->MiscVars.ulTotalMemSize - ( f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress - cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) ) - ( f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100BufferUnloadSer
+
+Description: Unloads a buffer from 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_pBufferUnload Pointer to buffer unload structure.
+f_fReleaseListStruct Whether to release the buffer playout list structure
+ or not.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferUnloadSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_UNLOAD f_pBufferUnload,
+ IN BOOL f_fReleaseListStruct )
+{
+ UINT32 ulBufferIndex;
+ UINT32 ulBufferBase;
+ UINT32 ulResult;
+
+ /* Verify that all the parameters given match the state of the API. */
+ ulResult = Oct6100ApiAssertBufferParams( f_pApiInstance, f_pBufferUnload, &ulBufferIndex, &ulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the unloaded buffer. */
+ ulResult = Oct6100ApiReleaseBufferResources( f_pApiInstance, ulBufferIndex, ulBufferBase, f_fReleaseListStruct );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiAssertBufferParams
+
+Description: Checks the buffer playout unload 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_pBufferUnload Pointer to buffer unload structure.
+f_pulBufferIndex Pointer to the index of the buffer in the API's buffers list.
+f_pulBufferBase Pointer to the base address of the buffer in external memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiAssertBufferParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_BUFFER_UNLOAD f_pBufferUnload,
+ OUT PUINT32 f_pulBufferIndex,
+ OUT PUINT32 f_pulBufferBase )
+{
+ tPOCT6100_API_BUFFER pBufEntry;
+
+ *f_pulBufferIndex = f_pBufferUnload->ulBufferIndex;
+
+ if ( *f_pulBufferIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
+
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, *f_pulBufferIndex )
+
+ /* Check for errors. */
+ if ( pBufEntry->fReserved != TRUE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_OPEN;
+ if ( pBufEntry->usDependencyCnt != 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ACTIVE_DEPENDENCIES;
+
+ /* Return all info needed to invalidate buffer. */
+ *f_pulBufferBase = pBufEntry->ulBufferBase;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseBufferResources
+
+Description: Release resources needed by the 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_ulBufferIndex Allocated entry in buffer playout list.
+f_ulBufferBase Allocated external memory block for the buffer.
+f_fReleaseListStruct Free the list structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseBufferResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulBufferIndex,
+ IN UINT32 f_ulBufferBase,
+ IN BOOL f_fReleaseListStruct )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_BUFFER pBufEntry;
+ UINT32 ulResult;
+ UINT32 ulBufferSize;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Free the external memory reserved for the buffer. */
+ ulResult = Oct6100ApiReleaseBufferPlayoutMemory( f_pApiInstance, f_ulBufferBase );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_3E;
+
+ /* Release the entry from the buffer list. */
+ if ( f_fReleaseListStruct == TRUE )
+ ulResult = Oct6100ApiReleaseBufPlayoutListEntry( f_pApiInstance, f_ulBufferIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufEntry, f_ulBufferIndex );
+
+ /* Save buffer size before releasing that entry, will be needed to calculate the amount of */
+ /* free memory left for the user. */
+ ulBufferSize = pBufEntry->ulBufferSize;
+
+ /* Flag the buffer entry as free. */
+ pBufEntry->fReserved = FALSE;
+
+ /* Decrement the number of buffer loaded into the chip. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberPlayoutBuffers--;
+
+ /* Refresh the amount of memory used by buffer playout. */
+ /* Reserved size is divisible by 64. */
+ if ( ulBufferSize % 64 )
+ ulBufferSize = ulBufferSize + ( 64 - ( ulBufferSize % 64 ) );
+ f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed -= ulBufferSize;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100BufferPlayoutAddSer
+
+Description: This function adds a buffer to a channel buffer 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_pBufferPlayoutAdd Pointer to buffer playout add structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutAddSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd )
+{
+ UINT32 ulBufferIndex;
+ UINT32 ulChannelIndex;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the buffer for errors. */
+ ulResult = Oct6100ApiCheckPlayoutAddParams( f_pApiInstance, f_pBufferPlayoutAdd, &ulChannelIndex, &ulBufferIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write to all resources needed to activate buffer playout. */
+ ulResult = Oct6100ApiWriteBufferAddStructs( f_pApiInstance, f_pBufferPlayoutAdd, ulChannelIndex, ulBufferIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckPlayoutAddParams
+
+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_pBufferPlayoutAdd Pointer to buffer playout add structure.
+f_pulChannelIndex Pointer to the channel index of the selected channel.
+f_pulBufferIndex Pointer to the buffer index within the API's buffer list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckPlayoutAddParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd,
+ OUT PUINT32 f_pulChannelIndex,
+ OUT PUINT32 f_pulBufferIndex )
+{
+ tPOCT6100_API_BUFFER pBufferEntry;
+ tPOCT6100_API_CHANNEL pEchoChannel;
+ UINT32 ulEntryOpenCnt;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
+
+ if ( f_pBufferPlayoutAdd->ulChannelHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
+
+ if ( f_pBufferPlayoutAdd->ulPlayoutPort != cOCT6100_CHANNEL_PORT_ROUT &&
+ f_pBufferPlayoutAdd->ulPlayoutPort != cOCT6100_CHANNEL_PORT_SOUT )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT;
+
+ if ( f_pBufferPlayoutAdd->fRepeat != TRUE && f_pBufferPlayoutAdd->fRepeat != FALSE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_REPEAT;
+
+ if ( f_pBufferPlayoutAdd->fRepeat == TRUE )
+ {
+ if ( f_pBufferPlayoutAdd->ulRepeatCount != cOCT6100_REPEAT_INFINITELY )
+ {
+ if ( f_pBufferPlayoutAdd->ulRepeatCount == 0x0
+ || f_pBufferPlayoutAdd->ulRepeatCount > cOCT6100_REPEAT_MAX)
+ {
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_REPEAT_COUNT;
+ }
+ }
+ }
+
+ if ( f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_0_DB &&
+ f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_MINUS_6_DB &&
+ f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_MINUS_12_DB &&
+ f_pBufferPlayoutAdd->ulMixingMode != cOCT6100_MIXING_MUTE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_MIXING;
+
+ if ( ( f_pBufferPlayoutAdd->lGainDb < -24 )
+ || ( f_pBufferPlayoutAdd->lGainDb > 24 ) )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_GAIN_DB;
+
+ /*=====================================================================*/
+ /* Check the channel handle. */
+
+ if ( (f_pBufferPlayoutAdd->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
+
+ *f_pulChannelIndex = f_pBufferPlayoutAdd->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_pBufferPlayoutAdd->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;
+
+ /* Check if repeat flag has been used for this port. */
+ if ( ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) && ( pEchoChannel->fRinBufPlayoutRepeatUsed == TRUE ) )
+ || ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pEchoChannel->fSoutBufPlayoutRepeatUsed == TRUE ) ) )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_REPEAT_USED;
+
+ /*=====================================================================*/
+
+ /*=====================================================================*/
+ /* Check the buffer information. */
+
+ *f_pulBufferIndex = f_pBufferPlayoutAdd->ulBufferIndex;
+ if ( *f_pulBufferIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_INDEX;
+
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufferEntry, *f_pulBufferIndex )
+
+ if ( pBufferEntry->fReserved != TRUE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_OPEN;
+
+ /* Check if the play length is not larger then the currently uploaded buffer. */
+ if ( ( f_pBufferPlayoutAdd->ulBufferLength > pBufferEntry->ulBufferSize ) &&
+ ( f_pBufferPlayoutAdd->ulBufferLength != cOCT6100_AUTO_SELECT ) )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
+
+ if( f_pBufferPlayoutAdd->ulBufferLength != cOCT6100_AUTO_SELECT )
+ {
+ if ( f_pBufferPlayoutAdd->ulBufferLength < cOCT6100_MINIMUM_BUFFER_SIZE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_TOO_SMALL;
+
+ if ( ( f_pBufferPlayoutAdd->ulBufferLength % cOCT6100_BUFFER_SIZE_GRANULARITY ) != 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_BUF_SIZE;
+ }
+
+ /*=====================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteBufferAddStructs
+
+Description: Write the buffer playout event in the channel's port playout
+ circular 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_pBufferPlayoutAdd Pointer to buffer playout add structure.
+f_ulChannelIndex Index of the channel on which the buffer is to be added.
+f_ulBufferIndex Index of the buffer structure within the API's buffer list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiWriteBufferAddStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_BUFFER_PLAYOUT_ADD f_pBufferPlayoutAdd,
+ IN UINT32 f_ulChannelIndex,
+ IN UINT32 f_ulBufferIndex )
+{
+ tPOCT6100_API_BUFFER pBufferEntry;
+ tPOCT6100_API_CHANNEL pEchoChannel;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_READ_PARAMS ReadParams;
+ UINT32 ulResult;
+ UINT32 ulTempData;
+ UINT32 ulEventBuffer;
+
+ UINT32 ulReadPtrBytesOfst;
+ UINT32 ulReadPtrBitOfst;
+ UINT32 ulReadPtrFieldSize;
+
+ UINT32 ulWritePtrBytesOfst;
+ UINT32 ulWritePtrBitOfst;
+ UINT32 ulWritePtrFieldSize;
+
+ UINT32 ulWritePtr;
+ UINT32 ulReadPtr;
+
+ UINT32 ulPlayoutBaseAddress;
+ UINT32 ulAddress;
+ UINT32 ulEventIndex;
+ UINT32 ulMask;
+
+ UINT32 ulRepeatCount = 0;
+ BOOL fRepeatCountSet = FALSE;
+ UINT32 ulDurationModulo = 0;
+ UINT32 ulEventsToCreate = 1;
+ UINT32 ulBufferDurationMs;
+
+ UINT32 ulBufferLength;
+ UINT16 usTempData = 0;
+
+ UINT16 usReadData;
+ UINT32 ulChipWritePtr;
+ UINT32 ulReadData;
+ UINT32 ulLoopCnt = 0;
+ BOOL fStillPlaying = TRUE;
+ BOOL fCheckHardStop = FALSE;
+ BOOL fOldBufferPlayoutVersion = FALSE;
+
+ UINT32 aulWaitTime[ 2 ];
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufferEntry, f_ulBufferIndex );
+
+ /* Select the buffer of interest. */
+ if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
+ {
+ ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
+ ulWritePtr = pEchoChannel->ulRinBufWritePtr;
+
+ 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 /* f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
+ {
+ ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
+ ulWritePtr = pEchoChannel->ulSoutBufWritePtr;
+
+ 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;
+ }
+
+ /*=======================================================================*/
+ /* Calculate the repeat count. */
+
+ /* The buffer length is either the total buffer size or the value specified by the user */
+ if ( f_pBufferPlayoutAdd->ulBufferLength == cOCT6100_AUTO_SELECT )
+ {
+ ulBufferLength = pBufferEntry->ulBufferSize;
+ }
+ else
+ {
+ ulBufferLength = f_pBufferPlayoutAdd->ulBufferLength;
+ }
+
+ if ( f_pBufferPlayoutAdd->ulDuration != cOCT6100_INVALID_VALUE )
+ {
+ /* With duration and buffer length, we can find the number of times we must repeat playing this buffer. */
+ ulBufferDurationMs = ulBufferLength / cOCT6100_SAMPLES_PER_MS;
+ ulRepeatCount = f_pBufferPlayoutAdd->ulDuration / ulBufferDurationMs;
+ fRepeatCountSet = TRUE;
+
+ /* Check if buffer is larger then asked duration. */
+ if ( ulRepeatCount != 0x0 )
+ {
+ /* We might have to create more then 1 event to accomodate for the repeat-max limit. */
+ ulEventsToCreate = ( ulRepeatCount / cOCT6100_REPEAT_MAX ) + 1;
+ }
+ else
+ {
+ /* No repeat event. Maybe only the duration modulo! */
+ ulEventsToCreate = 0x0;
+ }
+
+ /* Check if must create a second event for a buffer that cannot be played completely. */
+ ulDurationModulo = f_pBufferPlayoutAdd->ulDuration % ulBufferDurationMs;
+ if ( ulDurationModulo != 0x0 )
+ {
+ ulDurationModulo *= cOCT6100_SAMPLES_PER_MS;
+ if ( ulDurationModulo / cOCT6100_BUFFER_SIZE_GRANULARITY )
+ {
+ /* Round the modulo to be on a buffer size granularity. */
+ /* This will round down. */
+ ulDurationModulo = ( ulDurationModulo / cOCT6100_BUFFER_SIZE_GRANULARITY ) * cOCT6100_BUFFER_SIZE_GRANULARITY;
+
+ /* If the event about to be created is smaller then the minimum buffer size, */
+ /* round up to the minimum required by the hardware. */
+ if ( ulDurationModulo < cOCT6100_MINIMUM_BUFFER_SIZE )
+ ulDurationModulo = cOCT6100_MINIMUM_BUFFER_SIZE;
+ ulEventsToCreate++;
+ }
+ else
+ {
+ /* The modulo is too small to be played. Skip. */
+ ulDurationModulo = 0;
+ }
+ }
+ }
+ else if ( f_pBufferPlayoutAdd->fRepeat == TRUE
+ && f_pBufferPlayoutAdd->ulRepeatCount != cOCT6100_REPEAT_INFINITELY )
+ {
+ /* The repeat count is set directly from the user. */
+ ulRepeatCount = f_pBufferPlayoutAdd->ulRepeatCount;
+ fRepeatCountSet = TRUE;
+ }
+
+ /*=======================================================================*/
+
+ /* Set the playout feature base address. */
+ ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_ulChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
+
+ /* Read the read pointer. */
+ ulAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
+
+ /* Must read in memory directly since this value is changed by hardware. */
+ ulResult = Oct6100ApiReadDword( f_pApiInstance, ulAddress, &ulTempData );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
+
+ /* Store the read pointer. */
+ ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
+
+ /* Compare the pointers... Are they different? If so, there is something already in the list. */
+ if ( ulReadPtr != ulWritePtr )
+ {
+ /* Check if there is enough room for the playout events. */
+ if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
+ && ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
+ {
+ /* 127 or 31 events image. */
+ if ( (UINT8)( ( ulWritePtr - ulReadPtr ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 ) ) >= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - (UINT8)ulEventsToCreate ) )
+ fCheckHardStop = TRUE;
+ }
+ else
+ {
+ /* Old 31 events image. */
+ if ( ( ( ulWritePtr - ulReadPtr ) & 0x1F ) >= ( 0x20 - ulEventsToCreate ) )
+ fCheckHardStop = TRUE;
+
+ fOldBufferPlayoutVersion = TRUE;
+ }
+
+ if ( fCheckHardStop == TRUE )
+ {
+ /* Ok. From what was read, the list is full. But we might still have a chance if the hard-stop */
+ /* version was used. In this case, some of the buffers in the list might */
+ /* become free in a couple of milliseconds, so try to wait for this. */
+
+ if ( ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) && ( pEchoChannel->fRinHardStop == TRUE ) )
+ || ( ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pEchoChannel->fSoutHardStop == TRUE ) ) )
+ {
+ /* Read the 'chip' write pointer in the hardware. */
+ ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+ ReadParams.pusReadData = &usReadData;
+ ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
+
+ /* 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. */
+ ulChipWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst;
+
+ /* Optimize this access by only reading the word we are interested in. */
+ if ( ulReadPtrBitOfst < 16 )
+ ReadParams.ulReadAddress += 2;
+
+ while( fStillPlaying == TRUE )
+ {
+ /* Read the read pointer until equals to the write pointer. */
+ 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 == ulChipWritePtr )
+ break;
+
+ ulLoopCnt++;
+ if ( ulLoopCnt > cOCT6100_MAX_LOOP )
+ {
+ return cOCT6100_ERR_FATAL_E7;
+ }
+
+ aulWaitTime[ 0 ] = 100;
+ aulWaitTime[ 1 ] = 0;
+ ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+
+ /* Clear hard-stop flag. */
+ if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
+ {
+ /* No hard stop for now. */
+ pEchoChannel->fRinHardStop = FALSE;
+ }
+ else /* if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
+ {
+ /* No hard stop for now. */
+ pEchoChannel->fSoutHardStop = FALSE;
+ }
+
+ /* Now check again if the event can be added... */
+ if ( fOldBufferPlayoutVersion == FALSE )
+ {
+ if ( (UINT8)( ( ulWritePtr - ulReadPtr ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 ) ) >= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - (UINT8)ulEventsToCreate ) )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL;
+ }
+ else /* if ( fOldBufferPlayoutVersion == TRUE ) */
+ {
+ /* Old 31 events image. */
+ if ( ( ( ulWritePtr - ulReadPtr ) & 0x1F ) >= ( 0x20 - ulEventsToCreate ) )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL;
+ }
+
+ /* Good, at least another buffer can be added! Add the buffer to the list. */
+ }
+ else
+ {
+ /* Well the list is full! */
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ADD_EVENT_BUF_FULL;
+ }
+ }
+ }
+
+ /*=======================================================================*/
+ /* Write the events. */
+
+ for ( ulEventIndex = 0; ulEventIndex < ulEventsToCreate; ulEventIndex ++ )
+ {
+ /* 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_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * (ulWritePtr & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 )));
+ }
+ else
+ {
+ /* Old 31 events image. */
+ ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + (f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * (ulWritePtr & 0x1F));
+ }
+
+ /* EVENT BASE + 0 */
+ /* Make sure the xIS and xHS bits are cleared. */
+ ulTempData = 0;
+
+ /* Set the repeat count. */
+ if ( fRepeatCountSet == TRUE )
+ {
+ if ( ( ulRepeatCount != 0x0 ) && ( ulRepeatCount <= cOCT6100_REPEAT_MAX ) )
+ {
+ /* Use repeat count directly. */
+ ulTempData |= ulRepeatCount;
+
+ /* Will be used later when creating the duration modulo event. */
+ ulRepeatCount = 0;
+ }
+ else if ( ulRepeatCount != 0x0 )
+ {
+ /* Get ready for next event. */
+ ulRepeatCount -= cOCT6100_REPEAT_MAX;
+
+ /* Set maximum for this event. */
+ ulTempData |= cOCT6100_REPEAT_MAX;
+ }
+ else
+ {
+ /* Duration modulo case. Nothing to set here. */
+ }
+ }
+ else /* if ( fRepeatCountSet != TRUE ) */
+ {
+ /* Repeat only once. */
+ ulTempData |= 0x1;
+ }
+
+ ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* EVENT BASE + 4 */
+ /* Set the buffer base address and playout configuration. */
+ ulAddress += 4;
+ ulTempData = pBufferEntry->ulBufferBase & 0x07FFFFFF;
+
+ /* Set play indefinitely or loop N times. */
+ if ( ( fRepeatCountSet == FALSE ) && ( f_pBufferPlayoutAdd->fRepeat == TRUE ) )
+ {
+ /* Repeat indefinitely. */
+ ulTempData |= 0x1 << cOCT6100_PLAYOUT_EVENT_REPEAT_OFFSET;
+
+ if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
+ pEchoChannel->fRinBufPlayoutRepeatUsed = TRUE;
+ else /* if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
+ pEchoChannel->fSoutBufPlayoutRepeatUsed = TRUE;
+ }
+
+ /* Use loop N times feature. */
+ ulTempData |= 0x1 << cOCT6100_PLAYOUT_EVENT_LOOP_TIMES_OFFSET;
+
+ /* Set the law.*/
+ ulTempData |= ( pBufferEntry->byBufferPcmLaw << cOCT6100_PLAYOUT_EVENT_LAW_OFFSET );
+
+ /* Set the mixing configuration.*/
+ ulTempData |= f_pBufferPlayoutAdd->ulMixingMode << cOCT6100_PLAYOUT_EVENT_MIX_OFFSET;
+
+ ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+
+ /* EVENT BASE + 8 */
+ /* Set the buffer size and playout gain. */
+ ulAddress += 4;
+
+ /* Check if we are setting the duration modulo. This would be the last event and this */
+ /* event is of a very specific size. */
+ if ( ( fRepeatCountSet == TRUE )
+ && ( ulEventIndex == ( ulEventsToCreate - 1 ) )
+ && ( ulDurationModulo != 0x0 ) )
+ {
+ /* The duration modulo variable contains all that is needed here. */
+ ulBufferLength = ulDurationModulo;
+ }
+ ulTempData = ulBufferLength;
+
+ /* Adjust playout gain. */
+ if ( f_pBufferPlayoutAdd->lGainDb != 0 )
+ {
+ /* Convert the dB value into OctFloat format. */
+ usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pBufferPlayoutAdd->lGainDb );
+ ulTempData |= ( usTempData & 0xFF00 ) << 16;
+ }
+ else
+ {
+ ulTempData |= cOCT6100_PLAYOUT_GAIN;
+ }
+
+ ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* EVENT BASE + 0xC */
+ ulAddress += 4;
+ ulTempData = ( ulBufferLength - 1 ) & 0xFFFFFFC0; /* Must be multiple of 64 bytes */
+
+ /* Adjust playout gain. */
+ if ( f_pBufferPlayoutAdd->lGainDb != 0 )
+ {
+ ulTempData |= ( usTempData & 0xFF ) << 24;
+ }
+
+ ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulAddress, ulTempData );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Next event. */
+ ulWritePtr++;
+ }
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Increment the write pointer to make it point to the next empty entry. */
+
+ if ( f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
+ {
+ pEchoChannel->ulRinBufWritePtr = ( pEchoChannel->ulRinBufWritePtr + ulEventsToCreate ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 );
+ /* Remember that a buffer was added on the rin port. */
+ pEchoChannel->fRinBufAdded = TRUE;
+ }
+ else /* f_pBufferPlayoutAdd->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
+ {
+ pEchoChannel->ulSoutBufWritePtr = ( pEchoChannel->ulSoutBufWritePtr + ulEventsToCreate ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 );
+ /* Remember that a buffer was added on the sout port. */
+ pEchoChannel->fSoutBufAdded = TRUE;
+ }
+
+ /*=======================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100BufferPlayoutStartSer
+
+Description: Starts 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_pBufferPlayoutStart Pointer to buffer playout start structure.
+
+f_ulPlayoutStopEventType Playout stop event type to be generated if required.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100BufferPlayoutStartSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_PLAYOUT_START f_pBufferPlayoutStart,
+ IN UINT32 f_ulPlayoutStopEventType )
+{
+ UINT32 ulBufferIndex;
+ UINT32 ulChannelIndex;
+ BOOL fNotifyOnPlayoutStop;
+ UINT32 ulUserEventId;
+ BOOL fAddToCurrentlyPlayingList;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the buffer for errors. */
+ ulResult = Oct6100ApiCheckPlayoutStartParams( f_pApiInstance, f_pBufferPlayoutStart, &ulChannelIndex, &ulBufferIndex, &fNotifyOnPlayoutStop, &ulUserEventId, &fAddToCurrentlyPlayingList );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write to all resources needed to activate buffer playout. */
+ ulResult = Oct6100ApiWriteChanPlayoutStructs( f_pApiInstance, f_pBufferPlayoutStart, ulChannelIndex, ulBufferIndex, fNotifyOnPlayoutStop, ulUserEventId, fAddToCurrentlyPlayingList, f_ulPlayoutStopEventType );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckPlayoutStartParams
+
+Description: Check the validity of the channel and buffer requested.
+ Check the validity of the flags 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_pBufferPlayoutStart Pointer to buffer playout start structure.
+f_pulChannelIndex Pointer to the channel index of the selected channel.
+f_pulBufferIndex Pointer to the buffer index within the API's buffer list.
+f_pfNotifyOnPlayoutStop Pointer to the notify on playout stop flag.
+f_pulUserEventId Pointer to the user event id specified.
+f_pfAllowStartIfActive Pointer to the add to currently playing list flag.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckPlayoutStartParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT 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 )
+{
+ tPOCT6100_API_CHANNEL pEchoChannel;
+ UINT32 ulEntryOpenCnt;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
+
+ if ( f_pBufferPlayoutStart->ulChannelHndl == cOCT6100_INVALID_HANDLE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
+
+ if ( f_pBufferPlayoutStart->ulPlayoutPort != cOCT6100_CHANNEL_PORT_ROUT &&
+ f_pBufferPlayoutStart->ulPlayoutPort != cOCT6100_CHANNEL_PORT_SOUT )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT;
+
+ if ( f_pBufferPlayoutStart->fNotifyOnPlayoutStop != FALSE
+ && f_pBufferPlayoutStart->fNotifyOnPlayoutStop != TRUE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_NOTIFY_ON_STOP;
+
+ if ( f_pBufferPlayoutStart->fAllowStartWhileActive != FALSE
+ && f_pBufferPlayoutStart->fAllowStartWhileActive != TRUE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ALLOW_ACTIVE;
+
+ /*=====================================================================*/
+ /* Check the channel handle. */
+
+ if ( (f_pBufferPlayoutStart->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
+
+ *f_pulChannelIndex = f_pBufferPlayoutStart->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_pBufferPlayoutStart->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;
+
+ /* The channel cannot be in POWER_DOWN or HT_FREEZE to start the playout. */
+ if ( ( pEchoChannel->byEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN )
+ || ( pEchoChannel->byEchoOperationMode == cOCT6100_ECHO_OP_MODE_HT_FREEZE ) )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ECHO_OP_MODE;
+
+ /* The channel's NLP must be enabled for playout to occur. */
+ if ( pEchoChannel->VqeConfig.fEnableNlp == FALSE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_NLP_DISABLED;
+
+ /*=====================================================================*/
+
+ /*=====================================================================*/
+ /* Check if the user activated the buffer playout events. */
+
+ if ( f_pBufferPlayoutStart->fNotifyOnPlayoutStop == TRUE
+ && f_pApiInstance->pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize == 0 )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_EVENT_DISABLED;
+
+ /*=====================================================================*/
+
+ /*=====================================================================*/
+ /* Check if there is actually a buffer added in the list. */
+
+ if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
+ {
+ if ( pEchoChannel->fRinBufAdded == FALSE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_LIST_EMPTY;
+ }
+ else /* if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
+ {
+ if ( pEchoChannel->fSoutBufAdded == FALSE )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_LIST_EMPTY;
+ }
+
+ /*=====================================================================*/
+
+ /* Return the requested information. */
+ *f_pfNotifyOnPlayoutStop = f_pBufferPlayoutStart->fNotifyOnPlayoutStop;
+ *f_pulUserEventId = f_pBufferPlayoutStart->ulUserEventId;
+ *f_pfAllowStartIfActive = f_pBufferPlayoutStart->fAllowStartWhileActive;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteChanPlayoutStructs
+
+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_pBufferPlayoutStart Pointer to buffer playout start structure.
+f_ulChannelIndex Index of the channel within the API's channel list.
+f_ulBufferIndex Index of the buffer within the API's buffer list.
+f_fNotifyOnPlayoutStop Flag for the notify on playout stop.
+f_ulUserEventId User event id passed to the user when a playout event is generated.
+f_fAllowStartIfActive Add to currently playing list flag.
+f_ulPlayoutStopEventType Playout stop event type to be generated if required.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_API_BUFFER pBufferEntry;
+ tPOCT6100_API_CHANNEL pEchoChannel;
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_READ_PARAMS ReadParams;
+
+ UINT32 ulResult;
+
+ UINT32 ulWritePtr;
+ UINT32 ulChipWritePtr;
+ PUINT32 pulSkipPtr;
+ UINT32 ulWritePtrBytesOfst;
+ UINT32 ulSkipPtrBytesOfst;
+ UINT32 ulWritePtrBitOfst;
+ UINT32 ulSkipPtrBitOfst;
+ UINT32 ulWritePtrFieldSize;
+ UINT32 ulSkipPtrFieldSize;
+
+ UINT32 ulIgnoreBytesOfst;
+ UINT32 ulIgnoreBitOfst;
+ UINT32 ulIgnoreFieldSize;
+
+ UINT32 ulHardSkipBytesOfst;
+ UINT32 ulHardSkipBitOfst;
+ UINT32 ulHardSkipFieldSize;
+
+ UINT32 ulReadPtrBytesOfst;
+ UINT32 ulReadPtrBitOfst;
+ UINT32 ulReadPtrFieldSize;
+
+ UINT32 ulPlayoutBaseAddress;
+ UINT32 ulAddress;
+ UINT32 ulTempData;
+ UINT32 ulMask;
+ UINT32 ulReadData;
+ UINT32 ulReadPtr;
+ UINT32 ulLoopCnt = 0;
+
+ UINT16 usReadData;
+
+ BOOL fBufferPlayoutStopDetected;
+ BOOL fWriteSkipPtr = FALSE;
+ BOOL fStillPlaying = TRUE;
+
+ UINT32 aulWaitTime[ 2 ];
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
+ mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBufferEntry, f_ulBufferIndex );
+
+ /* First off, check for buffer playout events, if requested for this channel/port. */
+ /* At the same time, if requested, check that the playout has stopped for this channel/port. */
+ if ( ( ( pEchoChannel->fRinBufPlaying == TRUE )
+ && ( ( pEchoChannel->fRinBufPlayoutNotifyOnStop == TRUE ) || ( f_fAllowStartIfActive == FALSE ) )
+ && ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) )
+ || ( ( ( pEchoChannel->fSoutBufPlaying == TRUE ) || ( f_fAllowStartIfActive == FALSE ) )
+ && ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == TRUE )
+ && ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) ) )
+ {
+ /* Buffer playout might still be going on for this channel/port. */
+ ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance,
+ f_ulChannelIndex,
+ f_pBufferPlayoutStart->ulPlayoutPort,
+ pEchoChannel->fRinBufPlayoutNotifyOnStop,
+ &fBufferPlayoutStopDetected );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Check if the user requested to only start if playout is over. Return an error if */
+ /* buffer playout is still going on on this channel/port. */
+ if ( ( f_fAllowStartIfActive == FALSE ) && ( fBufferPlayoutStopDetected == FALSE ) )
+ {
+ /* No go! User should wait for the current list to stop, or call the */
+ /* Oct6100BufferPlayoutStop function. */
+ return cOCT6100_ERR_BUFFER_PLAYOUT_STILL_ACTIVE;
+ }
+ }
+
+ /* Select the buffer of interest. */
+ if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
+ {
+ ulWritePtr = pEchoChannel->ulRinBufWritePtr;
+ pulSkipPtr = &pEchoChannel->ulRinBufSkipPtr;
+
+ ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
+ ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.usDwordOffset * 4;
+ ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.usDwordOffset * 4;
+ ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.usDwordOffset * 4;
+ ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
+
+ ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
+ ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byBitOffset;
+ ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byBitOffset;
+ ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byBitOffset;
+ ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
+
+ ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
+ ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byFieldSize;
+ ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byFieldSize;
+ ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byFieldSize;
+ ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
+ }
+ else /* f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
+ {
+ ulWritePtr = pEchoChannel->ulSoutBufWritePtr;
+ pulSkipPtr = &pEchoChannel->ulSoutBufSkipPtr;
+
+ ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
+ ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.usDwordOffset * 4;
+ ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.usDwordOffset * 4;
+ ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.usDwordOffset * 4;
+ ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
+
+ ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
+ ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byBitOffset;
+ ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byBitOffset;
+ ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byBitOffset;
+ ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
+
+ ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
+ ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byFieldSize;
+ ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byFieldSize;
+ ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byFieldSize;
+ ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
+ }
+
+
+
+ /* Set the playout feature base address. */
+ ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_ulChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
+
+ /* Check if we must wait for stop to complete before starting a new list. */
+ if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
+ {
+ if ( ( ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) && ( pEchoChannel->fRinHardStop == TRUE ) )
+ || ( ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) && ( pEchoChannel->fSoutHardStop == TRUE ) ) )
+ {
+ /* Read the read pointer. */
+ ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+ ReadParams.pusReadData = &usReadData;
+ ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
+
+ /* 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. */
+ ulChipWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst;
+
+ /* Optimize this access by only reading the word we are interested in. */
+ if ( ulReadPtrBitOfst < 16 )
+ ReadParams.ulReadAddress += 2;
+
+ while( fStillPlaying == TRUE )
+ {
+ /* Read the read pointer until equals to the write pointer. */
+ 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 == ulChipWritePtr )
+ break;
+
+ ulLoopCnt++;
+ if( ulLoopCnt > cOCT6100_MAX_LOOP )
+ {
+ return cOCT6100_ERR_FATAL_E6;
+ }
+
+ aulWaitTime[ 0 ] = 100;
+ aulWaitTime[ 1 ] = 0;
+ ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+ }
+
+ /* Check if must clear the skip bit. */
+ if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
+ {
+ if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
+ && ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
+ {
+ /* Make sure the skip bit is cleared to start playout! */
+ 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 );
+
+ /* Cleared! */
+ ulTempData &= ( ~ulMask );
+
+ mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
+ pEchoChannel,
+ ulAddress,
+ ulTempData,
+ ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Make sure the hard skip bit is cleared to start playout! */
+ 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( ulIgnoreFieldSize, ulHardSkipBitOfst, &ulMask );
+
+ /* Cleared! */
+ ulTempData &= ( ~ulMask );
+
+ mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
+ pEchoChannel,
+ ulAddress,
+ ulTempData,
+ ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+ }
+ }
+
+ /* Write the skip and write pointer to activate buffer playout. */
+
+ /* Update the skip pointer. */
+ if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == FALSE )
+ || ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == FALSE ) )
+ {
+ /* Old 31 events image. */
+ if ( ( ( ulWritePtr - *pulSkipPtr ) & 0x7F ) > 63 )
+ {
+ *pulSkipPtr = ( ulWritePtr - 63 ) & 0x7F;
+ fWriteSkipPtr = TRUE;
+ }
+ }
+ else
+ {
+ /* No need to update the skip pointer, a bit needs to be set when skipping. */
+ /* fWriteSkipPtr set to FALSE from variable declaration. */
+ }
+
+ if ( fWriteSkipPtr == TRUE )
+ {
+ /*=======================================================================*/
+ /* 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 |= *pulSkipPtr << ulSkipPtrBitOfst;
+
+ 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;
+
+ /*=======================================================================*/
+
+
+ /*=======================================================================*/
+ /* Now update the state of the channel stating that the buffer playout is activated. */
+
+ /* Select the buffer of interest.*/
+ if ( f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
+ {
+ /* Check if the global ports active stat must be incremented. */
+ if ( pEchoChannel->fRinBufPlaying == FALSE )
+ {
+ /* Increment the number of active buffer playout ports. */
+ pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts++;
+ }
+
+ pEchoChannel->fRinBufPlaying = TRUE;
+ /* Keep the new notify on event flag. */
+ pEchoChannel->fRinBufPlayoutNotifyOnStop = (UINT8)( f_fNotifyOnPlayoutStop & 0xFF );
+ /* Keep the specified user event id. */
+ pEchoChannel->ulRinUserBufPlayoutEventId = f_ulUserEventId;
+ /* Keep type of event to be generated. */
+ pEchoChannel->byRinPlayoutStopEventType = (UINT8)( f_ulPlayoutStopEventType & 0xFF );
+ /* No hard stop for now. */
+ pEchoChannel->fRinHardStop = FALSE;
+ /* No buffer added in the rin list for now. */
+ pEchoChannel->fRinBufAdded = FALSE;
+ /* Buffer playout is active on this channel. */
+ pEchoChannel->fBufPlayoutActive = TRUE;
+ }
+ else /* f_pBufferPlayoutStart->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
+ {
+ /* Check if the global ports active stat must be incremented. */
+ if ( pEchoChannel->fSoutBufPlaying == FALSE )
+ {
+ /* Increment the number of active buffer playout ports. */
+ pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts++;
+ }
+
+ pEchoChannel->fSoutBufPlaying = TRUE;
+ /* Keep the new notify on event flag. */
+ pEchoChannel->fSoutBufPlayoutNotifyOnStop = (UINT8)( f_fNotifyOnPlayoutStop & 0xFF );
+ /* Keep the specified user event id. */
+ pEchoChannel->ulSoutUserBufPlayoutEventId = f_ulUserEventId;
+ /* Keep type of event to be generated. */
+ pEchoChannel->bySoutPlayoutStopEventType = (UINT8)( f_ulPlayoutStopEventType & 0xFF );
+ /* No hard stop for now. */
+ pEchoChannel->fSoutHardStop = FALSE;
+ /* No buffer added in the sout list for now. */
+ pEchoChannel->fSoutBufAdded = FALSE;
+ /* Buffer playout is active on this channel. */
+ pEchoChannel->fBufPlayoutActive = TRUE;
+ }
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveBufPlayoutListEntry
+
+Description: Reserves a free entry in the Buffer playout 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_pulBufferIndex List entry reserved.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveBufPlayoutListEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT32 f_pulBufferIndex )
+{
+ PVOID pBufPlayoutAlloc;
+ UINT32 ulResult;
+
+ mOCT6100_GET_BUFFER_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBufPlayoutAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pBufPlayoutAlloc, f_pulBufferIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_BUFFER_PLAYOUT_ALL_BUFFERS_OPEN;
+ else
+ return cOCT6100_ERR_FATAL_40;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseBufPlayoutListEntry
+
+Description: Release an entry from the Buffer playout 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_ulBufferIndex List entry to be freed.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseBufPlayoutListEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulBufferIndex )
+{
+ PVOID pBufPlayoutAlloc;
+ UINT32 ulResult;
+
+ mOCT6100_GET_BUFFER_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBufPlayoutAlloc )
+
+ ulResult = OctapiLlmAllocDealloc( pBufPlayoutAlloc, f_ulBufferIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_41;
+
+ return cOCT6100_ERR_OK;
+}
+
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_remote_debug.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_remote_debug.c
new file mode 100644
index 0000000..89d1cd0
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_remote_debug.c
@@ -0,0 +1,1560 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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"
+
+/**************************** PUBLIC FUNCTIONS *****************************/
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100RemoteDebug
+
+Description: This function interprets the remote debugging packets received
+ by the user’s software. Commands contained in the packet are
+ executed by the API. In addition, a response packet is
+ constructed and returned by the function. It is the responsibility
+ of the user’s software to transmit the response packet back to
+ the source of the debugging packet.
+
+-------------------------------------------------------------------------------
+| 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_pRemoteDebug Pointer to a remote debug structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100RemoteDebugDef(
+ tPOCT6100_REMOTE_DEBUG f_pRemoteDebug )
+{
+ f_pRemoteDebug->pulReceivedPktPayload = NULL;
+ f_pRemoteDebug->ulReceivedPktLength = 0;
+ f_pRemoteDebug->pulResponsePktPayload = NULL;
+ f_pRemoteDebug->ulMaxResponsePktLength = 0;
+ f_pRemoteDebug->ulResponsePktLength = 0;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100RemoteDebug(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_REMOTE_DEBUG f_pRemoteDebug )
+{
+ tPOCTRPC_OGRDTP_HEADER pOgrdtpHeader;
+ tPOCTRPC_INTERFACE_HEADER pInterfaceHeader;
+ tPOCTRPC_COMMAND_HEADER pRspCmndHeader;
+ PUINT32 pulRcvPktPayload;
+ PUINT32 pulRspPktPayload;
+ UINT32 ulPktLengthDword;
+ UINT32 ulSessionIndex;
+ UINT32 ulChecksum;
+ UINT32 ulResult;
+
+ /* Check for errors. */
+ if ( f_pRemoteDebug->pulReceivedPktPayload == NULL )
+ return cOCT6100_ERR_REMOTEDEBUG_RECEIVED_PKT_PAYLOAD;
+ if ( f_pRemoteDebug->pulResponsePktPayload == NULL )
+ return cOCT6100_ERR_REMOTEDEBUG_RESPONSE_PKT_PAYLOAD;
+ if ( f_pRemoteDebug->ulReceivedPktLength < cOCTRPC_MIN_PACKET_BYTE_LENGTH )
+ return cOCT6100_ERR_REMOTEDEBUG_RECEIVED_PKT_LENGTH;
+ if ( f_pRemoteDebug->ulReceivedPktLength > cOCTRPC_MAX_PACKET_BYTE_LENGTH )
+ return cOCT6100_ERR_REMOTEDEBUG_RECEIVED_PKT_LENGTH;
+ if ( f_pRemoteDebug->ulMaxResponsePktLength < f_pRemoteDebug->ulReceivedPktLength )
+ return cOCT6100_ERR_REMOTEDEBUG_RESPONSE_PKT_LENGTH;
+ if ( (f_pRemoteDebug->ulReceivedPktLength % 4) != 0 )
+ return cOCT6100_ERR_REMOTEDEBUG_RECEIVED_PKT_LENGTH;
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxRemoteDebugSessions == 0 )
+ return cOCT6100_ERR_REMOTEDEBUG_DISABLED;
+
+ /* Set response length as received length. */
+ f_pRemoteDebug->ulResponsePktLength = f_pRemoteDebug->ulReceivedPktLength;
+
+ /* Typecast the packet payload to local pointers. */
+ pOgrdtpHeader = ( tPOCTRPC_OGRDTP_HEADER )f_pRemoteDebug->pulReceivedPktPayload;
+ pInterfaceHeader = ( tPOCTRPC_INTERFACE_HEADER )(f_pRemoteDebug->pulReceivedPktPayload + (sizeof( tOCTRPC_OGRDTP_HEADER ) / 4));
+
+ /* Get local pointer to received and response packet payloads. */
+ pulRcvPktPayload = f_pRemoteDebug->pulReceivedPktPayload;
+ pulRspPktPayload = f_pRemoteDebug->pulResponsePktPayload;
+
+ /* Get the length of the packet in UINT32s. */
+ ulPktLengthDword = f_pRemoteDebug->ulReceivedPktLength / 4;
+
+ /* Check the endian detection field to determine if the payload must be */
+ /* swapped to account for different endian formats. */
+ ulResult = Oct6100ApiCheckEndianDetectField( pOgrdtpHeader, ulPktLengthDword );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Check the packet's length. */
+ if ( pOgrdtpHeader->ulPktByteSize != f_pRemoteDebug->ulReceivedPktLength )
+ return cOCT6100_ERR_REMOTEDEBUG_RECEIVED_PKT_LENGTH;
+
+ /* Perform the sum of each word in the packet and compare to checksum. */
+ Oct6100ApiCalculateChecksum( pulRcvPktPayload, ulPktLengthDword, &ulChecksum );
+ if ( ulChecksum != pOgrdtpHeader->ulChecksum )
+ return cOCT6100_ERR_REMOTEDEBUG_CHECKSUM;
+
+ /* Check if the packet's session number has a corresponding entry in the API table.
+ If not then close an entry which has timed out, and allocate the entry to the
+ new session number. */
+ ulResult = Oct6100ApiCheckSessionNum( f_pApiInstance, pOgrdtpHeader, &ulSessionIndex );
+ if ( ulResult == cOCT6100_ERR_REMOTEDEBUG_ALL_SESSIONS_OPEN )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, FALSE, FALSE, FALSE, FALSE, cOCT6100_INVALID_VALUE, cOCTRPC_RDBGERR_ALL_SESSIONS_OPEN, cOCT6100_INVALID_VALUE, ulChecksum );
+ return cOCT6100_ERR_OK;
+ }
+ else if ( ulResult == cOCT6100_ERR_REMOTEDEBUG_TRANSACTION_ANSWERED )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, TRUE, FALSE, FALSE, FALSE, ulSessionIndex, cOCT6100_INVALID_VALUE, cOCT6100_INVALID_VALUE, ulChecksum );
+ return cOCT6100_ERR_OK;
+ }
+ else if ( ulResult != cOCT6100_ERR_OK )
+ {
+ return ulResult;
+ }
+
+ /* Check if an echo packet. If so then there's no need to check the rest of
+ the packet. Simply copy the packet back to the output buffer, enter the
+ protocol number supported by this API compilation, and recalculate the
+ checksum. If the packet is not an echo packet and the protocol version
+ does not correspond to this compiled version then return the supported
+ protocol version. */
+ if ( pOgrdtpHeader->ulRpcProtocolNum == cOCTRPC_ECHO_PROTOCOL )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, FALSE, TRUE, FALSE, FALSE, ulSessionIndex, cOCT6100_INVALID_VALUE, cOCT6100_INVALID_VALUE, ulChecksum );
+ return cOCT6100_ERR_OK;
+ }
+ else if ( pOgrdtpHeader->ulRpcProtocolNum != cOCTRPC_PROTOCOL_V1_1 )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, FALSE, TRUE, FALSE, FALSE, ulSessionIndex, cOCTRPC_RDBGERR_PROTOCOL_NUMBER, cOCT6100_INVALID_VALUE, ulChecksum );
+ return cOCT6100_ERR_OK;
+ }
+ else if ( f_pRemoteDebug->ulReceivedPktLength <= cOCTRPC_FIRST_COMMAND_BYTE_OFFSET )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, FALSE, FALSE, FALSE, FALSE, ulSessionIndex, cOCTRPC_RDBGERR_NO_COMMAND_HEADER, cOCT6100_INVALID_VALUE, ulChecksum );
+ return cOCT6100_ERR_OK;
+ }
+
+
+ /* Check the packet's RPC interface type and version. If either does not match then
+ return the packet with the supported interface type and version of this compilation. */
+ if ( pInterfaceHeader->ulInterfaceVersion != cOCTRPC_INTERFACE_VERSION )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, FALSE, FALSE, TRUE, TRUE, ulSessionIndex, cOCTRPC_RDBGERR_INTERFACE_VERSION, cOCT6100_INVALID_VALUE, ulChecksum );
+ return cOCT6100_ERR_OK;
+ }
+ if ( pInterfaceHeader->ulInterfaceType != cOCTRPC_OCT6100_INTERFACE )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, FALSE, FALSE, TRUE, TRUE, ulSessionIndex, cOCTRPC_RDBGERR_INTERFACE_TYPE, cOCT6100_INVALID_VALUE, ulChecksum );
+ return cOCT6100_ERR_OK;
+ }
+
+ /* Check each command header to make sure the indicated command and length agree. If
+ there is an error in the packet's commands then the response packet will be
+ constructed by the function. */
+ ulResult = Oct6100ApiCheckPktCommands( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulSessionIndex, ulPktLengthDword, ulChecksum );
+ if ( ulResult == cOCT6100_ERR_REMOTE_DEBUG_PARSING_ERROR )
+ return cOCT6100_ERR_OK;
+
+ /* The packet's fields are valid. Each command must now be extracted and executed. */
+ Oct6100ApiExecutePktCommands( f_pApiInstance, pulRcvPktPayload, ulPktLengthDword );
+
+ pRspCmndHeader = ( tPOCTRPC_COMMAND_HEADER )(( PUINT32 )pulRspPktPayload + ((sizeof( tOCTRPC_OGRDTP_HEADER ) + sizeof( tOCTRPC_INTERFACE_HEADER )) / 4));
+
+ /* Verify if the new method of using the protocol is the selected case. */
+ /* All commands have been executed. Calculate the packet's new checksum
+ and copy the packet to user provided buffer for response packet. */
+ Oct6100ApiCalculateChecksum( pulRcvPktPayload, ulPktLengthDword, &ulChecksum );
+
+ /* Send response packet. */
+ Oct6100ApiFormResponsePkt( f_pApiInstance, pulRcvPktPayload, pulRspPktPayload, ulPktLengthDword, FALSE, FALSE, FALSE, FALSE, ulSessionIndex, cOCTRPC_RDBGERR_OK, cOCT6100_INVALID_VALUE, ulChecksum );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/**************************** 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckEndianDetectField
+
+Description: Checks the endian field of a packet and performs a swap of
+ the packet data if deemed necessary.
+
+-------------------------------------------------------------------------------
+| 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_ulPktLengthDword Length of the packet in dwords.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckEndianDetectField(
+ IN OUT tPOCTRPC_OGRDTP_HEADER f_pOgrdtpHeader,
+ IN UINT32 f_ulPktLengthDword )
+{
+ PUINT32 pulPktPayload;
+ UINT32 ulBytePositionW = cOCT6100_INVALID_VALUE;
+ UINT32 ulBytePositionX = cOCT6100_INVALID_VALUE;
+ UINT32 ulBytePositionY = cOCT6100_INVALID_VALUE;
+ UINT32 ulBytePositionZ = cOCT6100_INVALID_VALUE;
+ UINT32 ulTempVar;
+ UINT32 i;
+
+ /* Bytes in dword are labeled as Z Y X W. */
+
+ /* Only swap if necessary. */
+ if ( f_pOgrdtpHeader->ulEndianDetect != cOCTRPC_ENDIAN_DETECT )
+ {
+ /* Find the position of each byte. */
+ for ( i = 0; i < 4; i++ )
+ {
+ ulTempVar = (f_pOgrdtpHeader->ulEndianDetect >> (8 * i)) & 0xFF;
+ switch ( ulTempVar )
+ {
+ case cOCTRPC_ENDIAN_DETECT_BYTE_W:
+ ulBytePositionW = i * 8;
+ break;
+ case cOCTRPC_ENDIAN_DETECT_BYTE_X:
+ ulBytePositionX = i * 8;
+ break;
+ case cOCTRPC_ENDIAN_DETECT_BYTE_Y:
+ ulBytePositionY = i * 8;
+ break;
+ case cOCTRPC_ENDIAN_DETECT_BYTE_Z:
+ ulBytePositionZ = i * 8;
+ break;
+ default:
+ return cOCT6100_ERR_REMOTEDEBUG_INVALID_PACKET;
+ }
+ }
+
+ /* Make sure all bytes of the endian detect field were found. */
+ if ( ulBytePositionW == cOCT6100_INVALID_VALUE ||
+ ulBytePositionX == cOCT6100_INVALID_VALUE ||
+ ulBytePositionY == cOCT6100_INVALID_VALUE ||
+ ulBytePositionZ == cOCT6100_INVALID_VALUE )
+ return cOCT6100_ERR_REMOTEDEBUG_INVALID_PACKET;
+
+ /* Swap the bytes of each dword of the packet. */
+ pulPktPayload = ( PUINT32 )f_pOgrdtpHeader;
+ for ( i = 0; i < f_ulPktLengthDword; i++ )
+ {
+ ulTempVar = pulPktPayload[ i ];
+ pulPktPayload[ i ] = ((ulTempVar >> ulBytePositionZ) & 0xFF) << 24;
+ pulPktPayload[ i ] |= ((ulTempVar >> ulBytePositionY) & 0xFF) << 16;
+ pulPktPayload[ i ] |= ((ulTempVar >> ulBytePositionX) & 0xFF) << 8;
+ pulPktPayload[ i ] |= ((ulTempVar >> ulBytePositionW) & 0xFF) << 0;
+ }
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCalculateChecksum
+
+Description: Calculates the checksum of the given packet payload.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pulPktPayload Pointer to the payload of the packet.
+f_ulPktLengthDword Length of the packet in dwords.
+f_pulChecksum Pointer to the checksum of the packet.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiCalculateChecksum(
+ IN PUINT32 f_pulPktPayload,
+ IN UINT32 f_ulPktLengthDword,
+ OUT PUINT32 f_pulChecksum )
+{
+ tPOCTRPC_OGRDTP_HEADER pOgrdtpHeader;
+ UINT32 i;
+
+ for ( i = 0, *f_pulChecksum = 0; i < f_ulPktLengthDword; i++ )
+ {
+ *f_pulChecksum += (f_pulPktPayload[ i ] >> 16) & 0xFFFF;
+ *f_pulChecksum += (f_pulPktPayload[ i ] >> 0) & 0xFFFF;
+ }
+
+ pOgrdtpHeader = ( tPOCTRPC_OGRDTP_HEADER )f_pulPktPayload;
+ *f_pulChecksum -= (pOgrdtpHeader->ulChecksum >> 16) & 0xFFFF;
+ *f_pulChecksum -= (pOgrdtpHeader->ulChecksum >> 0) & 0xFFFF;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiFormResponsePkt
+
+Description: Modifies the values of the indicated receive packet, update
+ the checksum field, and copy the receive packet to the
+ response packet.
+
+-------------------------------------------------------------------------------
+| 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_pulRcvPktPayload Pointer to the payload of the received packet.
+f_pulRspPktPayload Pointer to the payload of the response packet.
+f_ulPktLengthDword Length of the packet in dwords.
+f_fRetryPktResponse Flag indicating if the received packet was a retry packet.
+f_fReplaceProtocolNum Flag indicating if the protocol number must be replaced.
+f_fReplaceInterfaceType Flag indicating if the interface type must be replaced.
+f_fReplaceInterfaceVersion Flag indicating if the interface version must be replaced.
+f_ulSessionIndex Index of the remote debug session within the API' session list.
+f_ulParsingErrorValue Parsing error value.
+f_ulPayloadDwordIndex Index in the packet where the payload starts.
+f_ulChecksum Checksum of the packet.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiFormResponsePkt(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN PUINT32 f_pulRcvPktPayload,
+ 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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCTRPC_OGRDTP_HEADER pOgrdtpHeader;
+ tPOCTRPC_INTERFACE_HEADER pInterfaceHeader;
+ PUINT32 pulPktCache;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Typecast pointer to OGRDTP packet header. */
+ pOgrdtpHeader = ( tPOCTRPC_OGRDTP_HEADER )f_pulRcvPktPayload;
+
+ /* Check if a response to a retry packet. */
+ if ( f_fRetryPktResponse == TRUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_SESSION_PKT_CACHE_PNT( pSharedInfo, pulPktCache, f_ulSessionIndex )
+
+ Oct6100UserMemCopy( f_pulRspPktPayload, pulPktCache, f_ulPktLengthDword * 4 );
+ return;
+ }
+
+ /* Replace all packet header fields which must be changed. */
+ if ( f_ulParsingErrorValue != cOCT6100_INVALID_VALUE )
+ {
+ f_ulChecksum -= (pOgrdtpHeader->ulParsingError >> 16) & 0xFFFF;
+ f_ulChecksum -= (pOgrdtpHeader->ulParsingError >> 0) & 0xFFFF;
+
+ pOgrdtpHeader->ulParsingError = f_ulParsingErrorValue;
+
+ f_ulChecksum += (pOgrdtpHeader->ulParsingError >> 16) & 0xFFFF;
+ f_ulChecksum += (pOgrdtpHeader->ulParsingError >> 0) & 0xFFFF;
+ }
+
+ if ( f_fReplaceProtocolNum == TRUE )
+ {
+ f_ulChecksum -= (pOgrdtpHeader->ulRpcProtocolNum >> 16) & 0xFFFF;
+ f_ulChecksum -= (pOgrdtpHeader->ulRpcProtocolNum >> 0) & 0xFFFF;
+
+ pOgrdtpHeader->ulRpcProtocolNum = cOCTRPC_PROTOCOL_V1_1;
+
+ f_ulChecksum += (pOgrdtpHeader->ulRpcProtocolNum >> 16) & 0xFFFF;
+ f_ulChecksum += (pOgrdtpHeader->ulRpcProtocolNum >> 0) & 0xFFFF;
+ }
+
+ if ( f_fReplaceInterfaceType == TRUE )
+ {
+ pInterfaceHeader = ( tPOCTRPC_INTERFACE_HEADER )(f_pulRcvPktPayload + (sizeof( tOCTRPC_OGRDTP_HEADER ) / 4));
+
+ f_ulChecksum -= (pInterfaceHeader->ulInterfaceType >> 16) & 0xFFFF;
+ f_ulChecksum -= (pInterfaceHeader->ulInterfaceType >> 0) & 0xFFFF;
+
+ pInterfaceHeader->ulInterfaceType = cOCTRPC_OCT6100_INTERFACE;
+
+ f_ulChecksum += (pInterfaceHeader->ulInterfaceType >> 16) & 0xFFFF;
+ f_ulChecksum += (pInterfaceHeader->ulInterfaceType >> 0) & 0xFFFF;
+ }
+
+ if ( f_fReplaceInterfaceVersion == TRUE )
+ {
+ pInterfaceHeader = ( tPOCTRPC_INTERFACE_HEADER )(f_pulRcvPktPayload + (sizeof( tOCTRPC_OGRDTP_HEADER ) / 4));
+
+ f_ulChecksum -= (pInterfaceHeader->ulInterfaceVersion >> 16) & 0xFFFF;
+ f_ulChecksum -= (pInterfaceHeader->ulInterfaceVersion >> 0) & 0xFFFF;
+
+ pInterfaceHeader->ulInterfaceVersion = cOCTRPC_INTERFACE_VERSION;
+
+ f_ulChecksum += (pInterfaceHeader->ulInterfaceVersion >> 16) & 0xFFFF;
+ f_ulChecksum += (pInterfaceHeader->ulInterfaceVersion >> 0) & 0xFFFF;
+ }
+
+ if ( f_ulPayloadDwordIndex != cOCT6100_INVALID_VALUE )
+ {
+ f_pulRcvPktPayload += f_ulPayloadDwordIndex;
+
+ f_ulChecksum -= (*f_pulRcvPktPayload >> 16) & 0xFFFF;
+ f_ulChecksum -= (*f_pulRcvPktPayload >> 0) & 0xFFFF;
+
+ *f_pulRcvPktPayload = cOCTRPC_UNKNOWN_COMMAND_NUM;
+
+ f_ulChecksum += (*f_pulRcvPktPayload >> 16) & 0xFFFF;
+ f_ulChecksum += (*f_pulRcvPktPayload >> 0) & 0xFFFF;
+
+ f_pulRcvPktPayload -= f_ulPayloadDwordIndex;
+ }
+
+ /* Replace checksum. */
+ pOgrdtpHeader->ulChecksum = f_ulChecksum;
+
+ /* Copy the modified receive packet payload to the response packet. */
+ Oct6100UserMemCopy( f_pulRspPktPayload, f_pulRcvPktPayload, f_ulPktLengthDword * 4 );
+
+ /* Copy the response packet to the session's packet cache. */
+ if ( f_ulSessionIndex != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_SESSION_PKT_CACHE_PNT( pSharedInfo, pulPktCache, f_ulSessionIndex )
+
+ Oct6100UserMemCopy( pulPktCache, f_pulRspPktPayload, f_ulPktLengthDword * 4 );
+ }
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckPktCommands
+
+Description: Checks the commands contained in the packet for errors in size.
+ Also checks for unknown commands. If an error is encountered
+ then the function will construct the response packet.
+
+-------------------------------------------------------------------------------
+| 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_pulRcvPktPayload Pointer to the payload of the received packet.
+f_pulRspPktPayload Pointer to the payload of the response packet.
+f_ulPktLengthDword Length of the packet in dwords.
+f_ulSessionIndex Index of the remote debug session within the API' session list.
+f_ulChecksum Checksum of the packet.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCTRPC_COMMAND_HEADER pCmndHeader;
+ UINT32 ulNumDwordsLeft;
+ UINT32 ulNumDwordsNeeded = 0;
+ UINT32 ulRpcCmndSizeDword;
+ BOOL fCmndIdentified;
+ BOOL fCmndHeaderPresent;
+
+ pCmndHeader = ( tPOCTRPC_COMMAND_HEADER )(f_pulRcvPktPayload + ((sizeof( tOCTRPC_OGRDTP_HEADER ) + sizeof( tOCTRPC_INTERFACE_HEADER )) / 4));
+ ulNumDwordsLeft = f_ulPktLengthDword - ((sizeof( tOCTRPC_OGRDTP_HEADER ) + sizeof( tOCTRPC_INTERFACE_HEADER )) / 4);
+ ulRpcCmndSizeDword = sizeof( tOCTRPC_COMMAND_HEADER ) / 4;
+ fCmndIdentified = TRUE;
+
+ while ( ulNumDwordsLeft != 0 )
+ {
+ if ( ulNumDwordsLeft < ulRpcCmndSizeDword )
+ {
+ fCmndHeaderPresent = FALSE;
+ }
+ else
+ {
+ fCmndHeaderPresent = TRUE;
+
+ switch ( pCmndHeader->ulRpcCommandNum )
+ {
+ case cOCT6100_RPC_READ_WORD:
+ {
+ ulNumDwordsNeeded = sizeof( tOCT6100_RPC_READ_WORD ) / 4;
+ }
+ break;
+ case cOCT6100_RPC_READ_BURST:
+ {
+ tPOCT6100_RPC_READ_BURST pBurstHeader;
+
+ ulNumDwordsNeeded = (sizeof( tOCT6100_RPC_READ_BURST ) - sizeof( UINT32 )) / 4;
+ pBurstHeader = ( tPOCT6100_RPC_READ_BURST )(( PUINT32 )pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+ ulNumDwordsNeeded += (pBurstHeader->ulBurstLength + 1) / 2;
+ }
+ break;
+ case cOCT6100_RPC_WRITE_WORD:
+ {
+ ulNumDwordsNeeded = sizeof( tOCT6100_RPC_WRITE_WORD ) / 4;
+ }
+ break;
+ case cOCT6100_RPC_WRITE_SMEAR:
+ {
+ ulNumDwordsNeeded = sizeof( tOCT6100_RPC_WRITE_SMEAR ) / 4;
+ }
+ break;
+ case cOCT6100_RPC_WRITE_INC:
+ {
+ ulNumDwordsNeeded = sizeof( tOCT6100_RPC_WRITE_INC ) / 4;
+ }
+ break;
+ case cOCT6100_RPC_READ_ARRAY:
+ {
+ tPOCT6100_RPC_READ_ARRAY pArrayHeader;
+
+ ulNumDwordsNeeded = (sizeof( tOCT6100_RPC_READ_ARRAY ) - sizeof( UINT32 )) / 4;
+ pArrayHeader = ( tPOCT6100_RPC_READ_ARRAY )(( PUINT32 )pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+ ulNumDwordsNeeded += pArrayHeader->ulArrayLength;
+ ulNumDwordsNeeded += (pArrayHeader->ulArrayLength + 1) / 2;
+ }
+ break;
+ case cOCT6100_RPC_WRITE_BURST:
+ {
+ tPOCT6100_RPC_WRITE_BURST pBurstHeader;
+
+ ulNumDwordsNeeded = (sizeof( tOCT6100_RPC_WRITE_BURST ) - sizeof( UINT32 )) / 4;
+ pBurstHeader = ( tPOCT6100_RPC_WRITE_BURST )(( PUINT32 )pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+ ulNumDwordsNeeded += (pBurstHeader->ulBurstLength + 1) / 2;
+ }
+ break;
+ case cOCT6100_RPC_SET_HOT_CHANNEL:
+ {
+ ulNumDwordsNeeded = sizeof( tOCT6100_RPC_SET_HOT_CHANNEL ) / 4;
+ }
+ break;
+ case cOCT6100_RPC_GET_DEBUG_CHAN_INDEX:
+ {
+ ulNumDwordsNeeded = sizeof( tOCT6100_RPC_GET_DEBUG_CHAN_INDEX ) / 4;
+ }
+ break;
+ case cOCT6100_RPC_API_DISCONNECT:
+ {
+ /* There is no parameter to the disconnect command. */
+ ulNumDwordsNeeded = 0;
+ }
+ break;
+ default:
+ fCmndIdentified = FALSE;
+ }
+
+ ulNumDwordsNeeded += sizeof( tOCTRPC_COMMAND_HEADER ) / 4;
+ }
+
+ if ( fCmndHeaderPresent != TRUE )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, f_pulRcvPktPayload, f_pulRspPktPayload, f_ulPktLengthDword, FALSE, FALSE, FALSE, FALSE, f_ulSessionIndex, cOCTRPC_RDBGERR_INVALID_PACKET_LENGTH, cOCT6100_INVALID_VALUE, f_ulChecksum );
+ return cOCT6100_ERR_REMOTE_DEBUG_PARSING_ERROR;
+ }
+ if ( fCmndIdentified != TRUE )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, f_pulRcvPktPayload, f_pulRspPktPayload, f_ulPktLengthDword, FALSE, FALSE, FALSE, FALSE, f_ulSessionIndex, cOCTRPC_RDBGERR_INVALID_COMMAND_NUMBER, f_ulPktLengthDword - ulNumDwordsLeft, f_ulChecksum );
+ return cOCT6100_ERR_REMOTE_DEBUG_PARSING_ERROR;
+ }
+
+ if ( ulNumDwordsNeeded != (pCmndHeader->ulCommandByteSize / 4) ||
+ ulNumDwordsNeeded > ulNumDwordsLeft )
+ {
+ Oct6100ApiFormResponsePkt( f_pApiInstance, f_pulRcvPktPayload, f_pulRspPktPayload, f_ulPktLengthDword, FALSE, FALSE, FALSE, FALSE, f_ulSessionIndex, cOCTRPC_RDBGERR_INVALID_COMMAND_LENGTH, cOCT6100_INVALID_VALUE, f_ulChecksum );
+ return cOCT6100_ERR_REMOTE_DEBUG_PARSING_ERROR;
+ }
+
+ pCmndHeader = ( tPOCTRPC_COMMAND_HEADER )(( PUINT32 )pCmndHeader + ulNumDwordsNeeded);
+ ulNumDwordsLeft -= ulNumDwordsNeeded;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiExecutePktCommands
+
+Description: Executes the commands contained in the received packet. The
+ received packet payload buffer is modified but NOT copied to
+ the response packet 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_pulRcvPktPayload Pointer to the payload of the received packet.
+f_ulPktLengthDword Length of the packet in dwords.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiExecutePktCommands(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN PUINT32 f_pulRcvPktPayload,
+ IN UINT32 f_ulPktLengthDword )
+{
+ tPOCTRPC_COMMAND_HEADER pReqCmndHeader;
+ tPOCTRPC_OGRDTP_HEADER pReqPktHeader;
+ UINT32 ulNumDwordsLeft;
+ UINT32 ulRpcCmndSizeDword;
+
+ pReqPktHeader = ( tPOCTRPC_OGRDTP_HEADER )(f_pulRcvPktPayload);
+ pReqCmndHeader = ( tPOCTRPC_COMMAND_HEADER )(( PUINT32 )f_pulRcvPktPayload + ((sizeof( tOCTRPC_OGRDTP_HEADER ) + sizeof( tOCTRPC_INTERFACE_HEADER )) / 4));
+ ulNumDwordsLeft = f_ulPktLengthDword - ((sizeof( tOCTRPC_OGRDTP_HEADER ) + sizeof( tOCTRPC_INTERFACE_HEADER )) / 4);
+ ulRpcCmndSizeDword = sizeof( tOCTRPC_COMMAND_HEADER ) / 4;
+
+ while ( ulNumDwordsLeft != 0 )
+ {
+ /* Switch on command number. */
+ switch ( pReqCmndHeader->ulRpcCommandNum )
+ {
+ case cOCT6100_RPC_READ_WORD:
+ Oct6100ApiRpcReadWord( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_READ_BURST:
+ Oct6100ApiRpcReadBurst( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_READ_ARRAY:
+ Oct6100ApiRpcReadArray( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_WRITE_WORD:
+ Oct6100ApiRpcWriteWord( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_WRITE_SMEAR:
+ Oct6100ApiRpcWriteSmear( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_WRITE_BURST:
+ Oct6100ApiRpcWriteBurst( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_SET_HOT_CHANNEL:
+ Oct6100ApiRpcSetHotChannel( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_GET_DEBUG_CHAN_INDEX:
+ Oct6100ApiRpcGetDebugChanIndex( f_pApiInstance, pReqCmndHeader );
+ break;
+ case cOCT6100_RPC_API_DISCONNECT:
+ Oct6100ApiRpcDisconnect( f_pApiInstance, pReqCmndHeader, pReqPktHeader->ulDebugSessionNum );
+ break;
+ default:
+ pReqCmndHeader->ulFunctionResult = cOCT6100_ERR_REMOTEDEBUG_INVALID_RPC_COMMAND_NUM;
+ break;
+ }
+
+ /* Insert the result of the operation in the command header. */
+ if ( pReqCmndHeader->ulFunctionResult != cOCT6100_ERR_OK )
+ break;
+
+ /* Decrement the number of DWORDs left in the packet. */
+ ulNumDwordsLeft -= pReqCmndHeader->ulCommandByteSize / 4;
+
+ /* Point to the next command in the packet. */
+ pReqCmndHeader = ( tPOCTRPC_COMMAND_HEADER )(( PUINT32 )pReqCmndHeader + (pReqCmndHeader->ulCommandByteSize / 4));
+ }
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckSessionNum
+
+Description: Checks if there is a session list entry open for the session
+ number received. If not, a free one is reserved if one is
+ available. If none are free, one which has timed-out is
+ released. If none are timed out then an error is returned.
+
+-------------------------------------------------------------------------------
+| 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_pOgrdtpHeader Pointer to the header of the packet.
+f_pulSessionIndex Pointer to the remote debugging session within the
+ API's session list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckSessionNum(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCTRPC_OGRDTP_HEADER f_pOgrdtpHeader,
+ OUT PUINT32 f_pulSessionIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_REMOTE_DEBUG_INFO pRemoteDebugInfo;
+ tPOCT6100_API_REMOTE_DEBUG_SESSION pSessionEntry;
+ tPOCT6100_API_REMOTE_DEBUG_SESSION pSessionLink;
+ tOCT6100_GET_TIME GetTime;
+ PVOID pSessionTree;
+ PUINT32 pulTreeData;
+ UINT32 ulNewSessionIndex;
+ UINT32 aulTimeDiff[ 2 ];
+ UINT32 ulResult;
+ UINT16 usNegative;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Set the process context of GetTime. */
+ GetTime.pProcessContext = f_pApiInstance->pProcessContext;
+
+ /* Get the current system time. */
+ ulResult = Oct6100UserGetTime( &GetTime );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Get a local pointer to the remote debugging info. */
+ pRemoteDebugInfo = &pSharedInfo->RemoteDebugInfo;
+
+ /* Check if the session number has an associated session list entry. */
+ mOCT6100_GET_REMOTE_DEBUG_TREE_PNT( pSharedInfo, pSessionTree )
+
+ ulResult = octapi_bt0_query_node( pSessionTree, ( ( PVOID )(&f_pOgrdtpHeader->ulDebugSessionNum) ), ( ( PVOID* )&pulTreeData ) );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Return session index. */
+ *f_pulSessionIndex = *pulTreeData;
+
+ /* A session list entry is associated, so update the entries last packet time,
+ transaction number and packet retry number, and position in the linked list. */
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, *pulTreeData, pSessionEntry )
+
+ pSessionEntry->aulLastPktTime[ 0 ] = GetTime.aulWallTimeUs[ 0 ];
+ pSessionEntry->aulLastPktTime[ 1 ] = GetTime.aulWallTimeUs[ 1 ];
+ pSessionEntry->ulPktRetryNum = f_pOgrdtpHeader->ulPktRetryNum;
+
+ /* Remove the node from its current place in the linked-list and add it to the end. */
+ if ( pRemoteDebugInfo->ulSessionListTail != *pulTreeData )
+ {
+ /* Obtain local pointer to the session list entry to be moved. */
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, *pulTreeData, pSessionEntry )
+
+ /* Update link of previous session in list. */
+ if ( pSessionEntry->ulBackwardLink != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulBackwardLink, pSessionLink )
+ pSessionLink->ulForwardLink = pSessionEntry->ulForwardLink;
+ }
+ else
+ {
+ pRemoteDebugInfo->ulSessionListHead = pSessionEntry->ulForwardLink;
+ }
+
+ /* Update link of next session in list. */
+ if ( pSessionEntry->ulForwardLink != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulForwardLink, pSessionLink )
+ pSessionLink->ulBackwardLink = pSessionEntry->ulBackwardLink;
+ }
+ else
+ {
+ pRemoteDebugInfo->ulSessionListTail = pSessionEntry->ulBackwardLink;
+ }
+
+ /* Place session at the end of the list. */
+ pSessionEntry->ulBackwardLink = pRemoteDebugInfo->ulSessionListTail;
+ pSessionEntry->ulForwardLink = cOCT6100_INVALID_VALUE;
+
+ pRemoteDebugInfo->ulSessionListTail = *pulTreeData;
+
+ if ( pRemoteDebugInfo->ulSessionListHead == cOCT6100_INVALID_VALUE )
+ {
+ pRemoteDebugInfo->ulSessionListHead = *pulTreeData;
+ }
+ else
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulBackwardLink, pSessionLink )
+ pSessionLink->ulForwardLink = *pulTreeData;
+ }
+ }
+
+ /* Check if packet should be interpreted based on transaction number. */
+ if ( f_pOgrdtpHeader->ulPktRetryNum != 0 &&
+ pSessionEntry->ulTransactionNum == f_pOgrdtpHeader->ulTransactionNum &&
+ pSessionEntry->ulPktByteSize == f_pOgrdtpHeader->ulPktByteSize )
+ return cOCT6100_ERR_REMOTEDEBUG_TRANSACTION_ANSWERED;
+
+ /* Update transaction number since packet will be interpreted. */
+ pSessionEntry->ulTransactionNum = f_pOgrdtpHeader->ulTransactionNum;
+ pSessionEntry->ulPktByteSize = f_pOgrdtpHeader->ulPktByteSize;
+
+ return cOCT6100_ERR_OK;
+ }
+ else if ( ulResult == OCTAPI_BT0_KEY_NOT_IN_TREE )
+ {
+ /* If there is a free entry in the session list then seize it. Else, try to
+ find an entry which has timed out. If there are none then return an error. */
+ if ( pRemoteDebugInfo->ulNumSessionsOpen < pRemoteDebugInfo->ulMaxSessionsOpen )
+ {
+ ulNewSessionIndex = pRemoteDebugInfo->ulNumSessionsOpen;
+ }
+ else /* ( pRemoteDebugInfo->ulNumSessionsOpen == pRemoteDebugInfo->ulMaxSessionsOpen ) */
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pRemoteDebugInfo->ulSessionListHead, pSessionEntry )
+
+ ulResult = octapi_lm_subtract( GetTime.aulWallTimeUs, 1, pSessionEntry->aulLastPktTime, 1, aulTimeDiff, 1, &usNegative );
+ if ( ulResult != cOCT6100_ERR_OK || usNegative != FALSE )
+ return cOCT6100_ERR_FATAL_43;
+
+ /* If there are no session list entries available then return the packet with
+ a parsing error. */
+ if ( aulTimeDiff[ 1 ] == 0 && aulTimeDiff[ 0 ] < (cOCTRPC_SESSION_TIMEOUT * 1000000) )
+ return cOCT6100_ERR_REMOTEDEBUG_ALL_SESSIONS_OPEN;
+
+ ulNewSessionIndex = pRemoteDebugInfo->ulSessionListHead;
+
+ /* Remove old session index. */
+ ulResult = octapi_bt0_remove_node( pSessionTree, ( ( PVOID )&pSessionEntry->ulSessionNum ) );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_44;
+
+ if ( pSessionEntry->ulBackwardLink != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulBackwardLink, pSessionLink )
+ pSessionLink->ulForwardLink = pSessionEntry->ulForwardLink;
+ }
+ else
+ {
+ pRemoteDebugInfo->ulSessionListHead = pSessionEntry->ulForwardLink;
+ }
+
+ if ( pSessionEntry->ulForwardLink != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulForwardLink, pSessionLink )
+ pSessionLink->ulBackwardLink = pSessionEntry->ulBackwardLink;
+ }
+ else
+ {
+ pRemoteDebugInfo->ulSessionListTail = pSessionEntry->ulBackwardLink;
+ }
+
+ /* Decrement number of open sessions. */
+ pRemoteDebugInfo->ulNumSessionsOpen--;
+ }
+
+ /* Add new session. */
+ ulResult = octapi_bt0_add_node( pSessionTree, ( ( PVOID )&f_pOgrdtpHeader->ulDebugSessionNum ), ( ( PVOID* )&pulTreeData ) );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_FATAL_45;
+ *pulTreeData = ulNewSessionIndex;
+
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, ulNewSessionIndex, pSessionEntry )
+
+ pSessionEntry->aulLastPktTime[ 0 ] = GetTime.aulWallTimeUs[ 0 ];
+ pSessionEntry->aulLastPktTime[ 1 ] = GetTime.aulWallTimeUs[ 1 ];
+ pSessionEntry->ulSessionNum = f_pOgrdtpHeader->ulDebugSessionNum;
+ pSessionEntry->ulTransactionNum = f_pOgrdtpHeader->ulTransactionNum;
+ pSessionEntry->ulPktRetryNum = f_pOgrdtpHeader->ulPktRetryNum;
+
+ pSessionEntry->ulBackwardLink = pRemoteDebugInfo->ulSessionListTail;
+ pSessionEntry->ulForwardLink = cOCT6100_INVALID_VALUE;
+
+ pRemoteDebugInfo->ulSessionListTail = ulNewSessionIndex;
+ if ( pRemoteDebugInfo->ulSessionListHead == cOCT6100_INVALID_VALUE )
+ pRemoteDebugInfo->ulSessionListHead = ulNewSessionIndex;
+
+ if ( pSessionEntry->ulBackwardLink != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulBackwardLink, pSessionLink )
+ pSessionLink->ulForwardLink = ulNewSessionIndex;
+ }
+
+ *f_pulSessionIndex = ulNewSessionIndex;
+
+ /* Increment number of open sessions. */
+ pRemoteDebugInfo->ulNumSessionsOpen++;
+
+ return cOCT6100_ERR_OK;
+ }
+ else
+ {
+ return cOCT6100_ERR_FATAL_46;
+ }
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcReadWord
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_READ_WORD 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcReadWord(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_READ_WORD pReadCommand;
+ tOCT6100_READ_PARAMS ReadParams;
+ UINT32 ulResult;
+ UINT16 usReadData;
+
+ /* Get pointer to command arguments. */
+ pReadCommand = ( tPOCT6100_RPC_READ_WORD )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ /* Set some read structure parameters. */
+ ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Copy parameters from packet payload to local read structure. */
+ ReadParams.ulReadAddress = pReadCommand->ulAddress;
+
+ /* Supply memory for read data. */
+ ReadParams.pusReadData = &usReadData;
+
+ /* Perform read access. */
+ mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
+
+ usReadData &= 0xFFFF;
+
+ /* Return read data and result. */
+ pReadCommand->ulReadData = (usReadData << 16) | usReadData;
+ f_pCmndHeader->ulFunctionResult = ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcReadBurst
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_READ_BURST 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcReadBurst(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_READ_BURST pBurstCommand;
+ tOCT6100_READ_BURST_PARAMS BurstParams;
+ UINT32 ulResult = cOCT6100_ERR_OK;
+ UINT32 ulTempVar;
+ UINT32 i;
+ PUINT16 pusReadData;
+ UINT32 ulNumWordsToRead;
+
+ /* Get local pointer to remote debugging read data buffer. */
+ mOCT6100_GET_REMOTE_DEBUG_DATA_BUF_PNT( f_pApiInstance->pSharedInfo, pusReadData )
+
+ /* Get pointer to command arguments. */
+ pBurstCommand = ( tPOCT6100_RPC_READ_BURST )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ /* Set some read structure parameters. */
+ BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Copy parameters from packet payload to local read structure. */
+ BurstParams.ulReadAddress = pBurstCommand->ulAddress;
+
+
+ /* Supply memory for read data. */
+ BurstParams.pusReadData = pusReadData;
+
+ ulNumWordsToRead = pBurstCommand->ulBurstLength;
+ while( ulNumWordsToRead > 0)
+ {
+ if ( ulNumWordsToRead <= f_pApiInstance->pSharedInfo->ChipConfig.usMaxRwAccesses )
+ BurstParams.ulReadLength = ulNumWordsToRead;
+ else
+ BurstParams.ulReadLength = f_pApiInstance->pSharedInfo->ChipConfig.usMaxRwAccesses;
+
+ /* Perform read access. */
+ mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult )
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ f_pCmndHeader->ulFunctionResult = ulResult;
+ return;
+ }
+
+ BurstParams.ulReadAddress += BurstParams.ulReadLength * 2;
+ BurstParams.pusReadData += BurstParams.ulReadLength;
+
+ /* Update the number of dword to read. */
+ ulNumWordsToRead -= BurstParams.ulReadLength;
+ }
+
+ /* Return read data. */
+ ulTempVar = (pBurstCommand->ulBurstLength + 1) / 2;
+ for ( i = 0; i < ulTempVar; i++ )
+ {
+ pBurstCommand->aulReadData[ i ] = (*pusReadData & 0xFFFF) << 16;
+ pusReadData++;
+ pBurstCommand->aulReadData[ i ] |= (*pusReadData & 0xFFFF) << 0;
+ pusReadData++;
+ }
+
+ /* Return result. */
+ f_pCmndHeader->ulFunctionResult = ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcReadArray
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_READ_ARRAY 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcReadArray(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_READ_ARRAY pArrayCommand;
+ tOCT6100_READ_PARAMS ReadParams;
+ UINT32 ulResult = cOCT6100_ERR_OK;
+ UINT32 i;
+ PUINT32 pulAddressArray;
+ PUINT32 pulDataArray;
+ UINT16 usReadData;
+
+
+ /* Get pointer to command arguments. */
+ pArrayCommand = ( tPOCT6100_RPC_READ_ARRAY )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ /* Set some read structure parameters. */
+ ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Supply memory for read data. */
+ ReadParams.pusReadData = &usReadData;
+
+ /* Get pointers to array of addresses and data. */
+ pulAddressArray = pArrayCommand->aulArrayData;
+ pulDataArray = pArrayCommand->aulArrayData + pArrayCommand->ulArrayLength;
+
+ for ( i = 0; i < pArrayCommand->ulArrayLength; i++ )
+ {
+ /* Copy parameters from packet payload to local read structure. */
+ ReadParams.ulReadAddress = pulAddressArray[ i ];
+
+ /* Perform read access. */
+ mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
+ if ( ulResult != cOCT6100_ERR_OK )
+ break;
+
+ /* Return read data. */
+ if ( (i % 2) == 0 )
+ pulDataArray[ i / 2 ] = (usReadData & 0xFFFF) << 16;
+ else /* ( (i % 2) == 1 ) */
+ pulDataArray[ i / 2 ] |= (usReadData & 0xFFFF) << 0;
+ }
+
+ /* Return result. */
+ f_pCmndHeader->ulFunctionResult = ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcWriteWord
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_WRITE_WORD 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcWriteWord(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_WRITE_WORD pWriteCommand;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* Get pointer to command arguments. */
+ pWriteCommand = ( tPOCT6100_RPC_WRITE_WORD )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ /* Set some read structure parameters. */
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Copy parameters from packet payload to local read structure. */
+ WriteParams.ulWriteAddress = pWriteCommand->ulAddress;
+ WriteParams.usWriteData = (UINT16)pWriteCommand->ulWriteData;
+
+ /* Perform write access. */
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
+
+ /* Return result. */
+ f_pCmndHeader->ulFunctionResult = ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcWriteSmear
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_WRITE_SMEAR 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcWriteSmear(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_WRITE_SMEAR pSmearCommand;
+ tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
+ UINT32 ulResult;
+
+ /* Get pointer to command arguments. */
+ pSmearCommand = ( tPOCT6100_RPC_WRITE_SMEAR )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ /* Set the smear structure parameters. */
+ SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ SmearParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Copy parameters from packet payload to local read structure. */
+ SmearParams.ulWriteAddress = pSmearCommand->ulAddress;
+ SmearParams.usWriteData = (UINT16)pSmearCommand->ulWriteData;
+ SmearParams.ulWriteLength = pSmearCommand->ulSmearLength;
+
+ /* Perform write access. */
+ mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult )
+
+ /* Return result. */
+ f_pCmndHeader->ulFunctionResult = ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcWriteBurst
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_WRITE_BURST 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcWriteBurst(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_WRITE_BURST pBurstCommand;
+ tOCT6100_WRITE_BURST_PARAMS BurstParams;
+ UINT32 ulResult;
+ UINT32 ulTempVar;
+ UINT32 i, j;
+ PUINT16 pusWriteData;
+
+ /* Get local pointer to remote debugging write data buffer. */
+ mOCT6100_GET_REMOTE_DEBUG_DATA_BUF_PNT( f_pApiInstance->pSharedInfo, pusWriteData )
+
+ /* Get pointer to command arguments. */
+ pBurstCommand = ( tPOCT6100_RPC_WRITE_BURST )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ ulTempVar = (pBurstCommand->ulBurstLength + 1) / 2;
+ for ( i = 0, j = 0; i < ulTempVar; i++ )
+ {
+ pusWriteData[ j++ ] = (UINT16)((pBurstCommand->aulWriteData[ i ] >> 16) & 0xFFFF);
+ pusWriteData[ j++ ] = (UINT16)((pBurstCommand->aulWriteData[ i ] >> 0) & 0xFFFF);
+ }
+
+ /* Set some structure parameters. */
+ BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
+
+ /* Copy parameters from packet payload to local read structure. */
+ BurstParams.ulWriteAddress = pBurstCommand->ulAddress;
+ BurstParams.ulWriteLength = pBurstCommand->ulBurstLength;
+ BurstParams.pusWriteData = pusWriteData;
+
+ /* Perform write access. */
+ mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )
+
+ /* Return result. */
+ f_pCmndHeader->ulFunctionResult = ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcSetHotChannel
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_SET_HOT_CHANNEL 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcSetHotChannel(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_SET_HOT_CHANNEL pHotChanCommand;
+ tOCT6100_DEBUG_SELECT_CHANNEL DebugSelectChannel;
+ tPOCT6100_API_CHANNEL pChanEntry;
+ UINT32 ulResult;
+
+ pHotChanCommand = ( tPOCT6100_RPC_SET_HOT_CHANNEL )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ /* Verify if the hot channel index is valid. */
+ if ( pHotChanCommand->ulHotChannel >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
+ {
+ f_pCmndHeader->ulFunctionResult = cOCT6100_ERR_REMOTEDEBUG_INVALID_HOT_CHAN_INDEX;
+ return;
+ }
+
+ mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, pHotChanCommand->ulHotChannel );
+
+ DebugSelectChannel.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pHotChanCommand->ulHotChannel;
+
+ /* The PCM law parameter is now obsolete. */
+ /* The instance knows the law of the channel being recorded! */
+
+ /* Call the function. */
+ ulResult = Oct6100DebugSelectChannelSer( f_pApiInstance, &DebugSelectChannel, FALSE );
+
+ /* Return result. */
+ f_pCmndHeader->ulFunctionResult = ulResult;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcGetDebugChanIndex
+
+Description: Checks the provided portion of an OCTRPC packet and interprets
+ it as an cOCT6100_RPC_GET_DEBUG_CHAN_INDEX 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_pCmndHeader Pointer to RPC command structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcGetDebugChanIndex(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader )
+{
+ tPOCT6100_RPC_GET_DEBUG_CHAN_INDEX pDebugChanCommand;
+
+ pDebugChanCommand = ( tPOCT6100_RPC_GET_DEBUG_CHAN_INDEX )(( PUINT32 )f_pCmndHeader + (sizeof( tOCTRPC_COMMAND_HEADER ) / 4));
+
+ /* Set the debug channel index of the structure. */
+ pDebugChanCommand->ulDebugChanIndex = f_pApiInstance->pSharedInfo->DebugInfo.usRecordMemIndex;
+
+ /* Return result. */
+ f_pCmndHeader->ulFunctionResult = cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiRpcDisconnect
+
+Description: Destroy the current session.
+
+-------------------------------------------------------------------------------
+| 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_pCmndHeader Pointer to RPC command structure.
+f_ulSessionNumber Session number of the current remote debugging session.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+VOID Oct6100ApiRpcDisconnect(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCTRPC_COMMAND_HEADER f_pCmndHeader,
+ IN UINT32 f_ulSessionNumber )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_REMOTE_DEBUG_INFO pRemoteDebugInfo;
+ tPOCT6100_API_REMOTE_DEBUG_SESSION pSessionEntry;
+ tPOCT6100_API_REMOTE_DEBUG_SESSION pSessionTempEntry;
+ PVOID pSessionTree;
+ UINT32 ulResult;
+ PUINT32 pulTreeData;
+ UINT32 ulSessionIndex;
+
+ f_pCmndHeader->ulFunctionResult = cOCT6100_ERR_OK;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Get a local pointer to the remote debugging info. */
+ pRemoteDebugInfo = &pSharedInfo->RemoteDebugInfo;
+
+ /* Check if the session number has an associated session list entry. */
+ mOCT6100_GET_REMOTE_DEBUG_TREE_PNT( pSharedInfo, pSessionTree )
+
+ ulResult = octapi_bt0_query_node( pSessionTree, ( ( PVOID )(&f_ulSessionNumber) ), ( ( PVOID* )&pulTreeData ) );
+ if ( ulResult != cOCT6100_ERR_OK )
+ f_pCmndHeader->ulFunctionResult = cOCT6100_ERR_REMOTEDEBUG_INAVLID_SESSION_NUMBER;
+
+ /* Return session index. */
+ ulSessionIndex= *pulTreeData;
+
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, ulSessionIndex, pSessionEntry );
+
+ /* Clear the entry of the session. */
+ pSessionEntry->aulLastPktTime[ 0 ] = 0;
+ pSessionEntry->aulLastPktTime[ 1 ] = 0;
+ pSessionEntry->ulSessionNum = cOCT6100_INVALID_VALUE;
+ pSessionEntry->ulTransactionNum = cOCT6100_INVALID_VALUE;
+ pSessionEntry->ulPktRetryNum = cOCT6100_INVALID_VALUE;
+
+ /* Update the other entry before removing the node. */
+ pSessionEntry->ulBackwardLink = pRemoteDebugInfo->ulSessionListTail;
+ pSessionEntry->ulForwardLink = cOCT6100_INVALID_VALUE;
+
+ if ( pSessionEntry->ulBackwardLink != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulBackwardLink, pSessionTempEntry );
+ pSessionTempEntry->ulForwardLink = pSessionEntry->ulForwardLink;
+ }
+ else /* pSessionEntry->ulBackwardLink == cOCT6100_INVALID_VALUE */
+ {
+ pRemoteDebugInfo->ulSessionListHead = pSessionEntry->ulForwardLink;
+ }
+
+ if ( pSessionEntry->ulForwardLink != cOCT6100_INVALID_VALUE )
+ {
+ mOCT6100_GET_REMOTE_DEBUG_LIST_ENTRY_PNT( pSharedInfo, pSessionEntry->ulForwardLink, pSessionTempEntry );
+ pSessionTempEntry->ulBackwardLink = pSessionEntry->ulBackwardLink;
+ }
+ else /* pSessionEntry->ulForwardLink == cOCT6100_INVALID_VALUE */
+ {
+ pRemoteDebugInfo->ulSessionListTail = pSessionEntry->ulBackwardLink;
+ }
+
+ /* Invalidate the pointer. */
+ pSessionEntry->ulBackwardLink = cOCT6100_INVALID_VALUE;
+ pSessionEntry->ulForwardLink = cOCT6100_INVALID_VALUE;
+
+ /* Remove the session. */
+ ulResult = octapi_bt0_remove_node( pSessionTree, ( ( PVOID )&f_ulSessionNumber ) );
+ if ( ulResult != cOCT6100_ERR_OK )
+ f_pCmndHeader->ulFunctionResult = cOCT6100_ERR_FATAL_47;
+
+ /* Increment number of open sessions. */
+ pRemoteDebugInfo->ulNumSessionsOpen--;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tlv.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tlv.c
new file mode 100644
index 0000000..759fc7d
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tlv.c
@@ -0,0 +1,2033 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tone_detection.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tone_detection.c
new file mode 100644
index 0000000..fdcfd7a
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tone_detection.c
@@ -0,0 +1,1002 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ToneDetectionEnableDef(
+ tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable )
+{
+ f_pToneDetectEnable->ulChannelHndl = cOCT6100_INVALID_HANDLE;
+ f_pToneDetectEnable->ulToneNumber = cOCT6100_INVALID_TONE;
+
+ return cOCT6100_ERR_OK;
+}
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+UINT32 Oct6100ToneDetectionDisable(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable )
+{
+ 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 = Oct6100ToneDetectionDisableSer( f_pApiInstance, f_pToneDetectDisable );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ToneDetectionEnableSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable )
+{
+ UINT32 ulChanIndex;
+ UINT32 ulExtToneChanIndex;
+ UINT32 ulToneEventNumber;
+
+ 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsi_cnct.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsi_cnct.c
new file mode 100644
index 0000000..f4887ce
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsi_cnct.c
@@ -0,0 +1,989 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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"
+
+/**************************** PUBLIC FUNCTIONS ****************************/
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100TsiCnctOpen
+
+Description: This function opens a TSI connection between two TDM timeslots.
+
+-------------------------------------------------------------------------------
+| 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_pTsiCnctOpen Pointer to TSI connection open structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100TsiCnctOpenDef(
+ tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen )
+{
+ f_pTsiCnctOpen->pulTsiCnctHndl = NULL;
+
+ f_pTsiCnctOpen->ulInputTimeslot = cOCT6100_INVALID_TIMESLOT;
+ f_pTsiCnctOpen->ulInputStream = cOCT6100_INVALID_STREAM;
+ f_pTsiCnctOpen->ulOutputTimeslot = cOCT6100_INVALID_TIMESLOT;
+ f_pTsiCnctOpen->ulOutputStream = cOCT6100_INVALID_STREAM;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100TsiCnctOpen(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen )
+{
+ 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 = Oct6100TsiCnctOpenSer( f_pApiInstance, f_pTsiCnctOpen );
+ }
+ 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: Oct6100TsiCnctClose
+
+Description: This function closes a TSI connection.
+
+-------------------------------------------------------------------------------
+| 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_pTsiCnctClose Pointer to TSI connection close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100TsiCnctCloseDef(
+ tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose )
+{
+ f_pTsiCnctClose->ulTsiCnctHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100TsiCnctClose(
+ tPOCT6100_INSTANCE_API f_pApiInstance,
+ tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose )
+{
+ 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 = Oct6100TsiCnctCloseSer( f_pApiInstance, f_pTsiCnctClose );
+ }
+ 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: 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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100TsiCnctOpenSer
+
+Description: Opens a TSI connection.
+
+-------------------------------------------------------------------------------
+| 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_pTsiCnctOpen Pointer to a tOCT6100_TSI_CNCT_OPEN structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100TsiCnctOpenSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen )
+{
+ UINT16 usTsiChanIndex;
+ UINT16 usTsiMemIndex;
+ UINT16 usInputTsstIndex;
+ UINT16 usOutputTsstIndex;
+ UINT32 ulResult;
+
+ /* Check the user's configuration of the TSI connection open structure for errors. */
+ ulResult = Oct6100ApiCheckTsiParams( f_pApiInstance, f_pTsiCnctOpen );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Reserve all resources needed by the TSI connection. */
+ ulResult = Oct6100ApiReserveTsiResources( f_pApiInstance, f_pTsiCnctOpen, &usTsiChanIndex, &usTsiMemIndex, &usInputTsstIndex, &usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Write all necessary structures to activate the TSI connection. */
+ ulResult = Oct6100ApiWriteTsiStructs( f_pApiInstance, f_pTsiCnctOpen, usTsiMemIndex, usInputTsstIndex, usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Update the TSI connection entry in the API list. */
+ ulResult = Oct6100ApiUpdateTsiEntry( f_pApiInstance, f_pTsiCnctOpen, usTsiChanIndex, usTsiMemIndex, usInputTsstIndex, usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiCheckTsiParams
+
+Description: Checks the user's TSI connection 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_pTsiCnctOpen Pointer to TSI connection open configuration structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiCheckTsiParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen )
+{
+ UINT32 ulResult;
+
+ /* Check for errors. */
+ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxTsiCncts == 0 )
+ return cOCT6100_ERR_TSI_CNCT_DISABLED;
+
+ if ( f_pTsiCnctOpen->pulTsiCnctHndl == NULL )
+ return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE;
+
+ /* Check the input TDM streams, timeslots component for errors. */
+ ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
+ cOCT6100_NUMBER_TSSTS_1,
+ f_pTsiCnctOpen->ulInputTimeslot,
+ f_pTsiCnctOpen->ulInputStream,
+ cOCT6100_INPUT_TSST );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
+ {
+ return cOCT6100_ERR_TSI_CNCT_INPUT_TIMESLOT;
+ }
+ else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
+ {
+ return cOCT6100_ERR_TSI_CNCT_INPUT_STREAM;
+ }
+ else
+ {
+ return ulResult;
+ }
+ }
+
+ /* Check the output TDM streams, timeslots component for errors. */
+ ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
+ cOCT6100_NUMBER_TSSTS_1,
+ f_pTsiCnctOpen->ulOutputTimeslot,
+ f_pTsiCnctOpen->ulOutputStream,
+ cOCT6100_OUTPUT_TSST );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
+ {
+ return cOCT6100_ERR_TSI_CNCT_OUTPUT_TIMESLOT;
+ }
+ else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
+ {
+ return cOCT6100_ERR_TSI_CNCT_OUTPUT_STREAM;
+ }
+ else
+ {
+ return ulResult;
+ }
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveTsiResources
+
+Description: Reserves all resources needed for the new TSI connection.
+
+-------------------------------------------------------------------------------
+| 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_pTsiCnctOpen Pointer to tsi channel configuration structure.
+f_pusTsiChanIndex Allocated entry in TSI channel list.
+f_pusTsiMemIndex Allocated entry in the TSI control memory.
+f_pusInputTsstIndex TSST memory index of the input samples.
+f_pusOutputTsstIndex TSST memory index of the output samples.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ UINT32 ulResult;
+ UINT32 ulTempVar;
+ BOOL fTsiChanEntry = FALSE;
+ BOOL fTsiMemEntry = FALSE;
+ BOOL fInputTsst = FALSE;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Reserve an entry in the TSI connection list. */
+ ulResult = Oct6100ApiReserveTsiCnctEntry( f_pApiInstance, f_pusTsiChanIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fTsiChanEntry = TRUE;
+
+ /* Find a TSI memory entry. */
+ ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, f_pusTsiMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fTsiMemEntry = TRUE;
+
+ /* Reserve the input TSST entry. */
+ ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
+ f_pTsiCnctOpen->ulInputTimeslot,
+ f_pTsiCnctOpen->ulInputStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_INPUT_TSST,
+ f_pusInputTsstIndex,
+ NULL );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ fInputTsst = TRUE;
+
+ /* Reserve the output TSST entry. */
+ ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
+ f_pTsiCnctOpen->ulOutputTimeslot,
+ f_pTsiCnctOpen->ulOutputStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_OUTPUT_TSST,
+ f_pusOutputTsstIndex,
+ NULL );
+ }
+ }
+ else
+ {
+ /* Return an error other then a fatal. */
+ ulResult = cOCT6100_ERR_TSI_CNCT_NO_MORE_TSI_AVAILABLE;
+ }
+ }
+
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if( fTsiChanEntry == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsiCnctEntry( f_pApiInstance, *f_pusTsiChanIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if( fTsiMemEntry == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, *f_pusTsiMemIndex );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ if( fInputTsst == TRUE )
+ {
+ ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
+ f_pTsiCnctOpen->ulInputTimeslot,
+ f_pTsiCnctOpen->ulInputStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_INPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulTempVar != cOCT6100_ERR_OK )
+ return ulTempVar;
+ }
+
+ return ulResult;
+ }
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiWriteTsiStructs
+
+Description: Performs all the required structure writes to configure the
+ new TSI connection.
+
+-------------------------------------------------------------------------------
+| 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_pTsiCnctOpen Pointer to tsi connection open structure.
+f_usTsiMemIndex Allocated entry in the TSI control memory.
+f_usInputTsstIndex TSST memory index of the input samples.
+f_usOutputTsstIndex TSST memory index of the output samples.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*==================================================================================*/
+ /* Configure the TSST control memory.*/
+
+ /* Set the input TSST control entry.*/
+ ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
+ f_usInputTsstIndex,
+ f_usTsiMemIndex,
+ cOCT6100_PCM_U_LAW );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Set the output TSST control entry. */
+ ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
+ f_usOutputTsstIndex,
+ cOCT6100_ADPCM_IN_LOW_BITS,
+ 1,
+ f_usTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*==================================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiUpdateTsiEntry
+
+Description: Updates the new TSI connection in the TSI connection 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_pTsiCnctOpen Pointer to TSI connection open configuration structure.
+f_usTsiMemIndex Allocated entry in TSI chariot memory.
+f_usTsiChanIndex Allocated entry in the TSI channel list.
+f_usInputTsstIndex TSST control memory index of the input TSST.
+f_usOutputTsstIndex TSST control memory index of the output TSST.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_API_TSI_CNCT pTsiCnctEntry;
+
+ /*================================================================================*/
+ /* Obtain a pointer to the new TSI connection's list entry. */
+
+ mOCT6100_GET_TSI_CNCT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsiCnctEntry, f_usTsiChanIndex )
+
+ /* Copy the TSI's configuration and allocated resources. */
+ pTsiCnctEntry->usInputTimeslot = (UINT16)( f_pTsiCnctOpen->ulInputTimeslot & 0xFFFF );
+ pTsiCnctEntry->usInputStream = (UINT16)( f_pTsiCnctOpen->ulInputStream & 0xFFFF );
+
+ pTsiCnctEntry->usOutputTimeslot = (UINT16)( f_pTsiCnctOpen->ulOutputTimeslot & 0xFFFF );
+ pTsiCnctEntry->usOutputStream = (UINT16)( f_pTsiCnctOpen->ulOutputStream & 0xFFFF );
+
+ /* Store hardware related information. */
+ pTsiCnctEntry->usTsiMemIndex = f_usTsiMemIndex;
+ pTsiCnctEntry->usInputTsstIndex = f_usInputTsstIndex;
+ pTsiCnctEntry->usOutputTsstIndex = f_usOutputTsstIndex;
+
+ /* Form handle returned to user. */
+ *f_pTsiCnctOpen->pulTsiCnctHndl = cOCT6100_HNDL_TAG_TSI_CNCT | (pTsiCnctEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usTsiChanIndex;
+
+ /* Finally, mark the connection as opened. */
+ pTsiCnctEntry->fReserved = TRUE;
+
+ /* Increment the number of TSI connection opened. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberTsiCncts++;
+
+ /*================================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100TsiCnctCloseSer
+
+Description: Closes a TSI connection.
+
+-------------------------------------------------------------------------------
+| 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_pTsiCnctClose Pointer to TSI connection close structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100TsiCnctCloseSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose )
+{
+ UINT16 usTsiChanIndex;
+ UINT16 usTsiMemIndex;
+ UINT16 usInputTsstIndex;
+ UINT16 usOutputTsstIndex;
+ UINT32 ulResult;
+
+ /* Verify that all the parameters given match the state of the API. */
+ ulResult = Oct6100ApiAssertTsiParams( f_pApiInstance, f_pTsiCnctClose, &usTsiChanIndex, &usTsiMemIndex, &usInputTsstIndex, &usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the TSI channel. */
+ ulResult = Oct6100ApiInvalidateTsiStructs( f_pApiInstance, usInputTsstIndex, usOutputTsstIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Release all resources associated to the TSI connection. */
+ ulResult = Oct6100ApiReleaseTsiResources( f_pApiInstance, usTsiChanIndex, usTsiMemIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Invalidate the handle. */
+ f_pTsiCnctClose->ulTsiCnctHndl = cOCT6100_INVALID_HANDLE;
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiAssertTsiParams
+
+Description: Validate the handle given by the user and verify the state of
+ the TSI connection about to be closed.
+ Also returns all required information to deactivate the connection.
+
+-------------------------------------------------------------------------------
+| 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_pTsiCnctClose Pointer to TSI connection close structure.
+f_pusTsiChanIndex Index of the TSI connection structure in the API list.
+f_pusTsiMemIndex Index of the TSI entry within the TSI chariot memory
+f_pusInputTsstIndex Index of the input entry in the TSST control memory.
+f_pusOutputTsstIndex Index of the output entry in the TSST control memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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 )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_TSI_CNCT pTsiEntry;
+ UINT32 ulEntryOpenCnt;
+
+ /* Get local pointer(s). */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ /* Check the provided handle. */
+ if ( (f_pTsiCnctClose->ulTsiCnctHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_TSI_CNCT )
+ return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE;
+
+ *f_pusTsiChanIndex = (UINT16)( f_pTsiCnctClose->ulTsiCnctHndl & cOCT6100_HNDL_INDEX_MASK );
+
+ if ( *f_pusTsiChanIndex >= pSharedInfo->ChipConfig.usMaxTsiCncts )
+ return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE;
+
+ /*=======================================================================*/
+ /* Get a pointer to the channel's list entry. */
+
+ mOCT6100_GET_TSI_CNCT_ENTRY_PNT( pSharedInfo, pTsiEntry, *f_pusTsiChanIndex )
+
+ /* Extract the entry open count from the provided handle. */
+ ulEntryOpenCnt = (f_pTsiCnctClose->ulTsiCnctHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
+
+ /* Check for errors. */
+ if ( pTsiEntry->fReserved != TRUE )
+ return cOCT6100_ERR_TSI_CNCT_NOT_OPEN;
+ if ( ulEntryOpenCnt != pTsiEntry->byEntryOpenCnt )
+ return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE;
+
+ /* Return info needed to close the channel and release all resources. */
+ *f_pusInputTsstIndex = pTsiEntry->usInputTsstIndex;
+ *f_pusOutputTsstIndex = pTsiEntry->usOutputTsstIndex;
+ *f_pusTsiMemIndex = pTsiEntry->usTsiMemIndex;
+
+ /*=======================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiInvalidateTsiStructs
+
+Description: This function closes a TSI connection.
+
+-------------------------------------------------------------------------------
+| 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_usInputTsstIndex Index of the input entry in the TSST control memory.
+f_usOutputTsstIndex Index of the output entry in the TSST control memory.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiInvalidateTsiStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usInputTsstIndex,
+ IN UINT16 f_usOutputTsstIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tOCT6100_WRITE_PARAMS WriteParams;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
+
+ WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
+
+ /*==================================================================================*/
+ /* Deactivate the TSST control memory. */
+
+ /* Set the input TSST control entry to unused. */
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usInputTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = 0x0000;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /* Set the output TSST control entry to unused. */
+ WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usOutputTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
+
+ WriteParams.usWriteData = 0x0000;
+ mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
+ if ( ulResult != cOCT6100_ERR_OK )
+ return ulResult;
+
+ /*==================================================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseTsiResources
+
+Description: Release and clear the API entry associated to the TSI 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_usTsiChanIndex Index of the TSI connection in the API list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseTsiResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usTsiChanIndex,
+ IN UINT16 f_usTsiMemIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ tPOCT6100_API_TSI_CNCT pTsiEntry;
+ UINT32 ulResult;
+
+ /* Obtain local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_TSI_CNCT_ENTRY_PNT( pSharedInfo, pTsiEntry, f_usTsiChanIndex );
+
+ /* Release the entry in the TSI connection list. */
+ ulResult = Oct6100ApiReleaseTsiCnctEntry( f_pApiInstance, f_usTsiChanIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, f_usTsiMemIndex );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Release the input entry. */
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ pTsiEntry->usInputTimeslot,
+ pTsiEntry->usInputStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_INPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ if ( ulResult == cOCT6100_ERR_OK )
+ {
+ /* Release the output TSST entry. */
+ ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
+ pTsiEntry->usOutputTimeslot,
+ pTsiEntry->usOutputStream,
+ cOCT6100_NUMBER_TSSTS_1,
+ cOCT6100_OUTPUT_TSST,
+ cOCT6100_INVALID_INDEX );
+ }
+ }
+ }
+
+ /* Check if an error occured while releasing the reserved resources. */
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult >= cOCT6100_ERR_FATAL )
+ return ulResult;
+ else
+ return cOCT6100_ERR_FATAL_4A;
+ }
+
+ /*=============================================================*/
+ /* Update the TSI connection's list entry. */
+
+ /* Mark the connection as closed. */
+ pTsiEntry->fReserved = FALSE;
+ pTsiEntry->byEntryOpenCnt++;
+
+ /* Decrement the number of TSI connection opened. */
+ f_pApiInstance->pSharedInfo->ChipStats.usNumberTsiCncts--;
+
+ /*=============================================================*/
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReserveTsiCnctEntry
+
+Description: Reserves one of the TSI connection 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_pusTsiChanIndex Resulting index reserved in the TSI channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReserveTsiCnctEntry(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusTsiChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pTsiChanAlloc;
+ UINT32 ulResult;
+ UINT32 ulTsiIndex;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChanAlloc )
+
+ ulResult = OctapiLlmAllocAlloc( pTsiChanAlloc, &ulTsiIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
+ return cOCT6100_ERR_TSI_CNCT_ALL_CHANNELS_ARE_OPENED;
+ else
+ return cOCT6100_ERR_FATAL_4B;
+ }
+
+ *f_pusTsiChanIndex = (UINT16)( ulTsiIndex & 0xFFFF );
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100ApiReleaseTsiCnctEntry
+
+Description: Releases the specified TSI connection 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_usTsiChanIndex Index reserved in the TSI channel list.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100ApiReleaseTsiCnctEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usTsiChanIndex )
+{
+ tPOCT6100_SHARED_INFO pSharedInfo;
+ PVOID pTsiChanAlloc;
+ UINT32 ulResult;
+
+ /* Get local pointer to shared portion of instance. */
+ pSharedInfo = f_pApiInstance->pSharedInfo;
+
+ mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChanAlloc )
+
+ ulResult = OctapiLlmAllocDealloc( pTsiChanAlloc, f_usTsiChanIndex );
+ if ( ulResult != cOCT6100_ERR_OK )
+ {
+ return cOCT6100_ERR_FATAL_4C;
+ }
+
+ return cOCT6100_ERR_OK;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsst.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsst.c
new file mode 100644
index 0000000..8804874
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_tsst.c
@@ -0,0 +1,565 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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).
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+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;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_user.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_user.c
new file mode 100644
index 0000000..24f99f9
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_user.c
@@ -0,0 +1,474 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: oct6100_user.c
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ This file contains the functions provided 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: 27 $
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+
+
+/***************************** INCLUDE FILES *******************************/
+
+
+#include "oct6100api/oct6100_apiud.h"
+#include "oct6100api/oct6100_errors.h"
+
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserGetTime
+
+Description: Returns the system time in us.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pTime Pointer to structure in which the time is returned.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserGetTime(
+ IN OUT tPOCT6100_GET_TIME f_pTime )
+{
+
+ return cOCT6100_ERR_OK;
+}
+
+
+
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserMemSet
+
+Description: Sets f_ulLength bytes pointed to by f_pAddress to f_ulPattern.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+
+f_pAddress Address in host memory where data should be set.
+f_ulPattern Pattern to apply at the address. This value will never
+ exceed 0xFF.
+f_ulLength Length in bytes to set.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserMemSet(
+ IN PVOID f_pAddress,
+ IN UINT32 f_ulPattern,
+ IN UINT32 f_ulLength )
+{
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserMemCopy
+
+Description: Copy f_ulLength bytes from f_pSource to f_pDestination.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+
+f_pDestination Host data destination address.
+f_pSource Host data source address.
+f_ulLength Length in bytes to copy.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserMemCopy(
+ IN PVOID f_pDestination,
+ IN PVOID f_pSource,
+ IN UINT32 f_ulLength )
+{
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserCreateSerializeObject
+
+Description: Creates a serialization object. The serialization object is
+ seized via the Oct6100UserSeizeSerializeObject function.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pCreate Pointer to structure in which the serialization object's
+ handle is returned.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserCreateSerializeObject(
+ IN OUT tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDestroySerializeObject
+
+Description: Destroys the indicated serialization object.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pDestroy Pointer to structure containing the handle of the
+ serialization object.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDestroySerializeObject(
+ IN tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserSeizeSerializeObject
+
+Description: Seizes the indicated serialization object.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pSeize Pointer to structure containing the handle of the
+ serialization object.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserSeizeSerializeObject(
+ IN tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserReleaseSerializeObject
+
+Description: Releases the indicated serialization object.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pRelease Pointer to structure containing the handle of the
+ serialization object.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserReleaseSerializeObject(
+ IN tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverWriteApi
+
+Description: Performs a write access to the chip. This function is
+ accessible only from the API code entity (i.e. not from the
+ APIMI code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pWriteParams Pointer to structure containing the Params to the
+ write function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverWriteApi(
+ IN tPOCT6100_WRITE_PARAMS f_pWriteParams )
+{
+
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverWriteOs
+
+Description: Performs a write access to the chip. This function is
+ accessible only from the APIMI code entity (i.e. not from the
+ API code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pWriteParams Pointer to structure containing the Params to the
+ write function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverWriteOs(
+ IN tPOCT6100_WRITE_PARAMS f_pWriteParams )
+{
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverWriteSmearApi
+
+Description: Performs a series of write accesses to the chip. The same data
+ word is written to a series of addresses. The writes begin at
+ the start address, and the address is incremented by the
+ indicated amount for each subsequent write. This function is
+ accessible only from the API code entity (i.e. not from the
+ APIMI code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pSmearParams Pointer to structure containing the parameters to the
+ write smear function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverWriteSmearApi(
+ IN tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams )
+{
+
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverWriteSmearOs
+
+Description: Performs a series of write accesses to the chip. The same data
+ word is written to a series of addresses. The writes begin at
+ the start address, and the address is incremented by the
+ indicated amount for each subsequent write. This function is
+ accessible only from the APIMI code entity (i.e. not from the
+ API code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pSmearParams Pointer to structure containing the parameters to the
+ write smear function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverWriteSmearOs(
+ IN tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverWriteBurstApi
+
+Description: Performs a series of write accesses to the chip. An array of
+ data words is written to a series of consecutive addresses.
+ The writes begin at the start address with element 0 of the
+ provided array as the data word. The address is incremented by
+ two for each subsequent write. This function is accessible only
+ from the API code entity (i.e. not from the APIMI code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pBurstParams Pointer to structure containing the parameters to the
+ write burst function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverWriteBurstApi(
+ IN tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams )
+{
+
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverWriteBurstOs
+
+Description: Performs a series of write accesses to the chip. An array of
+ data words is written to a series of consecutive addresses.
+ The writes begin at the start address with element 0 of the
+ provided array as the data word. The address is incremented by
+ two for each subsequent write. This function is accessible only
+ from the API code entity (i.e. not from the APIMI code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pBurstParams Pointer to structure containing the parameters to the
+ write burst function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverWriteBurstOs(
+ IN tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverReadApi
+
+Description: Performs a read access to the chip. This function is accessible
+ only from the API code entity (i.e. not from the APIMI code
+ entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pReadParams Pointer to structure containing the parameters to the
+ read function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverReadApi(
+ IN OUT tPOCT6100_READ_PARAMS f_pReadParams )
+{
+
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverReadOs
+
+Description: Performs a read access to the chip. This function is accessible
+ only from the APIMI code entity (i.e. not from the API code
+ entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pReadParams Pointer to structure containing the parameters to the
+ read function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverReadOs(
+ IN OUT tPOCT6100_READ_PARAMS f_pReadParams )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverReadBurstApi
+
+Description: Performs a burst of read accesses to the chip. The first read
+ is performed at the start address, and the address is
+ incremented by two for each subsequent read. The data is
+ retunred in an array provided by the user. This function is
+ accessible only from the API code entity (i.e. not from the
+ APIMI code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pBurstParams Pointer to structure containing the parameters to the
+ read burst function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverReadBurstApi(
+ IN OUT tPOCT6100_READ_BURST_PARAMS f_pBurstParams )
+{
+
+
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100UserDriverReadBurstOs
+
+Description: Performs a burst of read accesses to the chip. The first read
+ is performed at the start address, and the address is
+ incremented by two for each subsequent read. The data is
+ retunred in an array provided by the user. This function is
+ accessible only from the APIMI code entity (i.e. not from the
+ API code entity).
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pBurstParams Pointer to structure containing the parameters to the
+ read burst function.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100UserDriverReadBurstOs(
+ IN OUT tPOCT6100_READ_BURST_PARAMS f_pBurstParams )
+{
+
+
+ return cOCT6100_ERR_OK;
+}
+
+
+
+
+
+
+
diff --git a/software/octdeviceapi/oct6100api/oct6100_apimi/oct6100_mask_interrupts.c b/software/octdeviceapi/oct6100api/oct6100_apimi/oct6100_mask_interrupts.c
new file mode 100644
index 0000000..38caff4
--- /dev/null
+++ b/software/octdeviceapi/oct6100api/oct6100_apimi/oct6100_mask_interrupts.c
@@ -0,0 +1,116 @@
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+File: oct6100_mask_interrupts.c
+
+ Copyright (c) 2001-2005 Octasic Inc.
+
+Description:
+
+ This file contains the mask interrupts function.
+
+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 $
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+
+
+/***************************** INCLUDE FILES *******************************/
+
+#include "oct6100api/oct6100_apimi.h"
+#include "oct6100api/oct6100_apiud.h"
+#include "oct6100api/oct6100_errors.h"
+#include "oct6100api/oct6100_defines.h"
+
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
+
+Function: Oct6100InterruptMask
+
+Description: 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
+ signaled interrupt is treated). Which chip is to have its
+ interrupts masked is determined by the mask structure,
+ f_pInterruptMask.
+
+-------------------------------------------------------------------------------
+| Argument | Description
+-------------------------------------------------------------------------------
+f_pInterruptMask Pointer to the interrupt masking structure.
+
+\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+UINT32 Oct6100InterruptMaskDef(
+ OUT tPOCT6100_INTERRUPT_MASK f_pInterruptMask )
+{
+ f_pInterruptMask->ulUserChipIndex = cOCT6100_INVALID_VALUE;
+ f_pInterruptMask->pProcessContext = NULL;
+
+
+ return cOCT6100_ERR_OK;
+}
+
+UINT32 Oct6100InterruptMask(
+ IN tPOCT6100_INTERRUPT_MASK f_pInterruptMask )
+{
+ tOCT6100_WRITE_PARAMS WriteParams;
+ tOCT6100_READ_PARAMS ReadParams;
+ UINT32 result;
+ UINT16 usReadData;
+
+ /* Determine if the chip's interrupt pin is active.*/
+ ReadParams.ulReadAddress = 0x210;
+ ReadParams.pusReadData = &usReadData;
+ ReadParams.pProcessContext = f_pInterruptMask->pProcessContext;
+
+ ReadParams.ulUserChipId = f_pInterruptMask->ulUserChipIndex;
+
+ result = Oct6100UserDriverReadOs( &ReadParams );
+ if ( result != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_INTRPTS_RW_ERROR;
+
+ if ( (usReadData & 0xFFFF) != 0 )
+ {
+ /* Chip's interrupt pin is active, so mask interrupt pin. */
+ ReadParams.ulReadAddress = 0x214;
+ result = Oct6100UserDriverReadOs( &ReadParams );
+ if ( result != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_INTRPTS_RW_ERROR;
+
+ /* Determine if the chip's interrupt pin is active. */
+ WriteParams.pProcessContext = f_pInterruptMask->pProcessContext;
+
+ WriteParams.ulUserChipId = f_pInterruptMask->ulUserChipIndex;
+ WriteParams.ulWriteAddress = 0x214;
+ WriteParams.usWriteData = (UINT16)( (usReadData & 0xC000) | 0x3FFF );
+
+ result = Oct6100UserDriverWriteOs( &WriteParams );
+ if ( result != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_INTRPTS_RW_ERROR;
+
+ WriteParams.ulWriteAddress = 0x212;
+ WriteParams.usWriteData = 0x8000;
+
+ result = Oct6100UserDriverWriteOs( &WriteParams );
+ if ( result != cOCT6100_ERR_OK )
+ return cOCT6100_ERR_INTRPTS_RW_ERROR;
+
+ return cOCT6100_ERR_OK;
+ }
+
+ return cOCT6100_ERR_INTRPTS_NOT_ACTIVE;
+}
diff --git a/software/octdeviceapi/oct6100api/oct6100_channel_priv.h b/software/octdeviceapi/oct6100api/oct6100_channel_priv.h
new file mode 100644
index 0000000..4ec209c
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulChannelListOfst );
+
+#define mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_CHANNEL )(( UINT32 )pSharedInfo + pSharedInfo->ulChannelListOfst)) + ulIndex;
+
+#define mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulChannelAllocOfst);
+
+#define mOCT6100_GET_BIDIR_CHANNEL_LIST_PNT( pSharedInfo, pList ) \
+ pList = ( tPOCT6100_API_BIDIR_CHANNEL )(( UINT32 )pSharedInfo + pSharedInfo->ulBiDirChannelListOfst );
+
+#define mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_BIDIR_CHANNEL )(( UINT32 )pSharedInfo + pSharedInfo->ulBiDirChannelListOfst)) + ulIndex;
+
+#define mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )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 *****************************/
+
+UINT32 Oct6100ApiGetChannelsEchoSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+UINT32 Oct6100ApiChannelsEchoSwInit(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ChannelOpenSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen );
+
+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 );
+
+UINT32 Oct6100ApiReserveChannelResources(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
+ IN OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf );
+
+UINT32 Oct6100ApiWriteChannelStructs(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
+ IN tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf );
+
+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 );
+
+UINT32 Oct6100ChannelModifySer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify );
+
+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 );
+
+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 );
+
+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 );
+
+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 );
+
+UINT32 Oct6100ChannelBroadcastTsstRemoveSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove);
+
+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 );
+
+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 );
+
+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 );
+
+UINT32 Oct6100ApiReserveEchoEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusEchoIndex );
+
+UINT32 Oct6100ApiReleaseEchoEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usEchoChanIndex );
+
+UINT32 Oct6100ApiCheckTdmConfig(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig );
+
+UINT32 Oct6100ApiCheckVqeConfig(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
+ IN BOOL f_fEnableToneDisabler );
+
+UINT32 Oct6100ApiCheckCodecConfig(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHANNEL_OPEN_CODEC f_pCodecConfig,
+ IN UINT32 f_ulDecoderNumTssts,
+ OUT PUINT16 f_pusPhasingTsstIndex );
+
+UINT32 Oct6100ApiWriteInputTsstControlMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usTsstIndex,
+ IN UINT16 f_usTsiMemIndex,
+ IN UINT32 f_ulTsstInputLaw );
+
+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 );
+
+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 );
+
+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 );
+
+
+UINT32 Oct6100ApiClearConversionMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usConversionMemIndex );
+
+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 );
+
+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 );
+
+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 );
+
+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 );
+
+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 );
+
+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 );
+
+UINT32 Oct6100ApiDebugChannelOpen(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+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 );
+
+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 );
+
+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 );
+
+UINT16 Oct6100ApiDbAmpHalfToOctFloat(
+ IN INT32 x );
+
+#endif /* __OCT6100_CHANNEL_PRIV_H__ */
diff --git a/software/octdeviceapi/oct6100api/oct6100_chip_open_priv.h b/software/octdeviceapi/oct6100api/oct6100_chip_open_priv.h
new file mode 100644
index 0000000..90c6841
--- /dev/null
+++ b/software/octdeviceapi/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 *****************************/
+
+UINT32 Oct6100ApiCheckChipConfiguration(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip );
+
+UINT32 Oct6100ApiCopyChipConfiguration(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip );
+
+UINT32 Oct6100ApiInitializeMiscellaneousVariables(
+ IN OUT tPOCT6100_INSTANCE_API f_pInstance );
+
+UINT32 Oct6100ApiCalculateInstanceSizes(
+ IN OUT tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstanceSizes );
+
+UINT32 Oct6100ApiAllocateInstanceMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pInstance,
+ IN tPOCT6100_API_INSTANCE_SIZES f_pInstanceSizes );
+
+UINT32 Oct6100ApiInitializeInstanceMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pInstance );
+
+UINT32 Oct6100ApiGetChipRevisionNum(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiMapExternalMemory(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiDecodeKeyAndBist(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiBootFc2Pll(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiProgramFc1Pll(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiBootFc1Pll(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiWriteH100Registers(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiExternalMemoryBist(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiExternalMemoryInit(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiLoadImage(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiCpuRegisterBist(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiBootSdram(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiEnableClocks(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiProgramNLP(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiSetH100Register(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiWriteMiscellaneousRegisters(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT16 Oct6100ApiGenerateNumber(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulIndex,
+ IN UINT32 f_ulDataMask );
+
+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 );
+
+UINT32 Oct6100ApiUserIoTest(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiCreateSerializeObjects(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulUserChipId );
+
+UINT32 Oct6100ApiDestroySerializeObjects(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiRunEgo(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN BOOL f_fStoreFlag,
+ IN UINT32 f_ulNumEntry,
+ OUT PUINT32 f_aulEntry );
+
+UINT32 Oct6100ApiCreateEgoEntry(
+ IN OUT UINT32 f_ulExternalAddress,
+ IN UINT32 f_ulInternalAddress,
+ IN UINT32 f_ulNumBytes,
+ IN UINT32 f_aulEntry[ 2 ] );
+
+
+
+
+
+UINT32 Oct6100ApiInitChannels(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiInitMixer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+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 );
+
+UINT32 Oct6100ApiProductionCrc(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN PUINT32 f_pulMessage,
+ IN UINT32 f_ulMessageLength,
+ OUT PUINT32 f_pulCrcResult );
+
+UINT32 Oct6100ApiInitToneInfo(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+#endif /* __OCT6100_CHIP_OPEN_PRIV_H__ */
diff --git a/software/octdeviceapi/oct6100api/oct6100_chip_stats_priv.h b/software/octdeviceapi/oct6100api/oct6100_chip_stats_priv.h
new file mode 100644
index 0000000..058aa8f
--- /dev/null
+++ b/software/octdeviceapi/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 *****************************/
+
+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/software/octdeviceapi/oct6100api/oct6100_conf_bridge_priv.h b/software/octdeviceapi/oct6100api/oct6100_conf_bridge_priv.h
new file mode 100644
index 0000000..11506c2
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulConfBridgeListOfst);
+
+#define mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_CONF_BRIDGE )(( UINT32 )pSharedInfo + pSharedInfo->ulConfBridgeListOfst)) + ulIndex;
+
+#define mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulConfBridgeAllocOfst);
+
+#define mOCT6100_GET_FLEX_CONF_PARTICIPANT_LIST_PNT( pSharedInfo, pList ) \
+ pList = ( tPOCT6100_API_FLEX_CONF_PARTICIPANT )(( UINT32 )pSharedInfo + pSharedInfo->ulFlexConfParticipantListOfst);
+
+#define mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_FLEX_CONF_PARTICIPANT )(( UINT32 )pSharedInfo + pSharedInfo->ulFlexConfParticipantListOfst)) + ulIndex;
+
+#define mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulFlexConfParticipantAllocOfst);
+
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetConfBridgeSwSizes(
+ IN OUT tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+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 );
+
+UINT32 Oct6100ConfBridgeCloseSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInst,
+ IN tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose );
+
+UINT32 Oct6100ApiAssertBridgeParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInst,
+ IN tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose,
+ OUT PUINT16 f_pusBridgeIndex );
+
+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 );
+
+UINT32 Oct6100ConfBridgeChanRemoveSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInst,
+ IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove );
+
+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 );
+
+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 );
+
+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 );
+
+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 );
+
+UINT32 Oct6100ApiReleaseBridgeEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInst,
+ IN UINT16 f_usConfBridgeIndex );
+
+UINT32 Oct6100ApiGetPrevLastSubStoreEvent(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInst,
+ IN UINT16 f_usBridgeIndex,
+ IN UINT16 f_usBridgeFirstLoadEventPtr,
+ OUT PUINT16 f_pusLastSubStoreEventIndex );
+
+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 );
+
+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 );
+
+UINT32 Oct6100ApiReleaseFlexConfParticipantEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInst,
+ IN UINT16 f_usParticipantIndex );
+
+#endif /* __OCT6100_CONF_BRIDGE_PRIV_H__ */
diff --git a/software/octdeviceapi/oct6100api/oct6100_debug_priv.h b/software/octdeviceapi/oct6100api/oct6100_debug_priv.h
new file mode 100644
index 0000000..a00e6d2
--- /dev/null
+++ b/software/octdeviceapi/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/software/octdeviceapi/oct6100api/oct6100_events_priv.h b/software/octdeviceapi/oct6100api/oct6100_events_priv.h
new file mode 100644
index 0000000..a11b35c
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->SoftBufs.ulToneEventBufferMemOfst );
+
+#define mOCT6100_GET_BUFFER_PLAYOUT_EVENT_BUF_PNT( pSharedInfo, pSoftBuf ) \
+ pSoftBuf = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->SoftBufs.ulBufPlayoutEventBufferMemOfst );
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetEventsSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+UINT32 Oct6100EventGetToneSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_EVENT_GET_TONE f_pEventGetTone );
+
+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 );
+
+UINT32 Oct6100BufferPlayoutTransferEvents(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulResetBuf );
+
+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/software/octdeviceapi/oct6100api/oct6100_interrupts_priv.h b/software/octdeviceapi/oct6100api/oct6100_interrupts_priv.h
new file mode 100644
index 0000000..8458c03
--- /dev/null
+++ b/software/octdeviceapi/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 *****************************/
+
+UINT32 Oct6100ApiIsrSwInit(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiIsrHwInit(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig );
+
+UINT32 Oct6100InterruptConfigureSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig,
+ IN BOOL f_fCheckParams );
+
+UINT32 Oct6100InterruptServiceRoutineSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags );
+
+UINT32 Oct6100ApiWriteIeRegs(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiReadIntrptRegs(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags,
+ IN UINT32 f_ulRegister210h );
+
+UINT32 Oct6100ApiUpdateIntrptStates(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags );
+
+UINT32 Oct6100ApiWriteIntrptRegs(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiReadChipMclkTime(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiUpdateIntrptTimeouts(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiScheduleNextMclkIntrpt(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulIntrptToSet );
+
+UINT32 Oct6100ApiScheduleNextMclkIntrptSer(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiCheckProcessorState(
+ IN tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags );
+
+#endif /* __OCT6100_INTERRUPTS_PRIV_H__ */
diff --git a/software/octdeviceapi/oct6100api/oct6100_memory_priv.h b/software/octdeviceapi/oct6100api/oct6100_memory_priv.h
new file mode 100644
index 0000000..cd68107
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulTsiMemoryAllocOfst );
+
+/* Conversion memory allocation pointer macros. */
+#define mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulConversionMemoryAllocOfst );
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetMemorySwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+UINT32 Oct6100ApiMemorySwInit(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+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 );
+
+UINT32 Oct6100ApiReserveTsiMemEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusTsiMemIndex );
+
+UINT32 Oct6100ApiReleaseTsiMemEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usTsiMemIndex );
+
+UINT32 Oct6100ApiReserveConversionMemEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusConversionMemIndex );
+
+UINT32 Oct6100ApiReleaseConversionMemEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usConversionMemIndex );
+
+#endif /* __OCT6100_MEMORY_PRIV_H__ */
diff --git a/software/octdeviceapi/oct6100api/oct6100_miscellaneous_priv.h b/software/octdeviceapi/oct6100api/oct6100_miscellaneous_priv.h
new file mode 100644
index 0000000..d511674
--- /dev/null
+++ b/software/octdeviceapi/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 *****************************/
+
+UINT32 Oct6100ApiWaitForTime(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_aulWaitTime[ 2 ] );
+
+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 );
+
+UINT32 Oct6100ApiWriteDword(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulAddress,
+ IN UINT32 f_ulWriteData );
+
+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 );
+
+PUINT8 Oct6100ApiStrStr(
+ IN PUINT8 f_pszSource,
+ IN PUINT8 f_pszString,
+ IN PUINT8 f_pszLastCharPtr );
+
+UINT32 Oct6100ApiStrLen(
+ IN PUINT8 f_pszString );
+
+UINT32 Oct6100ApiAsciiToHex(
+ IN UINT8 f_chCharacter,
+ IN PUINT32 f_pulValue );
+
+UINT8 Oct6100ApiHexToAscii(
+ IN UINT32 f_ulNumber );
+
+UINT32 Oct6100ApiRand(
+ IN UINT32 f_ulRange );
+
+#endif /* __OCT6100_MISCELLANEOUS_PRIV_H__ */
diff --git a/software/octdeviceapi/oct6100api/oct6100_mixer_priv.h b/software/octdeviceapi/oct6100api/oct6100_mixer_priv.h
new file mode 100644
index 0000000..efc4b39
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulMixerEventListOfst);
+
+#define mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_MIXER_EVENT )(( UINT32 )pSharedInfo + pSharedInfo->ulMixerEventListOfst)) + ulIndex;
+
+#define mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulMixerEventAllocOfst);
+
+#define mOCT6100_GET_COPY_EVENT_LIST_PNT( pSharedInfo, pList ) \
+ pList = ( tPOCT6100_API_COPY_EVENT )(( UINT32 )pSharedInfo + pSharedInfo->ulCopyEventListOfst);
+
+#define mOCT6100_GET_COPY_EVENT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_COPY_EVENT )(( UINT32 )pSharedInfo + pSharedInfo->ulCopyEventListOfst)) + ulIndex;
+
+#define mOCT6100_GET_COPY_EVENT_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulCopyEventAllocOfst);
+
+/***************************** TYPES ***************************************/
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetMixerSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+UINT32 Oct6100ApiMixerSwInit(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiMixerEventAdd(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usEventIndex,
+ IN UINT16 f_usEventType,
+ IN UINT16 f_usDestinationChanIndex );
+
+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 );
+
+UINT32 Oct6100ApiReserveMixerEventEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ OUT PUINT16 f_pusEventIndex );
+
+UINT32 Oct6100ApiReleaseMixerEventEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT16 f_usEventIndex );
+
+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/software/octdeviceapi/oct6100api/oct6100_phasing_tsst_priv.h b/software/octdeviceapi/oct6100api/oct6100_phasing_tsst_priv.h
new file mode 100644
index 0000000..37e9135
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulPhasingTsstListOfst);
+
+#define mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_PHASING_TSST )(( UINT32 )pSharedInfo + pSharedInfo->ulPhasingTsstListOfst)) + ulIndex;
+
+#define mOCT6100_GET_PHASING_TSST_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulPhasingTsstAllocOfst);
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetPhasingTsstSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+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/software/octdeviceapi/oct6100api/oct6100_playout_buf_priv.h b/software/octdeviceapi/oct6100api/oct6100_playout_buf_priv.h
new file mode 100644
index 0000000..4a11874
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulPlayoutBufListOfst );
+
+#define mOCT6100_GET_BUFFER_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_BUFFER )(( UINT32 )pSharedInfo + pSharedInfo->ulPlayoutBufListOfst)) + ulIndex;
+
+#define mOCT6100_GET_BUFFER_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulPlayoutBufAllocOfst);
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetPlayoutBufferSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+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 );
+
+UINT32 Oct6100BufferPlayoutStopSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop );
+
+UINT32 Oct6100ApiAssertPlayoutStopParams(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop,
+ OUT PUINT32 f_pulChannelIndex,
+ OUT PUINT16 f_pusEchoMemIndex );
+
+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/software/octdeviceapi/oct6100api/oct6100_remote_debug_priv.h b/software/octdeviceapi/oct6100api/oct6100_remote_debug_priv.h
new file mode 100644
index 0000000..c6a42a0
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulSessionListOfst) + ulIndex;
+
+#define mOCT6100_GET_REMOTE_DEBUG_TREE_PNT( pSharedInfo, pList ) \
+ pList = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulSessionTreeOfst);
+
+#define mOCT6100_GET_REMOTE_DEBUG_DATA_BUF_PNT( pSharedInfo, pulDataBuf ) \
+ pulDataBuf = ( PUINT16 )(( UINT32 )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulDataBufOfst);
+
+#define mOCT6100_GET_REMOTE_DEBUG_SESSION_PKT_CACHE_PNT( pSharedInfo, pulPktCache, ulSessionIndex ) \
+ pulPktCache = ( PUINT32 )(( UINT32 )pSharedInfo + pSharedInfo->RemoteDebugInfo.ulPktCacheOfst) + (ulSessionIndex * (cOCTRPC_MAX_PACKET_BYTE_LENGTH / 4));
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetRemoteDebugSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+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/software/octdeviceapi/oct6100api/oct6100_tlv_priv.h b/software/octdeviceapi/oct6100api/oct6100_tlv_priv.h
new file mode 100644
index 0000000..21534df
--- /dev/null
+++ b/software/octdeviceapi/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 *****************************/
+
+UINT32 Oct6100ApiProcessTlvRegion(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+UINT32 Oct6100ApiInterpretTlvEntry(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulTlvFieldType,
+ IN UINT32 f_ulTlvFieldLength,
+ IN UINT32 f_ulTlvValueAddress );
+
+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 );
+
+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/software/octdeviceapi/oct6100api/oct6100_tone_detection_priv.h b/software/octdeviceapi/oct6100api/oct6100_tone_detection_priv.h
new file mode 100644
index 0000000..5c2ef94
--- /dev/null
+++ b/software/octdeviceapi/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 *****************************/
+
+UINT32 Oct6100ToneDetectionEnableSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable );
+
+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 );
+
+UINT32 Oct6100ApiWriteToneDetectEvent(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulChannelIndex,
+ IN UINT32 f_ulToneEventNumber,
+
+ IN UINT32 f_ulExtToneChanIndex );
+
+UINT32 Oct6100ApiUpdateChanToneDetectEntry (
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN UINT32 f_ulChannelIndex,
+ IN UINT32 f_ulToneEventNumber,
+ IN UINT32 f_ulExtToneChanIndex );
+
+UINT32 Oct6100ToneDetectionDisableSer(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
+ IN OUT tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable );
+
+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 );
+
+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 );
+
+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 );
+
+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/software/octdeviceapi/oct6100api/oct6100_tsi_cnct_priv.h b/software/octdeviceapi/oct6100api/oct6100_tsi_cnct_priv.h
new file mode 100644
index 0000000..0274c7a
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulTsiCnctListOfst );
+
+#define mOCT6100_GET_TSI_CNCT_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_TSI_CNCT )(( UINT32 )pSharedInfo + pSharedInfo->ulTsiCnctListOfst)) + ulIndex;
+
+#define mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulTsiCnctAllocOfst);
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetTsiCnctSwSizes(
+ IN tPOCT6100_CHIP_OPEN f_pOpenChip,
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+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/software/octdeviceapi/oct6100api/oct6100_tsst_priv.h b/software/octdeviceapi/oct6100api/oct6100_tsst_priv.h
new file mode 100644
index 0000000..57b323f
--- /dev/null
+++ b/software/octdeviceapi/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 )(( UINT32 )pSharedInfo + pSharedInfo->ulTsstAllocOfst);
+
+#define mOCT6100_GET_TSST_LIST_PNT( pSharedInfo, pList ) \
+ pList = ( tPOCT6100_API_TSST_ENTRY )(( UINT32 )pSharedInfo + pSharedInfo->ulTsstListOfst );
+
+#define mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pEntry, ulIndex ) \
+ pEntry = (( tPOCT6100_API_TSST_ENTRY )(( UINT32 )pSharedInfo + pSharedInfo->ulTsstListOfst)) + ulIndex;
+
+#define mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pAlloc ) \
+ pAlloc = ( PVOID )(( UINT32 )pSharedInfo + pSharedInfo->ulTsstListAllocOfst);
+
+/***************************** TYPES ***************************************/
+
+
+/************************** FUNCTION PROTOTYPES *****************************/
+
+UINT32 Oct6100ApiGetTsstSwSizes(
+ OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes );
+
+UINT32 Oct6100ApiTsstSwInit(
+ IN OUT tPOCT6100_INSTANCE_API f_pApiInstance );
+
+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 );
+
+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 );
+
+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/software/octdeviceapi/oct6100api/oct6100_version.h b/software/octdeviceapi/oct6100api/oct6100_version.h
new file mode 100644
index 0000000..31db16e
--- /dev/null
+++ b/software/octdeviceapi/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__ */