/*************************************************************************************************
// INTEL CONFIDENTIAL Copyright 2011-2025 Intel Corporation All Rights Reserved.
//
// The source code contained or described herein and all documents related to the source code
// ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material
// remains with Intel Corporation or its suppliers and licensors. The Material contains trade secrets
// and proprietary and confidential information of Intel or its suppliers and licensors. The Material is
// protected by worldwide copyright and trade secret laws and treaty provisions. No part of the
// Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted,
// distributed, or disclosed in any way without Intel's prior express written permission.
//
// No license under any patent, copyright, trade secret or other intellectual property right is
// granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by
// implication, inducement, estoppel or otherwise. Any license under such intellectual property
// rights must be express and approved by Intel in writing.
//*************************************************************************************************/

#ifndef SENSOR_TYPES_H
#define SENSOR_TYPES_H

#include "platf_info.h"
#include <minwindef.h>

/*!
 * \brief Resolution ratio
 */
#define RATIO_MUX 1000                              /*!< Resolution Ratio Mux */
#define GET_RATIO(a, b) ((a) * RATIO_MUX / (b))     /*!< Resolution Ratio Converter */

#define ASPECT_RATIO_IS_EQUAL(a, b)             ((abs((a) - (b))) < (RATIO_MUX / 20))
#define ASPECT_RATIO_IS_EQUAL_16to9(a)          ASPECT_RATIO_IS_EQUAL(a, GET_RATIO(16, 9))
#define ASPECT_RATIO_IS_EQUAL_4to3(a)           ASPECT_RATIO_IS_EQUAL(a, GET_RATIO(4, 3))

#define MAX_MAPPING_MODE_ITEM_NUM 20               /*!< max sensor mapping table item */

/*!
 * \brief Panel Orientation of Sensor
 */
#define PANEL_LEFT  2                               /*!< Panel Left Camera, */
#define PANEL_RIGHT 3                              /*!< Panel Right Camera, */
#define PANEL_FRONT 4                               /*!< Panel Front Camera, User Face */
#define PANEL_BACK  5                               /*!< Panel Back Camera, World Face */

/*!
 * \brief Function Type of Sensor
 */
#define  TYPE_RAW                       0           /*!< Sensor used as a raw sensor */
#define  TYPE_YUV                       1           /*!< Sensor used as a yuv sensor */
#define  TYPE_EXT                       2           /*!< Sensor used as a external ISP*/
#define  TYPE_ET                        3           /*!< Sensor used as an eye track special sensor */
#define  TYPE_MOCK                      4           /*!< Sensor mock */
#define  TYPE_IVCAM_USB_RAW             5           /*!< IVCAM USB RAW sensor */
#define  TYPE_MONOIR                    6           /*!< Sensor used as a mono ir sensor*/
#define  TYPE_MONO                      7           /*!< Sensor used as a mono sensor*/
#define  TYPE_RAWIR                     8           /*!< Sensor used as a rawir sensor*/
#define  TYPE_RGBIR                     9           /*!< Sensor used as a RGB-IR sensor*/
#define  TYPE_TPG                       10          /*!< Sensor used as a mipi-gen, which is not the real sensor*/


/*!
 * \brief Sensor output format
 *
 * \Sensor output format is the same as ISP streaming input format. same as ShCss_input_format data enum
 */
#define INPUT_FORMAT_YUV420_8_LEGACY    0           /*!< 8 bits per subpixel */
#define INPUT_FORMAT_YUV420_8           1           /*!< 8 bits per subpixel */
#define INPUT_FORMAT_YUV420_10          2           /*!< 10 bits per subpixel */
#define INPUT_FORMAT_YUV422_8           3           /*!< UYVY..UVYV, 8 bits per subpixel */
#define INPUT_FORMAT_YUV422_10          4           /*!< UYVY..UVYV, 10 bits per subpixel */
#define INPUT_FORMAT_RGB_444            5           /*!< BGR..BGR, 4 bits per subpixel */
#define INPUT_FORMAT_RGB_555            6           /*!< BGR..BGR, 5 bits per subpixel */
#define INPUT_FORMAT_RGB_565            7           /*!< BGR..BGR, 5 bits B and $, 6 bits G */
#define INPUT_FORMAT_RGB_666            8           /*!< BGR..BGR, 6 bits per subpixel */
#define INPUT_FORMAT_RGB_888            9           /*!< BGR..BGR, 8 bits per subpixel */
#define INPUT_FORMAT_RAW_6              10          /*!< RAW data, 6 bits per pixel */
#define INPUT_FORMAT_RAW_7              11          /*!< RAW data, 7 bits per pixel */
#define INPUT_FORMAT_RAW_8              12          /*!< RAW data, 8 bits per pixel */
#define INPUT_FORMAT_RAW_10             13          /*!< RAW data, 10 bits per pixel */
#define INPUT_FORMAT_RAW_12             14          /*!< RAW data, 12 bits per pixel */
#define INPUT_FORMAT_RAW_14             15          /*!< RAW data, 14 bits per pixel */
#define INPUT_FORMAT_RAW_16             16          /*!< RAW data, 16 bits per pixel */
#define INPUT_FORMAT_BINARY_8           17          /*!< Binary byte stream. */

// Max register numbers for bulk register w/r
#define MAX_BULK_REG_NUM  16

