PDK-3279: FVID2 Trace should use user defined callback function to print
authorSivaraj R <sivaraj@ti.com>
Mon, 24 Sep 2018 11:14:38 +0000 (16:44 +0530)
committerSivaraj R <sivaraj@ti.com>
Fri, 28 Sep 2018 14:04:23 +0000 (19:34 +0530)
- Added fix for print disable for A53
- Fully revamed the trace function to not depend on stdio
- Removed unwanted features
- Added function pointer for print callback registeration

Signed-off-by: Sivaraj R <sivaraj@ti.com>
fvid2_component.mk
include/fvid2_api.h
include/fvid2_utils.h
include/trace.h
src/fvid2_drvMgr.c
src/makefile
src/trace.c

index 2455d806b5c53d6b249bd664c7d88246b5c02e85..68e45220b7c79e583aecf0d869b34dffb988dbc6 100755 (executable)
@@ -91,11 +91,6 @@ FVID2_CFLAGS =
 # Enable asserts and prints
 FVID2_CFLAGS += -DFVID2_CFG_TRACE_ENABLE
 FVID2_CFLAGS += -DFVID2_CFG_ASSERT_ENABLE
-#TODO: Enable for A53 after semi-hosting is enabled
-ifneq ($(CORE),$(filter $(CORE), mpu1_0 mpu1_1))
-  FVID2_CFLAGS += -DFVID2_CFG_USE_STD_ASSERT
-  FVID2_CFLAGS += -DFVID2_CFG_PRINT_ENABLE
-endif
 
 export FVID2_CFLAGS
 
