csl_vcp2.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. /* ============================================================================
  2. * Copyright (c) Texas Instruments Incorporated 2008, 2009
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the
  14. * distribution.
  15. *
  16. * Neither the name of Texas Instruments Incorporated nor the names of
  17. * its contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. */
  33. /**
  34. * @file csl_vcp2.h
  35. *
  36. * @brief
  37. * Header file with data structure and API declarations for VCP2
  38. * CSL module.
  39. *
  40. * \par
  41. * ============================================================================
  42. * @n (C) Copyright 2008, 2009, Texas Instruments, Inc.
  43. * @n Use of this software is controlled by the terms and conditions found
  44. * @n in the license agreement under which this software has been supplied.
  45. * ===========================================================================
  46. * \par
  47. */
  48. /** @defgroup CSL_VCP2_API VCP2
  49. *
  50. * @section Introduction
  51. *
  52. * @subsection xxx Overview
  53. * Channel decoding of voice and low bit-rate data channels found in cellular standards such as 2.5G, 3G,
  54. * and WiMAX requires the decoding of convolutional encoded data. The Viterbi-decoder coprocessor 2
  55. * (VCP2) provided in the TCI648x devices performs Viterbi decoding for IS2000 and 3GPP wireless
  56. * standards. The VCP2 coprocessor also performs forward-error correction for 2G and 3G wireless systems.
  57. * The VCP2 coprocessor offers a very cost effective and synergistic solution when combined with Texas
  58. * Instruments (TI) DSPs. The VCP2 supports 1941 12.2 Kbps class A 3G voice channels running at
  59. * 333 MHz.
  60. *
  61. * @subsection References
  62. * -# VCP2 User's Guide SPRUE09A.pdf (May 2006 - Revised April 2008)
  63. *
  64. */
  65. #ifndef CSL_VCP2__H
  66. #define CSL_VCP2__H
  67. #include <ti/csl/csl.h>
  68. #include <ti/csl/cslr_vcp2.h>
  69. #include <ti/csl/soc.h>
  70. /**
  71. @defgroup CSL_VCP2_SYMBOL VCP2 Symbols Defined
  72. @ingroup CSL_VCP2_API
  73. */
  74. /**
  75. @defgroup CSL_VCP2_DATASTRUCT VCP2 Data Structures
  76. @ingroup CSL_VCP2_API
  77. */
  78. /**
  79. @defgroup CSL_VCP2_FUNCTION VCP2 Functions
  80. @ingroup CSL_VCP2_API
  81. */
  82. #ifdef __cplusplus
  83. extern "C"
  84. {
  85. #endif
  86. /**
  87. @addtogroup CSL_VCP2_SYMBOL
  88. @{
  89. */
  90. /******************************************************************************
  91. * VCP Macros
  92. *****************************************************************************/
  93. /** Code rate = 2 */
  94. #define VCP2_RATE_1_2 (2U)
  95. /** Code rate = 3 */
  96. #define VCP2_RATE_1_3 (3U)
  97. /** Code rate = 4 */
  98. #define VCP2_RATE_1_4 (4U)
  99. /** Speed critical */
  100. #define VCP2_SPEED_CRITICAL (0U)
  101. /** Speed most critical */
  102. #define VCP2_SPEED_MOST_CRITICAL (1U)
  103. /** Performance critical */
  104. #define VCP2_PERF_CRITICAL (2U)
  105. /** Performance most critical */
  106. #define VCP2_PERF_MOST_CRITICAL (3U)
  107. /** Default value */
  108. #define VCP2_PERF_DEFAULT (VCP2_SPEED_CRITICAL)
  109. /** Out order of VCP output for decoded data : 0 to 31 */
  110. #define VCP2_OUTORDER_0_31 (CSL_VCP2_VCPIC3_OUT_ORDER_LSB)
  111. /** Out order of VCP output for decoded data : 31 to 0 */
  112. #define VCP2_OUTORDER_31_0 (CSL_VCP2_VCPIC3_OUT_ORDER_MSB)
  113. /** Output decision type : Hard decisions */
  114. #define VCP2_DECISION_HARD (CSL_VCP2_VCPIC5_SDHD_HARD)
  115. /** Output decision type : Soft decisions */
  116. #define VCP2_DECISION_SOFT (CSL_VCP2_VCPIC5_SDHD_SOFT)
  117. /** Output parameters read flag : VCP read event is not generated */
  118. #define VCP2_OUTF_NO (CSL_VCP2_VCPIC5_OUTF_NO)
  119. /** Output parameters read flag : VCP read event is generated */
  120. #define VCP2_OUTF_YES (CSL_VCP2_VCPIC5_OUTF_YES)
  121. /** No trace back allowed */
  122. #define VCP2_TRACEBACK_NONE (CSL_VCP2_VCPIC5_TB_NO)
  123. /** Traceback mode : Tailed */
  124. #define VCP2_TRACEBACK_TAILED (CSL_VCP2_VCPIC5_TB_TAIL)
  125. /** Traceback mode : Convergent */
  126. #define VCP2_TRACEBACK_CONVERGENT (CSL_VCP2_VCPIC5_TB_CONV)
  127. /** Traceback mode : Mixed */
  128. #define VCP2_TRACEBACK_MIXED (CSL_VCP2_VCPIC5_TB_MIX)
  129. /**
  130. * VCP unpause type : VCP restarts and processes one sliding window before
  131. * pausing again
  132. */
  133. #define VCP2_UNPAUSE_ONESW (CSL_VCP2_VCPEXE_COMMAND_RESTART_PAUSE)
  134. /** VCP unpause type : VCP restarts */
  135. #define VCP2_UNPAUSE_NORMAL (CSL_VCP2_VCPEXE_COMMAND_RESTART)
  136. /** Soft decisions memory format : 32-bit word packed */
  137. #define VCP2_END_PACKED32 (CSL_VCP2_VCPEND_SD_32BIT)
  138. /** Soft decisions memory format : Native (8 bits) */
  139. #define VCP2_END_NATIVE (CSL_VCP2_VCPEND_SD_NATIVE)
  140. /** EMU mode : VCP halts at the end of completion of the current window of
  141. * state metric processing or at the end of a frame */
  142. #define VCP2_EMUHALT_DEFAULT (CSL_VCP2_VCPEMU_SOFT_HALT_DEFAULT)
  143. /**
  144. * EMU mode : VCP halts at the end of completion of the processing of the
  145. * frame
  146. */
  147. #define VCP2_EMUHALT_FRAMEEND (CSL_VCP2_VCPEMU_SOFT_HALT_FRAMEEND)
  148. /***************************************************************************
  149. * Following are Polynomials used in GSM/Edge/GPRS
  150. **************************************************************************/
  151. /**
  152. * GSM/Edge/GPRS generator polynomial 0
  153. */
  154. #define VCP2_GEN_POLY_0 0x30
  155. /**
  156. * GSM/Edge/GPRS generator polynomial 1
  157. */
  158. #define VCP2_GEN_POLY_1 0xB0
  159. /**
  160. * GSM/Edge/GPRS generator polynomial 2
  161. */
  162. #define VCP2_GEN_POLY_2 0x50
  163. /**
  164. * GSM/Edge/GPRS generator polynomial 3
  165. */
  166. #define VCP2_GEN_POLY_3 0xF0
  167. /**
  168. * GSM/Edge/GPRS generator polynomial 4
  169. */
  170. #define VCP2_GEN_POLY_4 0x6C
  171. /**
  172. * GSM/Edge/GPRS generator polynomial 5
  173. */
  174. #define VCP2_GEN_POLY_5 0x94
  175. /**
  176. * GSM/Edge/GPRS generator polynomial 6
  177. */
  178. #define VCP2_GEN_POLY_6 0xF4
  179. /**
  180. * GSM/Edge/GPRS generator polynomial 7
  181. */
  182. #define VCP2_GEN_POLY_7 0xE4
  183. /**
  184. * NULL generator polynomial for GSM/Edge/GPRS
  185. */
  186. #define VCP2_GEN_POLY_GNULL 0x00
  187. /**
  188. @}
  189. */
  190. /** @addtogroup CSL_VCP2_DATASTRUCT
  191. @{ */
  192. /** VCP Peripheral ID structure */
  193. typedef struct
  194. {
  195. /** Peripheral type */
  196. Uint8 type;
  197. /** Peripheral class */
  198. Uint8 pid_class;
  199. /** Peripheral revision */
  200. Uint8 rev;
  201. } VCP2_PID;
  202. /**
  203. * VCP code rate type
  204. */
  205. typedef Uint32 VCP2_Rate;
  206. /**
  207. * VCP input configuration structure that holds all of the configuration
  208. * values that are to be transferred to the VCP via the EDMA.
  209. */
  210. typedef struct
  211. {
  212. /** Value of VCP input configuration register 0 */
  213. Uint32 ic0;
  214. /** Value of VCP input configuration register 1 */
  215. Uint32 ic1;
  216. /** Value of VCP input configuration register 2 */
  217. Uint32 ic2;
  218. /** Value of VCP input configuration register 3 */
  219. Uint32 ic3;
  220. /** Value of VCP input configuration register 4 */
  221. Uint32 ic4;
  222. /** Value of VCP input configuration register 5 */
  223. Uint32 ic5;
  224. } VCP2_ConfigIc;
  225. /**
  226. * VCP channel parameters structure that holds all of the information
  227. * concerning the user channel. These values are used to generate the
  228. * appropriate input configuration values for the VCP and to program
  229. * the EDMA.
  230. */
  231. typedef struct
  232. {
  233. /** Code rate */
  234. VCP2_Rate rate;
  235. /** Constraint length */
  236. Uint8 constLen;
  237. /** Polynomial 0 */
  238. Uint8 poly0;
  239. /** Polynomial 1 */
  240. Uint8 poly1;
  241. /** Polynomial 2 */
  242. Uint8 poly2;
  243. /** Polynomial 3 */
  244. Uint8 poly3;
  245. /** Yamamoto threshold value*/
  246. Uint16 yamTh;
  247. /** Frame length i.e. number of symbols in a frame*/
  248. Uint16 frameLen;
  249. /** Reliability length */
  250. Uint16 relLen;
  251. /** Convergence distance */
  252. Uint16 convDist;
  253. /** Traceback state index */
  254. Uint16 traceBackIndex;
  255. /** Traceback state index enable/disable */
  256. Bool traceBackEn;
  257. /** Hard decision output ordering */
  258. Uint16 outOrder;
  259. /** Maximum initial state metric */
  260. Int16 maxSm;
  261. /** Minimum initial state metric */
  262. Int16 minSm;
  263. /** State index set to the maximum initial state metric*/
  264. Uint8 stateNum;
  265. /** Branch metrics buffer length in input FIFO */
  266. Uint8 bmBuffLen;
  267. /** Decisions buffer length in output FIFO */
  268. Uint8 decBuffLen;
  269. /** Traceback mode */
  270. Uint8 traceBack;
  271. /** Output parameters read flag */
  272. Uint8 readFlag;
  273. /** Decision selection: hard or soft */
  274. Uint8 decision;
  275. /** Number of branch metric frames*/
  276. Uint16 numBmFrames;
  277. /** Number of decision frames */
  278. Uint16 numDecFrames;
  279. } VCP2_Params;
  280. /**
  281. * VCP base parameter structure that is used to configure the VCP parameters
  282. * structure with the given values using VCP2_genParams() function.
  283. */
  284. typedef struct
  285. {
  286. /** Code rate */
  287. VCP2_Rate rate;
  288. /** Constraint length */
  289. Uint8 constLen;
  290. /** Frame length */
  291. Uint16 frameLen;
  292. /** Yamamoto threshold value */
  293. Uint16 yamTh;
  294. /** Maximum initial state metric value */
  295. Uint8 stateNum;
  296. /** Traceback convergement mode */
  297. Bool tbConvrgMode;
  298. /** Output decision type */
  299. Uint8 decision;
  300. /** Output parameters read flag */
  301. Uint8 readFlag;
  302. /** Enable/Disable tail biting */
  303. Bool tailBitEnable;
  304. /** Tailbiting traceback index mode */
  305. Uint16 traceBackIndex;
  306. /** Hard decision output ordering */
  307. Uint8 outOrder;
  308. /** Performance and speed */
  309. Uint8 perf;
  310. } VCP2_BaseParams;
  311. /** VCP Error structure */
  312. typedef struct
  313. {
  314. /** Traceback mode error */
  315. Bool tbnaErr;
  316. /** Frame length error */
  317. Bool ftlErr;
  318. /** Reliability + convergence distance error */
  319. Bool fctlErr;
  320. /** Max-Min error */
  321. Bool maxminErr;
  322. /** SYMX error */
  323. Bool symxErr;
  324. /** SYMR error */
  325. Bool symrErr;
  326. } VCP2_Errors;
  327. /** VCP generator polynomials structure */
  328. typedef struct
  329. {
  330. /** Generator polynomial 0 */
  331. Uint8 poly0;
  332. /** Generator polynomial 1 */
  333. Uint8 poly1;
  334. /** Generator polynomial 2 */
  335. Uint8 poly2;
  336. /** Generator polynomial 3 */
  337. Uint8 poly3;
  338. } VCP2_Poly;
  339. /**************************************************************************\
  340. * Overlay structure typedef definition
  341. \**************************************************************************/
  342. typedef volatile CSL_Vcp2EdmaRegs *CSL_Vcp2RegsOvly;
  343. typedef volatile CSL_Vcp2ConfigRegs *CSL_Vcp2CfgRegsOvly;
  344. /**
  345. * This will have the base-address information for the peripheral instance
  346. */
  347. typedef struct {
  348. /** Base-address of the registers of VCP2 */
  349. CSL_Vcp2RegsOvly regs;
  350. /** Base-address of the Configuration registers of VCP2 */
  351. CSL_Vcp2CfgRegsOvly cfgregs;
  352. } VCP2BaseAddress;
  353. /**
  354. * This structure/object holds the context of the instance of VCP2
  355. * opened using VCP2_init() function.
  356. *
  357. * Pointer to this object is passed as VCP2 Handle to all VCP2 CSL APIs.
  358. * VCP2_init() function intializes this structure based on the parameters
  359. * passed
  360. */
  361. typedef struct VCP2Obj_s {
  362. /** Pointer to the register overlay structure of the Tcp2 */
  363. CSL_Vcp2RegsOvly regs;
  364. /** Pointer to the Configuration registers overlay structure of the Tcp2 */
  365. CSL_Vcp2CfgRegsOvly cfgregs;
  366. /** Instance of TCP2 being referred by this object */
  367. CSL_InstNum perNum;
  368. } VCP2Obj;
  369. /** This is a pointer to Vcp2Obj and is passed as the first
  370. * parameter to all VCP2 CSL APIs
  371. */
  372. typedef struct VCP2Obj_s *VCP2Handle;
  373. /* @} */
  374. /** @addtogroup CSL_VCP2_FUNCTION
  375. @{ */
  376. /******************************************************************************
  377. * VCP2 global function declarations
  378. *****************************************************************************/
  379. extern void VCP2_genParams (
  380. const VCP2_BaseParams * pConfigBase,
  381. VCP2_Params * pConfigParams
  382. );
  383. extern void VCP2_genIc (
  384. const VCP2_Params * pConfigParams,
  385. VCP2_ConfigIc * pConfigIc
  386. );
  387. extern VCP2Handle VCP2_init(
  388. VCP2Obj * pVcp2Obj,
  389. Int32 instNum,
  390. Int32 * pStatus
  391. );
  392. extern CSL_Status VCP2_Close (
  393. VCP2Handle hVcp2
  394. );
  395. /* @} */
  396. #ifdef __cplusplus
  397. }
  398. #endif
  399. #endif