// Max numbers of embedded data members
#define MAX_EMB_DATA_INFO_NUM 253

// The reserve number of MIPI_EXT_DATA
#define RESERVE_MIPI_EXT_DATA_NUM 9

/*!
 * \Brief Sensor PDAF T2 RAW10 support
 *
 * \Describes if long MIPI packets have DT with some other DT format.
 */

typedef enum _ISYS_MIPI_DT_RENAME_MODE
{
        ISYS_MIPI_DT_NO_RENAME = 0,
        ISYS_MIPI_DT_RENAMED_MODE,
        N_ISYS_MIPI_DT_MODE
} ISYS_MIPI_DT_RENAME_MODE;

typedef enum _ISYS_MIPI_USERDEFINE_DATA_TYPE
{
        /* User defined 8-bit data type 1 */
        ISYS_MIPI_DATA_TYPE_USER_DEF1            = 0x30,
        /* User defined 8-bit data type 2 */
        ISYS_MIPI_DATA_TYPE_USER_DEF2            = 0x31,
        /* User defined 8-bit data type 3 */
        ISYS_MIPI_DATA_TYPE_USER_DEF3            = 0x32,
        /* User defined 8-bit data type 4 */
        ISYS_MIPI_DATA_TYPE_USER_DEF4            = 0x33,
        /* User defined 8-bit data type 5 */
        ISYS_MIPI_DATA_TYPE_USER_DEF5            = 0x34,
        /* User defined 8-bit data type 6 */
        ISYS_MIPI_DATA_TYPE_USER_DEF6            = 0x35,
        /* User defined 8-bit data type 7 */
        ISYS_MIPI_DATA_TYPE_USER_DEF7            = 0x36,
        /* User defined 8-bit data type 8 */
        ISYS_MIPI_DATA_TYPE_USER_DEF8            = 0x37,
        /** Reserved 0x38-0x3F */
} ISYS_MIPI_USERDEFINE_DATA_TYPE;


/*!
 * \Brief Sensor mode enum
 *
 * \different sensor mode will have different resolution and configuration support
 */
typedef enum _SNSR_MODE
{
    StillMode,                                      /*!< sensor still mode. */
    VideoMode,                                      /*!< sensor video mode. */
    PreviewMode,                                    /*!< sensor preview mode. */
    RawMode,                                        /*!< sensor raw mode. */
    maxMode,                                         /*!< sensor mode number. */
    StillModeSwitch = 0x11,
    VideoModeSwitch = 0x12,
    PreviewModeSwitch = 0x13,
    RawModeModeSwitch = 0x14,                                         /*!< sensor mode number. */
} SNSR_MODE;

/*!
* \brief Sensor rotation enum
*
* \different sensor rotation (clockwise) will result in different support on pipeline and algorithm
*/
typedef enum _SENSOR_ROTATION
{
    Rotation_0   = 0x00,                                      /*!< rotate 0 degree. */
    Rotation_45  = 0x01,                                      /*!< rotate 45 degree. */
    Rotation_90  = 0x02,                                      /*!< rotate 90 degree. */
    Rotation_135 = 0x03,                                      /*!< rotate 135 degree. */
    Rotation_180 = 0x04,                                      /*!< rotate 180 degree.*/
    Rotation_225 = 0x05,                                      /*!< rotate 225 degree. */
    Rotation_270 = 0x06,                                      /*!< rotate 270 degree. */
    Rotation_315 = 0x07,                                      /*!< rotate 315 degree. */
} SENSOR_ROTATION;

/*!
 * \brief Sensor data input interface type enum
 */
typedef enum
{
    MIPI,                                           /*!< sensor using mipi as data input interface. */
    FIFO                                            /*!< sensor using fifo as data input interface, it is not a real sensor. */
} SNSR_INTERFACE_TYPE;

/*!
 * \brief Sensor data type enum
 */
typedef enum
{
    TPG,                                            /*!< sensor data is TPG, which is not a real sensor. */
    RAW,                                            /*!< sensor data is RAW. */
    SOC,                                            /*!< sensor data is SOC processed data. */
    EXTISP,                                         /*!< sensor data is External ISP processed data. */
    MONOIR,                                         /*!< sensor data is MONO IR. */
    MONO,                                           /*!< sensor data is MONO. */
    RGBIR                                           /*!< sensor data is RGB-IR. */
} SNSR_TYPE;

typedef enum
{
    NO_PDAF_SENSOR = 0,
    PDAF_SENSOR_T1,
    PDAF_SENSOR_T2,
    PDAF_SENSOR_T3,
    SUPPORT_PDAF_SENSOR_NUM
} PDAF_sensor_type;


/*!
 * \brief Shutter Type of Sensor
 */
typedef enum
{
    ROLLING_SHUTTER,                                /*!< Rolling shutter sensor. */
    GLOBAL_SHUTTER                                  /*!< Global shutter sensor. */
} SNSR_SHUTTER_TYPE;

// For Module Auto-detection
#define MODULE_NAME_EEPROM_NOT_SUPPORTED            0x00000000    /*!< No module name info in EEPROM */
#define MODULE_NAME_EEPROM_SUPPORTED                0x00000001    /*!< Module name Info is stored in EEPROM */
#define MODULE_NAME_EEPROM_INUSE                    0x00000002    /*!< Module name from EEPROM is for current use*/
#define MODULE_NAME_EEPROM_FALLBACK                 0x00000004    /*!< Module name from EEPROM is wrong, have fallback to DSDT name*/