index eceacb824c12a3409f82f5ce943a6222a3cc1759..c46a2ecbd0a7cc453ff4acf4725f358b1b2c6557 100644 (file)
@@ -322,6 +322,15 @@ typedef int32_t (*Fvid2_SubFrameCbFxn)(Fvid2_Handle handle,
  */
 typedef uint64_t (*Fvid2_TimeStampFxn)(void *args);
 
+/**
+ *  \brief FVID2 info/debug print function prototype.
+ *
+ *  This function is used by the driver to print info/debug messages.
+ *
+ *  \param format   [OUT] Info string to print.
+ */
+typedef void (*Fvid2_PrintFxn)(const char *format, ...);
+
 /**
  *  \name FVID2 Max limits
  *  @{
@@ -473,7 +482,7 @@ typedef struct
  */
 typedef struct
 {
-    Fvid2_TimeStampFxn timeStampFxn;
+    Fvid2_TimeStampFxn  timeStampFxn;
     /**< By default, OSAL (BIOS) API is used to time stamp frames.
      *
      *   Applications could over-ride the same, by providing a
@@ -491,6 +500,16 @@ typedef struct
     /**< Not used now. Set to zero. */
 } Fvid2_TimeStampParams;
 
+/**
+ *  \brief FVID2 initialization parameters.
+ */
+typedef struct
+{
+    Fvid2_PrintFxn      printFxn;
+    /**< If not NULL, this function will be called to print debug/info message
+     *   with appropriate string. */
+} Fvid2_InitPrms;
+
 /* ========================================================================== */
 /*                          Function Declarations                             */
 /* ========================================================================== */
@@ -502,11 +521,13 @@ typedef struct
  *  This function should be called before calling any of FVID2 API's and
  *  should be called only once.
  *
- *  \param args         [IN] Not used currently. Set to NULL.
+ *  \param initPrms     [IN] FVID2 Initialization parameters.
+ *                           If NULL is passed, the default parameters will be
+ *                           assumed - no print will be enabled
  *
  *  \return FVID2_SOK on success else appropriate FVID2 error code on failure.
  */
-int32_t Fvid2_init(void *args);
+int32_t Fvid2_init(const Fvid2_InitPrms *initPrms);
 
 /**
  *  \brief FVID2 deinit function.
@@ -789,6 +810,17 @@ static inline int32_t Fvid2_setFormat(Fvid2_Handle handle, Fvid2_Format *fmt);
  */
 static inline int32_t Fvid2_getFormat(Fvid2_Handle handle, Fvid2_Format *fmt);
 
+/*
+ * Structure Init functions
+ */
+/**
+ *  \brief Fvid2_InitPrms structure init function.
+ *
+ *  \param initPrms     [IN] Pointer to #Fvid2_InitPrms structure.
+ *
+ */
+static inline void Fvid2InitPrms_init(Fvid2_InitPrms *initPrms);
+
 /**
  *  \brief Fvid2_CbParams structure init function.
  *
@@ -821,6 +853,16 @@ static inline int32_t Fvid2_getFormat(Fvid2_Handle handle, Fvid2_Format *fmt)
     return Fvid2_control(handle, FVID2_GET_FORMAT, fmt, NULL);
 }
 
+static inline void Fvid2InitPrms_init(Fvid2_InitPrms *initPrms)
+{
+    if (NULL != initPrms)
+    {
+        initPrms->printFxn  = NULL;
+    }
+
+    return;
+}
+
 static inline void Fvid2CbParams_init(Fvid2_CbParams *cbPrms)
 {
     if (NULL != cbPrms)
index 03b828aa5884bda99afe148d9610a304d74b3751..5b7c33cc7962a6cfe83440dc29ce2d7c76541f9c 100755 (executable)
@@ -56,9 +56,6 @@ extern "C" {
 /*                           Macros & Typedefs                                */
 /* ========================================================================== */
 
-/** \brief Log enable for FVID2 Utils. */
-#define Fvid2Trace                      (GT_DEFAULT_MASK)
-
 /** \brief Number of timestamps. */
 #define FVID2UTILS_NUM_TIMESTAMP_LOG    (100U)
 
index b7eef57e564efb863bc6afd818dc3fdbb396162b..ec3c77d57ff15fd993b70acc1a2c8426b2293abd 100755 (executable)
 
 #include <ti/csl/tistdtypes.h>
 
- #if defined (FVID2_CFG_USE_STD_ASSERT)
-#include <assert.h>
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/** \brief The global trace variable containing current trace configuration. */
-extern int32_t curTrace;
-
 /*!
  *  @def    GT_TRACESTATE_MASK
  *  @brief  Trace state mask
  */
-#define GT_TRACESTATE_MASK                 0x0000000FU
-
+#define GT_TRACESTATE_MASK              (0x0000000FU)
 /*!
  *  @def    GT_TRACESTATE_SHIFT
  *  @brief  Bit shift for trace state
  */
-#define GT_TRACESTATE_SHIFT                0U
-
-/*!
- *  @def    GT_TRACEENTER_MASK
- *  @brief  Trace enter mask
- */
-#define GT_TRACEENTER_MASK                 0x000000F0U
-
-/*!
- *  @def    GT_TRACEENTER_SHIFT
- *  @brief  Bit shift for trace enter
- */
-#define GT_TRACEENTER_SHIFT                4U
-
-/*!
- *  @def    GT_TRACESETFAILURE_MASK
- *  @brief  Trace Set Failure Reason mask
- */
-#define GT_TRACESETFAILURE_MASK            0x00000F00U
-
-/*!
- *  @def    GT_TRACESETFAILURE_SHIFT
- *  @brief  Bit shift for trace Set Failure Reason
- */
-#define GT_TRACESETFAILURE_SHIFT           8U
-
+#define GT_TRACESTATE_SHIFT             (0U)
 /*!
  *  @def    GT_TRACECLASS_MASK
  *  @brief  GT class mask
  */
-#define GT_TRACECLASS_MASK                 0x000F0000U
-
+#define GT_TRACECLASS_MASK              (0x000F0000U)
 /*!
  *  @def    GT_TRACECLASS_SHIFT
  *  @brief  Bit shift for GT class mask
  */
-#define GT_TRACECLASS_SHIFT                16U
+#define GT_TRACECLASS_SHIFT             (16U)
 
 /*!
  *  @brief  Default Mask to use with GT_assert
  */
-#define GT_DEFAULT_MASK                    (GT_ERR | GT_TraceState_Enable)
+#define GT_DEFAULT_MASK                 (GT_ERR | GT_TraceState_Enable)
 
 /*!
  *  @brief   Enumerates the types of states of trace (enable/disable)
@@ -122,32 +88,6 @@ typedef enum {
                               *values for this enum */
 } GT_TraceState;
 
-/*!
- *  @brief   Enumerates the states of enter/leave trace (enable/disable)
- */
-typedef enum {
-    GT_TraceEnter_Disable = 0x00000000U,
-    /*!< Disable GT_ENTER trace prints */
-    GT_TraceEnter_Enable = 0x00000010U,
-    /*!< Enable GT_ENTER trace prints */
-    GT_TraceEnter_EndValue = 0x00000020U
-                             /*!< End delimiter indicating start of invalid
-                              *values for this enum */
-} GT_TraceEnter;
-
-/*!
- *  @brief   Enumerates the states of SetFailureReason trace (enable/disable)
- */
-typedef enum {
-    GT_TraceSetFailure_Disable = 0x00000000U,
-    /*!< Disable Set Failure trace prints */
-    GT_TraceSetFailure_Enable = 0x00000100U,
-    /*!< Enable Set Failure trace prints */
-    GT_TraceSetFailure_EndValue = 0x00000200U
-                                  /*!< End delimiter indicating start of invalid
-                                   *values for this enum */
-} GT_TraceSetFailure;
-
 /*!
  *  @brief   Enumerates the types of trace classes
  */
