[DSS DRV][Bug Fix][PDK-5040]Display stops working if two pipelines are started back...
[processor-sdk/pdk.git] / packages / ti / drv / dss / src / drv / dctrl / dss_dctrlApi.c
1 /*
2  *  Copyright (c) Texas Instruments Incorporated 2018
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *    Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *    Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *    Neither the name of Texas Instruments Incorporated nor the names of
18  *    its contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
34 /**
35  *  \file dss_dctrlApi.c
36  *
37  *  \brief File containing the DSS Controller driver implementation.
38  *
39  */
41 /* ========================================================================== */
42 /*                             Include Files                                  */
43 /* ========================================================================== */
45 #include <ti/drv/dss/dss.h>
46 #include <ti/drv/dss/src/drv/common/dss_evtMgr.h>
47 #include <ti/drv/dss/src/drv/dctrl/dss_dctrlDrv.h>
48 #include <ti/drv/dss/src/drv/dctrl/dss_dctrlIntr.h>
49 #include <ti/drv/dss/src/drv/dctrl/dss_dctrlPriv.h>
50 #include <dss_soc_priv.h>
52 /* ========================================================================== */
53 /*                           Macros & Typedefs                                */
54 /* ========================================================================== */
56 /* None */
58 /* ========================================================================== */
59 /*                         Structure Declarations                             */
60 /* ========================================================================== */
62 /* None */
64 /* ========================================================================== */
65 /*                          Function Declarations                             */
66 /* ========================================================================== */
68 /**
69  *  Below ifdef __cplusplus is added so that C++ build passes without
70  *  typecasting. This is because the prototype is build as C type
71  *  whereas this file is build as CPP file. Hence we get C++ build error.
72  *  Also if typecasting is used, then we get MisraC error Rule 11.1.
73  */
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 /*
78  * Display Controller APIs
79  */
80 static Fdrv_Handle Dss_dctrlDrvCreate(uint32_t drvId,
81                                       uint32_t instId,
82                                       void *createArgs,
83                                       void *createStatusArgs,
84                                       const Fvid2_DrvCbParams *fdmCbParams);
85 static int32_t Dss_dctrlDrvDelete(Fdrv_Handle handle, void *reserved);
86 static int32_t Dss_dctrlDrvControl(Fdrv_Handle handle,
87                                    uint32_t cmd,
88                                    void *cmdArgs,
89                                    void *cmdStatusArgs);
90 #ifdef __cplusplus
91 }
92 #endif
94 /* ========================================================================== */
95 /*                            Global Variables                                */
96 /* ========================================================================== */
98 Dss_DctrlDrvCommonObj gDss_DctrlDrvCommonObj;
99 Dss_DctrlDrvInstObj   gDss_DctrlDrvInstObj;
101 Dss_DctrlDrvGraphObj gDss_DctrlDrvGraphObj;
102 Dss_DctrlDrvInfo gDss_DctrlDrvInfo;
103 Dss_EvtMgrClientInfo gDss_DctrlEvtMgrClientInfo[DSS_DCTRL_EVT_MGR_MAX_CLIENTS];
105 /* Semaphore to sync up back to back Fvid2_start() calls.
106    A VSYNC is needed between back to back Fvid2_start() calls. */
107 SemaphoreP_Handle gDssStartSyncSem;
108 /* ========================================================================== */
109 /*                  Internal/Private Function Declarations                    */
110 /* ========================================================================== */
112 static int32_t Dss_dctrlDrvSetPathIoctl(Dss_DctrlDrvInstObj *instObj,
113                                         const Dss_DctrlPathInfo *pathInfo);
114 static int32_t Dss_dctrlDrvClearPathIoctl(Dss_DctrlDrvInstObj *instObj,
115                                           const Dss_DctrlPathInfo *pathInfo);
116 static int32_t Dss_dctrlDrvSetVpParamsIoctl(
117                             Dss_DctrlDrvInstObj *instObj,
118                             const Dss_DctrlVpParams *vpParams);
119 static int32_t Dss_dctrlDrvSetOverlayParamsIoctl(
120                             Dss_DctrlDrvInstObj *instObj,
121                             const Dss_DctrlOverlayParams *overlayParams);
122 static int32_t Dss_dctrlDrvSetLayerParamsIoctl(
123                             Dss_DctrlDrvInstObj *instObj,
124                             const Dss_DctrlOverlayLayerParams *layerParams);
125 static int32_t Dss_dctrlDrvSetVpCscCoeffIoctl(
126                             Dss_DctrlDrvInstObj *instObj,
127                             const Dss_DctrlVpCscCoeff *vpCscCoeff);
128 static int32_t Dss_dctrlDrvSetAdvVpParamsIoctl(
129                             Dss_DctrlDrvInstObj *instObj,
130                             const Dss_DctrlAdvVpParams *advVpParams);
131 static int32_t Dss_dctrlDrvSetLcdBlankTimingIoctl(
132                             Dss_DctrlDrvInstObj *instObj,
133                             const Dss_DctrlLcdBlankTimingParams *timingParams);
134 static int32_t Dss_dctrlDrvSetVpSafetyChkParamsIoctl(
135                             Dss_DctrlDrvInstObj *instObj,
136                             const Dss_DctrlVpSafetyChkParams *safetyChkParams);
137 static int32_t Dss_dctrlDrvGetErrorStatsIoctl(
138                             Dss_DctrlDrvInstObj *instObj,
139                             Dss_DctrlVpErrorStats *vpErrStats);
140 static int32_t Dss_dctrlDrvSetGlobalDssParamsIoctl(
141                             Dss_DctrlDrvInstObj *instObj,
142                             const Dss_DctrlGlobalDssParams *globalDssParams);
143 static int32_t Dss_dctrlDrvStopVpIoctl(Dss_DctrlDrvInstObj *instObj,
144                                        const Dss_DctrlVpParams *vpParams);
145 static int32_t Dss_dctrlDrvSetSyncLostCbParamsIoctl(
146                             Dss_DctrlDrvInstObj *instObj,
147                             const Dss_DctrlSyncLostCbParams *syncLostCbParams);
148 static int32_t Dss_dctrlDrvSetLineNumCbParamsIoctl(
149                             Dss_DctrlDrvInstObj *instObj,
150                             const Dss_DctrlLineNumCbParams *lineNumCbParams);
151 static void Dss_dctrlFuncCbFxn(const uint32_t *event,
152                                uint32_t numEvents,
153                                void *arg);
154 static void Dss_dctrlErrCbFxn(const uint32_t *event,
155                               uint32_t numEvents,
156                               void *arg);
157 static void Dss_dctrlSafetyErrCbFxn(const uint32_t *event,
158                                     uint32_t numEvents,
159                                     void *arg);
160 static int32_t Dss_dctrlConnectNodes(uint32_t inputNode, uint32_t outNode);
162 #if defined (SOC_AM65XX)
163 static int32_t Dss_dctrlDrvSetOldiParamsIoctl(
164                             Dss_DctrlDrvInstObj *instObj,
165                             const Dss_DctrlOldiParams *oldiParams);
166 #endif
168 #if defined (SOC_J721E)
169 static uint32_t Dss_dctrlDrvIsOutputDP(uint32_t vpId);
170 static int32_t Dss_dctrlDrvSetDpHpdCbParamsIoctl(
171                             Dss_DctrlDrvInstObj *instObj,
172                             const Dss_DctrlDpHpdCbParams *dpHpdCbParams);
173 static int32_t Dss_dctrlDrvProcessDpHpdIoctl(
174                             Dss_DctrlDrvInstObj *instObj,
175                             const uint32_t *dpProcessHpdParams);
176 static int32_t Dss_dctrlSetDsiParamsIoctl(Dss_DctrlDrvInstObj *instObj,
177                                           const Dss_DctrlDsiParams *dsiPrms);
178 static uint32_t Dss_dctrlDrvIsOutputDSI(uint32_t vpId);
179 #endif
182 static void Dss_dctrlVpSetGoBit(uint32_t vpId);
183 static void Dss_dctrlVpReset(uint32_t vpId);
184 static void Dss_dctrlVpEnable(uint32_t vpId, uint32_t enable);
186 /* ========================================================================== */
187 /*                          Function Definitions                              */
188 /* ========================================================================== */
190 int32_t Dss_dctrlDrvInit(const Dss_DctrlDrvInitParams *drvInitParams)
192     int32_t retVal = FVID2_SOK;
193     uint32_t i, cnt, eventGroup, vpId, numHandle, numEvents, evtMgrId;
194     uint32_t enabledEvents[DSS_EVT_MGR_MAX_CLIENT_EVENTS];
195     Dss_DctrlDrvInfo *pDrvInfo;
196     Dss_DctrlDrvCommonObj *pObj;
197     Dss_DctrlDrvGraphObj *pGraphObj;
198     Dss_DctrlDrvInstObj *pDrvInstObj;
199     Dss_EvtMgrClientInfo *pClientInfo;
200     SemaphoreP_Params semParams;
202     pDrvInfo = &gDss_DctrlDrvInfo;
203     pObj = &gDss_DctrlDrvCommonObj;
204     pGraphObj = &gDss_DctrlDrvGraphObj;
205     pDrvInstObj = &gDss_DctrlDrvInstObj;
207     Fvid2Utils_memset(pObj, 0U, sizeof (Dss_DctrlDrvCommonObj));
208     Fvid2Utils_memset(pGraphObj, 0U, sizeof (Dss_DctrlDrvGraphObj));
209     Fvid2Utils_memset(pDrvInfo, 0U, sizeof (Dss_DctrlDrvInfo));
210     Fvid2Utils_memset(pDrvInstObj, 0U, sizeof (Dss_DctrlDrvInstObj));
212     for(i=0U; i<DSS_DCTRL_EVT_MGR_MAX_CLIENTS; i++)
213     {
214         pClientInfo = &gDss_DctrlEvtMgrClientInfo[i];
215         Fvid2Utils_memset(pClientInfo, 0U, sizeof (Dss_EvtMgrClientInfo));
216     }
217     /* Initialize instance object members */
218     pObj->instObj = &gDss_DctrlDrvInstObj;
219     pObj->instObj->drvInstId = drvInitParams->drvInstId;
221     /* Initialize graph object */
222     (void) Dss_dctrlDrvGraphInit(pGraphObj);
224     if(FVID2_SOK == retVal)
225     {
226         /* Allocate instance semaphore */
227         SemaphoreP_Params_init(&semParams);
228         semParams.mode = SemaphoreP_Mode_BINARY;
229         pObj->instObj->lockSem = SemaphoreP_create(1U, &semParams);
230         if(NULL == pObj->instObj->lockSem)
231         {
232             GT_0trace(DssTrace,
233                     GT_ERR,
234                     "Instance semaphore create failed!!\r\n");
235             retVal = FVID2_EALLOC;
236         }
238         for(i=0U; i<CSL_DSS_VID_PIPE_ID_MAX; i++)
239         {
240             /* Allocate instance semaphore */
241             pDrvInfo->pipeInfo[i].stopSem = SemaphoreP_create(0U, &semParams);
242             if(NULL == pDrvInfo->pipeInfo[i].stopSem)
243             {
244                 GT_0trace(DssTrace,
245                         GT_ERR,
246                         "Sync Stop semaphore create failed!!\r\n");
247                 retVal = FVID2_EALLOC;
248             }
249         }
251         for(i=0U; i<CSL_DSS_VP_ID_MAX; i++)
252         {
253             pDrvInfo->vpState[i] = DSS_DCTRL_VP_IDLE;
254         }
256         pObj->instObj->drvState.isInit = TRUE;
257         pObj->instObj->drvState.isOpened = FALSE;
258         pObj->instObj->drvState.isStarted = FALSE;
259     }
261     if(FVID2_SOK == retVal)
262     {
263         /* Register for Video Port events */
264         for(cnt=0U; cnt<drvInitParams->numAvailablePorts; cnt++)
265         {
266             vpId = drvInitParams->availablePortId[cnt];
267             Dss_convModuletoEventGroup(&eventGroup,
268                                        vpId,
269                                        DSS_EVENT_GROUP_TYPE_VP);
270             GT_assert(DssTrace, (DSS_EVENT_GROUP_INVALID != eventGroup));
272             /* Register functional events */
273             Dss_getEnabledVpFuncEvents(&enabledEvents[0U], &numEvents);
274             numHandle = pObj->instObj->numRegEvtHandle;
275             evtMgrId = Dss_getEvtMgrFuncIntrId();
276             pObj->instObj->evtGroupHandle[pObj->instObj->numRegEvtHandle] =
277                             Dss_evtMgrRegister(
278                                 evtMgrId,
279                                 eventGroup,
280                                 (const uint32_t *)&enabledEvents[0U],
281                                 numEvents,
282                                 Dss_dctrlFuncCbFxn,
283                                 (void *)&gDss_DctrlEvtMgrClientInfo[numHandle]);
284             pObj->instObj->numRegEvtHandle++;
286             /* Register error events */
287             Dss_getEnabledVpErrEvents(&enabledEvents[0U], &numEvents);
288             numHandle = pObj->instObj->numRegEvtHandle;
289             pObj->instObj->evtGroupHandle[pObj->instObj->numRegEvtHandle] =
290                             Dss_evtMgrRegister(
291                                 evtMgrId,
292                                 eventGroup,
293                                 (const uint32_t *)&enabledEvents[0U],
294                                 numEvents,
295                                 Dss_dctrlErrCbFxn,
296                                 (void *)&gDss_DctrlEvtMgrClientInfo[numHandle]);
297             pObj->instObj->numRegEvtHandle++;
298         }
299     }
301 #if defined (SOC_J721E)
302     if((FVID2_SOK == retVal) &&
303     (TRUE == drvInitParams->dpInitParams.isAvailable))
304     {
305         retVal = Dss_dctrlDrvInitDp(drvInitParams->dpInitParams.isHpdSupported);
306     }
308     if (TRUE == drvInitParams->dsiInitParams.isAvailable)
309     {
310         Dss_dctrlDrvInitDSI();
311     }
312 #endif
314     if(FVID2_SOK == retVal)
315     {
316         /* Initialize Driver operations */
317         Fvid2DrvOps_init(&pObj->fvidDrvOps);
319         pObj->fvidDrvOps.drvId = DSS_DCTRL_DRV_ID;
320         pObj->fvidDrvOps.createFxn = &Dss_dctrlDrvCreate;
321         pObj->fvidDrvOps.deleteFxn = &Dss_dctrlDrvDelete;
322         pObj->fvidDrvOps.controlFxn = &Dss_dctrlDrvControl;
324         retVal = Fvid2_registerDriver(&pObj->fvidDrvOps);
325         if(FVID2_SOK != retVal)
326         {
327             GT_0trace(DssTrace,
328                       GT_ERR,
329                       "Registering to FVID2 driver manager failed\r\n");
330         }
331         else
332         {
333             /* Init successful */
334             pObj->isRegistered = TRUE;
336             /* Copy Init params to local object, for future use. */
337             Fvid2Utils_memcpy(&pObj->drvInitParams, drvInitParams,
338                 sizeof (Dss_DctrlDrvInitParams));
339         }
340     }
341     if (FVID2_SOK == retVal)
342     {
343         /* create semaphore */
344         SemaphoreP_Params_init(&semParams);
345         semParams.mode    = SemaphoreP_Mode_BINARY;
346         gDssStartSyncSem = SemaphoreP_create(1U, &semParams);
347     }
349     return (retVal);
352 int32_t Dss_dctrlDrvDeInit(void)
354     int32_t retVal = FVID2_SOK;
355     uint32_t cnt, numRegEvtHandle, i, vpFound = FALSE;;
356     Dss_DctrlDrvCommonObj *pObj;
357     Dss_DctrlDrvInstObj *instObj;
358     Dss_DctrlDrvGraphObj *pGraphObj;
359     Dss_DctrlDrvInfo *pDrvInfo;
360     pObj = &gDss_DctrlDrvCommonObj;
361     pGraphObj = &gDss_DctrlDrvGraphObj;
362     pDrvInfo = &gDss_DctrlDrvInfo;
363     if(NULL != pObj->instObj)
364     {
365         instObj = pObj->instObj;
366         if(instObj->drvState.isOpened == TRUE)
367         {
368             GT_0trace(DssTrace,
369                       GT_ERR,
370                       "Can't de-initialize when an instance is active\r\n");
371             retVal = FVID2_EFAIL;
372         }
374         for(i=0U; i<CSL_DSS_VP_ID_MAX; i++)
375         {
376             if(DSS_DCTRL_VP_IDLE != pDrvInfo->vpState[i])
377             {
378                 vpFound = TRUE;
379                 break;
380             }
381         }
382         if(TRUE == vpFound)
383         {
384             GT_0trace(DssTrace,
385                     GT_ERR,
386                     "Can't de-initialize when a VP is running\r\n");
387             retVal = FVID2_EFAIL;
388         }
390         /* Delete the graph object */
391         Dss_dctrlDrvGraphDeInit((void *) pGraphObj);
393         numRegEvtHandle = instObj->numRegEvtHandle;
394         /* Unregister event groups and delete object */
395         for(cnt=0U; cnt<numRegEvtHandle; cnt++)
396         {
397             (void) Dss_evtMgrUnRegister(instObj->evtGroupHandle[cnt]);
398             instObj->numRegEvtHandle--;
399         }
401         /* Delete the instance semaphore */
402         if(NULL != instObj->lockSem)
403         {
404             (void) SemaphoreP_delete(instObj->lockSem);
405             instObj->lockSem = NULL;
406         }
408         for(i=0U; i<CSL_DSS_VID_PIPE_ID_MAX; i++)
409         {
410             /* Delete instance semaphore */
411             if(NULL != pDrvInfo->pipeInfo[i].stopSem)
412             {
413                 (void) SemaphoreP_delete(pDrvInfo->pipeInfo[i].stopSem);
414                 pDrvInfo->pipeInfo[i].stopSem = NULL;
415             }
416         }
418         instObj->drvState.isInit = FALSE;
419         pObj->instObj = NULL;
420     }
422     if(TRUE == pObj->isRegistered)
423     {
424         /* Unregister from driver manager */
425         retVal = Fvid2_unRegisterDriver(&pObj->fvidDrvOps);
426         if(FVID2_SOK != retVal)
427         {
428             GT_0trace(DssTrace,
429                       GT_ERR,
430                       "Unregistering from FVID2 driver manager failed\r\n");
431         }
432         pObj->isRegistered = FALSE;
433     }
435     if (gDssStartSyncSem != NULL)
436     {
437         /* Delete semaphore */
438         (void)SemaphoreP_delete(gDssStartSyncSem);
439     }
441     return (retVal);
444 DssDctrlDrvClientHandle Dss_dctrlDrvRegisterClient(
445                                     uint32_t nodeId,
446                                     const Dss_DctrlDrvClientInfo *clientInfo)
448     uint32_t i;
449     DssDctrlDrvClientHandle clientHandle = NULL;
450     GT_assert(DssTrace, (NULL != clientInfo));
451     GT_assert(DssTrace,
452               (gDss_DctrlDrvInfo.numValidPipes <= CSL_DSS_VID_PIPE_ID_MAX));
454     for(i=0U; i<gDss_DctrlDrvInfo.numValidPipes; i++)
455     {
456         if(gDss_DctrlDrvInfo.pipeInfo[i].pipeNodeId == nodeId)
457         {
458             gDss_DctrlDrvInfo.pipeInfo[i].gClientInfo.cbFxn = clientInfo->cbFxn;
459             gDss_DctrlDrvInfo.pipeInfo[i].gClientInfo.arg = clientInfo->arg;
460             gDss_DctrlDrvInfo.pipeInfo[i].pipeState = DSS_DCTRL_PIPE_OPENED;
461             clientHandle = &gDss_DctrlDrvInfo.pipeInfo[i];
462             break;
463         }
464     }
466     return clientHandle;
469 int32_t Dss_dctrlDrvUnRegisterClient(DssDctrlDrvClientHandle handle)
471     int32_t retVal = FVID2_SOK;
472     Dss_DctrlDrvPipeInfo *pipeInfo;
473     GT_assert(DssTrace, (NULL != handle));
475     pipeInfo = (Dss_DctrlDrvPipeInfo *) handle;
476     pipeInfo->gClientInfo.cbFxn = NULL;
477     pipeInfo->gClientInfo.arg = NULL;
478     pipeInfo->pipeState = DSS_DCTRL_PIPE_IDLE;
480     return retVal;
483 int32_t Dss_dctrlDrvStartClient(DssDctrlDrvClientHandle handle,
484                                 uint32_t dummyStart)
486     int32_t retVal = FVID2_SOK;
487     uint32_t cookie;
488     Dss_DctrlDrvPipeInfo *pipeInfo;
489     GT_assert(DssTrace, (NULL != handle));
491     cookie = HwiP_disable();
493     pipeInfo = (Dss_DctrlDrvPipeInfo *) handle;
494     if(TRUE == dummyStart)
495     {
496         pipeInfo->pipeState = DSS_DCTRL_PIPE_STARTING;
497     }
498     else
499     {
500         pipeInfo->pipeState = DSS_DCTRL_PIPE_STARTED;
501     }
503     if(FALSE == dummyStart)
504     {
505         retVal = Dss_dctrlDrvSetGoBit(handle);
506     }
508     HwiP_restore(cookie);
510     return retVal;
513 int32_t Dss_dctrlDrvStopClient(DssDctrlDrvClientHandle handle,
514                                uint32_t syncStop)
516     int32_t retVal = FVID2_SOK;
517     uint32_t cookie;
518     Dss_DctrlDrvPipeInfo *pipeInfo;
519     GT_assert(DssTrace, (NULL != handle));
521     cookie = HwiP_disable();
522     pipeInfo = (Dss_DctrlDrvPipeInfo *) handle;
523     if(TRUE == syncStop)
524     {
525         pipeInfo->pipeState = DSS_DCTRL_PIPE_STOPPING;
526     }
527     else
528     {
529         pipeInfo->pipeState = DSS_DCTRL_PIPE_STOPPED;
530     }
532     if(FALSE == syncStop)
533     {
534         retVal = Dss_dctrlDrvSetGoBit(handle);
535     }
537     HwiP_restore(cookie);
539     /* Take the stop semaphore */
540     (void) SemaphoreP_pend(pipeInfo->stopSem, SemaphoreP_WAIT_FOREVER);
541     return retVal;
544 int32_t Dss_dctrlDrvGetVpParams(DssDctrlDrvClientHandle handle,
545                                 Dss_DctrlVpParams *vpParams)
547     int32_t retVal = FVID2_SOK;
548     uint32_t i;
549     Dss_DctrlDrvPipeInfo *pipeInfo;
550     Dss_DctrlDrvInstObj *instObj;
551     Dss_DctrlDrvCommonObj *pObj = &gDss_DctrlDrvCommonObj;
552     GT_assert(DssTrace, (NULL != handle));
554     instObj = pObj->instObj;
556     /* Take the instance semaphore */
557     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
559     /* Get VP Params */
560     pipeInfo = (Dss_DctrlDrvPipeInfo *) handle;
561     for(i=0U; i<CSL_DSS_VP_ID_MAX; i++)
562     {
563         if(pipeInfo->vpId == gDss_DctrlDrvInfo.vpParams[i].vpId)
564         {
565             vpParams->lcdOpTimingCfg.mInfo.scanFormat =
566                     gDss_DctrlDrvInfo.vpParams[i].lcdOpTimingCfg.mInfo.scanFormat;
567             vpParams->lcdOpTimingCfg.mInfo.standard =
568                     gDss_DctrlDrvInfo.vpParams[i].lcdOpTimingCfg.mInfo.standard;
569             vpParams->lcdOpTimingCfg.mInfo.width =
570                     gDss_DctrlDrvInfo.vpParams[i].lcdOpTimingCfg.mInfo.width;
571             vpParams->lcdOpTimingCfg.mInfo.height =
572                     gDss_DctrlDrvInfo.vpParams[i].lcdOpTimingCfg.mInfo.height;
573             vpParams->vpId = gDss_DctrlDrvInfo.vpParams[i].vpId;
574             break;
575         }
576     }
578     /* Post the instance semaphore */
579     (void) SemaphoreP_post(instObj->lockSem);
581     return retVal;
584 int32_t Dss_dctrlDrvSetGoBit(DssDctrlDrvClientHandle handle)
586     int32_t retVal = FVID2_SOK;
587     Dss_DctrlDrvPipeInfo *pipeInfo;
588     GT_assert(DssTrace, (NULL != handle));
590     pipeInfo = (Dss_DctrlDrvPipeInfo *) handle;
592     /* Set Go Bit */
593     Dss_dctrlVpSetGoBit(pipeInfo->vpId);
595     return (retVal);
598 uint32_t Dss_dctrlDrvIsSafeToPush(DssDctrlDrvClientHandle handle)
600     uint32_t retVal = FALSE, cookie;
601     Dss_DctrlDrvPipeInfo *pipeInfo;
602     GT_assert(DssTrace, (NULL != handle));
604     pipeInfo = (Dss_DctrlDrvPipeInfo *) handle;
605     cookie = HwiP_disable();
606     retVal = gDss_DctrlDrvInfo.isPushSafe[pipeInfo->vpId];
607     HwiP_restore(cookie);
609     return retVal;
612 Dss_DctrlDrvPipeInfo *Dss_dctrlDrvGetPipeInfo(DssDctrlDrvClientHandle handle)
614     uint32_t i;
615     Dss_DctrlDrvPipeInfo *pipeInfo;
616     GT_assert(DssTrace, (NULL != handle));
618     pipeInfo = (Dss_DctrlDrvPipeInfo *) handle;
619     for(i=0U; i<gDss_DctrlDrvInfo.numValidPipes; i++)
620     {
621         if((gDss_DctrlDrvInfo.pipeInfo[i].pipeId == pipeInfo->pipeId) &&
622            ((gDss_DctrlDrvInfo.pipeInfo[i].pipeState ==
623                                             DSS_DCTRL_PIPE_OPENED)   ||
624             (gDss_DctrlDrvInfo.pipeInfo[i].pipeState ==
625                                             DSS_DCTRL_PIPE_STARTING) ||
626             (gDss_DctrlDrvInfo.pipeInfo[i].pipeState ==
627                                             DSS_DCTRL_PIPE_STARTED)  ||
628             (gDss_DctrlDrvInfo.pipeInfo[i].pipeState ==
629                                             DSS_DCTRL_PIPE_RUNNING)  ||
630             (gDss_DctrlDrvInfo.pipeInfo[i].pipeState ==
631                                             DSS_DCTRL_PIPE_STOPPING) ||
632             (gDss_DctrlDrvInfo.pipeInfo[i].pipeState ==
633                                             DSS_DCTRL_PIPE_STOPPED)))
634         {
635             break;
636         }
637     }
638     return &gDss_DctrlDrvInfo.pipeInfo[i];
641 /* ========================================================================== */
642 /*                       Static Function Definitions                          */
643 /* ========================================================================== */
645 static Fdrv_Handle Dss_dctrlDrvCreate(uint32_t drvId,
646                                       uint32_t instId,
647                                       void *createArgs,
648                                       void *createStatusArgs,
649                                       const Fvid2_DrvCbParams *fdmCbParams)
651     int32_t retVal = FVID2_SOK;
652     Fdrv_Handle drvHandle = NULL;
653     Dss_DctrlDrvInstObj *instObj = NULL;
654     Dss_DctrlDrvCommonObj *pObj;
656     pObj = &gDss_DctrlDrvCommonObj;
658     GT_assert(DssTrace, (NULL != pObj));
659     GT_assert(DssTrace, (NULL != pObj->instObj));
661     instObj = pObj->instObj;
663     if(NULL == instObj)
664     {
665         GT_0trace(DssTrace, GT_ERR, "Invalid instance ID\r\n");
666         retVal = FVID2_EINVALID_PARAMS;
667     }
669     if(NULL != instObj)
670     {
671         /* Take the instance semaphore */
672         (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
673     }
675     if(FVID2_SOK == retVal)
676     {
677         /* Initialize instance variables */
678         if(0U == instObj->numOpenDrvHandle)
679         {
680             instObj->drvState.isOpened = TRUE;
681         }
682         instObj->numOpenDrvHandle++;
683         drvHandle = instObj;
684     }
686     if(NULL != instObj)
687     {
688         /* Post the instance semaphore */
689         (void) SemaphoreP_post(instObj->lockSem);
690     }
692     return (drvHandle);
695 static int32_t Dss_dctrlDrvDelete(Fdrv_Handle handle, void *reserved)
697     int32_t retVal = FVID2_SOK;
699     Dss_DctrlDrvInstObj *instObj = NULL, *pInstObj = NULL;
700     Dss_DctrlDrvCommonObj *pObj;
702     /* Check for NULL pointers and invalid arguments */
703     if(NULL == handle)
704     {
705         GT_0trace(DssTrace, GT_ERR, "Invalid arguments\r\n");
706         retVal = FVID2_EBADARGS;
707     }
708     else
709     {
710         instObj = (Dss_DctrlDrvInstObj *) handle;
711         pObj = &gDss_DctrlDrvCommonObj;
712         pInstObj = pObj->instObj;
713     }
715     if(instObj != pInstObj)
716     {
717         GT_0trace(DssTrace, GT_ERR, "Invalid arguments\r\n");
718         retVal = FVID2_EBADARGS;
719     }
721     if((NULL != instObj) && (FVID2_SOK == retVal))
722     {
723         /* Take the instance semaphore */
724         (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
726         /* Check if already opened. */
727         if(TRUE != instObj->drvState.isOpened)
728         {
729             GT_0trace(DssTrace, GT_ERR, "ERROR: Driver not opened\r\n");
730             retVal = FVID2_EFAIL;
731         }
732     }
734     if(FVID2_SOK == retVal)
735     {
736         /* Reset other variables */
737         instObj->numOpenDrvHandle--;
738         if(0U == instObj->numOpenDrvHandle)
739         {
740             instObj->drvState.isOpened  = FALSE;
741             instObj->drvState.isStarted = FALSE;
742         }
743     }
745     if(NULL != instObj)
746     {
747         /* Post the instance semaphore */
748         (void) SemaphoreP_post(instObj->lockSem);
749     }
751     return (retVal);
754 static int32_t Dss_dctrlDrvControl(Fdrv_Handle handle,
755                                    uint32_t cmd,
756                                    void *cmdArgs,
757                                    void *cmdStatusArgs)
759     int32_t retVal = FVID2_SOK;
760     Dss_DctrlDrvInstObj *instObj;
762     /* Check for NULL pointers */
763     if((NULL == handle) || (NULL == cmdArgs))
764     {
765         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
766         retVal = FVID2_EBADARGS;
767     }
769     if(FVID2_SOK == retVal)
770     {
771         instObj = (Dss_DctrlDrvInstObj *) handle;
772         switch (cmd)
773         {
774             case IOCTL_DSS_DCTRL_SET_PATH:
775                 retVal = Dss_dctrlDrvSetPathIoctl(
776                     instObj,
777                     (const Dss_DctrlPathInfo*) cmdArgs);
778                 break;
779             case IOCTL_DSS_DCTRL_CLEAR_PATH:
780                 retVal = Dss_dctrlDrvClearPathIoctl(
781                     instObj,
782                     (const Dss_DctrlPathInfo*) cmdArgs);
783                 break;
784             case IOCTL_DSS_DCTRL_SET_VP_PARAMS:
785                 retVal = Dss_dctrlDrvSetVpParamsIoctl(
786                     instObj,
787                     (const Dss_DctrlVpParams*) cmdArgs);
788                 break;
789             case IOCTL_DSS_DCTRL_SET_OVERLAY_PARAMS:
790                 retVal = Dss_dctrlDrvSetOverlayParamsIoctl(
791                     instObj,
792                     (const Dss_DctrlOverlayParams*) cmdArgs);
793                 break;
794             case IOCTL_DSS_DCTRL_SET_LAYER_PARAMS:
795                 retVal = Dss_dctrlDrvSetLayerParamsIoctl(
796                     instObj,
797                     (const Dss_DctrlOverlayLayerParams*) cmdArgs);
798                 break;
799             case IOCTL_DSS_DCTRL_SET_VP_CSC_COEFF:
800                 retVal = Dss_dctrlDrvSetVpCscCoeffIoctl(
801                     instObj,
802                     (const Dss_DctrlVpCscCoeff*) cmdArgs);
803                 break;
804             case IOCTL_DSS_DCTRL_SET_ADV_VP_PARAMS:
805                 retVal = Dss_dctrlDrvSetAdvVpParamsIoctl(
806                     instObj,
807                     (const Dss_DctrlAdvVpParams*) cmdArgs);
808                 break;
809             case IOCTL_DSS_DCTRL_SET_LCD_BLANK_TIMING_PARAMS:
810                 retVal = Dss_dctrlDrvSetLcdBlankTimingIoctl(
811                     instObj,
812                     (const Dss_DctrlLcdBlankTimingParams*) cmdArgs);
813                 break;
814             case IOCTL_DSS_DCTRL_SET_VP_SAFETY_CHK_PARAMS:
815                 retVal = Dss_dctrlDrvSetVpSafetyChkParamsIoctl(
816                     instObj,
817                     (const Dss_DctrlVpSafetyChkParams*) cmdArgs);
818                 break;
819             case IOCTL_DSS_DCTRL_GET_VP_ERROR_STATS:
820                 retVal = Dss_dctrlDrvGetErrorStatsIoctl(
821                     instObj,
822                     (Dss_DctrlVpErrorStats*) cmdArgs);
823                 break;
824             case IOCTL_DSS_DCTRL_SET_GLOBAL_DSS_PARAMS:
825                 retVal = Dss_dctrlDrvSetGlobalDssParamsIoctl(
826                     instObj,
827                     (const Dss_DctrlGlobalDssParams*) cmdArgs);
828                 break;
829             case IOCTL_DSS_DCTRL_STOP_VP:
830                 retVal = Dss_dctrlDrvStopVpIoctl(
831                     instObj,
832                     (const Dss_DctrlVpParams*) cmdArgs);
833                 break;
834             case IOCTL_DSS_DCTRL_REGISTER_SYNCLOST_CB:
835                 retVal = Dss_dctrlDrvSetSyncLostCbParamsIoctl(
836                     instObj,
837                     (const Dss_DctrlSyncLostCbParams*) cmdArgs);
838                 break;
839             case IOCTL_DSS_DCTRL_REGISTER_LINENUM_CB:
840                 retVal = Dss_dctrlDrvSetLineNumCbParamsIoctl(
841                     instObj,
842                     (const Dss_DctrlLineNumCbParams*) cmdArgs);
843                 break;
844 #if defined (SOC_AM65XX)
845             case IOCTL_DSS_DCTRL_SET_OLDI_PARAMS:
846                 retVal = Dss_dctrlDrvSetOldiParamsIoctl(
847                     instObj,
848                     (const Dss_DctrlOldiParams*) cmdArgs);
849                 break;
850 #endif
851 #if defined (SOC_J721E)
852             case IOCTL_DSS_DCTRL_PROCESS_DP_HPD:
853                 retVal = Dss_dctrlDrvProcessDpHpdIoctl(
854                     instObj,
855                     (const uint32_t*) cmdArgs);
856                 break;
857             case IOCTL_DSS_DCTRL_REGISTER_DP_HPD_CB:
858                 retVal = Dss_dctrlDrvSetDpHpdCbParamsIoctl(
859                     instObj,
860                     (const Dss_DctrlDpHpdCbParams*) cmdArgs);
861                 break;
862             case IOCTL_DSS_DCTRL_SET_DSI_PARAMS:
863                 retVal = Dss_dctrlSetDsiParamsIoctl(
864                     instObj, (const Dss_DctrlDsiParams*) cmdArgs);
865                 break;
866 #endif
867             default:
868                 GT_0trace(DssTrace,
869                           GT_ERR,
870                           "UNSUPPORTED_CMD: IOCTL not supported\r\n");
871                 retVal = FVID2_EUNSUPPORTED_CMD;
872                 break;
873         }
874     }
876     return (retVal);
879 static int32_t Dss_dctrlDrvSetPathIoctl(Dss_DctrlDrvInstObj *instObj,
880                                         const Dss_DctrlPathInfo *pathInfo)
882     int32_t retVal = FVID2_SOK;
883     uint32_t i, j, k, moduleId, currPipeNum;
884     Fvid2_GraphEdgeInfo *currEdge, *vpEdge, *outEdge;
885     Dss_DctrlDrvPipeInfo *pPipeInfo;
887     /* Check for NULL pointers */
888     GT_assert(DssTrace, (NULL != instObj));
889     GT_assert(DssTrace, (NULL != pathInfo));
891     /* Take the instance semaphore */
892     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
894     gDss_DctrlDrvInfo.numValidPipes = 0;
896     if(0U != pathInfo->numEdges)
897     {
898         retVal = Dss_dctrlDrvCreateEdgeList(&gDss_DctrlDrvGraphObj,
899                                    pathInfo);
900     }
902     if((FVID2_SOK == retVal) && (0U != pathInfo->numEdges))
903     {
904         for(i=0U; i<gDss_DctrlDrvGraphObj.dctrlEdgeList.numEdges; i++)
905         {
906             currEdge = &gDss_DctrlDrvGraphObj.dctrlEdgeList.list[i];
908             if(TRUE == Dss_dctrlIsPipeNode(currEdge->startNode))
909             {
910                 /* Start graph construction from pipe */
911                 currPipeNum = gDss_DctrlDrvInfo.numValidPipes;
912                 pPipeInfo = &gDss_DctrlDrvInfo.pipeInfo[currPipeNum];
913                 GT_assert(DssTrace, (currPipeNum <= CSL_DSS_VID_PIPE_ID_MAX));
914                 pPipeInfo->pipeNodeId = currEdge->startNode;
915                 /* Get Pipe Id */
916                 retVal = Dss_convNodetoModule(currEdge->startNode, &moduleId);
917                 GT_assert(DssTrace,
918                           ((CSL_DSS_MODULE_INVALID != moduleId) ||
919                            (FVID2_SOK == retVal)));
920                 pPipeInfo->pipeId = moduleId;
921                 pPipeInfo->pipeState = DSS_DCTRL_PIPE_IDLE;
922                 /* Assign overlay node & overlay id */
923                 pPipeInfo->overlayNodeId = currEdge->endNode;
924                 retVal = Dss_convNodetoModule(currEdge->endNode, &moduleId);
925                 GT_assert(DssTrace,
926                           ((CSL_DSS_MODULE_INVALID != moduleId) ||
927                            (FVID2_SOK == retVal)));
928                 pPipeInfo->overlayId = moduleId;
929                 retVal = Dss_dctrlConnectNodes(pPipeInfo->pipeNodeId,
930                                                pPipeInfo->overlayNodeId);
931                 GT_assert(DssTrace, (FVID2_SOK == retVal));
933                 /* Find video port connected to overlay */
934                 for(j=0U; j<gDss_DctrlDrvGraphObj.dctrlEdgeList.numEdges; j++)
935                 {
936                     vpEdge = &gDss_DctrlDrvGraphObj.dctrlEdgeList.list[j];
937                     if(vpEdge->startNode == currEdge->endNode)
938                     {
939                         /* Assign video port node and video port id */
940                         pPipeInfo->vpNodeId = vpEdge->endNode;
941                         retVal = Dss_convNodetoModule(vpEdge->endNode,
942                                                       &moduleId);
943                         GT_assert(DssTrace,
944                                   ((CSL_DSS_MODULE_INVALID != moduleId) ||
945                                    (FVID2_SOK == retVal)));
946                         pPipeInfo->vpId = moduleId;
947                         retVal = Dss_dctrlConnectNodes(pPipeInfo->overlayNodeId,
948                                                        pPipeInfo->vpNodeId);
949                         GT_assert(DssTrace, (FVID2_SOK == retVal));
951                         /* Find output node connected to video port */
952                         for(k=0U; k<gDss_DctrlDrvGraphObj.dctrlEdgeList.numEdges; k++)
953                         {
954                             /* Assign output node */
955                             outEdge = &gDss_DctrlDrvGraphObj.dctrlEdgeList.list[k];
956                             if(outEdge->startNode == vpEdge->endNode)
957                             {
958                                 pPipeInfo->outNodeId = outEdge->endNode;
959                                 retVal = Dss_dctrlConnectNodes(
960                                                         pPipeInfo->vpNodeId,
961                                                         pPipeInfo->outNodeId);
962                                 GT_assert(DssTrace, (FVID2_SOK == retVal));
963                             }
964                         }
965                     }
966                 }
967                 gDss_DctrlDrvInfo.numValidPipes++;
968             }
969         }
970     }
972     if(FVID2_SOK != retVal)
973     {
974         GT_0trace(DssTrace, GT_ERR, "Set Path IOCTL failed\r\n");
975     }
977     /* Post the instance semaphore */
978     (void) SemaphoreP_post(instObj->lockSem);
980     return retVal;
983 static int32_t Dss_dctrlDrvClearPathIoctl(Dss_DctrlDrvInstObj *instObj,
984                                           const Dss_DctrlPathInfo *pathInfo)
986     int32_t retVal = FVID2_SOK;
988     /* Check for NULL pointers */
989     GT_assert(DssTrace, (NULL != instObj));
990     GT_assert(DssTrace, (NULL != pathInfo));
992     /* Take the instance semaphore */
993     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
995     Dss_dctrlDrvFreeEdgeList(&gDss_DctrlDrvGraphObj);
997     if(FVID2_SOK != retVal)
998     {
999         GT_0trace(DssTrace, GT_ERR, "Clear Path IOCTL failed\r\n");
1000     }
1002     /* Post the instance semaphore */
1003     (void) SemaphoreP_post(instObj->lockSem);
1005     return retVal;
1008 static int32_t Dss_dctrlDrvSetVpParamsIoctl(
1009                             Dss_DctrlDrvInstObj *instObj,
1010                             const Dss_DctrlVpParams *vpParams)
1012     int32_t retVal = FVID2_SOK;
1013     uint32_t i, vpId, syncVpId, vpFound = FALSE;
1014     CSL_dss_vpRegs *vpRegs;
1015     const Dss_SocInfo *socInfo;
1016     const CSL_DssVpLcdOpTimingCfg *lcdOpTimingCfg;
1017     const CSL_DssVpLcdSignalPolarityCfg *lcdPolarityCfg;
1018     const CSL_DssVpLcdTdmCfg *lcdTdmCfg;
1019     const Dss_DctrlSyncOpCfg *syncOpCfg;
1020     Dss_DctrlVpParams *pVpParams;
1021     Dss_DctrlDrvInfo *pDrvInfo;
1023     pDrvInfo = &gDss_DctrlDrvInfo;
1025     /* Check for NULL pointers */
1026     GT_assert(DssTrace, (NULL != instObj));
1027     GT_assert(DssTrace, (NULL != vpParams));
1029     /* Check for wrong inputs */
1030     if(vpParams->vpId >= CSL_DSS_VP_ID_MAX)
1031     {
1032         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1033         retVal = FVID2_EBADARGS;
1034     }
1036     /* Take the instance semaphore */
1037     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1039     if(FVID2_SOK == retVal)
1040     {
1041         /* Check if VP was already running */
1042         vpId = vpParams->vpId;
1043         for(i = 0U; i < CSL_DSS_VP_ID_MAX; i++)
1044         {
1045             if((gDss_DctrlDrvInfo.vpParams[i].vpId == vpId) &&
1046             (DSS_DCTRL_VP_IDLE != gDss_DctrlDrvInfo.vpState[vpId]))
1047             {
1048                 retVal = FVID2_EDEVICE_INUSE;
1049                 GT_0trace(DssTrace, GT_ERR, "VP is already in use!!\r\n");
1050                 break;
1051             }
1052         }
1053     }
1055 #if defined (SOC_J721E)
1056     if(FVID2_SOK == retVal)
1057     {
1058         Dss_DctrlDrvCommonObj *pObj;
1060         pObj = &gDss_DctrlDrvCommonObj;
1061         if ((TRUE == Dss_dctrlDrvIsOutputDSI(vpId)) &&
1062             (FALSE == pObj->drvInitParams.dsiInitParams.isAvailable))
1063         {
1064             retVal = FVID2_EINVALID_PARAMS;
1065             GT_0trace(DssTrace, GT_ERR, "DSI is not supported!!\r\n");
1066         }
1067     }
1068 #endif
1070     if(FVID2_SOK == retVal)
1071     {
1072         /* Assign input parameters */
1073         lcdOpTimingCfg = &vpParams->lcdOpTimingCfg;
1074         lcdPolarityCfg = &vpParams->lcdPolarityCfg;
1075         lcdTdmCfg = &vpParams->lcdTdmCfg;
1076         syncOpCfg = &vpParams->syncOpCfg;
1077         pVpParams = &gDss_DctrlDrvInfo.vpParams[vpId];
1079         pVpParams->syncOpCfg.enabled = syncOpCfg->enabled;
1080         pVpParams->syncOpCfg.isPrimary = syncOpCfg->isPrimary;
1081         pVpParams->syncOpCfg.numSyncVpIds = syncOpCfg->numSyncVpIds;
1082         for(i = 0; i < syncOpCfg->numSyncVpIds; i++)
1083         {
1084             pVpParams->syncOpCfg.syncVpIds[i] = syncOpCfg->syncVpIds[i];
1085         }
1087         pVpParams->lcdOpTimingCfg.mInfo.scanFormat =
1088                                             lcdOpTimingCfg->mInfo.scanFormat;
1089         pVpParams->lcdOpTimingCfg.mInfo.standard =
1090                                             lcdOpTimingCfg->mInfo.standard;
1091         pVpParams->lcdOpTimingCfg.mInfo.height =
1092                                             lcdOpTimingCfg->mInfo.height;
1093         pVpParams->lcdOpTimingCfg.mInfo.width =
1094                                             lcdOpTimingCfg->mInfo.width;
1095         pVpParams->vpId = vpId;
1096     }
1098     if((FVID2_SOK == retVal) &&
1099     (TRUE == vpParams->syncOpCfg.enabled) &&
1100     (TRUE == vpParams->syncOpCfg.isPrimary))
1101     {
1102         syncOpCfg = &vpParams->syncOpCfg;
1104         for(i = 0; i < syncOpCfg->numSyncVpIds; i++)
1105         {
1106             syncVpId = syncOpCfg->syncVpIds[i];
1108             if(DSS_DCTRL_VP_STARTING != pDrvInfo->vpState[syncVpId])
1109             {
1110                 vpFound = TRUE;
1111                 break;
1112             }
1113         }
1114         if(TRUE == vpFound)
1115         {
1116             retVal = FVID2_EBADARGS;
1117             GT_0trace(DssTrace, GT_ERR, "Secondary sync VPs not started!!\r\n");
1118         }
1119     }
1121     if(FVID2_SOK == retVal)
1122     {
1123         /* Get video port registers */
1124         socInfo = Dss_getSocInfo();
1125         vpRegs = socInfo->vpRegs[vpId];
1126         GT_assert(DssTrace, (NULL != vpRegs));
1128         /* Not safe to push */
1129         gDss_DctrlDrvInfo.isPushSafe[vpId] = FALSE;
1131         /* Call CSL APIs */
1132         CSL_dssVpSetLcdSignalPolarityConfig(vpRegs, lcdPolarityCfg);
1133         CSL_dssVpSetLcdTdmConfig(vpRegs, lcdTdmCfg);
1134         retVal = CSL_dssVpSetLcdOpTimingConfig(vpRegs, lcdOpTimingCfg);
1136         if(FVID2_SOK != retVal)
1137         {
1138             GT_assert(DssTrace, FALSE);
1139         }
1141         if(lcdOpTimingCfg->mInfo.height > 5U)
1142         {
1143             CSL_dssVpSetLcdLineNum(vpRegs, lcdOpTimingCfg->mInfo.height - 5U);
1144         }
1146 #if defined (SOC_J721E)
1147         if ((FVID2_SOK == retVal) &&
1148             (TRUE == Dss_dctrlDrvIsOutputDSI(vpId)))
1149         {
1150             retVal = Dss_dctrlDrvEnableVideoDSI(pDrvInfo, &lcdOpTimingCfg->mInfo,
1151                 lcdPolarityCfg->hsPolarity, lcdPolarityCfg->vsPolarity);
1152         }
1153 #endif
1155         Dss_dctrlVpEnable(vpId, TRUE);
1156     }
1158 #if defined (SOC_J721E)
1159     if((FVID2_SOK == retVal) &&
1160     (TRUE == Dss_dctrlDrvIsOutputDP(vpId)))
1161     {
1162         retVal = Dss_dctrlDrvEnableVideoDP(&lcdOpTimingCfg->mInfo,
1163                                lcdPolarityCfg->hsPolarity,
1164                        lcdPolarityCfg->vsPolarity);
1165     }
1166 #endif
1168     if(FVID2_SOK != retVal)
1169     {
1170         GT_0trace(DssTrace, GT_ERR, "Set VP parameters IOCTL failed\r\n");
1171     }
1173     /* Post the instance semaphore */
1174     (void) SemaphoreP_post(instObj->lockSem);
1176     return retVal;
1179 #if defined (SOC_J721E)
1180 static int32_t Dss_dctrlDrvProcessDpHpdIoctl(
1181                             Dss_DctrlDrvInstObj *instObj,
1182                             const uint32_t *dpProcessHpdParams)
1184     int32_t retVal = FVID2_SOK;
1185     uint32_t hpdState;
1187     /* Check for NULL pointers */
1188     GT_assert(DssTrace, (NULL != instObj));
1189     GT_assert(DssTrace, (NULL != dpProcessHpdParams));
1191     hpdState = *dpProcessHpdParams;
1193     if(FVID2_SOK == retVal)
1194     {
1195         retVal = Dss_dctrlDrvProcessHpdDp(hpdState);
1196     }
1198     return retVal;
1201 static int32_t Dss_dctrlDrvSetDpHpdCbParamsIoctl(
1202                             Dss_DctrlDrvInstObj *instObj,
1203                             const Dss_DctrlDpHpdCbParams *dpHpdCbParams)
1205     int32_t retVal = FVID2_SOK;
1207     /* Check for NULL pointers */
1208     GT_assert(DssTrace, (NULL != instObj));
1209     GT_assert(DssTrace, (NULL != dpHpdCbParams));
1211     if(FVID2_SOK == retVal)
1212     {
1213         retVal = Dss_dctrlDrvRegisterHpdCb(dpHpdCbParams);
1214     }
1216     if(FVID2_SOK != retVal)
1217     {
1218         GT_0trace(DssTrace,
1219                   GT_ERR,
1220                   "Register Display port HPD CB Params IOCTL failed\r\n");
1221     }
1223     return retVal;
1226 static uint32_t Dss_dctrlDrvIsOutputDP(uint32_t vpId)
1228     int32_t retVal;
1229     uint32_t i;
1230     uint32_t nodeId, vpFound = FALSE;
1231     Fvid2_GraphEdgeInfo *currEdge;
1233     retVal = Dss_convModuletoNode(&nodeId, vpId, DSS_DCTRL_NODE_TYPE_VP);
1234     GT_assert(DssTrace,
1235             ((DSS_DCTRL_NODE_INVALID != nodeId) ||
1236              (FVID2_SOK == retVal)));
1238     for(i=0U; i<gDss_DctrlDrvGraphObj.dctrlEdgeList.numEdges; i++)
1239     {
1240         currEdge = &gDss_DctrlDrvGraphObj.dctrlEdgeList.list[i];
1241         if((DSS_DCTRL_NODE_EDP_DPI0 == currEdge->endNode) &&
1242                 (nodeId == currEdge->startNode))
1243         {
1244             vpFound = TRUE;
1245             break;
1246         }
1247     }
1249     return vpFound;
1252 static uint32_t Dss_dctrlDrvIsOutputDSI(uint32_t vpId)
1254     int32_t retVal;
1255     uint32_t i;
1256     uint32_t nodeId, vpFound = FALSE;
1257     Fvid2_GraphEdgeInfo *currEdge;
1259     retVal = Dss_convModuletoNode(&nodeId, vpId, DSS_DCTRL_NODE_TYPE_VP);
1260     GT_assert(DssTrace,
1261             ((DSS_DCTRL_NODE_INVALID != nodeId) ||
1262              (FVID2_SOK == retVal)));
1264     for(i=0U; i<gDss_DctrlDrvGraphObj.dctrlEdgeList.numEdges; i++)
1265     {
1266         currEdge = &gDss_DctrlDrvGraphObj.dctrlEdgeList.list[i];
1267         if((DSS_DCTRL_NODE_DSI_DPI2 == currEdge->endNode) &&
1268                 (nodeId == currEdge->startNode))
1269         {
1270             vpFound = TRUE;
1271             break;
1272         }
1273     }
1275     return vpFound;
1277 #endif
1279 static int32_t Dss_dctrlDrvSetOverlayParamsIoctl(
1280                             Dss_DctrlDrvInstObj *instObj,
1281                             const Dss_DctrlOverlayParams *overlayParams)
1283     int32_t retVal = FVID2_SOK;
1284     uint32_t vpId, overlayId = overlayParams->overlayId;
1285     CSL_dss_overlayRegs *overlayRegs;
1286     const Dss_SocInfo *socInfo;
1287     const CSL_DssOverlayCfg *overlayCfg;
1289     /* Check for NULL pointers */
1290     GT_assert(DssTrace, (NULL != instObj));
1291     GT_assert(DssTrace, (NULL != overlayParams));
1293     /* Check for wrong inputs */
1294     if(overlayId >= CSL_DSS_OVERLAY_ID_MAX)
1295     {
1296         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1297         retVal = FVID2_EBADARGS;
1298     }
1300     /* Take the instance semaphore */
1301     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1303     if(FVID2_SOK == retVal)
1304     {
1305         /* Get overlay registers */
1306         socInfo = Dss_getSocInfo();
1307         overlayRegs = socInfo->overlayRegs[overlayId];
1308         GT_assert(DssTrace, (NULL != overlayRegs));
1310         /* Get video port registers */
1311         vpId = Dss_getVpConnId(overlayId);
1312         GT_assert(DssTrace, (CSL_DSS_MODULE_INVALID != vpId));
1314         /* Assign input parameters */
1315         overlayCfg = &overlayParams->overlayCfg;
1317         /* Call CSL APIs */
1318         if(FALSE == overlayParams->colorbarEnable)
1319         {
1320             CSL_dssOverlayColorBarEnable(overlayRegs, FALSE);
1321             CSL_dssOverlaySetConfig(overlayRegs, overlayCfg);
1322         }
1323         else
1324         {
1325             CSL_dssOverlayColorBarEnable(overlayRegs, TRUE);
1326             Dss_dctrlVpSetGoBit(vpId);
1327         }
1328     }
1330     if(FVID2_SOK != retVal)
1331     {
1332         GT_0trace(DssTrace, GT_ERR, "Set overlay parameters IOCTL failed\r\n");
1333     }
1335     /* Post the instance semaphore */
1336     (void) SemaphoreP_post(instObj->lockSem);
1338     return retVal;
1341 static int32_t Dss_dctrlDrvSetLayerParamsIoctl(
1342                             Dss_DctrlDrvInstObj *instObj,
1343                             const Dss_DctrlOverlayLayerParams *layerParams)
1345     int32_t retVal = FVID2_SOK;
1346     uint32_t i, overlayId = layerParams->overlayId;
1347     CSL_dss_overlayRegs *overlayRegs;
1348     const Dss_SocInfo *socInfo;
1349     CSL_DssOverlayLayerCfg layerCfg;
1351     /* Check for NULL pointers */
1352     GT_assert(DssTrace, (NULL != instObj));
1353     GT_assert(DssTrace, (NULL != layerParams));
1355     /* Check for wrong inputs */
1356     if(overlayId >= CSL_DSS_OVERLAY_ID_MAX)
1357     {
1358         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1359         retVal = FVID2_EBADARGS;
1360     }
1362     /* Take the instance semaphore */
1363     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1365     if(FVID2_SOK == retVal)
1366     {
1367         /* Initialize layer configuration */
1368         CSL_dssOverlayLayerCfgInit(&layerCfg);
1370         /* Get overlay registers */
1371         socInfo = Dss_getSocInfo();
1372         overlayRegs = socInfo->overlayRegs[overlayId];
1373         GT_assert(DssTrace, (NULL != overlayRegs));
1375         /* Call CSL APIs */
1376         for(i=0U; i<CSL_DSS_VID_PIPE_ID_MAX; i++)
1377         {
1378             if(CSL_DSS_OVERLAY_LAYER_INVALID != layerParams->pipeLayerNum[i])
1379             {
1380                 layerCfg.layerEnable = TRUE;
1381                 layerCfg.layerNum = layerParams->pipeLayerNum[i];
1382                 layerCfg.inputPipe = i;
1383                 CSL_dssOverlaySetLayerConfig(
1384                                     overlayRegs,
1385                                     (const CSL_DssOverlayLayerCfg *) &layerCfg);
1386             }
1387         }
1388     }
1390     if(FVID2_SOK != retVal)
1391     {
1392         GT_0trace(DssTrace, GT_ERR, "Set layer parameters IOCTL failed\r\n");
1393     }
1395     /* Post the instance semaphore */
1396     (void) SemaphoreP_post(instObj->lockSem);
1398     return retVal;
1401 static int32_t Dss_dctrlDrvSetVpCscCoeffIoctl(
1402                             Dss_DctrlDrvInstObj *instObj,
1403                             const Dss_DctrlVpCscCoeff *vpCscCoeff)
1405     int32_t retVal = FVID2_SOK;
1406     uint32_t cscPos, vpId;
1407     CSL_dss_vpRegs *vpRegs;
1408     const Dss_SocInfo *socInfo;
1409     const CSL_DssCscCoeff *cscCoeff;
1411     /* Check for NULL pointers */
1412     GT_assert(DssTrace, (NULL != instObj));
1413     GT_assert(DssTrace, (NULL != vpCscCoeff));
1415     /* Take the instance semaphore */
1416     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1418     /* Get video port registers */
1419     vpId = vpCscCoeff->vpId;
1420     socInfo = Dss_getSocInfo();
1421     vpRegs = socInfo->vpRegs[vpId];
1422     GT_assert(DssTrace, (NULL != vpRegs));
1424     /* Assign input parameters */
1425     cscPos = vpCscCoeff->cscPos;
1426     cscCoeff = &vpCscCoeff->cscCoeff;
1428     /* Call CSL API */
1429     if(FVID2_SOK == retVal)
1430     {
1431         CSL_dssVpSetCSCCoeff(vpRegs, cscCoeff, cscPos, TRUE);
1432     }
1434     if(FVID2_SOK != retVal)
1435     {
1436         GT_0trace(DssTrace, GT_ERR, "Set VP CSC coefficients IOCTL failed\r\n");
1437     }
1439     /* Post the instance semaphore */
1440     (void) SemaphoreP_post(instObj->lockSem);
1442     return retVal;
1445 static int32_t Dss_dctrlDrvSetAdvVpParamsIoctl(
1446                             Dss_DctrlDrvInstObj *instObj,
1447                             const Dss_DctrlAdvVpParams *advVpParams)
1449     int32_t retVal = FVID2_SOK;
1450     CSL_dss_vpRegs *vpRegs;
1451     const Dss_SocInfo *socInfo;
1452     const CSL_DssVpLcdAdvSignalCfg *lcdAdvSignalCfg;
1454     /* Check for NULL pointers */
1455     GT_assert(DssTrace, (NULL != instObj));
1456     GT_assert(DssTrace, (NULL != advVpParams));
1458     /* Check for wrong inputs */
1459     if(advVpParams->vpId >= CSL_DSS_VP_ID_MAX)
1460     {
1461         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1462         retVal = FVID2_EBADARGS;
1463     }
1465     /* Take the instance semaphore */
1466     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1468     if(FVID2_SOK == retVal)
1469     {
1470         /* Get video port registers */
1471         socInfo = Dss_getSocInfo();
1472         vpRegs = socInfo->vpRegs[advVpParams->vpId];
1473         GT_assert(DssTrace, (NULL != vpRegs));
1475         /* Assign input parameters */
1476         lcdAdvSignalCfg = &advVpParams->lcdAdvSignalCfg;
1478         /* Call CSL APIs */
1479         CSL_dssVpSetLcdAdvSignalConfig(vpRegs, lcdAdvSignalCfg);
1480     }
1482     if(FVID2_SOK != retVal)
1483     {
1484         GT_0trace(DssTrace,
1485                   GT_ERR,
1486                   "Set advance VP parameters IOCTL failed\r\n");
1487     }
1489     /* Post the instance semaphore */
1490     (void) SemaphoreP_post(instObj->lockSem);
1492     return retVal;
1495 static int32_t Dss_dctrlDrvSetLcdBlankTimingIoctl(
1496                             Dss_DctrlDrvInstObj *instObj,
1497                             const Dss_DctrlLcdBlankTimingParams *timingParams)
1499     int32_t retVal = FVID2_SOK;
1500     uint32_t vpId, scanFormat;
1501     CSL_dss_vpRegs *vpRegs;
1502     const Dss_SocInfo *socInfo;
1503     const CSL_DssVpLcdBlankTimingCfg *lcdBlankTimingCfg;
1505     /* Check for NULL pointers */
1506     GT_assert(DssTrace, (NULL != instObj));
1507     GT_assert(DssTrace, (NULL != timingParams));
1509     /* Check for wrong inputs */
1510     if(timingParams->vpId >= CSL_DSS_VP_ID_MAX)
1511     {
1512         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1513         retVal = FVID2_EBADARGS;
1514     }
1516     /* Take the instance semaphore */
1517     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1519     if(FVID2_SOK == retVal)
1520     {
1521         /* Assign input parameters */
1522         vpId = timingParams->vpId;
1523         lcdBlankTimingCfg = &timingParams->lcdBlankTimingCfg;
1525         /* Get scan format */
1526         scanFormat = gDss_DctrlDrvInfo.vpParams[vpId].lcdOpTimingCfg.mInfo.scanFormat;
1528         /* Get video port registers */
1529         socInfo = Dss_getSocInfo();
1530         vpRegs = socInfo->vpRegs[vpId];
1531         GT_assert(DssTrace, (NULL != vpRegs));
1533         /* Call CSL APIs */
1534         retVal = CSL_dssVpSetLcdBlankTiming(
1535                         vpRegs,
1536                         lcdBlankTimingCfg,
1537                         timingParams->dvoFormat,
1538                         scanFormat,
1539                         TRUE);
1540     }
1542     if(FVID2_SOK != retVal)
1543     {
1544         GT_0trace(DssTrace, GT_ERR, "Set LCD blank timing IOCTL failed\r\n");
1545     }
1547     /* Post the instance semaphore */
1548     (void) SemaphoreP_post(instObj->lockSem);
1550     return retVal;
1553 static int32_t Dss_dctrlDrvSetVpSafetyChkParamsIoctl(
1554                             Dss_DctrlDrvInstObj *instObj,
1555                             const Dss_DctrlVpSafetyChkParams *safetyChkParams)
1557     int32_t retVal = FVID2_SOK;
1558     uint32_t vpId, regionId, eventGroup, numHandle, evtMgrId, safetyEvt;
1559     Dss_DctrlDrvCommonObj *pObj;
1560     CSL_dss_vpRegs *vpRegs;
1561     const Dss_SocInfo *socInfo;
1562     const CSL_DssSafetyChkCfg *safetyChkCfg;
1564     /* Check for NULL pointers */
1565     GT_assert(DssTrace, (NULL != instObj));
1566     GT_assert(DssTrace, (NULL != safetyChkParams));
1568     /* Assign inputs */
1569     pObj = &gDss_DctrlDrvCommonObj;
1570     vpId = safetyChkParams->vpId;
1571     regionId = safetyChkParams->regionSafetyChkCfg.regionId;
1572     /* Check for wrong inputs */
1573     if((vpId >= CSL_DSS_VP_ID_MAX)||(regionId >= CSL_DSS_VP_SAFETY_REGION_MAX))
1574     {
1575         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1576         retVal = FVID2_EBADARGS;
1577     }
1578     else
1579     {
1580         /* Get video port registers */
1581         socInfo = Dss_getSocInfo();
1582         vpRegs = socInfo->vpRegs[vpId];
1583         GT_assert(DssTrace, (NULL != vpRegs));
1584     }
1586     /* Take the instance semaphore */
1587     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1589     if(FVID2_SOK == retVal)
1590     {
1591         Fvid2Utils_memcpy(
1592                     &gDss_DctrlDrvInfo.safetyChkParams[regionId][vpId],
1593                     safetyChkParams,
1594                     sizeof (Dss_DctrlVpSafetyChkParams));
1596         /* Register for Safety Error Events */
1597         Dss_convModuletoEventGroup(&eventGroup,
1598                                    vpId,
1599                                    DSS_EVENT_GROUP_TYPE_VP);
1600         GT_assert(DssTrace, (DSS_EVENT_GROUP_INVALID != eventGroup));
1601         numHandle = pObj->instObj->numRegEvtHandle;
1602         evtMgrId = Dss_getEvtMgrSafetyIntrId();
1603         safetyEvt = Dss_dctrlGetVpSafetyEvtId(regionId);
1604         GT_assert(DssTrace, (DSS_VP_EVENT_INVALID != safetyEvt));
1605         pObj->instObj->evtGroupHandle[pObj->instObj->numRegEvtHandle] =
1606                             Dss_evtMgrRegister(
1607                                 evtMgrId,
1608                                 eventGroup,
1609                                 (const uint32_t *)(&safetyEvt),
1610                                 1U,
1611                                 Dss_dctrlSafetyErrCbFxn,
1612                                 (void *)&gDss_DctrlEvtMgrClientInfo[numHandle]);
1613         pObj->instObj->numRegEvtHandle++;
1615         /* Call CSL APIs */
1616         if(0U != safetyChkParams->safetySignSeedVal)
1617         {
1618             CSL_dssVpSetSafetySignSeedVal(vpRegs,
1619                                           safetyChkParams->safetySignSeedVal);
1620         }
1621         if(CSL_DSS_SAFETY_CHK_DATA_INTEGRITY ==
1622                 safetyChkParams->regionSafetyChkCfg.safetyChkCfg.safetyChkMode)
1623         {
1624             CSL_dssVpSetSafetyReferenceSign(
1625                             vpRegs,
1626                             safetyChkParams->regionSafetyChkCfg.referenceSign,
1627                             regionId);
1628         }
1629         safetyChkCfg = &safetyChkParams->regionSafetyChkCfg.safetyChkCfg;
1630         CSL_dssVpSetSafetyChkConfig(vpRegs, safetyChkCfg, regionId);
1631     }
1633     if(FVID2_SOK != retVal)
1634     {
1635         GT_0trace(DssTrace,
1636                   GT_ERR,
1637                   "Register Safety Error Cb Params IOCTL failed\r\n");
1638     }
1640     /* Post the instance semaphore */
1641     (void) SemaphoreP_post(instObj->lockSem);
1643     return retVal;
1646 static int32_t Dss_dctrlDrvGetErrorStatsIoctl(
1647                             Dss_DctrlDrvInstObj *instObj,
1648                             Dss_DctrlVpErrorStats *vpErrStats)
1650     int32_t retVal = FVID2_SOK;
1651     uint32_t i, vpFound = FALSE;
1653     /* Check for NULL pointers */
1654     GT_assert(DssTrace, (NULL != instObj));
1655     GT_assert(DssTrace, (NULL != vpErrStats));
1657     /* Check for wrong inputs */
1658     if(vpErrStats->vpId >= CSL_DSS_VP_ID_MAX)
1659     {
1660         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1661         retVal = FVID2_EBADARGS;
1662     }
1664     /* Take the instance semaphore */
1665     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1667     if(FVID2_SOK == retVal)
1668     {
1669         /* Check if Video Port is valid */
1670         for(i=0U; i<CSL_DSS_VP_ID_MAX; i++)
1671         {
1672             if(gDss_DctrlDrvInfo.vpParams[i].vpId == vpErrStats->vpId)
1673             {
1674                 vpFound = TRUE;
1675                 break;
1676             }
1677         }
1679         if(TRUE == vpFound)
1680         {
1681             retVal = FVID2_SOK;
1682             vpErrStats->syncLost =
1683                     gDss_DctrlDrvInfo.errorCnt.vpsyncLost[vpErrStats->vpId];
1684             for(i=0U; i<CSL_DSS_VP_SAFETY_REGION_MAX; i++)
1685             {
1686                 vpErrStats->safetyViolation[i] =
1687                     gDss_DctrlDrvInfo.errorCnt.vpSafetyViolation[i][vpErrStats->vpId];
1688             }
1690             vpErrStats->securityViolation =
1691                     gDss_DctrlDrvInfo.errorCnt.vpSecurityViolation[vpErrStats->vpId];
1692         }
1693     }
1695     if(FVID2_SOK != retVal)
1696     {
1697         GT_0trace(DssTrace, GT_ERR, "GET VP error stat IOCTL failed\r\n");
1698     }
1700     /* Post the instance semaphore */
1701     (void) SemaphoreP_post(instObj->lockSem);
1703     return retVal;
1706 static int32_t Dss_dctrlDrvSetGlobalDssParamsIoctl(
1707                             Dss_DctrlDrvInstObj *instObj,
1708                             const Dss_DctrlGlobalDssParams *globalDssParams)
1710     int32_t retVal = FVID2_SOK;
1711     CSL_dss_commRegs *commRegs;
1712     const Dss_SocInfo *socInfo;
1713     const CSL_DssGlobalMFlagCfg *globalMflagCfg;
1714     const CSL_DssCbaCfg *cbaCfg;
1716     /* Check for NULL pointers */
1717     GT_assert(DssTrace, (NULL != instObj));
1718     GT_assert(DssTrace, (NULL != globalDssParams));
1720     /* Take the instance semaphore */
1721     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1723     /* Get common registers */
1724     socInfo = Dss_getSocInfo();
1725     commRegs = socInfo->commRegs[CSL_DSS_COMM_REG_ID_0];
1726     GT_assert(DssTrace, (NULL != commRegs));
1728     /* Assign input parameters */
1729     globalMflagCfg = &globalDssParams->globalMflagCfg;
1730     cbaCfg = &globalDssParams->cbaCfg;
1732     /* Call CSL APIs */
1733     if(FVID2_SOK == retVal)
1734     {
1735         CSL_dssSetGlobalMflagConfig(commRegs, globalMflagCfg);
1736         CSL_dssSetCbaConfig(commRegs, cbaCfg);
1737     }
1739     if(FVID2_SOK != retVal)
1740     {
1741         GT_0trace(DssTrace, GT_ERR, "Set global parameters IOCTL failed\r\n");
1742     }
1744     /* Post the instance semaphore */
1745     (void) SemaphoreP_post(instObj->lockSem);
1747     return retVal;
1750 #if defined (SOC_AM65XX)
1751 static int32_t Dss_dctrlDrvSetOldiParamsIoctl(
1752                             Dss_DctrlDrvInstObj *instObj,
1753                             const Dss_DctrlOldiParams *oldiParams)
1755     int32_t retVal = FVID2_SOK;
1756     uint32_t resetOldi = FALSE;
1757     CSL_dss_commRegs *commRegs;
1758     CSL_dss_vpRegs *vpRegs;
1759     const Dss_SocInfo *socInfo;
1760     const CSL_DssVpOldiCfg *oldiCfg;
1762     /* Check for NULL pointers */
1763     GT_assert(DssTrace, (NULL != instObj));
1764     GT_assert(DssTrace, (NULL != oldiParams));
1766     /* Take the instance semaphore */
1767     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1769     /* Get video port registers */
1770     socInfo = Dss_getSocInfo();
1771     vpRegs = socInfo->vpRegs[oldiParams->vpId];
1772     GT_assert(DssTrace, (NULL != vpRegs));
1774     /* Get common registers */
1775     commRegs = socInfo->commRegs[CSL_DSS_COMM_REG_ID_0];
1776     GT_assert(DssTrace, (NULL != commRegs));
1778     /* Assign input parameters */
1779     oldiCfg = &oldiParams->oldiCfg;
1781     /* Call CSL APIs */
1782     CSL_dssVpOldiReset(vpRegs);
1783     do
1784     {
1785         resetOldi = CSL_dssIsOldiResetDone(commRegs);
1786     } while (TRUE != resetOldi);
1788     CSL_dssVpSetOldiConfig(vpRegs, oldiCfg);
1789     CSL_dssVpOldiEnable(vpRegs, TRUE);
1791     if(FVID2_SOK != retVal)
1792     {
1793         GT_0trace(DssTrace, GT_ERR, "Set OLDI parameters IOCTL failed\r\n");
1794     }
1796     /* Post the instance semaphore */
1797     (void) SemaphoreP_post(instObj->lockSem);
1799     return retVal;
1801 #endif
1803 static int32_t Dss_dctrlDrvStopVpIoctl(Dss_DctrlDrvInstObj *instObj,
1804                                        const Dss_DctrlVpParams *vpParams)
1806     int32_t retVal = FVID2_SOK;
1807     uint32_t i, vpId, syncVpId;
1808     uint32_t vpFound = FALSE;
1809     uint32_t cookie;
1810     Dss_DctrlVpParams *sVpParams = NULL;
1812     /* Check for NULL pointers */
1813     GT_assert(DssTrace, (NULL != instObj));
1814     GT_assert(DssTrace, (NULL != vpParams));
1815     GT_assert(DssTrace, (vpParams->vpId < CSL_DSS_VP_ID_MAX));
1817     vpId = vpParams->vpId;
1818     sVpParams = &gDss_DctrlDrvInfo.vpParams[vpId];
1820     /* Check for wrong inputs */
1821     if(vpParams->vpId >= CSL_DSS_VP_ID_MAX)
1822     {
1823         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1824         retVal = FVID2_EBADARGS;
1825     }
1827     /* Take the instance semaphore */
1828     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1830     if(FVID2_SOK == retVal)
1831     {
1832         if((DSS_DCTRL_VP_RUNNING != gDss_DctrlDrvInfo.vpState[vpId]) &&
1833         (DSS_DCTRL_VP_STARTING != gDss_DctrlDrvInfo.vpState[vpId]))
1834         {
1835             GT_0trace(DssTrace, GT_ERR, "VP not started!!\r\n");
1836             retVal = FVID2_EBADARGS;
1837         }
1838     }
1840     if((FVID2_SOK == retVal) &&
1841     (TRUE == sVpParams->syncOpCfg.enabled) &&
1842     (TRUE == sVpParams->syncOpCfg.isPrimary))
1843     {
1844         for(i = 0; i < sVpParams->syncOpCfg.numSyncVpIds; i++)
1845         {
1846             syncVpId = sVpParams->syncOpCfg.syncVpIds[i];
1848             if(DSS_DCTRL_VP_STOPPING != gDss_DctrlDrvInfo.vpState[syncVpId])
1849             {
1850                 vpFound = TRUE;
1851             }
1852         }
1854         if(TRUE == vpFound)
1855         {
1856             GT_0trace(DssTrace, GT_ERR, "Secondary sync VPs not stopped!!\r\n");
1857             retVal = FVID2_EBADARGS;
1858         }
1859     }
1861 #if defined (SOC_J721E)
1862     if((FVID2_SOK == retVal) && (TRUE == Dss_dctrlDrvIsOutputDP(vpId)))
1863     {
1864         retVal = Dss_dctrlDrvDisableVideoDP();
1865     }
1866 #endif
1868     if(FVID2_SOK == retVal)
1869     {
1870         cookie = HwiP_disable();
1871         Dss_dctrlVpEnable(vpId, FALSE);
1872         HwiP_restore(cookie);
1874         Dss_dctrlVpReset(vpId);
1876         if((TRUE == sVpParams->syncOpCfg.enabled) &&
1877         (TRUE == sVpParams->syncOpCfg.isPrimary))
1878         {
1879             for(i = 0; i < sVpParams->syncOpCfg.numSyncVpIds; i++)
1880             {
1881                 syncVpId = sVpParams->syncOpCfg.syncVpIds[i];
1882                 Dss_dctrlVpReset(syncVpId);
1883             }
1884         }
1885     }
1887     if(FVID2_SOK != retVal)
1888     {
1889         GT_0trace(DssTrace, GT_ERR, "Stop VP IOCTL failed\r\n");
1890     }
1892     /* Post the instance semaphore */
1893     (void) SemaphoreP_post(instObj->lockSem);
1895     return retVal;
1898 static int32_t Dss_dctrlDrvSetSyncLostCbParamsIoctl(
1899                             Dss_DctrlDrvInstObj *instObj,
1900                             const Dss_DctrlSyncLostCbParams *syncLostCbParams)
1902     int32_t retVal = FVID2_SOK;
1903     uint32_t vpId;
1905     /* Check for NULL pointers */
1906     GT_assert(DssTrace, (NULL != instObj));
1907     GT_assert(DssTrace, (NULL != syncLostCbParams));
1909     /* Check for wrong inputs */
1910     if(syncLostCbParams->vpId >= CSL_DSS_VP_ID_MAX)
1911     {
1912         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1913         retVal = FVID2_EBADARGS;
1914     }
1916     /* Take the instance semaphore */
1917     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1919     if(FVID2_SOK == retVal)
1920     {
1921         vpId = syncLostCbParams->vpId;
1922         Fvid2Utils_memcpy(&gDss_DctrlDrvInfo.syncLostCbParams[vpId],
1923                           syncLostCbParams,
1924                           sizeof (Dss_DctrlSyncLostCbParams));
1925     }
1927     if(FVID2_SOK != retVal)
1928     {
1929         GT_0trace(DssTrace,
1930                   GT_ERR,
1931                   "Register Sync Lost Cb Params IOCTL failed\r\n");
1932     }
1934     /* Post the instance semaphore */
1935     (void) SemaphoreP_post(instObj->lockSem);
1937     return retVal;
1940 static int32_t Dss_dctrlDrvSetLineNumCbParamsIoctl(
1941                             Dss_DctrlDrvInstObj *instObj,
1942                             const Dss_DctrlLineNumCbParams *lineNumCbParams)
1944     int32_t retVal = FVID2_SOK;
1945     uint32_t vpId = lineNumCbParams->vpId;
1947     /* Check for NULL pointers */
1948     GT_assert(DssTrace, (NULL != instObj));
1949     GT_assert(DssTrace, (NULL != lineNumCbParams));
1951     /* Check for wrong inputs */
1952     if(vpId >= CSL_DSS_VP_ID_MAX)
1953     {
1954         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
1955         retVal = FVID2_EBADARGS;
1956     }
1958     /* Take the instance semaphore */
1959     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
1961     if(FVID2_SOK == retVal)
1962     {
1963         Fvid2Utils_memcpy(&gDss_DctrlDrvInfo.lineNumCbParams[vpId],
1964                           lineNumCbParams,
1965                           sizeof (Dss_DctrlLineNumCbParams));
1966     }
1968     if(FVID2_SOK != retVal)
1969     {
1970         GT_0trace(DssTrace,
1971                   GT_ERR,
1972                   "Register Line Num Cb Params IOCTL failed\r\n");
1973     }
1975     /* Post the instance semaphore */
1976     (void) SemaphoreP_post(instObj->lockSem);
1978     return retVal;
1981 static void Dss_dctrlFuncCbFxn(const uint32_t *event,
1982                                uint32_t numEvents,
1983                                void *arg)
1985     uint32_t  i, j, currEvent, vpId = 0U, activePipeNum;
1986     Dss_EvtMgrClientInfo *pClientObj = (Dss_EvtMgrClientInfo *)arg;
1988     GT_assert(DssTrace,
1989               (gDss_DctrlDrvInfo.numValidPipes <= CSL_DSS_VID_PIPE_ID_MAX));
1991     uint32_t eventGroup = pClientObj->eventGroup;
1992     Dss_convEventGrouptoModule(eventGroup, &vpId);
1993     GT_assert(DssTrace, (CSL_DSS_MODULE_INVALID != vpId));
1995     for(i=0U; i<numEvents; i++)
1996     {
1997         currEvent = event[i];
1998         if(DSS_VP_EVENT_LINE_NUM == currEvent)
1999         {
2000             gDss_DctrlDrvInfo.isPushSafe[vpId] = FALSE;
2001             if(NULL != gDss_DctrlDrvInfo.lineNumCbParams[vpId].lineNumCbFxn)
2002             {
2003                 gDss_DctrlDrvInfo.lineNumCbParams[vpId].lineNumCbFxn(
2004                             vpId,
2005                             gDss_DctrlDrvInfo.lineNumCbParams[vpId].appData);
2006             }
2007         }
2008         else if(DSS_VP_EVENT_VSYNC == currEvent)
2009         {
2010             /* Post crate sync semaphore */
2011             if(NULL != gDssStartSyncSem)
2012             {
2013                 /* Post the instance semaphore */
2014                 (void) SemaphoreP_post(gDssStartSyncSem);
2015             }
2016             activePipeNum = 0U;
2017             for(j=0U; j<gDss_DctrlDrvInfo.numValidPipes; j++)
2018             {
2019                 if(gDss_DctrlDrvInfo.pipeInfo[j].vpId == vpId)
2020                 {
2021                     if((gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2022                                                 DSS_DCTRL_PIPE_STARTING)     ||
2023                        (gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2024                                                 DSS_DCTRL_PIPE_STARTED)      ||
2025                        (gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2026                                                 DSS_DCTRL_PIPE_RUNNING)      ||
2027                        (gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2028                                                 DSS_DCTRL_PIPE_STOPPING))
2029                     {
2030                         activePipeNum++;
2031                         if(gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2032                                                     DSS_DCTRL_PIPE_STARTING)
2033                         {
2034                             /* This is the first VSync for dummy start i.e.
2035                              * either start is synchronous or start was called
2036                              * close to VSYNC */
2037                             gDss_DctrlDrvInfo.pipeInfo[j].pipeState =
2038                                                         DSS_DCTRL_PIPE_STARTED;
2039                         }
2040                         if(gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2041                                                     DSS_DCTRL_PIPE_STARTED)
2042                         {
2043                             /* This is the first actual VSync where the buffer
2044                              * B1's display has started */
2045                             gDss_DctrlDrvInfo.pipeInfo[j].pipeState =
2046                                                         DSS_DCTRL_PIPE_RUNNING;
2047                         }
2048                         if(gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2049                                                     DSS_DCTRL_PIPE_STOPPING)
2050                         {
2051                             /* This is the VSYNC before synchronous stop */
2052                             gDss_DctrlDrvInfo.pipeInfo[j].pipeState =
2053                                                         DSS_DCTRL_PIPE_STOPPED;
2054                         }
2055                         gDss_DctrlDrvInfo.isPushSafe[vpId] = TRUE;
2056                         GT_assert(DssTrace,
2057                                   (NULL !=
2058                                    gDss_DctrlDrvInfo.pipeInfo[j].gClientInfo.cbFxn));
2059                         gDss_DctrlDrvInfo.pipeInfo[j].gClientInfo.cbFxn(
2060                             gDss_DctrlDrvInfo.pipeInfo[j].gClientInfo.arg);
2061                     }
2062                     else if(gDss_DctrlDrvInfo.pipeInfo[j].pipeState ==
2063                                                     DSS_DCTRL_PIPE_STOPPED)
2064                     {
2065                         /* This is the actual stop */
2066                         gDss_DctrlDrvInfo.pipeInfo[j].pipeState =
2067                                                         DSS_DCTRL_PIPE_OPENED;
2068                         (void) SemaphoreP_post(gDss_DctrlDrvInfo.pipeInfo[j].stopSem);
2069                     }
2070                     else {
2071                         /* To fix MISRAC issue - this is a valid else - do nothing */
2072                     }
2073                 }
2074             }
2076             if(activePipeNum > 0U)
2077             {
2078                 Dss_dctrlVpSetGoBit(vpId);
2079             }
2080         }
2081         else
2082         {
2083             GT_assert(DssTrace, FALSE);
2084         }
2085     }
2087     return;
2090 static void Dss_dctrlErrCbFxn(const uint32_t *event,
2091                               uint32_t numEvents,
2092                               void *arg)
2094     uint32_t  i, currEvent, vpId = 0U;
2095     Dss_EvtMgrClientInfo *pClientObj = (Dss_EvtMgrClientInfo *)arg;
2096     uint32_t eventGroup = pClientObj->eventGroup;
2097     Dss_DctrlDrvErrorCount *pErrorCnt;
2099     pErrorCnt = &gDss_DctrlDrvInfo.errorCnt;
2100     Dss_convEventGrouptoModule(eventGroup, &vpId);
2101     GT_assert(DssTrace, (CSL_DSS_MODULE_INVALID != vpId));
2103     for(i=0U; i<numEvents; i++)
2104     {
2105         currEvent = event[i];
2106         if(DSS_VP_EVENT_SYNC_LOST == currEvent)
2107         {
2108            pErrorCnt->vpsyncLost[vpId]++;
2109            if(NULL != gDss_DctrlDrvInfo.syncLostCbParams[vpId].syncLostCbFxn)
2110            {
2111                gDss_DctrlDrvInfo.syncLostCbParams[vpId].syncLostCbFxn(
2112                             vpId,
2113                             gDss_DctrlDrvInfo.syncLostCbParams[vpId].appData);
2114            }
2115         }
2116         else
2117         {
2118             GT_assert(DssTrace, FALSE);
2119         }
2120     }
2122     return;
2125 static void Dss_dctrlSafetyErrCbFxn(const uint32_t *event,
2126                                     uint32_t numEvents,
2127                                     void *arg)
2129     uint32_t  i, currEvent, vpId = 0U, regionId;
2130     Dss_EvtMgrClientInfo *pClientObj = (Dss_EvtMgrClientInfo *)arg;
2131     uint32_t eventGroup = pClientObj->eventGroup;
2132     Dss_DctrlDrvErrorCount *pErrorCnt;
2133     Dss_DctrlVpSafetyChkParams *pSafetyChkParams;
2134     CSL_dss_vpRegs *vpRegs;
2135     const Dss_SocInfo *socInfo;
2137     pErrorCnt = &gDss_DctrlDrvInfo.errorCnt;
2138     Dss_convEventGrouptoModule(eventGroup, &vpId);
2139     GT_assert(DssTrace, (CSL_DSS_MODULE_INVALID != vpId));
2141     /* Get video port registers */
2142     socInfo = Dss_getSocInfo();
2143     vpRegs = socInfo->vpRegs[vpId];
2144     GT_assert(DssTrace, (NULL != vpRegs));
2146     for(i=0U; i<numEvents; i++)
2147     {
2148         currEvent = event[i];
2149         if(TRUE == Dss_dctrlIsSafetyEvent(currEvent))
2150         {
2151             regionId = Dss_dctrlGetVpSafetyRegionId(currEvent);
2152             GT_assert(DssTrace, (CSL_DSS_VP_SAFETY_REGION_INVALID != regionId));
2153             pErrorCnt->vpSafetyViolation[regionId][vpId]++;
2154             pSafetyChkParams = &gDss_DctrlDrvInfo.safetyChkParams[regionId][vpId];
2155             pSafetyChkParams->safetyCbData.regionId = regionId;
2156             if(CSL_DSS_SAFETY_CHK_DATA_INTEGRITY ==
2157                 pSafetyChkParams->regionSafetyChkCfg.safetyChkCfg.safetyChkMode)
2158             {
2159                 pSafetyChkParams->safetyCbData.capturedSign =
2160                                     CSL_dssVpGetSafetySign(vpRegs, regionId);
2161             }
2163             if(NULL != pSafetyChkParams->safetyErrCbFxn)
2164             {
2165                 pSafetyChkParams->safetyErrCbFxn(vpId,
2166                                                  pSafetyChkParams->safetyCbData,
2167                                                  pSafetyChkParams->appData);
2168             }
2169         }
2170         else
2171         {
2172             GT_assert(DssTrace, FALSE);
2173         }
2174     }
2176     return;
2179 static int32_t Dss_dctrlConnectNodes(uint32_t inputNode, uint32_t outNode)
2181     int32_t retVal = FVID2_SOK;
2183     if((FALSE == Dss_dctrlIsValidNode(inputNode)) ||
2184        (FALSE == Dss_dctrlIsValidNode(outNode)))
2185     {
2186         retVal = FVID2_EBADARGS;
2187     }
2189     if(TRUE == Dss_dctrlIsVideoMuxNeeded(inputNode, outNode))
2190     {
2191         retVal = Dss_dctrlProgramVideoMux(inputNode,
2192                                           outNode);
2193         GT_assert(DssTrace, (FVID2_SOK == retVal));
2194     }
2196     return (retVal);
2199 static void Dss_dctrlVpSetGoBit(uint32_t vpId)
2201     CSL_dss_vpRegs *vpRegs;
2202     CSL_dss_commRegs *commRegs;
2203     const Dss_SocInfo *socInfo;
2204     const Dss_DctrlVpParams *vpParams;
2205     uint32_t syncVpId;
2206     uint32_t vpMask;
2207     uint32_t i;
2209     socInfo = Dss_getSocInfo();
2211     /* Get video port registers */
2212     vpRegs = socInfo->vpRegs[vpId];
2213     GT_assert(DssTrace, (NULL != vpRegs));
2215     /* Get DSS common_m / common_0 registers */
2216     /* XXX if common_0/m is not enabled in rmInfo? */
2217     commRegs = socInfo->commRegs[0U];
2218     GT_assert(DssTrace, (NULL != commRegs));
2220     vpParams = &gDss_DctrlDrvInfo.vpParams[vpId];
2222     if(TRUE == vpParams->syncOpCfg.enabled)
2223     {
2224         if(TRUE == vpParams->syncOpCfg.isPrimary)
2225         {
2226             vpMask = (uint32_t)(1U << vpId);
2227             for(i = 0U; i < vpParams->syncOpCfg.numSyncVpIds; i++)
2228             {
2229                 syncVpId = vpParams->syncOpCfg.syncVpIds[i];
2230                 vpMask |= (uint32_t)(1U << syncVpId);
2231             }
2233             CSL_dssGlobalVpGoBitEnable(commRegs, vpMask);
2234         }
2235     }
2236     else
2237     {
2238         CSL_dssVpSetGoBit(vpRegs);
2239     }
2242 static void Dss_dctrlVpReset(uint32_t vpId)
2244     CSL_dss_vpRegs *vpRegs;
2245     const Dss_SocInfo *socInfo;
2246     CSL_DssVpLcdSignalPolarityCfg lcdPolarityCfg;
2247     CSL_DssVpLcdOpTimingCfg lcdOpTimingCfg;
2248     CSL_DssVpLcdTdmCfg lcdTdmCfg;
2250     socInfo = Dss_getSocInfo();
2252     /* Get video port registers */
2253     vpRegs = socInfo->vpRegs[vpId];
2254     GT_assert(DssTrace, (NULL != vpRegs));
2256     CSL_dssVpLcdTdmCfgInit(&lcdTdmCfg);
2257     CSL_dssVpLcdSignalPolarityCfgInit(&lcdPolarityCfg);
2258     CSL_dssVpLcdOpTimingCfgInit(&lcdOpTimingCfg);
2260     CSL_dssVpSetLcdSignalPolarityConfig(
2261         vpRegs,
2262         (const CSL_DssVpLcdSignalPolarityCfg *)(&lcdPolarityCfg));
2263     CSL_dssVpSetLcdTdmConfig(
2264         vpRegs,
2265         (const CSL_DssVpLcdTdmCfg *)(&lcdTdmCfg));
2267     /* There is no point in checking the result here. We are resetting */
2268     (void) CSL_dssVpSetLcdOpTimingConfig(vpRegs, &lcdOpTimingCfg);
2271 static void Dss_dctrlVpEnable(uint32_t vpId, uint32_t enable)
2273     CSL_dss_vpRegs *vpRegs;
2274     CSL_dss_commRegs *commRegs;
2275     const Dss_SocInfo *socInfo;
2276     const Dss_DctrlVpParams *vpParams;
2277     uint32_t syncVpId;
2278     uint32_t vpMask;
2279     uint32_t i;
2281     socInfo = Dss_getSocInfo();
2283     /* Get video port registers */
2284     vpRegs = socInfo->vpRegs[vpId];
2285     GT_assert(DssTrace, (NULL != vpRegs));
2287     /* Get DSS common_m / common_0 registers */
2288     /* XXX if common_0/m is not enabled in rmInfo? */
2289     commRegs = socInfo->commRegs[0U];
2290     GT_assert(DssTrace, (NULL != commRegs));
2292     vpParams = &gDss_DctrlDrvInfo.vpParams[vpId];
2294     if(TRUE == vpParams->syncOpCfg.enabled)
2295     {
2296         if(TRUE == vpParams->syncOpCfg.isPrimary)
2297         {
2298             vpMask = (uint32_t)(1U << vpId);
2299             for(i = 0U; i < vpParams->syncOpCfg.numSyncVpIds; i++)
2300             {
2301                 syncVpId = vpParams->syncOpCfg.syncVpIds[i];
2302                 vpMask |= (uint32_t)(1U << syncVpId);
2303             }
2305             CSL_dssGlobalVpEnable(commRegs, vpMask, enable);
2307             if(TRUE == enable)
2308             {
2309                 gDss_DctrlDrvInfo.vpState[vpId] = DSS_DCTRL_VP_RUNNING;
2310             }
2311             else
2312             {
2313                 gDss_DctrlDrvInfo.vpState[vpId] = DSS_DCTRL_VP_IDLE;
2314             }
2316             for(i = 0U; i < vpParams->syncOpCfg.numSyncVpIds; i++)
2317             {
2318                 syncVpId = vpParams->syncOpCfg.syncVpIds[i];
2319                 if(TRUE == enable)
2320                 {
2321                     gDss_DctrlDrvInfo.vpState[syncVpId] = DSS_DCTRL_VP_RUNNING;
2322                 }
2323                 else
2324                 {
2325                     gDss_DctrlDrvInfo.vpState[syncVpId] = DSS_DCTRL_VP_IDLE;
2326                 }
2327             }
2328         }
2329         else
2330         {
2331             if(TRUE == enable)
2332             {
2333                 gDss_DctrlDrvInfo.vpState[vpId] = DSS_DCTRL_VP_STARTING;
2334             }
2335             else
2336             {
2337                 gDss_DctrlDrvInfo.vpState[vpId] = DSS_DCTRL_VP_STOPPING;
2338             }
2339         }
2340     }
2341     else
2342     {
2343         CSL_dssVpEnable(vpRegs, enable);
2344         if(TRUE == enable)
2345         {
2346             gDss_DctrlDrvInfo.vpState[vpId] = DSS_DCTRL_VP_RUNNING;
2347         }
2348         else
2349         {
2350             gDss_DctrlDrvInfo.vpState[vpId] = DSS_DCTRL_VP_IDLE;
2351         }
2352     }
2355 #if defined (SOC_J721E)
2356 static int32_t Dss_dctrlSetDsiParamsIoctl(Dss_DctrlDrvInstObj *instObj,
2357                                           const Dss_DctrlDsiParams *dsiPrms)
2359     int32_t retVal = FVID2_SOK;
2361     /* Check for NULL pointers */
2362     GT_assert(DssTrace, (NULL != instObj));
2364     /* Check for wrong inputs */
2365     if(NULL == dsiPrms)
2366     {
2367         GT_0trace(DssTrace, GT_ERR, "Invalid argument!!\r\n");
2368         retVal = FVID2_EBADARGS;
2369     }
2371     /* Take the instance semaphore */
2372     (void) SemaphoreP_pend(instObj->lockSem, SemaphoreP_WAIT_FOREVER);
2374     if(FVID2_SOK == retVal)
2375     {
2376         if (FALSE ==
2377                 gDss_DctrlDrvCommonObj.drvInitParams.dsiInitParams.isAvailable)
2378         {
2379             GT_0trace(DssTrace,
2380                       GT_ERR,
2381                       "DSI Output is not supported \r\n");
2382             retVal = FVID2_EBADARGS;
2383         }
2384         else
2385         {
2386             retVal = Dss_dctrlDrvSetDSIParams(&gDss_DctrlDrvInfo, dsiPrms);
2387         }
2388     }
2390     if(FVID2_SOK != retVal)
2391     {
2392         GT_0trace(DssTrace,
2393                   GT_ERR,
2394                   "Set DSI Params IOCTL failed\r\n");
2395     }
2397     /* Post the instance semaphore */
2398     (void) SemaphoreP_post(instObj->lockSem);
2400     return retVal;
2402 #endif