/*!
 * \brief Sensor information data structure
 */
#define MAXSTRING_SENSOR    16                      /*!< Max charactor numbers of sensor string. */
#define MAXSTRING_MODULE    64                      /*!< Max charactor numbers of module string. */
#define MAXSTRING_INFO      64                      /*!< Max charactor numbers of information string. */

typedef struct
{
    char eepromModuleName[MAXSTRING_INFO];
    char dsdtModuleName[MAXSTRING_INFO];
    ULONG state;
} MODULE_DETECTION_INFO, *PMODULE_DETECTION_INFO;

typedef struct _SNSR_INFO
{
    GUID guid;                                      /*!< Mandatory. Sensor device GUID. */
    char type;                                      /*!< Mandatory. Sensor output data type. */
    char format;                                    /*!< Mandatory. Sensor output data format. */
    char cmos[MAXSTRING_SENSOR];                    /*!< Mandatory. Name string of cmos. */
    char module[MAXSTRING_MODULE];                  /*!< Mandatory. Name string of module. */
    MODULE_DETECTION_INFO moduleDetectInfo;         /*!< Mandatory. Information for module auto detection.*/
    char info[MAXSTRING_INFO];                      /*!< Mandatory. Name string of platform information. */
    char infosub[MAXSTRING_SENSOR];                   /*!< Mandatory. Name string of platform sub information. */
    char silicon[MAXSTRING_SENSOR];                 /*!< Mandatory. Name string of silicon information. */
    char customer[MAXSTRING_SENSOR];                /*!< Mandatory. Name string of customer information. */
    char controllogic_id;
    ULONG mclk_port;
    WCHAR driverpath[MAX_PATH];
    WCHAR extensionPath[MAX_PATH];
    BOOLEAN EnableStateSeparation;
    UCHAR flashID;
    UCHAR PPRValue;
} SNSR_INFO, *PSNSR_INFO;

/*!
 * \brief Sensor verion information data structure
 */
typedef struct _SNSR_VERSION_INFO
{
    ULONG FwVersion;                               /*!< Optional. Sensor firmware version. */
    ULONG FwRevision;                              /*!< Optional. Sensor firmware revision. */
    ULONG SensorRevision;                          /*!< Optional. Sensor revision. */
    ULONG SensorId;                                /*!< Mandatory. Sensor ID. */
    ULONG ControllerVersion;                       /*!< Optional. Sensor controller version. */
    ULONG ControllerId;                            /*!< Optional. Sensor controller ID. */
    ULONG ControllerRevision;                      /*!< Optional. Sensor controller revision. */
    ULONG SystemClock;                             /*!< Optional. Sensor system clock */
} SNSR_VERSION_INFO;

/*!
 * \brief Sensor resolution information data structure
 */
typedef struct _SNSR_RESOLUTION
{
    ULONG Width;                                    /*!< Mandatory. Sensor resolution width. */
    ULONG Height;                                   /*!< Mandatory. Sensor resolution height. */
    ULONG CropX;                                    /*!< Optional. Sensor resolution crop in width. */
    ULONG CropY;                                    /*!< Optional. Sensor resolution crop in height. */
    LONG  FPS;                                      /*!< Mandatory. Sensor resolution frame number per second. */
    ULONG BayerOrder;                               /*!< Mandatory. Sensor resolution bayer order. */
    ULONG BayerOrder180Degree;                      /*!< Mandatory. Sensor resolution bayer order when image mirror/flip. */
    ULONG IsFullFov;                                /*!< Mandatory. Whether the sensor resolution is full FOV. */
} SNSR_RESOLUTION;

/*!
* \brief framerate mapping information data structure, to support muliptle framerate from single sensor mode
*/

#define MAX_MAPPING_FPS_ITEM_NUM 6                  /*!< Maximum item in mapping table */
#define MAX_MAPPING_FPS_NUM 6                       /*!< Maximum output framerate on each item*/

typedef struct _FPS_MAPPING_ITEM
{
    ULONG width;                                    /*!< Resolution Width */
    ULONG height;                                   /*!< Resolution Height */
    ULONG fps;                                      /*!< Sensor mode framerate*/
    ULONG mappingFPS[MAX_MAPPING_FPS_NUM];          /*!< Output framerate which will be mapped to sensor output */
} FPS_MAPPING_ITEM, *PFPS_MAPPING_ITEM;

typedef struct _FPS_MAPPING_TABLE
{
    BOOL  bExposed;                                                 /*!< is the mapped fps be exposed to end user */
    ULONG count;                                                    /*!< Mapped fps count */
    FPS_MAPPING_ITEM fpsMappingItems[MAX_MAPPING_FPS_ITEM_NUM];     /*!< Mapped fps items */
} FPS_MAPPING_TABLE, *PFPS_MAPPING_TABLE;

/*!
* \brief PDAF data pattern, this should be aligned with ia_css_isys_type_paf
*/