@@ -168,6 +108,9 @@ typedef enum {
                /*!< Indicates a function leave class of trace */
 } GT_TraceClass;
 
+/** \brief Log enable for FVID2 Utils. */
+#define Fvid2Trace                      (GT_DEFAULT_MASK)
+
 /**
  *  \brief Prints to Shared memory and CCS console
  *
@@ -179,83 +122,25 @@ typedef enum {
  */
 void Fvid2_printf(const char *format, ...);
 
-/**
- *  \brief Prints to Shared memory only
- *
- *  This function prints the provided formatted string to shared memory only
- *
- *  \param format       [IN] Formatted string followed by variable arguments
- *
- */
-void Fvid2_rprintf(const char *format, ...);
+#if defined (FVID2_CFG_ASSERT_ENABLE)
 
 /** \brief assert function. */
-static inline void GT_assertLocal(uint32_t    enableMask,
-                                  uint32_t    condition,
-                                  const char *str,
-                                  const char *fileName,
-                                  int32_t     lineNum);
+void GT_assertLocal(uint32_t    enableMask,
+                    uint32_t    condition,
+                    const char *str,
+                    const char *fileName,
+                    int32_t     lineNum);
 
 /** \brief GT_assert */
 #define GT_assert(x, y)                                           \
     (GT_assertLocal((uint32_t) (x), (uint32_t) (y), (const char *) # y, \
                     (const char *) __FILE__, (int32_t) __LINE__))
 
-static inline void GT_assertLocal(uint32_t    enableMask,
-                                  uint32_t    condition,
-                                  const char *str,
-                                  const char *fileName,
-                                  int32_t     lineNum)
-{
-#if defined (FVID2_CFG_ASSERT_ENABLE)
-    if ((!(condition)) != 0)
-    {
-        Fvid2_printf(" Assertion @ Line: %d in %s: %s : failed !!!\n",
-                   lineNum, fileName, str);
- #if defined (FVID2_CFG_USE_STD_ASSERT)
-        assert((!(condition)) != 0);
- #else
-        while (TRUE)
-        {
-            ;
-        }
- #endif /* #if defined(FVID2_CFG_USE_STD_ASSERT) */
-    }
-#endif  /* if defined(FVID2_CFG_ASSERT_ENABLE) */
-
-    return;
-}
+#else
 
-#if defined (FVID2_CFG_TRACE_ENABLE)
-/** \brief Function to report the FVID2 failure and log the trace. */
-void GT_failureReasonSet(int32_t      enableMask,
-                         const char  *func,
-                         const char  *fileName,
-                         int32_t      lineNum,
-                         uint32_t     status,
-                         const char  *msg);
-/** \brief Function to report the FVID2 failure and log the trace. */
-#define GT_setFailureReason(maskType, classType, func, status, msg) \
-    (GT_failureReasonSet((maskType), (const char *) (func),         \
-                         (const char *) __FILE__, (int32_t) __LINE__, \
-                         (status), (const char *) (msg)))
-
-#else /* if defined (FVID2_CFG_TRACE_ENABLE) */
-
-/** \brief Function to report the FVID2 failure and log the trace. */
-#define GT_setFailureReason(maskType, classType, func, status, msg) \
-    do {                                                            \
-        if (maskType) {                                             \
-        }                                                           \
-        if (classType) {                                            \
-        }                                                           \
-        if (status) {                                               \
-        }                                                           \
-        if ((uint32_t) (msg)) {                                     \
-        }                                                           \
-    } while (FALSE)
-
-#endif /* if defined (FVID2_CFG_TRACE_ENABLE) */
+#define GT_assert(x, y)
+
+#endif
 
 /**
  *  \brief Log the trace with zero parameters and information string.
index c6fb7231b6c059ff66c2ff789dddddce59aa8d9f..c709238313b250bc43614af4880a5b9382e7e9d3 100755 (executable)
@@ -42,6 +42,9 @@
 /*                             Include Files                                  */
 /* ========================================================================== */
 
