Home | History | Annotate | Download | only in common
      1 /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
      2  *
      3  * Redistribution and use in source and binary forms, with or without
      4  * modification, are permitted provided that the following conditions are
      5  * met:
      6  *     * Redistributions of source code must retain the above copyright
      7  *       notice, this list of conditions and the following disclaimer.
      8  *     * Redistributions in binary form must reproduce the above
      9  *       copyright notice, this list of conditions and the following
     10  *       disclaimer in the documentation and/or other materials provided
     11  *       with the distribution.
     12  *     * Neither the name of The Linux Foundation nor the names of its
     13  *       contributors may be used to endorse or promote products derived
     14  *       from this software without specific prior written permission.
     15  *
     16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  *
     28  */
     29 
     30 #ifndef __QCAMERA_TYPES_H__
     31 #define __QCAMERA_TYPES_H__
     32 
     33 #include <stdint.h>
     34 #include <pthread.h>
     35 #include <inttypes.h>
     36 #include <media/msmb_camera.h>
     37 
     38 #define CAM_MAX_NUM_BUFS_PER_STREAM 24
     39 #define MAX_METADATA_PAYLOAD_SIZE 1024
     40 
     41 #define CEILING32(X) (((X) + 0x0001F) & 0xFFFFFFE0)
     42 #define CEILING16(X) (((X) + 0x000F) & 0xFFF0)
     43 #define CEILING4(X)  (((X) + 0x0003) & 0xFFFC)
     44 #define CEILING2(X)  (((X) + 0x0001) & 0xFFFE)
     45 
     46 #define MAX_ZOOMS_CNT 64
     47 #define MAX_SIZES_CNT 24
     48 #define MAX_EXP_BRACKETING_LENGTH 32
     49 #define MAX_ROI 5
     50 #define MAX_STREAM_NUM_IN_BUNDLE 4
     51 #define MAX_NUM_STREAMS          8
     52 #define MAX_TEST_PATTERN_CNT     8
     53 #define MAX_AVAILABLE_CAPABILITIES 4
     54 
     55 #define GPS_PROCESSING_METHOD_SIZE 33
     56 
     57 typedef enum {
     58     CAM_HAL_V1 = 1,
     59     CAM_HAL_V3 = 3
     60 } cam_hal_version_t;
     61 
     62 typedef enum {
     63     CAM_STATUS_SUCCESS,       /* Operation Succeded */
     64     CAM_STATUS_FAILED,        /* Failure in doing operation */
     65     CAM_STATUS_INVALID_PARM,  /* Inavlid parameter provided */
     66     CAM_STATUS_NOT_SUPPORTED, /* Parameter/operation not supported */
     67     CAM_STATUS_ACCEPTED,      /* Parameter accepted */
     68     CAM_STATUS_MAX,
     69 } cam_status_t;
     70 
     71 typedef enum {
     72     CAM_POSITION_BACK,
     73     CAM_POSITION_FRONT
     74 } cam_position_t;
     75 
     76 typedef enum {
     77     CAM_FLICKER_NONE,
     78     CAM_FLICKER_50_HZ,
     79     CAM_FLICKER_60_HZ
     80 } cam_flicker_t;
     81 
     82 typedef enum {
     83     CAM_FORMAT_JPEG = 0,
     84     CAM_FORMAT_YUV_420_NV12 = 1,
     85     CAM_FORMAT_YUV_420_NV21,
     86     CAM_FORMAT_YUV_420_NV21_ADRENO,
     87     CAM_FORMAT_YUV_420_YV12,
     88     CAM_FORMAT_YUV_422_NV16,
     89     CAM_FORMAT_YUV_422_NV61,
     90     CAM_FORMAT_YUV_420_NV12_VENUS,
     91 
     92     /* Please note below are the defintions for raw image.
     93      * Any format other than raw image format should be declared
     94      * before this line!!!!!!!!!!!!! */
     95 
     96     /* Note: For all raw formats, each scanline needs to be 16 bytes aligned */
     97 
     98     /* Packed YUV/YVU raw format, 16 bpp: 8 bits Y and 8 bits UV.
     99      * U and V are interleaved with Y: YUYV or YVYV */
    100     CAM_FORMAT_YUV_RAW_8BIT_YUYV,
    101     CAM_FORMAT_YUV_RAW_8BIT_YVYU,
    102     CAM_FORMAT_YUV_RAW_8BIT_UYVY,
    103     CAM_FORMAT_YUV_RAW_8BIT_VYUY,
    104 
    105     /* QCOM RAW formats where data is packed into 64bit word.
    106      * 8BPP: 1 64-bit word contains 8 pixels p0 - p7, where p0 is
    107      *       stored at LSB.
    108      * 10BPP: 1 64-bit word contains 6 pixels p0 - p5, where most
    109      *       significant 4 bits are set to 0. P0 is stored at LSB.
    110      * 12BPP: 1 64-bit word contains 5 pixels p0 - p4, where most
    111      *       significant 4 bits are set to 0. P0 is stored at LSB. */
    112     CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG,
    113     CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GRBG,
    114     CAM_FORMAT_BAYER_QCOM_RAW_8BPP_RGGB,
    115     CAM_FORMAT_BAYER_QCOM_RAW_8BPP_BGGR,
    116     CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG,
    117     CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GRBG,
    118     CAM_FORMAT_BAYER_QCOM_RAW_10BPP_RGGB,
    119     CAM_FORMAT_BAYER_QCOM_RAW_10BPP_BGGR,
    120     CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG,
    121     CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GRBG,
    122     CAM_FORMAT_BAYER_QCOM_RAW_12BPP_RGGB,
    123     CAM_FORMAT_BAYER_QCOM_RAW_12BPP_BGGR,
    124     /* MIPI RAW formats based on MIPI CSI-2 specifiction.
    125      * 8BPP: Each pixel occupies one bytes, starting at LSB.
    126      *       Output with of image has no restrictons.
    127      * 10BPP: Four pixels are held in every 5 bytes. The output
    128      *       with of image must be a multiple of 4 pixels.
    129      * 12BPP: Two pixels are held in every 3 bytes. The output
    130      *       width of image must be a multiple of 2 pixels. */
    131     CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG,
    132     CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GRBG,
    133     CAM_FORMAT_BAYER_MIPI_RAW_8BPP_RGGB,
    134     CAM_FORMAT_BAYER_MIPI_RAW_8BPP_BGGR,
    135     CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG,
    136     CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GRBG,
    137     CAM_FORMAT_BAYER_MIPI_RAW_10BPP_RGGB,
    138     CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR,
    139     CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG,
    140     CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GRBG,
    141     CAM_FORMAT_BAYER_MIPI_RAW_12BPP_RGGB,
    142     CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR,
    143     /* Ideal raw formats where image data has gone through black
    144      * correction, lens rolloff, demux/channel gain, bad pixel
    145      * correction, and ABF.
    146      * Ideal raw formats could output any of QCOM_RAW and MIPI_RAW
    147      * formats, plus plain8 8bbp, plain16 800, plain16 10bpp, and
    148      * plain 16 12bpp */
    149     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GBRG,
    150     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GRBG,
    151     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_RGGB,
    152     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_BGGR,
    153     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GBRG,
    154     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GRBG,
    155     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_RGGB,
    156     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_BGGR,
    157     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GBRG,
    158     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GRBG,
    159     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_RGGB,
    160     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_BGGR,
    161     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GBRG,
    162     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GRBG,
    163     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_RGGB,
    164     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_BGGR,
    165     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GBRG,
    166     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GRBG,
    167     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_RGGB,
    168     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_BGGR,
    169     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GBRG,
    170     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GRBG,
    171     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_RGGB,
    172     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_BGGR,
    173     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GBRG,
    174     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GRBG,
    175     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_RGGB,
    176     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_BGGR,
    177     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG,
    178     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GRBG,
    179     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_RGGB,
    180     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_BGGR,
    181     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GBRG,
    182     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GRBG,
    183     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_RGGB,
    184     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_BGGR,
    185     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GBRG,
    186     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GRBG,
    187     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_RGGB,
    188     CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR,
    189 
    190     /* generic 8-bit raw */
    191     CAM_FORMAT_JPEG_RAW_8BIT,
    192     CAM_FORMAT_META_RAW_8BIT,
    193 
    194     CAM_FORMAT_MAX
    195 } cam_format_t;
    196 
    197 typedef enum {
    198     /* applies to HAL 1 */
    199     CAM_STREAM_TYPE_DEFAULT,       /* default stream type */
    200     CAM_STREAM_TYPE_PREVIEW,       /* preview */
    201     CAM_STREAM_TYPE_POSTVIEW,      /* postview */
    202     CAM_STREAM_TYPE_SNAPSHOT,      /* snapshot */
    203     CAM_STREAM_TYPE_VIDEO,         /* video */
    204 
    205     /* applies to HAL 3 */
    206     CAM_STREAM_TYPE_CALLBACK,      /* app requested callback */
    207     CAM_STREAM_TYPE_NON_ZSL_SNAPSHOT, /* non zsl snapshot */
    208     CAM_STREAM_TYPE_IMPL_DEFINED, /* opaque format: could be display, video enc, ZSL YUV */
    209 
    210     /* applies to both HAL 1 and HAL 3 */
    211     CAM_STREAM_TYPE_METADATA,      /* meta data */
    212     CAM_STREAM_TYPE_RAW,           /* raw dump from camif */
    213     CAM_STREAM_TYPE_OFFLINE_PROC,  /* offline process */
    214     CAM_STREAM_TYPE_MAX,
    215 } cam_stream_type_t;
    216 
    217 typedef enum {
    218     CAM_PAD_NONE = 1,
    219     CAM_PAD_TO_2 = 2,
    220     CAM_PAD_TO_4 = 4,
    221     CAM_PAD_TO_WORD = CAM_PAD_TO_4,
    222     CAM_PAD_TO_8 = 8,
    223     CAM_PAD_TO_16 = 16,
    224     CAM_PAD_TO_32 = 32,
    225     CAM_PAD_TO_64 = 64,
    226     CAM_PAD_TO_1K = 1024,
    227     CAM_PAD_TO_2K = 2048,
    228     CAM_PAD_TO_4K = 4096,
    229     CAM_PAD_TO_8K = 8192
    230 } cam_pad_format_t;
    231 
    232 typedef enum {
    233     /* followings are per camera */
    234     CAM_MAPPING_BUF_TYPE_CAPABILITY,  /* mapping camera capability buffer */
    235     CAM_MAPPING_BUF_TYPE_PARM_BUF,    /* mapping parameters buffer */
    236 
    237     /* followings are per stream */
    238     CAM_MAPPING_BUF_TYPE_STREAM_BUF,        /* mapping stream buffers */
    239     CAM_MAPPING_BUF_TYPE_STREAM_INFO,       /* mapping stream information buffer */
    240     CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF, /* mapping offline process input buffer */
    241     CAM_MAPPING_BUF_TYPE_MAX
    242 } cam_mapping_buf_type;
    243 
    244 typedef struct {
    245     cam_mapping_buf_type type;
    246     uint32_t stream_id;   /* stream id: valid if STREAM_BUF */
    247     uint32_t frame_idx;   /* frame index: valid if type is STREAM_BUF */
    248     int32_t plane_idx;    /* planner index. valid if type is STREAM_BUF.
    249                            * -1 means all planners shanre the same fd;
    250                            * otherwise, each planner has its own fd */
    251     unsigned long cookie; /* could be job_id(uint32_t) to identify mapping job */
    252     int fd;               /* origin fd */
    253     uint32_t size;        /* size of the buffer */
    254 } cam_buf_map_type;
    255 
    256 typedef struct {
    257     cam_mapping_buf_type type;
    258     uint32_t stream_id;   /* stream id: valid if STREAM_BUF */
    259     uint32_t frame_idx;   /* frame index: valid if STREAM_BUF or HIST_BUF */
    260     int32_t plane_idx;    /* planner index. valid if type is STREAM_BUF.
    261                            * -1 means all planners shanre the same fd;
    262                            * otherwise, each planner has its own fd */
    263     unsigned long cookie; /* could be job_id(uint32_t) to identify unmapping job */
    264 } cam_buf_unmap_type;
    265 
    266 typedef enum {
    267     CAM_MAPPING_TYPE_FD_MAPPING,
    268     CAM_MAPPING_TYPE_FD_UNMAPPING,
    269     CAM_MAPPING_TYPE_MAX
    270 } cam_mapping_type;
    271 
    272 typedef struct {
    273     cam_mapping_type msg_type;
    274     union {
    275         cam_buf_map_type buf_map;
    276         cam_buf_unmap_type buf_unmap;
    277     } payload;
    278 } cam_sock_packet_t;
    279 
    280 typedef enum {
    281     CAM_MODE_2D = (1<<0),
    282     CAM_MODE_3D = (1<<1)
    283 } cam_mode_t;
    284 
    285 typedef struct {
    286     uint32_t len;
    287     uint32_t y_offset;
    288     uint32_t cbcr_offset;
    289 } cam_sp_len_offset_t;
    290 
    291 typedef struct{
    292     uint32_t len;
    293     uint32_t offset;
    294     int32_t offset_x;
    295     int32_t offset_y;
    296     int32_t stride;
    297     int32_t scanline;
    298 } cam_mp_len_offset_t;
    299 
    300 typedef struct {
    301     uint32_t width_padding;
    302     uint32_t height_padding;
    303     uint32_t plane_padding;
    304 } cam_padding_info_t;
    305 
    306 typedef struct {
    307     int num_planes;
    308     union {
    309         cam_sp_len_offset_t sp;
    310         cam_mp_len_offset_t mp[VIDEO_MAX_PLANES];
    311     };
    312     uint32_t frame_len;
    313 } cam_frame_len_offset_t;
    314 
    315 typedef struct {
    316     int32_t width;
    317     int32_t height;
    318 } cam_dimension_t;
    319 
    320 typedef struct {
    321     cam_frame_len_offset_t plane_info;
    322 } cam_stream_buf_plane_info_t;
    323 
    324 typedef struct {
    325     float min_fps;
    326     float max_fps;
    327 } cam_fps_range_t;
    328 
    329 typedef struct {
    330     int32_t min_sensitivity;
    331     int32_t max_sensitivity;
    332 } cam_sensitivity_range_t;
    333 
    334 typedef enum {
    335     CAM_HFR_MODE_OFF,
    336     CAM_HFR_MODE_60FPS,
    337     CAM_HFR_MODE_90FPS,
    338     CAM_HFR_MODE_120FPS,
    339     CAM_HFR_MODE_150FPS,
    340     CAM_HFR_MODE_MAX
    341 } cam_hfr_mode_t;
    342 
    343 typedef struct {
    344     cam_hfr_mode_t mode;
    345     cam_dimension_t dim;
    346     uint8_t frame_skip;
    347     uint8_t livesnapshot_sizes_tbl_cnt;                     /* livesnapshot sizes table size */
    348     cam_dimension_t livesnapshot_sizes_tbl[MAX_SIZES_CNT];  /* livesnapshot sizes table */
    349 } cam_hfr_info_t;
    350 
    351 typedef enum {
    352     CAM_WB_MODE_AUTO,
    353     CAM_WB_MODE_CUSTOM,
    354     CAM_WB_MODE_INCANDESCENT,
    355     CAM_WB_MODE_FLUORESCENT,
    356     CAM_WB_MODE_WARM_FLUORESCENT,
    357     CAM_WB_MODE_DAYLIGHT,
    358     CAM_WB_MODE_CLOUDY_DAYLIGHT,
    359     CAM_WB_MODE_TWILIGHT,
    360     CAM_WB_MODE_SHADE,
    361     CAM_WB_MODE_OFF,
    362     CAM_WB_MODE_MAX
    363 } cam_wb_mode_type;
    364 
    365 typedef enum {
    366     CAM_ANTIBANDING_MODE_OFF,
    367     CAM_ANTIBANDING_MODE_60HZ,
    368     CAM_ANTIBANDING_MODE_50HZ,
    369     CAM_ANTIBANDING_MODE_AUTO,
    370     CAM_ANTIBANDING_MODE_AUTO_50HZ,
    371     CAM_ANTIBANDING_MODE_AUTO_60HZ,
    372     CAM_ANTIBANDING_MODE_MAX,
    373 } cam_antibanding_mode_type;
    374 
    375 /* Enum Type for different ISO Mode supported */
    376 typedef enum {
    377     CAM_ISO_MODE_AUTO,
    378     CAM_ISO_MODE_DEBLUR,
    379     CAM_ISO_MODE_100,
    380     CAM_ISO_MODE_200,
    381     CAM_ISO_MODE_400,
    382     CAM_ISO_MODE_800,
    383     CAM_ISO_MODE_1600,
    384     CAM_ISO_MODE_MAX
    385 } cam_iso_mode_type;
    386 
    387 typedef enum {
    388     CAM_AEC_MODE_FRAME_AVERAGE,
    389     CAM_AEC_MODE_CENTER_WEIGHTED,
    390     CAM_AEC_MODE_SPOT_METERING,
    391     CAM_AEC_MODE_SMART_METERING,
    392     CAM_AEC_MODE_USER_METERING,
    393     CAM_AEC_MODE_SPOT_METERING_ADV,
    394     CAM_AEC_MODE_CENTER_WEIGHTED_ADV,
    395     CAM_AEC_MODE_MAX
    396 } cam_auto_exposure_mode_type;
    397 
    398 typedef enum {
    399     CAM_AE_MODE_OFF,
    400     CAM_AE_MODE_ON,
    401     CAM_AE_MODE_MAX
    402 } cam_ae_mode_type;
    403 
    404 typedef enum {
    405     CAM_FOCUS_ALGO_AUTO,
    406     CAM_FOCUS_ALGO_SPOT,
    407     CAM_FOCUS_ALGO_CENTER_WEIGHTED,
    408     CAM_FOCUS_ALGO_AVERAGE,
    409     CAM_FOCUS_ALGO_MAX
    410 } cam_focus_algorithm_type;
    411 
    412 /* Auto focus mode */
    413 typedef enum {
    414     CAM_FOCUS_MODE_OFF,
    415     CAM_FOCUS_MODE_AUTO,
    416     CAM_FOCUS_MODE_INFINITY,
    417     CAM_FOCUS_MODE_MACRO,
    418     CAM_FOCUS_MODE_FIXED,
    419     CAM_FOCUS_MODE_EDOF,
    420     CAM_FOCUS_MODE_CONTINOUS_VIDEO,
    421     CAM_FOCUS_MODE_CONTINOUS_PICTURE,
    422     CAM_FOCUS_MODE_MAX
    423 } cam_focus_mode_type;
    424 
    425 typedef enum {
    426     CAM_SCENE_MODE_OFF,
    427     CAM_SCENE_MODE_AUTO,
    428     CAM_SCENE_MODE_LANDSCAPE,
    429     CAM_SCENE_MODE_SNOW,
    430     CAM_SCENE_MODE_BEACH,
    431     CAM_SCENE_MODE_SUNSET,
    432     CAM_SCENE_MODE_NIGHT,
    433     CAM_SCENE_MODE_PORTRAIT,
    434     CAM_SCENE_MODE_BACKLIGHT,
    435     CAM_SCENE_MODE_SPORTS,
    436     CAM_SCENE_MODE_ANTISHAKE,
    437     CAM_SCENE_MODE_FLOWERS,
    438     CAM_SCENE_MODE_CANDLELIGHT,
    439     CAM_SCENE_MODE_FIREWORKS,
    440     CAM_SCENE_MODE_PARTY,
    441     CAM_SCENE_MODE_NIGHT_PORTRAIT,
    442     CAM_SCENE_MODE_THEATRE,
    443     CAM_SCENE_MODE_ACTION,
    444     CAM_SCENE_MODE_AR,
    445     CAM_SCENE_MODE_FACE_PRIORITY,
    446     CAM_SCENE_MODE_BARCODE,
    447     CAM_SCENE_MODE_MAX
    448 } cam_scene_mode_type;
    449 
    450 typedef enum {
    451     CAM_EFFECT_MODE_OFF,
    452     CAM_EFFECT_MODE_MONO,
    453     CAM_EFFECT_MODE_NEGATIVE,
    454     CAM_EFFECT_MODE_SOLARIZE,
    455     CAM_EFFECT_MODE_SEPIA,
    456     CAM_EFFECT_MODE_POSTERIZE,
    457     CAM_EFFECT_MODE_WHITEBOARD,
    458     CAM_EFFECT_MODE_BLACKBOARD,
    459     CAM_EFFECT_MODE_AQUA,
    460     CAM_EFFECT_MODE_EMBOSS,
    461     CAM_EFFECT_MODE_SKETCH,
    462     CAM_EFFECT_MODE_NEON,
    463     CAM_EFFECT_MODE_MAX
    464 } cam_effect_mode_type;
    465 
    466 typedef enum {
    467     CAM_FLASH_MODE_OFF,
    468     CAM_FLASH_MODE_AUTO,
    469     CAM_FLASH_MODE_ON,
    470     CAM_FLASH_MODE_TORCH,
    471     CAM_FLASH_MODE_SINGLE,
    472     CAM_FLASH_MODE_MAX
    473 } cam_flash_mode_t;
    474 
    475 // Flash States
    476 typedef enum {
    477     CAM_FLASH_STATE_UNAVAILABLE,
    478     CAM_FLASH_STATE_CHARGING,
    479     CAM_FLASH_STATE_READY,
    480     CAM_FLASH_STATE_FIRED,
    481     CAM_FLASH_STATE_PARTIAL,
    482     CAM_FLASH_STATE_MAX
    483 } cam_flash_state_t;
    484 
    485 typedef enum {
    486     CAM_FLASH_FIRING_LEVEL_0,
    487     CAM_FLASH_FIRING_LEVEL_1,
    488     CAM_FLASH_FIRING_LEVEL_2,
    489     CAM_FLASH_FIRING_LEVEL_3,
    490     CAM_FLASH_FIRING_LEVEL_4,
    491     CAM_FLASH_FIRING_LEVEL_5,
    492     CAM_FLASH_FIRING_LEVEL_6,
    493     CAM_FLASH_FIRING_LEVEL_7,
    494     CAM_FLASH_FIRING_LEVEL_8,
    495     CAM_FLASH_FIRING_LEVEL_9,
    496     CAM_FLASH_FIRING_LEVEL_10,
    497     CAM_FLASH_FIRING_LEVEL_MAX
    498 } cam_flash_firing_level_t;
    499 
    500 
    501 typedef enum {
    502     CAM_AEC_TRIGGER_IDLE,
    503     CAM_AEC_TRIGGER_START
    504 } cam_aec_trigger_type_t;
    505 
    506 typedef enum {
    507     CAM_AF_TRIGGER_IDLE,
    508     CAM_AF_TRIGGER_START,
    509     CAM_AF_TRIGGER_CANCEL
    510 } cam_af_trigger_type_t;
    511 
    512 typedef enum {
    513     CAM_AE_STATE_INACTIVE,
    514     CAM_AE_STATE_SEARCHING,
    515     CAM_AE_STATE_CONVERGED,
    516     CAM_AE_STATE_LOCKED,
    517     CAM_AE_STATE_FLASH_REQUIRED,
    518     CAM_AE_STATE_PRECAPTURE
    519 } cam_ae_state_t;
    520 
    521 typedef enum {
    522     CAM_NOISE_REDUCTION_MODE_OFF,
    523     CAM_NOISE_REDUCTION_MODE_FAST,
    524     CAM_NOISE_REDUCTION_MODE_HIGH_QUALITY
    525 } cam_noise_reduction_mode_t;
    526 
    527 typedef enum {
    528     CAM_EDGE_MODE_OFF,
    529     CAM_EDGE_MODE_FAST,
    530     CAM_EDGE_MODE_HIGH_QUALITY,
    531 } cam_edge_mode_t;
    532 
    533 typedef struct {
    534    uint8_t edge_mode;
    535    int32_t sharpness;
    536 } cam_edge_application_t;
    537 
    538 typedef enum {
    539     CAM_BLACK_LEVEL_LOCK_OFF,
    540     CAM_BLACK_LEVEL_LOCK_ON,
    541 } cam_black_level_lock_t;
    542 
    543 typedef enum {
    544     CAM_LENS_SHADING_MAP_MODE_OFF,
    545     CAM_LENS_SHADING_MAP_MODE_ON,
    546 } cam_lens_shading_map_mode_t;
    547 
    548 typedef enum {
    549     CAM_LENS_SHADING_MODE_OFF,
    550     CAM_LENS_SHADING_MODE_FAST,
    551     CAM_LENS_SHADING_MODE_HIGH_QUALITY,
    552 } cam_lens_shading_mode_t;
    553 
    554 typedef enum {
    555     CAM_FACE_DETECT_MODE_OFF,
    556     CAM_FACE_DETECT_MODE_SIMPLE,
    557     CAM_FACE_DETECT_MODE_FULL,
    558 } cam_face_detect_mode_t;
    559 
    560 typedef enum {
    561     CAM_TONEMAP_MODE_CONTRAST_CURVE,
    562     CAM_TONEMAP_MODE_FAST,
    563     CAM_TONEMAP_MODE_HIGH_QUALITY,
    564 } cam_tonemap_mode_t;
    565 
    566 typedef struct  {
    567     int32_t left;
    568     int32_t top;
    569     int32_t width;
    570     int32_t height;
    571 } cam_rect_t;
    572 
    573 typedef struct  {
    574     cam_rect_t rect;
    575     int32_t weight; /* weight of the area, valid for focusing/metering areas */
    576 } cam_area_t;
    577 
    578 typedef enum {
    579     CAM_STREAMING_MODE_CONTINUOUS, /* continous streaming */
    580     CAM_STREAMING_MODE_BURST,      /* burst streaming */
    581     CAM_STREAMING_MODE_MAX
    582 } cam_streaming_mode_t;
    583 
    584 #define CAM_REPROCESS_MASK_TYPE_WNR (1<<0)
    585 
    586 /* event from server */
    587 typedef enum {
    588     CAM_EVENT_TYPE_MAP_UNMAP_DONE  = (1<<0),
    589     CAM_EVENT_TYPE_AUTO_FOCUS_DONE = (1<<1),
    590     CAM_EVENT_TYPE_ZOOM_DONE       = (1<<2),
    591     CAM_EVENT_TYPE_DAEMON_DIED     = (1<<3),
    592     CAM_EVENT_TYPE_MAX
    593 } cam_event_type_t;
    594 
    595 typedef enum {
    596     CAM_EXP_BRACKETING_OFF,
    597     CAM_EXP_BRACKETING_ON
    598 } cam_bracket_mode;
    599 
    600 typedef struct {
    601     cam_bracket_mode mode;
    602     char values[MAX_EXP_BRACKETING_LENGTH];  /* user defined values */
    603 } cam_exp_bracketing_t;
    604 
    605 typedef enum {
    606     CAM_AEC_ROI_OFF,
    607     CAM_AEC_ROI_ON
    608 } cam_aec_roi_ctrl_t;
    609 
    610 typedef enum {
    611     CAM_AEC_ROI_BY_INDEX,
    612     CAM_AEC_ROI_BY_COORDINATE,
    613 } cam_aec_roi_type_t;
    614 
    615 typedef struct {
    616     uint32_t x;
    617     uint32_t y;
    618 } cam_coordinate_type_t;
    619 
    620 typedef struct {
    621     int32_t numerator;
    622     int32_t denominator;
    623 } cam_rational_type_t;
    624 
    625 typedef struct {
    626     cam_aec_roi_ctrl_t aec_roi_enable;
    627     cam_aec_roi_type_t aec_roi_type;
    628     union {
    629         cam_coordinate_type_t coordinate[MAX_ROI];
    630         uint32_t aec_roi_idx[MAX_ROI];
    631     } cam_aec_roi_position;
    632 } cam_set_aec_roi_t;
    633 
    634 typedef struct {
    635     uint32_t frm_id;
    636     uint8_t num_roi;
    637     cam_rect_t roi[MAX_ROI];
    638     int32_t weight[MAX_ROI];
    639     uint8_t is_multiwindow;
    640 } cam_roi_info_t;
    641 
    642 typedef enum {
    643     CAM_WAVELET_DENOISE_YCBCR_PLANE,
    644     CAM_WAVELET_DENOISE_CBCR_ONLY,
    645     CAM_WAVELET_DENOISE_STREAMLINE_YCBCR,
    646     CAM_WAVELET_DENOISE_STREAMLINED_CBCR
    647 } cam_denoise_process_type_t;
    648 
    649 typedef struct {
    650     int denoise_enable;
    651     cam_denoise_process_type_t process_plates;
    652 } cam_denoise_param_t;
    653 
    654 #define CAM_FACE_PROCESS_MASK_DETECTION    (1<<0)
    655 #define CAM_FACE_PROCESS_MASK_RECOGNITION  (1<<1)
    656 typedef struct {
    657     int fd_mode;               /* mask of face process */
    658     int num_fd;
    659 } cam_fd_set_parm_t;
    660 
    661 typedef struct {
    662     int8_t face_id;            /* unique id for face tracking within view unless view changes */
    663     int8_t score;              /* score of confidence (0, -100) */
    664     cam_rect_t face_boundary;  /* boundary of face detected */
    665     cam_coordinate_type_t left_eye_center;  /* coordinate of center of left eye */
    666     cam_coordinate_type_t right_eye_center; /* coordinate of center of right eye */
    667     cam_coordinate_type_t mouth_center;     /* coordinate of center of mouth */
    668     uint8_t smile_degree;      /* smile degree (0, -100) */
    669     uint8_t smile_confidence;  /* smile confidence (0, 100) */
    670     uint8_t face_recognised;   /* if face is recognised */
    671     int8_t gaze_angle;         /* -90 -45 0 45 90 for head left to rigth tilt */
    672     int8_t updown_dir;         /* up down direction (-90, 90) */
    673     int8_t leftright_dir;      /* left right direction (-90, 90) */
    674     int8_t roll_dir;           /* roll direction (-90, 90) */
    675     int8_t left_right_gaze;    /* left right gaze degree (-50, 50) */
    676     int8_t top_bottom_gaze;    /* up down gaze degree (-50, 50) */
    677     uint8_t blink_detected;    /* if blink is detected */
    678     uint8_t left_blink;        /* left eye blink degeree (0, -100) */
    679     uint8_t right_blink;       /* right eye blink degree (0, - 100) */
    680 } cam_face_detection_info_t;
    681 
    682 typedef struct {
    683     uint32_t frame_id;                         /* frame index of which faces are detected */
    684     uint8_t num_faces_detected;                /* number of faces detected */
    685     cam_face_detection_info_t faces[MAX_ROI];  /* detailed information of faces detected */
    686 } cam_face_detection_data_t;
    687 
    688 #define CAM_HISTOGRAM_STATS_SIZE 256
    689 typedef struct {
    690     uint32_t max_hist_value;
    691     uint32_t hist_buf[CAM_HISTOGRAM_STATS_SIZE]; /* buf holding histogram stats data */
    692 } cam_histogram_data_t;
    693 
    694 typedef struct {
    695     cam_histogram_data_t r_stats;
    696     cam_histogram_data_t b_stats;
    697     cam_histogram_data_t gr_stats;
    698     cam_histogram_data_t gb_stats;
    699 } cam_bayer_hist_stats_t;
    700 
    701 typedef enum {
    702     CAM_HISTOGRAM_TYPE_BAYER,
    703     CAM_HISTOGRAM_TYPE_YUV
    704 } cam_histogram_type_t;
    705 
    706 typedef struct {
    707     cam_histogram_type_t type;
    708     union {
    709         cam_bayer_hist_stats_t bayer_stats;
    710         cam_histogram_data_t yuv_stats;
    711     };
    712 } cam_hist_stats_t;
    713 
    714 enum cam_focus_distance_index{
    715   CAM_FOCUS_DISTANCE_NEAR_INDEX,  /* 0 */
    716   CAM_FOCUS_DISTANCE_OPTIMAL_INDEX,
    717   CAM_FOCUS_DISTANCE_FAR_INDEX,
    718   CAM_FOCUS_DISTANCE_MAX_INDEX
    719 };
    720 
    721 typedef struct {
    722   float focus_distance[CAM_FOCUS_DISTANCE_MAX_INDEX];
    723 } cam_focus_distances_info_t;
    724 
    725 /* Different autofocus cycle when calling do_autoFocus
    726  * CAM_AF_COMPLETE_EXISTING_SWEEP: Complete existing sweep
    727  * if one is ongoing, and lock.
    728  * CAM_AF_DO_ONE_FULL_SWEEP: Do one full sweep, regardless
    729  * of the current state, and lock.
    730  * CAM_AF_START_CONTINUOUS_SWEEP: Start continous sweep.
    731  * After do_autoFocus, HAL receives an event: CAM_AF_FOCUSED,
    732  * or CAM_AF_NOT_FOCUSED.
    733  * cancel_autoFocus stops any lens movement.
    734  * Each do_autoFocus call only produces 1 FOCUSED/NOT_FOCUSED
    735  * event, not both.
    736  */
    737 typedef enum {
    738     CAM_AF_COMPLETE_EXISTING_SWEEP,
    739     CAM_AF_DO_ONE_FULL_SWEEP,
    740     CAM_AF_START_CONTINUOUS_SWEEP
    741 } cam_autofocus_cycle_t;
    742 
    743 typedef enum {
    744     CAM_AF_SCANNING,
    745     CAM_AF_FOCUSED,
    746     CAM_AF_NOT_FOCUSED
    747 } cam_autofocus_state_t;
    748 
    749 typedef struct {
    750     cam_autofocus_state_t focus_state;           /* state of focus */
    751     cam_focus_distances_info_t focus_dist;       /* focus distance */
    752 } cam_auto_focus_data_t;
    753 
    754 typedef struct {
    755     uint32_t stream_id;
    756     cam_rect_t crop;
    757 } cam_stream_crop_info_t;
    758 
    759 typedef struct {
    760     uint8_t num_of_streams;
    761     cam_stream_crop_info_t crop_info[MAX_NUM_STREAMS];
    762 } cam_crop_data_t;
    763 
    764 typedef enum {
    765     DO_NOT_NEED_FUTURE_FRAME,
    766     NEED_FUTURE_FRAME,
    767 } cam_prep_snapshot_state_t;
    768 
    769 typedef struct {
    770     float gains[4];
    771 } cam_color_correct_gains_t;
    772 
    773 typedef struct {
    774     uint32_t min_frame_idx;
    775     uint32_t max_frame_idx;
    776 } cam_frame_idx_range_t;
    777 
    778 
    779 typedef  struct {
    780    float aperture_value;
    781    /* Store current LED flash state */
    782    cam_flash_mode_t         flash_mode;
    783    cam_flash_state_t        flash_state;
    784 } cam_sensor_params_t;
    785 
    786 typedef struct {
    787     float exp_time;
    788     int iso_value;
    789     cam_wb_mode_type wb_mode;
    790 } cam_3a_params_t;
    791 
    792 typedef struct {
    793     cam_dimension_t stream_sizes[MAX_NUM_STREAMS];
    794     uint32_t num_streams;
    795     uint32_t type[MAX_NUM_STREAMS];
    796 } cam_stream_size_info_t;
    797 
    798 typedef struct {
    799     uint32_t num_streams;
    800     uint32_t streamID[MAX_NUM_STREAMS];
    801 } cam_stream_ID_t;
    802 
    803 typedef  struct {
    804     uint8_t is_stats_valid;               /* if histgram data is valid */
    805     cam_hist_stats_t stats_data;          /* histogram data */
    806 
    807     uint8_t is_faces_valid;               /* if face detection data is valid */
    808     cam_face_detection_data_t faces_data; /* face detection result */
    809 
    810     uint8_t is_focus_valid;               /* if focus data is valid */
    811     cam_auto_focus_data_t focus_data;     /* focus data */
    812 
    813     uint8_t is_crop_valid;                /* if crop data is valid */
    814     cam_crop_data_t crop_data;            /* crop data */
    815 
    816     uint8_t is_prep_snapshot_done_valid;  /* if prep snapshot done is valid */
    817     cam_prep_snapshot_state_t prep_snapshot_done_state;  /* prepare snapshot done state */
    818 
    819     /* if good frame idx range is valid */
    820     uint8_t is_good_frame_idx_range_valid;
    821     /* good frame idx range, make sure:
    822      * 1. good_frame_idx_range.min_frame_idx > current_frame_idx
    823      * 2. good_frame_idx_range.min_frame_idx - current_frame_idx < 100 */
    824     cam_frame_idx_range_t good_frame_idx_range;
    825 
    826     char private_metadata[MAX_METADATA_PAYLOAD_SIZE];
    827 
    828     /* AE parameters */
    829     uint8_t is_3a_params_valid;
    830     cam_3a_params_t cam_3a_params;
    831     /* sensor parameters */
    832     uint8_t is_sensor_params_valid;
    833     cam_sensor_params_t sensor_params;
    834 } cam_metadata_info_t;
    835 
    836 #define TUNING_DATA_VERSION        1
    837 #define TUNING_SENSOR_DATA_MAX     0x10000 /*(need value from sensor team)*/
    838 #define TUNING_VFE_DATA_MAX        0x10000 /*(need value from vfe team)*/
    839 #define TUNING_CPP_DATA_MAX        0x10000 /*(need value from pproc team)*/
    840 #define TUNING_CAC_DATA_MAX        0x10000 /*(need value from imglib team)*/
    841 #define TUNING_DATA_MAX            (TUNING_SENSOR_DATA_MAX + \
    842                                     TUNING_VFE_DATA_MAX + TUNING_CPP_DATA_MAX + \
    843                                     TUNING_CAC_DATA_MAX)
    844 
    845 #define TUNING_SENSOR_DATA_OFFSET  0
    846 #define TUNING_VFE_DATA_OFFSET     TUNING_SENSOR_DATA_MAX
    847 #define TUNING_CPP_DATA_OFFSET     (TUNING_SENSOR_DATA_MAX + TUNING_VFE_DATA_MAX)
    848 #define TUNING_CAC_DATA_OFFSET     (TUNING_SENSOR_DATA_MAX + \
    849                                     TUNING_VFE_DATA_MAX + TUNING_CPP_DATA_MAX)
    850 
    851 typedef struct {
    852     uint32_t tuning_data_version;
    853     uint32_t tuning_sensor_data_size;
    854     uint32_t tuning_vfe_data_size;
    855     uint32_t tuning_cpp_data_size;
    856     uint32_t tuning_cac_data_size;
    857     uint8_t  data[TUNING_DATA_MAX];
    858 }tuning_params_t;
    859 
    860 typedef enum {
    861     CAM_INTF_PARM_HAL_VERSION,
    862 
    863     /* Overall mode of 3A control routines. We need to have this parameter
    864      * because not all android.control.* have an OFF option, for example,
    865      * AE_FPS_Range, aePrecaptureTrigger */
    866     CAM_INTF_META_MODE,
    867     /* Whether AE is currently updating the sensor exposure and sensitivity
    868      * fields */
    869     CAM_INTF_META_AEC_MODE,
    870     CAM_INTF_PARM_WHITE_BALANCE,
    871     CAM_INTF_PARM_FOCUS_MODE,
    872 
    873     /* common between HAL1 and HAL3 */
    874     CAM_INTF_PARM_ANTIBANDING,
    875     CAM_INTF_PARM_EV,
    876     CAM_INTF_PARM_EV_STEP,
    877     CAM_INTF_PARM_AEC_LOCK,
    878     CAM_INTF_PARM_FPS_RANGE,
    879     CAM_INTF_PARM_AWB_LOCK,
    880     CAM_INTF_PARM_EFFECT,
    881     CAM_INTF_PARM_BESTSHOT_MODE,
    882     CAM_INTF_PARM_DIS_ENABLE,
    883     CAM_INTF_PARM_LED_MODE,
    884     CAM_INTF_META_HISTOGRAM, /* 10 */
    885     CAM_INTF_META_FACE_DETECTION,
    886 
    887     /* specific to HAl1 */
    888     CAM_INTF_META_AUTOFOCUS_DATA,
    889     CAM_INTF_PARM_QUERY_FLASH4SNAP,
    890     CAM_INTF_PARM_SHARPNESS,
    891     CAM_INTF_PARM_CONTRAST,
    892     CAM_INTF_PARM_SATURATION,
    893     CAM_INTF_PARM_BRIGHTNESS,
    894     CAM_INTF_PARM_ISO,
    895     CAM_INTF_PARM_ZOOM, /* 20 */
    896     CAM_INTF_PARM_ROLLOFF,
    897     CAM_INTF_PARM_MODE,             /* camera mode */
    898     CAM_INTF_PARM_AEC_ALGO_TYPE,    /* auto exposure algorithm */
    899     CAM_INTF_PARM_FOCUS_ALGO_TYPE,  /* focus algorithm */
    900     CAM_INTF_PARM_AEC_ROI,
    901     CAM_INTF_PARM_AF_ROI,
    902     CAM_INTF_PARM_SCE_FACTOR,
    903     CAM_INTF_PARM_FD,
    904     CAM_INTF_PARM_MCE, /* 30 */
    905     CAM_INTF_PARM_HFR,
    906     CAM_INTF_PARM_REDEYE_REDUCTION,
    907     CAM_INTF_PARM_WAVELET_DENOISE,
    908     CAM_INTF_PARM_HISTOGRAM,
    909     CAM_INTF_PARM_ASD_ENABLE,
    910     CAM_INTF_PARM_RECORDING_HINT,
    911     CAM_INTF_PARM_HDR,
    912     CAM_INTF_PARM_FRAMESKIP,
    913     CAM_INTF_PARM_ZSL_MODE,  /* indicating if it's running in ZSL mode */
    914     CAM_INTF_PARM_HDR_NEED_1X, /* if HDR needs 1x output */ /* 40 */
    915     CAM_INTF_PARM_LOCK_CAF,
    916     CAM_INTF_PARM_VIDEO_HDR,
    917     CAM_INTF_PARM_ROTATION,
    918     CAM_INTF_META_CROP_DATA,
    919     CAM_INTF_META_PREP_SNAPSHOT_DONE,
    920     CAM_INTF_META_GOOD_FRAME_IDX_RANGE,
    921 
    922     /* stream based parameters */
    923     CAM_INTF_PARM_DO_REPROCESS,
    924     CAM_INTF_PARM_SET_BUNDLE,
    925 
    926     /* specific to HAL3 */
    927     /* Whether the metadata maps to a valid frame number */
    928     CAM_INTF_META_FRAME_NUMBER_VALID,
    929     /* Whether the urgent metadata maps to a valid frame number */
    930     CAM_INTF_META_URGENT_FRAME_NUMBER_VALID,
    931     /* Whether the stream buffer corresponding this frame is dropped or not */
    932     CAM_INTF_META_FRAME_DROPPED,
    933     /* Number of pending requests yet to be processed */
    934     CAM_INTF_META_PENDING_REQUESTS,
    935     /* COLOR CORRECTION.*/
    936     CAM_INTF_META_COLOR_CORRECT_MODE,
    937     /* A transform matrix to chromatically adapt pixels in the CIE XYZ (1931)
    938      * color space from the scene illuminant to the sRGB-standard D65-illuminant. */
    939     CAM_INTF_META_COLOR_CORRECT_TRANSFORM, /* 50 */
    940     /*Color channel gains in the Bayer raw domain in the order [RGeGoB]*/
    941     CAM_INTF_META_COLOR_CORRECT_GAINS,
    942     /*The best fit color transform matrix calculated by the stats*/
    943     CAM_INTF_META_PRED_COLOR_CORRECT_TRANSFORM,
    944     /*The best fit color channels gains calculated by the stats*/
    945     CAM_INTF_META_PRED_COLOR_CORRECT_GAINS,
    946     /* CONTROL */
    947     /* A frame counter set by the framework. Must be maintained unchanged in
    948      * output frame. */
    949     CAM_INTF_META_FRAME_NUMBER,
    950     /* A frame counter set by the framework. Must be maintained unchanged in
    951      * output frame. */
    952     CAM_INTF_META_URGENT_FRAME_NUMBER,
    953     /*Number of streams and size of streams in current configuration*/
    954     CAM_INTF_META_STREAM_INFO,
    955     /* List of areas to use for metering */
    956     CAM_INTF_META_AEC_ROI,
    957     /* Whether the HAL must trigger precapture metering. Used to sync trigger
    958      * value and precapture ID */
    959     CAM_INTF_META_AEC_PRECAPTURE_TRIGGER,
    960     /* Use to report back to the trigger value, triger is requested using
    961      * CAM_INTF_META_AEC_PRECAPTURE_TRIGGER */
    962     CAM_INTF_META_PRECAPTURE_TRIGGER,
    963     /* Current state of AE algorithm */
    964     CAM_INTF_META_AEC_STATE,
    965     /* List of areas to use for focus estimation */
    966     CAM_INTF_META_AF_ROI,
    967     /* Whether the HAL must trigger autofocus. */
    968     CAM_INTF_META_AF_TRIGGER,
    969     /* Use to report back AF trigger value, trigger is requested using
    970      * CAM_INTF_META_AF_TRIGGER and CAM_INTF_META_AF_TRIGGER_ID */
    971     CAM_INTF_META_AF_TRIGGER_NOTICE,
    972     /* Current state of AF algorithm */
    973     CAM_INTF_META_AF_STATE,
    974     /* List of areas to use for illuminant estimation */
    975     CAM_INTF_META_AWB_REGIONS,
    976     /* Current state of AWB algorithm */
    977     CAM_INTF_META_AWB_STATE,
    978     /*Whether black level compensation is frozen or free to vary*/
    979     CAM_INTF_META_BLACK_LEVEL_LOCK,
    980     /* Information to 3A routines about the purpose of this capture, to help
    981      * decide optimal 3A strategy */
    982     CAM_INTF_META_CAPTURE_INTENT,
    983     /* DEMOSAIC */
    984     /* Controls the quality of the demosaicing processing */
    985     CAM_INTF_META_DEMOSAIC,
    986     /* EDGE */
    987     /* Operation mode for edge enhancement */
    988     CAM_INTF_META_EDGE_MODE,
    989     /* Control the amount of edge enhancement applied to the images.*/
    990     /* 1-10; 10 is maximum sharpening */
    991     CAM_INTF_META_SHARPNESS_STRENGTH,
    992     /* FLASH */
    993     /* Power for flash firing/torch, 10 is max power; 0 is no flash. Linear */
    994     CAM_INTF_META_FLASH_POWER,
    995     /* Firing time of flash relative to start of exposure, in nanoseconds*/
    996     CAM_INTF_META_FLASH_FIRING_TIME,
    997     /* Current state of the flash unit */
    998     CAM_INTF_META_FLASH_STATE,
    999     /* GEOMETRIC */
   1000     /* Operating mode of geometric correction */
   1001     CAM_INTF_META_GEOMETRIC_MODE,
   1002     /* Control the amount of shading correction applied to the images */
   1003     CAM_INTF_META_GEOMETRIC_STRENGTH,
   1004     /* HOT PIXEL */
   1005     /* Set operational mode for hot pixel correction */
   1006     CAM_INTF_META_HOTPIXEL_MODE,
   1007     /* LENS */
   1008     /* Size of the lens aperture */
   1009     CAM_INTF_META_LENS_APERTURE,
   1010     /* State of lens neutral density filter(s) */
   1011     CAM_INTF_META_LENS_FILTERDENSITY,
   1012     /* Lens optical zoom setting */
   1013     CAM_INTF_META_LENS_FOCAL_LENGTH,
   1014     /* Distance to plane of sharpest focus, measured from frontmost surface
   1015      * of the lens */
   1016     CAM_INTF_META_LENS_FOCUS_DISTANCE,
   1017     /* The range of scene distances that are in sharp focus (depth of field) */
   1018     CAM_INTF_META_LENS_FOCUS_RANGE,
   1019     /* Whether optical image stabilization is enabled. */
   1020     CAM_INTF_META_LENS_OPT_STAB_MODE,
   1021     /*Whether the hal needs to output the lens shading map*/
   1022     CAM_INTF_META_LENS_SHADING_MAP_MODE,
   1023     /* Current lens status */
   1024     CAM_INTF_META_LENS_STATE,
   1025     /* NOISE REDUCTION */
   1026     /* Mode of operation for the noise reduction algorithm */
   1027     CAM_INTF_META_NOISE_REDUCTION_MODE,
   1028    /* Control the amount of noise reduction applied to the images.
   1029     * 1-10; 10 is max noise reduction */
   1030     CAM_INTF_META_NOISE_REDUCTION_STRENGTH,
   1031     /* SCALER */
   1032     /* Top-left corner and width of the output region to select from the active
   1033      * pixel array */
   1034     CAM_INTF_META_SCALER_CROP_REGION,
   1035     /* The estimated scene illumination lighting frequency */
   1036     CAM_INTF_META_SCENE_FLICKER,
   1037     /* SENSOR */
   1038     /* Duration each pixel is exposed to light, in nanoseconds */
   1039     CAM_INTF_META_SENSOR_EXPOSURE_TIME,
   1040     /* Duration from start of frame exposure to start of next frame exposure,
   1041      * in nanoseconds */
   1042     CAM_INTF_META_SENSOR_FRAME_DURATION,
   1043     /* Gain applied to image data. Must be implemented through analog gain only
   1044      * if set to values below 'maximum analog sensitivity'. */
   1045     CAM_INTF_META_SENSOR_SENSITIVITY,
   1046     /* Time at start of exposure of first row */
   1047     CAM_INTF_META_SENSOR_TIMESTAMP,
   1048     /* Duration b/w start of first row exposure and the start of last
   1049       row exposure in nanoseconds */
   1050     CAM_INTF_META_SENSOR_ROLLING_SHUTTER_SKEW,
   1051     /* SHADING */
   1052     /* Quality of lens shading correction applied to the image data */
   1053     CAM_INTF_META_SHADING_MODE,
   1054     /* Control the amount of shading correction applied to the images.
   1055      * unitless: 1-10; 10 is full shading compensation */
   1056     CAM_INTF_META_SHADING_STRENGTH,
   1057     /* STATISTICS */
   1058     /* State of the face detector unit */
   1059     CAM_INTF_META_STATS_FACEDETECT_MODE,
   1060     /* Operating mode for histogram generation */
   1061     CAM_INTF_META_STATS_HISTOGRAM_MODE,
   1062     /* Operating mode for sharpness map generation */
   1063     CAM_INTF_META_STATS_SHARPNESS_MAP_MODE,
   1064     /* A 3-channel sharpness map, based on the raw sensor data,
   1065      * If only a monochrome sharpness map is supported, all channels
   1066      * should have the same data
   1067      */
   1068     CAM_INTF_META_STATS_SHARPNESS_MAP,
   1069 
   1070     /* TONEMAP */
   1071     /* Tone map mode */
   1072     CAM_INTF_META_TONEMAP_MODE,
   1073     /* Table mapping RGB input values to output values */
   1074     CAM_INTF_META_TONEMAP_CURVES,
   1075 
   1076     CAM_INTF_META_FLASH_MODE,
   1077     /* 2D array of gain factors for each color channel that was used to
   1078      * compensate for lens shading for this frame */
   1079     CAM_INTF_META_LENS_SHADING_MAP,
   1080     CAM_INTF_META_PRIVATE_DATA,
   1081     /* Indicates streams ID of all the requested buffers */
   1082     CAM_INTF_META_STREAM_ID,
   1083     CAM_INTF_META_TEST_PATTERN_DATA,
   1084     /*AEC info for Exif*/
   1085     CAM_INTF_META_AEC_INFO,
   1086     CAM_INTF_META_JPEG_GPS_COORDINATES,
   1087     CAM_INTF_META_JPEG_GPS_PROC_METHODS,
   1088     CAM_INTF_META_JPEG_GPS_TIMESTAMP,
   1089     CAM_INTF_META_JPEG_ORIENTATION,
   1090     CAM_INTF_META_JPEG_QUALITY,
   1091     CAM_INTF_META_JPEG_THUMB_QUALITY,
   1092     CAM_INTF_META_JPEG_THUMB_SIZE,
   1093 
   1094     /* OTP : WB gr/gb */
   1095     CAM_INTF_META_OTP_WB_GRGB,
   1096     /* DNG file support */
   1097     CAM_INTF_META_PROFILE_TONE_CURVE,
   1098     CAM_INTF_META_NEUTRAL_COL_POINT,
   1099 
   1100     CAM_INTF_PARM_MAX
   1101 } cam_intf_parm_type_t;
   1102 
   1103 /*****************************************************************************
   1104  *                 Code for HAL3 data types                                  *
   1105  ****************************************************************************/
   1106 typedef enum {
   1107     CAM_INTF_METADATA_MAX
   1108 } cam_intf_metadata_type_t;
   1109 
   1110 typedef enum {
   1111     CAM_INTENT_CUSTOM,
   1112     CAM_INTENT_PREVIEW,
   1113     CAM_INTENT_STILL_CAPTURE,
   1114     CAM_INTENT_VIDEO_RECORD,
   1115     CAM_INTENT_VIDEO_SNAPSHOT,
   1116     CAM_INTENT_ZERO_SHUTTER_LAG,
   1117     CAM_INTENT_MAX,
   1118 } cam_intent_t;
   1119 
   1120 typedef enum {
   1121     /* Full application control of pipeline. All 3A routines are disabled,
   1122      * no other settings in android.control.* have any effect */
   1123     CAM_CONTROL_OFF,
   1124     /* Use settings for each individual 3A routine. Manual control of capture
   1125      * parameters is disabled. All controls in android.control.* besides sceneMode
   1126      * take effect */
   1127     CAM_CONTROL_AUTO,
   1128     /* Use specific scene mode. Enabling this disables control.aeMode,
   1129      * control.awbMode and control.afMode controls; the HAL must ignore those
   1130      * settings while USE_SCENE_MODE is active (except for FACE_PRIORITY scene mode).
   1131      * Other control entries are still active. This setting can only be used if
   1132      * availableSceneModes != UNSUPPORTED. TODO: Should we remove this and handle this
   1133      * in HAL ?*/
   1134     CAM_CONTROL_USE_SCENE_MODE,
   1135     CAM_CONTROL_MAX
   1136 } cam_control_mode_t;
   1137 
   1138 typedef enum {
   1139     /* Use the android.colorCorrection.transform matrix to do color conversion */
   1140     CAM_COLOR_CORRECTION_TRANSFORM_MATRIX,
   1141     /* Must not slow down frame rate relative to raw bayer output */
   1142     CAM_COLOR_CORRECTION_FAST,
   1143     /* Frame rate may be reduced by high quality */
   1144     CAM_COLOR_CORRECTION_HIGH_QUALITY,
   1145 } cam_color_correct_mode_t;
   1146 
   1147 typedef struct {
   1148     /* 3x3 float matrix in row-major order. each element is in range of (0, 1) */
   1149     cam_rational_type_t transform_matrix[3][3];
   1150 } cam_color_correct_matrix_t;
   1151 
   1152 #define CAM_FOCAL_LENGTHS_MAX     1
   1153 #define CAM_APERTURES_MAX         1
   1154 #define CAM_FILTER_DENSITIES_MAX  1
   1155 #define CAM_MAX_MAP_HEIGHT        6
   1156 #define CAM_MAX_MAP_WIDTH         6
   1157 #define CAM_MAX_SHADING_MAP_WIDTH 17
   1158 #define CAM_MAX_SHADING_MAP_HEIGHT 13
   1159 #define CAM_MAX_TONEMAP_CURVE_SIZE    128
   1160 
   1161 typedef struct {
   1162     /* A 1D array of pairs of floats.
   1163      * Mapping a 0-1 input range to a 0-1 output range.
   1164      * The input range must be monotonically increasing with N,
   1165      * and values between entries should be linearly interpolated.
   1166      * For example, if the array is: [0.0, 0.0, 0.3, 0.5, 1.0, 1.0],
   1167      * then the input->output mapping for a few sample points would be:
   1168      * 0 -> 0, 0.15 -> 0.25, 0.3 -> 0.5, 0.5 -> 0.64 */
   1169     float tonemap_points[CAM_MAX_TONEMAP_CURVE_SIZE][2];
   1170 } cam_tonemap_curve_t;
   1171 
   1172 typedef struct {
   1173    int tonemap_points_cnt;
   1174    cam_tonemap_curve_t curves[3];
   1175 } cam_rgb_tonemap_curves;
   1176 
   1177 typedef struct {
   1178    int tonemap_points_cnt;
   1179    cam_tonemap_curve_t curve;
   1180 } cam_profile_tone_curve;
   1181 
   1182 typedef struct {
   1183     cam_rational_type_t neutral_col_point[3];
   1184 } cam_neutral_col_point_t;
   1185 
   1186 typedef enum {
   1187     OFF,
   1188     FAST,
   1189     QUALITY,
   1190 } cam_quality_preference_t;
   1191 
   1192 typedef enum {
   1193     CAM_FLASH_CTRL_OFF,
   1194     CAM_FLASH_CTRL_SINGLE,
   1195     CAM_FLASH_CTRL_TORCH
   1196 } cam_flash_ctrl_t;
   1197 
   1198 typedef struct {
   1199     uint8_t frame_dropped; /*  This flag indicates whether any stream buffer is dropped or not */
   1200     cam_stream_ID_t cam_stream_ID; /* if dropped, Stream ID of dropped streams */
   1201 } cam_frame_dropped_t;
   1202 
   1203 typedef struct {
   1204     uint8_t ae_mode;
   1205     uint8_t awb_mode;
   1206     uint8_t af_mode;
   1207 } cam_scene_mode_overrides_t;
   1208 
   1209 typedef struct {
   1210     int32_t left;
   1211     int32_t top;
   1212     int32_t width;
   1213     int32_t height;
   1214 } cam_crop_region_t;
   1215 
   1216 typedef struct {
   1217     /* Estimated sharpness for each region of the input image.
   1218      * Normalized to be between 0 and maxSharpnessMapValue.
   1219      * Higher values mean sharper (better focused) */
   1220     int32_t sharpness[CAM_MAX_MAP_WIDTH][CAM_MAX_MAP_HEIGHT];
   1221 } cam_sharpness_map_t;
   1222 
   1223 typedef struct {
   1224    float lens_shading[4*CAM_MAX_SHADING_MAP_HEIGHT*CAM_MAX_SHADING_MAP_WIDTH];
   1225 } cam_lens_shading_map_t;
   1226 
   1227 typedef struct {
   1228     int32_t min_value;
   1229     int32_t max_value;
   1230     int32_t def_value;
   1231     int32_t step;
   1232 } cam_control_range_t;
   1233 
   1234 #define CAM_QCOM_FEATURE_FACE_DETECTION (1<<0)
   1235 #define CAM_QCOM_FEATURE_DENOISE2D      (1<<1)
   1236 #define CAM_QCOM_FEATURE_CROP           (1<<2)
   1237 #define CAM_QCOM_FEATURE_ROTATION       (1<<3)
   1238 #define CAM_QCOM_FEATURE_FLIP           (1<<4)
   1239 #define CAM_QCOM_FEATURE_HDR            (1<<5)
   1240 #define CAM_QCOM_FEATURE_REGISTER_FACE  (1<<6)
   1241 #define CAM_QCOM_FEATURE_SHARPNESS      (1<<7)
   1242 #define CAM_QCOM_FEATURE_VIDEO_HDR      (1<<8)
   1243 #define CAM_QCOM_FEATURE_CAC            (1<<9)
   1244 
   1245 // Counter clock wise
   1246 typedef enum {
   1247     ROTATE_0 = 1<<0,
   1248     ROTATE_90 = 1<<1,
   1249     ROTATE_180 = 1<<2,
   1250     ROTATE_270 = 1<<3,
   1251 } cam_rotation_t;
   1252 
   1253 typedef enum {
   1254     FLIP_H = 1<<0,
   1255     FLIP_V = 1<<1,
   1256 } cam_flip_t;
   1257 
   1258 typedef struct {
   1259     uint32_t bundle_id;                            /* bundle id */
   1260     uint8_t num_of_streams;                        /* number of streams in the bundle */
   1261     uint32_t stream_ids[MAX_STREAM_NUM_IN_BUNDLE]; /* array of stream ids to be bundled */
   1262 } cam_bundle_config_t;
   1263 
   1264 typedef enum {
   1265     CAM_ONLINE_REPROCESS_TYPE,    /* online reprocess, frames from running streams */
   1266     CAM_OFFLINE_REPROCESS_TYPE,   /* offline reprocess, frames from external source */
   1267 } cam_reprocess_type_enum_t;
   1268 
   1269 typedef struct {
   1270     /* reprocess feature mask */
   1271     uint32_t feature_mask;
   1272 
   1273     /* individual setting for features to be reprocessed */
   1274     cam_denoise_param_t denoise2d;
   1275     cam_rect_t input_crop;
   1276     cam_rotation_t rotation;
   1277     uint32_t flip;
   1278     int32_t sharpness;
   1279     int32_t hdr_need_1x; /* when CAM_QCOM_FEATURE_HDR enabled, indicate if 1x is needed for output */
   1280 } cam_pp_feature_config_t;
   1281 
   1282 typedef struct {
   1283     uint32_t input_stream_id;
   1284     /* input source stream type */
   1285     cam_stream_type_t input_stream_type;
   1286 } cam_pp_online_src_config_t;
   1287 
   1288 typedef struct {
   1289     /* image format */
   1290     cam_format_t input_fmt;
   1291 
   1292     /* image dimension */
   1293     cam_dimension_t input_dim;
   1294 
   1295     /* buffer plane information, will be calc based on stream_type, fmt,
   1296        dim, and padding_info(from stream config). Info including:
   1297        offset_x, offset_y, stride, scanline, plane offset */
   1298     cam_stream_buf_plane_info_t input_buf_planes;
   1299 
   1300     /* number of input reprocess buffers */
   1301     uint8_t num_of_bufs;
   1302 
   1303     cam_stream_type_t input_stream_type;
   1304 
   1305 } cam_pp_offline_src_config_t;
   1306 
   1307 /* reprocess stream input configuration */
   1308 typedef struct {
   1309     /* input source config */
   1310     cam_reprocess_type_enum_t pp_type;
   1311     union {
   1312         cam_pp_online_src_config_t online;
   1313         cam_pp_offline_src_config_t offline;
   1314     };
   1315 
   1316     /* pp feature config */
   1317     cam_pp_feature_config_t pp_feature_config;
   1318 } cam_stream_reproc_config_t;
   1319 
   1320 typedef struct {
   1321     uint8_t trigger;
   1322 } cam_trigger_t;
   1323 
   1324 typedef enum {
   1325     CAM_OPT_STAB_OFF,
   1326     CAM_OPT_STAB_ON,
   1327     CAM_OPT_STAB_MAX
   1328 } cam_optical_stab_modes_t;
   1329 
   1330 typedef enum {
   1331     CAM_FILTER_ARRANGEMENT_RGGB,
   1332     CAM_FILTER_ARRANGEMENT_GRBG,
   1333     CAM_FILTER_ARRANGEMENT_GBRG,
   1334     CAM_FILTER_ARRANGEMENT_BGGR,
   1335 
   1336     /* Sensor is not Bayer; output has 3 16-bit values for each pixel,
   1337      * instead of just 1 16-bit value per pixel.*/
   1338     CAM_FILTER_ARRANGEMENT_RGB
   1339 } cam_color_filter_arrangement_t;
   1340 
   1341 typedef enum {
   1342     CAM_AF_STATE_INACTIVE,
   1343     CAM_AF_STATE_PASSIVE_SCAN,
   1344     CAM_AF_STATE_PASSIVE_FOCUSED,
   1345     CAM_AF_STATE_ACTIVE_SCAN,
   1346     CAM_AF_STATE_FOCUSED_LOCKED,
   1347     CAM_AF_STATE_NOT_FOCUSED_LOCKED,
   1348     CAM_AF_STATE_PASSIVE_UNFOCUSED
   1349 } cam_af_state_t;
   1350 
   1351 typedef enum {
   1352   CAM_AF_LENS_STATE_STATIONARY,
   1353   CAM_AF_LENS_STATE_MOVING,
   1354 } cam_af_lens_state_t;
   1355 
   1356 typedef enum {
   1357     CAM_AWB_STATE_INACTIVE,
   1358     CAM_AWB_STATE_SEARCHING,
   1359     CAM_AWB_STATE_CONVERGED,
   1360     CAM_AWB_STATE_LOCKED
   1361 } cam_awb_state_t;
   1362 
   1363 typedef enum {
   1364     CAM_FOCUS_UNCALIBRATED,
   1365     CAM_FOCUS_APPROXIMATE,
   1366     CAM_FOCUS_CALIBRATED
   1367 } cam_focus_calibration_t;
   1368 
   1369 typedef enum {
   1370     CAM_TEST_PATTERN_OFF,
   1371     CAM_TEST_PATTERN_SOLID_COLOR,
   1372     CAM_TEST_PATTERN_COLOR_BARS,
   1373     CAM_TEST_PATTERN_COLOR_BARS_FADE_TO_GRAY,
   1374     CAM_TEST_PATTERN_PN9,
   1375 } cam_test_pattern_mode_t;
   1376 
   1377 typedef struct {
   1378     cam_test_pattern_mode_t mode;
   1379     int32_t r;
   1380     int32_t gr;
   1381     int32_t gb;
   1382     int32_t b;
   1383 } cam_test_pattern_data_t;
   1384 
   1385 typedef enum {
   1386     CAM_AWB_D50,
   1387     CAM_AWB_D65,
   1388     CAM_AWB_D75,
   1389     CAM_AWB_A,
   1390     CAM_AWB_CUSTOM_A,
   1391     CAM_AWB_WARM_FLO,
   1392     CAM_AWB_COLD_FLO,
   1393     CAM_AWB_CUSTOM_FLO,
   1394     CAM_AWB_NOON,
   1395     CAM_AWB_CUSTOM_DAYLIGHT,
   1396     CAM_AWB_INVALID_ALL_LIGHT,
   1397 } cam_illuminant_t;
   1398 
   1399 typedef enum {
   1400     LEGACY_RAW,
   1401     MIPI_RAW,
   1402 } cam_opaque_raw_format_t;
   1403 
   1404 #endif /* __QCAMERA_TYPES_H__ */
   1405