typedef enum
{
    NO_PAF,
    INTERLEAVED_PAF,
    /* PAF data in non-interleaved format(LL/RR or RR/LL) */
    NON_INTERLEAVED_PAF,
    /* Type 3 sensor types , PAF data embedded in Image Frame*/
    /* Frame Embedded PAF in interleaved format(RLRL or LRLR)*/
    FRAME_EMB_INTERLEAVED_PAF,
    /* Frame Embedded PAF non-interleaved format(LL/RR or RR/LL)*/
    FRAME_EMB_NON_INTERLEAVED_PAF,
    N_PATTERN_TYPE_PAF
} PAF_PATTERN_TYPE;

/*!
* \brief PDAF data bpp
*/
typedef enum
{
    PAF_INPUT_BPP_8_BITS = 0,
    PAF_INPUT_BPP_10_BITS
} PAF_INPUT_BPP;

/*!
* \FOLED Major/Secondary Sensor Mode
*/
typedef enum
{
    FOLED_MODE_NONE = 0,
    FOLED_MODE_MAJOR,
    FOLED_MODE_SECONDARY
} FOLED_DEVICE_MODE;

/*!
* \Array sensor caps
*/
typedef enum
{
    ARRAY_SENSOR_NOT_SUPPORT = 0,
    ARRAY_SENSOR_ONE,
    ARRAY_SENSOR_TWO
} ARRAY_SENSOR_CAPS;

/*!
* \Multi stream caps
*/
typedef enum
{
    MULTI_STREAM_NOT_SUPPORT = 0,
    MULTI_STREAM_DOL,
    MULTI_STREAM_OneAIQB_1C_4C1,                         // 0-FHD:4C1                                  FHD-4K:1C
    MULTI_STREAM_OneAIQB_1C_DOL,                         // 0-FHD:DOL                                  FHD-4K:1C
    MULTI_STREAM_OneAIQB_1C_DOL_AutoSwitch,              // 0-FHD:DOL/4C1 (Controlled by KsProperty)   FHD-4K:1C/4C1 (Auto switch)
    MULTI_STREAM_MODE_SWITCH_IOCTL                       // 0-4K: IOCtl controlled 1C/4C1 switch
} MULTI_STREAM_CAPS;

/*!
* \Auto switch exposure adjust method
*/
typedef enum
{
    AGAIN_ONLY = 0,
    EXPOSURE_ONLY,
    AGAIN_AND_EXPOSURE
} AUTO_SWITCH_CONTROL_TYPE;

/*!
 * \EXT_AICAM_CHIP_TYPE is for sensor driver to identify 3rd chip connection per camera link.
 */
typedef enum
{
    EXT_AICAM_CHIP_Unk,
    EXT_AICAM_CHIP_ALTEK_M1,
    EXT_AICAM_CHIP_EMZA_WE1,
    EXT_AICAM_CHIP_HIMAX_EP_II
} EXT_AICAM_CHIP_TYPE;

/*!
* \brief RAW PDAF resolution information data structure, it only be used in PDAF sensor
*/
typedef struct _RAWPDAF_RESOLUTION
{
    ULONG sensorWidth;                              /*!< Mandatory. Sensor resolution width. */
    ULONG sensorHeight;                             /*!< Mandatory. Sensor resolution height. */
    ULONG PDAFWidth;                                /*!< Mandatory. PDAF resolution width. */
    ULONG PDAFHeight;                               /*!< Mandatory. PDAF resolution height. */
    ULONG fps;
} RAWPDAF_RESOLUTION;

/*!
* \brief PDAF resolution information data structure, it only be used in PDAF sensor
*/
typedef struct _PDAF_RESOLUTION
{
    ULONG PDAFWidth;                                /*!< Mandatory. PDAF resolution width. */
    ULONG PDAFHeight;                               /*!< Mandatory. PDAF resolution height. */
    ULONG fps;
} PDAF_RESOLUTION;

typedef struct _PDAF_RESOLUTION_SET
{
    ULONG Count;                                    /*!< Mandatory. Number of sensor PDAF resolutions. */
    PDAF_RESOLUTION* Resolutions;                   /*!< Mandatory. Pointer list of sensor PDAF resolutions. */
} PDAF_RESOLUTION_SET;
/*!
* \brief PDAF Caps information data structure, it only be used in PDAF sensor
*/
typedef struct _PDAF_CAPS
{
    BOOLEAN split_accross_multiple_lines;
    PAF_PATTERN_TYPE input_modes;
    ULONG input_bpp;
    RAWPDAF_RESOLUTION pdaf_resolution;                           /*!< Mandatory. PDAF resolution height. */
    ISYS_MIPI_DT_RENAME_MODE dt_rename_mode;
    ISYS_MIPI_USERDEFINE_DATA_TYPE data_type;
    BOOLEAN virtual_channel_enable;
} PDAF_CAPS;

/*!
 * \brief Sensor resolution set data structure
 */
typedef struct _SNSR_RESOLUTION_SET
{
    ULONG Count;                                    /*!< Mandatory. Number of sensor resolutions. */
    SNSR_RESOLUTION* Resolutions;                   /*!< Mandatory. Pointer list of sensor resolutions. */
} SNSR_RESOLUTION_SET;

#ifdef LNL
/*!
 * \brief Sensor capability data structure for LNL platform
 */