+/* This is needed for vsnprintf */
+#include <stdio.h>
+#include <stdarg.h>
 #include <ti/drv/fvid2/include/fvid2_drvMgr.h>
 
 /* ========================================================================== */
 #define FDM_NUM_STD_STR_ENTRIES         (sizeof (gFdmStdStrTable) / \
                                          sizeof (Fdm_StdString))
 
+#if defined (FVID2_CFG_TRACE_ENABLE)
+#define REMOTE_DEBUG_SERVER_PRINT_BUF_LEN        (uint32_t) (1024U * 2U)
+#endif
+
 /* ========================================================================== */
 /*                         Structure Declarations                             */
 /* ========================================================================== */
@@ -136,6 +143,14 @@ typedef struct
     /**< Semaphore to protect function calls and other memory allocation. */
 } Fdm_Object;
 
+#if defined (FVID2_CFG_TRACE_ENABLE)
+typedef struct
+{
+    uint32_t    coreId;
+    char        printBuf[REMOTE_DEBUG_SERVER_PRINT_BUF_LEN];
+} RemoteDebug_ServerObj;
+#endif
+
 /* ========================================================================== */
 /*                          Function Declarations                             */
 /* ========================================================================== */
@@ -162,6 +177,13 @@ static int32_t fdmFreeChannelObject(Fdm_Channel *channel);
 /*                            Global Variables                                */
 /* ========================================================================== */
 
+#if defined (FVID2_CFG_TRACE_ENABLE)
+static RemoteDebug_ServerObj gRemoteDebug_serverObj = {0};
+#endif
+
+/** \brief FDM init params. */
+static Fvid2_InitPrms   gFdmInitPrms = {NULL};
+
 /** \brief FDM objects. */
 static Fdm_Object        gFdmObj;
 
@@ -447,13 +469,19 @@ static Fdm_StdString     gFdmStdStrTable[] =
  *
  *  \return             Returns 0 on success else returns error value.
  */
-int32_t Fvid2_init(void *args)
+int32_t Fvid2_init(const Fvid2_InitPrms *initPrms)
 {
     uint32_t cnt;
     int32_t  retVal = FVID2_SOK;
     int32_t  initValue;
     SemaphoreP_Params params;
 
+    Fvid2InitPrms_init(&gFdmInitPrms);
+    if (NULL != initPrms)
+    {
+        Fvid2Utils_memcpy(&gFdmInitPrms, initPrms, sizeof (gFdmInitPrms));
+    }
+
     /* Init all global variables to zero */
     Fvid2Utils_memset(&gFdmObj, 0U, sizeof (gFdmObj));
 
@@ -477,7 +505,7 @@ int32_t Fvid2_init(void *args)
     gFdmObj.lockSem = SemaphoreP_create(initValue, &params);
     if (NULL == gFdmObj.lockSem)
     {
-        Fvid2_printf("FVID2 semaphore create failed!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "FVID2 semaphore create failed!!\r\n");
         retVal = FVID2_EALLOC;
     }
 
@@ -563,7 +591,8 @@ int32_t Fvid2_registerDriver(const Fvid2_DrvOps *drvOps)
 
             if (drvOps->drvId == gFdmObj.fdmDriverObjects[cnt].drvOps->drvId)
             {
-                Fvid2_printf("Driver with same id already registered!!\r\n");
+                GT_0trace(Fvid2Trace, GT_ERR,
+                          "Driver with same id already registered!!\r\n");
                 retVal = FVID2_EDRIVER_INUSE;
                 break;
             }
@@ -581,7 +610,7 @@ int32_t Fvid2_registerDriver(const Fvid2_DrvOps *drvOps)
         }
         else
         {
-            Fvid2_printf("Alloc driver object failed!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Alloc driver object failed!!\r\n");
             retVal = FVID2_EALLOC;
         }
     }
@@ -691,7 +720,7 @@ Fvid2_Handle Fvid2_create(uint32_t              drvId,
         }
         else
         {
-            Fvid2_printf("Driver Ops not supported!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver Ops not supported!!\r\n");
         }
 
         if (NULL != drvHandle)
