From 6616278131edd80a12545085e06ee6b0e0a0a788 Mon Sep 17 00:00:00 2001 From: Prateek Chaubey Date: Sun, 7 Jan 2018 20:55:14 +0530 Subject: msm8996-common: zuk: Import OSS Camera HAL Tag: LA.HB.1.3.2-32600-8x96.0 Signed-off-by: Davide Garberi --- camera/QCamera2/stack/common/cam_intf.h | 1067 ++++++++ camera/QCamera2/stack/common/cam_list.h | 84 + camera/QCamera2/stack/common/cam_queue.h | 134 + camera/QCamera2/stack/common/cam_semaphore.h | 88 + camera/QCamera2/stack/common/cam_types.h | 2753 ++++++++++++++++++++ camera/QCamera2/stack/common/mm_camera_interface.h | 923 +++++++ camera/QCamera2/stack/common/mm_jpeg_interface.h | 408 +++ 7 files changed, 5457 insertions(+) create mode 100644 camera/QCamera2/stack/common/cam_intf.h create mode 100644 camera/QCamera2/stack/common/cam_list.h create mode 100644 camera/QCamera2/stack/common/cam_queue.h create mode 100644 camera/QCamera2/stack/common/cam_semaphore.h create mode 100644 camera/QCamera2/stack/common/cam_types.h create mode 100644 camera/QCamera2/stack/common/mm_camera_interface.h create mode 100644 camera/QCamera2/stack/common/mm_jpeg_interface.h (limited to 'camera/QCamera2/stack/common') diff --git a/camera/QCamera2/stack/common/cam_intf.h b/camera/QCamera2/stack/common/cam_intf.h new file mode 100644 index 0000000..9eb52e9 --- /dev/null +++ b/camera/QCamera2/stack/common/cam_intf.h @@ -0,0 +1,1067 @@ +/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __QCAMERA_INTF_H__ +#define __QCAMERA_INTF_H__ + +// System dependencies +#include +#include + +// Camera dependencies +#include "cam_types.h" + +#define CAM_PRIV_IOCTL_BASE (V4L2_CID_PRIVATE_BASE + MSM_CAMERA_PRIV_CMD_MAX) +typedef enum { + /* session based parameters */ + CAM_PRIV_PARM = CAM_PRIV_IOCTL_BASE, + /* session based action: do auto focus.*/ + CAM_PRIV_DO_AUTO_FOCUS, + /* session based action: cancel auto focus.*/ + CAM_PRIV_CANCEL_AUTO_FOCUS, + /* session based action: prepare for snapshot.*/ + CAM_PRIV_PREPARE_SNAPSHOT, + /* sync stream info.*/ + CAM_PRIV_STREAM_INFO_SYNC, + /* stream based parameters*/ + CAM_PRIV_STREAM_PARM, + /* start ZSL snapshot.*/ + CAM_PRIV_START_ZSL_SNAPSHOT, + /* stop ZSL snapshot.*/ + CAM_PRIV_STOP_ZSL_SNAPSHOT, + /* event for related sensors synchronization. */ + CAM_PRIV_SYNC_RELATED_SENSORS, + /* flush */ + CAM_PRIV_FLUSH +} cam_private_ioctl_enum_t; + +typedef enum { + /* start syncing for related cameras */ + CAM_SYNC_RELATED_SENSORS_ON = 1, + /* stop syncing for related cameras */ + CAM_SYNC_RELATED_SENSORS_OFF +} cam_sync_related_sensors_control_t; + +typedef enum { + /* Driving camera of the related camera sub-system */ + /* Certain features are enabled only for primary camera + such as display mode for preview, autofocus etc + In certain configurations for eg. when optical zoom + limit is reached, Aux Camera would become + the driving camera and there will be role switch.*/ + CAM_MODE_PRIMARY = 0, + /* Non-driving camera of the related camera sub-system + no display mode set for secondary camera */ + CAM_MODE_SECONDARY +} cam_sync_mode_t; + +/* Payload for sending bundling info to backend */ +typedef struct { + cam_sync_related_sensors_control_t sync_control; + cam_sync_type_t type; + cam_sync_mode_t mode; + /* session Id of the other camera session + Linking will be done with this session in the + backend */ + uint32_t related_sensor_session_id; + uint8_t is_frame_sync_enabled; +}cam_sync_related_sensors_event_info_t; + +/* Related camera sensor specific calibration data */ +// Align bytes according to API document. +#pragma pack(2) +typedef struct { + /* Focal length in pixels @ calibration resolution.*/ + float normalized_focal_length; + /* Native sensor resolution W that was used to capture calibration image */ + uint16_t native_sensor_resolution_width; + /* Native sensor resolution H that was used to capture calibration image */ + uint16_t native_sensor_resolution_height; + /* Image size W used internally by calibration tool */ + uint16_t calibration_sensor_resolution_width; + /* Image size H used internally by calibration tool */ + uint16_t calibration_sensor_resolution_height; + /* Focal length ratio @ Calibration */ + float focal_length_ratio; +}cam_related_sensor_calibration_data_t; +#pragma pack() + +/* Related Camera System Calibration data + Calibration data for the entire related cam sub-system is + in a shared EEPROM. We have 2 fields which are specific to + each sensor followed by a set of common calibration of the + entire related cam system*/ +// Align bytes according to API document. +#pragma pack(2) +typedef struct { + /* Version information */ + uint32_t calibration_format_version; + /* Main Camera Sensor specific calibration */ + cam_related_sensor_calibration_data_t main_cam_specific_calibration; + /* Aux Camera Sensor specific calibration */ + cam_related_sensor_calibration_data_t aux_cam_specific_calibration; + /* Relative viewpoint matching matrix w.r.t Main */ + float relative_rotation_matrix[RELCAM_CALIB_ROT_MATRIX_MAX]; + /* Relative geometric surface description parameters */ + float relative_geometric_surface_parameters[ + RELCAM_CALIB_SURFACE_PARMS_MAX]; + /* Relative offset of sensor center from optical axis along horizontal dimension */ + float relative_principle_point_x_offset; + /* Relative offset of sensor center from optical axis along vertical dimension */ + float relative_principle_point_y_offset; + /* 0=Main Camera is on the left of Aux; 1=Main Camera is on the right of Aux */ + uint16_t relative_position_flag; + /* Camera separation in mm */ + float relative_baseline_distance; + /* main sensor setting during cal: 0-none, 1-hor-mirror, 2-ver-flip, 3-both */ + uint16_t main_sensor_mirror_flip_setting; + /* aux sensor setting during cal: 0-none, 1-hor-mirror, 2-ver-flip, 3-both */ + uint16_t aux_sensor_mirror_flip_setting; + /* module orientation during cal: 0-sensors in landscape, 1-sensors in portrait */ + uint16_t module_orientation_during_calibration; + /* cal images required rotation: 0-no, 1-90 degrees right, 2-90 degrees left */ + uint16_t rotation_flag; + /* AEC sync OTP data */ + /* AEC sync brightness ration. Fixed Point Q10*/ + int16_t brightness_ratio; + /* Reference mono gain value obtained from setup stage and used during calibration stage */ + /* Fixed Point Q10 */ + int16_t ref_mono_gain; + /* Reference mono line count obtained from setup stage and used during calibration stage */ + uint16_t ref_mono_linecount; + /* Reference bayer gain value obtained from setup stage and used during calibration stage */ + /* Fixed Point Q10 */ + int16_t ref_bayer_gain; + /* Reference bayer line count obtained from setup stage and used during calibration stage */ + uint16_t ref_bayer_linecount; + /* Reference bayer color temperature */ + uint16_t ref_bayer_color_temperature; + /* Reserved for future use */ + float reserved[RELCAM_CALIB_RESERVED_MAX]; +} cam_related_system_calibration_data_t; +#pragma pack() + +typedef struct { + uint32_t default_sensor_flip; + uint32_t sensor_mount_angle; + cam_related_system_calibration_data_t otp_calibration_data; +} cam_jpeg_metadata_t; + +/* capability struct definition for HAL 1*/ +typedef struct{ + cam_hal_version_t version; + + cam_position_t position; /* sensor position: front, back */ + + uint8_t auto_hdr_supported; + + uint16_t isWnrSupported; + /* supported iso modes */ + size_t supported_iso_modes_cnt; + cam_iso_mode_type supported_iso_modes[CAM_ISO_MODE_MAX]; + + /* supported flash modes */ + size_t supported_flash_modes_cnt; + cam_flash_mode_t supported_flash_modes[CAM_FLASH_MODE_MAX]; + + size_t zoom_ratio_tbl_cnt; /* table size for zoom ratios */ + uint32_t zoom_ratio_tbl[MAX_ZOOMS_CNT]; /* zoom ratios table */ + + /* supported effect modes */ + size_t supported_effects_cnt; + cam_effect_mode_type supported_effects[CAM_EFFECT_MODE_MAX]; + + /* supported scene modes */ + size_t supported_scene_modes_cnt; + cam_scene_mode_type supported_scene_modes[CAM_SCENE_MODE_MAX]; + + /* supported auto exposure modes */ + size_t supported_aec_modes_cnt; + cam_auto_exposure_mode_type supported_aec_modes[CAM_AEC_MODE_MAX]; + + size_t fps_ranges_tbl_cnt; /* fps ranges table size */ + cam_fps_range_t fps_ranges_tbl[MAX_SIZES_CNT]; /* fps ranges table */ + + /* supported antibanding modes */ + size_t supported_antibandings_cnt; + cam_antibanding_mode_type supported_antibandings[CAM_ANTIBANDING_MODE_MAX]; + + /* supported white balance modes */ + size_t supported_white_balances_cnt; + cam_wb_mode_type supported_white_balances[CAM_WB_MODE_MAX]; + + /* Capability list of supported insensor HDR types + * Backend is expected to fill in all the supported types and set appropriate + * count, see cam_sensor_hdr_type_t for valid types + */ + size_t supported_sensor_hdr_types_cnt; + cam_sensor_hdr_type_t supported_sensor_hdr_types[CAM_SENSOR_HDR_MAX]; + + /* supported manual wb cct */ + int32_t min_wb_cct; + int32_t max_wb_cct; + + /* supported manual wb rgb gains */ + float min_wb_gain; + float max_wb_gain; + + /* supported focus modes */ + size_t supported_focus_modes_cnt; + cam_focus_mode_type supported_focus_modes[CAM_FOCUS_MODE_MAX]; + + /* supported manual focus position */ + float min_focus_pos[CAM_MANUAL_FOCUS_MODE_MAX]; + float max_focus_pos[CAM_MANUAL_FOCUS_MODE_MAX]; + + int32_t exposure_compensation_min; /* min value of exposure compensation index */ + int32_t exposure_compensation_max; /* max value of exposure compensation index */ + int32_t exposure_compensation_default; /* default value of exposure compensation index */ + float exposure_compensation_step; + cam_rational_type_t exp_compensation_step; /* exposure compensation step value */ + + uint8_t video_stablization_supported; /* flag id video stablization is supported */ + + size_t picture_sizes_tbl_cnt; /* picture sizes table size */ + cam_dimension_t picture_sizes_tbl[MAX_SIZES_CNT]; /* picture sizes table */ + /* The minimum frame duration that is supported for each + * resolution in availableProcessedSizes. Should correspond + * to the frame duration when only that processed stream + * is active, with all processing set to FAST */ + int64_t picture_min_duration[MAX_SIZES_CNT]; + + /* capabilities specific to HAL 1 */ + + int32_t modes_supported; /* mask of modes supported: 2D, 3D */ + uint32_t sensor_mount_angle; /* sensor mount angle */ + + float focal_length; /* focal length */ + float hor_view_angle; /* horizontal view angle */ + float ver_view_angle; /* vertical view angle */ + + size_t preview_sizes_tbl_cnt; /* preview sizes table size */ + cam_dimension_t preview_sizes_tbl[MAX_SIZES_CNT]; /* preiew sizes table */ + + size_t video_sizes_tbl_cnt; /* video sizes table size */ + cam_dimension_t video_sizes_tbl[MAX_SIZES_CNT]; /* video sizes table */ + + + size_t livesnapshot_sizes_tbl_cnt; /* livesnapshot sizes table size */ + cam_dimension_t livesnapshot_sizes_tbl[MAX_SIZES_CNT]; /* livesnapshot sizes table */ + + size_t vhdr_livesnapshot_sizes_tbl_cnt; /* vhdr_livesnapshot sizes table size */ + cam_dimension_t vhdr_livesnapshot_sizes_tbl[MAX_SIZES_CNT]; /* vhdr_livesnapshot sizes table */ + + size_t hfr_tbl_cnt; /* table size for HFR */ + cam_hfr_info_t hfr_tbl[CAM_HFR_MODE_MAX]; /* HFR table */ + + size_t zzhdr_sizes_tbl_cnt; /* Number of resolutions in zzHDR mode*/ + cam_dimension_t zzhdr_sizes_tbl[MAX_SIZES_CNT]; /* Table for ZZHDR supported sizes */ + + size_t supported_quadra_cfa_dim_cnt; /* Number of resolutions in Quadra CFA mode */ + cam_dimension_t quadra_cfa_dim[MAX_SIZES_CNT]; /* Table for Quadra CFA supported sizes */ + cam_format_t quadra_cfa_format; /* Quadra CFA output format */ + uint32_t is_remosaic_lib_present; /* Flag indicating if remosaic lib present */ + + /* supported preview formats */ + size_t supported_preview_fmt_cnt; + cam_format_t supported_preview_fmts[CAM_FORMAT_MAX]; + + /* supported picture formats */ + size_t supported_picture_fmt_cnt; + cam_format_t supported_picture_fmts[CAM_FORMAT_MAX]; + + uint8_t max_downscale_factor; + + /* dimension and supported output format of raw dump from camif */ + size_t supported_raw_dim_cnt; + cam_dimension_t raw_dim[MAX_SIZES_CNT]; + size_t supported_raw_fmt_cnt; + cam_format_t supported_raw_fmts[CAM_FORMAT_MAX]; + /* The minimum frame duration that is supported for above + raw resolution */ + int64_t raw_min_duration[MAX_SIZES_CNT]; + + /* 3A version*/ + cam_q3a_version_t q3a_version; + /* supported focus algorithms */ + size_t supported_focus_algos_cnt; + cam_focus_algorithm_type supported_focus_algos[CAM_FOCUS_ALGO_MAX]; + + + uint8_t auto_wb_lock_supported; /* flag if auto white balance lock is supported */ + uint8_t zoom_supported; /* flag if zoom is supported */ + uint8_t smooth_zoom_supported; /* flag if smooth zoom is supported */ + uint8_t auto_exposure_lock_supported; /* flag if auto exposure lock is supported */ + uint8_t video_snapshot_supported; /* flag if video snapshot is supported */ + + uint8_t max_num_roi; /* max number of roi can be detected */ + uint8_t max_num_focus_areas; /* max num of focus areas */ + uint8_t max_num_metering_areas; /* max num opf metering areas */ + uint8_t max_zoom_step; /* max zoom step value */ + + /* QCOM specific control */ + cam_control_range_t brightness_ctrl; /* brightness */ + cam_control_range_t sharpness_ctrl; /* sharpness */ + cam_control_range_t contrast_ctrl; /* contrast */ + cam_control_range_t saturation_ctrl; /* saturation */ + cam_control_range_t sce_ctrl; /* skintone enhancement factor */ + + /* QCOM HDR specific control. Indicates number of frames and exposure needs for the frames */ + cam_hdr_bracketing_info_t hdr_bracketing_setting; + + cam_feature_mask_t qcom_supported_feature_mask; /* mask of qcom specific features supported: + * such as CAM_QCOM_FEATURE_SUPPORTED_FACE_DETECTION*/ + cam_padding_info_t padding_info; /* padding information from PP */ + uint32_t min_num_pp_bufs; /* minimum number of buffers needed by postproc module */ + cam_format_t rdi_mode_stream_fmt; /* stream format supported in rdi mode */ + + /* capabilities specific to HAL 3 */ + + float min_focus_distance; + float hyper_focal_distance; + + float focal_lengths[CAM_FOCAL_LENGTHS_MAX]; + uint8_t focal_lengths_count; + + /* Needs to be regular f number instead of APEX */ + float apertures[CAM_APERTURES_MAX]; + uint8_t apertures_count; + + float filter_densities[CAM_FILTER_DENSITIES_MAX]; + uint8_t filter_densities_count; + + uint8_t optical_stab_modes[CAM_OPT_STAB_MAX]; + uint8_t optical_stab_modes_count; + + cam_dimension_t lens_shading_map_size; + + cam_dimension_t geo_correction_map_size; + float geo_correction_map[2 * 3 * CAM_MAX_MAP_WIDTH * + CAM_MAX_MAP_HEIGHT]; + + float lens_position[3]; + + /* nano seconds */ + int64_t exposure_time_range[EXPOSURE_TIME_RANGE_CNT]; + + /* nano seconds */ + int64_t max_frame_duration; + + cam_color_filter_arrangement_t color_arrangement; + uint8_t num_color_channels; + + /* parameters required to calculate S and O co-efficients */ + double gradient_S; + double offset_S; + double gradient_O; + double offset_O; + + float sensor_physical_size[SENSOR_PHYSICAL_SIZE_CNT]; + + /* Dimensions of full pixel array, possibly including + black calibration pixels */ + cam_dimension_t pixel_array_size; + /* Area of raw data which corresponds to only active + pixels; smaller or equal to pixelArraySize. */ + cam_rect_t active_array_size; + + /* Maximum raw value output by sensor */ + int32_t white_level; + + /* A fixed black level offset for each of the Bayer + mosaic channels */ + int32_t black_level_pattern[BLACK_LEVEL_PATTERN_CNT]; + + /* Time taken before flash can fire again in nano secs */ + int64_t flash_charge_duration; + + /* flash firing power */ + size_t supported_flash_firing_level_cnt; + cam_format_t supported_firing_levels[CAM_FLASH_FIRING_LEVEL_MAX]; + + /* Flash Firing Time */ + int64_t flash_firing_time; + + /* Flash Ciolor Temperature */ + uint8_t flash_color_temp; + + /* Flash max Energy */ + uint8_t flash_max_energy; + + /* Maximum number of supported points in the tonemap + curve */ + int32_t max_tone_map_curve_points; + + /* supported formats */ + size_t supported_scalar_format_cnt; + cam_format_t supported_scalar_fmts[CAM_FORMAT_MAX]; + + uint32_t max_face_detection_count; + + uint8_t histogram_supported; + /* Number of histogram buckets supported */ + int32_t histogram_size; + /* Maximum value possible for a histogram bucket */ + int32_t max_histogram_count; + + cam_dimension_t sharpness_map_size; + + /* Maximum value possible for a sharpness map region */ + int32_t max_sharpness_map_value; + + /*Autoexposure modes for camera 3 api*/ + size_t supported_ae_modes_cnt; + cam_ae_mode_type supported_ae_modes[CAM_AE_MODE_MAX]; + + + cam_sensitivity_range_t sensitivity_range; + int32_t max_analog_sensitivity; + + /* ISP digital gain */ + cam_sensitivity_range_t isp_sensitivity_range; + + /* picture sizes need scale*/ + cam_scene_mode_overrides_t scene_mode_overrides[CAM_SCENE_MODE_MAX]; + size_t scale_picture_sizes_cnt; + cam_dimension_t scale_picture_sizes[MAX_SCALE_SIZES_CNT]; + + uint8_t flash_available; + + cam_rational_type_t base_gain_factor; /* sensor base gain factor */ + /* AF Bracketing info */ + cam_af_bracketing_t ubifocus_af_bracketing_need; + cam_af_bracketing_t refocus_af_bracketing_need; + /* opti Zoom info */ + cam_opti_zoom_t opti_zoom_settings_need; + /* still more info */ + cam_still_more_t stillmore_settings_need; + /* chroma flash info */ + cam_chroma_flash_t chroma_flash_settings_need; + + cam_rational_type_t forward_matrix[3][3]; + cam_rational_type_t color_transform[3][3]; + + uint8_t focus_dist_calibrated; + uint8_t supported_test_pattern_modes_cnt; + cam_test_pattern_mode_t supported_test_pattern_modes[MAX_TEST_PATTERN_CNT]; + + int64_t stall_durations[MAX_SIZES_CNT]; + + cam_illuminat_t reference_illuminant1; + cam_illuminat_t reference_illuminant2; + + int64_t jpeg_stall_durations[MAX_SIZES_CNT]; + int64_t raw16_stall_durations[MAX_SIZES_CNT]; + cam_rational_type_t forward_matrix1[FORWARD_MATRIX_ROWS][FORWARD_MATRIX_COLS]; + cam_rational_type_t forward_matrix2[FORWARD_MATRIX_ROWS][FORWARD_MATRIX_COLS]; + cam_rational_type_t color_transform1[COLOR_TRANSFORM_ROWS][COLOR_TRANSFORM_COLS]; + cam_rational_type_t color_transform2[COLOR_TRANSFORM_ROWS][COLOR_TRANSFORM_COLS]; + cam_rational_type_t calibration_transform1[CAL_TRANSFORM_ROWS][CAL_TRANSFORM_COLS]; + cam_rational_type_t calibration_transform2[CAL_TRANSFORM_ROWS][CAL_TRANSFORM_COLS]; + uint16_t isCacSupported; + + cam_opaque_raw_format_t opaque_raw_fmt; + + /* true Portrait info */ + cam_true_portrait_t true_portrait_settings_need; + + /* Sensor type information */ + cam_sensor_type_t sensor_type; + + cam_aberration_mode_t aberration_modes[CAM_COLOR_CORRECTION_ABERRATION_MAX]; + uint32_t aberration_modes_count; + + /* Can the sensor timestamp be compared to + * timestamps from other sub-systems (gyro, accelerometer etc.) */ + uint8_t isTimestampCalibrated; + + /* Max size supported by ISP viewfinder path */ + cam_dimension_t max_viewfinder_size; + + /* Analysis buffer requirements */ + cam_analysis_info_t analysis_info[CAM_ANALYSIS_INFO_MAX]; + + /* This is set to 'true' if sensor cannot guarantee per frame control */ + /* Default value of this capability is 'false' indicating per-frame */ + /* control is supported */ + uint8_t no_per_frame_control_support; + + /* EIS information */ + uint8_t supported_is_types_cnt; + uint32_t supported_is_types[IS_TYPE_MAX]; + /*for each type, specify the margin needed. Margin will be + the decimal representation of a percentage + ex: 10% margin = 0.1 */ + float supported_is_type_margins[IS_TYPE_MAX]; + + /* Max cpp batch size */ + uint8_t max_batch_bufs_supported; + uint32_t buf_alignment; + uint32_t min_stride; + uint32_t min_scanline; + uint8_t flash_dev_name[QCAMERA_MAX_FILEPATH_LENGTH]; + uint8_t eeprom_version_info[MAX_EEPROM_VERSION_INFO_LEN]; + + /* maximum pixel bandwidth shared between cameras */ + uint64_t max_pixel_bandwidth; + + /* Array of K integers, where K%4==0, + as a list of rectangles in the pixelArray co-ord system + left, top, right, bottom */ + int32_t optical_black_regions[MAX_OPTICAL_BLACK_REGIONS * 4]; + /* Count is K/4 */ + uint8_t optical_black_region_count; + + /* hot pixel */ + uint8_t hotPixel_mode; + uint32_t hotPixel_count; + cam_coordinate_type_t hotPixelMap[512]; + + /* supported instant capture/AEC convergence modes */ + size_t supported_instant_aec_modes_cnt; + cam_aec_convergence_type supported_instant_aec_modes[CAM_AEC_CONVERGENCE_MAX]; + + /* Dual cam calibration data */ + cam_related_system_calibration_data_t related_cam_calibration; +} cam_capability_t; + +typedef enum { + CAM_STREAM_PARAM_TYPE_DO_REPROCESS = CAM_INTF_PARM_DO_REPROCESS, + CAM_STREAM_PARAM_TYPE_SET_BUNDLE_INFO = CAM_INTF_PARM_SET_BUNDLE, + CAM_STREAM_PARAM_TYPE_SET_FLIP = CAM_INTF_PARM_STREAM_FLIP, + CAM_STREAM_PARAM_TYPE_GET_OUTPUT_CROP = CAM_INTF_PARM_GET_OUTPUT_CROP, + CAM_STREAM_PARAM_TYPE_GET_IMG_PROP = CAM_INTF_PARM_GET_IMG_PROP, + CAM_STREAM_PARAM_TYPE_REQUEST_FRAMES = CAM_INTF_PARM_REQUEST_FRAMES, + CAM_STREAM_PARAM_TYPE_REQUEST_OPS_MODE = CAM_INTF_PARM_REQUEST_OPS_MODE, + CAM_STREAM_PARAM_TYPE_MAX +} cam_stream_param_type_e; + +typedef struct { + uint32_t buf_index; /* buf index to the source frame buffer that needs reprocess, + (assume buffer is already mapped)*/ + uint32_t frame_idx; /* frame id of source frame to be reprocessed */ + int32_t ret_val; /* return value from reprocess. Could have different meanings. + i.e., faceID in the case of face registration. */ + uint8_t meta_present; /* if there is meta data associated with this reprocess frame */ + uint32_t meta_stream_handle; /* meta data stream ID. only valid if meta_present != 0 */ + uint32_t meta_buf_index; /* buf index to meta data buffer. only valid if meta_present != 0 */ + + /* opaque metadata required for reprocessing */ + int32_t private_data[MAX_METADATA_PRIVATE_PAYLOAD_SIZE_IN_BYTES]; + cam_rect_t crop_rect; +} cam_reprocess_param; + +typedef struct { + uint32_t flip_mask; +} cam_flip_mode_t; + +#define IMG_NAME_SIZE 32 +typedef struct { + cam_rect_t crop; /* crop info for the image */ + cam_dimension_t input; /* input dimension of the image */ + cam_dimension_t output; /* output dimension of the image */ + char name[IMG_NAME_SIZE]; /* optional name of the ext*/ + cam_format_t format; /* image format */ +} cam_stream_img_prop_t; + +typedef struct { + uint8_t enableStream; /*0 – stop and 1-start */ +} cam_request_frames; + +typedef struct { + cam_stream_param_type_e type; + union { + cam_reprocess_param reprocess; /* do reprocess */ + cam_bundle_config_t bundleInfo; /* set bundle info*/ + cam_flip_mode_t flipInfo; /* flip mode */ + cam_crop_data_t outputCrop; /* output crop for current frame */ + cam_stream_img_prop_t imgProp; /* image properties of current frame */ + cam_request_frames frameRequest; /*do TNR process*/ + cam_perf_mode_t perf_mode; /*request operational mode*/ + }; +} cam_stream_parm_buffer_t; + +/* stream info */ +typedef struct { + /* stream ID from server */ + uint32_t stream_svr_id; + + /* stream type */ + cam_stream_type_t stream_type; + + /* image format */ + cam_format_t fmt; + + /* image dimension */ + cam_dimension_t dim; + + /* buffer plane information, will be calc based on stream_type, fmt, + dim, and padding_info(from stream config). Info including: + offset_x, offset_y, stride, scanline, plane offset */ + cam_stream_buf_plane_info_t buf_planes; + + /* number of stream bufs will be allocated */ + uint32_t num_bufs; + + /* streaming type */ + cam_streaming_mode_t streaming_mode; + + /* num of frames needs to be generated. + * only valid when streaming_mode = CAM_STREAMING_MODE_BURST */ + uint8_t num_of_burst; + + /* num of frames in one batch. + * only valid when streaming_mode = CAM_STREAMING_MODE_BATCH */ + cam_stream_user_buf_info_t user_buf_info; + + /* stream specific pp config */ + cam_pp_feature_config_t pp_config; + + /* this section is valid if offline reprocess type stream */ + cam_stream_reproc_config_t reprocess_config; + + cam_stream_parm_buffer_t parm_buf; /* stream based parameters */ + + uint8_t dis_enable; + + /* Image Stabilization type */ + cam_is_type_t is_type; + + /* Signifies Secure stream mode */ + cam_stream_secure_t is_secure; + + /* Preferred Performance mode */ + cam_perf_mode_t perf_mode; + + /* if frames will not be received */ + uint8_t noFrameExpected; +} cam_stream_info_t; + +/***************************************************************************** + * Code for Domain Socket Based Parameters * + ****************************************************************************/ +#define INCLUDE(PARAM_ID,DATATYPE,COUNT) \ + DATATYPE member_variable_##PARAM_ID[ COUNT ] + +#define POINTER_OF_META(META_ID, TABLE_PTR) \ + ((NULL != TABLE_PTR) ? \ + (&TABLE_PTR->data.member_variable_##META_ID[ 0 ]) : (NULL)) + +#define SIZE_OF_PARAM(META_ID, TABLE_PTR) \ + sizeof(TABLE_PTR->data.member_variable_##META_ID) + +#define IF_META_AVAILABLE(META_TYPE, META_PTR_NAME, META_ID, TABLE_PTR) \ + META_TYPE *META_PTR_NAME = \ + (((NULL != TABLE_PTR) && (TABLE_PTR->is_valid[META_ID])) ? \ + (&TABLE_PTR->data.member_variable_##META_ID[ 0 ]) : \ + (NULL)); \ + if (NULL != META_PTR_NAME) \ + +#define ADD_SET_PARAM_ENTRY_TO_BATCH(TABLE_PTR, META_ID, DATA) \ + ((NULL != TABLE_PTR) ? \ + ((TABLE_PTR->data.member_variable_##META_ID[ 0 ] = DATA), \ + (TABLE_PTR->is_valid[META_ID] = 1), (0)) : \ + ((LOGE("Unable to set metadata TABLE_PTR:%p META_ID:%d", \ + TABLE_PTR, META_ID)), (-1))) \ + +#define ADD_SET_PARAM_ARRAY_TO_BATCH(TABLE_PTR, META_ID, PDATA, COUNT, RCOUNT) \ +{ \ + if ((NULL != TABLE_PTR) && \ + (0 < COUNT) && \ + ((sizeof(TABLE_PTR->data.member_variable_##META_ID) / \ + sizeof(TABLE_PTR->data.member_variable_##META_ID[ 0 ])) \ + >= COUNT)) { \ + for (size_t _i = 0; _i < COUNT ; _i++) { \ + TABLE_PTR->data.member_variable_##META_ID[ _i ] = PDATA [ _i ]; \ + } \ + TABLE_PTR->is_valid[META_ID] = 1; \ + RCOUNT = COUNT; \ + } else { \ + LOGE("Unable to set metadata TABLE_PTR:%p META_ID:%d COUNT:%zu", \ + TABLE_PTR, META_ID, COUNT); \ + RCOUNT = 0; \ + } \ +} + +#define ADD_GET_PARAM_ENTRY_TO_BATCH(TABLE_PTR, META_ID) \ +{ \ + if (NULL != TABLE_PTR) { \ + TABLE_PTR->is_reqd[META_ID] = 1; \ + } else { \ + LOGE("Unable to get metadata TABLE_PTR:%p META_ID:%d", \ + TABLE_PTR, META_ID); \ + } \ +} + +#define READ_PARAM_ENTRY(TABLE_PTR, META_ID, DATA) \ +{ \ + if (NULL != TABLE_PTR) { \ + DATA = TABLE_PTR->data.member_variable_##META_ID[ 0 ]; \ + } else { \ + LOGE("Unable to read metadata TABLE_PTR:%p META_ID:%d", \ + TABLE_PTR, META_ID); \ + } \ +} + +/************************************ +* Custom parameter data definition +*************************************/ +typedef struct { + /*CAM_CUSTOM_PARM_EXAMPLE is added to explain custom param procedure*/ + INCLUDE(CAM_CUSTOM_PARM_EXAMPLE, int32_t, 1); +} custom_parm_data_t; + +/************************************ +* Custom Parameter buffer definition +*************************************/ +typedef struct { + union { + /* Hash table of 'is valid' flags */ + uint8_t is_valid[CAM_CUSTOM_PARM_MAX]; + + /* Hash table of 'is required' flags for the GET PARAM */ + uint8_t is_reqd[CAM_CUSTOM_PARM_MAX]; + }; + custom_parm_data_t data; +} custom_parm_buffer_t; + + +typedef struct { +/************************************************************************************** + * ID from (cam_intf_metadata_type_t) DATATYPE COUNT + **************************************************************************************/ + /* common between HAL1 and HAL3 */ + INCLUDE(CAM_INTF_META_HISTOGRAM, cam_hist_stats_t, 1); + INCLUDE(CAM_INTF_META_FACE_DETECTION, cam_face_detection_data_t, 1); + INCLUDE(CAM_INTF_META_FACE_RECOG, cam_face_recog_data_t, 1); + INCLUDE(CAM_INTF_META_FACE_BLINK, cam_face_blink_data_t, 1); + INCLUDE(CAM_INTF_META_FACE_GAZE, cam_face_gaze_data_t, 1); + INCLUDE(CAM_INTF_META_FACE_SMILE, cam_face_smile_data_t, 1); + INCLUDE(CAM_INTF_META_FACE_LANDMARK, cam_face_landmarks_data_t, 1); + INCLUDE(CAM_INTF_META_FACE_CONTOUR, cam_face_contour_data_t, 1); + INCLUDE(CAM_INTF_META_AUTOFOCUS_DATA, cam_auto_focus_data_t, 1); + INCLUDE(CAM_INTF_META_CDS_DATA, cam_cds_data_t, 1); + INCLUDE(CAM_INTF_PARM_UPDATE_DEBUG_LEVEL, uint32_t, 1); + + /* Specific to HAl1 */ + INCLUDE(CAM_INTF_META_CROP_DATA, cam_crop_data_t, 1); + INCLUDE(CAM_INTF_META_PREP_SNAPSHOT_DONE, int32_t, 1); + INCLUDE(CAM_INTF_META_GOOD_FRAME_IDX_RANGE, cam_frame_idx_range_t, 1); + INCLUDE(CAM_INTF_META_ASD_HDR_SCENE_DATA, cam_asd_hdr_scene_data_t, 1); + INCLUDE(CAM_INTF_META_ASD_SCENE_INFO, cam_asd_decision_t, 1); + INCLUDE(CAM_INTF_META_CURRENT_SCENE, cam_scene_mode_type, 1); + INCLUDE(CAM_INTF_META_AWB_INFO, cam_awb_params_t, 1); + INCLUDE(CAM_INTF_META_FOCUS_POSITION, cam_focus_pos_info_t, 1); + INCLUDE(CAM_INTF_META_CHROMATIX_LITE_ISP, cam_chromatix_lite_isp_t, 1); + INCLUDE(CAM_INTF_META_CHROMATIX_LITE_PP, cam_chromatix_lite_pp_t, 1); + INCLUDE(CAM_INTF_META_CHROMATIX_LITE_AE, cam_chromatix_lite_ae_stats_t, 1); + INCLUDE(CAM_INTF_META_CHROMATIX_LITE_AWB, cam_chromatix_lite_awb_stats_t, 1); + INCLUDE(CAM_INTF_META_CHROMATIX_LITE_AF, cam_chromatix_lite_af_stats_t, 1); + INCLUDE(CAM_INTF_META_CHROMATIX_LITE_ASD, cam_chromatix_lite_asd_stats_t, 1); + INCLUDE(CAM_INTF_BUF_DIVERT_INFO, cam_buf_divert_info_t, 1); + + /* Specific to HAL3 */ + INCLUDE(CAM_INTF_META_FRAME_NUMBER_VALID, int32_t, 1); + INCLUDE(CAM_INTF_META_URGENT_FRAME_NUMBER_VALID, int32_t, 1); + INCLUDE(CAM_INTF_META_FRAME_DROPPED, cam_frame_dropped_t, 1); + INCLUDE(CAM_INTF_META_FRAME_NUMBER, uint32_t, 1); + INCLUDE(CAM_INTF_META_URGENT_FRAME_NUMBER, uint32_t, 1); + INCLUDE(CAM_INTF_META_COLOR_CORRECT_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_COLOR_CORRECT_TRANSFORM, cam_color_correct_matrix_t, 1); + INCLUDE(CAM_INTF_META_COLOR_CORRECT_GAINS, cam_color_correct_gains_t, 1); + INCLUDE(CAM_INTF_META_PRED_COLOR_CORRECT_TRANSFORM, cam_color_correct_matrix_t, 1); + INCLUDE(CAM_INTF_META_PRED_COLOR_CORRECT_GAINS, cam_color_correct_gains_t, 1); + INCLUDE(CAM_INTF_META_AEC_ROI, cam_area_t, 1); + INCLUDE(CAM_INTF_META_AEC_STATE, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_FOCUS_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_MANUAL_FOCUS_POS, cam_manual_focus_parm_t, 1); + INCLUDE(CAM_INTF_META_AF_ROI, cam_area_t, 1); + INCLUDE(CAM_INTF_META_AF_STATE, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_WHITE_BALANCE, int32_t, 1); + INCLUDE(CAM_INTF_META_AWB_REGIONS, cam_area_t, 1); + INCLUDE(CAM_INTF_META_AWB_STATE, uint32_t, 1); + INCLUDE(CAM_INTF_META_BLACK_LEVEL_LOCK, uint32_t, 1); + INCLUDE(CAM_INTF_META_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_EDGE_MODE, cam_edge_application_t, 1); + INCLUDE(CAM_INTF_META_FLASH_POWER, uint32_t, 1); + INCLUDE(CAM_INTF_META_FLASH_FIRING_TIME, int64_t, 1); + INCLUDE(CAM_INTF_META_FLASH_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_FLASH_STATE, int32_t, 1); + INCLUDE(CAM_INTF_META_HOTPIXEL_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_LENS_APERTURE, float, 1); + INCLUDE(CAM_INTF_META_LENS_FILTERDENSITY, float, 1); + INCLUDE(CAM_INTF_META_LENS_FOCAL_LENGTH, float, 1); + INCLUDE(CAM_INTF_META_LENS_FOCUS_DISTANCE, float, 1); + INCLUDE(CAM_INTF_META_LENS_FOCUS_RANGE, float, 2); + INCLUDE(CAM_INTF_META_LENS_STATE, cam_af_lens_state_t, 1); + INCLUDE(CAM_INTF_META_LENS_OPT_STAB_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_VIDEO_STAB_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_LENS_FOCUS_STATE, uint32_t, 1); + INCLUDE(CAM_INTF_META_NOISE_REDUCTION_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_NOISE_REDUCTION_STRENGTH, uint32_t, 1); + INCLUDE(CAM_INTF_META_SCALER_CROP_REGION, cam_crop_region_t, 1); + INCLUDE(CAM_INTF_META_SCENE_FLICKER, uint32_t, 1); + INCLUDE(CAM_INTF_META_SENSOR_EXPOSURE_TIME, int64_t, 1); + INCLUDE(CAM_INTF_META_SENSOR_FRAME_DURATION, int64_t, 1); + INCLUDE(CAM_INTF_META_SENSOR_SENSITIVITY, int32_t, 1); + INCLUDE(CAM_INTF_META_ISP_SENSITIVITY , int32_t, 1); + INCLUDE(CAM_INTF_META_SENSOR_TIMESTAMP, int64_t, 1); + INCLUDE(CAM_INTF_META_SENSOR_ROLLING_SHUTTER_SKEW, int64_t, 1); + INCLUDE(CAM_INTF_META_SHADING_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_STATS_FACEDETECT_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_STATS_HISTOGRAM_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_STATS_SHARPNESS_MAP_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_STATS_SHARPNESS_MAP, cam_sharpness_map_t, 3); + INCLUDE(CAM_INTF_META_TONEMAP_CURVES, cam_rgb_tonemap_curves, 1); + INCLUDE(CAM_INTF_META_LENS_SHADING_MAP, cam_lens_shading_map_t, 1); + INCLUDE(CAM_INTF_META_AEC_INFO, cam_3a_params_t, 1); + INCLUDE(CAM_INTF_META_SENSOR_INFO, cam_sensor_params_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_AE, cam_ae_exif_debug_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_AWB, cam_awb_exif_debug_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_AF, cam_af_exif_debug_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_ASD, cam_asd_exif_debug_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_STATS, cam_stats_buffer_exif_debug_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_BESTATS, cam_bestats_buffer_exif_debug_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_BHIST, cam_bhist_buffer_exif_debug_t, 1); + INCLUDE(CAM_INTF_META_EXIF_DEBUG_3A_TUNING, cam_q3a_tuning_info_t, 1); + INCLUDE(CAM_INTF_META_ASD_SCENE_CAPTURE_TYPE, cam_auto_scene_t, 1); + INCLUDE(CAM_INTF_PARM_EFFECT, uint32_t, 1); + /* Defining as int32_t so that this array is 4 byte aligned */ + INCLUDE(CAM_INTF_META_PRIVATE_DATA, int32_t, + MAX_METADATA_PRIVATE_PAYLOAD_SIZE_IN_BYTES / 4); + + /* Following are Params only and not metadata currently */ + INCLUDE(CAM_INTF_PARM_HAL_VERSION, int32_t, 1); + /* Shared between HAL1 and HAL3 */ + INCLUDE(CAM_INTF_PARM_ANTIBANDING, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_EXPOSURE_COMPENSATION, int32_t, 1); + INCLUDE(CAM_INTF_PARM_EV_STEP, cam_rational_type_t, 1); + INCLUDE(CAM_INTF_PARM_AEC_LOCK, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_FPS_RANGE, cam_fps_range_t, 1); + INCLUDE(CAM_INTF_PARM_AWB_LOCK, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_BESTSHOT_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_DIS_ENABLE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_LED_MODE, int32_t, 1); + INCLUDE(CAM_INTF_META_LED_MODE_OVERRIDE, uint32_t, 1); + + /* dual camera specific params */ + INCLUDE(CAM_INTF_PARM_RELATED_SENSORS_CALIBRATION, cam_related_system_calibration_data_t, 1); + INCLUDE(CAM_INTF_META_AF_FOCAL_LENGTH_RATIO, cam_focal_length_ratio_t, 1); + INCLUDE(CAM_INTF_META_SNAP_CROP_INFO_SENSOR, cam_stream_crop_info_t, 1); + INCLUDE(CAM_INTF_META_SNAP_CROP_INFO_CAMIF, cam_stream_crop_info_t, 1); + INCLUDE(CAM_INTF_META_SNAP_CROP_INFO_ISP, cam_stream_crop_info_t, 1); + INCLUDE(CAM_INTF_META_SNAP_CROP_INFO_CPP, cam_stream_crop_info_t, 1); + INCLUDE(CAM_INTF_META_DCRF, cam_dcrf_result_t, 1); + + /* HAL1 specific */ + /* read only */ + INCLUDE(CAM_INTF_PARM_QUERY_FLASH4SNAP, int32_t, 1); + INCLUDE(CAM_INTF_PARM_EXPOSURE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_SHARPNESS, int32_t, 1); + INCLUDE(CAM_INTF_PARM_CONTRAST, int32_t, 1); + INCLUDE(CAM_INTF_PARM_SATURATION, int32_t, 1); + INCLUDE(CAM_INTF_PARM_BRIGHTNESS, int32_t, 1); + INCLUDE(CAM_INTF_PARM_ISO, cam_intf_parm_manual_3a_t, 1); + INCLUDE(CAM_INTF_PARM_EXPOSURE_TIME, cam_intf_parm_manual_3a_t, 1); + INCLUDE(CAM_INTF_PARM_ZOOM, int32_t, 1); + INCLUDE(CAM_INTF_PARM_ROLLOFF, int32_t, 1); + INCLUDE(CAM_INTF_PARM_MODE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_AEC_ALGO_TYPE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_FOCUS_ALGO_TYPE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_AEC_ROI, cam_set_aec_roi_t, 1); + INCLUDE(CAM_INTF_PARM_AF_ROI, cam_roi_info_t, 1); + INCLUDE(CAM_INTF_PARM_SCE_FACTOR, int32_t, 1); + INCLUDE(CAM_INTF_PARM_FD, cam_fd_set_parm_t, 1); + INCLUDE(CAM_INTF_PARM_MCE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_HFR, int32_t, 1); + INCLUDE(CAM_INTF_PARM_REDEYE_REDUCTION, int32_t, 1); + INCLUDE(CAM_INTF_PARM_WAVELET_DENOISE, cam_denoise_param_t, 1); + INCLUDE(CAM_INTF_PARM_TEMPORAL_DENOISE, cam_denoise_param_t, 1); + INCLUDE(CAM_INTF_PARM_HISTOGRAM, int32_t, 1); + INCLUDE(CAM_INTF_PARM_ASD_ENABLE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_RECORDING_HINT, int32_t, 1); + INCLUDE(CAM_INTF_PARM_HDR, cam_exp_bracketing_t, 1); + INCLUDE(CAM_INTF_PARM_FRAMESKIP, int32_t, 1); + INCLUDE(CAM_INTF_PARM_ZSL_MODE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_HDR_NEED_1X, int32_t, 1); + INCLUDE(CAM_INTF_PARM_LOCK_CAF, int32_t, 1); + INCLUDE(CAM_INTF_PARM_VIDEO_HDR, int32_t, 1); + INCLUDE(CAM_INTF_PARM_SENSOR_HDR, cam_sensor_hdr_type_t, 1); + INCLUDE(CAM_INTF_PARM_VT, int32_t, 1); + INCLUDE(CAM_INTF_PARM_SET_AUTOFOCUSTUNING, tune_actuator_t, 1); + INCLUDE(CAM_INTF_PARM_SET_VFE_COMMAND, tune_cmd_t, 1); + INCLUDE(CAM_INTF_PARM_SET_PP_COMMAND, tune_cmd_t, 1); + INCLUDE(CAM_INTF_PARM_MAX_DIMENSION, cam_dimension_t, 1); + INCLUDE(CAM_INTF_PARM_RAW_DIMENSION, cam_dimension_t, 1); + INCLUDE(CAM_INTF_PARM_TINTLESS, int32_t, 1); + INCLUDE(CAM_INTF_PARM_WB_MANUAL, cam_manual_wb_parm_t, 1); + INCLUDE(CAM_INTF_PARM_CDS_MODE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_EZTUNE_CMD, cam_eztune_cmd_data_t, 1); + INCLUDE(CAM_INTF_PARM_INT_EVT, cam_int_evt_params_t, 1); + INCLUDE(CAM_INTF_PARM_RDI_MODE, int32_t, 1); + INCLUDE(CAM_INTF_PARM_BURST_NUM, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_RETRO_BURST_NUM, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_BURST_LED_ON_PERIOD, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_LONGSHOT_ENABLE, int8_t, 1); + INCLUDE(CAM_INTF_PARM_TONE_MAP_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_TOUCH_AE_RESULT, int32_t, 1); + INCLUDE(CAM_INTF_PARM_DUAL_LED_CALIBRATION, int32_t, 1); + INCLUDE(CAM_INTF_PARM_ADV_CAPTURE_MODE, uint8_t, 1); + INCLUDE(CAM_INTF_PARM_QUADRA_CFA, int32_t, 1); + + /* HAL3 specific */ + INCLUDE(CAM_INTF_META_STREAM_INFO, cam_stream_size_info_t, 1); + INCLUDE(CAM_INTF_META_AEC_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_AEC_PRECAPTURE_TRIGGER, cam_trigger_t, 1); + INCLUDE(CAM_INTF_META_AF_TRIGGER, cam_trigger_t, 1); + INCLUDE(CAM_INTF_META_CAPTURE_INTENT, uint32_t, 1); + INCLUDE(CAM_INTF_META_DEMOSAIC, int32_t, 1); + INCLUDE(CAM_INTF_META_SHARPNESS_STRENGTH, int32_t, 1); + INCLUDE(CAM_INTF_META_GEOMETRIC_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_GEOMETRIC_STRENGTH, uint32_t, 1); + INCLUDE(CAM_INTF_META_LENS_SHADING_MAP_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_SHADING_STRENGTH, uint32_t, 1); + INCLUDE(CAM_INTF_META_TONEMAP_MODE, uint32_t, 1); + INCLUDE(CAM_INTF_META_STREAM_ID, cam_stream_ID_t, 1); + INCLUDE(CAM_INTF_PARM_STATS_DEBUG_MASK, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_STATS_AF_PAAF, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_FOCUS_BRACKETING, cam_af_bracketing_t, 1); + INCLUDE(CAM_INTF_PARM_FLASH_BRACKETING, cam_flash_bracketing_t, 1); + INCLUDE(CAM_INTF_META_JPEG_GPS_COORDINATES, double, 3); + INCLUDE(CAM_INTF_META_JPEG_GPS_PROC_METHODS, uint8_t, GPS_PROCESSING_METHOD_SIZE); + INCLUDE(CAM_INTF_META_JPEG_GPS_TIMESTAMP, int64_t, 1); + INCLUDE(CAM_INTF_META_JPEG_ORIENTATION, int32_t, 1); + INCLUDE(CAM_INTF_META_JPEG_QUALITY, uint32_t, 1); + INCLUDE(CAM_INTF_META_JPEG_THUMB_QUALITY, uint32_t, 1); + INCLUDE(CAM_INTF_META_JPEG_THUMB_SIZE, cam_dimension_t, 1); + INCLUDE(CAM_INTF_META_TEST_PATTERN_DATA, cam_test_pattern_data_t, 1); + INCLUDE(CAM_INTF_META_PROFILE_TONE_CURVE, cam_profile_tone_curve, 1); + INCLUDE(CAM_INTF_META_OTP_WB_GRGB, float, 1); + INCLUDE(CAM_INTF_META_IMG_HYST_INFO, cam_img_hysterisis_info_t, 1); + INCLUDE(CAM_INTF_META_CAC_INFO, cam_cac_info_t, 1); + INCLUDE(CAM_INTF_PARM_CAC, cam_aberration_mode_t, 1); + INCLUDE(CAM_INTF_META_NEUTRAL_COL_POINT, cam_neutral_col_point_t, 1); + INCLUDE(CAM_INTF_PARM_ROTATION, cam_rotation_info_t, 1); + INCLUDE(CAM_INTF_PARM_HW_DATA_OVERWRITE, cam_hw_data_overwrite_t, 1); + INCLUDE(CAM_INTF_META_IMGLIB, cam_intf_meta_imglib_t, 1); + INCLUDE(CAM_INTF_PARM_CAPTURE_FRAME_CONFIG, cam_capture_frame_config_t, 1); + INCLUDE(CAM_INTF_PARM_CUSTOM, custom_parm_buffer_t, 1); + INCLUDE(CAM_INTF_PARM_FLIP, int32_t, 1); + INCLUDE(CAM_INTF_META_USE_AV_TIMER, uint8_t, 1); + INCLUDE(CAM_INTF_META_EFFECTIVE_EXPOSURE_FACTOR, float, 1); + INCLUDE(CAM_INTF_META_LDAF_EXIF, uint32_t, 2); + INCLUDE(CAM_INTF_META_BLACK_LEVEL_SOURCE_PATTERN, cam_black_level_metadata_t, 1); + INCLUDE(CAM_INTF_META_BLACK_LEVEL_APPLIED_PATTERN, cam_black_level_metadata_t, 1); + INCLUDE(CAM_INTF_META_LOW_LIGHT, cam_low_light_mode_t, 1); + INCLUDE(CAM_INTF_META_IMG_DYN_FEAT, cam_dyn_img_data_t, 1); + INCLUDE(CAM_INTF_PARM_MANUAL_CAPTURE_TYPE, cam_manual_capture_type, 1); + INCLUDE(CAM_INTF_AF_STATE_TRANSITION, uint8_t, 1); + INCLUDE(CAM_INTF_PARM_INITIAL_EXPOSURE_INDEX, uint32_t, 1); + INCLUDE(CAM_INTF_PARM_INSTANT_AEC, uint8_t, 1); + INCLUDE(CAM_INTF_META_REPROCESS_FLAGS, uint8_t, 1); + INCLUDE(CAM_INTF_PARM_JPEG_ENCODE_CROP, cam_stream_crop_info_t, 1); + INCLUDE(CAM_INTF_PARM_JPEG_SCALE_DIMENSION, cam_dimension_t, 1); +} metadata_data_t; + +/* Update clear_metadata_buffer() function when a new is_xxx_valid is added to + * or removed from this structure */ +typedef struct { + union{ + /* Hash table of 'is valid' flags */ + uint8_t is_valid[CAM_INTF_PARM_MAX]; + + /* Hash table of 'is required' flags for the GET PARAM */ + uint8_t is_reqd[CAM_INTF_PARM_MAX]; + }; + metadata_data_t data; + /*Tuning Data */ + uint8_t is_tuning_params_valid; + tuning_params_t tuning_params; + + /* Mobicat Params */ + uint8_t is_mobicat_aec_params_valid; + cam_3a_params_t mobicat_aec_params; + + /* Stats 3A Debug Params */ + uint8_t is_statsdebug_ae_params_valid; + cam_ae_exif_debug_t statsdebug_ae_data; + + uint8_t is_statsdebug_awb_params_valid; + cam_awb_exif_debug_t statsdebug_awb_data; + + uint8_t is_statsdebug_af_params_valid; + cam_af_exif_debug_t statsdebug_af_data; + + uint8_t is_statsdebug_asd_params_valid; + cam_asd_exif_debug_t statsdebug_asd_data; + + uint8_t is_statsdebug_stats_params_valid; + cam_stats_buffer_exif_debug_t statsdebug_stats_buffer_data; + + uint8_t is_statsdebug_bestats_params_valid; + cam_bestats_buffer_exif_debug_t statsdebug_bestats_buffer_data; + + uint8_t is_statsdebug_bhist_params_valid; + cam_bhist_buffer_exif_debug_t statsdebug_bhist_data; + + uint8_t is_statsdebug_3a_tuning_params_valid; + cam_q3a_tuning_info_t statsdebug_3a_tuning_data; + +} metadata_buffer_t; + +typedef metadata_buffer_t parm_buffer_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Update this inline function when a new is_xxx_valid is added to + * or removed from metadata_buffer_t */ +static inline void clear_metadata_buffer(metadata_buffer_t *meta) +{ + if (meta) { + memset(meta->is_valid, 0, CAM_INTF_PARM_MAX); + meta->is_tuning_params_valid = 0; + meta->is_mobicat_aec_params_valid = 0; + meta->is_statsdebug_ae_params_valid = 0; + meta->is_statsdebug_awb_params_valid = 0; + meta->is_statsdebug_af_params_valid = 0; + meta->is_statsdebug_asd_params_valid = 0; + meta->is_statsdebug_stats_params_valid = 0; + meta->is_statsdebug_bestats_params_valid = 0; + meta->is_statsdebug_bhist_params_valid = 0; + meta->is_statsdebug_3a_tuning_params_valid = 0; + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* __QCAMERA_INTF_H__ */ diff --git a/camera/QCamera2/stack/common/cam_list.h b/camera/QCamera2/stack/common/cam_list.h new file mode 100644 index 0000000..0fbfa07 --- /dev/null +++ b/camera/QCamera2/stack/common/cam_list.h @@ -0,0 +1,84 @@ +/* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* This file is a slave copy from /vendor/qcom/propreitary/mm-cammera/common, + * Please do not modify it directly here. */ + +#ifndef __CAMLIST_H +#define __CAMLIST_H + +// System dependency +#include + +#define member_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member) *__mptr = (ptr); \ + (type *)((char *)__mptr - offsetof(type,member));}) + +struct cam_list { + struct cam_list *next, *prev; +}; + +static inline void cam_list_init(struct cam_list *ptr) +{ + ptr->next = ptr; + ptr->prev = ptr; +} + +static inline void cam_list_add_tail_node(struct cam_list *item, + struct cam_list *head) +{ + struct cam_list *prev = head->prev; + + head->prev = item; + item->next = head; + item->prev = prev; + prev->next = item; +} + +static inline void cam_list_insert_before_node(struct cam_list *item, + struct cam_list *node) +{ + item->next = node; + item->prev = node->prev; + item->prev->next = item; + node->prev = item; +} + +static inline void cam_list_del_node(struct cam_list *ptr) +{ + struct cam_list *prev = ptr->prev; + struct cam_list *next = ptr->next; + + next->prev = ptr->prev; + prev->next = ptr->next; + ptr->next = ptr; + ptr->prev = ptr; +} + +#endif /* __CAMLIST_H */ diff --git a/camera/QCamera2/stack/common/cam_queue.h b/camera/QCamera2/stack/common/cam_queue.h new file mode 100644 index 0000000..fbb5f63 --- /dev/null +++ b/camera/QCamera2/stack/common/cam_queue.h @@ -0,0 +1,134 @@ +/* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +// System dependencies +#include + +// Camera dependencies +#include "cam_list.h" + +typedef struct { + struct cam_list list; + void *data; +} cam_node_t; + +typedef struct { + cam_node_t head; /* dummy head */ + uint32_t size; + pthread_mutex_t lock; +} cam_queue_t; + +static inline int32_t cam_queue_init(cam_queue_t *queue) +{ + pthread_mutex_init(&queue->lock, NULL); + cam_list_init(&queue->head.list); + queue->size = 0; + return 0; +} + +static inline int32_t cam_queue_enq(cam_queue_t *queue, void *data) +{ + cam_node_t *node = + (cam_node_t *)malloc(sizeof(cam_node_t)); + if (NULL == node) { + return -1; + } + + memset(node, 0, sizeof(cam_node_t)); + node->data = data; + + pthread_mutex_lock(&queue->lock); + cam_list_add_tail_node(&node->list, &queue->head.list); + queue->size++; + pthread_mutex_unlock(&queue->lock); + + return 0; +} + +static inline void *cam_queue_deq(cam_queue_t *queue) +{ + cam_node_t *node = NULL; + void *data = NULL; + struct cam_list *head = NULL; + struct cam_list *pos = NULL; + + pthread_mutex_lock(&queue->lock); + head = &queue->head.list; + pos = head->next; + if (pos != head) { + node = member_of(pos, cam_node_t, list); + cam_list_del_node(&node->list); + queue->size--; + } + pthread_mutex_unlock(&queue->lock); + + if (NULL != node) { + data = node->data; + free(node); + } + + return data; +} + +static inline int32_t cam_queue_flush(cam_queue_t *queue) +{ + cam_node_t *node = NULL; + struct cam_list *head = NULL; + struct cam_list *pos = NULL; + + pthread_mutex_lock(&queue->lock); + head = &queue->head.list; + pos = head->next; + + while(pos != head) { + node = member_of(pos, cam_node_t, list); + pos = pos->next; + cam_list_del_node(&node->list); + queue->size--; + + /* TODO later to consider ptr inside data */ + /* for now we only assume there is no ptr inside data + * so we free data directly */ + if (NULL != node->data) { + free(node->data); + } + free(node); + + } + queue->size = 0; + pthread_mutex_unlock(&queue->lock); + return 0; +} + +static inline int32_t cam_queue_deinit(cam_queue_t *queue) +{ + cam_queue_flush(queue); + pthread_mutex_destroy(&queue->lock); + return 0; +} diff --git a/camera/QCamera2/stack/common/cam_semaphore.h b/camera/QCamera2/stack/common/cam_semaphore.h new file mode 100644 index 0000000..a35634c --- /dev/null +++ b/camera/QCamera2/stack/common/cam_semaphore.h @@ -0,0 +1,88 @@ +/* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __QCAMERA_SEMAPHORE_H__ +#define __QCAMERA_SEMAPHORE_H__ + +// System dependencies +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Implement semaphore with mutex and conditional variable. + * Reason being, POSIX semaphore on Android are not used or + * well tested. + */ + +typedef struct { + int val; + pthread_mutex_t mutex; + pthread_cond_t cond; +} cam_semaphore_t; + +static inline void cam_sem_init(cam_semaphore_t *s, int n) +{ + pthread_mutex_init(&(s->mutex), NULL); + pthread_cond_init(&(s->cond), NULL); + s->val = n; +} + +static inline void cam_sem_post(cam_semaphore_t *s) +{ + pthread_mutex_lock(&(s->mutex)); + s->val++; + pthread_cond_signal(&(s->cond)); + pthread_mutex_unlock(&(s->mutex)); +} + +static inline int cam_sem_wait(cam_semaphore_t *s) +{ + int rc = 0; + pthread_mutex_lock(&(s->mutex)); + while (s->val == 0) + rc = pthread_cond_wait(&(s->cond), &(s->mutex)); + s->val--; + pthread_mutex_unlock(&(s->mutex)); + return rc; +} + +static inline void cam_sem_destroy(cam_semaphore_t *s) +{ + pthread_mutex_destroy(&(s->mutex)); + pthread_cond_destroy(&(s->cond)); + s->val = 0; +} + +#ifdef __cplusplus +} +#endif + +#endif /* __QCAMERA_SEMAPHORE_H__ */ diff --git a/camera/QCamera2/stack/common/cam_types.h b/camera/QCamera2/stack/common/cam_types.h new file mode 100644 index 0000000..421a3ba --- /dev/null +++ b/camera/QCamera2/stack/common/cam_types.h @@ -0,0 +1,2753 @@ +/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __QCAMERA_TYPES_H__ +#define __QCAMERA_TYPES_H__ + +// System dependencies +#include +#include + +#define CAM_MAX_NUM_BUFS_PER_STREAM 64 +#define MAX_METADATA_PRIVATE_PAYLOAD_SIZE_IN_BYTES 8096 +#define AWB_DEBUG_DATA_SIZE (45000) +#define AEC_DEBUG_DATA_SIZE (5000) +#define AF_DEBUG_DATA_SIZE (50000) +#define ASD_DEBUG_DATA_SIZE (100) +#define STATS_BUFFER_DEBUG_DATA_SIZE (75000) +#define BESTATS_BUFFER_DEBUG_DATA_SIZE (150000) +#define BHIST_STATS_DEBUG_DATA_SIZE (70000) +#define TUNING_INFO_DEBUG_DATA_SIZE (4) + +#define CEILING64(X) (((X) + 0x0003F) & 0xFFFFFFC0) +#define CEILING32(X) (((X) + 0x0001F) & 0xFFFFFFE0) +#define CEILING16(X) (((X) + 0x000F) & 0xFFF0) +#define CEILING4(X) (((X) + 0x0003) & 0xFFFC) +#define CEILING2(X) (((X) + 0x0001) & 0xFFFE) + +#define MAX_ZOOMS_CNT 91 +#define MAX_SIZES_CNT 40 +#define MAX_EXP_BRACKETING_LENGTH 32 +#define MAX_ROI 10 +#define MAX_STREAM_NUM_IN_BUNDLE 8 +#define MAX_NUM_STREAMS 8 +#define CHROMATIX_SIZE 60000 +#define COMMONCHROMATIX_SIZE 45000 +#define CPPCHROMATIX_SIZE 36000 +#define SWPOSTPROCCHROMATIX_SIZE 36000 +#define AFTUNE_SIZE 32768 +#define A3CHROMATIX_SIZE 30000 +#define MAX_SCALE_SIZES_CNT 8 +#define MAX_SAMP_DECISION_CNT 64 +#define SENSOR_PHYSICAL_SIZE_CNT 2 +#define EXPOSURE_TIME_RANGE_CNT 2 +#define BLACK_LEVEL_PATTERN_CNT 4 +#define FORWARD_MATRIX_COLS 3 +#define FORWARD_MATRIX_ROWS 3 +#define COLOR_TRANSFORM_COLS 3 +#define COLOR_TRANSFORM_ROWS 3 +#define CAL_TRANSFORM_COLS 3 +#define CAL_TRANSFORM_ROWS 3 + +#define MAX_ISP_DATA_SIZE (20*1024) +#define MAX_PP_DATA_SIZE 16384 +#define MAX_AE_STATS_DATA_SIZE 1000 +#define MAX_AWB_STATS_DATA_SIZE 1000 +#define MAX_AF_STATS_DATA_SIZE 1000 +#define MAX_ASD_STATS_DATA_SIZE 1000 + +#define MAX_CAPTURE_BATCH_NUM 32 + +#define TUNING_DATA_VERSION 6 +#define TUNING_SENSOR_DATA_MAX 0x10000 /*(need value from sensor team)*/ +#define TUNING_VFE_DATA_MAX 0x10000 /*(need value from vfe team)*/ +#define TUNING_CPP_DATA_MAX 0x10000 /*(need value from pproc team)*/ +#define TUNING_CAC_DATA_MAX 0x10000 /*(need value from imglib team)*/ +#define TUNING_DATA_MAX (TUNING_SENSOR_DATA_MAX + \ + TUNING_VFE_DATA_MAX + TUNING_CPP_DATA_MAX + \ + TUNING_CAC_DATA_MAX) + +#define TUNING_SENSOR_DATA_OFFSET 0 +#define TUNING_VFE_DATA_OFFSET TUNING_SENSOR_DATA_MAX +#define TUNING_CPP_DATA_OFFSET (TUNING_SENSOR_DATA_MAX + TUNING_VFE_DATA_MAX) +#define TUNING_CAC_DATA_OFFSET (TUNING_SENSOR_DATA_MAX + \ + TUNING_VFE_DATA_MAX + TUNING_CPP_DATA_MAX) +#define MAX_STATS_DATA_SIZE 4000 + +#define MAX_AF_BRACKETING_VALUES 5 +#define MAX_TEST_PATTERN_CNT 8 + +#define GPS_PROCESSING_METHOD_SIZE 33 +#define EXIF_IMAGE_DESCRIPTION_SIZE 100 + +#define MAX_INFLIGHT_REQUESTS 6 +#define MAX_INFLIGHT_BLOB 3 +#define MIN_INFLIGHT_REQUESTS 3 +#define MAX_INFLIGHT_REPROCESS_REQUESTS 1 +#define MAX_INFLIGHT_HFR_REQUESTS (48) +#define MIN_INFLIGHT_HFR_REQUESTS (40) + +#define QCAMERA_DUMP_FRM_LOCATION "/data/misc/camera/" +#define QCAMERA_MAX_FILEPATH_LENGTH 64 + +#define LIKELY(x) __builtin_expect((x), true) +#define UNLIKELY(x) __builtin_expect((x), false) + +#define RELCAM_CALIB_ROT_MATRIX_MAX 9 +#define RELCAM_CALIB_SURFACE_PARMS_MAX 32 +#define RELCAM_CALIB_RESERVED_MAX 50 + +#define MAX_NUM_CAMERA_PER_BUNDLE 2 /* Max number of cameras per bundle */ +#define EXTRA_FRAME_SYNC_BUFFERS 4 /* Extra frame sync buffers in dc mode*/ +#define MM_CAMERA_FRAME_SYNC_NODES EXTRA_FRAME_SYNC_BUFFERS + +#define MAX_REPROCESS_STALL 2 + +#define QCAMERA_MAX_FILEPATH_LENGTH 64 + +#define MAX_EEPROM_VERSION_INFO_LEN 32 + +#define MAX_OPTICAL_BLACK_REGIONS 5 + +/*reprocess pipeline stages are pproc and jpeg */ +#define MAX_REPROCESS_PIPELINE_STAGES 2 + +/* Defines the number of rows in the color correction matrix (CCM) */ +#define AWB_NUM_CCM_ROWS (3) + +/* Defines the number of columns in the color correction matrix (CCM) */ +#define AWB_NUM_CCM_COLS (3) + +typedef uint64_t cam_feature_mask_t; + +typedef enum { + CAM_HAL_V1 = 1, + CAM_HAL_V3 = 3 +} cam_hal_version_t; + +typedef enum { + CAM_STATUS_SUCCESS, /* Operation Succeded */ + CAM_STATUS_FAILED, /* Failure in doing operation */ + CAM_STATUS_INVALID_PARM, /* Inavlid parameter provided */ + CAM_STATUS_NOT_SUPPORTED, /* Parameter/operation not supported */ + CAM_STATUS_ACCEPTED, /* Parameter accepted */ + CAM_STATUS_MAX, +} cam_status_t; + +typedef enum { + /* back main camera */ + CAM_POSITION_BACK, + /* front main camera */ + CAM_POSITION_FRONT, + /* back aux camera */ + CAM_POSITION_BACK_AUX, + /* front aux camera */ + CAM_POSITION_FRONT_AUX +} cam_position_t; + +typedef enum { + CAM_FLICKER_NONE, + CAM_FLICKER_50_HZ, + CAM_FLICKER_60_HZ +} cam_flicker_t; + +typedef enum { + CAM_FORMAT_JPEG = 0, + CAM_FORMAT_YUV_420_NV12 = 1, + CAM_FORMAT_YUV_420_NV21, + CAM_FORMAT_YUV_420_NV21_ADRENO, + CAM_FORMAT_YUV_420_YV12, + CAM_FORMAT_YUV_422_NV16, + CAM_FORMAT_YUV_422_NV61, + CAM_FORMAT_YUV_420_NV12_VENUS, + /* Note: For all raw formats, each scanline needs to be 16 bytes aligned */ + + /* Packed YUV/YVU raw format, 16 bpp: 8 bits Y and 8 bits UV. + * U and V are interleaved with Y: YUYV or YVYV */ + CAM_FORMAT_YUV_RAW_8BIT_YUYV, + CAM_FORMAT_YUV_RAW_8BIT_YVYU, + CAM_FORMAT_YUV_RAW_8BIT_UYVY, //10 + CAM_FORMAT_YUV_RAW_8BIT_VYUY, + + /* QCOM RAW formats where data is packed into 64bit word. + * 8BPP: 1 64-bit word contains 8 pixels p0 - p7, where p0 is + * stored at LSB. + * 10BPP: 1 64-bit word contains 6 pixels p0 - p5, where most + * significant 4 bits are set to 0. P0 is stored at LSB. + * 12BPP: 1 64-bit word contains 5 pixels p0 - p4, where most + * significant 4 bits are set to 0. P0 is stored at LSB. */ + CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG, + CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GRBG, + CAM_FORMAT_BAYER_QCOM_RAW_8BPP_RGGB, + CAM_FORMAT_BAYER_QCOM_RAW_8BPP_BGGR, + CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG, + CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GRBG, + CAM_FORMAT_BAYER_QCOM_RAW_10BPP_RGGB, + CAM_FORMAT_BAYER_QCOM_RAW_10BPP_BGGR, + CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG, //20 + CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GRBG, + CAM_FORMAT_BAYER_QCOM_RAW_12BPP_RGGB, + CAM_FORMAT_BAYER_QCOM_RAW_12BPP_BGGR, + /* MIPI RAW formats based on MIPI CSI-2 specifiction. + * 8BPP: Each pixel occupies one bytes, starting at LSB. + * Output with of image has no restrictons. + * 10BPP: Four pixels are held in every 5 bytes. The output + * with of image must be a multiple of 4 pixels. + * 12BPP: Two pixels are held in every 3 bytes. The output + * width of image must be a multiple of 2 pixels. */ + CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG, + CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GRBG, + CAM_FORMAT_BAYER_MIPI_RAW_8BPP_RGGB, + CAM_FORMAT_BAYER_MIPI_RAW_8BPP_BGGR, + CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG, + CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GRBG, + CAM_FORMAT_BAYER_MIPI_RAW_10BPP_RGGB, //30 + CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR, + CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG, + CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GRBG, + CAM_FORMAT_BAYER_MIPI_RAW_12BPP_RGGB, + CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR, + /* Ideal raw formats where image data has gone through black + * correction, lens rolloff, demux/channel gain, bad pixel + * correction, and ABF. + * Ideal raw formats could output any of QCOM_RAW and MIPI_RAW + * formats, plus plain8 8bbp, plain16 800, plain16 10bpp, and + * plain 16 12bpp */ + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GBRG, //40 + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_RGGB, //50 + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GBRG, //60 + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_RGGB, //70 + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR, + + /* generic 8-bit raw */ + CAM_FORMAT_JPEG_RAW_8BIT, + CAM_FORMAT_META_RAW_8BIT, + + /* QCOM RAW formats where data is packed into 64bit word. + * 14BPP: 1 64-bit word contains 4 pixels p0 - p3, where most + * significant 4 bits are set to 0. P0 is stored at LSB. + */ + CAM_FORMAT_BAYER_QCOM_RAW_14BPP_GBRG, + CAM_FORMAT_BAYER_QCOM_RAW_14BPP_GRBG, + CAM_FORMAT_BAYER_QCOM_RAW_14BPP_RGGB, //80 + CAM_FORMAT_BAYER_QCOM_RAW_14BPP_BGGR, + /* MIPI RAW formats based on MIPI CSI-2 specifiction. + * 14 BPPP: 1st byte: P0 [13:6] + * 2nd byte: P1 [13:6] + * 3rd byte: P2 [13:6] + * 4th byte: P3 [13:6] + * 5th byte: P0 [5:0] + * 7th byte: P1 [5:0] + * 8th byte: P2 [5:0] + * 9th byte: P3 [5:0] + */ + CAM_FORMAT_BAYER_MIPI_RAW_14BPP_GBRG, + CAM_FORMAT_BAYER_MIPI_RAW_14BPP_GRBG, + CAM_FORMAT_BAYER_MIPI_RAW_14BPP_RGGB, + CAM_FORMAT_BAYER_MIPI_RAW_14BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_14BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_14BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_14BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_14BPP_BGGR, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_14BPP_GBRG, //90 + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_14BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_14BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_14BPP_BGGR, + /* 14BPP: 1st byte: P0 [8:0] + * 2nd byte: P0 [13:9] + * 3rd byte: P1 [8:0] + * 4th byte: P1 [13:9] + */ + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_14BPP_GBRG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_14BPP_GRBG, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_14BPP_RGGB, + CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_14BPP_BGGR, + + CAM_FORMAT_YUV_444_NV24, + CAM_FORMAT_YUV_444_NV42, + + /* Y plane only, used for FD, 8BPP */ + CAM_FORMAT_Y_ONLY, //100 + + /* UBWC format */ + CAM_FORMAT_YUV_420_NV12_UBWC, + + CAM_FORMAT_YUV_420_NV21_VENUS, + + /* RGB formats */ + CAM_FORMAT_8888_ARGB, + + /* Y plane only */ + CAM_FORMAT_Y_ONLY_10_BPP, + CAM_FORMAT_Y_ONLY_12_BPP, + CAM_FORMAT_Y_ONLY_14_BPP, + CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GREY, + CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GREY, + CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GREY, + CAM_FORMAT_BAYER_QCOM_RAW_14BPP_GREY, + CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GREY, + CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GREY, + CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GREY, + CAM_FORMAT_BAYER_MIPI_RAW_14BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_14BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GREY, + CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_14BPP_GREY, + + CAM_FORMAT_MAX +} cam_format_t; + +typedef enum { + CAM_STREAM_TYPE_DEFAULT, /* default stream type */ + CAM_STREAM_TYPE_PREVIEW, /* preview */ + CAM_STREAM_TYPE_POSTVIEW, /* postview */ + CAM_STREAM_TYPE_SNAPSHOT, /* snapshot */ + CAM_STREAM_TYPE_VIDEO, /* video */ + CAM_STREAM_TYPE_CALLBACK, /* app requested callback */ + CAM_STREAM_TYPE_IMPL_DEFINED, /* opaque format: could be display, video enc, ZSL YUV */ + CAM_STREAM_TYPE_METADATA, /* meta data */ + CAM_STREAM_TYPE_RAW, /* raw dump from camif */ + CAM_STREAM_TYPE_OFFLINE_PROC, /* offline process */ + CAM_STREAM_TYPE_PARM, /* mct internal stream */ + CAM_STREAM_TYPE_ANALYSIS, /* analysis stream */ + CAM_STREAM_TYPE_MAX, +} cam_stream_type_t; + +typedef enum { + CAM_PAD_NONE = 1, + CAM_PAD_TO_2 = 2, + CAM_PAD_TO_4 = 4, + CAM_PAD_TO_WORD = CAM_PAD_TO_4, + CAM_PAD_TO_8 = 8, + CAM_PAD_TO_16 = 16, + CAM_PAD_TO_32 = 32, + CAM_PAD_TO_64 = 64, + CAM_PAD_TO_128 = 128, + CAM_PAD_TO_256 = 256, + CAM_PAD_TO_512 = 512, + CAM_PAD_TO_1K = 1024, + CAM_PAD_TO_2K = 2048, + CAM_PAD_TO_4K = 4096, + CAM_PAD_TO_8K = 8192 +} cam_pad_format_t; + +typedef enum { + /* followings are per camera */ + CAM_MAPPING_BUF_TYPE_CAPABILITY, /* mapping camera capability buffer */ + CAM_MAPPING_BUF_TYPE_PARM_BUF, /* mapping parameters buffer */ + /* this buffer is needed for the payload to be sent with bundling related cameras cmd */ + CAM_MAPPING_BUF_TYPE_SYNC_RELATED_SENSORS_BUF, /* mapping sync buffer.*/ + + /* followings are per stream */ + CAM_MAPPING_BUF_TYPE_STREAM_BUF, /* mapping stream buffers */ + CAM_MAPPING_BUF_TYPE_STREAM_INFO, /* mapping stream information buffer */ + CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF, /* mapping offline process input buffer */ + CAM_MAPPING_BUF_TYPE_OFFLINE_META_BUF, /* mapping offline meta buffer */ + CAM_MAPPING_BUF_TYPE_MISC_BUF, /* mapping offline miscellaneous buffer */ + CAM_MAPPING_BUF_TYPE_STREAM_USER_BUF, /* mapping user ptr stream buffers */ + CAM_MAPPING_BUF_TYPE_MAX +} cam_mapping_buf_type; + +typedef enum { + CAM_STREAM_BUF_TYPE_MPLANE, /* Multiplanar Buffer type */ + CAM_STREAM_BUF_TYPE_USERPTR, /* User specific structure pointer*/ + CAM_STREAM_BUF_TYPE_MAX +} cam_stream_buf_type; + +typedef struct { + cam_mapping_buf_type type; + uint32_t stream_id; /* stream id: valid if STREAM_BUF */ + uint32_t frame_idx; /* frame index: valid if type is STREAM_BUF */ + int32_t plane_idx; /* planner index. valid if type is STREAM_BUF. + * -1 means all planners shanre the same fd; + * otherwise, each planner has its own fd */ + uint32_t cookie; /* could be job_id(uint32_t) to identify mapping job */ + int32_t fd; /* origin fd */ + size_t size; /* size of the buffer */ +} cam_buf_map_type; + +typedef struct { + uint32_t length; + cam_buf_map_type buf_maps[CAM_MAX_NUM_BUFS_PER_STREAM]; +} cam_buf_map_type_list; + +typedef struct { + cam_mapping_buf_type type; + uint32_t stream_id; /* stream id: valid if STREAM_BUF */ + uint32_t frame_idx; /* frame index: valid if STREAM_BUF or HIST_BUF */ + int32_t plane_idx; /* planner index. valid if type is STREAM_BUF. + * -1 means all planners shanre the same fd; + * otherwise, each planner has its own fd */ + uint32_t cookie; /* could be job_id(uint32_t) to identify unmapping job */ +} cam_buf_unmap_type; + +typedef struct { + uint32_t length; + cam_buf_unmap_type buf_unmaps[CAM_MAX_NUM_BUFS_PER_STREAM]; +} cam_buf_unmap_type_list; + +typedef enum { + CAM_MAPPING_TYPE_FD_MAPPING, + CAM_MAPPING_TYPE_FD_UNMAPPING, + CAM_MAPPING_TYPE_FD_BUNDLED_MAPPING, + CAM_MAPPING_TYPE_FD_BUNDLED_UNMAPPING, + CAM_MAPPING_TYPE_MAX +} cam_mapping_type; + +typedef struct { + cam_mapping_type msg_type; + union { + cam_buf_map_type buf_map; + cam_buf_unmap_type buf_unmap; + cam_buf_map_type_list buf_map_list; + cam_buf_unmap_type_list buf_unmap_list; + } payload; +} cam_sock_packet_t; + +typedef enum { + CAM_MODE_2D = (1<<0), + CAM_MODE_3D = (1<<1) +} cam_mode_t; + +typedef struct { + uint32_t len; + uint32_t y_offset; + uint32_t cbcr_offset; +} cam_sp_len_offset_t; + +typedef struct{ + uint32_t len; + uint32_t offset; + int32_t offset_x; + int32_t offset_y; + int32_t stride; + int32_t stride_in_bytes; + int32_t scanline; + int32_t width; /* width without padding */ + int32_t height; /* height without padding */ + int32_t meta_stride; /*Meta stride*/ + int32_t meta_scanline; /*Meta Scanline*/ + int32_t meta_len; /*Meta plane length including 4k padding*/ +} cam_mp_len_offset_t; + +typedef struct { + uint32_t offset_x; + uint32_t offset_y; +} cam_offset_info_t; + +typedef struct { + uint32_t width_padding; + uint32_t height_padding; + uint32_t plane_padding; + uint32_t min_stride; + uint32_t min_scanline; + cam_offset_info_t offset_info; +} cam_padding_info_t; + +typedef struct { + uint32_t num_planes; /*Number of planes in planar buffer*/ + union { + cam_sp_len_offset_t sp; + cam_mp_len_offset_t mp[VIDEO_MAX_PLANES]; + }; + uint32_t frame_len; +} cam_frame_len_offset_t; + +typedef struct { + uint8_t frame_buf_cnt; /*Total plane frames present in 1 batch*/ + uint32_t size; /*Size of 1 batch buffer. Kernel structure size*/ + long frameInterval; /*frame interval between each frame*/ +} cam_stream_user_buf_info_t; + +typedef struct { + int32_t width; + int32_t height; +} cam_dimension_t; + +typedef struct { + cam_frame_len_offset_t plane_info; +} cam_stream_buf_plane_info_t; + +typedef struct { + float min_fps; + float max_fps; + float video_min_fps; + float video_max_fps; +} cam_fps_range_t; + +typedef struct { + int32_t min_sensitivity; + int32_t max_sensitivity; +} cam_sensitivity_range_t; + +typedef enum { + CAM_HFR_MODE_OFF, + CAM_HFR_MODE_60FPS, + CAM_HFR_MODE_90FPS, + CAM_HFR_MODE_120FPS, + CAM_HFR_MODE_150FPS, + CAM_HFR_MODE_180FPS, + CAM_HFR_MODE_210FPS, + CAM_HFR_MODE_240FPS, + CAM_HFR_MODE_480FPS, + CAM_HFR_MODE_MAX +} cam_hfr_mode_t; + +typedef struct { + cam_hfr_mode_t mode; + uint8_t dim_cnt; /* hfr sizes table count */ + cam_dimension_t dim[MAX_SIZES_CNT]; /* hfr sizes table */ + uint8_t livesnapshot_sizes_tbl_cnt; /* livesnapshot sizes table count */ + cam_dimension_t livesnapshot_sizes_tbl[MAX_SIZES_CNT]; /* livesnapshot sizes table */ +} cam_hfr_info_t; + +typedef enum { + CAM_WB_MODE_AUTO, + CAM_WB_MODE_CUSTOM, + CAM_WB_MODE_INCANDESCENT, + CAM_WB_MODE_FLUORESCENT, + CAM_WB_MODE_WARM_FLUORESCENT, + CAM_WB_MODE_DAYLIGHT, + CAM_WB_MODE_CLOUDY_DAYLIGHT, + CAM_WB_MODE_TWILIGHT, + CAM_WB_MODE_SHADE, + CAM_WB_MODE_MANUAL, + CAM_WB_MODE_OFF, + CAM_WB_MODE_MAX +} cam_wb_mode_type; + +typedef enum { + CAM_ANTIBANDING_MODE_OFF, + CAM_ANTIBANDING_MODE_60HZ, + CAM_ANTIBANDING_MODE_50HZ, + CAM_ANTIBANDING_MODE_AUTO, + CAM_ANTIBANDING_MODE_AUTO_50HZ, + CAM_ANTIBANDING_MODE_AUTO_60HZ, + CAM_ANTIBANDING_MODE_MAX, +} cam_antibanding_mode_type; + +/* Enum Type for different ISO Mode supported */ +typedef enum { + CAM_ISO_MODE_AUTO, + CAM_ISO_MODE_DEBLUR, + CAM_ISO_MODE_100, + CAM_ISO_MODE_200, + CAM_ISO_MODE_400, + CAM_ISO_MODE_800, + CAM_ISO_MODE_1600, + CAM_ISO_MODE_3200, + CAM_ISO_MODE_MAX +} cam_iso_mode_type; + +typedef enum { + CAM_AEC_MODE_FRAME_AVERAGE, + CAM_AEC_MODE_CENTER_WEIGHTED, + CAM_AEC_MODE_SPOT_METERING, + CAM_AEC_MODE_SMART_METERING, + CAM_AEC_MODE_USER_METERING, + CAM_AEC_MODE_SPOT_METERING_ADV, + CAM_AEC_MODE_CENTER_WEIGHTED_ADV, + CAM_AEC_MODE_MAX +} cam_auto_exposure_mode_type; + +/* enum to select AEC convergence type */ +typedef enum { + /* Normal AEC connvergence */ + CAM_AEC_NORMAL_CONVERGENCE = 0, + /* Aggressive AEC connvergence */ + CAM_AEC_AGGRESSIVE_CONVERGENCE, + /* Fast AEC convergence */ + CAM_AEC_FAST_CONVERGENCE, + CAM_AEC_CONVERGENCE_MAX +} cam_aec_convergence_type; + +typedef enum { + CAM_AE_MODE_OFF, + CAM_AE_MODE_ON, + CAM_AE_MODE_MAX +} cam_ae_mode_type; + +typedef enum { + CAM_FOCUS_ALGO_AUTO, + CAM_FOCUS_ALGO_SPOT, + CAM_FOCUS_ALGO_CENTER_WEIGHTED, + CAM_FOCUS_ALGO_AVERAGE, + CAM_FOCUS_ALGO_MAX +} cam_focus_algorithm_type; + +/* Auto focus mode */ +typedef enum { + CAM_FOCUS_MODE_OFF, + CAM_FOCUS_MODE_AUTO, + CAM_FOCUS_MODE_INFINITY, + CAM_FOCUS_MODE_MACRO, + CAM_FOCUS_MODE_FIXED, + CAM_FOCUS_MODE_EDOF, + CAM_FOCUS_MODE_CONTINOUS_VIDEO, + CAM_FOCUS_MODE_CONTINOUS_PICTURE, + CAM_FOCUS_MODE_MANUAL, + CAM_FOCUS_MODE_MAX +} cam_focus_mode_type; + +typedef enum { + CAM_MANUAL_FOCUS_MODE_INDEX, + CAM_MANUAL_FOCUS_MODE_DAC_CODE, + CAM_MANUAL_FOCUS_MODE_RATIO, + CAM_MANUAL_FOCUS_MODE_DIOPTER, + CAM_MANUAL_FOCUS_MODE_MAX +} cam_manual_focus_mode_type; + +typedef struct { + cam_manual_focus_mode_type flag; + union{ + int32_t af_manual_lens_position_index; + int32_t af_manual_lens_position_dac; + int32_t af_manual_lens_position_ratio; + float af_manual_diopter; + }; +} cam_manual_focus_parm_t; + +typedef enum { + CAM_MANUAL_WB_MODE_CCT, + CAM_MANUAL_WB_MODE_GAIN, + CAM_MANUAL_WB_MODE_MAX +} cam_manual_wb_mode_type; + +typedef struct { + float r_gain; + float g_gain; + float b_gain; +} cam_awb_gain_t; + +typedef struct { + cam_manual_wb_mode_type type; + union{ + int32_t cct; + cam_awb_gain_t gains; + }; +} cam_manual_wb_parm_t; + +typedef enum { + CAM_SCENE_MODE_OFF, + CAM_SCENE_MODE_AUTO, + CAM_SCENE_MODE_LANDSCAPE, + CAM_SCENE_MODE_SNOW, + CAM_SCENE_MODE_BEACH, + CAM_SCENE_MODE_SUNSET, + CAM_SCENE_MODE_NIGHT, + CAM_SCENE_MODE_PORTRAIT, + CAM_SCENE_MODE_BACKLIGHT, + CAM_SCENE_MODE_SPORTS, + CAM_SCENE_MODE_ANTISHAKE, + CAM_SCENE_MODE_FLOWERS, + CAM_SCENE_MODE_CANDLELIGHT, + CAM_SCENE_MODE_FIREWORKS, + CAM_SCENE_MODE_PARTY, + CAM_SCENE_MODE_NIGHT_PORTRAIT, + CAM_SCENE_MODE_THEATRE, + CAM_SCENE_MODE_ACTION, + CAM_SCENE_MODE_AR, + CAM_SCENE_MODE_FACE_PRIORITY, + CAM_SCENE_MODE_BARCODE, + CAM_SCENE_MODE_HDR, + CAM_SCENE_MODE_AQUA, + CAM_SCENE_MODE_MAX +} cam_scene_mode_type; + +typedef enum { + CAM_EFFECT_MODE_OFF, + CAM_EFFECT_MODE_MONO, + CAM_EFFECT_MODE_NEGATIVE, + CAM_EFFECT_MODE_SOLARIZE, + CAM_EFFECT_MODE_SEPIA, + CAM_EFFECT_MODE_POSTERIZE, + CAM_EFFECT_MODE_WHITEBOARD, + CAM_EFFECT_MODE_BLACKBOARD, + CAM_EFFECT_MODE_AQUA, + CAM_EFFECT_MODE_EMBOSS, + CAM_EFFECT_MODE_SKETCH, + CAM_EFFECT_MODE_NEON, + CAM_EFFECT_MODE_BEAUTY, + CAM_EFFECT_MODE_MAX +} cam_effect_mode_type; + +typedef enum { + CAM_FLASH_MODE_OFF, + CAM_FLASH_MODE_AUTO, + CAM_FLASH_MODE_ON, + CAM_FLASH_MODE_TORCH, + CAM_FLASH_MODE_SINGLE, + CAM_FLASH_MODE_MAX +} cam_flash_mode_t; + +// Flash States +typedef enum { + CAM_FLASH_STATE_UNAVAILABLE, + CAM_FLASH_STATE_CHARGING, + CAM_FLASH_STATE_READY, + CAM_FLASH_STATE_FIRED, + CAM_FLASH_STATE_PARTIAL, + CAM_FLASH_STATE_MAX +} cam_flash_state_t; + +typedef enum { + CAM_FLASH_FIRING_LEVEL_0, + CAM_FLASH_FIRING_LEVEL_1, + CAM_FLASH_FIRING_LEVEL_2, + CAM_FLASH_FIRING_LEVEL_3, + CAM_FLASH_FIRING_LEVEL_4, + CAM_FLASH_FIRING_LEVEL_5, + CAM_FLASH_FIRING_LEVEL_6, + CAM_FLASH_FIRING_LEVEL_7, + CAM_FLASH_FIRING_LEVEL_8, + CAM_FLASH_FIRING_LEVEL_9, + CAM_FLASH_FIRING_LEVEL_10, + CAM_FLASH_FIRING_LEVEL_MAX +} cam_flash_firing_level_t; + + +typedef enum { + CAM_AEC_TRIGGER_IDLE, + CAM_AEC_TRIGGER_START +} cam_aec_trigger_type_t; + +typedef enum { + CAM_AF_TRIGGER_IDLE, + CAM_AF_TRIGGER_START, + CAM_AF_TRIGGER_CANCEL +} cam_af_trigger_type_t; + +typedef enum { + CAM_AE_STATE_INACTIVE, + CAM_AE_STATE_SEARCHING, + CAM_AE_STATE_CONVERGED, + CAM_AE_STATE_LOCKED, + CAM_AE_STATE_FLASH_REQUIRED, + CAM_AE_STATE_PRECAPTURE +} cam_ae_state_t; + +typedef enum { + CAM_NOISE_REDUCTION_MODE_OFF, + CAM_NOISE_REDUCTION_MODE_FAST, + CAM_NOISE_REDUCTION_MODE_HIGH_QUALITY, + CAM_NOISE_REDUCTION_MODE_MINIMAL, + CAM_NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG +} cam_noise_reduction_mode_t; + +typedef enum { + CAM_EDGE_MODE_OFF, + CAM_EDGE_MODE_FAST, + CAM_EDGE_MODE_HIGH_QUALITY, + CAM_EDGE_MODE_ZERO_SHUTTER_LAG, +} cam_edge_mode_t; + +typedef struct { + uint8_t edge_mode; + int32_t sharpness; +} cam_edge_application_t; + +typedef enum { + CAM_BLACK_LEVEL_LOCK_OFF, + CAM_BLACK_LEVEL_LOCK_ON, +} cam_black_level_lock_t; + +typedef enum { + CAM_HOTPIXEL_MODE_OFF, + CAM_HOTPIXEL_MODE_FAST, + CAM_HOTPIXEL_MODE_HIGH_QUALITY, +} cam_hotpixel_mode_t; + +typedef enum { + CAM_LENS_SHADING_MAP_MODE_OFF, + CAM_LENS_SHADING_MAP_MODE_ON, +} cam_lens_shading_map_mode_t; + +typedef enum { + CAM_LENS_SHADING_MODE_OFF, + CAM_LENS_SHADING_MODE_FAST, + CAM_LENS_SHADING_MODE_HIGH_QUALITY, +} cam_lens_shading_mode_t; + +typedef enum { + CAM_FACE_DETECT_MODE_OFF, + CAM_FACE_DETECT_MODE_SIMPLE, + CAM_FACE_DETECT_MODE_FULL, +} cam_face_detect_mode_t; + +typedef enum { + CAM_TONEMAP_MODE_CONTRAST_CURVE, + CAM_TONEMAP_MODE_FAST, + CAM_TONEMAP_MODE_HIGH_QUALITY, +} cam_tonemap_mode_t; + +typedef enum { + CAM_CDS_MODE_OFF, + CAM_CDS_MODE_ON, + CAM_CDS_MODE_AUTO, + CAM_CDS_MODE_LOCK, + CAM_CDS_MODE_MAX +} cam_cds_mode_type_t; + +typedef enum { + CAM_SENSOR_HDR_OFF, + CAM_SENSOR_HDR_IN_SENSOR = 1, + CAM_SENSOR_HDR_ZIGZAG, + CAM_SENSOR_HDR_MAX, +} cam_sensor_hdr_type_t; + +typedef struct { + int32_t left; + int32_t top; + int32_t width; + int32_t height; +} cam_rect_t; + +typedef struct { + cam_rect_t rect; + int32_t weight; /* weight of the area, valid for focusing/metering areas */ +} cam_area_t; + +typedef enum { + CAM_STREAMING_MODE_CONTINUOUS, /* continous streaming */ + CAM_STREAMING_MODE_BURST, /* burst streaming */ + CAM_STREAMING_MODE_BATCH, /* stream frames in batches */ + CAM_STREAMING_MODE_MAX +} cam_streaming_mode_t; + +typedef enum { + IS_TYPE_NONE, + IS_TYPE_DIS, + IS_TYPE_GA_DIS, + IS_TYPE_EIS_1_0, + IS_TYPE_EIS_2_0, + IS_TYPE_EIS_3_0, + IS_TYPE_MAX +} cam_is_type_t; + +typedef enum { + DIS_DISABLE, + DIS_ENABLE +} cam_dis_mode_t; + +typedef enum { + NON_SECURE, + SECURE +} cam_stream_secure_t; + +#define CAM_REPROCESS_MASK_TYPE_WNR (1<<0) + +/* event from server */ +typedef enum { + CAM_EVENT_TYPE_MAP_UNMAP_DONE = (1<<0), + CAM_EVENT_TYPE_AUTO_FOCUS_DONE = (1<<1), + CAM_EVENT_TYPE_ZOOM_DONE = (1<<2), + CAM_EVENT_TYPE_DAEMON_DIED = (1<<3), + CAM_EVENT_TYPE_INT_TAKE_JPEG = (1<<4), + CAM_EVENT_TYPE_INT_TAKE_RAW = (1<<5), + CAM_EVENT_TYPE_DAEMON_PULL_REQ = (1<<6), + CAM_EVENT_TYPE_CAC_DONE = (1<<7), + CAM_EVENT_TYPE_MAX +} cam_event_type_t; + +typedef enum { + CAM_EXP_BRACKETING_OFF, + CAM_EXP_BRACKETING_ON +} cam_bracket_mode; + +typedef enum { + CAM_LOW_LIGHT_OFF = 0, + CAM_LOW_LIGHT_ON, +} cam_low_light_mode_t; + +typedef struct { + cam_bracket_mode mode; + char values[MAX_EXP_BRACKETING_LENGTH]; /* user defined values */ +} cam_exp_bracketing_t; + +typedef struct { + uint32_t num_frames; + cam_exp_bracketing_t exp_val; +} cam_hdr_bracketing_info_t; + + typedef struct { + cam_bracket_mode mode; + int32_t values; /* user defined values */ +} cam_capture_bracketing_t; + +typedef enum { + CAM_SETTINGS_TYPE_OFF, + CAM_SETTINGS_TYPE_ON, + CAM_SETTINGS_TYPE_AUTO +} cam_manual_setting_mode; + +typedef struct { + cam_manual_setting_mode exp_mode; + int64_t exp_time; + cam_manual_setting_mode iso_mode; + int32_t iso_value; +} cam_capture_manual_3A_t; + +typedef enum { + CAM_CAPTURE_NORMAL, + CAM_CAPTURE_FLASH, + CAM_CAPTURE_BRACKETING, + CAM_CAPTURE_LOW_LIGHT, + CAM_CAPTURE_RESET, + CAM_CAPTURE_MANUAL_3A, + CAM_CAPTURE_MAX +} cam_capture_type; + +typedef struct { + int32_t num_frames; /*Num of frames requested on this quality*/ + cam_capture_type type; /*type of the capture request*/ + + /*union to strore values of capture type*/ + union { + cam_flash_mode_t flash_mode; + cam_capture_bracketing_t hdr_mode; + cam_low_light_mode_t low_light_mode; + cam_capture_manual_3A_t manual_3A_mode; + }; +} cam_capture_settings_t; + +typedef struct { + uint32_t num_batch; /*Number of frames batch requested*/ + cam_capture_settings_t configs[MAX_CAPTURE_BATCH_NUM]; +} cam_capture_frame_config_t; + +typedef struct { + uint8_t stepsize; + uint8_t direction; + int32_t num_steps; + uint8_t ttype; +} tune_actuator_t; + +typedef struct { + uint8_t module; + uint8_t type; + int32_t value; +} tune_cmd_t; + +typedef enum { + CAM_AEC_ROI_OFF, + CAM_AEC_ROI_ON +} cam_aec_roi_ctrl_t; + +typedef enum { + CAM_AEC_ROI_BY_INDEX, + CAM_AEC_ROI_BY_COORDINATE, +} cam_aec_roi_type_t; + +typedef struct { + uint32_t x; + uint32_t y; +} cam_coordinate_type_t; + +typedef struct { + int32_t numerator; + int32_t denominator; +} cam_rational_type_t; + +typedef struct { + cam_aec_roi_ctrl_t aec_roi_enable; + cam_aec_roi_type_t aec_roi_type; + union { + cam_coordinate_type_t coordinate[MAX_ROI]; + uint32_t aec_roi_idx[MAX_ROI]; + } cam_aec_roi_position; +} cam_set_aec_roi_t; + +typedef struct { + uint32_t frm_id; + uint8_t num_roi; + cam_rect_t roi[MAX_ROI]; + int32_t weight[MAX_ROI]; + uint8_t is_multiwindow; +} cam_roi_info_t; + +typedef enum { + CAM_WAVELET_DENOISE_YCBCR_PLANE, + CAM_WAVELET_DENOISE_CBCR_ONLY, + CAM_WAVELET_DENOISE_STREAMLINE_YCBCR, + CAM_WAVELET_DENOISE_STREAMLINED_CBCR +} cam_denoise_process_type_t; + +typedef struct { + uint8_t denoise_enable; + cam_denoise_process_type_t process_plates; +} cam_denoise_param_t; + +#define CAM_FACE_PROCESS_MASK_DETECTION (1U<<0) +#define CAM_FACE_PROCESS_MASK_RECOGNITION (1U<<1) +#define CAM_FACE_PROCESS_MASK_FOCUS (1U<<2) +#define CAM_FACE_PROCESS_MASK_BLINK (1U<<3) +#define CAM_FACE_PROCESS_MASK_SMILE (1U<<4) +#define CAM_FACE_PROCESS_MASK_GAZE (1U<<5) + +typedef struct { + uint32_t fd_mode; /* mask of face process */ + uint32_t num_fd; +} cam_fd_set_parm_t; + +typedef enum { + QCAMERA_FD_PREVIEW, + QCAMERA_FD_SNAPSHOT +}qcamera_face_detect_type_t; + +typedef enum { + CAM_FACE_CT_POINT_EYE_L_PUPIL, + CAM_FACE_CT_POINT_EYE_L_IN, + CAM_FACE_CT_POINT_EYE_L_OUT, + CAM_FACE_CT_POINT_EYE_L_UP, + CAM_FACE_CT_POINT_EYE_L_DOWN, + CAM_FACE_CT_POINT_EYE_R_PUPIL, + CAM_FACE_CT_POINT_EYE_R_IN, + CAM_FACE_CT_POINT_EYE_R_OUT, + CAM_FACE_CT_POINT_EYE_R_UP, + CAM_FACE_CT_POINT_EYE_R_DOWN, + CAM_FACE_CT_POINT_EYE_MAX +} cam_face_ct_point_eye_t; + +typedef enum { + CAM_FACE_CT_POINT_FOREHEAD, + CAM_FACE_CT_POINT_FOREHEAD_MAX +} cam_face_ct_point_forh_t; + +typedef enum { + CAM_FACE_CT_POINT_NOSE, + CAM_FACE_CT_POINT_NOSE_TIP, + CAM_FACE_CT_POINT_NOSE_L, + CAM_FACE_CT_POINT_NOSE_R, + CAM_FACE_CT_POINT_NOSE_L_0, + CAM_FACE_CT_POINT_NOSE_R_0, + CAM_FACE_CT_POINT_NOSE_L_1, + CAM_FACE_CT_POINT_NOSE_R_1, + CAM_FACE_CT_POINT_NOSE_MAX +} cam_face_ct_point_nose_t; + +typedef enum { + CAM_FACE_CT_POINT_MOUTH_L, + CAM_FACE_CT_POINT_MOUTH_R, + CAM_FACE_CT_POINT_MOUTH_UP, + CAM_FACE_CT_POINT_MOUTH_DOWN, + CAM_FACE_CT_POINT_MOUTH_MAX +} cam_face_ct_point_mouth_t; + +typedef enum { + CAM_FACE_CT_POINT_LIP_UP, + CAM_FACE_CT_POINT_LIP_DOWN, + CAM_FACE_CT_POINT_LIP_MAX +} cam_face_ct_point_lip_t; + +typedef enum { + CAM_FACE_CT_POINT_BROW_L_UP, + CAM_FACE_CT_POINT_BROW_L_DOWN, + CAM_FACE_CT_POINT_BROW_L_IN, + CAM_FACE_CT_POINT_BROW_L_OUT, + CAM_FACE_CT_POINT_BROW_R_UP, + CAM_FACE_CT_POINT_BROW_R_DOWN, + CAM_FACE_CT_POINT_BROW_R_IN, + CAM_FACE_CT_POINT_BROW_R_OUT, + CAM_FACE_CT_POINT_BROW_MAX +} cam_face_ct_point_brow_t; + +typedef enum { + CAM_FACE_CT_POINT_CHIN, + CAM_FACE_CT_POINT_CHIN_L, + CAM_FACE_CT_POINT_CHIN_R, + CAM_FACE_CT_POINT_CHIN_MAX +} cam_face_ct_point_chin_t; + +typedef enum { + CAM_FACE_CT_POINT_EAR_L_DOWN, + CAM_FACE_CT_POINT_EAR_R_DOWN, + CAM_FACE_CT_POINT_EAR_L_UP, + CAM_FACE_CT_POINT_EAR_R_UP, + CAM_FACE_CT_POINT_EAR_MAX +} cam_face_ct_point_ear_t; + +typedef struct { + uint8_t is_eye_valid; + cam_coordinate_type_t contour_eye_pt[CAM_FACE_CT_POINT_EYE_MAX]; + uint8_t is_forehead_valid; + cam_coordinate_type_t contour_forh_pt[CAM_FACE_CT_POINT_FOREHEAD_MAX]; + uint8_t is_nose_valid; + cam_coordinate_type_t contour_nose_pt[CAM_FACE_CT_POINT_NOSE_MAX]; + uint8_t is_mouth_valid; + cam_coordinate_type_t contour_mouth_pt[CAM_FACE_CT_POINT_MOUTH_MAX]; + uint8_t is_lip_valid; + cam_coordinate_type_t contour_lip_pt[CAM_FACE_CT_POINT_LIP_MAX]; + uint8_t is_brow_valid; + cam_coordinate_type_t contour_brow_pt[CAM_FACE_CT_POINT_BROW_MAX]; + uint8_t is_chin_valid; + cam_coordinate_type_t contour_chin_pt[CAM_FACE_CT_POINT_CHIN_MAX]; + uint8_t is_ear_valid; + cam_coordinate_type_t contour_ear_pt[CAM_FACE_CT_POINT_EAR_MAX]; +} cam_face_contour_info_t; + +typedef struct { + cam_face_contour_info_t face_contour[MAX_ROI]; +} cam_face_contour_data_t; + +typedef struct { + cam_coordinate_type_t left_eye_center; /* coordinate of center of left eye */ + cam_coordinate_type_t right_eye_center; /* coordinate of center of right eye */ + cam_coordinate_type_t mouth_center; /* coordinate of center of mouth */ +} cam_face_landmarks_info_t; + +typedef struct { + cam_face_landmarks_info_t face_landmarks[MAX_ROI]; +} cam_face_landmarks_data_t; + +typedef struct { + uint8_t smile_degree; /* smile degree (0, -100) */ + uint8_t smile_confidence; /* smile confidence (0, 100) */ +} cam_face_smile_info_t; + +typedef struct { + cam_face_smile_info_t smile[MAX_ROI]; +} cam_face_smile_data_t; + +typedef struct { + int8_t gaze_angle; /* -90 -45 0 45 90 for head left to rigth tilt */ + int32_t updown_dir; /* up down direction (-180, 179) */ + int32_t leftright_dir; /* left right direction (-180, 179) */ + int32_t roll_dir; /* roll direction (-180, 179) */ + int8_t left_right_gaze; /* left right gaze degree (-50, 50) */ + int8_t top_bottom_gaze; /* up down gaze degree (-50, 50) */ +} cam_face_gaze_info_t; + +typedef struct { + cam_face_gaze_info_t gaze[MAX_ROI]; +} cam_face_gaze_data_t; + +typedef struct { + uint8_t blink_detected; /* if blink is detected */ + uint8_t left_blink; /* left eye blink degeree (0, -100) */ + uint8_t right_blink; /* right eye blink degree (0, - 100) */ +} cam_face_blink_info_t; + +typedef struct { + cam_face_blink_info_t blink[MAX_ROI]; +} cam_face_blink_data_t; + +typedef struct { + uint8_t face_recognised; /* if face is recognised */ + uint32_t unique_id; /* if face is recognised */ +} cam_face_recog_info_t; + +typedef struct { + cam_face_recog_info_t face_rec[MAX_ROI]; +} cam_face_recog_data_t; + +typedef struct { + int32_t face_id; /* unique id for face tracking within view unless view changes */ + int8_t score; /* score of confidence (0, -100) */ + cam_rect_t face_boundary; /* boundary of face detected */ +} cam_face_detection_info_t; + +typedef struct { + uint32_t frame_id; /* frame index of which faces are detected */ + uint8_t num_faces_detected; /* number of faces detected */ + cam_face_detection_info_t faces[MAX_ROI]; /* detailed information of faces detected */ + qcamera_face_detect_type_t fd_type; /* face detect for preview or snapshot frame*/ + cam_dimension_t fd_frame_dim; /* frame dims on which fd is applied */ + uint8_t update_flag; /* flag to inform whether HAL needs to send cb + * to app or not */ +} cam_face_detection_data_t; + +// definition of composite face detection data +typedef struct { + cam_face_detection_data_t detection_data; + + int8_t recog_valid; + cam_face_recog_data_t recog_data; + + int8_t blink_valid; + cam_face_blink_data_t blink_data; + + int8_t gaze_valid; + cam_face_gaze_data_t gaze_data; + + int8_t smile_valid; + cam_face_smile_data_t smile_data; + + int8_t landmark_valid; + cam_face_landmarks_data_t landmark_data; + + int8_t contour_valid; + cam_face_contour_data_t contour_data; +} cam_faces_data_t; + +#define CAM_HISTOGRAM_STATS_SIZE 256 +typedef struct { + uint32_t max_hist_value; + uint32_t hist_buf[CAM_HISTOGRAM_STATS_SIZE]; /* buf holding histogram stats data */ +} cam_histogram_data_t; + +typedef struct { + cam_histogram_data_t r_stats; + cam_histogram_data_t b_stats; + cam_histogram_data_t gr_stats; + cam_histogram_data_t gb_stats; +} cam_bayer_hist_stats_t; + +typedef enum { + CAM_HISTOGRAM_TYPE_BAYER, + CAM_HISTOGRAM_TYPE_YUV +} cam_histogram_type_t; + +typedef struct { + cam_histogram_type_t type; + union { + cam_bayer_hist_stats_t bayer_stats; + cam_histogram_data_t yuv_stats; + }; +} cam_hist_stats_t; + +enum cam_focus_distance_index{ + CAM_FOCUS_DISTANCE_NEAR_INDEX, /* 0 */ + CAM_FOCUS_DISTANCE_OPTIMAL_INDEX, + CAM_FOCUS_DISTANCE_FAR_INDEX, + CAM_FOCUS_DISTANCE_MAX_INDEX +}; + +typedef struct { + float focus_distance[CAM_FOCUS_DISTANCE_MAX_INDEX]; +} cam_focus_distances_info_t; + +typedef struct { + uint32_t scale; + float diopter; +} cam_focus_pos_info_t ; + +typedef struct { + float focalLengthRatio; +} cam_focal_length_ratio_t; + +typedef struct { + uint8_t needFlush; + uint32_t focused_frame_idx; +} cam_af_flush_info_t; + +/* Different autofocus cycle when calling do_autoFocus + * CAM_AF_COMPLETE_EXISTING_SWEEP: Complete existing sweep + * if one is ongoing, and lock. + * CAM_AF_DO_ONE_FULL_SWEEP: Do one full sweep, regardless + * of the current state, and lock. + * CAM_AF_START_CONTINUOUS_SWEEP: Start continous sweep. + * After do_autoFocus, HAL receives an event: CAM_AF_FOCUSED, + * or CAM_AF_NOT_FOCUSED. + * cancel_autoFocus stops any lens movement. + * Each do_autoFocus call only produces 1 FOCUSED/NOT_FOCUSED + * event, not both. + */ +typedef enum { + CAM_AF_COMPLETE_EXISTING_SWEEP, + CAM_AF_DO_ONE_FULL_SWEEP, + CAM_AF_START_CONTINUOUS_SWEEP +} cam_autofocus_cycle_t; + +typedef enum { + CAM_AF_SCANNING, + CAM_AF_FOCUSED, + CAM_AF_NOT_FOCUSED, + CAM_CAF_SCANNING, + CAM_CAF_FOCUSED, + CAM_CAF_NOT_FOCUSED, + CAM_AF_INACTIVE +} cam_autofocus_state_t; + +//Don't change the order of the AF states below. It should match +//with the corresponding enum in frameworks (camera3.h and +//CameraMetadata.java) +typedef enum { + CAM_AF_STATE_INACTIVE, + CAM_AF_STATE_PASSIVE_SCAN, + CAM_AF_STATE_PASSIVE_FOCUSED, + CAM_AF_STATE_ACTIVE_SCAN, + CAM_AF_STATE_FOCUSED_LOCKED, + CAM_AF_STATE_NOT_FOCUSED_LOCKED, + CAM_AF_STATE_PASSIVE_UNFOCUSED +} cam_af_state_t; + +typedef struct { + cam_af_state_t focus_state; /* state of focus */ + cam_focus_distances_info_t focus_dist; /* focus distance */ + cam_focus_mode_type focus_mode; /* focus mode from backend */ + int32_t focus_pos; + cam_af_flush_info_t flush_info; +} cam_auto_focus_data_t; + +typedef struct { + uint32_t stream_id; + cam_rect_t crop; + cam_rect_t roi_map; +} cam_stream_crop_info_t; + +typedef struct { + uint8_t num_of_streams; + cam_stream_crop_info_t crop_info[MAX_NUM_STREAMS]; +} cam_crop_data_t; + +typedef struct { + uint32_t stream_id; + uint32_t cds_enable; +} cam_stream_cds_info_t; + +typedef struct { + uint8_t session_cds_enable; + uint8_t num_of_streams; + cam_stream_cds_info_t cds_info[MAX_NUM_STREAMS]; +} cam_cds_data_t; + +typedef enum { + DO_NOT_NEED_FUTURE_FRAME, + NEED_FUTURE_FRAME, +} cam_prep_snapshot_state_t; + +#define CC_GAINS_COUNT 4 + +typedef struct { + float gains[CC_GAINS_COUNT]; +} cam_color_correct_gains_t; + +typedef struct { + // If LED is ON and Burst Num > 1, this is first LED ON frame + uint32_t min_frame_idx; + // If LED is ON and Burst Num > 1, this is first LED Off frame after ON + uint32_t max_frame_idx; + // Used only when LED Is ON and burst num > 1 + uint32_t num_led_on_frames; + // Skip count after LED is turned OFF + uint32_t frame_skip_count; + // Batch id for each picture request + uint32_t config_batch_idx; +} cam_frame_idx_range_t; + +typedef enum { + S_NORMAL = 0, + S_SCENERY, + S_PORTRAIT, + S_PORTRAIT_BACKLIGHT, + S_SCENERY_BACKLIGHT, + S_BACKLIGHT, + S_HDR, + S_MAX_DEFAULT, + S_CUSTOM0 = S_MAX_DEFAULT, + S_CUSTOM1, + S_CUSTOM2, + S_CUSTOM3, + S_CUSTOM4, + S_CUSTOM5, + S_CUSTOM6, + S_CUSTOM7, + S_CUSTOM8, + S_CUSTOM9, + S_MAX, +} cam_auto_scene_t; + +typedef struct { + uint32_t is_hdr_scene; + float hdr_confidence; +} cam_asd_hdr_scene_data_t; + +typedef struct { + uint32_t detected; + float confidence; + uint32_t auto_compensation; +} cam_asd_scene_info_t; + +typedef struct { + cam_auto_scene_t detected_scene; + uint8_t max_n_scenes; + cam_asd_scene_info_t scene_info[S_MAX]; +} cam_asd_decision_t; + + +typedef struct { + uint32_t meta_frame_id; +} cam_meta_valid_t; + +typedef enum { + CAM_SENSOR_RAW, + CAM_SENSOR_YUV, + CAM_SENSOR_MONO +} cam_sensor_t; + +typedef struct { + cam_flash_mode_t flash_mode; + float aperture_value; + cam_flash_state_t flash_state; + float focal_length; + float f_number; + int32_t sensing_method; + float crop_factor; + cam_sensor_t sens_type; +} cam_sensor_params_t; + +typedef enum { + CAM_METERING_MODE_UNKNOWN = 0, + CAM_METERING_MODE_AVERAGE = 1, + CAM_METERING_MODE_CENTER_WEIGHTED_AVERAGE = 2, + CAM_METERING_MODE_SPOT = 3, + CAM_METERING_MODE_MULTI_SPOT = 4, + CAM_METERING_MODE_PATTERN = 5, + CAM_METERING_MODE_PARTIAL = 6, + CAM_METERING_MODE_OTHER = 255, +} cam_metering_mode_t; + +typedef struct { + float exp_time; + int32_t iso_value; + uint32_t flash_needed; + uint32_t settled; + cam_wb_mode_type wb_mode; + uint32_t metering_mode; + uint32_t exposure_program; + uint32_t exposure_mode; + uint32_t scenetype; + float brightness; + float est_snap_exp_time; + int32_t est_snap_iso_value; + uint32_t est_snap_luma; + uint32_t est_snap_target; +} cam_3a_params_t; + +typedef struct { + uint64_t sw_version_number; + int32_t aec_debug_data_size; + char aec_private_debug_data[AEC_DEBUG_DATA_SIZE]; +} cam_ae_exif_debug_t; + +typedef struct { + int8_t awb_ccm_enable; + int8_t hard_awb_ccm_flag; + int8_t ccm_update_flag; + float ccm[AWB_NUM_CCM_ROWS][AWB_NUM_CCM_COLS]; + float ccm_offset[AWB_NUM_CCM_ROWS]; +} cam_awb_ccm_update_t; + +typedef struct { + int32_t cct_value; + cam_awb_gain_t rgb_gains; + cam_awb_ccm_update_t ccm_update; +} cam_awb_params_t; + +typedef struct { + int32_t awb_debug_data_size; + char awb_private_debug_data[AWB_DEBUG_DATA_SIZE]; +} cam_awb_exif_debug_t; + +/* AF debug data for exif*/ +typedef struct { + int32_t af_debug_data_size; + char af_private_debug_data[AF_DEBUG_DATA_SIZE]; +} cam_af_exif_debug_t; + +typedef struct { + int32_t asd_debug_data_size; + char asd_private_debug_data[ASD_DEBUG_DATA_SIZE]; +} cam_asd_exif_debug_t; + +typedef struct { + int32_t bg_stats_buffer_size; + int32_t bg_config_buffer_size; + char stats_buffer_private_debug_data[STATS_BUFFER_DEBUG_DATA_SIZE]; +} cam_stats_buffer_exif_debug_t; + +typedef struct { + int32_t be_stats_buffer_size; + int32_t be_config_buffer_size; + char bestats_buffer_private_debug_data[BESTATS_BUFFER_DEBUG_DATA_SIZE]; +} cam_bestats_buffer_exif_debug_t; + +typedef struct { + int32_t bhist_stats_buffer_size; + char bhist_private_debug_data[BHIST_STATS_DEBUG_DATA_SIZE]; +} cam_bhist_buffer_exif_debug_t; + +/* 3A version*/ +typedef struct { + uint16_t major_version; + uint16_t minor_version; + uint16_t patch_version; + uint16_t new_feature_des; +} cam_q3a_version_t; + +typedef struct { + int32_t tuning_info_buffer_size; + char tuning_info_private_debug_data[TUNING_INFO_DEBUG_DATA_SIZE]; +} cam_q3a_tuning_info_t; + +typedef struct { + uint32_t tuning_data_version; + size_t tuning_sensor_data_size; + size_t tuning_vfe_data_size; + size_t tuning_cpp_data_size; + size_t tuning_cac_data_size; + size_t tuning_cac_data_size2; + size_t tuning_mod3_data_size; + uint8_t data[TUNING_DATA_MAX]; +}tuning_params_t; + +typedef struct { + int32_t event_type; + cam_dimension_t dim; + size_t size; + char path[QCAMERA_MAX_FILEPATH_LENGTH]; + cam_format_t picture_format; +} cam_int_evt_params_t; + +typedef struct { + uint8_t private_isp_data[MAX_ISP_DATA_SIZE]; +} cam_chromatix_lite_isp_t; + +typedef struct { + uint8_t private_pp_data[MAX_PP_DATA_SIZE]; +} cam_chromatix_lite_pp_t; + +typedef struct { + uint8_t private_stats_data[MAX_AE_STATS_DATA_SIZE]; +} cam_chromatix_lite_ae_stats_t; + +typedef struct { + uint8_t private_stats_data[MAX_AWB_STATS_DATA_SIZE]; +} cam_chromatix_lite_awb_stats_t; + +typedef struct { + uint8_t private_stats_data[MAX_AF_STATS_DATA_SIZE]; +} cam_chromatix_lite_af_stats_t; + +typedef struct { + uint8_t private_stats_data[MAX_ASD_STATS_DATA_SIZE]; +} cam_chromatix_lite_asd_stats_t; + +typedef struct { + uint32_t min_buffers; + uint32_t max_buffers; +} cam_buffer_info_t; + +typedef enum { + /* Standalone camera (won't be linked) */ + CAM_TYPE_STANDALONE=0, + /* Main camera of the related cam subsystem which controls + HW sync at sensor level*/ + CAM_TYPE_MAIN, + /* Aux camera of the related cam subsystem */ + CAM_TYPE_AUX +} cam_sync_type_t; + +typedef struct { + cam_dimension_t stream_sizes[MAX_NUM_STREAMS]; + uint32_t num_streams; + cam_stream_type_t type[MAX_NUM_STREAMS]; + cam_feature_mask_t postprocess_mask[MAX_NUM_STREAMS]; + cam_buffer_info_t buffer_info; + cam_is_type_t is_type[MAX_NUM_STREAMS]; + cam_hfr_mode_t hfr_mode; + cam_format_t format[MAX_NUM_STREAMS]; + uint32_t buf_alignment; + uint32_t min_stride; + uint32_t min_scanline; + uint8_t batch_size; + cam_sync_type_t sync_type; +} cam_stream_size_info_t; + + +typedef enum { + CAM_INTF_OVERWRITE_MINI_CHROMATIX_OFFLINE, + CAM_INTF_OVERWRITE_ISP_HW_DATA_OFFLINE, + CAM_INTF_OVERWRITE_MINI_CHROMATIX_ONLINE, + CAM_INTF_OVERWRITE_ISP_HW_DATA_ONLINE, + CAM_INTF_OVERWRITE_MAX, +} cam_intf_overwrite_type_t; + +typedef struct { + uint8_t lds_enabled; + float rnr_sampling_factor; +} cam_img_hysterisis_info_t; + +typedef struct { + /* dynamic feature enablement */ + uint64_t dyn_feature_mask; + /* input frame count for stacking */ + uint32_t input_count; + /* reserved for future use */ + uint8_t reserved[32]; +} cam_dyn_img_data_t; + +typedef struct { + cam_intf_overwrite_type_t overwrite_type; + char isp_hw_data_list[4096]; /*add upper bound memory, customer to fill*/ + char chromatix_data_overwrite[4096]; /*add bound memory, customer fill*/ +} cam_hw_data_overwrite_t; + +typedef struct { + uint32_t num_streams; + uint32_t streamID[MAX_NUM_STREAMS]; +} cam_stream_ID_t; + +/*CAC Message posted during pipeline*/ +typedef struct { + uint32_t frame_id; + int32_t buf_idx; +} cam_cac_info_t; + +typedef struct +{ + uint32_t id; /* Frame ID */ + uint64_t timestamp; /* Time stamp */ + uint32_t distance_in_mm; /* Distance of object in ROI's in milimeters */ + uint32_t confidence; /* Confidence on distance from 0(No confidence)to 1024(max) */ + uint32_t status; /* Status of DCRF library execution call */ + cam_rect_t focused_roi; /* ROI's for which distance is estimated */ + uint32_t focused_x; /* Focus location X inside ROI with distance estimation */ + uint32_t focused_y; /* Focus location Y inside ROI with distance estimation */ +} cam_dcrf_result_t; + +typedef struct { + uint32_t frame_id; + uint32_t num_streams; + uint32_t stream_id[MAX_NUM_STREAMS]; +} cam_buf_divert_info_t; + +typedef struct { + uint8_t is_stats_valid; /* if histgram data is valid */ + cam_hist_stats_t stats_data; /* histogram data */ + + uint8_t is_faces_valid; /* if face detection data is valid */ + cam_face_detection_data_t faces_data; /* face detection result */ + + uint8_t is_focus_valid; /* if focus data is valid */ + cam_auto_focus_data_t focus_data; /* focus data */ + + uint8_t is_crop_valid; /* if crop data is valid */ + cam_crop_data_t crop_data; /* crop data */ + + uint8_t is_prep_snapshot_done_valid; /* if prep snapshot done is valid */ + cam_prep_snapshot_state_t prep_snapshot_done_state; /* prepare snapshot done state */ + + uint8_t is_cac_valid; /* if cac info is valid */ + cam_cac_info_t cac_info; /* cac info */ + + /* Hysterisis data from Img modules */ + uint8_t is_hyst_info_valid; /* if hyst info is valid */ + cam_img_hysterisis_info_t img_hyst_info; /* hyst info */ + + /* if good frame idx range is valid */ + uint8_t is_good_frame_idx_range_valid; + /* good frame idx range, make sure: + * 1. good_frame_idx_range.min_frame_idx > current_frame_idx + * 2. good_frame_idx_range.min_frame_idx - current_frame_idx < 100 */ + cam_frame_idx_range_t good_frame_idx_range; + + cam_asd_decision_t cam_asd_info; + + char private_metadata[MAX_METADATA_PRIVATE_PAYLOAD_SIZE_IN_BYTES]; + + /* AE parameters */ + uint8_t is_3a_params_valid; + cam_3a_params_t cam_3a_params; + + /* AE exif debug parameters */ + uint8_t is_ae_exif_debug_valid; + cam_ae_exif_debug_t ae_exif_debug_params; + + /* AWB exif debug parameters */ + uint8_t is_awb_exif_debug_valid; + cam_awb_exif_debug_t awb_exif_debug_params; + + /* AF exif debug parameters */ + uint8_t is_af_exif_debug_valid; + cam_af_exif_debug_t af_exif_debug_params; + + /* ASD exif debug parameters */ + uint8_t is_asd_exif_debug_valid; + cam_asd_exif_debug_t asd_exif_debug_params; + + /* Stats buffer exif debug parameters */ + uint8_t is_stats_buffer_exif_debug_valid; + cam_stats_buffer_exif_debug_t stats_buffer_exif_debug_params; + + /* BE stats buffer exif debug parameters */ + uint8_t is_bestats_buffer_exif_debug_valid; + cam_bestats_buffer_exif_debug_t bestats_buffer_exif_debug_params; + + /* Bhist exif debug parameters. */ + uint8_t is_bhist_exif_debug_valid; + cam_bhist_buffer_exif_debug_t bhist_exif_debug_params; + + /* AWB parameters */ + uint8_t is_awb_params_valid; + cam_awb_params_t awb_params; + + /* sensor parameters */ + uint8_t is_sensor_params_valid; + cam_sensor_params_t sensor_params; + + /* Meta valid params */ + uint8_t is_meta_valid; + cam_meta_valid_t meta_valid_params; + + /*Tuning Data*/ + uint8_t is_tuning_params_valid; + tuning_params_t tuning_params; + + uint8_t is_chromatix_lite_isp_valid; + cam_chromatix_lite_isp_t chromatix_lite_isp_data; + + uint8_t is_chromatix_lite_pp_valid; + cam_chromatix_lite_pp_t chromatix_lite_pp_data; + + uint8_t is_chromatix_lite_ae_stats_valid; + cam_chromatix_lite_ae_stats_t chromatix_lite_ae_stats_data; + + uint8_t is_chromatix_lite_awb_stats_valid; + cam_chromatix_lite_awb_stats_t chromatix_lite_awb_stats_data; + + uint8_t is_chromatix_lite_af_stats_valid; + cam_chromatix_lite_af_stats_t chromatix_lite_af_stats_data; + + uint8_t is_dcrf_result_valid; + cam_dcrf_result_t dcrf_result; + + /* Dynamic feature enablement from postprocessing modules */ + uint8_t is_dyn_img_data_valid; + cam_dyn_img_data_t dyn_img_data; + +} cam_metadata_info_t; + +typedef enum { + CAM_INTF_PARM_HAL_VERSION = 0x1, + + /* Overall mode of 3A control routines. We need to have this parameter + * because not all android.control.* have an OFF option, for example, + * AE_FPS_Range, aePrecaptureTrigger */ + CAM_INTF_META_MODE, + /* Whether AE is currently updating the sensor exposure and sensitivity + * fields */ + CAM_INTF_META_AEC_MODE, + CAM_INTF_PARM_WHITE_BALANCE, + CAM_INTF_PARM_FOCUS_MODE, + + /* common between HAL1 and HAL3 */ + CAM_INTF_PARM_ANTIBANDING, + CAM_INTF_PARM_EXPOSURE_COMPENSATION, + CAM_INTF_PARM_EV_STEP, + CAM_INTF_PARM_AEC_LOCK, + CAM_INTF_PARM_FPS_RANGE, /* 10 */ + CAM_INTF_PARM_AWB_LOCK, + CAM_INTF_PARM_EFFECT, + CAM_INTF_PARM_BESTSHOT_MODE, + CAM_INTF_PARM_DIS_ENABLE, + CAM_INTF_PARM_LED_MODE, + CAM_INTF_META_HISTOGRAM, + CAM_INTF_META_FACE_DETECTION, + /* Whether optical image stabilization is enabled. */ + CAM_INTF_META_LENS_OPT_STAB_MODE, + /* specific to HAl1 */ + CAM_INTF_META_AUTOFOCUS_DATA, + CAM_INTF_PARM_QUERY_FLASH4SNAP, /* 20 */ + CAM_INTF_PARM_EXPOSURE, + CAM_INTF_PARM_SHARPNESS, + CAM_INTF_PARM_CONTRAST, + CAM_INTF_PARM_SATURATION, + CAM_INTF_PARM_BRIGHTNESS, + CAM_INTF_PARM_ISO, + CAM_INTF_PARM_ZOOM, + CAM_INTF_PARM_ROLLOFF, + CAM_INTF_PARM_MODE, /* camera mode */ + CAM_INTF_PARM_AEC_ALGO_TYPE, /* 30 */ /* auto exposure algorithm */ + CAM_INTF_PARM_FOCUS_ALGO_TYPE, /* focus algorithm */ + CAM_INTF_PARM_AEC_ROI, + CAM_INTF_PARM_AF_ROI, + CAM_INTF_PARM_SCE_FACTOR, + CAM_INTF_PARM_FD, + CAM_INTF_PARM_MCE, + CAM_INTF_PARM_HFR, + CAM_INTF_PARM_REDEYE_REDUCTION, + CAM_INTF_PARM_WAVELET_DENOISE, + CAM_INTF_PARM_TEMPORAL_DENOISE, /* 40 */ + CAM_INTF_PARM_HISTOGRAM, + CAM_INTF_PARM_ASD_ENABLE, + CAM_INTF_PARM_RECORDING_HINT, + CAM_INTF_PARM_HDR, + CAM_INTF_PARM_MAX_DIMENSION, + CAM_INTF_PARM_RAW_DIMENSION, + CAM_INTF_PARM_FRAMESKIP, + CAM_INTF_PARM_ZSL_MODE, /* indicating if it's running in ZSL mode */ + CAM_INTF_PARM_BURST_NUM, + CAM_INTF_PARM_RETRO_BURST_NUM, /* 50 */ + CAM_INTF_PARM_BURST_LED_ON_PERIOD, + CAM_INTF_PARM_HDR_NEED_1X, /* if HDR needs 1x output */ + CAM_INTF_PARM_LOCK_CAF, + CAM_INTF_PARM_VIDEO_HDR, + CAM_INTF_PARM_SENSOR_HDR, + CAM_INTF_PARM_ROTATION, + CAM_INTF_PARM_SCALE, + CAM_INTF_PARM_VT, /* indicating if it's a Video Call Apllication */ + CAM_INTF_META_CROP_DATA, + CAM_INTF_META_PREP_SNAPSHOT_DONE, /* 60 */ + CAM_INTF_META_GOOD_FRAME_IDX_RANGE, + CAM_INTF_META_ASD_HDR_SCENE_DATA, + CAM_INTF_META_ASD_SCENE_INFO, + CAM_INTF_META_CURRENT_SCENE, + CAM_INTF_META_AEC_INFO, + CAM_INTF_META_SENSOR_INFO, + CAM_INTF_META_CHROMATIX_LITE_ISP, + CAM_INTF_META_CHROMATIX_LITE_PP, + CAM_INTF_META_CHROMATIX_LITE_AE, + CAM_INTF_META_CHROMATIX_LITE_AWB, /* 70 */ + CAM_INTF_META_CHROMATIX_LITE_AF, + CAM_INTF_META_CHROMATIX_LITE_ASD, + CAM_INTF_META_EXIF_DEBUG_AE, + CAM_INTF_META_EXIF_DEBUG_AWB, + CAM_INTF_META_EXIF_DEBUG_AF, + CAM_INTF_META_EXIF_DEBUG_ASD, + CAM_INTF_META_EXIF_DEBUG_STATS, + CAM_INTF_META_EXIF_DEBUG_BESTATS, + CAM_INTF_META_EXIF_DEBUG_BHIST, + CAM_INTF_META_EXIF_DEBUG_3A_TUNING, + CAM_INTF_PARM_GET_CHROMATIX, + CAM_INTF_PARM_SET_RELOAD_CHROMATIX, + CAM_INTF_PARM_SET_AUTOFOCUSTUNING, /* 80 */ + CAM_INTF_PARM_GET_AFTUNE, + CAM_INTF_PARM_SET_RELOAD_AFTUNE, + CAM_INTF_PARM_SET_VFE_COMMAND, + CAM_INTF_PARM_SET_PP_COMMAND, + CAM_INTF_PARM_TINTLESS, + CAM_INTF_PARM_LONGSHOT_ENABLE, + CAM_INTF_PARM_RDI_MODE, + CAM_INTF_PARM_CDS_MODE, + CAM_INTF_PARM_TONE_MAP_MODE, + CAM_INTF_PARM_CAPTURE_FRAME_CONFIG, /* 90 */ + CAM_INTF_PARM_DUAL_LED_CALIBRATION, + CAM_INTF_PARM_ADV_CAPTURE_MODE, + + /* stream based parameters */ + CAM_INTF_PARM_DO_REPROCESS, + CAM_INTF_PARM_SET_BUNDLE, + CAM_INTF_PARM_STREAM_FLIP, + CAM_INTF_PARM_GET_OUTPUT_CROP, + + CAM_INTF_PARM_EZTUNE_CMD, + CAM_INTF_PARM_INT_EVT, + + /* specific to HAL3 */ + /* Whether the metadata maps to a valid frame number */ + CAM_INTF_META_FRAME_NUMBER_VALID, + /* Whether the urgent metadata maps to a valid frame number */ + CAM_INTF_META_URGENT_FRAME_NUMBER_VALID, + /* Whether the stream buffer corresponding this frame is dropped or not */ + CAM_INTF_META_FRAME_DROPPED, /* 100 */ + /* COLOR CORRECTION.*/ + CAM_INTF_META_COLOR_CORRECT_MODE, + /* A transform matrix to chromatically adapt pixels in the CIE XYZ (1931) + * color space from the scene illuminant to the sRGB-standard D65-illuminant. */ + CAM_INTF_META_COLOR_CORRECT_TRANSFORM, + /*Color channel gains in the Bayer raw domain in the order [RGeGoB]*/ + CAM_INTF_META_COLOR_CORRECT_GAINS, + /*The best fit color transform matrix calculated by the stats*/ + CAM_INTF_META_PRED_COLOR_CORRECT_TRANSFORM, + /*The best fit color channels gains calculated by the stats*/ + CAM_INTF_META_PRED_COLOR_CORRECT_GAINS, + /* CONTROL */ + /* A frame counter set by the framework. Must be maintained unchanged in + * output frame. */ + CAM_INTF_META_FRAME_NUMBER, + /* A frame counter set by the framework. Must be maintained unchanged in + * output frame. */ + CAM_INTF_META_URGENT_FRAME_NUMBER, + /*Number of streams and size of streams in current configuration*/ + CAM_INTF_META_STREAM_INFO, + /* List of areas to use for metering */ + CAM_INTF_META_AEC_ROI, + /* Whether the HAL must trigger precapture metering.*/ + CAM_INTF_META_AEC_PRECAPTURE_TRIGGER, /* 110 */ + /* The ID sent with the latest CAMERA2_TRIGGER_PRECAPTURE_METERING call */ + /* Current state of AE algorithm */ + CAM_INTF_META_AEC_STATE, + /* List of areas to use for focus estimation */ + CAM_INTF_META_AF_ROI, + /* Whether the HAL must trigger autofocus. */ + CAM_INTF_META_AF_TRIGGER, + /* Current state of AF algorithm */ + CAM_INTF_META_AF_STATE, + /* List of areas to use for illuminant estimation */ + CAM_INTF_META_AWB_REGIONS, + /* Current state of AWB algorithm */ + CAM_INTF_META_AWB_STATE, + /*Whether black level compensation is frozen or free to vary*/ + CAM_INTF_META_BLACK_LEVEL_LOCK, + /* Information to 3A routines about the purpose of this capture, to help + * decide optimal 3A strategy */ + CAM_INTF_META_CAPTURE_INTENT, + /* DEMOSAIC */ + /* Controls the quality of the demosaicing processing */ + CAM_INTF_META_DEMOSAIC, + /* EDGE */ + /* Operation mode for edge enhancement */ + CAM_INTF_META_EDGE_MODE, /* 120 */ + /* Control the amount of edge enhancement applied to the images.*/ + /* 1-10; 10 is maximum sharpening */ + CAM_INTF_META_SHARPNESS_STRENGTH, + /* FLASH */ + /* Power for flash firing/torch, 10 is max power; 0 is no flash. Linear */ + CAM_INTF_META_FLASH_POWER, + /* Firing time of flash relative to start of exposure, in nanoseconds*/ + CAM_INTF_META_FLASH_FIRING_TIME, + /* Current state of the flash unit */ + CAM_INTF_META_FLASH_STATE, + /* GEOMETRIC */ + /* Operating mode of geometric correction */ + CAM_INTF_META_GEOMETRIC_MODE, + /* Control the amount of shading correction applied to the images */ + CAM_INTF_META_GEOMETRIC_STRENGTH, + /* HOT PIXEL */ + /* Set operational mode for hot pixel correction */ + CAM_INTF_META_HOTPIXEL_MODE, + /* LENS */ + /* Size of the lens aperture */ + CAM_INTF_META_LENS_APERTURE, + /* State of lens neutral density filter(s) */ + CAM_INTF_META_LENS_FILTERDENSITY, + /* Lens optical zoom setting */ + CAM_INTF_META_LENS_FOCAL_LENGTH, /* 130 */ + /* Distance to plane of sharpest focus, measured from frontmost surface + * of the lens */ + CAM_INTF_META_LENS_FOCUS_DISTANCE, + /* The range of scene distances that are in sharp focus (depth of field) */ + CAM_INTF_META_LENS_FOCUS_RANGE, + /*Whether the hal needs to output the lens shading map*/ + CAM_INTF_META_LENS_SHADING_MAP_MODE, + /* Current lens status */ + CAM_INTF_META_LENS_STATE, + /* NOISE REDUCTION */ + /* Mode of operation for the noise reduction algorithm */ + CAM_INTF_META_NOISE_REDUCTION_MODE, + /* Control the amount of noise reduction applied to the images. + * 1-10; 10 is max noise reduction */ + CAM_INTF_META_NOISE_REDUCTION_STRENGTH, + /* SCALER */ + /* Top-left corner and width of the output region to select from the active + * pixel array */ + CAM_INTF_META_SCALER_CROP_REGION, + /* The estimated scene illumination lighting frequency */ + CAM_INTF_META_SCENE_FLICKER, + /* SENSOR */ + /* Duration each pixel is exposed to light, in nanoseconds */ + CAM_INTF_META_SENSOR_EXPOSURE_TIME, + /* Duration from start of frame exposure to start of next frame exposure, + * in nanoseconds */ + CAM_INTF_META_SENSOR_FRAME_DURATION, /* 140 */ + /* Gain applied to image data. Must be implemented through analog gain only + * if set to values below 'maximum analog sensitivity'. */ + CAM_INTF_META_SENSOR_SENSITIVITY, + /* Time at start of exposure of first row */ + CAM_INTF_META_SENSOR_TIMESTAMP, + /* Duration b/w start of first row exposure and the start of last + row exposure in nanoseconds */ + CAM_INTF_META_SENSOR_ROLLING_SHUTTER_SKEW, + /* SHADING */ + /* Quality of lens shading correction applied to the image data */ + CAM_INTF_META_SHADING_MODE, + /* Control the amount of shading correction applied to the images. + * unitless: 1-10; 10 is full shading compensation */ + CAM_INTF_META_SHADING_STRENGTH, + /* STATISTICS */ + /* State of the face detector unit */ + CAM_INTF_META_STATS_FACEDETECT_MODE, + /* Operating mode for histogram generation */ + CAM_INTF_META_STATS_HISTOGRAM_MODE, + /* Operating mode for sharpness map generation */ + CAM_INTF_META_STATS_SHARPNESS_MAP_MODE, + /* A 3-channel sharpness map, based on the raw sensor data, + * If only a monochrome sharpness map is supported, all channels + * should have the same data + */ + CAM_INTF_META_STATS_SHARPNESS_MAP, + + /* TONEMAP */ + /* Tone map mode */ + CAM_INTF_META_TONEMAP_MODE, /* 150 */ + /* Table mapping RGB input values to output values */ + CAM_INTF_META_TONEMAP_CURVES, + + CAM_INTF_META_FLASH_MODE, + /* 2D array of gain factors for each color channel that was used to + * compensate for lens shading for this frame */ + CAM_INTF_META_LENS_SHADING_MAP, + CAM_INTF_META_PRIVATE_DATA, + CAM_INTF_PARM_STATS_DEBUG_MASK, + CAM_INTF_PARM_STATS_AF_PAAF, + /* Indicates streams ID of all the requested buffers */ + CAM_INTF_META_STREAM_ID, + CAM_INTF_PARM_FOCUS_BRACKETING, + CAM_INTF_PARM_FLASH_BRACKETING, + CAM_INTF_PARM_GET_IMG_PROP, /* 160 */ + CAM_INTF_META_JPEG_GPS_COORDINATES, + CAM_INTF_META_JPEG_GPS_PROC_METHODS, + CAM_INTF_META_JPEG_GPS_TIMESTAMP, + CAM_INTF_META_JPEG_ORIENTATION, + CAM_INTF_META_JPEG_QUALITY, + CAM_INTF_META_JPEG_THUMB_QUALITY, + CAM_INTF_META_JPEG_THUMB_SIZE, + + CAM_INTF_META_TEST_PATTERN_DATA, + /* DNG file support */ + CAM_INTF_META_PROFILE_TONE_CURVE, + CAM_INTF_META_NEUTRAL_COL_POINT, /* 170 */ + + /* CAC */ + CAM_INTF_META_CAC_INFO, + CAM_INTF_PARM_CAC, + CAM_INTF_META_IMG_HYST_INFO, + + /* trigger for all modules to read the debug/log level properties */ + CAM_INTF_PARM_UPDATE_DEBUG_LEVEL, + + /* OTP : WB gr/gb */ + CAM_INTF_META_OTP_WB_GRGB, + /* LED override for EZTUNE */ + CAM_INTF_META_LED_MODE_OVERRIDE, + /* auto lens position info */ + CAM_INTF_META_FOCUS_POSITION, + /* Manual exposure time */ + CAM_INTF_PARM_EXPOSURE_TIME, + /* AWB meta data info */ + CAM_INTF_META_AWB_INFO, + /* Manual lens position info */ + CAM_INTF_PARM_MANUAL_FOCUS_POS, /* 180 */ + /* Manual White balance gains */ + CAM_INTF_PARM_WB_MANUAL, + /* Offline Data Overwrite */ + CAM_INTF_PARM_HW_DATA_OVERWRITE, + /* IMG LIB reprocess debug section */ + CAM_INTF_META_IMGLIB, /* cam_intf_meta_imglib_t */ + /* OEM specific parameters */ + CAM_INTF_PARM_CUSTOM, + /* parameters added for related cameras */ + /* fetch calibration info for related cam subsystem */ + CAM_INTF_PARM_RELATED_SENSORS_CALIBRATION, + /* focal length ratio info */ + CAM_INTF_META_AF_FOCAL_LENGTH_RATIO, + /* crop for binning & FOV adjust */ + CAM_INTF_META_SNAP_CROP_INFO_SENSOR, + /* crop for trimming edge pixels */ + CAM_INTF_META_SNAP_CROP_INFO_CAMIF, + /* crop for FOV adjust and zoom */ + CAM_INTF_META_SNAP_CROP_INFO_ISP, + /* crop for image-stabilization and zoom */ + CAM_INTF_META_SNAP_CROP_INFO_CPP, /* 190 */ + /* parameter for enabling DCRF */ + CAM_INTF_PARM_DCRF, + /* metadata tag for DCRF info */ + CAM_INTF_META_DCRF, + /* FLIP mode parameter*/ + CAM_INTF_PARM_FLIP, + /*Frame divert info from ISP*/ + CAM_INTF_BUF_DIVERT_INFO, + /* Use AV timer */ + CAM_INTF_META_USE_AV_TIMER, + CAM_INTF_META_EFFECTIVE_EXPOSURE_FACTOR, + /* Special event to request stream frames*/ + CAM_INTF_PARM_REQUEST_FRAMES, + /* Special event to request operational mode*/ + CAM_INTF_PARM_REQUEST_OPS_MODE, + /*Black level parameters*/ + CAM_INTF_META_LDAF_EXIF, + CAM_INTF_META_BLACK_LEVEL_SOURCE_PATTERN, + CAM_INTF_META_BLACK_LEVEL_APPLIED_PATTERN, /* 200 */ + CAM_INTF_META_CDS_DATA, + /*3A low light level information*/ + CAM_INTF_META_LOW_LIGHT, + /* dynamic feature detection */ + CAM_INTF_META_IMG_DYN_FEAT, /* 200 */ + /*Parameter entry to communicate manual + capture type*/ + CAM_INTF_PARM_MANUAL_CAPTURE_TYPE, + /*AF state change detected by AF module*/ + CAM_INTF_AF_STATE_TRANSITION, + /* face recognition */ + CAM_INTF_META_FACE_RECOG, + /* face blink detection */ + CAM_INTF_META_FACE_BLINK, + /* face gaze detection */ + CAM_INTF_META_FACE_GAZE, + /* face smile detection */ + CAM_INTF_META_FACE_SMILE, + /* face landmark detection */ + CAM_INTF_META_FACE_LANDMARK, /* 210 */ + /* face contour detection */ + CAM_INTF_META_FACE_CONTOUR, + /* Whether EIS is enabled */ + CAM_INTF_META_VIDEO_STAB_MODE, + /* Touch exposure compensation (EV) status */ + CAM_INTF_META_TOUCH_AE_RESULT, + /* Param for updating initial exposure index value*/ + CAM_INTF_PARM_INITIAL_EXPOSURE_INDEX, + /* Gain applied post raw captrue. + ISP digital gain */ + CAM_INTF_META_ISP_SENSITIVITY, + /* Param for enabling instant aec*/ + CAM_INTF_PARM_INSTANT_AEC, + /* Param for tracking previous reprocessing activity */ + CAM_INTF_META_REPROCESS_FLAGS, + /* Param of cropping information for JPEG encoder */ + CAM_INTF_PARM_JPEG_ENCODE_CROP, + /* Param of scaling information for JPEG encoder */ + CAM_INTF_PARM_JPEG_SCALE_DIMENSION, + /*Param for updating Quadra CFA mode */ + CAM_INTF_PARM_QUADRA_CFA, + CAM_INTF_PARM_MAX +} cam_intf_parm_type_t; + +typedef struct { + uint32_t forced; + union { + uint32_t force_linecount_value; + float force_gain_value; + float force_snap_exp_value; + float force_exp_value; + uint32_t force_snap_linecount_value; + float force_snap_gain_value; + } u; +} cam_ez_force_params_t; + +typedef struct { + float cam_black_level[4]; +} cam_black_level_metadata_t; + +typedef enum { + CAM_EZTUNE_CMD_STATUS, + CAM_EZTUNE_CMD_AEC_ENABLE, + CAM_EZTUNE_CMD_AWB_ENABLE, + CAM_EZTUNE_CMD_AF_ENABLE, + CAM_EZTUNE_CMD_AEC_FORCE_LINECOUNT, + CAM_EZTUNE_CMD_AEC_FORCE_GAIN, + CAM_EZTUNE_CMD_AEC_FORCE_EXP, + CAM_EZTUNE_CMD_AEC_FORCE_SNAP_LC, + CAM_EZTUNE_CMD_AEC_FORCE_SNAP_GAIN, + CAM_EZTUNE_CMD_AEC_FORCE_SNAP_EXP, + CAM_EZTUNE_CMD_AWB_MODE, + CAM_EZTUNE_CMD_AWB_FORCE_DUAL_LED_IDX, +} cam_eztune_cmd_type_t; + +typedef struct { + cam_eztune_cmd_type_t cmd; + union { + int32_t running; + int32_t aec_enable; + int32_t awb_enable; + int32_t af_enable; + cam_ez_force_params_t ez_force_param; + int32_t awb_mode; + int32_t ez_force_dual_led_idx; + } u; +} cam_eztune_cmd_data_t; + + +/***************************************************************************** + * Code for HAL3 data types * + ****************************************************************************/ +typedef enum { + CAM_INTF_METADATA_MAX +} cam_intf_metadata_type_t; + +typedef enum { + CAM_INTENT_CUSTOM, + CAM_INTENT_PREVIEW, + CAM_INTENT_STILL_CAPTURE, + CAM_INTENT_VIDEO_RECORD, + CAM_INTENT_VIDEO_SNAPSHOT, + CAM_INTENT_ZERO_SHUTTER_LAG, + CAM_INTENT_MAX, +} cam_intent_t; + +typedef enum { + /* Full application control of pipeline. All 3A routines are disabled, + * no other settings in android.control.* have any effect */ + CAM_CONTROL_OFF, + /* Use settings for each individual 3A routine. Manual control of capture + * parameters is disabled. All controls in android.control.* besides sceneMode + * take effect */ + CAM_CONTROL_AUTO, + /* Use specific scene mode. Enabling this disables control.aeMode, + * control.awbMode and control.afMode controls; the HAL must ignore those + * settings while USE_SCENE_MODE is active (except for FACE_PRIORITY scene mode). + * Other control entries are still active. This setting can only be used if + * availableSceneModes != UNSUPPORTED. TODO: Should we remove this and handle this + * in HAL ?*/ + CAM_CONTROL_USE_SCENE_MODE, + CAM_CONTROL_MAX +} cam_control_mode_t; + +typedef enum { + /* Use the android.colorCorrection.transform matrix to do color conversion */ + CAM_COLOR_CORRECTION_TRANSFORM_MATRIX, + /* Must not slow down frame rate relative to raw bayer output */ + CAM_COLOR_CORRECTION_FAST, + /* Frame rate may be reduced by high quality */ + CAM_COLOR_CORRECTION_HIGH_QUALITY, +} cam_color_correct_mode_t; + +typedef enum { + CAM_COLOR_CORRECTION_ABERRATION_OFF, + CAM_COLOR_CORRECTION_ABERRATION_FAST, + CAM_COLOR_CORRECTION_ABERRATION_HIGH_QUALITY, + CAM_COLOR_CORRECTION_ABERRATION_MAX +} cam_aberration_mode_t; + +#define CC_MATRIX_ROWS 3 +#define CC_MATRIX_COLS 3 + +typedef struct { + /* 3x3 float matrix in row-major order. each element is in range of (0, 1) */ + cam_rational_type_t transform_matrix[CC_MATRIX_ROWS][CC_MATRIX_COLS]; +} cam_color_correct_matrix_t; + +#define CAM_FOCAL_LENGTHS_MAX 1 +#define CAM_APERTURES_MAX 1 +#define CAM_FILTER_DENSITIES_MAX 1 +#define CAM_MAX_MAP_HEIGHT 6 +#define CAM_MAX_MAP_WIDTH 6 +#define CAM_MAX_SHADING_MAP_WIDTH 17 +#define CAM_MAX_SHADING_MAP_HEIGHT 13 +#define CAM_MAX_TONEMAP_CURVE_SIZE 512 +#define CAM_MAX_FLASH_BRACKETING 5 + +typedef struct { + /* A 1D array of pairs of floats. + * Mapping a 0-1 input range to a 0-1 output range. + * The input range must be monotonically increasing with N, + * and values between entries should be linearly interpolated. + * For example, if the array is: [0.0, 0.0, 0.3, 0.5, 1.0, 1.0], + * then the input->output mapping for a few sample points would be: + * 0 -> 0, 0.15 -> 0.25, 0.3 -> 0.5, 0.5 -> 0.64 */ + float tonemap_points[CAM_MAX_TONEMAP_CURVE_SIZE][2]; +} cam_tonemap_curve_t; + +typedef struct { + size_t tonemap_points_cnt; + cam_tonemap_curve_t curves[3]; +} cam_rgb_tonemap_curves; + +typedef struct { + size_t tonemap_points_cnt; + cam_tonemap_curve_t curve; +} cam_profile_tone_curve; + +#define NEUTRAL_COL_POINTS 3 + +typedef struct { + cam_rational_type_t neutral_col_point[NEUTRAL_COL_POINTS]; +} cam_neutral_col_point_t; + +typedef enum { + OFF, + FAST, + QUALITY, +} cam_quality_preference_t; + +typedef enum { + CAM_FLASH_CTRL_OFF, + CAM_FLASH_CTRL_SINGLE, + CAM_FLASH_CTRL_TORCH +} cam_flash_ctrl_t; + +typedef struct { + uint8_t frame_dropped; /* This flag indicates whether any stream buffer is dropped or not */ + cam_stream_ID_t cam_stream_ID; /* if dropped, Stream ID of dropped streams */ +} cam_frame_dropped_t; + +typedef struct { + uint8_t ae_mode; + uint8_t awb_mode; + uint8_t af_mode; +} cam_scene_mode_overrides_t; + +typedef struct { + int32_t left; + int32_t top; + int32_t width; + int32_t height; +} cam_crop_region_t; + +typedef struct { + /* Estimated sharpness for each region of the input image. + * Normalized to be between 0 and maxSharpnessMapValue. + * Higher values mean sharper (better focused) */ + int32_t sharpness[CAM_MAX_MAP_WIDTH][CAM_MAX_MAP_HEIGHT]; +} cam_sharpness_map_t; + +typedef struct { + float lens_shading[4*CAM_MAX_SHADING_MAP_HEIGHT*CAM_MAX_SHADING_MAP_WIDTH]; +} cam_lens_shading_map_t; + +typedef struct { + int32_t min_value; + int32_t max_value; + int32_t def_value; + int32_t step; +} cam_control_range_t; + +#define CAM_QCOM_FEATURE_NONE (cam_feature_mask_t)0UL +#define CAM_QCOM_FEATURE_FACE_DETECTION ((cam_feature_mask_t)1UL<<0) +#define CAM_QCOM_FEATURE_DENOISE2D ((cam_feature_mask_t)1UL<<1) +#define CAM_QCOM_FEATURE_CROP ((cam_feature_mask_t)1UL<<2) +#define CAM_QCOM_FEATURE_ROTATION ((cam_feature_mask_t)1UL<<3) +#define CAM_QCOM_FEATURE_FLIP ((cam_feature_mask_t)1UL<<4) +#define CAM_QCOM_FEATURE_HDR ((cam_feature_mask_t)1UL<<5) +#define CAM_QCOM_FEATURE_REGISTER_FACE ((cam_feature_mask_t)1UL<<6) +#define CAM_QCOM_FEATURE_SHARPNESS ((cam_feature_mask_t)1UL<<7) +#define CAM_QCOM_FEATURE_VIDEO_HDR ((cam_feature_mask_t)1UL<<8) +#define CAM_QCOM_FEATURE_CAC ((cam_feature_mask_t)1UL<<9) +#define CAM_QCOM_FEATURE_SCALE ((cam_feature_mask_t)1UL<<10) +#define CAM_QCOM_FEATURE_EFFECT ((cam_feature_mask_t)1UL<<11) +#define CAM_QCOM_FEATURE_UBIFOCUS ((cam_feature_mask_t)1UL<<12) +#define CAM_QCOM_FEATURE_CHROMA_FLASH ((cam_feature_mask_t)1UL<<13) +#define CAM_QCOM_FEATURE_OPTIZOOM ((cam_feature_mask_t)1UL<<14) +#define CAM_QCOM_FEATURE_SENSOR_HDR ((cam_feature_mask_t)1UL<<15) +#define CAM_QCOM_FEATURE_REFOCUS ((cam_feature_mask_t)1UL<<16) +#define CAM_QCOM_FEATURE_CPP_TNR ((cam_feature_mask_t)1UL<<17) +#define CAM_QCOM_FEATURE_RAW_PROCESSING ((cam_feature_mask_t)1UL<<18) +#define CAM_QCOM_FEATURE_TRUEPORTRAIT ((cam_feature_mask_t)1UL<<19) +#define CAM_QCOM_FEATURE_LLVD ((cam_feature_mask_t)1UL<<20) +#define CAM_QCOM_FEATURE_DIS20 ((cam_feature_mask_t)1UL<<21) +#define CAM_QCOM_FEATURE_STILLMORE ((cam_feature_mask_t)1UL<<22) +#define CAM_QCOM_FEATURE_DCRF ((cam_feature_mask_t)1UL<<23) +#define CAM_QCOM_FEATURE_CDS ((cam_feature_mask_t)1UL<<24) +#define CAM_QCOM_FEATURE_EZTUNE ((cam_feature_mask_t)1UL<<25) +#define CAM_QCOM_FEATURE_DSDN ((cam_feature_mask_t)1UL<<26) //Special CDS in CPP block +#define CAM_QCOM_FEATURE_SW2D ((cam_feature_mask_t)1UL<<27) +#define CAM_OEM_FEATURE_1 ((cam_feature_mask_t)1UL<<28) +#define CAM_OEM_FEATURE_2 ((cam_feature_mask_t)1UL<<29) +#define CAM_QTI_FEATURE_SW_TNR ((cam_feature_mask_t)1UL<<30) +#define CAM_QCOM_FEATURE_METADATA_PROCESSING ((cam_feature_mask_t)1UL<<31) +#define CAM_QCOM_FEATURE_PAAF (((cam_feature_mask_t)1UL)<<32) +#define CAM_QCOM_FEATURE_QUADRA_CFA (((cam_feature_mask_t)1UL)<<33) +#define CAM_QCOM_FEATURE_PP_SUPERSET (CAM_QCOM_FEATURE_DENOISE2D|CAM_QCOM_FEATURE_CROP|\ + CAM_QCOM_FEATURE_ROTATION|CAM_QCOM_FEATURE_SHARPNESS|\ + CAM_QCOM_FEATURE_SCALE|CAM_QCOM_FEATURE_CAC|\ + CAM_QCOM_FEATURE_EZTUNE|CAM_QCOM_FEATURE_CPP_TNR|\ + CAM_QCOM_FEATURE_LLVD|CAM_QCOM_FEATURE_QUADRA_CFA) + +#define CAM_QCOM_FEATURE_PP_PASS_1 CAM_QCOM_FEATURE_PP_SUPERSET +#define CAM_QCOM_FEATURE_PP_PASS_2 CAM_QCOM_FEATURE_SCALE | CAM_QCOM_FEATURE_CROP; + +// Counter clock wise +typedef enum { + ROTATE_0 = 1<<0, + ROTATE_90 = 1<<1, + ROTATE_180 = 1<<2, + ROTATE_270 = 1<<3, +} cam_rotation_t; + +typedef struct { + cam_rotation_t rotation; /* jpeg rotation */ + cam_rotation_t device_rotation; /* device rotation */ + uint32_t streamId; +} cam_rotation_info_t; + +typedef enum { + FLIP_NONE = 0, /* 00b */ + FLIP_H = 1, /* 01b */ + FLIP_V = 2, /* 10b */ + FLIP_V_H = 3, /* 11b */ +} cam_flip_t; + +typedef struct { + uint32_t bundle_id; /* bundle id */ + uint8_t num_of_streams; /* number of streams in the bundle */ + uint32_t stream_ids[MAX_STREAM_NUM_IN_BUNDLE]; /* array of stream ids to be bundled */ +} cam_bundle_config_t; + +typedef enum { + CAM_ONLINE_REPROCESS_TYPE, /* online reprocess, frames from running streams */ + CAM_OFFLINE_REPROCESS_TYPE, /* offline reprocess, frames from external source */ +} cam_reprocess_type_enum_t; + +typedef struct { + uint8_t burst_count; + uint8_t min_burst_count; + uint8_t max_burst_count; +} cam_still_more_t; + +typedef struct { + uint8_t burst_count; + uint8_t output_count; + uint8_t flash_bracketing[CAM_MAX_FLASH_BRACKETING]; + uint8_t metadata_index; +} cam_chroma_flash_t; + +typedef enum { + CAM_HDR_MODE_SINGLEFRAME, /* Single frame HDR mode which does only tone mapping */ + CAM_HDR_MODE_MULTIFRAME, /* Multi frame HDR mode which needs two frames with 0.5x and 2x exposure respectively */ +} cam_hdr_mode_enum_t; + +typedef struct { + uint32_t hdr_enable; + uint32_t hdr_need_1x; /* when CAM_QCOM_FEATURE_HDR enabled, indicate if 1x is needed for output */ + cam_hdr_mode_enum_t hdr_mode; +} cam_hdr_param_t; + +typedef struct { + int32_t output_width; + int32_t output_height; +} cam_scale_param_t; + +typedef struct { + uint8_t enable; + uint8_t burst_count; + uint8_t focus_steps[MAX_AF_BRACKETING_VALUES]; + uint8_t output_count; + uint32_t meta_max_size; +} cam_af_bracketing_t; + +typedef struct { + uint8_t enable; + uint8_t burst_count; +} cam_flash_bracketing_t; + +typedef struct { + uint8_t enable; + uint8_t burst_count; + uint8_t zoom_threshold; +} cam_opti_zoom_t; + +typedef struct { + size_t meta_max_size; +} cam_true_portrait_t; + +typedef enum { + CAM_FLASH_OFF, + CAM_FLASH_ON +} cam_flash_value_t; + +typedef struct { + cam_sensor_t sens_type; + cam_format_t native_format; +} cam_sensor_type_t; + +typedef struct { + uint32_t result; + uint32_t header_size; + uint32_t width; + uint32_t height; + uint8_t data[0]; +} cam_misc_buf_t; + +typedef struct { + uint32_t misc_buffer_index; +} cam_misc_buf_param_t; + +typedef struct { + /* reprocess feature mask */ + cam_feature_mask_t feature_mask; + + /* individual setting for features to be reprocessed */ + cam_denoise_param_t denoise2d; + cam_rect_t input_crop; + cam_rotation_t rotation; + uint32_t flip; + int32_t sharpness; + int32_t effect; + cam_hdr_param_t hdr_param; + cam_scale_param_t scale_param; + + uint8_t zoom_level; + cam_flash_value_t flash_value; + cam_misc_buf_param_t misc_buf_param; + uint32_t burst_cnt; + uint8_t cur_reproc_count; + uint8_t total_reproc_count; +} cam_pp_feature_config_t; + +typedef struct { + uint32_t input_stream_id; + /* input source stream type */ + cam_stream_type_t input_stream_type; +} cam_pp_online_src_config_t; + +typedef struct { + /* image format */ + cam_format_t input_fmt; + + /* image dimension */ + cam_dimension_t input_dim; + + /* buffer plane information, will be calc based on stream_type, fmt, + dim, and padding_info(from stream config). Info including: + offset_x, offset_y, stride, scanline, plane offset */ + cam_stream_buf_plane_info_t input_buf_planes; + + /* number of input reprocess buffers */ + uint8_t num_of_bufs; + + /* input source type */ + cam_stream_type_t input_type; + +} cam_pp_offline_src_config_t; + +/* reprocess stream input configuration */ +typedef struct { + /* input source config */ + cam_reprocess_type_enum_t pp_type; + union { + cam_pp_online_src_config_t online; + cam_pp_offline_src_config_t offline; + }; + + /* pp feature config */ + cam_pp_feature_config_t pp_feature_config; +} cam_stream_reproc_config_t; + +typedef struct { + uint8_t crop_enabled; + cam_rect_t input_crop; +} cam_crop_param_t; + +typedef struct { + uint8_t trigger; + int32_t trigger_id; +} cam_trigger_t; + +typedef struct { + cam_denoise_param_t denoise2d; + cam_crop_param_t crop; + uint32_t flip; /* 0 means no flip */ + uint32_t uv_upsample; /* 0 means no chroma upsampling */ + int32_t sharpness; /* 0 means no sharpness */ + int32_t effect; + cam_rotation_t rotation; + cam_rotation_t device_rotation; +} cam_per_frame_pp_config_t; + +typedef enum { + CAM_OPT_STAB_OFF, + CAM_OPT_STAB_ON, + CAM_OPT_STAB_MAX +} cam_optical_stab_modes_t; + +typedef enum { + CAM_FILTER_ARRANGEMENT_RGGB, + CAM_FILTER_ARRANGEMENT_GRBG, + CAM_FILTER_ARRANGEMENT_GBRG, + CAM_FILTER_ARRANGEMENT_BGGR, + + /* Sensor is not Bayer; output has 3 16-bit values for each pixel, + * instead of just 1 16-bit value per pixel.*/ + CAM_FILTER_ARRANGEMENT_RGB, + /* Sensor is YUV; SW do not have access to actual RAW, + * output is interleaved UYVY */ + CAM_FILTER_ARRANGEMENT_UYVY, + CAM_FILTER_ARRANGEMENT_YUYV, + CAM_FILTER_ARRANGEMENT_Y +} cam_color_filter_arrangement_t; + +typedef enum { + CAM_AF_LENS_STATE_STATIONARY, + CAM_AF_LENS_STATE_MOVING, +} cam_af_lens_state_t; + +typedef enum { + CAM_AWB_STATE_INACTIVE, + CAM_AWB_STATE_SEARCHING, + CAM_AWB_STATE_CONVERGED, + CAM_AWB_STATE_LOCKED +} cam_awb_state_t; + +typedef enum { + CAM_FOCUS_UNCALIBRATED, + CAM_FOCUS_APPROXIMATE, + CAM_FOCUS_CALIBRATED +} cam_focus_calibration_t; + +typedef enum { + CAM_TEST_PATTERN_OFF, + CAM_TEST_PATTERN_SOLID_COLOR, + CAM_TEST_PATTERN_COLOR_BARS, + CAM_TEST_PATTERN_COLOR_BARS_FADE_TO_GRAY, + CAM_TEST_PATTERN_PN9, + CAM_TEST_PATTERN_CUSTOM1 = 256 +} cam_test_pattern_mode_t; + +typedef struct { + cam_test_pattern_mode_t mode; + int32_t r; + int32_t gr; + int32_t gb; + int32_t b; +} cam_test_pattern_data_t; + +typedef enum { + CAM_AWB_D50, + CAM_AWB_D65, + CAM_AWB_D75, + CAM_AWB_A, + CAM_AWB_CUSTOM_A, + CAM_AWB_WARM_FLO, + CAM_AWB_COLD_FLO, + CAM_AWB_CUSTOM_FLO, + CAM_AWB_NOON, + CAM_AWB_CUSTOM_DAYLIGHT, + CAM_AWB_INVALID_ALL_LIGHT, +} cam_illuminat_t; + +typedef enum { + LEGACY_RAW, + MIPI_RAW, +} cam_opaque_raw_format_t; + +typedef enum { + CAM_PERF_NORMAL = 0, + CAM_PERF_HIGH, + CAM_PERF_HIGH_PERFORMANCE, +} cam_perf_mode_t; + +typedef struct { + float real_gain; + float lux_idx; + float exp_time; +} cam_intf_aec_t; + +#define CAM_INTF_AEC_DATA_MAX (10) + +typedef struct { + uint32_t frame_count; + cam_intf_aec_t aec_data[CAM_INTF_AEC_DATA_MAX]; +} cam_intf_meta_imglib_input_aec_t; + +typedef struct { + cam_intf_meta_imglib_input_aec_t meta_imglib_input_aec; +} cam_intf_meta_imglib_t; + +typedef struct { + uint8_t previewOnly; + uint64_t value; +} cam_intf_parm_manual_3a_t; + +typedef enum { + CAM_MANUAL_CAPTURE_TYPE_OFF, /*Manual capture mode disabled*/ + CAM_MANUAL_CAPTURE_TYPE_1, /*Normal ZSL capture with limited 3A settings*/ + CAM_MANUAL_CAPTURE_TYPE_2, /*Low light capture mode */ + CAM_MANUAL_CAPTURE_TYPE_3, /*Offline RAW processing */ + CAM_MANUAL_CAPTURE_TYPE_4 /*Offline RAW processing with multiple RAW*/ +} cam_manual_capture_type; + +typedef enum { + CAM_ANALYSIS_INFO_FD_STILL, /*Analysis requirements for STILL PREVIEW*/ + CAM_ANALYSIS_INFO_FD_VIDEO, /*Analysis requirements for VIDEO*/ + CAM_ANALYSIS_INFO_PAAF, /*Analysis requirements for PAAF*/ + CAM_ANALYSIS_INFO_MAX, /*Max number*/ +} cam_analysis_info_type; + +typedef struct { + /* Whether the information here is valid or not */ + uint8_t valid; + + /* Whether analysis supported by hw */ + uint8_t hw_analysis_supported; + + /* Analysis stream max supported size */ + cam_dimension_t analysis_max_res; + + /* Analysis stream padding info */ + cam_padding_info_t analysis_padding_info; + + /* Analysis format */ + cam_format_t analysis_format; + + /* Analysis recommended size */ + cam_dimension_t analysis_recommended_res; +} cam_analysis_info_t; + +typedef struct { + /* Information for DDM metadata*/ + cam_stream_crop_info_t sensor_crop_info; /* sensor crop info */ + cam_stream_crop_info_t camif_crop_info; /* CAMIF crop info */ + cam_stream_crop_info_t isp_crop_info; /* ISP crop info */ + cam_stream_crop_info_t cpp_crop_info; /* CPP crop info */ + cam_focal_length_ratio_t af_focal_length_ratio; /* AF focal length ratio */ + int32_t pipeline_flip; /* current pipeline flip and rotational parameters */ + cam_rotation_info_t rotation_info; /* rotation information */ + cam_area_t af_roi; /* AF roi info */ + /* Information for CPP reprocess */ + cam_dyn_img_data_t dyn_mask; /* Post processing dynamic feature mask */ +} cam_reprocess_info_t; + +/*********************************** +* ENUM definition for custom parameter type +************************************/ +typedef enum { + CAM_CUSTOM_PARM_EXAMPLE, + CAM_CUSTOM_PARM_MAX, +} cam_custom_parm_type; + +#endif /* __QCAMERA_TYPES_H__ */ diff --git a/camera/QCamera2/stack/common/mm_camera_interface.h b/camera/QCamera2/stack/common/mm_camera_interface.h new file mode 100644 index 0000000..40bd6d3 --- /dev/null +++ b/camera/QCamera2/stack/common/mm_camera_interface.h @@ -0,0 +1,923 @@ +/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __MM_CAMERA_INTERFACE_H__ +#define __MM_CAMERA_INTERFACE_H__ + +// System dependencies +#include + +// Camera dependencies +#include "cam_intf.h" +#include "cam_queue.h" + +#define MM_CAMERA_MAX_NUM_SENSORS MSM_MAX_CAMERA_SENSORS +#define MM_CAMERA_MAX_NUM_FRAMES CAM_MAX_NUM_BUFS_PER_STREAM +/* num of channels allowed in a camera obj */ +#define MM_CAMERA_CHANNEL_MAX 16 + +#define PAD_TO_SIZE(size, padding) \ + ((size + (typeof(size))(padding - 1)) & \ + (typeof(size))(~(padding - 1))) + +#define CEIL_DIVISION(n, d) ((n+d-1)/d) + +/** CAM_DUMP_TO_FILE: + * @filename: file name + * @name:filename + * @index: index of the file + * @extn: file extension + * @p_addr: address of the buffer + * @len: buffer length + * + * dump the image to the file + **/ +#define CAM_DUMP_TO_FILE(path, name, index, extn, p_addr, len) ({ \ + size_t rc = 0; \ + char filename[FILENAME_MAX]; \ + if (index >= 0) \ + snprintf(filename, FILENAME_MAX, "%s/%s%d.%s", path, name, index, extn); \ + else \ + snprintf(filename, FILENAME_MAX, "%s/%s.%s", path, name, extn); \ + FILE *fp = fopen(filename, "w+"); \ + if (fp) { \ + rc = fwrite(p_addr, 1, len, fp); \ + LOGE("written size %d", len); \ + fclose(fp); \ + } else { \ + LOGE("open %s failed", filename); \ + } \ +}) + +/* Declaring Buffer structure */ +struct mm_camera_buf_def; + +/** mm_camera_plane_def_t : structure for frame plane info +* @num_planes : num of planes for the frame buffer, to be +* filled during mem allocation +* @planes : plane info for the frame buffer, to be filled +* during mem allocation +**/ +typedef struct { + int8_t num_planes; + struct v4l2_plane planes[VIDEO_MAX_PLANES]; +} mm_camera_plane_buf_def_t; + +/** mm_camera_user_buf_def_t : structure for frame plane info +* @num_buffers : num of buffers in this user defined structure +* @bufs_used : actual number of buffer filled +* @buf_in_use : flag to notify buffer usage status. +* @plane_buf : Plane buffer array pointer. +**/ +typedef struct { + uint8_t num_buffers; + uint8_t bufs_used; /*Num of Buffer filled by Kernel*/ + uint8_t buf_in_use; /* Container buffer is freed to fill*/ + int32_t buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT]; + struct mm_camera_buf_def *plane_buf; +} mm_camera_user_buf_def_t; + +/** mm_camera_buf_def_t: structure for stream frame buf +* @stream_id : stream handler to uniquely identify a stream +* object +* @buf_idx : index of the buf within the stream bufs, to be +* filled during mem allocation +* @timespec_ts : time stamp, to be filled when DQBUF is +* called +* @frame_idx : frame sequence num, to be filled when DQBUF +* @plane_buf : Frame plane definition +* @fd : file descriptor of the frame buffer, to be filled +* during mem allocation +* @buffer : pointer to the frame buffer, to be filled during +* mem allocation +* @frame_len : length of the whole frame, to be filled during +* mem allocation +* @mem_info : user specific pointer to additional mem info +* @flags: v4l2_buffer flags, used to report error in data buffers +**/ +typedef struct mm_camera_buf_def { + uint32_t stream_id; + cam_stream_type_t stream_type; + cam_stream_buf_type buf_type; + uint32_t buf_idx; + uint8_t is_uv_subsampled; + struct timespec ts; + uint32_t frame_idx; + union { + mm_camera_plane_buf_def_t planes_buf; + mm_camera_user_buf_def_t user_buf; + }; + int fd; + void *buffer; + size_t frame_len; + void *mem_info; + uint32_t flags; +} mm_camera_buf_def_t; + +/** mm_camera_super_buf_t: super buf structure for bundled +* stream frames +* @camera_handle : camera handler to uniquely identify +* a camera object +* @ch_id : channel handler to uniquely ideentify a channel +* object +* @num_bufs : number of buffers in the super buf, should not +* exceeds MAX_STREAM_NUM_IN_BUNDLE +* @bufs : array of buffers in the bundle +**/ +typedef struct { + uint32_t camera_handle; + uint32_t ch_id; + uint32_t num_bufs; + uint8_t bUnlockAEC; + uint8_t bReadyForPrepareSnapshot; + mm_camera_buf_def_t* bufs[MAX_STREAM_NUM_IN_BUNDLE]; +} mm_camera_super_buf_t; + +/** mm_camera_req_buf_type_t +* Request type for super buf from channel +**/ +typedef enum { + MM_CAMERA_REQ_SUPER_BUF, + MM_CAMERA_REQ_FRAME_SYNC_BUF +} mm_camera_req_buf_type_t; + +/** mm_camera_req_buf_t: Attributes for super buf request +* +* @type : type of super buf requested +* @num_buf_requested : num of super bufs requested +* @num_retro_buf_requested : number of retro bufs requested +* @primary_only : specifies if only primary camera frame for a dual +* camera is requested +**/ +typedef struct { + mm_camera_req_buf_type_t type; + uint32_t num_buf_requested; + uint32_t num_retro_buf_requested; + uint8_t primary_only; +} mm_camera_req_buf_t; + +/** mm_camera_event_t: structure for event +* @server_event_type : event type from serer +* @status : status of an event, value could be +* CAM_STATUS_SUCCESS +* CAM_STATUS_FAILED +**/ +typedef struct { + cam_event_type_t server_event_type; + uint32_t status; +} mm_camera_event_t; + +/** mm_camera_event_notify_t: function definition for event +* notify handling +* @camera_handle : camera handler +* @evt : pointer to an event struct +* @user_data: user data pointer +**/ +typedef void (*mm_camera_event_notify_t)(uint32_t camera_handle, + mm_camera_event_t *evt, + void *user_data); + +/** mm_camera_buf_notify_t: function definition for frame notify +* handling +* @mm_camera_super_buf_t : received frame buffers +* @user_data: user data pointer +**/ +typedef void (*mm_camera_buf_notify_t) (mm_camera_super_buf_t *bufs, + void *user_data); + +/** map_stream_buf_op_t: function definition for operation of +* mapping stream buffers via domain socket +* @frame_idx : buffer index within stream buffers +* @plane_idx : plane index. If all planes share the same +* fd, plane_idx = -1; otherwise, plean_idx is +* the index to plane (0..num_of_planes) +* @fd : file descriptor of the stream buffer +* @size: size of the stream buffer +* @userdata : user data pointer +**/ +typedef int32_t (*map_stream_buf_op_t) (uint32_t frame_idx, + int32_t plane_idx, + int fd, + size_t size, + cam_mapping_buf_type type, + void *userdata); + +typedef int32_t (*map_stream_bufs_op_t) (const cam_buf_map_type_list *buf_map_list, + void *userdata); + +/** unmap_stream_buf_op_t: function definition for operation of +* unmapping stream buffers via domain +* socket +* @frame_idx : buffer index within stream buffers +* @plane_idx : plane index. If all planes share the same +* fd, plane_idx = -1; otherwise, plean_idx is +* the index to plane (0..num_of_planes) +* @userdata : user data pointer +**/ +typedef int32_t (*unmap_stream_buf_op_t) (uint32_t frame_idx, + int32_t plane_idx, + cam_mapping_buf_type type, + void *userdata); + +/** mm_camera_map_unmap_ops_tbl_t: virtual table +* for mapping/unmapping stream buffers via +* domain socket +* @map_ops : operation for mapping +* @unmap_ops : operation for unmapping +* @userdata: user data pointer +**/ +typedef struct { + map_stream_buf_op_t map_ops; + map_stream_bufs_op_t bundled_map_ops; + unmap_stream_buf_op_t unmap_ops; + void *userdata; +} mm_camera_map_unmap_ops_tbl_t; + +/** mm_camera_stream_mem_vtbl_t: virtual table for stream +* memory allocation and deallocation +* @get_bufs : function definition for allocating +* stream buffers +* @put_bufs : function definition for deallocating +* stream buffers +* @user_data: user data pointer +**/ +typedef struct { + void *user_data; + int32_t (*set_config_ops) (mm_camera_map_unmap_ops_tbl_t *ops_tbl, + void *user_data); + int32_t (*get_bufs) (cam_frame_len_offset_t *offset, + uint8_t *num_bufs, + uint8_t **initial_reg_flag, + mm_camera_buf_def_t **bufs, + mm_camera_map_unmap_ops_tbl_t *ops_tbl, + void *user_data); + int32_t (*put_bufs) (mm_camera_map_unmap_ops_tbl_t *ops_tbl, + void *user_data); + int32_t (*invalidate_buf)(uint32_t index, void *user_data); + int32_t (*clean_invalidate_buf)(uint32_t index, void *user_data); +} mm_camera_stream_mem_vtbl_t; + +/** mm_camera_stream_config_t: structure for stream +* configuration +* @stream_info : pointer to a stream info structure +* @padding_info: padding info obtained from querycapability +* @mem_tbl : memory operation table for +* allocating/deallocating stream buffers +* @stream_cb_sync : SYNC callback handling stream frame notify +* @stream_cb : ASYNC callback handling stream frame notify +* @userdata : user data pointer +**/ +typedef struct { + cam_stream_info_t *stream_info; + cam_padding_info_t padding_info; + mm_camera_stream_mem_vtbl_t mem_vtbl; + mm_camera_buf_notify_t stream_cb_sync; + mm_camera_buf_notify_t stream_cb; + void *userdata; +} mm_camera_stream_config_t; + +/** mm_camera_super_buf_notify_mode_t: enum for super uffer +* notification mode +* @MM_CAMERA_SUPER_BUF_NOTIFY_BURST : +* ZSL use case: get burst of frames +* @MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS : +* get continuous frames: when the super buf is ready +* dispatch it to HAL +**/ +typedef enum { + MM_CAMERA_SUPER_BUF_NOTIFY_BURST = 0, + MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS, + MM_CAMERA_SUPER_BUF_NOTIFY_MAX +} mm_camera_super_buf_notify_mode_t; + +/** mm_camera_super_buf_priority_t: enum for super buffer +* matching priority +* @MM_CAMERA_SUPER_BUF_PRIORITY_NORMAL : +* Save the frame no matter focused or not. Currently only +* this type is supported. +* @MM_CAMERA_SUPER_BUF_PRIORITY_FOCUS : +* only queue the frame that is focused. Will enable meta +* data header to carry focus info +* @MM_CAMERA_SUPER_BUF_PRIORITY_EXPOSURE_BRACKETING : +* after shutter, only queue matched exposure index +**/ +typedef enum { + MM_CAMERA_SUPER_BUF_PRIORITY_NORMAL = 0, + MM_CAMERA_SUPER_BUF_PRIORITY_FOCUS, + MM_CAMERA_SUPER_BUF_PRIORITY_EXPOSURE_BRACKETING, + MM_CAMERA_SUPER_BUF_PRIORITY_LOW,/* Bundled metadata frame may not match*/ + MM_CAMERA_SUPER_BUF_PRIORITY_MAX +} mm_camera_super_buf_priority_t; + +/** mm_camera_advanced_capture_t: enum for advanced capture type. +* @MM_CAMERA_AF_BRACKETING : +* to enable AF Bracketig. +* @MM_CAMERA_AE_BRACKETING : +* to enable AF Bracketing. +* @MM_CAMERA_FLASH_BRACKETING : +* to enable Flash Bracketing. +* @MM_CAMERA_ZOOM_1X : +* to enable zoom 1x capture request +**/ +typedef enum { + MM_CAMERA_AF_BRACKETING = 0, + MM_CAMERA_AE_BRACKETING, + MM_CAMERA_FLASH_BRACKETING, + MM_CAMERA_ZOOM_1X, + MM_CAMERA_FRAME_CAPTURE, +} mm_camera_advanced_capture_t; + +/** mm_camera_stream_cb_type: enum for stream buffer callback type. +* @MM_CAMERA_STREAM_CB_TYPE_ASYNC : +* callback is async type. buffer process done in client thread context +* @MM_CAMERA_STREAM_CB_TYPE_SYNC : +* callback is sync type. buffer process done interface thread context +**/ +typedef enum { + MM_CAMERA_STREAM_CB_TYPE_ASYNC, + MM_CAMERA_STREAM_CB_TYPE_SYNC, +} mm_camera_stream_cb_type; + + +/** mm_camera_channel_attr_t: structure for defining channel +* attributes +* @notify_mode : notify mode: burst or continuous +* @water_mark : queue depth. Only valid for burst mode +* @look_back : look back how many frames from last buf. +* Only valid for burst mode +* @post_frame_skip : after send first frame to HAL, how many +* frames needing to be skipped for next +* delivery. Only valid for burst mode +* @max_unmatched_frames : max number of unmatched frames in +* queue +* @enable_frame_sync: Enables frame sync for dual camera +* @priority : save matched priority frames only +* @user_expected_frame_id : Number of frames, camera interface +* will wait for getting the instant capture frame. +**/ +typedef struct { + mm_camera_super_buf_notify_mode_t notify_mode; + uint8_t water_mark; + uint8_t look_back; + uint8_t post_frame_skip; + uint8_t max_unmatched_frames; + uint8_t enable_frame_sync; + mm_camera_super_buf_priority_t priority; + uint8_t user_expected_frame_id; +} mm_camera_channel_attr_t; + +typedef struct { + /** query_capability: fucntion definition for querying static + * camera capabilities + * @camera_handle : camer handler + * Return value: 0 -- success + * -1 -- failure + * Note: would assume cam_capability_t is already mapped + **/ + int32_t (*query_capability) (uint32_t camera_handle); + + /** register_event_notify: fucntion definition for registering + * for event notification + * @camera_handle : camer handler + * @evt_cb : callback for event notify + * @user_data : user data poiner + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*register_event_notify) (uint32_t camera_handle, + mm_camera_event_notify_t evt_cb, + void *user_data); + + /** close_camera: fucntion definition for closing a camera + * @camera_handle : camer handler + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*close_camera) (uint32_t camera_handle); + + /** map_buf: fucntion definition for mapping a camera buffer + * via domain socket + * @camera_handle : camer handler + * @buf_type : type of mapping buffers, can be value of + * CAM_MAPPING_BUF_TYPE_CAPABILITY + * CAM_MAPPING_BUF_TYPE_SETPARM_BUF + * CAM_MAPPING_BUF_TYPE_GETPARM_BUF + * @fd : file descriptor of the stream buffer + * @size : size of the stream buffer + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*map_buf) (uint32_t camera_handle, + uint8_t buf_type, + int fd, + size_t size); + + /** map_bufs: function definition for mapping multiple camera buffers + * via domain socket + * @camera_handle : camera handler + * @buf_map_list : list of buffers to map + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*map_bufs) (uint32_t camera_handle, + const cam_buf_map_type_list *buf_map_list); + + /** unmap_buf: fucntion definition for unmapping a camera buffer + * via domain socket + * @camera_handle : camer handler + * @buf_type : type of mapping buffers, can be value of + * CAM_MAPPING_BUF_TYPE_CAPABILITY + * CAM_MAPPING_BUF_TYPE_SETPARM_BUF + * CAM_MAPPING_BUF_TYPE_GETPARM_BUF + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*unmap_buf) (uint32_t camera_handle, + uint8_t buf_type); + + /** set_parms: fucntion definition for setting camera + * based parameters to server + * @camera_handle : camer handler + * @parms : batch for parameters to be set, stored in + * parm_buffer_t + * Return value: 0 -- success + * -1 -- failure + * Note: would assume parm_buffer_t is already mapped, and + * according parameter entries to be set are filled in the + * buf before this call + **/ + int32_t (*set_parms) (uint32_t camera_handle, + parm_buffer_t *parms); + + /** get_parms: fucntion definition for querying camera + * based parameters from server + * @camera_handle : camer handler + * @parms : batch for parameters to be queried, stored in + * parm_buffer_t + * Return value: 0 -- success + * -1 -- failure + * Note: would assume parm_buffer_t is already mapped, and + * according parameter entries to be queried are filled in + * the buf before this call + **/ + int32_t (*get_parms) (uint32_t camera_handle, + parm_buffer_t *parms); + + /** do_auto_focus: fucntion definition for performing auto focus + * @camera_handle : camer handler + * Return value: 0 -- success + * -1 -- failure + * Note: if this call success, we will always assume there will + * be an auto_focus event following up. + **/ + int32_t (*do_auto_focus) (uint32_t camera_handle); + + /** cancel_auto_focus: fucntion definition for cancelling + * previous auto focus request + * @camera_handle : camer handler + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*cancel_auto_focus) (uint32_t camera_handle); + + /** prepare_snapshot: fucntion definition for preparing hardware + * for snapshot. + * @camera_handle : camer handler + * @do_af_flag : flag indicating if AF needs to be done + * 0 -- no AF needed + * 1 -- AF needed + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*prepare_snapshot) (uint32_t camera_handle, + int32_t do_af_flag); + + /** start_zsl_snapshot: function definition for starting + * zsl snapshot. + * @camera_handle : camer handler + * @ch_id : channel id + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*start_zsl_snapshot) (uint32_t camera_handle, uint32_t ch_id); + + /** stop_zsl_snapshot: function definition for stopping + * zsl snapshot. + * @camera_handle : camer handler + * @ch_id : channel id + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*stop_zsl_snapshot) (uint32_t camera_handle, uint32_t ch_id); + + /** add_channel: fucntion definition for adding a channel + * @camera_handle : camer handler + * @ch_id : channel handler + * @attr : pointer to channel attribute structure + * @channel_cb : callbak to handle bundled super buffer + * @userdata : user data pointer + * Return value: channel id, zero is invalid ch_id + * Note: attr, channel_cb, and userdata can be NULL if no + * superbufCB is needed + **/ + uint32_t (*add_channel) (uint32_t camera_handle, + mm_camera_channel_attr_t *attr, + mm_camera_buf_notify_t channel_cb, + void *userdata); + + /** delete_channel: fucntion definition for deleting a channel + * @camera_handle : camer handler + * @ch_id : channel handler + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*delete_channel) (uint32_t camera_handle, + uint32_t ch_id); + + /** get_bundle_info: function definition for querying bundle + * info of the channel + * @camera_handle : camera handler + * @ch_id : channel handler + * @bundle_info : bundle info to be filled in + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*get_bundle_info) (uint32_t camera_handle, + uint32_t ch_id, + cam_bundle_config_t *bundle_info); + + /** add_stream: fucntion definition for adding a stream + * @camera_handle : camer handler + * @ch_id : channel handler + * Return value: stream_id. zero is invalid stream_id + **/ + uint32_t (*add_stream) (uint32_t camera_handle, + uint32_t ch_id); + + /** delete_stream: fucntion definition for deleting a stream + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*delete_stream) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t stream_id); + + /** link_stream: function definition for linking a stream + * @camera_handle : camera handle + * @ch_id : channel handle from which the stream originates + * @stream_id : stream handle + * @linked_ch_id: channel handle in which the stream will be linked + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*link_stream) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t stream_id, + uint32_t linked_ch_id); + + /** config_stream: fucntion definition for configuring a stream + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * @confid : pointer to a stream configuration structure + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*config_stream) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t stream_id, + mm_camera_stream_config_t *config); + + /** map_stream_buf: fucntion definition for mapping + * stream buffer via domain socket + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * @buf_type : type of mapping buffers, can be value of + * CAM_MAPPING_BUF_TYPE_STREAM_BUF + * CAM_MAPPING_BUF_TYPE_STREAM_INFO + * CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF + * @buf_idx : buffer index within the stream buffers + * @plane_idx : plane index. If all planes share the same fd, + * plane_idx = -1; otherwise, plean_idx is the + * index to plane (0..num_of_planes) + * @fd : file descriptor of the stream buffer + * @size : size of the stream buffer + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*map_stream_buf) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t stream_id, + uint8_t buf_type, + uint32_t buf_idx, + int32_t plane_idx, + int fd, + size_t size); + + /** map_stream_bufs: function definition for mapping multiple + * stream buffers via domain socket + * @camera_handle : camera handler + * @ch_id : channel handler + * @buf_map_list : list of buffers to map + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*map_stream_bufs) (uint32_t camera_handle, + uint32_t ch_id, + const cam_buf_map_type_list *buf_map_list); + + /** unmap_stream_buf: fucntion definition for unmapping + * stream buffer via domain socket + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * @buf_type : type of mapping buffers, can be value of + * CAM_MAPPING_BUF_TYPE_STREAM_BUF + * CAM_MAPPING_BUF_TYPE_STREAM_INFO + * CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF + * @buf_idx : buffer index within the stream buffers + * @plane_idx : plane index. If all planes share the same fd, + * plane_idx = -1; otherwise, plean_idx is the + * index to plane (0..num_of_planes) + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*unmap_stream_buf) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t stream_id, + uint8_t buf_type, + uint32_t buf_idx, + int32_t plane_idx); + + /** set_stream_parms: fucntion definition for setting stream + * specific parameters to server + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * @parms : batch for parameters to be set + * Return value: 0 -- success + * -1 -- failure + * Note: would assume parm buffer is already mapped, and + * according parameter entries to be set are filled in the + * buf before this call + **/ + int32_t (*set_stream_parms) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t s_id, + cam_stream_parm_buffer_t *parms); + + /** get_stream_parms: fucntion definition for querying stream + * specific parameters from server + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * @parms : batch for parameters to be queried + * Return value: 0 -- success + * -1 -- failure + * Note: would assume parm buffer is already mapped, and + * according parameter entries to be queried are filled in + * the buf before this call + **/ + int32_t (*get_stream_parms) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t s_id, + cam_stream_parm_buffer_t *parms); + + /** start_channel: fucntion definition for starting a channel + * @camera_handle : camer handler + * @ch_id : channel handler + * Return value: 0 -- success + * -1 -- failure + * This call will start all streams belongs to the channel + **/ + int32_t (*start_channel) (uint32_t camera_handle, + uint32_t ch_id); + + /** stop_channel: fucntion definition for stopping a channel + * @camera_handle : camer handler + * @ch_id : channel handler + * Return value: 0 -- success + * -1 -- failure + * This call will stop all streams belongs to the channel + **/ + int32_t (*stop_channel) (uint32_t camera_handle, + uint32_t ch_id); + + /** qbuf: fucntion definition for queuing a frame buffer back to + * kernel for reuse + * @camera_handle : camer handler + * @ch_id : channel handler + * @buf : a frame buffer to be queued back to kernel + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*qbuf) (uint32_t camera_handle, + uint32_t ch_id, + mm_camera_buf_def_t *buf); + + /** get_queued_buf_count: fucntion definition for querying queued buf count + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * Return value: queued buf count + **/ + int32_t (*get_queued_buf_count) (uint32_t camera_handle, + uint32_t ch_id, + uint32_t stream_id); + + /** request_super_buf: fucntion definition for requesting frames + * from superbuf queue in burst mode + * @camera_handle : camer handler + * @ch_id : channel handler + * @buf : provides info related to the super buf request + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*request_super_buf) (uint32_t camera_handle, + uint32_t ch_id, + mm_camera_req_buf_t *buf); + + /** cancel_super_buf_request: fucntion definition for canceling + * frames dispatched from superbuf queue in + * burst mode + * @camera_handle : camer handler + * @ch_id : channel handler + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*cancel_super_buf_request) (uint32_t camera_handle, + uint32_t ch_id); + + /** flush_super_buf_queue: function definition for flushing out + * all frames in the superbuf queue up to frame_idx, + * even if frames with frame_idx come in later than + * this call. + * @camera_handle : camer handler + * @ch_id : channel handler + * @frame_idx : frame index up until which all superbufs are flushed + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*flush_super_buf_queue) (uint32_t camera_handle, + uint32_t ch_id, uint32_t frame_idx); + + /** configure_notify_mode: function definition for configuring the + * notification mode of channel + * @camera_handle : camera handler + * @ch_id : channel handler + * @notify_mode : notification mode + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*configure_notify_mode) (uint32_t camera_handle, + uint32_t ch_id, + mm_camera_super_buf_notify_mode_t notify_mode); + + /** process_advanced_capture: function definition for start/stop advanced capture + * for snapshot. + * @camera_handle : camera handle + * @ch_id : channel handler + * @type : advanced capture type. + * @trigger : flag indicating if advanced capture needs to be done + * 0 -- stop advanced capture + * 1 -- start advanced capture + * @in_value: Input value. Configaration + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*process_advanced_capture) (uint32_t camera_handle, + uint32_t ch_id, mm_camera_advanced_capture_t type, + int8_t start_flag, void *in_value); + + /** get_session_id: gets the backend session id from the kernel + * @camera_handle : camera handle + * @sessionid : session id to be retrieved + * Return value: 0 -- success + * -1 -- failure + * Note: if this call succeeds, we will get a valid session id + **/ + int32_t (*get_session_id) (uint32_t camera_handle, + uint32_t* sessionid); + + /** sync_related_sensors: sends sync cmd + * @camera_handle : camera handle + * @related_cam_info : related cam info to be sent to server + * Return value: 0 -- success + * -1 -- failure + * Note: if this call succeeds, we will get linking established in back end + **/ + int32_t (*sync_related_sensors) (uint32_t camera_handle, + cam_sync_related_sensors_event_info_t* + related_cam_info); + /** flush: function definition for flush + * @camera_handle: camera handler + * Return value: 0 -- success + * -1 -- failure + **/ + int32_t (*flush) (uint32_t camera_handle); + + /** register_stream_buf_cb: fucntion definition for registering special stream callbacks + * @camera_handle : camer handler + * @ch_id : channel handler + * @stream_id : stream handler + * @buf_cb : callback function pointer + * @cb_type : Callback type SYNC/ASYNC + * @userdata : user data pointer + * Return value: 0 -- success + * - 1 -- failure + **/ + int32_t (*register_stream_buf_cb) (uint32_t camera_handle, + uint32_t ch_id, uint32_t stream_id, mm_camera_buf_notify_t buf_cb, + mm_camera_stream_cb_type cb_type, void *userdata); +} mm_camera_ops_t; + +/** mm_camera_vtbl_t: virtual table for camera operations +* @camera_handle : camera handler which uniquely identifies a +* camera object +* @ops : API call table +**/ +typedef struct { + uint32_t camera_handle; + mm_camera_ops_t *ops; +} mm_camera_vtbl_t; + +/* return number of cameras */ +uint8_t get_num_of_cameras(); + +/* return reference pointer of camera vtbl */ +int32_t camera_open(uint8_t camera_idx, mm_camera_vtbl_t **camera_obj); + +/* helper functions */ +int32_t mm_stream_calc_offset_preview(cam_stream_info_t *stream_info, + cam_dimension_t *dim, + cam_padding_info_t *padding, + cam_stream_buf_plane_info_t *buf_planes); + +int32_t mm_stream_calc_offset_post_view(cam_format_t fmt, + cam_dimension_t *dim, + cam_stream_buf_plane_info_t *buf_planes); + +int32_t mm_stream_calc_offset_snapshot(cam_format_t fmt, + cam_dimension_t *dim, + cam_padding_info_t *padding, + cam_stream_buf_plane_info_t *buf_planes); + +int32_t mm_stream_calc_offset_raw(cam_format_t fmt, + cam_dimension_t *dim, + cam_padding_info_t *padding, + cam_stream_buf_plane_info_t *buf_planes); + +int32_t mm_stream_calc_offset_video(cam_format_t fmt, + cam_dimension_t *dim, + cam_stream_buf_plane_info_t *buf_planes); + +int32_t mm_stream_calc_offset_metadata(cam_dimension_t *dim, + cam_padding_info_t *padding, + cam_stream_buf_plane_info_t *buf_planes); + +int32_t mm_stream_calc_offset_postproc(cam_stream_info_t *stream_info, + cam_padding_info_t *padding, + cam_stream_buf_plane_info_t *buf_planes); + +int32_t mm_stream_calc_offset_analysis(cam_format_t fmt, + cam_dimension_t *dim, + cam_padding_info_t *padding, + cam_stream_buf_plane_info_t *buf_planes); + +uint32_t mm_stream_calc_lcm (int32_t num1, int32_t num2); + +struct camera_info *get_cam_info(uint32_t camera_id, cam_sync_type_t *pCamType); + +uint8_t is_yuv_sensor(uint32_t camera_id); + +#endif /*__MM_CAMERA_INTERFACE_H__*/ diff --git a/camera/QCamera2/stack/common/mm_jpeg_interface.h b/camera/QCamera2/stack/common/mm_jpeg_interface.h new file mode 100644 index 0000000..9f0ac7f --- /dev/null +++ b/camera/QCamera2/stack/common/mm_jpeg_interface.h @@ -0,0 +1,408 @@ +/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef MM_JPEG_INTERFACE_H_ +#define MM_JPEG_INTERFACE_H_ + +// System dependencies +#include + +// Camera dependencies +#include "QOMX_JpegExtensions.h" +#include "cam_intf.h" + +#define MM_JPEG_MAX_PLANES 3 +#define MM_JPEG_MAX_BUF CAM_MAX_NUM_BUFS_PER_STREAM +#define QUANT_SIZE 64 +#define QTABLE_MAX 2 +#define MM_JPEG_MAX_MPO_IMAGES 2 + +typedef enum { + MM_JPEG_FMT_YUV, + MM_JPEG_FMT_BITSTREAM +} mm_jpeg_format_t; + +typedef enum { + MM_JPEG_TYPE_JPEG, + MM_JPEG_TYPE_MPO +} mm_jpeg_image_type_t; + +typedef struct { + cam_ae_exif_debug_t ae_debug_params; + cam_awb_exif_debug_t awb_debug_params; + cam_af_exif_debug_t af_debug_params; + cam_asd_exif_debug_t asd_debug_params; + cam_stats_buffer_exif_debug_t stats_debug_params; + cam_bestats_buffer_exif_debug_t bestats_debug_params; + cam_bhist_buffer_exif_debug_t bhist_debug_params; + cam_q3a_tuning_info_t q3a_tuning_debug_params; + uint8_t ae_debug_params_valid; + uint8_t awb_debug_params_valid; + uint8_t af_debug_params_valid; + uint8_t asd_debug_params_valid; + uint8_t stats_debug_params_valid; + uint8_t bestats_debug_params_valid; + uint8_t bhist_debug_params_valid; + uint8_t q3a_tuning_debug_params_valid; +} mm_jpeg_debug_exif_params_t; + +typedef struct { + cam_3a_params_t cam_3a_params; + uint8_t cam_3a_params_valid; + cam_sensor_params_t sensor_params; + mm_jpeg_debug_exif_params_t *debug_params; +} mm_jpeg_exif_params_t; + +typedef struct { + /* Indicates if it is a single jpeg or part of a multi picture sequence */ + mm_jpeg_image_type_t type; + + /* Indicates if image is the primary image in a sequence of images. + Applicable only to multi picture formats */ + uint8_t is_primary; + + /* Number of images in the sequence */ + uint32_t num_of_images; + + /* Flag to indicate if multi picture metadata need to be added to Exif */ + uint8_t enable_metadata; +} mm_jpeg_multi_image_t; + +typedef struct { + uint32_t sequence; /* for jpeg bit streams, assembling is based on sequence. sequence starts from 0 */ + uint8_t *buf_vaddr; /* ptr to buf */ + int fd; /* fd of buf */ + size_t buf_size; /* total size of buf (header + image) */ + mm_jpeg_format_t format; /* buffer format*/ + cam_frame_len_offset_t offset; /* offset of all the planes */ + uint32_t index; /* index used to identify the buffers */ +} mm_jpeg_buf_t; + +typedef struct { + uint8_t *buf_vaddr; /* ptr to buf */ + int fd; /* fd of buf */ + size_t buf_filled_len; /* used for output image. filled by the client */ +} mm_jpeg_output_t; + +typedef enum { + MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2, + MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V2, + MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V1, + MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V1, + MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V2, + MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V2, + MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V1, + MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V1, + MM_JPEG_COLOR_FORMAT_MONOCHROME, + MM_JPEG_COLOR_FORMAT_BITSTREAM_H2V2, + MM_JPEG_COLOR_FORMAT_BITSTREAM_H2V1, + MM_JPEG_COLOR_FORMAT_BITSTREAM_H1V2, + MM_JPEG_COLOR_FORMAT_BITSTREAM_H1V1, + MM_JPEG_COLOR_FORMAT_MAX +} mm_jpeg_color_format; + +typedef enum { + JPEG_JOB_STATUS_DONE = 0, + JPEG_JOB_STATUS_ERROR +} jpeg_job_status_t; + +typedef void (*jpeg_encode_callback_t)(jpeg_job_status_t status, + uint32_t client_hdl, + uint32_t jobId, + mm_jpeg_output_t *p_output, + void *userData); + +typedef struct { + /* src img dimension */ + cam_dimension_t src_dim; + + /* jpeg output dimension */ + cam_dimension_t dst_dim; + + /* crop information */ + cam_rect_t crop; +} mm_jpeg_dim_t; + +typedef struct { + /* num of buf in src img */ + uint32_t num_src_bufs; + + /* num of src tmb bufs */ + uint32_t num_tmb_bufs; + + /* num of buf in src img */ + uint32_t num_dst_bufs; + + /* should create thumbnail from main image or not */ + uint32_t encode_thumbnail; + + /* src img bufs */ + mm_jpeg_buf_t src_main_buf[MM_JPEG_MAX_BUF]; + + /* this will be used only for bitstream */ + mm_jpeg_buf_t src_thumb_buf[MM_JPEG_MAX_BUF]; + + /* this will be used only for bitstream */ + mm_jpeg_buf_t dest_buf[MM_JPEG_MAX_BUF]; + + /* mainimage color format */ + mm_jpeg_color_format color_format; + + /* thumbnail color format */ + mm_jpeg_color_format thumb_color_format; + + /* jpeg quality: range 0~100 */ + uint32_t quality; + + /* jpeg thumbnail quality: range 0~100 */ + uint32_t thumb_quality; + + /* buf to exif entries, caller needs to + * take care of the memory manage with insider ptr */ + QOMX_EXIF_INFO exif_info; + + /*Callback registered to be called after encode*/ + jpeg_encode_callback_t jpeg_cb; + + /*Appdata passed by the user*/ + void* userdata; + + /* thumbnail dimension */ + mm_jpeg_dim_t thumb_dim; + + /* rotation informaiton */ + uint32_t rotation; + + /* thumb rotation informaiton */ + uint32_t thumb_rotation; + + /* main image dimension */ + mm_jpeg_dim_t main_dim; + + /* enable encoder burst mode */ + uint32_t burst_mode; + + /* get memory function ptr */ + int (*get_memory)( omx_jpeg_ouput_buf_t *p_out_buf); + + /* release memory function ptr */ + int (*put_memory)( omx_jpeg_ouput_buf_t *p_out_buf); + + /* Flag to indicate whether to generate thumbnail from postview */ + bool thumb_from_postview; +} mm_jpeg_encode_params_t; + +typedef struct { + /* num of buf in src img */ + uint32_t num_src_bufs; + + /* num of buf in src img */ + uint32_t num_dst_bufs; + + /* src img bufs */ + mm_jpeg_buf_t src_main_buf[MM_JPEG_MAX_BUF]; + + /* this will be used only for bitstream */ + mm_jpeg_buf_t dest_buf[MM_JPEG_MAX_BUF]; + + /* color format */ + mm_jpeg_color_format color_format; + + jpeg_encode_callback_t jpeg_cb; + + void* userdata; + +} mm_jpeg_decode_params_t; + +typedef struct { + /* active indices of the buffers for encoding */ + int32_t src_index; + int32_t dst_index; + uint32_t thumb_index; + mm_jpeg_dim_t thumb_dim; + + /* rotation informaiton */ + uint32_t rotation; + + /* main image dimension */ + mm_jpeg_dim_t main_dim; + + /*session id*/ + uint32_t session_id; + + /* jpeg output buffer ref count */ + int32_t ref_count; + + /* allocated jpeg output buffer */ + void *alloc_out_buffer; + + /*Metadata stream*/ + metadata_buffer_t *p_metadata; + + /*HAL version*/ + cam_hal_version_t hal_version; + + /* buf to exif entries, caller needs to + * take care of the memory manage with insider ptr */ + QOMX_EXIF_INFO exif_info; + + /* 3a parameters */ + mm_jpeg_exif_params_t cam_exif_params; + + /* jpeg encoder QTable */ + uint8_t qtable_set[QTABLE_MAX]; + + OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE qtable[QTABLE_MAX]; + + /* flag to enable/disable mobicat */ + uint8_t mobicat_mask; + + /*Info associated with multiple image sequence*/ + mm_jpeg_multi_image_t multi_image_info; + + /* work buf */ + mm_jpeg_buf_t work_buf; +} mm_jpeg_encode_job_t; + +typedef struct { + /* active indices of the buffers for encoding */ + int32_t src_index; + int32_t dst_index; + uint32_t tmb_dst_index; + + /* rotation informaiton */ + uint32_t rotation; + + /* main image */ + mm_jpeg_dim_t main_dim; + + /*session id*/ + uint32_t session_id; +} mm_jpeg_decode_job_t; + +typedef enum { + JPEG_JOB_TYPE_ENCODE, + JPEG_JOB_TYPE_DECODE, + JPEG_JOB_TYPE_MAX +} mm_jpeg_job_type_t; + +typedef struct { + mm_jpeg_job_type_t job_type; + union { + mm_jpeg_encode_job_t encode_job; + mm_jpeg_decode_job_t decode_job; + }; +} mm_jpeg_job_t; + +typedef struct { + uint32_t w; + uint32_t h; +} mm_dimension; + +typedef struct { + /*Primary image in the MPO sequence*/ + mm_jpeg_output_t primary_image; + + /*All auxillary images in the sequence*/ + mm_jpeg_output_t aux_images[MM_JPEG_MAX_MPO_IMAGES - 1]; + + /*Total number of images in the MPO sequence*/ + int num_of_images; + + /*Output MPO buffer*/ + mm_jpeg_output_t output_buff; + + /*Size of the allocated output buffer*/ + size_t output_buff_size; +} mm_jpeg_mpo_info_t; + +typedef struct { + /* config a job -- async call */ + int (*start_job)(mm_jpeg_job_t* job, uint32_t* job_id); + + /* abort a job -- sync call */ + int (*abort_job)(uint32_t job_id); + + /* create a session */ + int (*create_session)(uint32_t client_hdl, + mm_jpeg_encode_params_t *p_params, uint32_t *p_session_id); + + /* destroy session */ + int (*destroy_session)(uint32_t session_id); + + /* close a jpeg client -- sync call */ + int (*close) (uint32_t clientHdl); + +} mm_jpeg_ops_t; + +typedef struct { + /* config a job -- async call */ + int (*start_job)(mm_jpeg_job_t* job, uint32_t* job_id); + + /* abort a job -- sync call */ + int (*abort_job)(uint32_t job_id); + + /* create a session */ + int (*create_session)(uint32_t client_hdl, + mm_jpeg_decode_params_t *p_params, uint32_t *p_session_id); + + /* destroy session */ + int (*destroy_session)(uint32_t session_id); + + /* close a jpeg client -- sync call */ + int (*close) (uint32_t clientHdl); +} mm_jpegdec_ops_t; + +typedef struct { + + /* Get Mpo size*/ + int (*get_mpo_size)(mm_jpeg_output_t jpeg_buffer[MM_JPEG_MAX_MPO_IMAGES], + int num_of_images); + + /* Compose MPO*/ + int (*compose_mpo)(mm_jpeg_mpo_info_t *mpo_info); + +} mm_jpeg_mpo_ops_t; + +/* open a jpeg client -- sync call + * returns client_handle. + * failed if client_handle=0 + * jpeg ops tbl and mpo ops tbl will be filled in if open succeeds + * and jpeg meta data will be cached */ +uint32_t jpeg_open(mm_jpeg_ops_t *ops, mm_jpeg_mpo_ops_t *mpo_ops, + mm_dimension picture_size, + cam_jpeg_metadata_t *jpeg_metadata); + +/* open a jpeg client -- sync call + * returns client_handle. + * failed if client_handle=0 + * jpeg ops tbl will be filled in if open succeeds */ +uint32_t jpegdec_open(mm_jpegdec_ops_t *ops); + +#endif /* MM_JPEG_INTERFACE_H_ */ -- cgit v1.2.3