typedef struct _SNSR_CAPS
{
    SNSR_INTERFACE_TYPE InterfaceType;              /*!< Mandatory. Sensor interface type. */
    SNSR_TYPE SensorType;                           /*!< Mandatory. Sensor type. */
    ULONG AspectRatio;                              /*!< Optional. Sensor resolution aspect ratio. */
    ULONG MaxAperture;                              /*!< Optional. */
    ULONG MinAperture;                              /*!< Optional. */
    ULONG MaxExposureTime;                          /*!< Optional. */
    ULONG MinExposureTime;                          /*!< Optional. */
    ULONG MaxGain;                                  /*!< Optional. */
    ULONG MinGain;                                  /*!< Optional. */
    LONG  MaxFocusPos;                              /*!< Optional. */
    LONG  MinFocusPos;                              /*!< Optional. */
    LONG  DefaultFocusPos;                          /*!< Optional. */
    BOOLEAN FocusSupport;                           /*!< Mandatory. Focus support capability. */
    BOOLEAN FlashSupport;                           /*!< Mandatory. Flash support capability. */
    BOOLEAN PreciseScaling;                         /*!< Mandatory. Precise scaling support capability. */
    LONG FovFocalLengthX;                           /*!< Mandatory. Fov focal length in X. */
    LONG FovFocalLengthY;                           /*!< Mandatory. Fov focal length in Y. */
    LONG CamAngleOffsetPitch;                       /*!< Mandatory. Camera angle offset pitch. */
    LONG CamAngleOffsetYaw;                         /*!< Mandatory. Camera angle offset yaw. */
    ULONG EmbeddedLineNum;                          /*!< Mandatory. Embedded line number. */
    ULONG SkipFramesStill;                          /*!< Optional. */
    ULONG SkipFramesCapture;                        /*!< Optional. */
    ULONG AeFrameStore;                             /*!< Optional. */
    ULONG NoDPC;                                    /*!< Optional. */
    ULONG PDAFType;                                 /*!< Optional. */
    ULONG PDAFLineNum;                              /*!< Optional. */
    ULONG ExposeHighFpsPreviewStill;                /*!< Optional. */
    SNSR_SHUTTER_TYPE ShutterType;                  /*!< Optional */
    BOOLEAN P10bitSupport;                          /*!< Optional */
    BOOLEAN BISPSupport;                            /*!< Optional */
    UCHAR CVFSupport;                               /*!< Optional. Support CVF-IPU interface. */
    UCHAR FOLEDSensorMode;                          /*!< Optional. FOLED master/slave sensor. */
    BOOLEAN StillTnrSupport;                        /*!< Optional */
    BOOLEAN StillHdrSupport;                        /*!< Optional */
    UCHAR ArraySensorSupport;                       /*!< Optional. Array sensor support capability.*/
    ULONG isEnabledCBD;                             /*!< Optional. */
    UCHAR MultiStreamSupport;                       /*!< Optional. Multi stream support capability.(stagger hdr/auto switch)*/
    BOOLEAN JointPipeSupport;
    EXT_AICAM_CHIP_TYPE AIChipType;                 /*!< Optional. Type of external AI chips. */
    BOOLEAN SuperSensorSupport;                     /*!< Optional. Super sensor support capability.*/
    ULONG LDCType;                                  /*!< Optional. MSFT LDC feautre enable flag*/
    ULONG EnableVAI;                                /*!< Optional. Enable VAI flag*/
    ULONG OpticalCenterOffsets;                     /*!< Optional. Combined optical center offsets in calibration data.*/
    ULONG Reserved[16]; // NOLINT                   /*!< Optional.*/
} SNSR_CAPS;

#else
/*!
 * \brief Sensor capability data structure for NON-LNL platform
 */
typedef struct _SNSR_CAPS
{
    SNSR_INTERFACE_TYPE InterfaceType;              /*!< Mandatory. Sensor interface type. */
    SNSR_TYPE SensorType;                           /*!< Mandatory. Sensor type. */
    ULONG AspectRatio;                              /*!< Optional. Sensor resolution aspect ratio. */
    ULONG MaxAperture;                              /*!< Optional. */
    ULONG MinAperture;                              /*!< Optional. */
    ULONG MaxExposureTime;                          /*!< Optional. */
    ULONG MinExposureTime;                          /*!< Optional. */
    ULONG MaxGain;                                  /*!< Optional. */
    ULONG MinGain;                                  /*!< Optional. */
    LONG  MaxFocusPos;                              /*!< Optional. */
    LONG  MinFocusPos;                              /*!< Optional. */
    LONG  DefaultFocusPos;                          /*!< Optional. */
    BOOLEAN FocusSupport;                           /*!< Mandatory. Focus support capability. */
    BOOLEAN FlashSupport;                           /*!< Mandatory. Flash support capability. */
    BOOLEAN PreciseScaling;                         /*!< Mandatory. Precise scaling support capability. */
    LONG FovFocalLengthX;                           /*!< Mandatory. Fov focal length in X. */
    LONG FovFocalLengthY;                           /*!< Mandatory. Fov focal length in Y. */
    LONG CamAngleOffsetPitch;                       /*!< Mandatory. Camera angle offset pitch. */
    LONG CamAngleOffsetYaw;                         /*!< Mandatory. Camera angle offset yaw. */
    ULONG EmbeddedLineNum;                          /*!< Mandatory. Embedded line number. */
    ULONG SkipFramesStill;                          /*!< Optional. */
    ULONG SkipFramesCapture;                        /*!< Optional. */
    ULONG AeFrameStore;                             /*!< Optional. */
    ULONG NoDPC;                                    /*!< Optional. */
    ULONG PDAFType;                                 /*!< Optional. */
    ULONG PDAFLineNum;                              /*!< Optional. */
    ULONG ExposeHighFpsPreviewStill;                /*!< Optional. */
    SNSR_SHUTTER_TYPE ShutterType;                  /*!< Optional */
    BOOLEAN P10bitSupport;                          /*!< Optional */
    BOOLEAN BISPSupport;                            /*!< Optional */
    UCHAR CVFSupport;                               /*!< Optional. Support CVF-IPU interface. */
    UCHAR FOLEDSensorMode;                          /*!< Optional. FOLED master/slave sensor. */
    BOOLEAN StillTnrSupport;                        /*!< Optional */
    BOOLEAN StillHdrSupport;                        /*!< Optional */
    UCHAR ArraySensorSupport;                       /*!< Optional. Array sensor support capability.*/
    ULONG isEnabledCBD;                             /*!< Optional. */
    UCHAR MultiStreamSupport;                       /*!< Optional. Multi stream support capability.(stagger hdr/auto switch)*/
    BOOLEAN JointPipeSupport;
    BOOLEAN SuperSensorSupport;                     /*!< Optional. Super sensor support capability.*/
    ULONG LDCType;                                  /*!< Optional. MSFT LDC feautre enable flag*/
    ULONG EnableVAI;                                /*!< Optional. Enable VAI flag*/
    ULONG OpticalCenterOffsets;                     /*!< Optional. Combined optical center offsets in calibration data.*/
    ULONG Reserved[16]; // NOLINT                   /*!< Optional.*/
} SNSR_CAPS;
#endif

