//-------------------------------------------------------------------------
// Copyright (c) 2020-2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// @file  iqsettings_v4.h
// @brief BPS(Bayer Processing Segment) & IPE (Image Processing Engine) data types
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// @Edit History
// when              who           what,where,why
// -----             ---           -------------
//
// 08/28/2020        mdoshi        Initial version
//------------------------------------------------------------------------
#ifndef _IQSETTINGS_V4_H_
#define _IQSETTINGS_V4_H_

#include "ipdefs.h"
#include "fwdefs.h"

#define BHIST_ROI_RGN_NUM    4

typedef enum
{
    STMP_AI_MOD_LTM = 0,
    STMP_AI_MOD_LTM_LCE = 1,
    STMP_AI_MOD_CCM = 2,
    STMP_AI_MOD_2DLUT = 3,

    STMP_AI_MOD_MAX,
} StmpAIModCfg;

typedef struct _LTM_MODULE_CFG_V2
{
    uint32_t EN;           /* 0:0  */
    uint32_t GAMMA_EN;     /* 8:8  */
    uint32_t RGAMMA_EN;    /* 9:9  */
    uint32_t LA_EN;        /* 12:12*/
    uint32_t NONLINEAR_IN; /* 20:20*/
    uint32_t TABLE_SEL;    /* 23:21*/
} LTM_MODULE_CFG_V2;

typedef struct _LtmParameters_v2
{
    LTM_MODULE_CFG_V2    moduleCfg;

    uint32_t             ltmImgProcessEn;

    uint32_t             ltmFaceControlEn;

    uint32_t             ltmEdgeAdaptiveMergeEn;

    uint32_t             dcMultipassMaskEn[PASS_NAME_MAX];
} LtmParameters_v2;

typedef struct SBLUR_MODULE_CFG
{
    uint32_t      EN;              /* 0:0 */
    uint32_t      MAP_BOOST_EN;    /* 1:1 */
    uint32_t      WEIGHT_BOOST_EN; /* 2:2 */
    uint32_t      MAP_LUT_EN;      /* 3:3 */
    uint32_t      SRI_EN;          /* 4:4 */
} SBLUR_MODULE_CFG;

typedef struct _SblurPassParameters
{
    SBLUR_MODULE_CFG    moduleCfg;
} SblurPassParameters;

typedef struct _SblurParameters //Sblur is a multi-pass CLC
{
    SblurPassParameters   parameters[PASS_NAME_MAX];
} SblurParameters;

typedef struct _COLOR_CORRECT_MODULE_CFG_V14
{
    uint32_t  EN; /* 0:0 */
    uint32_t  EN_1; /* 2:2 */
} COLOR_CORRECT_MODULE_CFG_V14;

typedef struct _ColorCorrectParameters_v14
{
    COLOR_CORRECT_MODULE_CFG_V14 moduleCfg;
} ColorCorrectParameters_v14;

typedef struct _CMUS_MODULE_CFG
{
    uint32_t  EN; /* 0:0 */
    uint32_t  CMUS_UP_MODE; /* 1:1 */
    uint32_t  FILTER_SIZE_DECISION_EN; /* 15:15 */
    uint32_t  FILTER_SIZE_DECISION_4X4; /* 16:16 */
} CMUS_MODULE_CFG;

typedef struct _CmusPassParameters
{
    CMUS_MODULE_CFG moduleCfg;
} CmusPassParameters;

typedef struct _CmusParameters
{
    CmusPassParameters   parameters[PASS_NAME_MAX];
} CmusParameters;

typedef struct _STMP_MODULE_CFG
{
    uint32_t  EN; /* 0:0 */
    uint32_t  PRE_CROP_EN; /* 8:8 */
} STMP_MODULE_CFG;

typedef struct _CatMapModCfg
{
    uint32_t  EN; /* 0:0 */
    uint32_t  UPSCALE_EN; /* 8:8 */
    uint32_t  POSTCROP_EN; /* 9:9 */
    uint32_t  NOP; /* 17:10 */
} CatMapModCfg;

typedef struct _CatMapModParameters
{
    CatMapModCfg modCfg;

    uint32_t  US_OUT_START_X;
    uint32_t  US_OUT_START_Y;
    uint32_t  US_STEP_X;
    uint32_t  US_STEP_Y;
} CatMapModParameters;

typedef struct _StmpPassParameters
{
    STMP_MODULE_CFG     moduleCfg;
    CatMapModParameters modCfgParams[STMP_AI_MOD_MAX];
} StmpPassParameters;