@@ -711,7 +740,7 @@ Fvid2_Handle Fvid2_create(uint32_t              drvId,
         }
         else
         {
-            Fvid2_printf("Driver create failed!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver create failed!!\r\n");
 
             /* Free the allocated channel object */
             fdmFreeChannelObject(channel);
@@ -720,7 +749,7 @@ Fvid2_Handle Fvid2_create(uint32_t              drvId,
     }
     else
     {
-        Fvid2_printf("EALLOC: Invalid driver ID!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EALLOC: Invalid driver ID!!\r\n");
     }
 
     SemaphoreP_post(gFdmObj.lockSem);
@@ -757,7 +786,7 @@ int32_t Fvid2_delete(Fvid2_Handle handle, void *deleteArgs)
         }
         else
         {
-            Fvid2_printf("Driver Ops not supported!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver Ops not supported!!\r\n");
         }
 
         channel->drv->numOpens--;
@@ -772,7 +801,7 @@ int32_t Fvid2_delete(Fvid2_Handle handle, void *deleteArgs)
     }
     else
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
 
@@ -813,13 +842,13 @@ int32_t Fvid2_control(Fvid2_Handle  handle,
         }
         else
         {
-            Fvid2_printf("Driver Ops not supported!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver Ops not supported!!\r\n");
             retVal = FVID2_EUNSUPPORTED_OPS;
         }
     }
     else
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
 
@@ -857,13 +886,13 @@ int32_t Fvid2_queue(Fvid2_Handle     handle,
         }
         else
         {
-            Fvid2_printf("Driver Ops not supported!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver Ops not supported!!\r\n");
             retVal = FVID2_EUNSUPPORTED_OPS;
         }
     }
     else
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
 
@@ -903,13 +932,13 @@ int32_t Fvid2_dequeue(Fvid2_Handle      handle,
         }
         else
         {
-            Fvid2_printf("Driver Ops not supported!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver Ops not supported!!\r\n");
             retVal = FVID2_EUNSUPPORTED_OPS;
         }
     }
     else
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
 
@@ -946,13 +975,13 @@ int32_t Fvid2_processRequest(Fvid2_Handle     handle,
         }
         else
         {
-            Fvid2_printf("Driver Ops not supported!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver Ops not supported!!\r\n");
             retVal = FVID2_EUNSUPPORTED_OPS;
         }
     }
     else
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
 
@@ -991,13 +1020,13 @@ int32_t Fvid2_getProcessedRequest(Fvid2_Handle     handle,
         }
         else
         {
-            Fvid2_printf("Driver Ops not supported!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Driver Ops not supported!!\r\n");
             retVal = FVID2_EUNSUPPORTED_OPS;
         }
     }
     else
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
 
@@ -1027,7 +1056,7 @@ int32_t Fvid2_getModeInfo(Fvid2_ModeInfo *modeInfo)
 
         if (NULL == matchedEntry)
         {
-            Fvid2_printf("Unsupported standard!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Unsupported standard!!\r\n");
             retVal = FVID2_EINVALID_PARAMS;
         }
         else
@@ -1037,7 +1066,7 @@ int32_t Fvid2_getModeInfo(Fvid2_ModeInfo *modeInfo)
     }
     else
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
 