/*!
 * \brief Sensor caps extension
 * This extension definition allows sensor driver to extend more sensor caps but keep
 * sensor API interface compatible between ISP and sensor driver.
 * Notes: all new definition is expected to give an explicit ID number.
 */
typedef enum _SNSR_CAPS_EXT_ID
{
    EXT_CAPS_VERSION = 0,                          /*!< EXT_CAPS version, initial version is 0x1 */
} SNSR_CAPS_EXT_ID;

/*!
 * \brief Sensor caps extension type
 */
typedef enum _SNSR_CAPS_EXT_TYPE
{
    EXT_CAPS_TYPE_ULONG = 0,
    EXT_CAPS_TYPE_LONG  = 1,
} SNSR_CAPS_EXT_TYPE;

/*!
 * \brief Sensor ext stop state type
 * Sensor boot to LP111 or LP000
 */
typedef enum _SNSR_MIPI_STOPSTATE_TYPE
{
    EXT_BOOT_STOPSTATE_LP111 = 0,
    EXT_BOOT_STOPSTATE_LP000 = 1,
} SNSR_MIPI_STOPSTATE_TYPE;

/*!
 * \brief Sensor caps extension data
 */
typedef union _SNSR_CAPS_EXT_DATA
{
    ULONG ulValue;                                /*!< ULONG value */
    LONG  lValue;                                 /*!< LONG value */
    ULONG Reserved[4];                            /*!< not used, reserved as data struct size */
} SNSR_CAPS_EXT_DATA;

/*!
 * \brief Sensor mipi extension data
 */
typedef struct _SNSR_MIPI_EXT_DATA
{
    ULONG Port;
    ULONG LaneNum;
    ULONG OutputFormat;
    ULONG Type;
    ULONG PhyConfig;                             /*!< 0-DPHY, 1-CPHY */
    ULONG LaneConfiguration;                     /*!< the trios or lane combination. range from 0x0 to 0xF */
    ULONG StopStateType;                         /*!< if boot to stop state LP000/LP111 >*/
    ULONG Reserved[RESERVE_MIPI_EXT_DATA_NUM];   /*!< not used, reserved as data struct size */
} SNSR_MIPI_EXT_DATA;

/*!
 * \brief Sensor exposure and gain data structure
 */
typedef struct _SNSR_EXPOSURE
{
    USHORT FineIntegrationTime;                     /*!< Mandatory. Fine exposure time. */
    USHORT CoarseIntegrationTime;                   /*!< Mandatory. Coarse exposre time. */
    USHORT AnalogGain;                              /*!< Mandatory. Analog gain. */
    USHORT DigitalGain;                             /*!< Mandatory. Digital gain. */
    USHORT LineLengthPixels;                        /*!< Mandatory. LineLengthPixels. */
    USHORT FrameLengthLines;                        /*!< Mandatory. Frame length lines. */
} SNSR_EXPOSURE;