typedef struct _StmpParameters
{
    StmpPassParameters   parameters;
} StmpParameters;

typedef struct _STATS_HDR_BHIST_MODULE_CFG_v17
{
    uint32_t  EN;                        /*  0:0  */
    uint32_t  HDR_BHIST_ACTIVE_ROI_EN;   /*  7:5  */
    uint32_t  HDR_BHIST_CHAN_SEL;        /* 18:16 */
} STATS_HDR_BHIST_MODULE_CFG_v17;

typedef struct _BayerHistogramParameters_v17
{
    STATS_HDR_BHIST_MODULE_CFG_v17 moduleCfg;
    int32_t    bihistRoiHOffset[BHIST_ROI_RGN_NUM];
    int32_t    bihistRoiVOffset[BHIST_ROI_RGN_NUM];
    int32_t    bihistRgnHNum[BHIST_ROI_RGN_NUM];
} BayerHistogramParameters_v17;

typedef struct _PDPC_BPC_1D_MODULE_CFG
{
    uint32_t  EN;                  /* 0:0 */
    uint32_t  PDPC_EN;             /* 2:2 */
    uint32_t  BPC_EN;              /* 3:3 */
} PDPC_BPC_1D_MODULE_CFG;

typedef struct _PDPC1DParameters
{
    PDPC_BPC_1D_MODULE_CFG moduleCfg;
    int32_t    pdGlobalOffsetX;
    int32_t    pdTableOffsetX;
    int32_t    pdGlobalOffsetY;
    int32_t    pdTableOffsetY;
    int32_t    pdXEnd;
    int32_t    pdYEnd;
} PDPC1DParameters;

typedef struct _LENS_ROLLOFF_MODULE_CFG_v42
{
    uint32_t  EN;                   /*  0:0  */
    uint32_t  ALSC_EN;              /*  1:1  */
    uint32_t  HIGHLIGHTKEEP_EN;     /*  3:3  */
    uint32_t  GAIN_1D_EN;           /*  4:4  */
    uint32_t  CORRECTION_MODE_1D;   /*  5:5  */
    uint32_t  BP_SCREEN_EN;         /*  6:6  */
    uint32_t  NUM_SUBBLOCKS;        /* 13:12 */
} LENS_ROLLOFF_MODULE_CFG_v42;

typedef struct _LensRollOffParameters_v42
{
    LENS_ROLLOFF_MODULE_CFG_v42 moduleCfg;
    uint32_t    subgridWidth;
    uint32_t    meshGridBwidth;
    uint32_t    startBlockIndex;
    uint32_t    startSubgridIndex;
    uint32_t    topLeftCoordinate;
    uint32_t    numHorizontalMeshGains;
    uint32_t    interpolationFactor;
    uint32_t    horizontalOffset;
    uint32_t    verticalOffset;
    int32_t     rSquareBx;
    int32_t     rSquareBy;

    uint32_t    initBlockY;
    uint32_t    initSubblockY;
    uint32_t    initPixelY;
} LensRollOffParameters_v42;

/* MFHDR RGB Compand */
typedef struct _RGB_COMP_MODULE_CFG
{
    uint32_t  EN;       /* 0:0 */
    uint32_t  ROUND_EN; /* 3:2 */
} RGB_COMP_MODULE_CFG;

typedef struct _RgbCompandParameters
{
    RGB_COMP_MODULE_CFG moduleCfg;
} RgbCompandParameters;

/* MFHDR RGB Decompand */
typedef struct _RGB_DECOMP_MODULE_CFG
{
    uint32_t  EN;       /* 0:0 */
    uint32_t  ROUND_EN; /* 3:2 */
} RGB_DECOMP_MODULE_CFG;

typedef struct _RgbDecompandParameters
{
    RGB_DECOMP_MODULE_CFG moduleCfg;
} RgbDecompandParameters;

typedef enum
{
    MAC1 = 0,
    MAC2
} MacSelect;

typedef enum
{
    DEFAULT = 0,
    PREANR
} MacMuxSelect;