@@ -1120,7 +1149,7 @@ int32_t Fvid2_checkFrameList(const Fvid2_FrameList *frameList,
     /* Check for NULL pointer */
     if (NULL == frameList)
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
     else
@@ -1128,21 +1157,22 @@ int32_t Fvid2_checkFrameList(const Fvid2_FrameList *frameList,
         /* Check whether num frames is within range */
         if (frameList->numFrames > maxFrames)
         {
-            Fvid2_printf("Number of frames exceeds max!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Number of frames exceeds max!!\r\n");
             retVal = FVID2_EOUT_OF_RANGE;
         }
 
         /* Check whether num frames is within range */
         if (frameList->numFrames > FVID2_MAX_FRAME_PTR)
         {
-            Fvid2_printf("Number of frames exceeds FVID2 max!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR,
+                      "Number of frames exceeds FVID2 max!!\r\n");
             retVal = FVID2_EOUT_OF_RANGE;
         }
 
         /* Check whether num frames is zero */
         if (0U == frameList->numFrames)
         {
-            Fvid2_printf("Number of frames is zero!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR, "Number of frames is zero!!\r\n");
             retVal = FVID2_EOUT_OF_RANGE;
         }
 
@@ -1154,7 +1184,8 @@ int32_t Fvid2_checkFrameList(const Fvid2_FrameList *frameList,
                 /* Check for NULL pointer */
                 if (NULL == frameList->frames[frmCnt])
                 {
-                    Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+                    GT_0trace(Fvid2Trace, GT_ERR,
+                              "EBADARGS: NULL pointer!!\r\n");
                     retVal = FVID2_EBADARGS;
                     break;
                 }
@@ -1180,7 +1211,7 @@ int32_t Fvid2_checkDqFrameList(const Fvid2_FrameList *frameList,
     /* Check for NULL pointer */
     if (NULL == frameList)
     {
-        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "EBADARGS: NULL pointer!!\r\n");
         retVal = FVID2_EBADARGS;
     }
     else
@@ -1188,7 +1219,8 @@ int32_t Fvid2_checkDqFrameList(const Fvid2_FrameList *frameList,
         /* Check whether max frames is within range */
         if (maxFrames > FVID2_MAX_FRAME_PTR)
         {
-            Fvid2_printf("Number of frames exceeds FVID2 max!!\r\n");
+            GT_0trace(Fvid2Trace, GT_ERR,
+                      "Number of frames exceeds FVID2 max!!\r\n");
             retVal = FVID2_EOUT_OF_RANGE;
         }
     }
@@ -1349,7 +1381,7 @@ static int32_t fdmFreeDriverObject(const Fvid2_DrvOps *drvOps)
             }
             else
             {
-                Fvid2_printf("Driver in use!!\r\n");
+                GT_0trace(Fvid2Trace, GT_ERR, "Driver in use!!\r\n");
                 retVal = FVID2_EDEVICE_INUSE;
             }
             break;
@@ -1358,7 +1390,7 @@ static int32_t fdmFreeDriverObject(const Fvid2_DrvOps *drvOps)
 
     if (FVID2_EFAIL == retVal)
     {
-        Fvid2_printf("Driver ops not found!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR, "Driver ops not found!!\r\n");
     }
 
     return (retVal);
@@ -1407,9 +1439,34 @@ static int32_t fdmFreeChannelObject(Fdm_Channel *channel)
     }
     else
     {
-        Fvid2_printf("Freeing a channel object not in use!!\r\n");
+        GT_0trace(Fvid2Trace, GT_ERR,
+                  "Freeing a channel object not in use!!\r\n");
     }
 
     return (retVal);
 }
 
+void Fvid2_printf(const char *format, ...)
+{
+#if defined (FVID2_CFG_TRACE_ENABLE)
+    va_list     vaArgPtr;
+    uintptr_t   cookie;
+    char       *buf = NULL;
+
+    cookie = HwiP_disable();
+
+    buf = &gRemoteDebug_serverObj.printBuf[0];
+    va_start(vaArgPtr, format);
+    vsnprintf(buf, REMOTE_DEBUG_SERVER_PRINT_BUF_LEN,
+              (const char *) format, vaArgPtr);
+    va_end(vaArgPtr);
+
+    HwiP_restore(cookie);
+
+    if(gFdmInitPrms.printFxn != NULL)
+    {
+        gFdmInitPrms.printFxn(buf);
+    }
+#endif
+    return;
+}
index dc96e3881f2837e2053483d4b73f63ebe715bd58..c7110b18d70a3d78f3fc2c55df841e20cc91c374 100755 (executable)
@@ -17,7 +17,7 @@ PACKAGE_SRCS_COMMON = .
 
 SRCS_COMMON += fvid2_drvMgr.c fvid2_utils.c fvid2_graph.c trace.c
 
-CFLAGS_LOCAL_COMMON = $(PDK_CFLAGS)
+CFLAGS_LOCAL_COMMON = $(PDK_CFLAGS) $(FVID2_CFLAGS)
 PACKAGE_SRCS_COMMON = fvid2.h fvid2_component.mk makefile .gitignore include src
 PACKAGE_SRCS_COMMON += config_mk.bld package.bld package.xdc package.xs
 PACKAGE_SRCS_COMMON += Settings.xdc.xdt fvid2ver.h fvid2ver.h.xdt
index f77600d0dc6a78dc976af4c53660106995c551f1..9097882c154d017892c0de317b0578dcb45fb299 100644 (file)
@@ -47,9 +47,6 @@
 /* ========================================================================== */
 
 #include <stdint.h>
-/* This is needed for vsnprintf */
-#include <stdio.h>
-#include <stdarg.h>
 
 #include <ti/csl/tistdtypes.h>
 #include <ti/drv/fvid2/fvid2.h>
 /*                           Macros & Typedefs                                */
 /* ========================================================================== */
 
-#define REMOTE_DEBUG_SERVER_PRINT_BUF_LEN        (uint32_t) (1024U * 2U)
-
-//TODO: Move this to OSAL
-#define Osal_printf     printf
+/* None */
 
 /* ========================================================================== */
 /*                         Structure Declarations                             */
 /* ========================================================================== */
 
-typedef struct
-{
-    uint32_t coreId;
-    char   printBuf[REMOTE_DEBUG_SERVER_PRINT_BUF_LEN];
-} RemoteDebug_ServerObj;
+/* None */
 
 /* ========================================================================== */
 /*                          Function Declarations                             */
@@ -83,56 +73,13 @@ typedef struct
 /*                            Global Variables                                */
 /* ========================================================================== */
 
-static RemoteDebug_ServerObj gRemoteDebug_serverObj = {0};
-
-/** \brief Global trace flag. */
-int32_t curTrace = 0;
+/* None */
 
 /* ========================================================================== */
 /*                          Function Definitions                              */
 /* ========================================================================== */
 
-void Fvid2_printf(const char *format, ...)
-{
-    va_list     vaArgPtr;
-    uintptr_t   cookie;
-    char       *buf = NULL;
-
-    cookie = HwiP_disable();
-
-    buf = &gRemoteDebug_serverObj.printBuf[0];
-    va_start(vaArgPtr, format);
-    vsnprintf(buf, REMOTE_DEBUG_SERVER_PRINT_BUF_LEN,
-              (const char *) format, vaArgPtr);
-    va_end(vaArgPtr);
-
-    HwiP_restore(cookie);
-
-    Osal_printf(buf);
-
-    return;
-}
-
-void Fvid2_rprintf(const char *format, ...)
-{
-    uintptr_t   cookie;
-    char       *buf = NULL;
-    va_list     vaArgPtr;
-
-    cookie = HwiP_disable();
-
-    buf = &gRemoteDebug_serverObj.printBuf[0];
-
-    va_start(vaArgPtr, format);
-    vsnprintf(buf, REMOTE_DEBUG_SERVER_PRINT_BUF_LEN,
-              (const char *) format, vaArgPtr);
-    va_end(vaArgPtr);
-
-    HwiP_restore(cookie);
-
-    return;
-}
-
+#if defined (FVID2_CFG_TRACE_ENABLE)
 /**
  *  \brief      Function to log the trace with zero parameters and just
  *              information string.
@@ -145,37 +92,27 @@ void Fvid2_rprintf(const char *format, ...)
  *  \param      The debug string.
  */
 void
-GT_trace0(uint32_t        maskType,
+GT_trace0(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                Osal_printf((const char *) infoString);
-            }
-        }
-        else
-        {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
-            {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString);
         }
     }
 }
