From 72570a6b96f0a4599af7386474423648119e49c1 Mon Sep 17 00:00:00 2001
From: Brijesh Jadav <Brijesh.Jadav@ti.com>
Date: Tue, 15 Nov 2022 16:45:46 +0530
Subject: [PATCH 1/1] Enabled DSS-M2M for J784S4

Signed-off-by: Brijesh Jadav <Brijesh.Jadav@ti.com>
---
 packages/ti/drv/dss/dss.h                     |   6 +-
 packages/ti/drv/dss/dss_component.mk          |   5 +-
 .../dss/examples/dss_m2m_test/dss_m2m_test.c  | 676 ++++++++++++++++++
 .../examples/dss_m2m_test/dss_m2m_test_cfg.h  | 230 ++++++
 .../drv/dss/examples/dss_m2m_test/main_rtos.c | 189 +++++
 .../ti/drv/dss/examples/dss_m2m_test/makefile |  12 +
 .../drv/dss/examples/dss_m2m_test/makefile.mk |  52 ++
 packages/ti/drv/dss/src/drv/common/dss_init.c |   6 +-
 8 files changed, 1168 insertions(+), 8 deletions(-)
 create mode 100755 packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test.c
 create mode 100755 packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test_cfg.h
 create mode 100755 packages/ti/drv/dss/examples/dss_m2m_test/main_rtos.c
 create mode 100755 packages/ti/drv/dss/examples/dss_m2m_test/makefile
 create mode 100755 packages/ti/drv/dss/examples/dss_m2m_test/makefile.mk

diff --git a/packages/ti/drv/dss/dss.h b/packages/ti/drv/dss/dss.h
index 07ae2e9..1d2c480 100755
--- a/packages/ti/drv/dss/dss.h
+++ b/packages/ti/drv/dss/dss.h
@@ -70,7 +70,7 @@
 #include <ti/drv/dss/soc/dss_soc.h>
 #include <ti/drv/dss/include/dss_disp.h>
 #include <ti/drv/dss/include/dss_dctrl.h>
-#if defined (SOC_J721E) || defined (SOC_J721S2)
+#if defined (SOC_J721E) || defined (SOC_J721S2) || defined(SOC_J784S4)
 #include <ti/drv/dss/include/dss_m2m.h>
 #endif
 
