This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM62A7: ISP Tuning on SDK ver. 11, blurry images with EE on

Part Number: AM62A7

Hi,

I'm trying to tune ISP for my IMX327 camera sensor. While colors, white balancing and exposure seem alright, the image is blurry no matter what values for EE are selected. For the initial dcc configuration I've followed another post on how to use the auto-tune functionality from imaging repository: [FAQ] TDA4VM: How to use Auto-Tune in the python tool under “imaging/tools/” of TDA4x/AM6xA SDK?

I've used 4 different raw frames in different lighting conditions as well as a full black frame for reference. There was no ee dcc file among the freshly generated ones, therefore, I've created it using ISP Tuning tool with default values. Seeing as it hasn't brought any improvements, even thought the ee-mode for gstreamer pipeline was set to MODE_Y8, I used a sample ee dcc file for IMX390 camera sensor. The images received from both captures seem alike (with a slight difference related to the change in ambient lightning). 

To my knowledge, the same system but built on the sdk ver. 10 had noticeable improvements on the image sharpeness when run with the ee-mode set to MODE_Y8 (with default ee dcc files).

What could cause this different behaviour between sdk versions, is there a chance that the isp might not read the ee values correctly? DCC binaries build for the system with sdk ver. 10 don't work on the system with a newer version. Are there other ISP components, apart from EE and possibly NSF4, that could influence the sharpness of the images?

UPDATE:

I was confident that ee-mode=1 refers to the EE_MODE_Y8, however, it refers to the EE_MODE_Y12 mode. My camera sensor produces RAW rggb10 frames that should be processed to NV12 format, as far as I understand MODE_Y8 is more appropriate for this scenario. However, when MODE_Y8 is set to the tiovxisp node, it stalls the whole pipeline. MODE_Y12 works just fine, but as described above it doesn't yield any visible improvements. Could you confirm whether my intuition behind MODE_Y8 is correct and if this mode results in the similar behaviour with the other camera sensors?

