]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/fvid2.git/blobdiff - include/fvid2_utils.h
NOTICE OF RELOCATION
[keystone-rtos/fvid2.git] / include / fvid2_utils.h
index 5b7c33cc7962a6cfe83440dc29ce2d7c76541f9c..f584a00c1c44b1f1af9dd97722b21d3c40c02c39 100755 (executable)
@@ -46,6 +46,7 @@
 /*                             Include Files                                  */
 /* ========================================================================== */
 
+#include <ti/csl/csl_types.h>
 #include <ti/osal/osal.h>
 
 #ifdef __cplusplus
@@ -60,44 +61,53 @@ extern "C" {
 #define FVID2UTILS_NUM_TIMESTAMP_LOG    (100U)
 
 /**
- *  struct Fvid2Utils_LinkListType
+ *  \anchor Fvid2Utils_LinkListType
+ *  \name Link List Type
+ *  @{
+ */
+/**
  *  \brief Enums for the type of link list to be created.
  */
-typedef enum
-{
-    FVID2UTILS_LLT_DOUBLE,
-    /**< Double link list. */
-    FVID2UTILS_LLT_CIRCULAR
-    /**< Circular link list using double link list. */
-} Fvid2Utils_LinkListType;
+typedef uint32_t Fvid2Utils_LinkListType;
+#define FVID2UTILS_LLT_DOUBLE           (0U)
+/**< Double link list. */
+#define FVID2UTILS_LLT_CIRCULAR         (1U)
+/**< Circular link list using double link list. */
+/* @} */
 
 /**
- *  struct Fvid2Utils_LinkAddMode
+ *  \anchor Fvid2Utils_LinkAddMode
+ *  \name Link Add Mode
+ *  @{
+ */
+/**
  *  \brief Enums for the different modes of adding a node to a link list.
  */
-typedef enum
-{
-    FVID2UTILS_LAM_TOP,
-    /**< Add nodes to the top of the list. */
-    FVID2UTILS_LAM_BOTTOM,
-    /**< Add nodes to the bottom of the list. */
-    FVID2UTILS_LAM_PRIORITY
-    /**< Add nodes to the list based on ascending order of priority.
-     *   Nodes with the same priority are always added to the bottom of the
-     *   existing nodes with same priority. */
-} Fvid2Utils_LinkAddMode;
-
-/**
- *  struct Fvid2Utils_LinkAddMode
+typedef uint32_t Fvid2Utils_LinkAddMode;
+#define FVID2UTILS_LAM_TOP              (0U)
+/**< Add nodes to the top of the list. */
+#define FVID2UTILS_LAM_BOTTOM           (1U)
+/**< Add nodes to the bottom of the list. */
+#define FVID2UTILS_LAM_PRIORITY         (2U)
+/**< Add nodes to the list based on ascending order of priority.
+ *   Nodes with the same priority are always added to the bottom of the
+ *   existing nodes with same priority. */
+/* @} */
+
+/**
+ *  \anchor Fvid2Utils_NodDir
+ *  \name Node Direction
+ *  @{
+ */
+/**
  *  \brief Enums for the different modes of adding a node to a link list.
  */
-typedef enum
-{
-    FVID2UTILS_NODE_DIR_HEAD,
-    /**< Add nodes to the top of the list. */
-    FVID2UTILS_NODE_DIR_TAIL
-    /**< Add nodes to the bottom of the list. */
-} Fvid2Utils_NodDir;
+typedef uint32_t Fvid2Utils_NodDir;
+#define FVID2UTILS_NODE_DIR_HEAD        (0U)
+/**< Add nodes to the top of the list. */
+#define FVID2UTILS_NODE_DIR_TAIL        (1U)
+/**< Add nodes to the bottom of the list. */
+/* @} */
 
 /* ========================================================================== */
 /*                         Structure Declarations                             */
@@ -207,6 +217,23 @@ typedef Fvid2Utils_Handle Fvid2Utils_QHandle;
 /* ========================================================================== */
 /*                          Function Declarations                             */
 /* ========================================================================== */
+/**
+ *  Fvid2Utils_init
+ *  \brief Initializes the Util objects and create pool semaphore
+ *
+ *  \returns                Returns 0 on success else returns error value
+ */
+int32_t Fvid2Utils_init(void);
+
+/**
+ *  Fvid2Utils_deInit
+ *  \brief De-Initializes the Util objects by removing pool semaphore
+ *
+ *  \param arg              Not used currently. Meant for future purpose
+ *
+ *  \return                 Returns 0 on success else returns error value
+ */
+int32_t Fvid2Utils_deInit(void *arg);
 
 /**
  *  Fvid2Utils_memset
@@ -217,9 +244,9 @@ typedef Fvid2Utils_Handle Fvid2Utils_QHandle;
  *  \param ch               Byte value to fill with.
  *  \param byteCount        Number of bytes to fill.
  *
- *  \return                 The destination memory pointer.
+ *  \return                 None.
  */
-void *Fvid2Utils_memset(void *mem, uint8_t ch, uint32_t byteCount);
+void Fvid2Utils_memset(void *mem, uint8_t ch, size_t byteCount);
 
 /**
  *  Fvid2Utils_memsetw
@@ -244,9 +271,9 @@ void *Fvid2Utils_memsetw(void *mem, uint32_t word, uint32_t wordCount);
  *  \param src              Source memory pointer.
  *  \param byteCount        Number of bytes to copy.
  *
- *  \return                 The destination memory pointer.
+ *  \return                 None
  */
-void *Fvid2Utils_memcpy(void *dest, const void *src, uint32_t byteCount);
+void Fvid2Utils_memcpy(void *dest, const void *src, size_t byteCount);
 
 /**
  *  Fvid2Utils_memcmp
@@ -284,9 +311,9 @@ int32_t Fvid2Utils_constructLinkList(Fvid2UtilsLinkListObj  *llobj,
  *
  *  \param llobj pointer to object of type Fvid2UtilsLinkListObj
  *
- *  \return                 Returns FVID2_SOK on success else returns error value.
+ *  \return                 None
  */
-int32_t Fvid2Utils_destructLinkList(Fvid2UtilsLinkListObj *llobj);
+void Fvid2Utils_destructLinkList(Fvid2UtilsLinkListObj *llobj);
 
 /**
  *  Fvid2Utils_linkNodePri
@@ -478,9 +505,9 @@ int32_t Fvid2Utils_constructQ(Fvid2UtilsLinkListObj *llobj);
  *
  * \param llobj pointer to object of type Fvid2UtilsLinkListObj
  *
- *  \return                 Returns FVID2_SOK on success else returns error value.
+ *  \return                 None
  */
-int32_t Fvid2Utils_destructQ(Fvid2UtilsLinkListObj *llobj);
+void Fvid2Utils_destructQ(Fvid2UtilsLinkListObj *llobj);
 
 /**
  *  Fvid2Utils_queue
@@ -696,9 +723,9 @@ static inline void Fvid2Utils_initPool(Fvid2Utils_PoolParams *params,
     uint32_t cnt;
 
     /* NULL pointer check */
-    GT_assert(traceMask, (NULL != params));
-    GT_assert(traceMask, (NULL != mem));
-    GT_assert(traceMask, (NULL != flag));
+    GT_assert(traceMask, (NULL_PTR != params));
+    GT_assert(traceMask, (NULL_PTR != mem));
+    GT_assert(traceMask, (NULL_PTR != flag));
 
     /* Init pool parameters */
     params->mem         = mem;
@@ -722,11 +749,11 @@ static inline void *Fvid2Utils_alloc(Fvid2Utils_PoolParams *params,
 {
     uint32_t cnt;
     uintptr_t cookie;
-    uint32_t tempVal;
+    uintptr_t tempVal;
     void  *allocMem = NULL;
 
     /* NULL pointer check */
-    GT_assert(traceMask, (NULL != params));
+    GT_assert(traceMask, (NULL_PTR != params));
     /* Check if the requested size if within each fixed size element */
     GT_assert(traceMask, (size <= params->elemSize));
     GT_assert(traceMask, (0U != size));
@@ -738,7 +765,7 @@ static inline void *Fvid2Utils_alloc(Fvid2Utils_PoolParams *params,
     {
         if ((uint32_t) FALSE == params->flag[cnt])
         {
-            tempVal = ((uint32_t) params->mem) + (params->elemSize * cnt);
+            tempVal = ((uintptr_t) params->mem) + (((uintptr_t) params->elemSize) * ((uintptr_t) cnt));
             allocMem          = (void *) (tempVal);
             params->flag[cnt] = (uint32_t) TRUE;
 
@@ -761,20 +788,20 @@ static inline int32_t Fvid2Utils_free(Fvid2Utils_PoolParams *params,
                                       uint32_t               traceMask)
 {
     uint32_t cnt;
-    uint32_t tempVal;
+    uintptr_t tempVal;
     int32_t  retVal = FVID2_EFAIL;
     uintptr_t cookie;
 
     /* NULL pointer check */
-    GT_assert(traceMask, (NULL != params));
-    GT_assert(traceMask, (NULL != mem));
+    GT_assert(traceMask, (NULL_PTR != params));
+    GT_assert(traceMask, (NULL_PTR != mem));
 
     /* Disable global interrupts */
     cookie = HwiP_disable();
 
     for (cnt = 0U; cnt < params->numElem; cnt++)
     {
-        tempVal = ((uint32_t) params->mem) + (params->elemSize * cnt);
+        tempVal = ((uintptr_t) params->mem) + (((uintptr_t)params->elemSize) * ((uintptr_t)cnt));
         if ((void *) (tempVal) == mem)
         {
             /* Check if the memory is already allocated */
@@ -800,7 +827,7 @@ static inline int32_t Fvid2Utils_free(Fvid2Utils_PoolParams *params,
 static inline void Fvid2Utils_initTsPrfLog(Fvid2Utils_TsPrfLog *tsPrf)
 {
     /* NULL pointer check */
-    GT_assert(GT_DEFAULT_MASK, (NULL != tsPrf));
+    GT_assert(GT_DEFAULT_MASK, (NULL_PTR != tsPrf));
 
     Fvid2Utils_memset(tsPrf, 0, sizeof (Fvid2Utils_TsPrfLog));
     /* Min can't be init to 0, set a higher value so that actual min gets
@@ -813,7 +840,7 @@ static inline void Fvid2Utils_initTsPrfLog(Fvid2Utils_TsPrfLog *tsPrf)
 static inline void Fvid2Utils_startTsPrfLog(Fvid2Utils_TsPrfLog *tsPrf)
 {
     /* NULL pointer check */
-    GT_assert(GT_DEFAULT_MASK, (NULL != tsPrf));
+    GT_assert(GT_DEFAULT_MASK, (NULL_PTR != tsPrf));
 
     tsPrf->startTime = Osal_getTimestamp64();
 
@@ -825,7 +852,7 @@ static inline void Fvid2Utils_endTsPrfLog(Fvid2Utils_TsPrfLog *tsPrf)
     uint64_t endTime, diff;
 
     /* NULL pointer check */
-    GT_assert(GT_DEFAULT_MASK, (NULL != tsPrf));
+    GT_assert(GT_DEFAULT_MASK, (NULL_PTR != tsPrf));
 
     endTime = Osal_getTimestamp64();
     diff    = endTime - tsPrf->startTime;