@@ -192,38 +129,28 @@ GT_trace0(uint32_t        maskType,
  *  \param      param The additional parameter which needs to be logged.
  */
 void
-GT_trace1(uint32_t        maskType,
+GT_trace1(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0)
+          uint32_t      param0)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString, param0);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString, param0);
         }
     }
 }
@@ -241,39 +168,29 @@ GT_trace1(uint32_t        maskType,
  *  \param      param1 The second parameter which needs to be logged.
  */
 void
-GT_trace2(uint32_t        maskType,
+GT_trace2(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1)
+          uint32_t      param0,
+          uint32_t      param1)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString, param0, param1);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0, param1);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString, param0, param1);
         }
     }
 }
@@ -292,42 +209,30 @@ GT_trace2(uint32_t        maskType,
  *  \param      param2 The third parameter which needs to be logged.
  */
 void
-GT_trace3(uint32_t        maskType,
+GT_trace3(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2);
-            }
-        }
-        else
-        {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
-            {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf((const char *) infoString, param0, param1, param2);
         }
     }
 }
@@ -347,45 +252,32 @@ GT_trace3(uint32_t        maskType,
  *  \param      param3 The fourth parameter which needs to be logged.
  */
 void
-GT_trace4(uint32_t        maskType,
+GT_trace4(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2,
-                               param3);
-            }
-        }
-        else
-        {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
-            {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString, param0, param1,
-                               param2,
-                               param3);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString, param0, param1, param2, param3);
         }
     }
 }
@@ -406,52 +298,34 @@ GT_trace4(uint32_t        maskType,
  *  \param      param4 The fifth parameter which needs to be logged.
  */
 void
-GT_trace5(uint32_t        maskType,
+GT_trace5(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3,
-          uint32_t        param4)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3,
+          uint32_t      param4)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString,
+                param0, param1, param2, param3, param4);
         }
     }
 }
