Added FVID2 driver manager
authorBrijesh Jadav <brijesh.jadav@ti.com>
Thu, 1 Feb 2018 06:09:07 +0000 (11:39 +0530)
committerBrijesh Jadav <brijesh.jadav@ti.com>
Thu, 1 Feb 2018 06:09:07 +0000 (11:39 +0530)
Signed-off-by: Brijesh Jadav <brijesh.jadav@ti.com>
fvid2_component.mk [new file with mode: 0644]
include/fvid2.h [new file with mode: 0644]
include/fvid2_drvMgr.h [new file with mode: 0644]
src/fvid2_drvMgr.c [new file with mode: 0644]
src/makefile [new file with mode: 0644]

diff --git a/fvid2_component.mk b/fvid2_component.mk
new file mode 100644 (file)
index 0000000..e359883
--- /dev/null
@@ -0,0 +1,103 @@
+# File: fvid2_component.mk
+#       This file is component include make file of FVID2 driver library.
+# List of variables set in this file and their purpose:
+# <mod>_RELPATH        - This is the relative path of the module, typically from
+#                        top-level directory of the package
+# <mod>_PATH           - This is the absolute path of the module. It derives from
+#                        absolute path of the top-level directory (set in env.mk)
+#                        and relative path set above
+# <mod>_INCLUDE        - This is the path that has interface header files of the
+#                        module. This can be multiple directories (space separated)
+# <mod>_PKG_LIST       - Names of the modules (and sub-modules) that are a part
+#                        part of this module, including itself.
+# <mod>_BOARD_DEPENDENCY - "yes": means the code for this module depends on
+#                             platform and the compiled obj/lib has to be kept
+#                             under <platform> directory
+#                             "no" or "" or if this variable is not defined: means
+#                             this module has no platform dependent code and hence
+#                             the obj/libs are not kept under <platform> dir.
+# <mod>_CORE_DEPENDENCY     - "yes": means the code for this module depends on
+#                             core and the compiled obj/lib has to be kept
+#                             under <core> directory
+#                             "no" or "" or if this variable is not defined: means
+#                             this module has no core dependent code and hence
+#                             the obj/libs are not kept under <core> dir.
+# <mod>_APP_STAGE_FILES     - List of source files that belongs to the module
+#                             <mod>, but that needs to be compiled at application
+#                             build stage (in the context of the app). This is
+#                             primarily for link time configurations or if the
+#                             source file is dependent on options/defines that are
+#                             application dependent. This can be left blank or
+#                             not defined at all, in which case, it means there
+#                             no source files in the module <mod> that are required
+#                             to be compiled in the application build stage.
+#
+ifeq ($(fvid2_component_make_include), )
+
+fvid2_default_SOCLIST       = j7 am6x
+fvid2_default_BOARDLIST     = simJ7 am6x-sim
+fvid2_default_j7_CORELIST   = mcu1_0 mcu1_1
+fvid2_default_am6x_CORELIST = mcu1_0 mcu1_1
+
+############################
+# fvid2 package
+# List of components included under fvid2 lib
+# The components included here are built and will be part of fvid2 lib
+############################
+fvid2_LIB_LIST = fvid2
+
+############################
+# fvid2 examples
+# List of examples under fvid2 (+= is used at each example definition)
+# All the tests mentioned in list are built when test target is called
+# List below all examples for allowed values
+############################
+fvid2_EXAMPLE_LIST =
+
+#
+# FVID2 Modules
+#
+
+# FVID2 library
+fvid2_COMP_LIST = fvid2
+fvid2_RELPATH = ti/drv/fvid2
+fvid2_PATH = $(PDK_FVID2_COMP_PATH)
+fvid2_LIBNAME = fvid2
+fvid2_LIBPATH = $(PDK_FVID2_COMP_PATH)/lib
+fvid2_MAKEFILE = -fsrc/makefile
+export fvid2_MAKEFILE
+export fvid2_LIBNAME
+export fvid2_LIBPATH
+fvid2_BOARD_DEPENDENCY = no
+fvid2_CORE_DEPENDENCY = yes
+export fvid2_COMP_LIST
+export fvid2_BOARD_DEPENDENCY
+export fvid2_CORE_DEPENDENCY
+fvid2_PKG_LIST = fvid2
+fvid2_INCLUDE = $(fvid2_PATH)
+fvid2_SOCLIST = $(fvid2_default_SOCLIST)
+export fvid2_SOCLIST
+fvid2_$(SOC)_CORELIST = $(fvid2_default_$(SOC)_CORELIST)
+export fvid2_$(SOC)_CORELIST
+
+#
+# FVID2 Examples
+#
+
+export fvid2_LIB_LIST
+export fvid2_EXAMPLE_LIST
+
+FVID2_CFLAGS =
+
+# Enable asserts and prints
+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
+
+fvid2_component_make_include := 1
+endif
diff --git a/include/fvid2.h b/include/fvid2.h
new file mode 100644 (file)
index 0000000..5d9bb8e
--- /dev/null
@@ -0,0 +1,887 @@
+/* =============================================================================
+ *   Copyright (c) Texas Instruments Incorporated 2012-2017
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ *  \file csl_fvid2.h
+ *
+ *  \brief CSL FVID2 API
+ *
+ *  FVID2 API is an interface which is used to create, control and use different
+ *  video drivers. FVID2 API is used not only for on-chip
+ *  peripherals drivers like capture, display but also for external off-chip
+ *  video device peripherals like video decoders, video encoders and
+ *  video sensors.
+ *
+ *  All video drivers and external video peripherals implement the FVID2
+ *  API.
+ *  Many drivers also extend the FVID2 interface by defining their own driver
+ *  specific IOCTLs.
+ *
+ *  <b> All FVID2 API must be called from task context </b>. Some examples
+ *  in the package maybe calling FVID2 APIs from callback and/or
+ *  interrupt context. Such examples will be modified in subsequent releases
+ *  and in order that user application do not have to do special migration it
+ *  is strongly recommended to use FVID2 APIs only from task context.
+ *
+ *  A FVID2 API can be of two kinds,
+ *
+ *  - <b> Blocking API </b> <br>
+ *    Here the FVID2 API call returns only after completing the request or
+ *    functionality or if timed out or if some other error occurs.
+ *    The below APIs are always blocking, unless specified otherwise by
+ *    specific driver.
+ *    - Fvid2_create()
+ *    - Fvid2_delete()
+ *    - Fvid2_start()
+ *    - Fvid2_stop()
+ *    - Fvid2_control()
+ *    - Fvid2_setFormat()
+ *    - Fvid2_getFormat()
+ *
+ *  - <b> Non-blocking API </b> <br>
+ *    Here FVID2 API call queues the request to the driver and returns
+ *    immediately before the request is processed or completed.
+ *    Application should use the completion callback to wait for request
+ *    completion.
+ *    The below APIs are always non-blocking, unless specified otherwise by
+ *    specific driver.
+ *    - Fvid2_queue()
+ *    - Fvid2_dequeue()
+ *    - Fvid2_processFrames()
+ *    - Fvid2_getProcessedFrames()
+ *
+ *  A FVID2 Driver can belong to one the below categories. The FVID2 APIs
+ *  applicable to driver in a category are also listed below. The below is
+ *  true for most driver unless specified otherwise by a specific driver.
+ *  - <b> Streaming interface drivers </b> <br>
+ *  Examples include, capture, display, graphics.
+ *  Below FVID2 APIs are implemented by such drivers.
+ *    - Fvid2_create()
+ *    - Fvid2_delete()
+ *    - Fvid2_start()
+ *    - Fvid2_stop()
+ *    - Fvid2_queue()
+ *    - Fvid2_dequeue()
+ *    - Fvid2_control()
+ *    - Fvid2_setFormat() - OPTIONAL
+ *    - Fvid2_getFormat() - OPTIONAL
+ *
+ *  - <b> Memory to memory processing interface drivers </b> <br>
+ *   Examples include, M2M VPE.
+ *   Below FVID2 APIs are implemented by such drivers.
+ *    - Fvid2_create()
+ *    - Fvid2_delete()
+ *    - Fvid2_processFrames()
+ *    - Fvid2_getProcessedFrames()
+ *    - Fvid2_control()
+ *    - Fvid2_setFormat() - OPTIONAL
+ *    - Fvid2_getFormat() - OPTIONAL
+ *
+ *  - <b> Control interface drivers </b> <br>
+ *   Examples include, display controller, external video devices.
+ *   Below FVID2 APIs are implemented by such drivers.
+ *    - Fvid2_create()
+ *    - Fvid2_delete()
+ *    - Fvid2_control()
+ *    - Fvid2_start()
+ *    - Fvid2_stop()
+ *    - Fvid2_setFormat() - OPTIONAL
+ *    - Fvid2_getFormat() - OPTIONAL
+ *
+ *  Before making any FVID2 API calls, Fvid2_init() must be called.
+ *  Fvid2_deInit() must be called during system shutdown.
+ *
+ *  Fvid2_getVersionString() and Fvid2_getVersionNumber() can be used to get
+ *  information about current driver version number.
+ *
+ *  All FVID2 drivers are of type Fvid2_Handle, which gets created when
+ *  Fvid2_create() is called. This handle is used for all subsequent FVID2
+ *  API calls. This handle and its associated resources are free'ed when
+ *  Fvid2_delete() is called.
+ *
+ *  All FVID2 APIs make use of Fvid2_Frame, Fvid2_FrameList and/or
+ *  Fvid2_ProcessList for exchanging and processing video frames via a driver.
+ *  Further all drivers use a common user callback mechanism via Fvid2_CbParams
+ *  to indicate to the user that a frame is ready. Many drivers, but not all,
+ *  use the Fvid2_Format data structure to describe video input, output data
+ *  formats.
+ *
+ *  All drivers use the constants, enum's, error codes defined in this file to
+ *  control and configure a driver.
+ *
+ *  In addition, most drivers define driver specific create time parameters
+ *  and IOCTLs to allow the user to control and configure the driver in driver
+ *  specific ways. Further a driver may define driver specific run-time
+ *  parameters which are passed by user to the driver via
+ *  Fvid2_Frame.perFrameCfg and/or Fvid2_FrameList.perListCfg.
+ *
+ *  Also user application can associate user specific app data with a
+ *  driver handle via Fvid2_CbParams.appData or with every frame via
+ *  FIVD2_Frame.appData. The app data set as part of Fvid2_CbParams returned
+ *  back to user when callback occurs. The app data set as part of Fvid2_Frame
+ *  is returned back to the user when the Fvid2_Frame itself is returned back to
+ *  user via Fvid2_dequeue() or Fvid2_getProcessedFrames(). The driver will not
+ *  modify this app data. This could be used by the application to store any
+ *  application specific data like application object info and so on.
+ *
+ *  Many FVID2 APIs define 'reserved' fields. These are meant for future use
+ *  and should be set to NULL/zero by user.
+ *
+ */
+
+/*
+ *  \version 0.1    Created.
+ *           0.2    Changes for BIOS 6 and new FVID2 interface.
+ *           0.2.1  Merged color and data format enums to data format enums.
+ *                  Added process list structure to support M2M
+ *                  (memory to memory) drivers.
+ *                  Removed FVID2_Buf structure and directly used address array
+ *                  in Fvid2_Frame structure.
+ *                  Defined proper signature for FVID2 APIs.
+ *           0.2.2  Added proper comments.
+ *           0.3    Added subframe callback and added reserved fields in all the
+ *                  structures.
+ *           0.4    Made frames pointer to pointer to array of frame pointer in
+ *                  framelist to simplify application allocation and ease of
+ *                  use.
+ *           0.5    Added FVID2 standard enums.
+ *           0.6    Split into two files. fvid2.h will contain only FVID2 driver
+ *                  specific defintions/declarations. It will include
+ *                  fvid2_dataTypes.h for data type defintions
+ *
+ */
+
+#ifndef FVID2_H_
+#define FVID2_H_
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+
+#include <csl_fvid2_dataTypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+
+/**
+ *  \brief FVID2 driver version string.
+ *  Version is of the form mm_nn_xx_yy where,
+ *      mm - Product version (02 for FVID2). This increments for any new FVID2
+ *           versions.
+ *      nn - Major number - Increments if any backward compatibility is broken
+ *           or major change within a product version.
+ *      xx - Minor number - Increments for any minor change or any additions
+ *           done without breaking backward compatibility.
+ *      yy - Build number - Increments for every release.
+ */
+#define FVID2_VERSION_STRING            "FVID_02_01_00_02"
+
+/** \brief FVID2 driver version number. */
+#define FVID2_VERSION_NUMBER            (0x02010002U)
+
+/** \brief FVID2 Driver handle. */
+typedef Ptr Fvid2_Handle;
+
+/**
+ *  \brief FVID2 driver callback function prototype.
+ *
+ *  This callback is used by the drivers which implement non-blocking
+ *  FVID2 APIs.
+ *
+ *  User should assume that callbacks happen in ISR context and hence should
+ *  apply rules relevant to ISR context when implementing callback functions,
+ *  i.e blocking APIs should not be called from callback. Users should also
+ *  assume that interrupts are enabled when in callback context, i.e other
+ *  interrupt / callbacks can occur when a callback is under execution.
+ *  User callback implementation should not be very long, since callback
+ *  execution may block other drivers from executing. Typically it is
+ *  recommended to set a semaphore or flag when callback happens and do the
+ *  more involved callback handling in task context.
+ *
+ *  This callback is typically called by the driver as mentioned below,
+ *  unless specified otherwise by specific drivers.
+ *
+ *  In case of display drivers, this callback function will be called
+ *  when a frame(s) is/are completed displayed. Then the application can
+ *  dequeue the displayed buffer back from the driver.
+ *
+ *  In case of capture drivers, this callback function will be called
+ *  when a frame(s) is/are captured. Then the application can dequeue the
+ *  captured buffer back from the driver.
+ *
+ *  In case of M2M drivers, this callback function will be called
+ *  when a request from the application is completed by the driver. Then the
+ *  application can dequeue the completed request buffers back from the driver.
+ *
+ *  In case of control drivers, callbacks are typically not used since mostly
+ *  FVID2 APIs implemented by control drivers are of blocking nature.
+ *
+ *  \param handle   [OUT] FVID2 handle for which the callback has occurred.
+ *  \param appData  [OUT] Application data provided to the driver at the
+ *                        time of Fvid2_create().
+ *  \param reserved [OUT] For future use. Set to NULL.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+typedef Int32 (*Fvid2_CbFxn)(Fvid2_Handle handle, Ptr appData, Ptr reserved);
+
+/**
+ *  \brief FVID2 error callback function prototype.
+ *
+ *  Error callback is called by driver when it encounters a error during
+ *  processing of frames in its internal queue.
+ *
+ *  When user submits frames to the driver it does minimal error checks and
+ *  stores the the frames in its internal queues. In case of any error at
+ *  this point the FVID2 API will simply return error and error callback
+ *  will not be called.
+ *
+ *  The driver will later (depending on how its request queue is full) process
+ *  these frames submitted by the user. If driver finds any error in either
+ *  the input frame information or hardware itself then it will call this error
+ *  callback to notify the user about this error. As part of the callback
+ *  information it also returns the frames or request for which error happened
+ *  so that user can take appropriate action.
+ *
+ *  Users should apply same rules as that of Fvid2_CbFxn when implementing
+ *  error callbacks.
+ *
+ *  \param handle   [OUT] FVID2 handle for which the callback has occurred.
+ *  \param appData  [OUT] Application data provided to the driver at the time
+ *                        of Fvid2_create().
+ *  \param errList  [OUT] Pointer to a valid framelist (Fvid2_FrameList)
+ *                        in case of capture and display drivers or a pointer
+ *                        to a valid processlist (Fvid2_ProcessList) in case of
+ *                        M2M drivers. The driver copies the aborted/error
+ *                        frames in this frame list or process list.
+ *  \param reserved [OUT] For future use. Set to NULL.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+typedef Int32 (*Fvid2_ErrCbFxn)(Fvid2_Handle handle,
+                                Ptr          appData,
+                                Ptr          errList,
+                                Ptr          reserved);
+
+/**
+ *  \brief FVID2 callback that is called by subframe mode Capture driver.
+ *
+ *  This callback is called for every subframe of frame that
+ *  is captured. This function is used by Capture Driver and not meant for M2M
+ *  drivers.
+ *
+ *  Users should apply same rules as that of Fvid2_CbFxn when implementing
+ *  subframe callbacks.
+ *
+ *  \param handle       [OUT] FVID2 handle for which this callback happened.
+ *  \param subFrameInfo [OUT] SubFrame information.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+typedef Int32 (*Fvid2_SubFrameCbFxn)(Fvid2_Handle handle,
+                                     Fvid2_Frame *subFrame);
+
+/**
+ *  \name FVID2 Max limits
+ *  @{
+ */
+
+/** \brief Decide the streamid based on channel number.  */
+#define FVID2_STREAM_ID_ANY             (0xFFFFFFFFU)
+
+/* @} */
+
+/*
+ * =========== Command codes for Submit call =============
+ */
+/** \brief Control command base address. */
+#define FVID2_CTRL_BASE                 (0x00000000U)
+/** \brief User command base address. */
+#define FVID2_USER_BASE                 (0x10000000U)
+
+/**
+ *  \addtogroup BSP_DRV_IOCTL_FVID2
+ *  @{
+ */
+
+/**
+ *  \brief Control command used by Fvid2_setFormat()
+ *
+ *  \param cmdArgs       [IN]  const Fvid2_Format *
+ *  \param cmdStatusArgs [OUT] NULL
+ *
+ *  \return FVID2_SOK on success, else failure.
+ */
+#define FVID2_SET_FORMAT                ((UInt32)FVID2_CTRL_BASE + 3U)
+
+/**
+ *  \brief Control command used by Fvid2_getFormat()
+ *
+ *  \param cmdArgs       [IN]  Fvid2_Format *
+ *  \param cmdStatusArgs [OUT] NULL
+ *
+ *  \return FVID2_SOK on success, else failure.
+ */
+#define FVID2_GET_FORMAT                ((UInt32)FVID2_CTRL_BASE + 4U)
+
+/**
+ *  \brief Control command used by Fvid2_start()
+ *
+ *  \param cmdArgs       [IN]  Driver specific
+ *  \param cmdStatusArgs [OUT] NULL
+ *
+ *  \return FVID2_SOK on success, else failure.
+ */
+#define FVID2_START                     ((UInt32)FVID2_CTRL_BASE + 5U)
+
+/**
+ *  \brief Control command used by Fvid2_stop()
+ *
+ *  \param cmdArgs       [IN]  Driver specific
+ *  \param cmdStatusArgs [OUT] NULL
+ *
+ *  \return FVID2_SOK on success, else failure.
+ */
+#define FVID2_STOP                      ((UInt32)FVID2_CTRL_BASE + 6U)
+
+/* @} */
+
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+
+/**
+ *  \brief FVID2 callback parameters that are setup during Fvid2_create().
+ */
+typedef struct
+{
+    Fvid2_CbFxn    cbFxn;
+    /**< Application callback function used by the driver to intimate any
+     *   operation has completed or not. This is an optional parameter
+     *   in case application decides to use polling method and so could be
+     *   set to NULL. */
+
+    Fvid2_ErrCbFxn errCbFxn;
+    /**< Application error callback function used by the driver to intimate
+     *   any error occurs at the time of streaming. This is an optional
+     *   parameter in case application decides not to get any error callback
+     *   and so could be set to NULL. */
+
+    Ptr            errList;
+    /**< Pointer to a valid Fvid2_FrameList in case of capture
+     *   and display drivers or a pointer to a valid Fvid2_ProcessList
+     *   in case of M2M drivers where the driver copies
+     *   the aborted/error packet. The memory of this list should be
+     *   allocated by the application and provided to the driver at the time
+     *   of driver creation. When the application gets this callback, it has
+     *   to empty this list and taken necessary action like freeing up memories
+     *   etc. The driver will then reuse the same list for future error
+     *   callback.
+     *   This could be NULL if errCbFxn is NULL. Otherwise this should be
+     *   non-NULL. */
+
+    Ptr appData;
+    /**< Application specific data which is returned in the callback function
+     *   as it is. This could be set to NULL if not used. */
+    Ptr reserved;
+    /**< For future use. Not used currently. Set this to NULL. */
+} Fvid2_CbParams;
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+
+/**
+ *  \brief FVID2 init function.
+ *
+ *  Initializes the FVID2 layer.
+ *  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.
+ *
+ *  \return FVID2_SOK on success else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_init(Ptr args);
+
+/**
+ *  \brief FVID2 deinit function.
+ *
+ *  Uninitializes the FVID2 layer and should be called during system shutdown.
+ *  Should not be called if Fvid2_init() is not called.
+ *
+ *  \param args         [IN] Not used currently. Set to NULL.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_deInit(Ptr args);
+
+/**
+ *  \brief Get the version string for FVID2 interface.
+ *
+ *  This is the version number for the FVID2 interface. This
+ *  function can be called prior to #Fvid2_init() to get the version number.
+ *
+ *  \return Pointer to FVID2 version string.
+ */
+const Char *Fvid2_getVersionString(void);
+
+/**
+ *  \brief Same as #Fvid2_getVersionString() except it returns the version in
+ *  UInt32 form.
+ *
+ *  Example, v1.0.1.17 will be 0x01000117
+ *
+ *  \return FVID2 version number.
+ */
+UInt32 Fvid2_getVersionNumber(void);
+
+/**
+ *  \brief Creates the driver identified by the driver ID.
+ *
+ *  This will allocate HW and/or SW resources and return a Fvid2_Handle
+ *  for this driver. This handle will be used for subsequent FVID2 API calls
+ *
+ *  \param drvId        [IN] Driver to open. Driver ID is driver specific.
+ *
+ *  \param instanceId   [IN] Instance of the driver to open and is used
+ *                      to differentiate multiple instance support on a
+ *                      single driver. Instance ID is driver specific.
+ *
+ *  \param createArgs   [IN] Pointer to the create argument structure. The type
+ *                      of the structure is defined by the specific driver.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \param createStatusArgs [OUT] Pointer to status argument structure where the
+ *                      driver returns any status information. The type
+ *                      of the structure is defined by the specific driver.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \param cbParams     [IN] Application callback parameters.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \return non-NULL Fvid2_Handle object pointer on success else returns NULL
+ *  on error.
+ */
+Fvid2_Handle Fvid2_create(UInt32                drvId,
+                          UInt32                instanceId,
+                          Ptr                   createArgs,
+                          Ptr                   createStatusArgs,
+                          const Fvid2_CbParams *cbParams);
+
+/**
+ *  \brief Deletes a previously created FVID2 driver handle.
+ *
+ *  This free's the HW/SW resources allocated during create
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *
+ *  \param deleteArgs   [IN] Pointer to the delete argument structure. The type
+ *                      of the structure is defined by the specific driver.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_delete(Fvid2_Handle handle, Ptr deleteArgs);
+
+/**
+ *  \brief Send control commands (IOCTLs) to the driver.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *
+ *  \param cmd          [IN] IOCTL command. The type of command supported
+ *                      is defined by the specific driver.
+ *
+ *  \param cmdArgs      [IN] Pointer to the command argument structure. The type
+ *                      of the structure is defined by the specific driver
+ *                      for each of the supported IOCTL.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \param cmdStatusArgs [OUT] Pointer to status argument structure where the
+ *                      driver returns any status information. The type
+ *                      of the structure is defined by the specific driver
+ *                      for each of the supported IOCTL.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_control(Fvid2_Handle handle,
+                    UInt32       cmd,
+                    Ptr          cmdArgs,
+                    Ptr          cmdStatusArgs);
+
+/**
+ *  \brief An application calls Fvid2_queue to submit a video buffer to the
+ *  video device driver.
+ *
+ *  - This is used in capture/display drivers.
+ *  - This function could be called from task or ISR context unless the specific
+ *  driver restricts from doing so.
+ *  - This is a non-blocking API unless the specific driver restricts from
+ *  doing so.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param frameList    [IN] Pointer to the frame list structure containing the
+ *                      information about the FVID2 frames that has to be
+ *                      queued in the driver.
+ *  \param streamId     [IN] Stream ID to which the frames should be queued
+ *                      This is used in drivers where they could support
+ *                      multiple streams for the same handle. Otherwise this
+ *                      should be set to zero.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_queue(Fvid2_Handle     handle,
+                  Fvid2_FrameList *frameList,
+                  UInt32           streamId);
+
+/**
+ *  \brief An application calls Fvid2_dequeue to request the video device
+ *  driver to give ownership of a video buffer.
+ *
+ *  - This is used in capture/display drivers.
+ *  - This is a non-blocking API if timeout is FVID2_TIMEOUT_NONE and could be
+ *  called by task and ISR context unless the specific driver restricts from
+ *  doing so.
+ *  - This is blocking API if timeout is FVID2_TIMEOUT_FOREVER if supported by
+ *  specific driver implementation.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param frameList    [OUT] Pointer to the frame list structure where the
+ *                      dequeued frame pointer will be stored.
+ *  \param streamId     [IN] Stream ID from where frames should be dequeued.
+ *                      This is used in drivers where it could support multiple
+ *                      streams for the same handle. Otherwise this
+ *                      should be set to zero.
+ *  \param timeout      [IN] FVID2 timeout in units of OS ticks. This will
+ *                      determine the timeout value till the driver will block
+ *                      for a free or completed buffer is available.
+ *                      For non-blocking drivers this parameter might be
+ *                      ignored.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_dequeue(Fvid2_Handle     handle,
+                    Fvid2_FrameList *frameList,
+                    UInt32           streamId,
+                    UInt32           timeout);
+
+/**
+ *  \brief An application calls Fvid2_processRequest to submit a video buffer
+ *  to the video device driver.
+ *
+ *  This API is used for submitting a single channel video processing request
+ *  to the video device driver. It uses framelist to submit multiple
+ *  frames of different stream ids of the same request.
+ *
+ *  - This function could be called from task or ISR context unless the specific
+ *  driver restricts from doing so.
+ *  - This is a non-blocking API unless the specific driver restricts from
+ *  doing so.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param inFrameList  [IN] Pointer to the array of input frames with
+ *                           different stream ids.
+ *  \param outFrameList [IN] Pointer to the array of output frames with
+ *                           different stream ids
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_processRequest(Fvid2_Handle          handle,
+                           Fvid2_FrameList      *inFrameList,
+                           Fvid2_FrameList      *outFrameList);
+
+/**
+ *  \brief An application calls Fvid2_getProcessedRequest to get the
+ *  processed request back from the driver and thus to get the
+ *  ownership of request back from the driver.
+ *
+ *  - This is a non-blocking API if timeout is FVID2_TIMEOUT_NONE and could be
+ *  called by task and ISR context unless the specific driver restricts from
+ *  doing so.
+ *  - This is blocking API if timeout is FVID2_TIMEOUT_FOREVER if supported by
+ *  specific driver implementation.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param inFrameList  [OUT] Pointer to frame list in which input frames with
+ *                            different stream ids will be returned
+ *                            by the driver.
+ *  \param outFrameList [OUT] Pointer to frame list in which output frames with
+ *                            different stream ids will be returned by
+ *                            the driver.
+ *  \param timeout      [IN] FVID2 timeout. This will determine the timeout
+ *                           value till the driver will block for a
+ *                           free or completed buffer is available.
+ *                           For non-blocking drivers this parameter
+ *                           might be ignored.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+Int32 Fvid2_getProcessedRequest(Fvid2_Handle          handle,
+                                Fvid2_FrameList      *inFrameList,
+                                Fvid2_FrameList      *outFrameList,
+                                UInt32                timeout);
+/**
+ *  \brief An application calls Fvid2_start to request the video device
+ *  driver to start the video display or capture operation.
+ *  This function should be called from task context only and should not be
+ *  called from ISR context.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param cmdArgs      [IN] Pointer to the start argument structure. The type
+ *                      of the structure is defined by the specific driver.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+static inline Int32 Fvid2_start(Fvid2_Handle handle, Ptr cmdArgs);
+
+/**
+ *  \brief An application calls Fvid2_stop to request the video device
+ *  driver to stop the video display or capture operation.
+ *  This function should be called from task context only and should not be
+ *  called from ISR context.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param cmdArgs      [IN] Pointer to the stop argument structure. The type
+ *                      of the structure is defined by the specific driver.
+ *                      This parameter could be NULL depending on whether the
+ *                      actual driver forces it or not.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+static inline Int32 Fvid2_stop(Fvid2_Handle handle, Ptr cmdArgs);
+
+/**
+ *  \brief An application calls Fvid2_setFormat to request the video device
+ *  driver to set the format for a given channel.
+ *  This function should be called from task context only and should not be
+ *  called from ISR context.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param fmt          [IN] Pointer to the FVID2 format structure.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+static inline Int32 Fvid2_setFormat(Fvid2_Handle handle, Fvid2_Format *fmt);
+
+/**
+ *  \brief An application calls Fvid2_getFormat to request the video device
+ *  driver to get the current format for a given channel.
+ *  This function should be called from task context only and should not be
+ *  called from ISR context.
+ *
+ *  \param handle       [IN] FVID2 handle returned by create call.
+ *  \param fmt          [OUT] Pointer to the FVID2 format structure.
+ *
+ *  \return FVID2_SOK on success, else appropriate FVID2 error code on failure.
+ */
+static inline Int32 Fvid2_getFormat(Fvid2_Handle handle, Fvid2_Format *fmt);
+
+/**
+ *  \brief Fvid2_CbParams structure init function.
+ *
+ *  \param cbPrms       [IN] Pointer to #Fvid2_CbParams structure.
+ *
+ */
+static inline void Fvid2CbParams_init(Fvid2_CbParams *cbPrms);
+
+/* ========================================================================== */
+/*                       Static Function Definitions                          */
+/* ========================================================================== */
+
+static inline Int32 Fvid2_start(Fvid2_Handle handle, Ptr cmdArgs)
+{
+    return Fvid2_control(handle, FVID2_START, cmdArgs, NULL);
+}
+
+static inline Int32 Fvid2_stop(Fvid2_Handle handle, Ptr cmdArgs)
+{
+    return Fvid2_control(handle, FVID2_STOP, cmdArgs, NULL);
+}
+
+static inline Int32 Fvid2_setFormat(Fvid2_Handle handle, Fvid2_Format *fmt)
+{
+    return Fvid2_control(handle, FVID2_SET_FORMAT, fmt, NULL);
+}
+
+static inline Int32 Fvid2_getFormat(Fvid2_Handle handle, Fvid2_Format *fmt)
+{
+    return Fvid2_control(handle, FVID2_GET_FORMAT, fmt, NULL);
+}
+
+static inline void Fvid2CbParams_init(Fvid2_CbParams *cbPrms)
+{
+    if (NULL != cbPrms)
+    {
+        cbPrms->cbFxn    = NULL;
+        cbPrms->errCbFxn = NULL;
+        cbPrms->errList  = NULL;
+        cbPrms->appData  = NULL;
+        cbPrms->reserved = NULL;
+    }
+
+    return;
+}
+
+/*
+ *  The deprecated structures and API FVID2_* has been replaced with
+ *  Fvid2_*.
+ *  This has been done to follow coding guidelines and have a uniform
+ *  naming convention.
+ *  If backward compatibility is required, use could enable the below
+ *  macro.
+ *  By default this macro is not enabled.
+ */
+#ifdef FVID2_BACKWARD_COMPATIBLE
+
+/*
+ * Deprecated structures.
+ */
+/** \brief Macro for deprecated structure FVID2_Handle. */
+#define FVID2_Handle                    Fvid2_Handle
+/** \brief Macro for deprecated structure FVID2_CbFxn. */
+#define FVID2_CbFxn                     Fvid2_CbFxn
+/** \brief Macro for deprecated structure FVID2_ErrCbFxn. */
+#define FVID2_ErrCbFxn                  Fvid2_ErrCbFxn
+/** \brief Macro for deprecated structure FVID2_DataFormat. */
+#define FVID2_DataFormat                Fvid2_DataFormat
+/** \brief Macro for deprecated structure FVID2_ScanFormat. */
+#define FVID2_ScanFormat                Fvid2_ScanFormat
+/** \brief Macro for deprecated structure FVID2_Standard. */
+#define FVID2_Standard                  Fvid2_Standard
+/** \brief Macro for deprecated structure FVID2_Fid. */
+#define FVID2_Fid                       Fvid2_Fid
+/** \brief Macro for deprecated structure FVID2_Polarity. */
+#define FVID2_Polarity                  Fvid2_Polarity
+/** \brief Macro for deprecated structure FVID2_EdgePolarity. */
+#define FVID2_EdgePolarity              Fvid2_EdgePolarity
+/** \brief Macro for deprecated structure FVID2_BufferFormat. */
+#define FVID2_BufferFormat              Fvid2_BufferFormat
+/** \brief Macro for deprecated structure FVID2_BitsPerPixel. */
+#define FVID2_BitsPerPixel              Fvid2_BitsPerPixel
+/** \brief Macro for deprecated structure FVID2_CbParams. */
+#define FVID2_CbParams                  Fvid2_CbParams
+/** \brief Macro for deprecated structure FVID2_Format. */
+#define FVID2_Format                    Fvid2_Format
+/** \brief Macro for deprecated structure FVID2_Frame. */
+#define FVID2_Frame                     Fvid2_Frame
+/** \brief Macro for deprecated structure FVID2_FrameList. */
+#define FVID2_FrameList                 Fvid2_FrameList
+/** \brief Macro for deprecated structure FVID2_ProcessList. */
+#define FVID2_ProcessList               Fvid2_ProcessList
+/** \brief Macro for deprecated structure FVID2_ModeInfo. */
+#define FVID2_ModeInfo                  Fvid2_ModeInfo
+
+/*
+ * Deprecated functions.
+ */
+/** \brief Macro for deprecated function FVID2_init. */
+#define FVID2_init                      Fvid2_init
+/** \brief Macro for deprecated function FVID2_deInit. */
+#define FVID2_deInit                    Fvid2_deInit
+/** \brief Macro for deprecated function FVID2_getVersionString. */
+#define FVID2_getVersionString          Fvid2_getVersionString
+/** \brief Macro for deprecated function FVID2_getVersionNumber. */
+#define FVID2_getVersionNumber          Fvid2_getVersionNumber
+/** \brief Macro for deprecated function FVID2_create. */
+#define FVID2_create                    Fvid2_create
+/** \brief Macro for deprecated function FVID2_delete. */
+#define FVID2_delete                    Fvid2_delete
+/** \brief Macro for deprecated function FVID2_control. */
+#define FVID2_control                   Fvid2_control
+/** \brief Macro for deprecated function FVID2_queue. */
+#define FVID2_queue                     Fvid2_queue
+/** \brief Macro for deprecated function FVID2_dequeue. */
+#define FVID2_dequeue                   Fvid2_dequeue
+/** \brief Macro for deprecated function FVID2_processFrames. */
+#define FVID2_processFrames             Fvid2_processFrames
+/** \brief Macro for deprecated function FVID2_getProcessedFrames. */
+#define FVID2_getProcessedFrames        Fvid2_getProcessedFrames
+/** \brief Macro for deprecated function FVID2_start. */
+#define FVID2_start                     Fvid2_start
+/** \brief Macro for deprecated function FVID2_stop. */
+#define FVID2_stop                      Fvid2_stop
+/** \brief Macro for deprecated function FVID2_setFormat. */
+#define FVID2_setFormat                 Fvid2_setFormat
+/** \brief Macro for deprecated function FVID2_getFormat. */
+#define FVID2_getFormat                 Fvid2_getFormat
+/** \brief Macro for deprecated function FVID2_getModeInfo. */
+#define FVID2_getModeInfo               Fvid2_getModeInfo
+/** \brief Macro for deprecated function FVID2_getDataFmtString. */
+#define FVID2_getDataFmtString          Fvid2_getDataFmtString
+/** \brief Macro for deprecated function FVID2_getStandardString. */
+#define FVID2_getStandardString         Fvid2_getStandardString
+/** \brief Macro for deprecated function FVID2_isDataFmtYuv422. */
+#define FVID2_isDataFmtYuv422           Fvid2_isDataFmtYuv422
+/** \brief Macro for deprecated function FVID2_isDataFmtYuv420. */
+#define FVID2_isDataFmtYuv420           Fvid2_isDataFmtYuv420
+/** \brief Macro for deprecated function FVID2_isDataFmtSemiPlanar. */
+#define FVID2_isDataFmtSemiPlanar       Fvid2_isDataFmtSemiPlanar
+/** \brief Macro for deprecated function FVID2_isDataFmtYuv422I. */
+#define FVID2_isDataFmtYuv422I          Fvid2_isDataFmtYuv422I
+/** \brief Macro for deprecated function FVID2_isStandardVesa. */
+#define FVID2_isStandardVesa            Fvid2_isStandardVesa
+/** \brief Macro for deprecated function FVID2CbParams_init. */
+#define FVID2CbParams_init              Fvid2CbParams_init
+/** \brief Macro for deprecated function FVID2Format_init. */
+#define FVID2Format_init                Fvid2Format_init
+/** \brief Macro for deprecated function FVID2SubFrameInfo_init. */
+#define FVID2SubFrameInfo_init          Fvid2SubFrameInfo_init
+/** \brief Macro for deprecated function FVID2Frame_init. */
+#define FVID2Frame_init                 Fvid2Frame_init
+/** \brief Macro for deprecated function FVID2FrameList_init. */
+#define FVID2FrameList_init             Fvid2FrameList_init
+/** \brief Macro for deprecated function FVID2ProcessList_init. */
+#define FVID2ModeInfo_init              Fvid2ModeInfo_init
+
+#endif  /* #ifdef FVID2_BACKWARD_COMPATIBLE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* #ifndef FVID2_H_ */
+
+/* @} */
diff --git a/include/fvid2_drvMgr.h b/include/fvid2_drvMgr.h
new file mode 100644 (file)
index 0000000..90a62ea
--- /dev/null
@@ -0,0 +1,323 @@
+/* =============================================================================
+ *   Copyright (c) Texas Instruments Incorporated 2012-2018
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ *  \file fvid2_drvMgr.h
+ *
+ *  \brief FVID2 driver manager header file.
+ *
+ *  This file exposes internal functions of driver management functionality.
+ *  This is not used by application and is used by video drivers to register
+ *  itself to the FVID2.
+ *
+ */
+
+#ifndef FVID2_DRVMGR_H_
+#define FVID2_DRVMGR_H_
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+
+#include <fvid2.h>
+/* This is needed for memset/memcpy */
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+
+/** \brief Number of driver object to allocate in FVID2 library. */
+#define FVID2_CFG_FDM_NUM_DRV_OBJS          (40U)
+
+/** \brief Number of channel object to allocate in FVID2 library. */
+#define FVID2_CFG_FDM_NUM_CH_OBJS           (80U)
+
+
+
+/** \brief FVID2 driver handle returned by individual drivers. */
+typedef Ptr Fdrv_Handle;
+
+/** \brief Typedef for callback function parameters. */
+typedef struct Fvid2_DrvCbParams_t Fvid2_DrvCbParams;
+
+/**
+ *  \brief Typedef for FVID2 driver callback function prototype. This will be
+ *  called by the driver and then the FVID2 driver manager will route the
+ *  callback to the application.
+ *
+ *  fdmData: FVID2 driver manager internal data passed to driver during create
+ *  call.
+ *
+ *  reserved: For future use. Not used currently. This will be set to NULL.
+ */
+typedef Int32 (*Fdm_CbFxn)(Ptr fdmData, Ptr reserved);
+
+/**
+ *  \brief Typedef for FVID2 driver error callback function prototype.
+ *  This will be called by the driver and then the FVID2 driver manager
+ *  will route the error callback to the application.
+ *
+ *  fdmData: FVID2 driver manager internal data passed to driver during create
+ *  call.
+ *
+ *  errList: Error data passed to the application.
+ *
+ *  reserved: For future use. Not used currently. This will be set to NULL.
+ */
+typedef Int32 (*Fdm_ErrCbFxn)(Ptr fdmData, void *errList, Ptr reserved);
+
+/** \brief Typedef for FVID2 create function pointer. */
+typedef Fdrv_Handle (*Fvid2_DrvCreate)(UInt32                   drvId,
+                                       UInt32                   instanceId,
+                                       Ptr                      createArgs,
+                                       Ptr
+                                       createStatusArgs,
+                                       const Fvid2_DrvCbParams *fdmCbParams);
+
+/** \brief Typedef for FVID2 delete function pointer. */
+typedef Int32 (*Fvid2_DrvDelete)(Fdrv_Handle handle, Ptr deleteArgs);
+
+/** \brief Typedef for FVID2 control function pointer. */
+typedef Int32 (*Fvid2_DrvControl)(Fdrv_Handle handle,
+                                  UInt32      cmd,
+                                  Ptr         cmdArgs,
+                                  Ptr         cmdStatusArgs);
+
+/** \brief Typedef for FVID2 queue function pointer. */
+typedef Int32 (*Fvid2_DrvQueue)(Fdrv_Handle      handle,
+                                Fvid2_FrameList *frameList,
+                                UInt32           streamId);
+
+/** \brief Typedef for FVID2 dequeue function pointer. */
+typedef Int32 (*Fvid2_DrvDequeue)(Fdrv_Handle      handle,
+                                  Fvid2_FrameList *frameList,
+                                  UInt32           streamId,
+                                  UInt32           timeout);
+
+/** \brief Typedef for FVID2 process frames function pointer. */
+typedef Int32 (*Fvid2_DrvProcessRequest)(Fdrv_Handle        handle,
+                                         Fvid2_FrameList   *inProcessList,
+                                         Fvid2_FrameList   *outProcessList);
+
+/** \brief Typedef for FVID2 get processed frames function pointer. */
+typedef Int32 (*Fvid2_DrvGetProcessedRequest)(Fdrv_Handle        handle,
+                                              Fvid2_FrameList   *inProcessList,
+                                              Fvid2_FrameList   *outProcessList,
+                                              UInt32             timeout);
+
+
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+
+/**
+ *  struct Fvid2_DrvCbParams_t
+ *  \brief Structure for setting callback function parameters.
+ */
+struct Fvid2_DrvCbParams_t
+{
+    Fdm_CbFxn    fdmCbFxn;
+    /**< FDM callback function used by the driver to initimate any
+     *   operation has completed or not. */
+    Fdm_ErrCbFxn fdmErrCbFxn;
+    /**< FDM error callback function used by the driver to initimate
+     *   any error occuring at the time of streaming. */
+    Fvid2_Handle handle;
+    /**< FDM layer FVID2 handle. This can be used by the actual driver to call
+     *   application callback with proper FVID2 handle instead of routining
+     *   the call through FDM layer. */
+    void        *errList;
+    /**< Pointer to a valid framelist or processlist where the driver
+     *   copies the aborted/error packet. */
+    Ptr          fdmData;
+    /**< FDM specific data which is returned in the callback function
+     *   as it is. */
+    Ptr          reserved;
+    /**< For future use. Not used currently. Set this to NULL. */
+};
+
+/**
+ *  struct Fvid2_DrvOps
+ *  \brief Structure to store driver function pointers.
+ */
+typedef struct
+{
+    UInt32                      drvId;
+    /**< Unique driver Id. */
+    Fvid2_DrvCreate             createFxn;
+    /**< FVID2 create function pointer. */
+    Fvid2_DrvDelete             deleteFxn;
+    /**< FVID2 delete function pointer. */
+    Fvid2_DrvControl            controlFxn;
+    /**< FVID2 control function pointer. */
+    Fvid2_DrvQueue              queueFxn;
+    /**< FVID2 queue function pointer. */
+    Fvid2_DrvDequeue            dequeueFxn;
+    /**< FVID2 dequeue function pointer. */
+    Fvid2_DrvProcessRequest     processRequestFxn;
+    /**< FVID2 process request function pointer. */
+    Fvid2_DrvGetProcessedRequest getProcessedRequestFxn;
+    /**< FVID2 get processed request function pointer. */
+} Fvid2_DrvOps;
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+
+/**
+ *  Fvid2_registerDriver
+ *  \brief FVID2 register driver function.
+ *
+ *  This function registers a driver with the FVID2 driver manager.
+ *
+ *  \param drvOps       Driver function table pointer containing driver
+ *                      function pointers and driver name. The driver name
+ *                      should be unique - two or more drivers can't have the
+ *                      same driver name.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+Int32 Fvid2_registerDriver(const Fvid2_DrvOps *drvOps);
+
+/**
+ *  Fvid2_unRegisterDriver
+ *  \brief FVID2 unregister driver function.
+ *
+ *  This function unregisters a driver from the FVID2 driver manager.
+ *
+ *  \param drvOps       Driver function table pointer containing driver
+ *                      function pointers and driver name.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+Int32 Fvid2_unRegisterDriver(const Fvid2_DrvOps *drvOps);
+
+/**
+ *  Fvid2_checkFrameList
+ *  \brief Checks the FVID2 frame list for error and returns appropriate error.
+ *
+ *  This is used by the drivers and not by the application.
+ *
+ *  \param frameList    Pointer to frame list to check for errors.
+ *  \param maxFrames    Max frames to be checked against numFrames member
+ *                      in frame list.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+Int32 Fvid2_checkFrameList(const Fvid2_FrameList *frameList, UInt32 maxFrames);
+
+/**
+ *  Fvid2_checkDqFrameList
+ *  \brief Checks the FVID2 frame list of dequeue call for error and returns
+ *  appropriate error. For dequeue operation, the frame pointers in the frames
+ *  should not be checked as this will be filled by the driver.
+ *
+ *  This is used by the drivers and not by the application.
+ *
+ *  \param frameList    Pointer to frame list to check for errors.
+ *  \param maxFrames    Max frames to be checked against numFrames member
+ *                      in frame list.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+Int32 Fvid2_checkDqFrameList(const Fvid2_FrameList *frameList,
+                             UInt32                 maxFrames);
+
+/**
+ *  Fvid2_copyFrameList
+ *  \brief Copies the source frame list to the destination frame list.
+ *  This also resets the frame pointers from the source frame list.
+ *
+ *  This is used by the drivers and not by the application.
+ *
+ *  \param dest         Pointer to destination frame list.
+ *  \param src          Pointer to source frame list.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+void Fvid2_copyFrameList(Fvid2_FrameList *dest, Fvid2_FrameList *src);
+
+/**
+ *  Fvid2_duplicateFrameList
+ *  \brief Duplicate the source frame list to the destination frame list.
+ *  This does not reset the frame pointers from the source frame list.
+ *
+ *  This is used by the drivers and not by the application.
+ *
+ *  \param dest         Pointer to destination frame list.
+ *  \param src          Pointer to source frame list.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+void Fvid2_duplicateFrameList(Fvid2_FrameList       *dest,
+                              const Fvid2_FrameList *src);
+
+/**
+ *  \brief Fvid2_DrvOps structure init function.
+ *
+ *  \param drvOps   [IN] Pointer to #Fvid2_DrvOps structure.
+ *
+ */
+static inline void Fvid2DrvOps_init(Fvid2_DrvOps *drvOps);
+
+/* ========================================================================== */
+/*                       Static Function Definitions                          */
+/* ========================================================================== */
+
+static inline void Fvid2DrvOps_init(Fvid2_DrvOps *drvOps)
+{
+    if (NULL != drvOps)
+    {
+        drvOps->drvId                   = 0U;
+        drvOps->createFxn               = NULL;
+        drvOps->deleteFxn               = NULL;
+        drvOps->controlFxn              = NULL;
+        drvOps->queueFxn                = NULL;
+        drvOps->dequeueFxn              = NULL;
+        drvOps->processRequestFxn       = NULL;
+        drvOps->getProcessedRequestFxn  = NULL;
+    }
+
+    return;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef FVID2_DRVMGR_H_ */
diff --git a/src/fvid2_drvMgr.c b/src/fvid2_drvMgr.c
new file mode 100644 (file)
index 0000000..9f85c52
--- /dev/null
@@ -0,0 +1,1448 @@
+/* =============================================================================
+ *   Copyright (c) Texas Instruments Incorporated 2012-2015
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ *  \file fvid2_drvMgr.c
+ *
+ *  \brief FVID2 driver manager layer.
+ *  This file implements driver management functionality.
+ *
+ */
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+
+#include <ti/csl/tistdtypes.h>
+#include <csl_fvid2_dataTypes.h>
+#include <fvid2_drvMgr.h>
+#include <ti/osal/osal.h>
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+
+/** \brief Number of entries in FVID2 standard info table. */
+#define FDM_NUM_STD_INFO_ENTRIES        (sizeof (gFdmStdInfoTable) / \
+                                         sizeof (Fvid2_ModeInfo))
+
+/** \brief Number of entries in FVID2 standard info table. */
+#define FDM_NUM_DATA_FMT_STR_ENTRIES    (sizeof (gFdmDataFmtStrTable) / \
+                                         sizeof (Fdm_DataFmtString))
+
+/** \brief Number of entries in FVID2 standard info table. */
+#define FDM_NUM_STD_STR_ENTRIES         (sizeof (gFdmStdStrTable) / \
+                                         sizeof (Fdm_StdString))
+
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+
+/**
+ *  struct Fdm_Driver
+ *  \brief Structure to store driver information.
+ */
+typedef struct
+{
+    const Fvid2_DrvOps *drvOps;
+    /**< Driver operation table pointer. */
+    UInt32              numOpens;
+    /**< Number of times the driver is opened using create API. */
+    UInt32              isUsed;
+    /**< Flag indicating whether the object is used or not. */
+} Fdm_Driver;
+
+/**
+ *  struct Fdm_Channel
+ *  \brief Structure to store channel information.
+ */
+typedef struct
+{
+    Fdm_Driver    *drv;
+    /**< Pointer to the driver object to which this channel is created. */
+    Fdrv_Handle    drvHandle;
+    /**< Driver handle returned by the actual driver. */
+    Fvid2_CbParams cbParams;
+    /**< Application call back parameters. */
+    UInt32         isUsed;
+    /**< Flag indicating whether the object is used or not. */
+} Fdm_Channel;
+
+/**
+ *  struct Fdm_DataFmtString
+ *  \brief Structure to store data format and string pair.
+ */
+typedef struct
+{
+    Fvid2_DataFormat dataFmt;
+    /**< Data format. */
+    const Char      *dataFmtStr;
+    /**< Pointer to data format string. */
+} Fdm_DataFmtString;
+
+/**
+ *  struct Fdm_StdString
+ *  \brief Structure to store standard and string pair.
+ */
+typedef struct
+{
+    Fvid2_Standard standard;
+    /**< Standard. */
+    const Char    *stdStr;
+    /**< Pointer to data format string. */
+} Fdm_StdString;
+
+/**
+ *  struct Fdm_Object
+ *  \brief Struture to store all global objects.
+ */
+typedef struct
+{
+    Char             *versionString;
+    /**< FVID2 drivers version number as string. */
+    UInt32            versionNumber;
+    /**< FVID2 drivers version number as string. */
+    Fdm_Driver        fdmDriverObjects[FVID2_CFG_FDM_NUM_DRV_OBJS];
+    /**< FDM Driver objects. */
+    Fdm_Channel       fdmChannelObjects[FVID2_CFG_FDM_NUM_CH_OBJS];
+    /**< FDM Channel objects. */
+    SemaphoreP_Handle lockSem;
+    /**< Semaphore to protect function calls and other memory allocation. */
+} Fdm_Object;
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+/**
+ *  Below ifdef __cplusplus is added so that C++ build passes without
+ *  typecasting. This is because the prototype is build as C type
+ *  whereas this file is build as CPP file. Hence we get C++ build error.
+ *  Also if tyecasting is used, then we get MisraC error Rule 11.1.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+static Int32 fdmDriverCbFxn(Ptr fdmData, Ptr reserved);
+static Int32 fdmDriverErrCbFxn(Ptr fdmData, void *errList, Ptr reserved);
+static Fdm_Driver *fdmAllocDriverObject(void);
+static Int32 fdmFreeDriverObject(const Fvid2_DrvOps *drvOps);
+static Fdm_Channel *fdmAllocChannelObject(void);
+static Int32 fdmFreeChannelObject(Fdm_Channel *channel);
+static void Fvid2_printf(const char *format, ...);
+static void Fvid2_memset(void *mem, int32_t ch, uint32_t byteCount);
+static void Fvid2_memcpy(void *dest, const void *src, uint32_t byteCount);
+#ifdef __cplusplus
+}
+#endif
+/* ========================================================================== */
+/*                            Global Variables                                */
+/* ========================================================================== */
+
+/** \brief FDM objects. */
+static Fdm_Object        gFdmObj;
+
+/** \brief FVID2 standard information table. */
+static Fvid2_ModeInfo    gFdmStdInfoTable[] =
+{
+    /* Standard, FrameWidth, FrameHeight, ScanFormat, PixelClock (KHz), FPS,
+     * Reserved */
+    {FVID2_STD_NTSC,           720U,  480U,  FVID2_SF_INTERLACED,
+     27000U,
+     30U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_PAL,            720U,  576U,  FVID2_SF_INTERLACED, 27000U,   25U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_480I,           720U,  480U,  FVID2_SF_INTERLACED, 27000U,   30U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_576I,           720U,  576U,  FVID2_SF_INTERLACED, 27000U,   25U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_480P,           720U,  480U,  FVID2_SF_PROGRESSIVE,27000U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_576P,           720U,  576U,  FVID2_SF_PROGRESSIVE,27000U,   50U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_720P_60,        1280U, 720U,  FVID2_SF_PROGRESSIVE,74250U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_720P_50,        1280U, 720U,  FVID2_SF_PROGRESSIVE,74250U,   50U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1080I_60,       1920U, 1080U, FVID2_SF_INTERLACED, 74250U,   30U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1080I_50,       1920U, 1080U, FVID2_SF_INTERLACED, 74250U,   25U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1080P_60,       1920U, 1080U, FVID2_SF_PROGRESSIVE,148500U,  60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1080P_50,       1920U, 1080U, FVID2_SF_PROGRESSIVE,148500U,  50U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1080P_24,       1920U, 1080U, FVID2_SF_PROGRESSIVE,74250U,   24U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1080P_30,       1920U, 1080U, FVID2_SF_PROGRESSIVE,74250U,   30U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_VGA_60,         640U,  480U,  FVID2_SF_PROGRESSIVE,25175U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_VGA_72,         640U,  480U,  FVID2_SF_PROGRESSIVE,31500U,   72U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_VGA_75,         640U,  480U,  FVID2_SF_PROGRESSIVE,31500U,   75U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_VGA_85,         640U,  480U,  FVID2_SF_PROGRESSIVE,36000U,   85U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WVGA_60,        800U,  480U,  FVID2_SF_PROGRESSIVE,33500U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SVGA_60,        800U,  600U,  FVID2_SF_PROGRESSIVE,40000U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SVGA_72,        800U,  600U,  FVID2_SF_PROGRESSIVE,50000U,   72U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SVGA_75,        800U,  600U,  FVID2_SF_PROGRESSIVE,49500U,   75U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SVGA_85,        800U,  600U,  FVID2_SF_PROGRESSIVE,56250U,   85U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WSVGA_70,       1024U, 600U,  FVID2_SF_PROGRESSIVE,50800U,   70U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_XGA_60,         1024U, 768U,  FVID2_SF_PROGRESSIVE,65000U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_XGA_DSS_TDM_60, 1024U, 768U,  FVID2_SF_PROGRESSIVE,64000U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_XGA_70,         1024U, 768U,  FVID2_SF_PROGRESSIVE,75000U,   70U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_XGA_75,         1024U, 768U,  FVID2_SF_PROGRESSIVE,78750U,   75U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_XGA_85,         1024U, 768U,  FVID2_SF_PROGRESSIVE,94500U,   85U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WXGA_30,        1280U, 800U,  FVID2_SF_PROGRESSIVE,34125U,   30U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WXGA_60,        1280U, 800U,  FVID2_SF_PROGRESSIVE,83500U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WXGA_75,        1280U, 800U,  FVID2_SF_PROGRESSIVE,102250U,  75U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WXGA_85,        1280U, 800U,  FVID2_SF_PROGRESSIVE,117500U,  85U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1440_900_60,    1440U, 900U,  FVID2_SF_PROGRESSIVE,106500U,  60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1368_768_60,    1368U, 768U,  FVID2_SF_PROGRESSIVE,85860U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1366_768_60,    1366U, 768U,  FVID2_SF_PROGRESSIVE,85500U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_1360_768_60,    1360U, 768U,  FVID2_SF_PROGRESSIVE,85500U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SXGA_60,        1280U, 1024U, FVID2_SF_PROGRESSIVE,108000U,  60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SXGA_75,        1280U, 1024U, FVID2_SF_PROGRESSIVE,135000U,  75U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SXGA_85,        1280U, 1024U, FVID2_SF_PROGRESSIVE,157500U,  85U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WSXGAP_60,      1680U, 1050U, FVID2_SF_PROGRESSIVE,146250U,  60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SXGAP_60,       1400U, 1050U, FVID2_SF_PROGRESSIVE,121750U,  60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_SXGAP_75,       1400U, 1050U, FVID2_SF_PROGRESSIVE,156000U,  75U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_UXGA_60,        1600U, 1200U, FVID2_SF_PROGRESSIVE,162000U,  60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WXGA_5x3_30,    1280U, 800U,  FVID2_SF_PROGRESSIVE,34125U,   30U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WXGA_5x3_60,    1280U, 800U,  FVID2_SF_PROGRESSIVE,68250U,   60U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}},
+    {FVID2_STD_WXGA_5x3_75,    1280U, 800U,  FVID2_SF_PROGRESSIVE,102250U,  75U,
+     0U, 0U, 0U, 0U, 0U, 0U,{0U,                       0U,    0U,    0U}}
+};
+
+/** \brief Data format string table. */
+static Fdm_DataFmtString gFdmDataFmtStrTable[] =
+{
+    {FVID2_DF_YUV422I_UYVY,           "YUV422I_UYVY"          },
+    {FVID2_DF_YUV422I_YUYV,           "YUV422I_YUYV"          },
+    {FVID2_DF_YUV422I_YVYU,           "YUV422I_YVYU"          },
+    {FVID2_DF_YUV422I_VYUY,           "YUV422I_VYUY"          },
+    {FVID2_DF_YUV422SP_UV,            "YUV422SP_UV"           },
+    {FVID2_DF_YUV422SP_VU,            "YUV422SP_VU"           },
+    {FVID2_DF_YUV422P,                "YUV422P"               },
+    {FVID2_DF_YUV420SP_UV,            "YUV420SP_UV"           },
+    {FVID2_DF_YUV420SP_VU,            "YUV420SP_VU"           },
+    {FVID2_DF_YUV420P,                "YUV420P"               },
+    {FVID2_DF_YUV444P,                "YUV444P"               },
+    {FVID2_DF_YUV444I,                "YUV444I"               },
+    {FVID2_DF_RGB16_565,              "RGB16_565"             },
+    {FVID2_DF_ARGB16_1555,            "ARGB16_1555"           },
+    {FVID2_DF_RGBA16_5551,            "RGBA16_5551"           },
+    {FVID2_DF_ARGB16_4444,            "ARGB16_4444"           },
+    {FVID2_DF_RGBA16_4444,            "RGBA16_4444"           },
+    {FVID2_DF_BGRX_4444,              "RGBX12_4444"           },
+    {FVID2_DF_XBGR_4444,              "XRGB12_4444"           },
+    {FVID2_DF_ARGB24_6666,            "ARGB24_6666"           },
+    {FVID2_DF_RGBA24_6666,            "RGBA24_6666"           },
+    {FVID2_DF_RGB24_888,              "RGB24_888"             },
+    {FVID2_DF_XBGR24_8888,            "XBGR24_8888"           },
+    {FVID2_DF_RGBX24_8888,            "RGBX24_8888"           },
+    {FVID2_DF_BGRX24_8888,            "BGRX24_8888"           },
+    {FVID2_DF_ARGB32_8888,            "ARGB32_8888"           },
+    {FVID2_DF_RGBA32_8888,            "RGBA32_8888"           },
+    {FVID2_DF_BGR16_565,              "BGR16_565"             },
+    {FVID2_DF_ABGR16_1555,            "ABGR16_1555"           },
+    {FVID2_DF_ABGR16_4444,            "ABGR16_4444"           },
+    {FVID2_DF_BGRA16_5551,            "BGRA16_5551"           },
+    {FVID2_DF_BGRA16_4444,            "BGRA16_4444"           },
+    {FVID2_DF_AGBR16_1555,            "AGBR16_1555"           },
+    {FVID2_DF_AGBR16_4444,            "AGBR16_4444"           },
+    {FVID2_DF_XGBR16_1555,            "XGBR16_1555"           },
+    {FVID2_DF_BGRX16_5551,            "BGRX16_5551"           },
+    {FVID2_DF_ABGR24_6666,            "ABGR24_6666"           },
+    {FVID2_DF_BGR24_888,              "BGR24_888"             },
+    {FVID2_DF_ABGR32_8888,            "ABGR32_8888"           },
+    {FVID2_DF_BGRA24_6666,            "BGRA24_6666"           },
+    {FVID2_DF_BGRA32_8888,            "BGRA32_8888"           },
+    {FVID2_DF_BITMAP8,                "BITMAP8"               },
+    {FVID2_DF_BITMAP4_LOWER,          "BITMAP4_LOWER"         },
+    {FVID2_DF_BITMAP4_UPPER,          "BITMAP4_UPPER"         },
+    {FVID2_DF_BITMAP2_OFFSET0,        "BITMAP2_OFFSET0"       },
+    {FVID2_DF_BITMAP2_OFFSET1,        "BITMAP2_OFFSET1"       },
+    {FVID2_DF_BITMAP2_OFFSET2,        "BITMAP2_OFFSET2"       },
+    {FVID2_DF_BITMAP2_OFFSET3,        "BITMAP2_OFFSET3"       },
+    {FVID2_DF_BITMAP1_OFFSET0,        "BITMAP1_OFFSET0"       },
+    {FVID2_DF_BITMAP1_OFFSET1,        "BITMAP1_OFFSET1"       },
+    {FVID2_DF_BITMAP1_OFFSET2,        "BITMAP1_OFFSET2"       },
+    {FVID2_DF_BITMAP1_OFFSET3,        "BITMAP1_OFFSET3"       },
+    {FVID2_DF_BITMAP1_OFFSET4,        "BITMAP1_OFFSET4"       },
+    {FVID2_DF_BITMAP1_OFFSET5,        "BITMAP1_OFFSET5"       },
+    {FVID2_DF_BITMAP1_OFFSET6,        "BITMAP1_OFFSET6"       },
+    {FVID2_DF_BITMAP1_OFFSET7,        "BITMAP1_OFFSET7"       },
+    {FVID2_DF_BITMAP8_BGRA32,         "BITMAP8_BGRA32"        },
+    {FVID2_DF_BITMAP4_BGRA32_LOWER,   "BITMAP4_BGRA32_LOWER"  },
+    {FVID2_DF_BITMAP4_BGRA32_UPPER,   "BITMAP4_BGRA32_UPPER"  },
+    {FVID2_DF_BITMAP2_BGRA32_OFFSET0, "BITMAP2_BGRA32_OFFSET0"},
+    {FVID2_DF_BITMAP2_BGRA32_OFFSET1, "BITMAP2_BGRA32_OFFSET1"},
+    {FVID2_DF_BITMAP2_BGRA32_OFFSET2, "BITMAP2_BGRA32_OFFSET2"},
+    {FVID2_DF_BITMAP2_BGRA32_OFFSET3, "BITMAP2_BGRA32_OFFSET3"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET0, "BITMAP1_BGRA32_OFFSET0"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET1, "BITMAP1_BGRA32_OFFSET1"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET2, "BITMAP1_BGRA32_OFFSET2"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET3, "BITMAP1_BGRA32_OFFSET3"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET4, "BITMAP1_BGRA32_OFFSET4"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET5, "BITMAP1_BGRA32_OFFSET5"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET6, "BITMAP1_BGRA32_OFFSET6"},
+    {FVID2_DF_BITMAP1_BGRA32_OFFSET7, "BITMAP1_BGRA32_OFFSET7"},
+    {FVID2_DF_BAYER_RAW,              "BAYER_RAW"             },
+    {FVID2_DF_BAYER_GRBG,             "BAYER_GRBG"            },
+    {FVID2_DF_BAYER_RGGB,             "BAYER_RGGB"            },
+    {FVID2_DF_BAYER_BGGR,             "BAYER_BGGR"            },
+    {FVID2_DF_BAYER_GBRG,             "BAYER_GBRG"            },
+    {FVID2_DF_RAW_VBI,                "RAW_VBI"               },
+    {FVID2_DF_RAW24,                  "RAW24"                 },
+    {FVID2_DF_RAW16,                  "RAW16"                 },
+    {FVID2_DF_RAW08,                  "RAW08"                 },
+    {FVID2_DF_BGRX32_8888,            "BGRX32_8888"           },
+    {FVID2_DF_BGRA16_1555,            "BGRA16_1555"           },
+    {FVID2_DF_BGRX16_1555,            "BGRX16_1555"           },
+    {FVID2_DF_BGRA32_1010102,         "BGRA32_1010102"        },
+    {FVID2_DF_BGRX32_1010102,         "BGRX32_1010102"        },
+    {FVID2_DF_RGBA32_1010102,         "RGBA32_1010102"        },
+    {FVID2_DF_RGBX32_1010102,         "RGBX32_1010102"        },
+    {FVID2_DF_BGRA64_16161616,        "BGRA64_16161616"       },
+    {FVID2_DF_BGRX64_16161616,        "BGRX64_16161616"       },
+    {FVID2_DF_ABGR64_16161616,        "ABGR64_16161616"       },
+    {FVID2_DF_XBGR64_16161616,        "XBGR64_16161616"       },
+    {FVID2_DF_XRGB32_8888,            "XRGB32_8888"           },
+    {FVID2_DF_RGBX16_4444,            "RGBX16_4444"           },
+    {FVID2_DF_BGR16_565_A8,           "BRG16_565_A8"          },
+    {FVID2_DF_RGB16_565_A8,           "RGB16_565_A8"          },
+    {FVID2_DF_MISC,                   "MISC"                  },
+    {FVID2_DF_INVALID,                "INVALID"               },
+};
+
+/** \brief Standard string table. */
+static Fdm_StdString     gFdmStdStrTable[] =
+{
+    {FVID2_STD_NTSC,            "NTSC"           },
+    {FVID2_STD_PAL,             "PAL"            },
+    {FVID2_STD_480I,            "480I"           },
+    {FVID2_STD_576I,            "576I"           },
+    {FVID2_STD_CIF,             "CIF"            },
+    {FVID2_STD_HALF_D1,         "HALF_D1"        },
+    {FVID2_STD_D1,              "D1"             },
+    {FVID2_STD_480P,            "480P"           },
+    {FVID2_STD_576P,            "576P"           },
+    {FVID2_STD_720P_60,         "720P60"         },
+    {FVID2_STD_720P_50,         "720P50"         },
+    {FVID2_STD_1080I_60,        "1080I60"        },
+    {FVID2_STD_1080I_50,        "1080I50"        },
+    {FVID2_STD_1080P_60,        "1080P60"        },
+    {FVID2_STD_1080P_50,        "1080P50"        },
+    {FVID2_STD_1080P_24,        "1080P24"        },
+    {FVID2_STD_1080P_30,        "1080P30"        },
+    {FVID2_STD_VGA_60,          "VGA60"          },
+    {FVID2_STD_VGA_72,          "VGA72"          },
+    {FVID2_STD_VGA_75,          "VGA75"          },
+    {FVID2_STD_VGA_85,          "VGA85"          },
+    {FVID2_STD_WVGA_60,         "WVGA60"         },
+    {FVID2_STD_SVGA_60,         "SVGA60"         },
+    {FVID2_STD_SVGA_72,         "SVGA72"         },
+    {FVID2_STD_SVGA_75,         "SVGA75"         },
+    {FVID2_STD_SVGA_85,         "SVGA85"         },
+    {FVID2_STD_WSVGA_70,        "WSVGA70"        },
+    {FVID2_STD_XGA_60,          "XGA60"          },
+    {FVID2_STD_XGA_DSS_TDM_60,  "XGA_DSS_TDM_60" },
+    {FVID2_STD_XGA_70,          "XGA70"          },
+    {FVID2_STD_XGA_75,          "XGA75"          },
+    {FVID2_STD_XGA_85,          "XGA85"          },
+    {FVID2_STD_WXGA_30,         "WXGA30"         },
+    {FVID2_STD_WXGA_60,         "WXGA60"         },
+    {FVID2_STD_WXGA_75,         "WXGA75"         },
+    {FVID2_STD_WXGA_85,         "WXGA85"         },
+    {FVID2_STD_1440_900_60,     "1440X900@60"    },
+    {FVID2_STD_1368_768_60,     "1368X768@60"    },
+    {FVID2_STD_1366_768_60,     "1366X768@60"    },
+    {FVID2_STD_1360_768_60,     "1360X768@60"    },
+    {FVID2_STD_SXGA_60,         "SXGA60"         },
+    {FVID2_STD_SXGA_75,         "SXGA75"         },
+    {FVID2_STD_SXGA_85,         "SXGA85"         },
+    {FVID2_STD_WSXGAP_60,       "WSXGAP60"       },
+    {FVID2_STD_SXGAP_60,        "SXGAP60"        },
+    {FVID2_STD_SXGAP_75,        "SXGAP75"        },
+    {FVID2_STD_UXGA_60,         "UXGA60"         },
+    {FVID2_STD_MUX_2CH_D1,      "MUX_2CH_D1"     },
+    {FVID2_STD_MUX_2CH_HALF_D1, "MUX_2CH_HALF_D1"},
+    {FVID2_STD_MUX_2CH_CIF,     "MUX_2CH_CIF"    },
+    {FVID2_STD_MUX_4CH_D1,      "MUX_4CH_D1"     },
+    {FVID2_STD_MUX_4CH_CIF,     "MUX_4CH_CIF"    },
+    {FVID2_STD_MUX_4CH_HALF_D1, "MUX_4CH_HALF_D1"},
+    {FVID2_STD_MUX_8CH_CIF,     "MUX_8CH_CIF"    },
+    {FVID2_STD_MUX_8CH_HALF_D1, "MUX_8CH_HALF_D1"},
+    {FVID2_STD_WXGA_5x3_30,     "WXGA_5x3_30"    },
+    {FVID2_STD_WXGA_5x3_60,     "WXGA_5x3_60"    },
+    {FVID2_STD_WXGA_5x3_75,     "WXGA_5x3_75"    },
+    {FVID2_STD_AUTO_DETECT,     "AUTO_DETECT"    },
+    {FVID2_STD_CUSTOM,          "CUSTOM"         },
+};
+
+/* ========================================================================== */
+/*                          Function Definitions                              */
+/* ========================================================================== */
+
+/**
+ *  Fvid2_init
+ *  \brief FVID2 init function.
+ *
+ *  Initializes the drivers and the hardware.
+ *  This function should be called before calling any of driver API's.
+ *
+ *  \param arg          Not used currently. Meant for future purpose.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+Int32 Fvid2_init(Ptr args)
+{
+    UInt32 cnt;
+    Int32  retVal = FVID2_SOK;
+    Int32  initValue;
+    SemaphoreP_Params params;
+
+    /* Init all global variables to zero */
+    Fvid2_memset(&gFdmObj, 0U, sizeof (gFdmObj));
+
+    /* Mark pool flags as free */
+    for (cnt = 0u; cnt < FVID2_CFG_FDM_NUM_DRV_OBJS; cnt++)
+    {
+        gFdmObj.fdmDriverObjects[cnt].isUsed = (UInt32) FALSE;
+    }
+    for (cnt = 0u; cnt < FVID2_CFG_FDM_NUM_CH_OBJS; cnt++)
+    {
+        gFdmObj.fdmChannelObjects[cnt].isUsed = (UInt32) FALSE;
+    }
+
+    gFdmObj.versionString = FVID2_VERSION_STRING;
+    gFdmObj.versionNumber = FVID2_VERSION_NUMBER;
+
+    /* Allocate lock semaphore */
+    SemaphoreP_Params_init(&params);
+    params.mode = SemaphoreP_Mode_BINARY;
+    initValue       = 1;
+    gFdmObj.lockSem = SemaphoreP_create(initValue, &params);
+    if (NULL == gFdmObj.lockSem)
+    {
+        Fvid2_printf("FVID2 semaphore create failed!!\r\n");
+        retVal = FVID2_EALLOC;
+    }
+
+    /* Free-up memory if error occurs */
+    if (FVID2_SOK != retVal)
+    {
+        Fvid2_deInit(NULL);
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_deInit
+ *  \brief FVID2 deinit function.
+ *
+ *  Uninitializes the drivers and the hardware.
+ *
+ *  \param arg          Not used currently. Meant for future purpose.
+ *
+ *  \return             Returns 0 on success else returns error value.
+ */
+Int32 Fvid2_deInit(Ptr args)
+{
+    Int32 retVal = FVID2_SOK;
+
+    /* Delete the lock semaphore */
+    if (NULL != gFdmObj.lockSem)
+    {
+        SemaphoreP_delete(gFdmObj.lockSem);
+        gFdmObj.lockSem = NULL;
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_getVersionString
+ *  \brief Get the FVID2 driver version in string form. This API can be
+ *  called before calling #Fvid2_init().
+ *
+ *  \return             Returns pointer to FVID2 version string.
+ */
+const Char *Fvid2_getVersionString(void)
+{
+    return (FVID2_VERSION_STRING);
+}
+
+/**
+ *  Fvid2_getVersionNumber
+ *  \brief Get the FVID2 driver version in number form. This API can be
+ *  called before calling #Fvid2_init().
+ *
+ *  \return             FVID2 version number.
+ */
+UInt32 Fvid2_getVersionNumber(void)
+{
+    return (FVID2_VERSION_NUMBER);
+}
+
+/**
+ *  Fvid2_registerDriver
+ *  \brief FVID2 register driver function.
+ */
+Int32 Fvid2_registerDriver(const Fvid2_DrvOps *drvOps)
+{
+    Int32       retVal = FVID2_SOK;
+    Fdm_Driver *drv;
+    UInt32      cnt;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == drvOps);
+
+    SemaphoreP_pend(gFdmObj.lockSem, SemaphoreP_WAIT_FOREVER);
+
+    /* Check whether the driver is already registered */
+    for (cnt = 0u; cnt < FVID2_CFG_FDM_NUM_DRV_OBJS; cnt++)
+    {
+        if (TRUE == gFdmObj.fdmDriverObjects[cnt].isUsed)
+        {
+            /* Check for NULL pointers */
+            OSAL_Assert(NULL == gFdmObj.fdmDriverObjects[cnt].drvOps);
+
+            if (drvOps->drvId == gFdmObj.fdmDriverObjects[cnt].drvOps->drvId)
+            {
+                Fvid2_printf("Driver with same id already registered!!\r\n");
+                retVal = FVID2_EDRIVER_INUSE;
+                break;
+            }
+        }
+    }
+
+    if (FVID2_SOK == retVal)
+    {
+        /* Get a free driver object */
+        drv = fdmAllocDriverObject();
+        if (NULL != drv)
+        {
+            drv->drvOps   = drvOps;
+            drv->numOpens = 0U;
+        }
+        else
+        {
+            Fvid2_printf("Alloc driver object failed!!\r\n");
+            retVal = FVID2_EALLOC;
+        }
+    }
+
+    SemaphoreP_post(gFdmObj.lockSem);
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_unRegisterDriver
+ *  \brief FVID2 unregister driver function.
+ */
+Int32 Fvid2_unRegisterDriver(const Fvid2_DrvOps *drvOps)
+{
+    Int32 retVal = FVID2_EFAIL;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == drvOps);
+
+    SemaphoreP_pend(gFdmObj.lockSem, SemaphoreP_WAIT_FOREVER);
+
+    /* Free the driver object */
+    retVal = fdmFreeDriverObject(drvOps);
+
+    SemaphoreP_post(gFdmObj.lockSem);
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_create
+ *  \brief Opens the driver identified by the driver ID.
+ */
+Fvid2_Handle Fvid2_create(UInt32                drvId,
+                          UInt32                instanceId,
+                          Ptr                   createArgs,
+                          Ptr                   createStatusArgs,
+                          const Fvid2_CbParams *cbParams)
+{
+    Fdm_Driver       *drv = NULL;
+    UInt32            cnt;
+    Fdrv_Handle       drvHandle = NULL;
+    Fdm_Channel      *channel   = NULL;
+    Fvid2_DrvCbParams fdmCbParams, *tempCbParams;
+
+    SemaphoreP_pend(gFdmObj.lockSem, SemaphoreP_WAIT_FOREVER);
+
+    /* Get the matching driver object */
+    for (cnt = 0u; cnt < FVID2_CFG_FDM_NUM_DRV_OBJS; cnt++)
+    {
+        if (TRUE == gFdmObj.fdmDriverObjects[cnt].isUsed)
+        {
+            /* Check for NULL pointers */
+            OSAL_Assert(NULL == gFdmObj.fdmDriverObjects[cnt].drvOps);
+
+            if (drvId == gFdmObj.fdmDriverObjects[cnt].drvOps->drvId)
+            {
+                drv = &gFdmObj.fdmDriverObjects[cnt];
+                /* Allocate channel object */
+                channel = fdmAllocChannelObject();
+                break;
+            }
+        }
+    }
+
+    if (NULL != channel)
+    {
+        if (NULL != drv->drvOps->createFxn)
+        {
+            if (NULL != cbParams)
+            {
+                if (NULL != cbParams->cbFxn)
+                {
+                    fdmCbParams.fdmCbFxn = &fdmDriverCbFxn;
+                }
+                else
+                {
+                    fdmCbParams.fdmCbFxn = NULL;
+                }
+                if (NULL != cbParams->errCbFxn)
+                {
+                    fdmCbParams.fdmErrCbFxn = &fdmDriverErrCbFxn;
+                }
+                else
+                {
+                    fdmCbParams.fdmErrCbFxn = NULL;
+                }
+
+                fdmCbParams.handle   = channel;
+                fdmCbParams.errList  = cbParams->errList;
+                fdmCbParams.fdmData  = channel;
+                fdmCbParams.reserved = cbParams->reserved;
+                tempCbParams         = &fdmCbParams;
+            }
+            else
+            {
+                tempCbParams = NULL;
+            }
+
+            /* Call the driver's create function */
+            drvHandle = drv->drvOps->createFxn(
+                drvId,
+                instanceId,
+                createArgs,
+                createStatusArgs,
+                tempCbParams);
+        }
+        else
+        {
+            Fvid2_printf("Driver Ops not supported!!\r\n");
+        }
+
+        if (NULL != drvHandle)
+        {
+            drv->numOpens++;
+
+            channel->drv       = drv;
+            channel->drvHandle = drvHandle;
+            Fvid2CbParams_init(&channel->cbParams);
+            if (NULL != cbParams)
+            {
+                Fvid2_memcpy(
+                    &channel->cbParams,
+                    cbParams,
+                    sizeof (Fvid2_CbParams));
+            }
+        }
+        else
+        {
+            Fvid2_printf("Driver create failed!!\r\n");
+
+            /* Free the allocated channel object */
+            fdmFreeChannelObject(channel);
+            channel = NULL;
+        }
+    }
+    else
+    {
+        Fvid2_printf("EALLOC: Invalid driver ID!!\r\n");
+    }
+
+    SemaphoreP_post(gFdmObj.lockSem);
+
+    return (channel);
+}
+
+/**
+ *  Fvid2_delete
+ *  \brief Application calls Fvid2_delete to close the logical channel
+ *  associated with FVID2 handle.
+ */
+Int32 Fvid2_delete(Fvid2_Handle handle, Ptr deleteArgs)
+{
+    Int32        retVal = FVID2_SOK;
+    Fdm_Channel *channel;
+
+    SemaphoreP_pend(gFdmObj.lockSem, SemaphoreP_WAIT_FOREVER);
+
+    if (NULL != handle)
+    {
+        channel = (Fdm_Channel *) handle;
+
+        /* Check for NULL pointers */
+        OSAL_Assert(NULL == channel->drv);
+        OSAL_Assert(NULL == channel->drv->drvOps);
+
+        if (NULL != channel->drv->drvOps->deleteFxn)
+        {
+            /* Call the driver's delete function */
+            retVal = channel->drv->drvOps->deleteFxn(
+                channel->drvHandle,
+                deleteArgs);
+        }
+        else
+        {
+            Fvid2_printf("Driver Ops not supported!!\r\n");
+        }
+
+        channel->drv->numOpens--;
+        /* Free the allocated channel object */
+        channel->drv               = NULL;
+        channel->drvHandle         = NULL;
+        channel->cbParams.cbFxn    = NULL;
+        channel->cbParams.errCbFxn = NULL;
+        channel->cbParams.errList  = NULL;
+        channel->cbParams.appData  = NULL;
+        channel->cbParams.reserved = NULL;
+        fdmFreeChannelObject(channel);
+    }
+    else
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+
+    SemaphoreP_post(gFdmObj.lockSem);
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_control
+ *  \brief An application calls Fvid2_control to send device-specific control
+ *  commands to the video driver.
+ */
+Int32 Fvid2_control(Fvid2_Handle handle,
+                    UInt32       cmd,
+                    Ptr          cmdArgs,
+                    Ptr          cmdStatusArgs)
+{
+    Int32        retVal = FVID2_SOK;
+    Fdm_Channel *channel;
+
+    if (NULL != handle)
+    {
+        channel = (Fdm_Channel *) handle;
+
+        /* Check for NULL pointers */
+        OSAL_Assert(NULL == channel->drv);
+        OSAL_Assert(NULL == channel->drv->drvOps);
+
+        if (NULL != channel->drv->drvOps->controlFxn)
+        {
+            /* Call the driver's control function */
+            retVal = channel->drv->drvOps->controlFxn(
+                channel->drvHandle,
+                cmd,
+                cmdArgs,
+                cmdStatusArgs);
+        }
+        else
+        {
+            Fvid2_printf("Driver Ops not supported!!\r\n");
+            retVal = FVID2_EUNSUPPORTED_OPS;
+        }
+    }
+    else
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_queue
+ *  \brief An application calls Fvid2_queue to submit a video buffer to the
+ *  video device driver.
+ *  This is used in capture/display drivers.
+ */
+Int32 Fvid2_queue(Fvid2_Handle     handle,
+                  Fvid2_FrameList *frameList,
+                  UInt32           streamId)
+{
+    Int32        retVal = FVID2_SOK;
+    Fdm_Channel *channel;
+
+    if (NULL != handle)
+    {
+        channel = (Fdm_Channel *) handle;
+
+        /* Check for NULL pointers */
+        OSAL_Assert(NULL == channel->drv);
+        OSAL_Assert(NULL == channel->drv->drvOps);
+
+        if (NULL != channel->drv->drvOps->queueFxn)
+        {
+            /* Call the driver's queue function */
+            retVal = channel->drv->drvOps->queueFxn(
+                channel->drvHandle,
+                frameList,
+                streamId);
+        }
+        else
+        {
+            Fvid2_printf("Driver Ops not supported!!\r\n");
+            retVal = FVID2_EUNSUPPORTED_OPS;
+        }
+    }
+    else
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_dequeue
+ *  \brief An application calls Fvid2_dequeue to request the video device
+ *  driver to give ownership of a video buffer.
+ *  This is used in capture/display drivers.
+ */
+Int32 Fvid2_dequeue(Fvid2_Handle     handle,
+                    Fvid2_FrameList *frameList,
+                    UInt32           streamId,
+                    UInt32           timeout)
+{
+    Int32        retVal = FVID2_SOK;
+    Fdm_Channel *channel;
+
+    if (NULL != handle)
+    {
+        channel = (Fdm_Channel *) handle;
+
+        /* Check for NULL pointers */
+        OSAL_Assert(NULL == channel->drv);
+        OSAL_Assert(NULL == channel->drv->drvOps);
+
+        if (NULL != channel->drv->drvOps->dequeueFxn)
+        {
+            /* Call the driver's dequeue function */
+            retVal = channel->drv->drvOps->dequeueFxn(
+                channel->drvHandle,
+                frameList,
+                streamId,
+                timeout);
+        }
+        else
+        {
+            Fvid2_printf("Driver Ops not supported!!\r\n");
+            retVal = FVID2_EUNSUPPORTED_OPS;
+        }
+    }
+    else
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_processRequest
+ *  \brief An application calls Fvid2_processRequest to submit a video buffer
+ *  to the video device driver.
+ */
+Int32 Fvid2_processRequest(Fvid2_Handle     handle,
+                           Fvid2_FrameList *inFrameList,
+                           Fvid2_FrameList *outFrameList)
+{
+    Int32        retVal = FVID2_SOK;
+    Fdm_Channel *channel;
+
+    if (NULL != handle)
+    {
+        channel = (Fdm_Channel *) handle;
+
+        /* Check for NULL pointers */
+        OSAL_Assert(NULL == channel->drv);
+        OSAL_Assert(NULL == channel->drv->drvOps);
+
+        if (NULL != channel->drv->drvOps->processRequestFxn)
+        {
+            /* Call the driver's process frame function */
+            retVal = channel->drv->drvOps->processRequestFxn(
+                channel->drvHandle,
+                inFrameList,
+                outFrameList);
+        }
+        else
+        {
+            Fvid2_printf("Driver Ops not supported!!\r\n");
+            retVal = FVID2_EUNSUPPORTED_OPS;
+        }
+    }
+    else
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_getProcessedRequest
+ *  \brief An application calls Fvid2_getProcessedRequest to request the video
+ *  device driver to give ownership of a video buffer.
+ */
+Int32 Fvid2_getProcessedRequest(Fvid2_Handle     handle,
+                                Fvid2_FrameList *inFrameList,
+                                Fvid2_FrameList *outFrameList,
+                                UInt32           timeout)
+{
+    Int32        retVal = FVID2_SOK;
+    Fdm_Channel *channel;
+
+    if (NULL != handle)
+    {
+        channel = (Fdm_Channel *) handle;
+
+        /* Check for NULL pointers */
+        OSAL_Assert(NULL == channel->drv);
+        OSAL_Assert(NULL == channel->drv->drvOps);
+
+        if (NULL != channel->drv->drvOps->getProcessedRequestFxn)
+        {
+            /* Call the driver's get process frame function */
+            retVal = channel->drv->drvOps->getProcessedRequestFxn(
+                channel->drvHandle,
+                inFrameList,
+                outFrameList,
+                timeout);
+        }
+        else
+        {
+            Fvid2_printf("Driver Ops not supported!!\r\n");
+            retVal = FVID2_EUNSUPPORTED_OPS;
+        }
+    }
+    else
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_getModeInfo
+ *  \brief Function to get the information about various FVID2 modes/standards.
+ */
+Int32 Fvid2_getModeInfo(Fvid2_ModeInfo *modeInfo)
+{
+    Int32           retVal = FVID2_SOK;
+    UInt32          entryCnt;
+    Fvid2_ModeInfo *matchedEntry = NULL;
+
+    if (NULL != modeInfo)
+    {
+        for (entryCnt = 0U; entryCnt < FDM_NUM_STD_INFO_ENTRIES; entryCnt++)
+        {
+            if (gFdmStdInfoTable[entryCnt].standard == modeInfo->standard)
+            {
+                matchedEntry = &gFdmStdInfoTable[entryCnt];
+                break;
+            }
+        }
+
+        if (NULL == matchedEntry)
+        {
+            Fvid2_printf("Unsupported standard!!\r\n");
+            retVal = FVID2_EINVALID_PARAMS;
+        }
+        else
+        {
+            Fvid2_memcpy(modeInfo, matchedEntry, sizeof (Fvid2_ModeInfo));
+        }
+    }
+    else
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+
+    return (retVal);
+}
+
+/**
+ *  \brief Function to get the name of the data format in printable string.
+ *
+ *  \param dataFmt      [IN] Data format to get the name.
+ *                           For valid values see #Fvid2_DataFormat.
+ *
+ *  \return Returns a const pointer to the string. If the data format is not
+ *  known, then it return the string as "UNKNOWN".
+ */
+const Char *Fvid2_getDataFmtString(UInt32 dataFmt)
+{
+    UInt32      entryCnt;
+    const Char *dataFmtStr = NULL;
+
+    for (entryCnt = 0U; entryCnt < FDM_NUM_DATA_FMT_STR_ENTRIES; entryCnt++)
+    {
+        if (gFdmDataFmtStrTable[entryCnt].dataFmt == dataFmt)
+        {
+            dataFmtStr = gFdmDataFmtStrTable[entryCnt].dataFmtStr;
+            break;
+        }
+    }
+
+    if (NULL == dataFmtStr)
+    {
+        dataFmtStr = "UNKNOWN";
+    }
+
+    return (dataFmtStr);
+}
+
+/**
+ *  \brief Function to get the name of the standard in printable string.
+ *
+ *  \param standard     [IN] Standard to get the name.
+ *                           For valid values see #Fvid2_Standard.
+ *
+ *  \return Returns a const pointer to the string. If the standard is not
+ *  known, then it return the string as "UNKNOWN".
+ */
+const Char *Fvid2_getStandardString(UInt32 standard)
+{
+    UInt32      entryCnt;
+    const Char *stdStr = NULL;
+
+    for (entryCnt = 0U; entryCnt < FDM_NUM_STD_STR_ENTRIES; entryCnt++)
+    {
+        if (gFdmStdStrTable[entryCnt].standard == standard)
+        {
+            stdStr = gFdmStdStrTable[entryCnt].stdStr;
+            break;
+        }
+    }
+
+    if (NULL == stdStr)
+    {
+        stdStr = "UNKNOWN";
+    }
+
+    return (stdStr);
+}
+
+/**
+ *  Fvid2_checkFrameList
+ *  \brief Checks the FVID2 frame list for error and returns appropriate error.
+ *  This is used by the drivers and not by the application.
+ */
+Int32 Fvid2_checkFrameList(const Fvid2_FrameList *frameList, UInt32 maxFrames)
+{
+    Int32  retVal = FVID2_SOK;
+    UInt32 frmCnt;
+
+    /* Check for NULL pointer */
+    if (NULL == frameList)
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+    else
+    {
+        /* Check whether num frames is within range */
+        if (frameList->numFrames > maxFrames)
+        {
+            Fvid2_printf("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");
+            retVal = FVID2_EOUT_OF_RANGE;
+        }
+
+        /* Check whether num frames is zero */
+        if (0U == frameList->numFrames)
+        {
+            Fvid2_printf("Number of frames is zero!!\r\n");
+            retVal = FVID2_EOUT_OF_RANGE;
+        }
+
+        if (FVID2_SOK == retVal)
+        {
+            /* Check the individual frame pointers */
+            for (frmCnt = 0U; frmCnt < frameList->numFrames; frmCnt++)
+            {
+                /* Check for NULL pointer */
+                if (NULL == frameList->frames[frmCnt])
+                {
+                    Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+                    retVal = FVID2_EBADARGS;
+                    break;
+                }
+            }
+        }
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_checkDqFrameList
+ *  \brief Checks the FVID2 frame list of dequeue call for error and returns
+ *  appropriate error. For dequeue operation, the frame pointers in the frames
+ *  should not be checked as this will be filled by the driver.
+ *  This is used by the drivers and not by the application.
+ */
+Int32 Fvid2_checkDqFrameList(const Fvid2_FrameList *frameList,
+                             UInt32                 maxFrames)
+{
+    Int32 retVal = FVID2_SOK;
+
+    /* Check for NULL pointer */
+    if (NULL == frameList)
+    {
+        Fvid2_printf("EBADARGS: NULL pointer!!\r\n");
+        retVal = FVID2_EBADARGS;
+    }
+    else
+    {
+        /* Check whether max frames is within range */
+        if (maxFrames > FVID2_MAX_FRAME_PTR)
+        {
+            Fvid2_printf("Number of frames exceeds FVID2 max!!\r\n");
+            retVal = FVID2_EOUT_OF_RANGE;
+        }
+    }
+
+    return (retVal);
+}
+
+/**
+ *  Fvid2_copyFrameList
+ *  \brief Copies the source frame list to the destination frame list.
+ *  This also resets the frame pointers from the source frame list.
+ *  This is used by the drivers and not by the application.
+ */
+void Fvid2_copyFrameList(Fvid2_FrameList *dest, Fvid2_FrameList *src)
+{
+    UInt32 frmCnt;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == dest);
+    OSAL_Assert(NULL == src);
+    OSAL_Assert(src->numFrames >= FVID2_MAX_FRAME_PTR);
+
+    dest->numFrames  = src->numFrames;
+    dest->drvData    = src->drvData;
+    dest->reserved   = src->reserved;
+
+    /* Copy the individual frames */
+    for (frmCnt = 0U; frmCnt < src->numFrames; frmCnt++)
+    {
+        dest->frames[frmCnt] = src->frames[frmCnt];
+        src->frames[frmCnt]  = NULL;
+    }
+
+    return;
+}
+
+/**
+ *  Fvid2_duplicateFrameList
+ *  \brief Duplicate the source frame list to the destination frame list.
+ *  This does not reset the frame pointers from the source frame list.
+ *  This is used by the drivers and not by the application.
+ */
+void Fvid2_duplicateFrameList(Fvid2_FrameList *dest, const Fvid2_FrameList *src)
+{
+    UInt32 frmCnt;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == dest);
+    OSAL_Assert(NULL == src);
+    OSAL_Assert(src->numFrames >= FVID2_MAX_FRAME_PTR);
+
+    dest->numFrames  = src->numFrames;
+    dest->drvData    = src->drvData;
+    dest->reserved   = src->reserved;
+
+    /* Duplicate the individual frames */
+    for (frmCnt = 0U; frmCnt < src->numFrames; frmCnt++)
+    {
+        dest->frames[frmCnt] = src->frames[frmCnt];
+    }
+
+    return;
+}
+
+/**
+ *  fdmDriverCbFxn
+ *  \brief FVID2 driver manager driver callback function. Whenever the drivers
+ *  wants to call the application callback function, this function will be
+ *  called by the driver and FDM will in turn call the application callback
+ *  function.
+ *  This is used by the drivers and not by the application.
+ */
+static Int32 fdmDriverCbFxn(Ptr fdmData, Ptr reserved)
+{
+    Int32        retVal;
+    Fdm_Channel *channel;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == fdmData);
+
+    channel = (Fdm_Channel *) fdmData;
+    OSAL_Assert(NULL == channel->cbParams.cbFxn);
+    retVal = channel->cbParams.cbFxn(channel, channel->cbParams.appData, NULL);
+
+    return (retVal);
+}
+
+/**
+ *  fdmDriverErrCbFxn
+ *  \brief FVID2 driver manager driver error callback function.
+ *  Whenever the drivers wants to call the application error callback function,
+ *  this function will be called by the driver and FDM will in turn call the
+ *  application error callback function.
+ *  This is used by the drivers and not by the application.
+ */
+static Int32 fdmDriverErrCbFxn(Ptr fdmData, void *errList, Ptr reserved)
+{
+    Int32        retVal;
+    Fdm_Channel *channel;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == fdmData);
+
+    channel = (Fdm_Channel *) fdmData;
+    OSAL_Assert(NULL == channel->cbParams.errCbFxn);
+    retVal = channel->cbParams.errCbFxn(
+        channel,
+        channel->cbParams.appData,
+        errList,
+        NULL);
+
+    return (retVal);
+}
+
+/**
+ *  fdmAllocDriverObject
+ *  \brief Allocate memory for driver object from static memory pool.
+ *  Returns NULL if memory pool is full.
+ */
+static Fdm_Driver *fdmAllocDriverObject(void)
+{
+    UInt32      cnt;
+    Fdm_Driver *drv = NULL;
+
+    /* Get a free driver object */
+    for (cnt = 0u; cnt < FVID2_CFG_FDM_NUM_DRV_OBJS; cnt++)
+    {
+        if (FALSE == gFdmObj.fdmDriverObjects[cnt].isUsed)
+        {
+            drv         = &gFdmObj.fdmDriverObjects[cnt];
+            drv->isUsed = (UInt32) TRUE;
+            break;
+        }
+    }
+
+    return (drv);
+}
+
+/**
+ *  fdmFreeDriverObject
+ *  \brief Free-up the memory allocated for driver object.
+ */
+static Int32 fdmFreeDriverObject(const Fvid2_DrvOps *drvOps)
+{
+    UInt32 cnt;
+    Int32  retVal = FVID2_EFAIL;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == drvOps);
+
+    /* Free the driver object */
+    for (cnt = 0u; cnt < FVID2_CFG_FDM_NUM_DRV_OBJS; cnt++)
+    {
+        if ((TRUE == gFdmObj.fdmDriverObjects[cnt].isUsed) &&
+            (drvOps == gFdmObj.fdmDriverObjects[cnt].drvOps))
+        {
+            if (0u == gFdmObj.fdmDriverObjects[cnt].numOpens)
+            {
+                gFdmObj.fdmDriverObjects[cnt].isUsed   = (UInt32) FALSE;
+                gFdmObj.fdmDriverObjects[cnt].drvOps   = NULL;
+                gFdmObj.fdmDriverObjects[cnt].numOpens = 0u;
+                retVal = FVID2_SOK;
+            }
+            else
+            {
+                Fvid2_printf("Driver in use!!\r\n");
+                retVal = FVID2_EDEVICE_INUSE;
+            }
+            break;
+        }
+    }
+
+    if (FVID2_EFAIL == retVal)
+    {
+        Fvid2_printf("Driver ops not found!!\r\n");
+    }
+
+    return (retVal);
+}
+
+/**
+ *  fdmAllocChannelObject
+ *  \brief Allocate memory for channel object from static memory pool.
+ *  Returns NULL if memory pool is full.
+ */
+static Fdm_Channel *fdmAllocChannelObject(void)
+{
+    UInt32       cnt;
+    Fdm_Channel *channel = NULL;
+
+    /* Get a free channel object */
+    for (cnt = 0u; cnt < FVID2_CFG_FDM_NUM_CH_OBJS; cnt++)
+    {
+        if (FALSE == gFdmObj.fdmChannelObjects[cnt].isUsed)
+        {
+            channel         = &gFdmObj.fdmChannelObjects[cnt];
+            channel->isUsed = (UInt32) TRUE;
+            break;
+        }
+    }
+
+    return (channel);
+}
+
+/**
+ *  fdmFreeChannelObject
+ *  \brief Free-up the memory allocated for channel object.
+ */
+static Int32 fdmFreeChannelObject(Fdm_Channel *channel)
+{
+    Int32 retVal = FVID2_EALLOC;
+
+    /* Check for NULL pointers */
+    OSAL_Assert(NULL == channel);
+
+    /* Free the channel object */
+    if (TRUE == channel->isUsed)
+    {
+        channel->isUsed = (UInt32) FALSE;
+        retVal          = FVID2_SOK;
+    }
+    else
+    {
+        Fvid2_printf("Freeing a channel object not in use!!\r\n");
+    }
+
+    return (retVal);
+}
+
+
+
+static void Fvid2_printf(const char *format, ...)
+{
+    return;
+}
+
+static void Fvid2_memset(void *mem, int32_t ch, uint32_t byteCount)
+{
+    memset(mem, ch, byteCount);
+    return;
+}
+
+static void Fvid2_memcpy(void *dest, const void *src, uint32_t byteCount)
+{
+    memcpy(dest, src, byteCount);
+    return;
+}
+
diff --git a/src/makefile b/src/makefile
new file mode 100644 (file)
index 0000000..a1027fd
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# This file is the makefile for building sciclient .
+#
+include $(PDK_INSTALL_PATH)/ti/build/Rules.make
+
+MODULE_NAME = fvid2
+
+SRCDIR = src
+INCDIR = . ./include src
+
+# List all the external components/interfaces, whose interface header files
+# need to be included for this component
+INCLUDE_EXTERNAL_INTERFACES = pdk
+INCLUDE_INTERNAL_INTERFACES = csl osal
+
+# Common source files and CFLAGS across all platforms and cores
+PACKAGE_SRCS_COMMON = .
+
+SRCS_COMMON += fvid2_drvMgr.c
+
+CFLAGS_LOCAL_COMMON = $(PDK_CFLAGS)
+PACKAGE_SRCS_COMMON = . ../fvid2_component.mk ../include ../src  
+
+# Core/SoC/platform specific source files and CFLAGS
+# Example:
+#   SRCS_<core/SoC/platform-name> =
+#   CFLAGS_LOCAL_<core/SoC/platform-name> =
+
+# Include common make files
+ifeq ($(MAKERULEDIR), )
+#Makerule path not defined, define this and assume relative path from ROOTDIR
+  MAKERULEDIR := $(ROOTDIR)/ti/build/makerules
+  export MAKERULEDIR
+endif
+include $(MAKERULEDIR)/common.mk
+
+# OBJs and libraries are built by using rule defined in rules_<target>.mk
+#     and need not be explicitly specified here
+
+# Nothing beyond this point