@@ -89,7 +89,7 @@ extern "C" {
 /** \brief Display controller driver ID used at the time of FVID2 create. */
 #define DSS_DCTRL_DRV_ID                    (FVID2_DSS_DRV_BASE + 0x01U)
 
-#if defined (SOC_J721E) || defined (SOC_J721S2)
+#if defined (SOC_J721E) || defined (SOC_J721S2) || defined (SOC_J784S4)
 /** \brief Display M2M driver ID used at the time of FVID2 create. */
 #define DSS_M2M_DRV_ID                      (FVID2_DSS_DRV_BASE + 0x02U)
 #endif
@@ -106,7 +106,7 @@ extern "C" {
 /** \brief IOCTL base address for the SOC specific display controller driver
  *   IOCTLs. */
 #define DSS_DCTRL_SOC_IOCTL_BASE            (DSS_DCTRL_IOCTL_BASE + 0x40U)
-#if defined (SOC_J721E) || defined (SOC_J721S2)
+#if defined (SOC_J721E) || defined (SOC_J721S2) || defined (SOC_J784S4)
 /** \brief IOCTL base address for the Display M2M Driver IOCTLs. */
 #define DSS_M2M_IOCTL_BASE                  (FVID2_DSS_DRV_IOCTL_BASE + 0x200U)
 #endif
diff --git a/packages/ti/drv/dss/dss_component.mk b/packages/ti/drv/dss/dss_component.mk
index fcc7bda..8f299c3 100755
--- a/packages/ti/drv/dss/dss_component.mk
+++ b/packages/ti/drv/dss/dss_component.mk
@@ -40,10 +40,11 @@ drvdss_am65xx_CORELIST = mpu1_0
 drvdss_j721e_CORELIST  = mcu2_0
 drvdss_j721s2_CORELIST  = mcu2_0
 drvdss_j784s4_CORELIST  = mcu2_0
-drvdssm2m_SOCLIST         = j721e j721s2
-drvdssm2m_BOARDLIST       = j721e_evm j721s2_evm
+drvdssm2m_SOCLIST         = j721e j721s2 j784s4
+drvdssm2m_BOARDLIST       = j721e_evm j721s2_evm j784s4_evm
 drvdssm2m_j721e_CORELIST  = mcu2_0
 drvdssm2m_j721s2_CORELIST = mcu2_0
+drvdssm2m_j784s4_CORELIST = mcu2_0
 drvdss_RTOS_LIST       = $(DEFAULT_RTOS_LIST)
 
 define DRV_DSS_RTOS_BOARDLIST_RULE
diff --git a/packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test.c b/packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test.c
new file mode 100755
index 0000000..cf3a7aa
--- /dev/null
+++ b/packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test.c
@@ -0,0 +1,676 @@
+/*
+ *  Copyright (c) Texas Instruments Incorporated 2021
+ *  All rights reserved.
+ *
+ *  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 dss_m2m_test.c
+ *
+ *  \brief DSS sample application that does conversion frames for two instances
+ *         of M2M Driver.
+ *         This sample application demonstrates following:
+ *              - YUV422 -> YUV420 conversion
+ *              - Single channel conversion (through single M2M DRV instance)
+ *                  - controlled through 'APP_DSS_M2M_CH_NUM'
+ *              - Runtime loading of buffers (in this case YUV422)
+ *          Refer to 'dss_m2m_test_cfg' file for more details about
+ *          reconfigurability of this application.
+ */
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+
+#include <stdio.h>
+#include <string.h>
+#include <dss_m2m_test_cfg.h>
+
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+int32_t Dss_displayM2MTest(void);
+static int32_t App_init(M2MApp_AppObj *appObj);
+static int32_t App_deInit(M2MApp_AppObj *appObj);
+static int32_t App_create(M2MApp_AppObj *appObj);
+static int32_t App_delete(M2MApp_AppObj *appObj);
+static int32_t App_runTest(M2MApp_AppObj *appObj);
+static int32_t App_initParams(M2MApp_AppObj *appObj);
+static int32_t App_allocAndQueueFrames(M2MApp_InstParams *appObj);
+static int32_t App_pipeCbFxn(Fvid2_Handle handle, void *appData);
+extern void App_wait(uint32_t wait_in_ms);
+/* ========================================================================== */
+/*                            Global Variables                                */
+/* ========================================================================== */
+
+M2MApp_AppObj gM2MAppObj;
+uint32_t gTestStopTime, gTestStartTime;
+
+/* This buffer will be used to store RGB or Y */
+static uint8_t gOutFrms[(APP_DSS_M2M_CH_NUM * APP_DSS_M2M_DSS_PIPE_NUM)][(APP_DSS_M2M_OUT_FRAME_PITCH * APP_DSS_M2M_OUT_FRAME_HEIGHT)] __attribute__(( aligned(128), section(".data_buffer")));
+/* This buffer will be used to store UV */
+static uint8_t gOutUVComp[(APP_DSS_M2M_CH_NUM * APP_DSS_M2M_DSS_PIPE_NUM)][(APP_DSS_M2M_OUT_FRAME_PITCH * APP_DSS_M2M_OUT_FRAME_HEIGHT)] __attribute__(( aligned(128), section(".data_buffer")));
+/* ========================================================================== */
+/*                          Function Definitions                              */
+/* ========================================================================== */
+int32_t Dss_displayM2MTest(void)
+{
+    int32_t retVal = FVID2_SOK;
+    M2MApp_AppObj *appObj;
+
+    appObj = &gM2MAppObj;
+    /* Initialize application object to '0' and the set only required parameters */
+    Fvid2Utils_memset(appObj, 0U, sizeof(M2MApp_AppObj));
+
+    retVal = App_initParams(appObj);
+    if (FVID2_SOK != retVal)
+    {
+        App_consolePrintf("\nERROR: App_initParams() Failed!!!\n");
+    }
+
+    if (FVID2_SOK == retVal)
+    {
+        retVal += App_init(appObj);
+        if (FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: App_init() Failed!!!\n");
+        }
+    }
+
+    if (FVID2_SOK == retVal)
+    {
+        retVal += App_create(appObj);
+        if (FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: App_create() Failed!!!\n");
+        }
+    }
+
+    if (FVID2_SOK == retVal)
+    {
+        retVal += App_runTest(appObj);
+        if (FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: App_runTest() Failed!!!\n");
+        }
+    }
+
+    if (FVID2_SOK == retVal)
+    {
+        retVal += App_delete(appObj);
+        if (FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: App_delete() Failed!!!\n");
+        }
+    }
+
+    if (FVID2_SOK == retVal)
+    {
+        retVal += App_deInit(appObj);
+        if (FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: App_deInit() Failed!!!\n");
+        }
+    }
+
+
+    return retVal;
+}
+static int32_t App_initParams(M2MApp_AppObj *appObj)
+{
+    int32_t retVal = FVID2_SOK;
+    uint32_t loopCnt, pipeIdx, planeIdx, layerIdx;
+    M2MApp_InstParams *instObj;
+    SemaphoreP_Params semParams;
+    Dss_DispParams *dispParams;
+    CSL_DssWbPipeCfg *wbPipeCfg;
+    Dss_DctrlOverlayParams *ovrParams;
+    Dss_DctrlOverlayLayerParams *layerParams;
+
+    appObj->numInst            = APP_DSS_M2M_CH_NUM;
+    appObj->numFramesToConvert = APP_DSS_M2M_FRAMES_WB;
+    appObj->numFramesWb        = 0U;
+    for (loopCnt = 0U ; loopCnt < appObj->numInst ; loopCnt++)
+    {
+        instObj                     = &appObj->instParams[loopCnt];
+        instObj->instIdx            = loopCnt;
+        instObj->appObj             = appObj;
+        Dss_m2mCreateParamsInit(&instObj->createParams);
+        Fvid2CbParams_init(&instObj->cbParams);
+        instObj->cbParams.cbFxn         = &App_pipeCbFxn;
+        instObj->cbParams.appData       = instObj;
+        instObj->numPipe                = APP_DSS_M2M_DSS_PIPE_NUM;
+        instObj->createParams.numPipe   = APP_DSS_M2M_DSS_PIPE_NUM;
+        instObj->createParams.overlayId = APP_DSS_M2M_DSS_OVERLAY_ID;
+        /* Initialize Display pipeline parameters */
+        for (pipeIdx = 0U ; pipeIdx < APP_DSS_M2M_DSS_PIPE_NUM ; pipeIdx++)
+        {
+            instObj->createParams.pipeId[pipeIdx] = APP_DSS_M2M_DSS_PIPE_ID;
+            instObj->pipeCfg[pipeIdx].pipeId      = APP_DSS_M2M_DSS_PIPE_ID;
+            instObj->mFlagCfg[pipeIdx].pipeId     = APP_DSS_M2M_DSS_PIPE_ID;
+            instObj->cscCfg[pipeIdx].pipeId       = APP_DSS_M2M_DSS_PIPE_ID;
+            dispParams = &instObj->pipeCfg[pipeIdx].cfgParams;
+            Dss_dispParamsInit(dispParams);
+            dispParams->pipeCfg.pipeType = CSL_DSS_VID_PIPE_TYPE_VID;
+            dispParams->pipeCfg.inFmt.width = APP_DSS_M2M_IN_FRAME_WIDTH;
+            dispParams->pipeCfg.inFmt.height = APP_DSS_M2M_IN_FRAME_HEIGHT;
+            for(planeIdx = 0U ; planeIdx < FVID2_MAX_PLANES; planeIdx++)
+            {
+                dispParams->pipeCfg.inFmt.pitch[planeIdx] = APP_DSS_M2M_IN_FRAME_PITCH;
+            }
+            dispParams->pipeCfg.inFmt.dataFormat  = APP_DSS_M2M_IN_FRAME_FORMAT;
+            dispParams->pipeCfg.outWidth          = APP_DSS_M2M_IN_FRAME_WIDTH;
+            dispParams->pipeCfg.outHeight         = APP_DSS_M2M_IN_FRAME_HEIGHT;
+            dispParams->pipeCfg.scEnable          = FALSE;
+            dispParams->alphaCfg.globalAlpha      = 0xFFU;
+            dispParams->alphaCfg.preMultiplyAlpha = FALSE;
+            dispParams->layerPos.startX           = 0U;
+            dispParams->layerPos.startY           = 0U;
+
+            Dss_dispPipeMflagParamsInit(&instObj->mFlagCfg[pipeIdx].mFlagCfg);
+
+            CSL_dssCscCoeffInit(&instObj->cscCfg[pipeIdx].csc);
+        }
+        /* Initialize WB pipeline parameters */
+        Dss_m2mPipeCfgParamsInit(&instObj->wbCfg);
+        wbPipeCfg = &instObj->wbCfg.pipeCfg;
+        /* Dont' need to set dataFormat as this is fixed to 'FVID2_DF_ARGB48_12121212'
+           and is set in 'Dss_m2mPipeCfgParamsInit()' */
+        wbPipeCfg->inFmt.width       = APP_DSS_M2M_IN_FRAME_WIDTH;
+        wbPipeCfg->inFmt.height      = APP_DSS_M2M_IN_FRAME_HEIGHT;
+        wbPipeCfg->outFmt.width      = APP_DSS_M2M_OUT_FRAME_WIDTH;
+        wbPipeCfg->outFmt.height     = APP_DSS_M2M_OUT_FRAME_HEIGHT;
+        wbPipeCfg->outFmt.dataFormat = APP_DSS_M2M_OUT_FRAME_FORMAT;
+        wbPipeCfg->outFmt.ccsFormat  = FVID2_CCSF_BITS8_PACKED;
+        wbPipeCfg->inPos.startX      = 0U;
+        wbPipeCfg->inPos.startY      = 0U;
+        for(planeIdx = 0U ; planeIdx < FVID2_MAX_PLANES; planeIdx++)
+        {
+            wbPipeCfg->outFmt.pitch[planeIdx] = APP_DSS_M2M_OUT_FRAME_PITCH;
+        }
+        CSL_dssWbPipeDmaCfgInit(&instObj->wbDmaCfg);
+        Dss_m2mMFlagParamsInit(&instObj->wbMflagCfg);
+        CSL_dssCscCoeffInit(&instObj->wbCscCfg);
+        Dss_m2mStatusInit(&instObj->wbStatus);
+
+        /* Initialize Display overlay parameters */
+        ovrParams = &instObj->ovrCfg;
+        Dss_dctrlOverlayParamsInit(ovrParams);
+        ovrParams->overlayId = APP_DSS_M2M_DSS_OVERLAY_ID;
+        ovrParams->colorbarEnable = FALSE;
+        ovrParams->overlayCfg.colorKeyEnable = FALSE;
+        ovrParams->overlayCfg.colorKeySel = CSL_DSS_OVERLAY_TRANS_COLOR_DEST;
+        ovrParams->overlayCfg.backGroundColor = 0xc8c800U;
+
+        layerParams = &instObj->layerCfg;
+        Dss_dctrlOverlayLayerParamsInit(layerParams);
+        layerParams->overlayId = APP_DSS_M2M_DSS_OVERLAY_ID;
+        /* Set all layer to invalid first and then update only used ones */
+        for(layerIdx = 0U ; layerIdx < CSL_DSS_VID_PIPE_ID_MAX ; layerIdx++)
+        {
+            layerParams->pipeLayerNum[layerIdx] = CSL_DSS_OVERLAY_LAYER_INVALID;
+        }
+        layerParams->pipeLayerNum[instObj->createParams.pipeId[0U]] =
+                                                    CSL_DSS_OVERLAY_LAYER_NUM_0;
+        if(APP_DSS_M2M_DSS_PIPE_NUM > 1U)
+        {
+            for(layerIdx = 1U ; layerIdx < APP_DSS_M2M_DSS_PIPE_NUM ; layerIdx++)
+            {
+                layerParams->pipeLayerNum[instObj->createParams.pipeId[0U]] = layerIdx;
+            }
+        }
+
+        Dss_dctrlGlobalDssParamsInit(&instObj->globalParams);
+
+        /* Create sync semaphore */
+        /* Allocate instance semaphore */
+        SemaphoreP_Params_init(&semParams);
+        semParams.mode   = SemaphoreP_Mode_BINARY;
+        instObj->syncSem = SemaphoreP_create(0U, &semParams);
+        if (instObj->syncSem == NULL)
+        {
+            retVal = FVID2_EFAIL;
+            App_consolePrintf("\nERROR: Semaphore create failed!!!\n");
+        }
+    }
+
+    return retVal;
+}
+
+void App_consolePrintf(const char *pcString, ...)
+{
+    char printBuffer[APP_PRINT_BUFFER_SIZE];
+    va_list arguments;
+
+    /* Start the var args processing. */
+    va_start(arguments, pcString);
+    vsnprintf (printBuffer, sizeof(printBuffer), pcString, arguments);
+#if !defined (QT_BUILD)
+    UART_printf(printBuffer);
+#else
+    printf(printBuffer);
+#endif
+    /* End the var args processing. */
+    va_end(arguments);
+}
+
+static int32_t App_init(M2MApp_AppObj *appObj)
+{
+    int32_t retVal = FVID2_SOK;
+    Fvid2_InitPrms  initPrms;
+
+    Fvid2InitPrms_init(&initPrms);
+    initPrms.printFxn = &App_consolePrintf;
+    retVal = Fvid2_init(&initPrms);
+    if(retVal != FVID2_SOK)
+    {
+        App_consolePrintf("\nERROR: FVID2 Init Failed!!!\r\n");
+    }
+
+    Dss_initParamsInit(&appObj->initParams);
+    appObj->initParams.socParams.irqParams.dssCommonRegionId                    = CSL_DSS_COMM_REG_ID_1;
+    appObj->initParams.socParams.irqParams.numValidIrq                          = DSS_EVT_MGR_INST_ID_MAX;
+    appObj->initParams.socParams.irqParams.irqNum[DSS_EVT_MGR_INST_ID_FUNC]     = 53U;
+    appObj->initParams.socParams.irqParams.irqNum[DSS_EVT_MGR_INST_ID_SAFETY]   = 55U;
+    appObj->initParams.socParams.irqParams.irqNum[DSS_EVT_MGR_INST_ID_SECURITY] = 57U;
+    appObj->initParams.socParams.dpInitParams.isHpdSupported                    = FALSE;
+    Dss_init(&appObj->initParams);
+
+    if (FVID2_SOK == retVal)
+    {
+        App_consolePrintf("App_init() - DONE !!!\r\n");
+    }
+
+    return retVal;
+}
+
+static int32_t App_deInit(M2MApp_AppObj *appObj)
+{
+    int32_t retVal = FVID2_SOK;
+
+    retVal += Dss_deInit();
+    retVal += Fvid2_deInit(NULL);
+    if(retVal != FVID2_SOK)
+    {
+         App_consolePrintf("\nERROR: App_deInit failed!!!\r\n");
+    }
+    else
+    {
+         App_consolePrintf("App_deInit() - DONE !!!\r\n");
+    }
+
+    return retVal;
+}
+
+static int32_t App_create(M2MApp_AppObj *appObj)
+{
+    int32_t retVal = FVID2_SOK;
+    uint32_t instIdx, pipeIdx;
+    M2MApp_InstParams *instObj;
+
+    /* Create DSS M2M Driver instance */
+    for (instIdx = 0U ; instIdx < appObj->numInst ; instIdx++)
+    {
+        instObj = &appObj->instParams[instIdx];
+        instObj->drvHandle = Fvid2_create(DSS_M2M_DRV_ID,
+                                             APP_DSS_M2M_INST,
+                                             &instObj->createParams,
+                                             &instObj->createStatus,
+                                             &instObj->cbParams);
+        if((NULL == instObj->drvHandle) ||
+           (instObj->createStatus.retVal != FVID2_SOK))
+        {
+            retVal = instObj->createStatus.retVal;
+            App_consolePrintf("\nERROR: Display M2M DRV Create Failed!!!\r\n");
+        }
+        /* Call Driver IOCTLs */
+        if (FVID2_SOK == retVal)
+        {
+            for (pipeIdx = 0U ;
+                 pipeIdx < instObj->createParams.numPipe ;
+                 pipeIdx++)
+            {
+                retVal += Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_M2M_SET_PIPE_PARAMS,
+                            &instObj->pipeCfg[pipeIdx],
+                            NULL);
+                retVal += Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_M2M_SET_PIPE_MFLAG_PARAMS,
+                            &instObj->mFlagCfg[pipeIdx],
+                            NULL);
+                if (FVID2_SOK != retVal)
+                {
+                    App_consolePrintf("\nERROR: Display Pipe IOCTL Failed!!!\r\n");
+                    break;
+                }
+            }
+            if (FVID2_SOK == retVal)
+            {
+                retVal = Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_DCTRL_SET_OVERLAY_PARAMS,
+                            &instObj->ovrCfg,
+                            NULL);
+                if (FVID2_SOK != retVal)
+                {
+                    App_consolePrintf("\nERROR: IOCTL_DSS_DCTRL_SET_OVERLAY_PARAMS Failed!!!\r\n");
+                }
+            }
+            if (FVID2_SOK == retVal)
+            {
+                retVal = Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_DCTRL_SET_LAYER_PARAMS,
+                            &instObj->layerCfg,
+                            NULL);
+                if (FVID2_SOK != retVal)
+                {
+                    App_consolePrintf("\nERROR: IOCTL_DSS_DCTRL_SET_LAYER_PARAMS Failed!!!\r\n");
+                }
+            }
+            if (FVID2_SOK == retVal)
+            {
+                retVal = Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_DCTRL_SET_GLOBAL_DSS_PARAMS,
+                            &instObj->globalParams,
+                            NULL);
+                if (FVID2_SOK != retVal)
+                {
+                    App_consolePrintf("\nERROR: IOCTL_DSS_DCTRL_SET_GLOBAL_DSS_PARAMS Failed!!!\r\n");
+                }
+            }
+            if (FVID2_SOK == retVal)
+            {
+                retVal = Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_M2M_SET_WB_PIPE_PARAMS,
+                            &instObj->wbCfg,
+                            NULL);
+                if (FVID2_SOK != retVal)
+                {
+                    App_consolePrintf("\nERROR: IOCTL_DSS_M2M_SET_WB_PIPE_PARAMS Failed!!!\r\n");
+                }
+            }
+            if (FVID2_SOK == retVal)
+            {
+                retVal = Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_M2M_SET_WB_PIPE_MFLAG_PARAMS,
+                            &instObj->wbMflagCfg,
+                            NULL);
+                if (FVID2_SOK != retVal)
+                {
+                    App_consolePrintf("\nERROR: IOCTL_DSS_M2M_SET_WB_PIPE_MFLAG_PARAMS Failed!!!\r\n");
+                }
+            }
+            if (FVID2_SOK == retVal)
+            {
+                retVal = Fvid2_control(
+                            instObj->drvHandle,
+                            IOCTL_DSS_M2M_SET_WB_PIPE_DMA_CFG,
+                            &instObj->wbDmaCfg,
+                            NULL);
+                if (FVID2_SOK != retVal)
+                {
+                    App_consolePrintf("\nERROR: IOCTL_DSS_M2M_SET_WB_PIPE_DMA_CFG Failed!!!\r\n");
+                }
+            }
+        }
+    }
+
+    return retVal;
+}
+
+static int32_t App_delete(M2MApp_AppObj *appObj)
+{
+    int32_t retVal = FVID2_SOK;
+    uint32_t instIdx;
+    Fvid2_FrameList inFrmList, outFrmList;
+    M2MApp_InstParams *instObj;
+
+    for (instIdx = 0U ; instIdx < appObj->numInst ; instIdx++)
+    {
+        instObj = &appObj->instParams[instIdx];
+        /* Dequeue all the request from the driver */
+        while (1U)
+        {
+            retVal = Fvid2_getProcessedRequest(instObj->drvHandle,
+                                               &inFrmList,
+                                               &outFrmList,
+                                               FVID2_TIMEOUT_NONE);
+            if (retVal == FVID2_ENO_MORE_BUFFERS)
+            {
+                retVal = FVID2_SOK;
+                break;
+            }
+            else if (FVID2_SOK != retVal)
+            {
+                App_consolePrintf("\nERROR: Fvid2_getProcessedRequest Failed!!!\r\n");
+                break;
+            }
+            else
+            {
+                /* Do nothing here */
+            }
+        }
+
+        retVal = FVID2_SOK;
+
+        retVal = Fvid2_delete(instObj->drvHandle, NULL);
+        if(FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: M2M Driver Delete Failed!!!\r\n");
+            break;
+        }
+    }
+
+    return retVal;
+}
+
+static int32_t App_runTest(M2MApp_AppObj *appObj)
+{
+    int32_t retVal = FVID2_SOK;
+    uint32_t instIdx;
+    M2MApp_InstParams *instObj;
+    Fvid2_FrameList inFrmList, outFrmList;
+
+    for (instIdx = 0U ; instIdx < appObj->numInst ; instIdx++)
+    {
+        instObj = &appObj->instParams[instIdx];
+        /* Start the driver before queuing */
+        retVal = Fvid2_start(instObj->drvHandle, NULL);
+        if (FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: Fvid2_start Failed!!!\r\n");
+            break;
+        }
+
+        /* Allocate and submit frames for processing */
+        App_allocAndQueueFrames(instObj);
+    }
+
+    if (FVID2_SOK == retVal)
+    {
+        while (appObj->numFramesWb < appObj->numFramesToConvert)
+        {
+            if (FVID2_SOK == retVal)
+            {
+                for (instIdx = 0U ; instIdx < appObj->numInst ; instIdx++)
+                {
+                    instObj = &appObj->instParams[instIdx];
+                    /* Wait for Semaphore */
+                    (void) SemaphoreP_pend(instObj->syncSem, SemaphoreP_WAIT_FOREVER);
+                    /* Get processed frames */
+                    retVal = Fvid2_getProcessedRequest(instObj->drvHandle,
+                                                       &inFrmList,
+                                                       &outFrmList,
+                                                       FVID2_TIMEOUT_NONE);
+                    if(FVID2_SOK != retVal)
+                    {
+                        App_consolePrintf("\nERROR: Fvid2_processRequest Failed!!!\r\n");
+                        break;
+                    }
+                    /* Submit back frames for processing */
+                    retVal = Fvid2_processRequest(instObj->drvHandle,
+                                                  &inFrmList,
+                                                  &outFrmList,
+                                                  FVID2_TIMEOUT_NONE);
+                    if(FVID2_SOK != retVal)
+                    {
+                        App_consolePrintf("\nERROR: Fvid2_processRequest Failed!!!\r\n");
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    for (instIdx = 0U ; instIdx < appObj->numInst ; instIdx++)
+    {
+        instObj = &appObj->instParams[instIdx];
+        /* Stop the driver before queuing */
+        retVal = Fvid2_stop(instObj->drvHandle, NULL);
+        if (FVID2_SOK != retVal)
+        {
+            App_consolePrintf("\nERROR: Fvid2_stop Failed!!!\r\n");
+            break;
+        }
+    }
+
+    for (instIdx = 0U ; instIdx < appObj->numInst ; instIdx++)
+    {
+        /* Get status */
+        retVal += Fvid2_control(instObj->drvHandle,
+                                IOCTL_DSS_M2M_GET_CURRENT_STATUS,
+                                &instObj->wbStatus,
+                                NULL);
+        if (FVID2_SOK == retVal)
+        {
+            App_consolePrintf(
+                "\n\r==========================================================\r\n");
+            App_consolePrintf("Display M2M Status: %d\r\n", instIdx);
+            App_consolePrintf(
+                "==========================================================\r\n");
+            App_consolePrintf("Input Format: 0x%x\r\n", APP_DSS_M2M_IN_FRAME_FORMAT);
+            App_consolePrintf("Output Format: 0x%x\r\n", APP_DSS_M2M_OUT_FRAME_FORMAT);
+            App_consolePrintf("Frames Submitted: %d\r\n", instObj->wbStatus.queueCount);
+            App_consolePrintf("Frames Got Back After Processing: %d\r\n", instObj->wbStatus.dequeueCount);
+            App_consolePrintf("Frames Processed: %d\r\n", instObj->wbStatus.wbFrmCount);
+            App_consolePrintf("Frames Underflow Count: %d\r\n", instObj->wbStatus.underflowCount);
+            App_consolePrintf(
+                "==========================================================\r\n");
+        }
+        else
+        {
+            App_consolePrintf("\nERROR: Fvid2_control(IOCTL_DSS_M2M_GET_CURRENT_STATUS) Failed!!!\r\n");
+            break;
+        }
+    }
+
+    return retVal;
+}
+
+static int32_t App_allocAndQueueFrames(M2MApp_InstParams *instObj)
+{
+    int32_t  retVal = FVID2_SOK;
+    uint32_t pipeIdx;
+    Fvid2_Frame *frm;
+    Fvid2_FrameList inFrmList, outFrmList;
+    char uartInput = '0';
+
+    App_consolePrintf("Load Image using loadRaw command and then press '1'\n");
+    App_consolePrintf("Command is:\n");
+    App_consolePrintf("loadRaw(0x%x, 0, \"C:\\\\display_yuyv422_prog_packed_1920_1080.tigf\", 32, false);\n",
+              APP_DSS_M2M_DDR_LOAD_ADDRESS);
+    do
+    {
+        scanf("%c", &uartInput);
+    } while ('1' != uartInput);
+
+    Fvid2FrameList_init(&inFrmList);
+    for (pipeIdx = 0U ; pipeIdx < instObj->numPipe ; pipeIdx++)
+    {
+        frm = inFrmList.frames[pipeIdx];
+        /* init Fvid2_Frame to 0's  */
+        frm = (Fvid2_Frame *) &instObj->inFrames[pipeIdx];
+        frm->chNum = instObj->createParams.pipeId[pipeIdx];
+        frm->addr[0U] = (uint64_t)(APP_DSS_M2M_DDR_LOAD_ADDRESS +
+               (pipeIdx * APP_DSS_M2M_IN_FRAME_PITCH * APP_DSS_M2M_IN_FRAME_HEIGHT));
+        inFrmList.frames[pipeIdx] = frm;
+    }
+    inFrmList.numFrames = instObj->numPipe;
+    frm = (Fvid2_Frame *) &instObj->outFrames[0U];
+    /* init Fvid2_Frame to 0's  */
+    frm->addr[0U] = (uint64_t)&(gOutFrms[(instObj->instIdx * APP_DSS_M2M_CH_NUM)][0U]);
+    frm->addr[1U] = (uint64_t)&(gOutUVComp[(instObj->instIdx * APP_DSS_M2M_CH_NUM)][0U]);
+    outFrmList.frames[0U] = frm;
+    outFrmList.numFrames = 1U;
+    retVal = Fvid2_processRequest(instObj->drvHandle,
+                                  &inFrmList,
+                                  &outFrmList,
+                                  FVID2_TIMEOUT_NONE);
+    if(FVID2_SOK != retVal)
+    {
+        App_consolePrintf("\nERROR: Fvid2_processRequest Failed!!!\r\n");
+    }
+
+    return retVal;
+}
+
+static int32_t App_pipeCbFxn(Fvid2_Handle handle, void *appData)
+{
+    int32_t retVal = FVID2_SOK;
+    M2MApp_InstParams *instObj;
+
+    GT_assert(DssTrace, (appData != NULL));
+
+    instObj = (M2MApp_InstParams *)appData;
+    instObj->appObj->numFramesWb++;
+    /* Post semaphore */
+    (void) SemaphoreP_post(instObj->syncSem);
+
+    return retVal;
+}
diff --git a/packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test_cfg.h b/packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test_cfg.h
new file mode 100755
index 0000000..048f337
--- /dev/null
+++ b/packages/ti/drv/dss/examples/dss_m2m_test/dss_m2m_test_cfg.h
@@ -0,0 +1,230 @@
+/*
+ *  Copyright (c) Texas Instruments Incorporated 2021
+ *  All rights reserved.
+ *
+ *  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 dss_m2m_test_cfg.h
+ *
+ *  \brief DSS Display M2M Test Configuration Header file.
+ */
+
+#ifndef DSS_DISPLAY_TEST_CFG_H_
+#define DSS_DISPLAY_TEST_CFG_H_
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+#include <stdint.h>
+#include <stdio.h>
+#include "ti/osal/osal.h"
+#include "ti/osal/TaskP.h"
+
+#include <ti/board/board.h>
+#include <ti/drv/dss/examples/utils/app_utils.h>
+#include <ti/drv/sciclient/sciclient.h>
+#include <ti/csl/soc.h>
+#include <ti/drv/pm/pmlib.h>
+#include <ti/drv/uart/UART.h>
+#include <ti/drv/uart/UART_stdio.h>
+#include <ti/drv/dss/examples/utils/app_utils_prf.h>
+
+#include <ti/drv/dss/dss.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+/**< Application name */
+#define APP_NAME                        "DSS_M2M_APP"
+
+/**< Driver instance to use */
+#define APP_DSS_M2M_INST                ((uint32_t)DSS_M2M_WB_PIPELINE_ID_0)
+
+/**< Number of channels i.e number of driver instances to be opened */
+#define APP_DSS_M2M_CH_NUM                           ((uint32_t)1U)
+
+/**< Number of display pipelines to use */
+#define APP_DSS_M2M_DSS_PIPE_NUM                     ((uint32_t)1U)
+
+/**< ID of display pipeline to use */
+#define APP_DSS_M2M_DSS_PIPE_ID                      (CSL_DSS_VID_PIPE_ID_VID1)
+
+/**< ID of display overlay to use */
+#define APP_DSS_M2M_DSS_OVERLAY_ID                   (CSL_DSS_OVERLAY_ID_1)
+
+/**< Number of frames to convert */
+#define APP_DSS_M2M_FRAMES_WB                      ((uint32_t)1000U)
+
+/**< Buffer load address for runtime loading buffers */
+#define APP_DSS_M2M_DDR_LOAD_ADDRESS               (0x82000000U)
+
+/**< Input Frame Attribute: Format */
+#define APP_DSS_M2M_IN_FRAME_FORMAT                     (FVID2_DF_YUV422I_YUYV)
+/**< Input Frame Attribute: Width in pixels */
+#define APP_DSS_M2M_IN_FRAME_WIDTH                      ((uint32_t)1920U)
+/**< Input Frame Attribute: Height in pixels */
+#define APP_DSS_M2M_IN_FRAME_HEIGHT                     ((uint32_t)1080U)
+/**< Input Frame Attribute: Bytes per pixel */
+#define APP_DSS_M2M_IN_FRAME_BPP                        ((uint32_t)2U)
+/**< Input Frame Attribute: Pitch in bytes */
+#define APP_DSS_M2M_IN_FRAME_PITCH                      ((uint32_t)\
+                            (APP_DSS_M2M_IN_FRAME_WIDTH * APP_DSS_M2M_IN_FRAME_BPP))
+
+/**< Output Frame Attribute: Format */
+#define APP_DSS_M2M_OUT_FRAME_FORMAT                     (FVID2_DF_YUV420SP_UV)
+/**< Output Frame Attribute: Width in pixels */
+#define APP_DSS_M2M_OUT_FRAME_WIDTH                      ((uint32_t)1920U)
+/**< Output Frame Attribute: Height in pixels */
+#define APP_DSS_M2M_OUT_FRAME_HEIGHT                     ((uint32_t)1080U)
+/**< Output Frame Attribute: Bytes per pixel */
+#define APP_DSS_M2M_OUT_FRAME_BPP                        (1U)
+/**< Output Frame Attribute: Pitch in bytes */
+#define APP_DSS_M2M_OUT_FRAME_PITCH                      ((uint32_t)\
+                            (APP_DSS_M2M_OUT_FRAME_WIDTH * APP_DSS_M2M_OUT_FRAME_BPP))
+
+/* Print buffer character limit for prints- UART or CCS Console */
+#define APP_PRINT_BUFFER_SIZE                   ((uint32_t)4000)
+
+/** \brief Log enable for DSS M2M Sample application */
+#define DssM2MAppTrace                       ((uint32_t) GT_INFO   |\
+                                              (uint32_t) GT_TraceState_Enable)
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+typedef struct M2MApp_AppObj_t M2MApp_AppObj;
+
+/**
+ *  \brief Display application test parameters.
+ *  The test case execution happens based on values of this structure
+ */
+typedef struct
+{
+    uint32_t instIdx;
+    /**< Instance index in application object */
+    Fvid2_Handle drvHandle;
+    /**< FVID2 display driver handle */
+    uint32_t numPipe;
+    /**< Number of Display pipe used */
+    Dss_WbCreateParams createParams;
+    /**< WB pipe create parameters */
+    Dss_WbCreateStatus createStatus;
+    /**< WB pipe create status */
+    Fvid2_CbParams cbParams;
+    /**< Callback parameters */
+    Dss_WbStatus wbStatus;
+    /**< WB pipe status */
+    SemaphoreP_Handle syncSem;
+    /**< Semaphore for ISR */
+    Dss_WbPipeCfgParams wbCfg;
+    /**< WB pipe configuration */
+    CSL_DssWbPipeDmaCfg wbDmaCfg;
+    /**< WB pipe DMA configuration */
+    Dss_WbPipeMflagParams wbMflagCfg;
+    /**< WB pipe MFlag configuration */
+    CSL_DssCscCoeff wbCscCfg;
+    /**< WB pipe CSC configuration */
+    Dss_PipeCfgParams pipeCfg[DSSM2M_NUM_PIPELINE_TO_USE_IN_M2M_MODE];
+    /**< Display pipe configuration */
+    Dss_PipeMflagParams mFlagCfg[DSSM2M_NUM_PIPELINE_TO_USE_IN_M2M_MODE];
+    /**< Display pipe MFlag configuration */
+    Dss_PipeCscParams cscCfg[DSSM2M_NUM_PIPELINE_TO_USE_IN_M2M_MODE];
+    /**< Display pipe CSC configuration */
+    Dss_DctrlOverlayParams ovrCfg;
+    /**< Display Overlay configuration */
+    Dss_DctrlOverlayLayerParams layerCfg;
+    /**< Display Layer configuration */
+    Dss_DctrlGlobalDssParams globalParams;
+    /**< Display Global configuration */
+   M2MApp_AppObj *appObj;
+   /**< Reference to Application Object  */
+   Fvid2_Frame inFrames[DSSM2M_NUM_PIPELINE_TO_USE_IN_M2M_MODE];
+   /**< FVID2 Frames that will be used for capture. */
+   Fvid2_Frame outFrames[1U];
+   /**< FVID2 Frames that will be used for capture. */
+} M2MApp_InstParams;
+
+/**
+ *  \brief Display application object.
+ *  The test case execution happens based on values of this structure
+ */
+struct M2MApp_AppObj_t
+{
+    uint32_t numInst;
+    /**< Number of driver instances to open */
+    M2MApp_InstParams instParams[APP_DSS_M2M_CH_NUM];
+    /**< Instance object */
+    Dss_InitParams initParams;
+    /**< DSS Initialization Parameters */
+    uint32_t numFramesToConvert;
+    /**< Number of frames to convert for a given configuration */
+    volatile uint32_t numFramesWb;
+   /**< Number of frames wrote-back */
+};
+/* ========================================================================== */
+/*                  Internal/Private Function Declarations                   */
+/* ========================================================================== */
+
+
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+
+void App_consolePrintf(const char *pcString, ...);
+
+/* ========================================================================== */
+/*                              Global Variables                              */
+/* ========================================================================== */
+
+
+/* ========================================================================== */
+/*      Internal Function Declarations (Needed for other static inlines)      */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                       Static Function Definitions                          */
+/* ========================================================================== */
+
+/* None */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef DSS_DISPLAY_TEST_CFG_H_ */
+
+/* @} */
diff --git a/packages/ti/drv/dss/examples/dss_m2m_test/main_rtos.c b/packages/ti/drv/dss/examples/dss_m2m_test/main_rtos.c
new file mode 100755
index 0000000..a3a3cb0
--- /dev/null
+++ b/packages/ti/drv/dss/examples/dss_m2m_test/main_rtos.c
@@ -0,0 +1,189 @@
+/*
+ *  Copyright (c) Texas Instruments Incorporated 2021
+ *  All rights reserved.
+ *
+ *  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 main_rtos.c
+ *
+ *  \brief Main file for RTOS builds
+ */
+
+/* ========================================================================== */
+/*                             Include Files                                  */
+/* ========================================================================== */
+#include <ti/board/board.h>
+#include <ti/drv/dss/examples/utils/app_utils.h>
+#include <ti/drv/sciclient/sciclient.h>
+#include <ti/csl/soc.h>
+#include <ti/drv/pm/pmlib.h>
+#include "dss_m2m_test_cfg.h"
+
+/* ========================================================================== */
+/*                           Macros & Typedefs                                */
+/* ========================================================================== */
+
+/* Test application stack size */
+#define DISP_APP_TSK_STACK_MAIN         (10U * 1024U)
+
+/* ========================================================================== */
+/*                         Structure Declarations                             */
+/* ========================================================================== */
+
+/* None */
+
+/* ========================================================================== */
+/*                          Function Declarations                             */
+/* ========================================================================== */
+
+static void taskFxn(void* a0, void* a1);
+extern int32_t Dss_displayM2MTest(void);
+static void App_clkRateSet(uint32_t moduleId,
+                           uint32_t clkId,
+                           uint64_t clkRateHz);
+/* ========================================================================== */
+/*                            Global Variables                                */
+/* ========================================================================== */
+
+/* Test application stack */
+static uint8_t gDispAppTskStackMain[DISP_APP_TSK_STACK_MAIN];
+
+/* ========================================================================== */
+/*                          Function Definitions                              */
+/* ========================================================================== */
+
+int main(void)
+{
+    TaskP_Handle task;
+    TaskP_Params taskParams;
+
+    OS_init();
+
+    /* Initialize the task params */
+    TaskP_Params_init(&taskParams);
+    /* Set the task priority higher than the default priority (1) */
+    taskParams.priority = 2;
+    taskParams.stack = gDispAppTskStackMain;
+    taskParams.stacksize = sizeof(gDispAppTskStackMain);
+
+    task = TaskP_create(taskFxn, &taskParams);
+    if(NULL == task)
+    {
+        OS_stop();
+    }
+
+    OS_start();    /* does not return */
+
+    return(0);
+}
+
+static void taskFxn(void* a0, void* a1)
+{
+    int32_t retVal = CSL_PASS;
+    uint64_t clkFreq = 0U;
+    Board_initCfg boardCfg;
+
+    boardCfg = BOARD_INIT_PINMUX_CONFIG |
+                BOARD_INIT_UNLOCK_MMR |
+                BOARD_INIT_UART_STDIO;
+    Board_init(boardCfg);
+
+    Sciclient_init(NULL);
+    retVal += Sciclient_pmSetModuleState(TISCI_DEV_DSS0,
+                                   TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
+                                   TISCI_MSG_FLAG_AOP,
+                                   SCICLIENT_SERVICE_WAIT_FOREVER);
+    retVal += Sciclient_pmSetModuleState(TISCI_DEV_DSS_DSI0,
+                                   TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
+                                   TISCI_MSG_FLAG_AOP,
+                                   SCICLIENT_SERVICE_WAIT_FOREVER);
+    retVal += Sciclient_pmSetModuleState(TISCI_DEV_DSS_EDP0,
+                                   TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
+                                   TISCI_MSG_FLAG_AOP,
+                                   SCICLIENT_SERVICE_WAIT_FOREVER);
+
+    /* set DSS VP4 clocks */
+    App_clkRateSet(TISCI_DEV_DSS0,
+                   TISCI_DEV_DSS0_DSS_INST0_DPI_3_IN_2X_CLK,
+                   148500000U);
+    /* Get the DSS VP4 clock frequencies */
+    retVal += PMLIBClkRateGet(TISCI_DEV_DSS0,
+                              TISCI_DEV_DSS0_DSS_INST0_DPI_0_IN_2X_CLK,
+                              &clkFreq);
+    App_consolePrintf("\n TISCI_DEV_DSS0_DSS_INST0_DPI_0_IN_2X_CLK = %lld Hz\n", clkFreq);
+    retVal += PMLIBClkRateGet(TISCI_DEV_DSS0,
+                              TISCI_DEV_DSS0_DSS_INST0_DPI_1_IN_2X_CLK,
+                              &clkFreq);
+    App_consolePrintf("\n TISCI_DEV_DSS0_DSS_INST0_DPI_1_IN_2X_CLK = %lld Hz\n", clkFreq);
+    retVal += PMLIBClkRateGet(TISCI_DEV_DSS0,
+                              TISCI_DEV_DSS0_DSS_INST0_DPI_2_IN_2X_CLK,
+                              &clkFreq);
+    App_consolePrintf("\n TISCI_DEV_DSS0_DSS_INST0_DPI_2_IN_2X_CLK = %lld Hz\n", clkFreq);
+    retVal += PMLIBClkRateGet(TISCI_DEV_DSS0,
+                              TISCI_DEV_DSS0_DSS_INST0_DPI_3_IN_2X_CLK,
+                              &clkFreq);
+    App_consolePrintf("\n TISCI_DEV_DSS0_DSS_INST0_DPI_3_IN_2X_CLK = %lld Hz\n", clkFreq);
+    if (retVal == CSL_PASS)
+    {
+        Dss_displayM2MTest();
+    }
+
+    return;
+}
+
+
+void App_wait(uint32_t wait_in_ms)
+{
+    TaskP_sleep(wait_in_ms);
+}
+
+static void App_clkRateSet(uint32_t moduleId,
+                           uint32_t clkId,
+                           uint64_t clkRateHz)
+{
+    int32_t status;
+    uint64_t currClkFreqHz;
+
+    status = PMLIBClkRateGet(moduleId, clkId, &currClkFreqHz);
+    if ((status == CSL_PASS) &&
+        (currClkFreqHz != clkRateHz))
+    {
+        status = PMLIBClkRateSet(moduleId, clkId, clkRateHz);
+        if (status == CSL_PASS)
+        {
+            App_consolePrintf("\nPMLIBClkRateSet Passed for clock Id = %d\n", clkId);
+        }
+        else
+        {
+            App_consolePrintf("\nPMLIBClkRateSet failed for clock Id = %d\n", clkId);
+        }
+    }
+}
diff --git a/packages/ti/drv/dss/examples/dss_m2m_test/makefile b/packages/ti/drv/dss/examples/dss_m2m_test/makefile
new file mode 100755
index 0000000..6cc880f
--- /dev/null
+++ b/packages/ti/drv/dss/examples/dss_m2m_test/makefile
@@ -0,0 +1,12 @@
+#
+# This file is the makefile for building DSS display test app for TI RTOS
+#
+ifeq ($(RULES_MAKE), )
+include $(PDK_INSTALL_PATH)/ti/build/Rules.make
+else
+include $(RULES_MAKE)
+endif
+
+APP_NAME = dss_m2m_testapp_$(BUILD_OS_TYPE)
+
+include makefile.mk
diff --git a/packages/ti/drv/dss/examples/dss_m2m_test/makefile.mk b/packages/ti/drv/dss/examples/dss_m2m_test/makefile.mk
new file mode 100755
index 0000000..c779e39
--- /dev/null
+++ b/packages/ti/drv/dss/examples/dss_m2m_test/makefile.mk
@@ -0,0 +1,52 @@
+#
+# This file is the makefile for building DSS display test app for both TI RTOS
+# and baremetal
+#
+
+SRCDIR = .
+INCDIR = .
+
+# List all the external components/interfaces, whose interface header files
+#  need to be included for this component
+INCLUDE_EXTERNAL_INTERFACES = pdk
+
+ifeq ($(BUILD_OS_TYPE),tirtos)
+  CFLAGS_OS_DEFINES = -DUSE_BIOS
+  INCLUDE_EXTERNAL_INTERFACES += xdc bios
+  COMP_LIST_COMMON = $(PDK_COMMON_TIRTOS_COMP)
+  # Enable XDC build for application by providing XDC CFG File per core
+  XDC_CFG_FILE_$(CORE) = $(PDK_INSTALL_PATH)/ti/build/$(SOC)/sysbios_$(ISA).cfg
+endif
+
+ifeq ($(BUILD_OS_TYPE),freertos)
+  CFLAGS_OS_DEFINES = -DFREERTOS
+  INCLUDE_EXTERNAL_INTERFACES += freertos
+  COMP_LIST_COMMON += $(PDK_COMMON_FREERTOS_COMP)
+endif
+
+# List all the specific components required by the application
+COMP_LIST_COMMON += fvid2 dss
+
+# Common source files and CFLAGS across all platforms and cores
+PACKAGE_SRCS_COMMON = .
+SRCS_COMMON += main_rtos.c
+SRCS_COMMON += dss_m2m_test.c
+CFLAGS_LOCAL_COMMON += $(PDK_CFLAGS) $(DSS_CFLAGS) $(CFLAGS_OS_DEFINES)
+
+# 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
diff --git a/packages/ti/drv/dss/src/drv/common/dss_init.c b/packages/ti/drv/dss/src/drv/common/dss_init.c
index 5bdc869..29b593f 100755
--- a/packages/ti/drv/dss/src/drv/common/dss_init.c
+++ b/packages/ti/drv/dss/src/drv/common/dss_init.c
@@ -47,7 +47,7 @@
 #include <ti/drv/dss/src/drv/common/dss_evtMgr.h>
 #include <ti/drv/dss/src/drv/dctrl/dss_dctrlDrv.h>
 #include <ti/drv/dss/src/drv/disp/dss_dispDrv.h>
-#if defined (SOC_J721E) || defined (SOC_J721S2)
+#if defined (SOC_J721E) || defined (SOC_J721S2) || defined (SOC_J784S4)
 #include <ti/drv/dss/src/drv/m2m/dss_m2mDrv.h>
 #endif
 
@@ -167,7 +167,7 @@ int32_t Dss_init(const Dss_InitParams *initParams)
         }
         retVal += Dss_dispDrvInit(numInst, dispInitParams);
     }
-#if defined (SOC_J721E) || defined (SOC_J721S2)
+#if defined (SOC_J721E) || defined (SOC_J721S2) || defined (SOC_J784S4)
     if(FVID2_SOK == retVal)
     {
         /* Initialize display M2M driver */
@@ -182,7 +182,7 @@ int32_t Dss_deInit(void)
 {
     int32_t retVal = FVID2_SOK;
 
-#if defined (SOC_J721E) || defined (SOC_J721S2)
+#if defined (SOC_J721E) || defined (SOC_J721S2) || defined (SOC_J784S4)
     retVal += Dss_m2mDrvDeInit();
 #endif
     retVal += Dss_dispDrvDeInit();
-- 
2.17.1