/*!
* \brief Sensor exposure and gain data structure
*/
typedef struct _SENSOR_MODE_DATA
{
    unsigned int VtPixClkFreqHz;                    /*!< Mandatory. Sensor pixel clock in Hz. */
    USHORT LineLengthPck;                           /*!< Mandatory. Sensor HTS. */
    USHORT FrameLengthLines;                        /*!< Mandatory. Sensor VTS. */
    USHORT FineIntegrationTimeMin;                  /*!< Mandatory. Sensor exposure fine min value. */
    USHORT FineIntegrationTimeMaxMargin;            /*!< Mandatory. Sensor exposure fine max margin. */
    USHORT CoarseIntegrationTimeMin;                /*!< Mandatory. Sensor exposure coarse min value. */
    USHORT CoarseIntegrationTimeMaxMargin;          /*!< Mandatory. Sensor exposure coarse max margin. */
    USHORT CropHorizontalStart;                     /*!< Mandatory. Sensor crop start cord. (x0,y0) */
    USHORT CropVerticalStart;                       /*!< Mandatory. Sensor crop start cord. (x0,y0) */
    USHORT CropHorizontal_end;                      /*!< Mandatory. Sensor crop end cord. (x1,y1) */
    USHORT CropVertical_end;                        /*!< Mandatory. Sensor crop end cord. (x1,y1) */
    USHORT OutputWidth;                             /*!< Mandatory. Sensor output size to ISP after binning/scaling */
    USHORT OutputHeight;                            /*!< Mandatory. Sensor output size to ISP after binning/scaling */
    UCHAR  BinningFactorX;                          /*!< Mandatory. Sensor horizontal binning factor used */
    UCHAR  BinningFactorY;                          /*!< Mandatory. Sensor vertical binning factor used */
    USHORT IspEffectiveInputWidth;                  /*!< Mandatory. ISP input size */
    USHORT IspEffectiveInputHeight;                 /*!< Mandatory. ISP input size */
    USHORT IspOutputWidth;                          /*!< Mandatory. ISP output size */
    USHORT IspOutputheight;                         /*!< Mandatory. ISP output size */
} SENSOR_MODE_DATA, *PSENSOR_MODE_DATA;

/*!
* \brief Sensor vcm init data data structure
*/
typedef struct _SNSR_VCMDATA
{
    ULONG Count;                                    /*!< Mandatory. Sensor vcm date number */
    struct
    {
        ULONG Index;                                /*!< Mandatory. Vcm setting index */
        ULONG Value;                                /*!< Mandatory. Vcm setting value */
    } data[1];
} SNSR_VCMDATA;

/*!
 * \brief SEND_INPUT_IMAGE function.
 * This function is called to send input image.
 *
 * \param[in]     stream            Mandatory.\n
 *                                  The pointer of stream.
 * \param[in]     data              Mandatory.\n
 *                                  The pointer of data.
 * \param[out]    width             Mandatory.\n
 *                                  The image width.
 * \param[out]    height            Mandatory.\n
 *                                  The image height.
 */
typedef
void
(*SEND_INPUT_IMAGE) (
    const void *Stream,
    const unsigned short *Data,
    unsigned int Width,
    unsigned int Height
    );

#pragma warning(disable : 4214)

/* \brief Sensor lock value sturcture
*/
typedef struct _SNSR_LOCK_VALUE
{
    BOOLEAN bEnabled;
    USHORT Value;
} SNSR_LOCK_VALUE;

/*!
* \brief Sensor lock params enum
*/
typedef enum _SNSR_ID_LOCK_PARAMS_VALUES
{
    SNSR_LOCK_PARAMS_FRAME_LENGTH_LINES = 0,
    SNSR_LOCK_PARAMS_COARSE_INTEGRATION,
    SNSR_LOCK_PARAMS_ANALOG_GAIN,
    SNSR_LOCK_PARAMS_DIGITAL_GAIN,
    SNSR_LOCK_PARAMS_MAX
} SNSR_ID_LOCK_PARAMS_VALUES;

/*!
* \brief Sensor lock params sturcture
*/
typedef struct _SNSR_LOCK_PARAMS
{
    SNSR_LOCK_VALUE Lock[SNSR_LOCK_PARAMS_MAX];
} SNSR_LOCK_PARAMS, *PSNSR_LOCK_PARAMS;

typedef enum __SNSR_EXT_FEATURE_PRIVACY_LED_STATE
{
    SNSR_EXT_FEATURE_PRIVACY_LED_OFF,
    SNSR_EXT_FEATURE_PRIVACY_LED_ON,
} SNSR_EXT_FEATURE_PRIVACY_LED_STATE;

//Test mode params
typedef struct _SNSR_TESTMODE_PARAMS_
{
    BOOLEAN Enabled;
    ULONG Value;
} SNSR_TESTMODE_PARAMS, *PSNSR_TESTMODE_PARAMS;

//Specify position in X,Y
typedef struct
{
    ULONG dwXPos; //X Position
    ULONG dwYPos; //Y Position
} SNSR_EXT_FEATURE_ROI_POINT, *PSNSR_EXT_FEATURE_ROI_POINT;

//Specify ROI Window
typedef struct
{
    SNSR_EXT_FEATURE_ROI_POINT TLPoint; //Top left
    SNSR_EXT_FEATURE_ROI_POINT BRPoint; //Bottom Right
} SNSR_EXT_FEATURE_ROI_WINDOW, *PSNSR_EXT_FEATURE_ROI_WINDOW;

//Sensor Binning mode
typedef enum
{
    SNSR_EXT_FEATURE_ROI_SENSOR_BINNING_1x1 = 1,
    SNSR_EXT_FEATURE_ROI_SENSOR_BINNING_2x2,
    SNSR_EXT_FEATURE_ROI_SENSOR_BINNING_3x3,
    SNSR_EXT_FEATURE_ROI_SENSOR_BINNING_MAX
} SNSR_EXT_FEATURE_ROI_SENSOR_BINNING_VALUE, *PSNSR_EXT_FEATURE_ROI_SENSOR_BINNING_VALUE;