@@ -473,55 +347,35 @@ GT_trace5(uint32_t        maskType,
  *  \param      param5 The sixth parameter which needs to be logged.
  */
 void
-GT_trace6(uint32_t        maskType,
+GT_trace6(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3,
-          uint32_t        param4,
-          uint32_t        param5)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3,
+          uint32_t      param4,
+          uint32_t      param5)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString,
+                param0, param1, param2, param3, param4, param5);
         }
     }
 }
@@ -544,92 +398,60 @@ GT_trace6(uint32_t        maskType,
  *  \param      param6 The sixth parameter which needs to be logged.
  */
 void
-GT_trace7(uint32_t        maskType,
+GT_trace7(uint32_t      maskType,
           GT_TraceClass classType,
           const char   *fileName,
-          int32_t         lineNum,
+          int32_t       lineNum,
           const char   *infoString,
-          uint32_t        param0,
-          uint32_t        param1,
-          uint32_t        param2,
-          uint32_t        param3,
-          uint32_t        param4,
-          uint32_t        param5,
-          uint32_t        param6)
+          uint32_t      param0,
+          uint32_t      param1,
+          uint32_t      param2,
+          uint32_t      param3,
+          uint32_t      param4,
+          uint32_t      param5,
+          uint32_t      param6)
 {
     /* Check if trace is enabled. */
     if (((maskType & GT_TRACESTATE_MASK) >> GT_TRACESTATE_SHIFT)
         == GT_TraceState_Enable)
     {
-        if ((classType == GT_ENTER) || (classType == GT_LEAVE))
-        {
-            if ((maskType & GT_TRACEENTER_MASK) == GT_TraceEnter_Enable)
-            {
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5,
-                               param6);
-            }
-        }
-        else
+        /* Check if specified class is enabled. */
+        if ((maskType & GT_TRACECLASS_MASK) >= classType)
         {
-            /* Check if specified class is enabled. */
-            if ((maskType & GT_TRACECLASS_MASK) >= classType)
+            /* Print if specified class is greater than or equal to class
+             * for this specific print.
+             */
+            if (!((classType == GT_INFO) || (classType == GT_INFO1)))
             {
-                /* Print if specified class is greater than or equal to class
-                 * for this specific print.
-                 */
-                if (!((classType == GT_INFO) || (classType == GT_INFO1)))
-                {
-                    Osal_printf("%s @ Line %d: ", fileName, lineNum);
-                }
-                Osal_printf((const char *) infoString,
-                               param0,
-                               param1,
-                               param2,
-                               param3,
-                               param4,
-                               param5,
-                               param6);
+                Fvid2_printf("%s @ Line %d: ", fileName, lineNum);
             }
+            Fvid2_printf(
+                (const char *) infoString,
+                param0, param1, param2, param3, param4, param5, param6);
         }
     }
 }
-
-/**
- *  \brief      Function to report the vps failure and log the trace. This
- *              is mostly the fatal error and system can not recover without
- *              module restart.
- *  \param      mask        Indicates whether SetFailure is enabled.
- *  \param      func        Name of the function where this oc.cured
- *  \param      fileName    Where the condition has occured.
- *  \param      lineNum     Line number of the current file where this failure
- *                          has occured.
- *  \param      status      What was the code we got/set for this failure
- *  \param      msg         Any additional information which can be useful for
- *                          deciphering the error condition.
- */
-void GT_failureReasonSet(int32_t  enableMask,
-                         const char  *func,
-                         const char  *fileName,
-                         int32_t  lineNum,
-                         uint32_t status,
-                         const char  *msg)
+#endif
+
+#if defined (FVID2_CFG_ASSERT_ENABLE)
+void GT_assertLocal(uint32_t    enableMask,
+                    uint32_t    condition,
+                    const char *str,
+                    const char *fileName,
+                    int32_t     lineNum)
 {
-    if ((((uint32_t) enableMask &
-          GT_TRACESETFAILURE_MASK) >> GT_TRACESETFAILURE_SHIFT)
-        == GT_TraceState_Enable)
+    if ((!(condition)) != 0)
     {
-        Osal_printf("*** %s: %s\tError [0x%x] at Line no: %d in file %s\r\n",
-                       func,
-                       msg,
-                       status,
-                       lineNum,
-                       fileName);
+        GT_3trace(
+            Fvid2Trace, GT_ERR,
+            " Assertion @ Line: %d in %s: %s : failed !!!\n",
+            lineNum, fileName, str);
+        while (TRUE)
+        {
+            ;
+        }
     }
-}
 
+    return;
+}
+#endif  /* if defined(FVID2_CFG_ASSERT_ENABLE) */