typedef struct _MFHDR_MAC_MODULE_CFG_V5
{
    uint32_t EN;                         /* 0:0 */
    uint32_t MAC1_MOTION_EN;             /* 9:9 */
    uint32_t MAC2_MOTION_EN;             /* 10:10 */
    uint32_t MAC1_GRAD_MOTION_EN;        /* 11:11 */
    uint32_t MAC2_GRAD_MOTION_EN;        /* 12:12 */
    uint32_t MAC1_HIGHLIGHT_BLENDING_EN; /* 13:13 */
    uint32_t MAC2_HIGHLIGHT_BLENDING_EN; /* 14:14 */
    uint32_t MAC1_LOWLIGHT_BLENDING_EN;  /* 15:15 */
    uint32_t MAC2_LOWLIGHT_BLENDING_EN;  /* 16:16 */
    uint32_t MAC1_HIGHLIGHT_MOTION_EN;   /* 17:17 */
    uint32_t MAC2_HIGHLIGHT_MOTION_EN;   /* 18:18 */
    uint32_t MAC1_MOTION_W_EN;           /* 22:22 */
    uint32_t MAC2_MOTION_W_EN;           /* 23:23 */
    uint32_t MAC1_COLOR_SHIFT_WEIGHT_EN; /* 24:24 */
    uint32_t MAC2_COLOR_SHIFT_WEIGHT_EN; /* 25:25 */
    uint32_t MULTISIZE_KERNEL_EN;        /* 26:27 */
    uint32_t MAC1_MOTION_ANCHOR;         /* 30:30 */
    uint32_t MAC2_MOTION_ANCHOR;         /* 31:31 */
} MFHDR_MAC_MODULE_CFG_V5;

typedef struct _MFHDR_MAC_MODULE_CFG_2_V5
{
    uint32_t MAC1_RNR_EN;                                     /* 0:0 */
    uint32_t MAC1_HIGHLIGHT_COHERANCY_EN;                     /* 1:1 */
    uint32_t MAC1_A1_BLEND_EN;                                /* 2:2 */
    uint32_t MAC1_INVERSE_A1_IBLEND_EN;                       /* 3:3 */
    uint32_t MAC1_A2_BLEND_EN;                                /* 4:4 */
    uint32_t MAC1_NOISE_PROFILE_IN_SEL;                       /* 5:5 */
    uint32_t MAC1_MOTION_WEIGHT_LUMA_ONLY;                    /* 6:6 */
    uint32_t MAC1_MOTION_OUTPUT_OPTION;                       /* 7:7 */
    uint32_t MAC1_HIGHLIGHT_REFINEMENT_MODE;                  /* 8:9 */
    uint32_t MAC1_HIGHLIGHT_MOTION_OUTPUT_CONDITION_SEL;      /* 10:11 */
    uint32_t MAC2_RNR_EN;                                     /* 14:14 */
    uint32_t MAC2_HIGHLIGHT_COHERANCY_EN;                     /* 15:15 */
    uint32_t MAC2_A1_BLEND_EN;                                /* 16:16 */
    uint32_t MAC2_INVERSE_A1_IBLEND_EN;                       /* 17:17 */
    uint32_t MAC2_A2_BLEND_EN;                                /* 18:18 */
    uint32_t MAC2_NOISE_PROFILE_IN_SEL;                       /* 19:19 */
    uint32_t MAC2_MOTION_WEIGHT_LUMA_ONLY;                    /* 20:20 */
    uint32_t MAC2_MOTION_OUTPUT_OPTION;                       /* 21:21 */
    uint32_t MAC2_HIGHLIGHT_REFINEMENT_MODE;                  /* 22:23 */
    uint32_t MAC2_HIGHLIGHT_MOTION_OUTPUT_CONDITION_SEL;      /* 24:25 */
} MFHDR_MAC_MODULE_CFG_2_V5;

typedef struct _MFHDR_MAC_MODULE_CFG_3_V5
{
    uint32_t MULTISIZE_KERNEL_CHROMA_EN;    /* 4:6 */
} MFHDR_MAC_MODULE_CFG_3_V5;

/* MFHDR MAC */
typedef struct _MfhdrMacParameters_v5
{
    MFHDR_MAC_MODULE_CFG_V5   moduleCfg;
    ExposureSelect            exposureMap[MFHDR_EXPOSURE_MAX];

    /* MacSelect is only Valid for 2 exposures */
    MacSelect                 macSelect;

    /* Extension for MAC v5.1 */
    MacMuxSelect              MFHDR_MUX_SEL1;
    MacMuxSelect              MFHDR_MUX_SEL2;

    MFHDR_MAC_MODULE_CFG_2_V5 moduleCfg2;
    MFHDR_MAC_MODULE_CFG_3_V5 moduleCfg3;

    /* FW needs to generate pixel count or highlight motion weight map for SW to consume*/
    uint32_t mac1HighlightMotionOutputEnable[PASS_NAME_MAX];
    uint32_t mac2HighlightMotionOutputEnable[PASS_NAME_MAX];
}MfhdrMacParameters_v5;

#endif // _IQSETTINGS_V4_H_