Best regards,
Konrad 

  • Hi Konrad,

    Please note that ee-mode=1 refers to EE_MODE_Y12, as shown by gst-inspect:

    root@am62axx-evm:/opt/edgeai-gst-apps# gst-inspect-1.0 tiovxisp
    ...
      ee-mode             : Flag to set Edge Enhancement mode.
                            flags: readable, writable, controllable, changeable only in NULL or READY state
                            Enum "GstTIOVXISPEEModes" Default: 0, "EE_MODE_OFF"
                               (0): EE_MODE_OFF      - EE mode off
                               (1): EE_MODE_Y12      - Edge Enhancer is enabled on Y12 output (output0)
                               (2): EE_MODE_Y8       - Edge Enhancer is enabled on Y8 output (output2)
    

    MODE_Y12 works just fine, but as described above it doesn't yield any visible improvements.

    Can you try to increase the edge sharpener gain and see if there is any effect?

    Regards,

    Jianzhong

  • Hi Jianzhong,

    I've captured 3 different sample frames: EE disabled, EE config for IMX390, EE config with exaggerated values to verify whether EE influences the quality.

    EE disabled:

    EE disabled

    EE for IMX390:

    EE for IMX390

    Exaggerated EE:

    Exagerated EE

    The images were taken with following pipeline:

    gst-launch-1.0 -v \
        v4l2src device=/dev/video2 io-mode=dmabuf-import ! queue leaky=2 max-size-buffers=4 ! \
        video/x-bayer,width=1920,height=1080,framerate=30/1,format=rggb10 ! \
        tiovxisp sensor-name="SENSOR_SONY_IMX290" \
            dcc-isp-file=/opt/imaging/imx290/linear_tune/dcc_viss.bin format-msb=9 \
            sink_0::dcc-2a-file=/opt/imaging/imx290/linear_tune/dcc_2a.bin \
            sink_0::device=/dev/v4l-subdev2 \
            sink_0::ae-mode=0 sink_0::awb-mode=0 \
            ee-mode=1 ! \
        video/x-raw,format=NV12 ! \
        tiovxmultiscaler target=1 ! video/x-raw,width=1920,height=1080 ! \
        v4l2jpegenc ! \
        multifilesink location="$OUTPUT_PATTERN" max-files=5



    For both sessions with EE enabled, MODE_Y12 (ee-mode=1) was set. MODE_Y8 stalls the whole pipeline without producing any frame. I've verified that on the same hardware but with a system image based on SDK ver. 10 both Y12 and Y8 modes work perfectly fine, however, I wasn't able to compare the results between different EE config values. Could you verify whether EE_MODE_Y8 works fine on your setup with the latest SDK version?

    Best,
    Konrad

  • Hi,

    After playing more with the ISP, tuning tool and imaging repository I strongly suspect that there is a bug in the gsttiovxisp or underlying OpenVX graph.  ,  ,  could you please look into this? I believe MODE_Y8 is required to properly apply the edge enhancement and sharpening to our pipeline, is there a known patch for the TIOVX plugin or OpenVX module on the latest SDK?

    Best,
    Konrad

  • Hello Konrad,

    MODE_Y8 stalls the whole pipeline without producing any frame.

    Yes, I reproduced this issue on SDK 11.1 using my IMX219 setup. I've created a bug report and hope it gets resolved soon.

    Meanwhile, is it okay for you to use SDK 10.x?

    Regards,

    Jianzhong

  • Thank you Jianzhong. Who is in charge of resolving this? Is there a way to ping that person? Its quite urgent for us, and we can't use SDK 10.x and we have a big demo next week.

    Thank you so much. 
    Jimmy

  • Hi Jimmy,

    Please reach out to your local TI support team to expedite this.

    Regards,

    Jianzhong

  • Hi Jimmy,

    To rebuild the ISP firmware, you'll need the firmware builder from https://www.ti.com/tool/PROCESSOR-SDK-AM62A#downloads:

    Please send a request for it and let us know.

    Regards,

    Jianzhong

  • Dear Jianzhong and Gang, 

    Thank you for your help. For the time being we've decided to revert the SDK version to 10 as a temporary solution. However, we find some changes made in the newest SDK beneficial, therefore we'd appreciate if you kept us noticed when the fix is available.


    Best regards,
    Konrad

  • Hi Konrad,

    Sure, I'll keep you posted.

    Regards,

    Jianzhong

  • Dear Jianzhong,

    We've also requested the access to the firmware builder software to apply the fix in parallel to the development on the SDK ver. 10. We would appreciate if you could grant the access to the tool.

    Best regards,
    Konrad

  • Ok. Let me check.

  • Hi,

    I've reverted the commit back in the imaging module within ti-firmware-builder and now I'm running into dependency issues while trying to compile tispl.bin. Could you please explain how to compile the module without reverting versions of the other components?

    Best regards,
    Konrad

  • Hi Konrad,

    now I'm running into dependency issues

    Can you share the build log?

    Thank you.

    Jianzhong

  • Hi Jianzhong,

    Our team has managed to solve the issue. The trick was to keep the latest version of the imaging module but revert that single drv source and remove “if !defined(soc_am62) …” clause from 2 places (not doing so will result in VX init errors). 

    best regards,

    Konrad

  • Hi Konrad,

    Thanks for the update!

    and remove “if !defined(soc_am62) …” clause from 2 places (not doing so will result in VX init errors). 

    Could you please share these 2 required changes for us to file a bug if necessary?

  • Hi Gang,

    Sorry for the late reply. I'm attaching the source file with applied fixes. It involves removing ifdefs from lines 163, 226, 233, and 240. 

    I hope it helps resolve the issue. 

    Best regards,
    Konrad

     

    /*
     *
     * Copyright (c) 2019-2021 Texas Instruments Incorporated
     *
     * All rights reserved not granted herein.
     *
     * Limited License.
     *
     * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
     * license under copyrights and patents it now or hereafter owns or controls to make,
     * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
     * terms herein.  With respect to the foregoing patent license, such license is granted
     * solely to the extent that any such patent is necessary to Utilize the software alone.
     * The patent license shall not apply to any combinations which include this software,
     * other than combinations with devices manufactured by or for TI ("TI Devices").
     * No hardware patent is licensed hereunder.
     *
     * Redistributions must preserve existing copyright notices and reproduce this license
     * (including the above copyright notice and the disclaimer and (if applicable) source
     * code license limitations below) in the documentation and/or other materials provided
     * with the distribution
     *
     * Redistribution and use in binary form, without modification, are permitted provided
     * that the following conditions are met:
     *
     * *       No reverse engineering, decompilation, or disassembly of this software is
     * permitted with respect to any software provided in binary form.
     *
     * *       any redistribution and use are licensed by TI for use only with TI Devices.
     *
     * *       Nothing shall obligate TI to provide you with source code for the software
     * licensed and provided to you in object code.
     *
     * If software source code is provided to you, modification and redistribution of the
     * source code are permitted provided that the following conditions are met:
     *
     * *       any redistribution and use of the source code, including any resulting derivative
     * works, are licensed by TI for use only with TI Devices.
     *
     * *       any redistribution and use of any object code compiled from the source code
     * and any resulting derivative works, are licensed by TI for use only with TI Devices.
     *
     * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
     *
     * may be used to endorse or promote products derived from this software without
     * specific prior written permission.
     *
     * DISCLAIMER.
     *
     * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "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 TI AND TI'S LICENSORS 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.
     *
     */
    
    /* ========================================================================== */
    /*                             Include Files                                  */
    /* ========================================================================== */
    
    #include <vx_vpac_viss_target_priv.h>
    
    /* ========================================================================== */
    /*                           Macros & Typedefs                                */
    /* ========================================================================== */
    
    
    /* ========================================================================== */
    /*                         Structure Declarations                             */
    /* ========================================================================== */
    
    
    
    /* ========================================================================== */
    /*                          Function Declarations                             */
    /* ========================================================================== */
    
    static vx_status tivxVpacVissSetRfeConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef);
    static vx_status tivxVpacVissSetGlbceConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef);
    static vx_status tivxVpacVissSetNsf4Config(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef);
    static vx_status tivxVpacVissSetFcpConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef, uint32_t fcpInstance);
    #if defined(VPAC3L)
    static vx_status tivxVpacVissSetPcidConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef);
    #endif
    
    #if defined(VPAC3) || defined(VPAC3L)
    static vx_status tivxVpacVissSetCacConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef);
    #endif
    /* ========================================================================== */
    /*                            Global Variables                                */
    /* ========================================================================== */
    
    
    /* ========================================================================== */
    /*                          Function Definitions                              */
    /* ========================================================================== */
    
    vx_status tivxVpacVissSetConfigInDrv(tivxVpacVissObj *vissObj)
    {
        vx_status status;
        tivx_vpac_viss_params_t   *vissPrms = NULL;
    
        status = tivxVpacVissSetRfeConfig(vissObj, &vissObj->vissCfgRef);
    
        if ((vx_status)VX_SUCCESS == status)
        {
            status = tivxVpacVissSetGlbceConfig(vissObj, &vissObj->vissCfgRef);
        }
    
        if ((vx_status)VX_SUCCESS == status)
        {
            status = tivxVpacVissSetNsf4Config(vissObj, &vissObj->vissCfgRef);
        }
    
        if ((vx_status)VX_SUCCESS == status)
        {
            status = tivxVpacVissSetFcpConfig(vissObj, &vissObj->vissCfgRef, 0);
    #if defined(VPAC3)
            vissPrms = (tivx_vpac_viss_params_t *) vissObj->viss_prms_target_ptr;
            if(TIVX_VPAC_VISS_FCP1_DISABLED != vissPrms->fcp1_config)
            {
                status = tivxVpacVissSetFcpConfig(vissObj, &vissObj->vissCfgRef, 1);
            }
    #endif
        }
    #if defined(VPAC3) || defined(VPAC3L)
        if ((vx_status)VX_SUCCESS == status)
        {
            vissPrms = (tivx_vpac_viss_params_t *) vissObj->viss_prms_target_ptr;
            if (0U == vissPrms->bypass_cac)
            {
                status = tivxVpacVissSetCacConfig(vissObj, &vissObj->vissCfgRef);
            }
        }
    #endif
    
    #if defined(VPAC3L)
        if ((vx_status)VX_SUCCESS == status)
        {
            status = tivxVpacVissSetPcidConfig(vissObj, &vissObj->vissCfgRef);
        }
    #endif
    
        return (status);
    }
    
    vx_status tivxVpacVissSetConfigBuffer(tivxVpacVissObj *vissObj)
    {
        vx_status status =      (vx_status) VX_SUCCESS;
    
        int32_t fvid2_status =  FVID2_SOK;
    
        /* Initialize buffer pointer to NULL */
        vissObj->configurationBuffer.bufferPtr = NULL;
        /* Initialize length to zero */
        vissObj->configurationBuffer.length = 0;
        /* Initialize configThroughUDMA to false */
        vissObj->configurationBuffer.configThroughUdmaFlag = false;
    
        /* Get configuration buffer information */
        fvid2_status = Fvid2_control(vissObj->handle,
        IOCTL_VHWA_M2M_VISS_GET_BUFF_INFO, (void*) &vissObj->configurationBuffer,
                NULL);
    
        if (FVID2_SOK != fvid2_status)
        {
            VX_PRINT(VX_ZONE_ERROR, "Failed to Get config buff info from driver\n");
        }
    
        if (FVID2_SOK == fvid2_status)
        {
            /* configThroughUdmaFlag is true, allocate config buffer */
            if (true == vissObj->configurationBuffer.configThroughUdmaFlag)
            {
                /* Indicate that we are allocating out of memory that is cache write through policy */
                vissObj->configurationBuffer.isCacheWriteBackPolicy = false;
    
                /* allocate buffer for the length requested */
                vissObj->configurationBuffer.bufferPtr = (uint32_t*) tivxMemAlloc(
                        vissObj->configurationBuffer.length,
                        (vx_enum) TIVX_MEM_EXTERNAL_CACHEABLE_WT);
                if (NULL == vissObj->configurationBuffer.bufferPtr)
                {
                    VX_PRINT(VX_ZONE_ERROR, "failed to allocate %d bytes !!!\n",
                            vissObj->configurationBuffer.length);
                    fvid2_status = FVID2_EALLOC;
                }
                else
                {
                    /* Set configuration buffer information */
                    fvid2_status = Fvid2_control(vissObj->handle,
                    IOCTL_VHWA_M2M_VISS_SET_BUFF_INFO,
                            (void*) &vissObj->configurationBuffer, NULL);
    
                    if (FVID2_SOK != fvid2_status)
                    {
                        VX_PRINT(VX_ZONE_ERROR,
                                "Failed to set config buff info into driver\n");
                    }
                }
            }
        }
        /* Convert FVID2 status to OpenVX Status */
        if (FVID2_SOK != fvid2_status)
        {
            status = (vx_status) VX_ERROR_INVALID_PARAMETERS;
        }
        else
        {
            status = (vx_status) VX_SUCCESS;
        }
    
    
        return (status);
    }
    
    void tivxVpacVissDeleteConfigBuffer(tivxVpacVissObj *vissObj)
    {
        if (NULL != vissObj->configurationBuffer.bufferPtr)
        {
            tivxMemFree((void*) vissObj->configurationBuffer.bufferPtr,
                    vissObj->configurationBuffer.length,
                    (vx_enum) TIVX_MEM_EXTERNAL_CACHEABLE_WT);
        }
    }
    
    static vx_status tivxVpacVissSetRfeConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef)
    {
        vx_status           status = (vx_status)VX_SUCCESS;
        int32_t             fvid2_status = FVID2_SOK;
        Rfe_Control         rfeCtrl;
    
        if (NULL != vissCfgRef->lPwlCfg)
        {
            /* PWL for Long Input */
            rfeCtrl.module  = RFE_MODULE_PWL1;
            rfeCtrl.pwl1Cfg = vissCfgRef->lPwlCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set PWL1 Config !!!\n");
            }
    
            /* Reset Pointer */
            vissCfgRef->lPwlCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->sPwlCfg) && (FVID2_SOK == fvid2_status))
        {
            /* PWL for Short Input */
            rfeCtrl.module  = RFE_MODULE_PWL2;
            rfeCtrl.pwl2Cfg = vissCfgRef->sPwlCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set PWL2 Config !!!\n");
            }
    
            /* Reset Pointer */
            vissCfgRef->sPwlCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->vsPwlCfg) && (FVID2_SOK == fvid2_status))
        {
            /* PWL for Very Short Input */
            rfeCtrl.module  = RFE_MODULE_PWL3;
            rfeCtrl.pwl3Cfg = vissCfgRef->vsPwlCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set PWL3 Config !!!\n");
            }
    
            vissCfgRef->vsPwlCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->lLutCfg) && (FVID2_SOK == fvid2_status))
        {
            /* PWL Lut for Long Input */
            rfeCtrl.module          = RFE_MODULE_DECOMP_LUT1;
            rfeCtrl.decomp1Cfg      = vissCfgRef->lLutCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set PWL1_LUT Config !!!\n");
            }
    
            vissCfgRef->lLutCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->sLutCfg) && (FVID2_SOK == fvid2_status))
        {
            /* PWL Lut for Short Input */
            rfeCtrl.module          = RFE_MODULE_DECOMP_LUT2;
            rfeCtrl.decomp2Cfg      = vissCfgRef->sLutCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set PWL2_LUT Config !!!\n");
            }
    
            vissCfgRef->sLutCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->vsLutCfg) && (FVID2_SOK == fvid2_status))
        {
            /* PWL Lut for Very Short Input */
            rfeCtrl.module          = RFE_MODULE_DECOMP_LUT3;
            rfeCtrl.decomp3Cfg      = vissCfgRef->vsLutCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set PWL3_LUT Config !!!\n");
            }
    
            vissCfgRef->vsLutCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->wdr1Cfg) && (FVID2_SOK == fvid2_status))
        {
            /* WDR Merge 1 block configuration */
            rfeCtrl.module       = RFE_MODULE_WDR_MERGE_MA1;
            rfeCtrl.wdrMergeMa1  = vissCfgRef->wdr1Cfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set WDR_MERGE1 Config !!!\n");
            }
    
            vissCfgRef->wdr1Cfg = NULL;
        }
    
        if ((NULL != vissCfgRef->wdr2Cfg) && (FVID2_SOK == fvid2_status))
        {
            rfeCtrl.module       = RFE_MODULE_WDR_MERGE_MA2;
            rfeCtrl.wdrMergeMa2  = vissCfgRef->wdr2Cfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set WDR_MERGE2 Config !!!\n");
            }
    
            vissCfgRef->wdr2Cfg = NULL;
        }
    
        if ((NULL != vissCfgRef->comp20To16LutCfg) && (FVID2_SOK == fvid2_status))
        {
            /* Set Companding Lut to convert from 20 to 16bits */
            rfeCtrl.module       = RFE_MODULE_COMP_LUT;
            rfeCtrl.compCfg      = vissCfgRef->comp20To16LutCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set COMP_LUT Config !!!\n");
            }
    
            vissCfgRef->comp20To16LutCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->dpcOtf) && (FVID2_SOK == fvid2_status))
        {
            rfeCtrl.module       = RFE_MODULE_DPC_OTF;
            rfeCtrl.dpcOtfCfg    = vissCfgRef->dpcOtf;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set DPC_OTF Config !!!\n");
            }
    
            vissCfgRef->dpcOtf = NULL;
        }
    
        if ((NULL != vissCfgRef->dpcLut) && (FVID2_SOK == fvid2_status))
        {
            rfeCtrl.module       = RFE_MODULE_DPC_LUT;
            rfeCtrl.dpcLutCfg    = vissCfgRef->dpcLut;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
    
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set DPC_LUT Config !!!\n");
            }
    
            vissCfgRef->dpcLut = NULL;
        }
    
        if ((NULL != vissCfgRef->lscCfg) && (FVID2_SOK == fvid2_status))
        {
            rfeCtrl.module      = RFE_MODULE_LSC;
            rfeCtrl.lscConfig   = vissCfgRef->lscCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set LSC Config !!!\n");
            }
    
            vissCfgRef->lscCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->wbCfg) && (FVID2_SOK == fvid2_status))
        {
            rfeCtrl.module       = RFE_MODULE_GAIN_OFST;
            rfeCtrl.wbConfig     = vissCfgRef->wbCfg;
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set WhiteBalance Config !!!\n");
            }
    
            vissCfgRef->wbCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->rfeH3aInCfg) && (FVID2_SOK == fvid2_status))
        {
            /* H3A Input Selection and Lut configuration */
            rfeCtrl.module   = RFE_MODULE_H3A;
            rfeCtrl.h3aInCfg = vissCfgRef->rfeH3aInCfg;
    
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set H3A Input Config !!!\n");
            }
    
            vissCfgRef->rfeH3aInCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->h3aLutCfg) && (FVID2_SOK == fvid2_status))
        {
            /* H3A Input Selection and Lut configuration */
            rfeCtrl.module   = RFE_MODULE_H3A_LUT;
            rfeCtrl.h3aLutCfg = vissCfgRef->h3aLutCfg;
    
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_RFE_SET_CONFIG,
                (void *)&rfeCtrl, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set H3A Input Config !!!\n");
            }
    
            vissCfgRef->h3aLutCfg = NULL;
        }
    
        if ((NULL != vissCfgRef->h3aCfg) && (FVID2_SOK == fvid2_status))
        {
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_H3A_SET_CONFIG,
                (void *)vissCfgRef->h3aCfg, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set H3A Config !!!\n");
            }
            else
            {
                vissObj->h3a_output_size = vissCfgRef->h3aCfg->outputSize;
            }
    
            vissCfgRef->h3aCfg = NULL;
        }
    
        /* Convert FVID2 status to OpenVX Status */
        if (FVID2_SOK != fvid2_status)
        {
            status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
        }
        else
        {
            status = (vx_status)VX_SUCCESS;
        }
    
        return (status);
    }
    
    static vx_status tivxVpacVissSetGlbceConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef)
    {
        vx_status           status = (vx_status)VX_SUCCESS;
        int32_t             fvid2_status = FVID2_SOK;
        Vhwa_M2mVissParams *vissDrvPrms = NULL;
        Glbce_Control       glbceCtrl;
    
        vissDrvPrms = &vissObj->vissPrms;
    
        /* GLBCE Parameters can be set only if it is enabled at SET_PARAMS time */
        if ((uint32_t)UTRUE == vissDrvPrms->enableGlbce)
        {
            if (NULL != vissCfgRef->glbceCfg)
            {
                glbceCtrl.module = GLBCE_MODULE_GLBCE;
                glbceCtrl.glbceCfg = vissCfgRef->glbceCfg;
                fvid2_status = Fvid2_control(vissObj->handle, IOCTL_GLBCE_SET_CONFIG,
                    (void *)&glbceCtrl, NULL);
                if (FVID2_SOK != fvid2_status)
                {
                    VX_PRINT(VX_ZONE_ERROR, "Failed to set GLBCE Config !!!\n");
                }
    
                vissCfgRef->glbceCfg = NULL;
            }
    
            if (NULL != vissCfgRef->fwdPrcpCfg)
            {
                glbceCtrl.module = GLBCE_MODULE_FWD_PERCEPT;
                glbceCtrl.fwdPrcptCfg = vissCfgRef->fwdPrcpCfg;
                fvid2_status = Fvid2_control(vissObj->handle, IOCTL_GLBCE_SET_CONFIG,
                    (void *)&glbceCtrl, NULL);
                if (FVID2_SOK != fvid2_status)
                {
                    VX_PRINT(VX_ZONE_ERROR, "Failed to set GLBCE_FWD_PERCEPT Config !!!\n");
                }
    
                vissCfgRef->fwdPrcpCfg = NULL;
            }
    
            if (NULL != vissCfgRef->revPrcpCfg)
            {
                glbceCtrl.module = GLBCE_MODULE_REV_PERCEPT;
                glbceCtrl.revPrcptCfg = vissCfgRef->revPrcpCfg;
                fvid2_status = Fvid2_control(vissObj->handle, IOCTL_GLBCE_SET_CONFIG,
                    (void *)&glbceCtrl, NULL);
                if (FVID2_SOK != fvid2_status)
                {
                    VX_PRINT(VX_ZONE_ERROR, "Failed to set GLBCE_REV_PERCEPT Config !!!\n");
                }
    
                vissCfgRef->revPrcpCfg = NULL;
            }
        }
    
        /* Convert FVID2 status to OpenVX Status */
        if (FVID2_SOK != fvid2_status)
        {
            status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
        }
        else
        {
            status = (vx_status)VX_SUCCESS;
        }
    
        return (status);
    }
    
    static vx_status tivxVpacVissSetNsf4Config(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef)
    {
        vx_status           status = (vx_status)VX_SUCCESS;
        int32_t             fvid2_status = FVID2_SOK;
        Vhwa_M2mVissParams *vissDrvPrms = NULL;
    
        vissDrvPrms = &vissObj->vissPrms;
    
        if (((uint32_t)UTRUE == vissDrvPrms->enableNsf4) &&
            (NULL != vissCfgRef->nsf4Cfg))
        {
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_NSF4_SET_CONFIG,
                (void *)vissCfgRef->nsf4Cfg, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set NFS4 Config !!!\n");
            }
    
            vissCfgRef->nsf4Cfg = NULL;
        }
    
        #if defined(VPAC3) || defined (VPAC3L)
        if (NULL != vissObj->raw_hist_out_target_ptr)
        {
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_SET_RAW_HIST_APP_PTR,
                (void *)vissObj->raw_hist_out_target_ptr, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set Raw Histogram Config !!!\n");
            }
        }
        #endif
    
        /* Convert FVID2 status to OpenVX Status */
        if (FVID2_SOK != fvid2_status)
        {
            status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
        }
        else
        {
            status = (vx_status)VX_SUCCESS;
        }
    
        return (status);
    }
    
    static vx_status tivxVpacVissSetFcpConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef,
        uint32_t fcpInstance)
    {
        int32_t             status = (vx_status)VX_SUCCESS;
        uint32_t            ioctl_set_config = IOCTL_FCP_SET_CONFIG;
        Fcp_Control         fcpCtrl;
        Vhwa_M2mVissParams *vissDrvPrms = NULL;
    
        #if defined(VPAC3)
        if(fcpInstance == 1U)
        {
            ioctl_set_config = IOCTL_FCP2_SET_CONFIG;
        }
        #endif
        vissDrvPrms = &vissObj->vissPrms;
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].cfaLut16to12Cfg)
        {
            fcpCtrl.module = FCP_MODULE_COMPANDING;
            fcpCtrl.inComp = vissCfgRef->fcpCfg[fcpInstance].cfaLut16to12Cfg;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set COMP Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].cfaLut16to12Cfg = NULL;
        }
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].cfaCfg)
        {
            fcpCtrl.module          = FCP_MODULE_CFA;
            fcpCtrl.cfa             = vissCfgRef->fcpCfg[fcpInstance].cfaCfg;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set CFA Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].cfaCfg = NULL;
        }
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].ccm)
        {
    
            fcpCtrl.module      = FCP_MODULE_CCM;
            fcpCtrl.ccm         = vissCfgRef->fcpCfg[fcpInstance].ccm;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set CCM Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].ccm = NULL;
        }
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].gamma)
        {
            fcpCtrl.module = FCP_MODULE_GAMMA;
            fcpCtrl.gamma  = vissCfgRef->fcpCfg[fcpInstance].gamma;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set Gamma Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].gamma = NULL;
        }
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].rgb2Hsv)
        {
            fcpCtrl.module          = FCP_MODULE_RGB2HSV;
            fcpCtrl.rgb2Hsv         = vissCfgRef->fcpCfg[fcpInstance].rgb2Hsv;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set RGB2HSV Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].rgb2Hsv = NULL;
        }
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].rgb2yuv)
        {
            fcpCtrl.module          = FCP_MODULE_RGB2YUV;
            fcpCtrl.rgb2Yuv         = vissCfgRef->fcpCfg[fcpInstance].rgb2yuv;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set RGB2YUV Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].rgb2yuv = NULL;
        }
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].yuvSatLutCfg)
        {
            fcpCtrl.module                  = FCP_MODULE_YUV_SAT_LUT;
            fcpCtrl.yuvSatLut               = vissCfgRef->fcpCfg[fcpInstance].yuvSatLutCfg;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set YUV_LUT Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].yuvSatLutCfg = NULL;
        }
    
        if (NULL != vissCfgRef->fcpCfg[fcpInstance].histCfg)
        {
            fcpCtrl.module                  = FCP_MODULE_HISTOGRAM;
            fcpCtrl.hist                    = vissCfgRef->fcpCfg[fcpInstance].histCfg;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set Histogram Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].histCfg = NULL;
        }
    
        if (((VHWA_M2M_VISS_EE_ON_LUMA12 == vissDrvPrms->edgeEnhancerMode) ||
             (VHWA_M2M_VISS_EE_ON_LUMA8 == vissDrvPrms->edgeEnhancerMode)) &&
            (NULL != vissCfgRef->fcpCfg[fcpInstance].eeCfg))
        {
            if (VHWA_M2M_VISS_EE_ON_LUMA12 == vissDrvPrms->edgeEnhancerMode)
            {
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassY12 = UFALSE;
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassC12 = UTRUE;
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->eeForY12OrY8 = 0u;
    
                if ( (FVID2_DF_YUV422I_UYVY == vissDrvPrms->outPrms[VHWA_M2M_VISS_OUT_YUV422_12B_IDX].fmt.dataFormat) ||
                     (FVID2_DF_YUV422I_YUYV == vissDrvPrms->outPrms[VHWA_M2M_VISS_OUT_YUV422_12B_IDX].fmt.dataFormat) )
                {
                    vissCfgRef->fcpCfg[fcpInstance].eeCfg->alignY12withChroma = UTRUE;
                    vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassC12 = UFALSE;
                }
            }
            else
            {
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassY12 = UTRUE;
            }
    
            if (VHWA_M2M_VISS_EE_ON_LUMA8 == vissDrvPrms->edgeEnhancerMode)
            {
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassY8 = UFALSE;
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassC8 = UTRUE;
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->eeForY12OrY8 = 1u;
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->leftShift = 2u;
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->rightShift = 2u;
    
                if ( (FVID2_DF_YUV422I_UYVY == vissDrvPrms->outPrms[VHWA_M2M_VISS_OUT_YUV422_8B_IDX].fmt.dataFormat) ||
                     (FVID2_DF_YUV422I_YUYV == vissDrvPrms->outPrms[VHWA_M2M_VISS_OUT_YUV422_8B_IDX].fmt.dataFormat) )
                {
                    vissCfgRef->fcpCfg[fcpInstance].eeCfg->alignY8withChroma = UTRUE;
                    vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassC8 = UFALSE;
                }
            }
            else
            {
                vissCfgRef->fcpCfg[fcpInstance].eeCfg->bypassY8 = UTRUE;
            }
    
            fcpCtrl.module              = FCP_MODULE_EE;
            fcpCtrl.eeCfg               = vissCfgRef->fcpCfg[fcpInstance].eeCfg;
            status = Fvid2_control(vissObj->handle, ioctl_set_config,
                (void *)&fcpCtrl, NULL);
            if (FVID2_SOK != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set YEE Config !!!\n");
            }
    
            vissCfgRef->fcpCfg[fcpInstance].eeCfg = NULL;
        }
    
        return (status);
    }
    
    #if defined(VPAC3) || defined(VPAC3L)
    static vx_status tivxVpacVissSetCacConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef)
    {
        vx_status           status = (vx_status)VX_SUCCESS;
        int32_t             fvid2_status = FVID2_SOK;
        Vhwa_M2mVissParams *vissDrvPrms = NULL;
    
        vissDrvPrms = &vissObj->vissPrms;
    
        if (((uint32_t)UTRUE == vissDrvPrms->enableCac) &&
            (NULL != vissCfgRef->cacCfg))
        {
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_CAC_SET_CONFIG,
                (void *)vissCfgRef->cacCfg, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set CAC Config !!!\n");
            }
    
            vissCfgRef->cacCfg = NULL;
        }
    
        /* Convert FVID2 status to OpenVX Status */
        if (FVID2_SOK != fvid2_status)
        {
            status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
        }
        else
        {
            status = (vx_status)VX_SUCCESS;
        }
    
        return (status);
    }
    #endif
    
    #if defined(VPAC3L)
    static vx_status tivxVpacVissSetPcidConfig(tivxVpacVissObj *vissObj,
        tivxVpacVissConfigRef *vissCfgRef)
    {
        vx_status           status = (vx_status)VX_SUCCESS;
        int32_t             fvid2_status = FVID2_SOK;
        Vhwa_M2mVissParams *vissDrvPrms = NULL;
    
        vissDrvPrms = &vissObj->vissPrms;
    
        if (((uint32_t)UTRUE == vissDrvPrms->enablePcid) &&
            (NULL != vissCfgRef->pcidCfg))
        {
            fvid2_status = Fvid2_control(vissObj->handle, IOCTL_PCID_SET_CONFIG,
                (void *)vissCfgRef->pcidCfg, NULL);
            if (FVID2_SOK != fvid2_status)
            {
                VX_PRINT(VX_ZONE_ERROR, "Failed to set PCID Config !!!\n");
            }
    
            vissCfgRef->pcidCfg = NULL;
        }
    
        /* Convert FVID2 status to OpenVX Status */
        if (FVID2_SOK != fvid2_status)
        {
            status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
        }
        else
        {
            status = (vx_status)VX_SUCCESS;
        }
    
        return (status);
    }
    #endif
    
    
    

  • Hi Konrad,

    Thank you very much for sharing!