//ROI params
typedef struct
{
    SNSR_EXT_FEATURE_ROI_SENSOR_BINNING_VALUE Binning; //Current sensor binning mode
    SNSR_EXT_FEATURE_ROI_WINDOW ActiveROI; //Active ROI
    SNSR_EXT_FEATURE_ROI_WINDOW FullROI; //Full sensor ROI
} SNSR_EXT_FEATURE_ROI_PARAMS, *PSNSR_EXT_FEATURE_ROI_PARAMS;


typedef struct
{
    UINT8 closed_loop_hall_offset_vert;             /*!< vertical distance b/w Hall sensor and Magnet */
    UINT8 closed_loop_hall_bias_horz;               /*!< horizontal distance b/w Hall sensor and Magnet */
    UINT8 pdaf_ps_sensor_modes;                     /*!< number of sensor modes calibrated for PS */
    UINT8 pdaf_ps_knots_width;                      /*!< number of PS knots across width */
    UINT8 pdaf_ps_knots_height;                     /*!< number of PS knots across height */
    UINT8 pdaf_ps_frac_bits;                        /*!< PS Fractional Bit depth */
    UINT16* pdaf_ps_tables;                         /*!< PS Gain tables for Left Pixels */
} SNSR_CALIBRATION_DATA;

typedef
BOOL
(*PCAMERA_SET_PRIVACY_MODE)(
    void *Context,
    BOOL PrivacyState
    );

typedef struct _FEATURE_PRIVACY_MODE
{
    PCAMERA_SET_PRIVACY_MODE Callback;
    PVOID Context;
} FEATURE_PRIVACY_MODE;

typedef struct _EMB_DATA_INFO
{
    UINT32 DataFormat;
    UINT32 FrameCountOffset;
    UINT32 FrameCounterStartId;
    UINT32 Reserved[MAX_EMB_DATA_INFO_NUM];
} EMB_DATA_INFO;

typedef enum
{
    SREG_8BIT,
    SREG_16BIT,
    SREG_32BIT,
} SREG_BIT_WIDTH;

typedef struct
{
    UINT16 address;
    UINT16 width; /* SREG_BIT_WIDTH */
    UINT32 value;
} SNSR_REG;

typedef struct
{
    SNSR_REG Regs[MAX_BULK_REG_NUM];
    UINT32 RegNum;
    UINT32 Reserved;
} SNSR_REG_LIST, *PSNSR_REG_LIST;

typedef
BOOL
(*PCAMERA_SET_FLIP_MODE)(
    void *Context,
    UINT angle
    );

typedef struct _FEATURE_FLIP_MODE
{
    PCAMERA_SET_FLIP_MODE Callback;
    PVOID Context;
} FEATURE_FLIP_MODE;

typedef
void
(*PCAMERA_HDMI_STATUS_UPDATE)(
    void *Context,
    ULONG event,
    DWORD format,
    ULONG width,
    ULONG height,
    ULONG fps
    );

typedef struct _FEATURE_HDMI_STATUS_UPDATE
{
    PCAMERA_HDMI_STATUS_UPDATE Callback;
    PVOID Context;
} FEATURE_HDMI_STATUS_UPDATE;

typedef enum _HDMI_STATUS_FLAG
{
    HDMI_RESOLUTION_CHANGE_FLAG = 1 << 0,
    HDMI_PLUG_OFF_FLAG = 1 << 1,
    HDMI_PLUG_IN_FLAG = 1 << 2,
    HDMI_DISCONNECT = 1 << 3
} HDMI_STATUS_FLAG;

typedef struct _SNSR_MULTI_MODE_MAPPING_ITEM
{
    ULONG width;
    ULONG height;
    ULONG fps;
    ULONG ModesSupported;
    ULONG ModeControl;
    ULONG Reserved[8];
} SNSR_MULTI_MODE_MAPPING_ITEM, *PSNSR_MULTI_MODE_MAPPING_ITEM;

typedef struct _SNSR_MODE_MAPPING_TABLE
{
    ULONG count;                                                                       /*!< Mapped item count */
    SNSR_MULTI_MODE_MAPPING_ITEM MultiModeMappingItems[MAX_MAPPING_MODE_ITEM_NUM];     /*!< Mapped mode items */
} SNSR_MODE_MAPPING_TABLE, *PSNSR_MODE_MAPPING_TABLE;

typedef enum  _SENSOR_MODE_TYPE
{
    NORMAL = 0,          // SNR_MODE_1C
    FOURC1_BINNING,      // SNR_MODE_4C1
    STAGGER_HDR,         // SNR_MODE_4C1_DOL
    FOURC1_UPSCALE,
    NORMAL_FS,
    FOURC1_BINNING_FS,
    MODE_END
} SENSOR_MODE_TYPE;

typedef enum _SENSOR_MODE_CTL
{
    SNR_MODE_CTL_NONE = 0,
    SNR_MODE_CTL_AUTO,
    SNR_MODE_CTL_KS,
    SNR_MODE_CTL_IOCTL
} SENSOR_MODE_CTL;

typedef struct _LENS_DATA_INFO
{
    UINT32 LensIdOffset;
    UINT8  SecondSourceLensId;
} LENS_DATA_INFO;

typedef struct _MODULE_LENS_MAPPING
{
    CHAR *ModuleName;
    UINT8 LensId;
} MODULE_LENS_MAPPING;

#include "sensor_feature.h"
#include "sensor_skycam.h"

#endif
