cam_intf.h revision 2f073d4cfa214187fc326377a1e0eecad84eaf3d
1/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above
9 *       copyright notice, this list of conditions and the following
10 *       disclaimer in the documentation and/or other materials provided
11 *       with the distribution.
12 *     * Neither the name of The Linux Foundation nor the names of its
13 *       contributors may be used to endorse or promote products derived
14 *       from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#ifndef __QCAMERA_INTF_H__
31#define __QCAMERA_INTF_H__
32
33#include <media/msmb_isp.h>
34#include "cam_types.h"
35
36#define CAM_PRIV_IOCTL_BASE (V4L2_CID_PRIVATE_BASE + 14)
37typedef enum {
38    CAM_PRIV_PARM = CAM_PRIV_IOCTL_BASE, /* session based parameters */
39    CAM_PRIV_DO_AUTO_FOCUS,              /* session based action: do auto focus */
40    CAM_PRIV_CANCEL_AUTO_FOCUS,          /* session based action: cancel auto focus */
41    CAM_PRIV_PREPARE_SNAPSHOT,           /* session based action: prepare for snapshot */
42    CAM_PRIV_STREAM_INFO_SYNC,           /* sync stream info */
43    CAM_PRIV_STREAM_PARM,                /* stream based parameters */
44    CAM_PRIV_START_ZSL_SNAPSHOT,         /* start ZSL snapshot */
45    CAM_PRIV_STOP_ZSL_SNAPSHOT,          /* stop ZSL snapshot */
46} cam_private_ioctl_enum_t;
47
48/* capability struct definition */
49typedef struct{
50    int modes_supported;                                    /* mask of modes supported: 2D, 3D */
51    cam_position_t position;                                /* sensor position: front, back */
52    uint32_t sensor_mount_angle;                            /* sensor mount angle */
53
54    float focal_length;                                     /* focal length */
55    float hor_view_angle;                                   /* horizontal view angle */
56    float ver_view_angle;                                   /* vertical view angle */
57
58    uint8_t zoom_ratio_tbl_cnt;                             /* table size for zoom ratios */
59    int zoom_ratio_tbl[MAX_ZOOMS_CNT];                      /* zoom ratios table */
60
61    uint8_t preview_sizes_tbl_cnt;                          /* preview sizes table size */
62    cam_dimension_t preview_sizes_tbl[MAX_SIZES_CNT];       /* preiew sizes table */
63
64    uint8_t video_sizes_tbl_cnt;                            /* video sizes table size */
65    cam_dimension_t video_sizes_tbl[MAX_SIZES_CNT];         /* video sizes table */
66
67    uint8_t picture_sizes_tbl_cnt;                          /* picture sizes table size */
68    cam_dimension_t picture_sizes_tbl[MAX_SIZES_CNT];       /* picture sizes table */
69
70    uint8_t fps_ranges_tbl_cnt;                             /* fps ranges table size */
71    cam_fps_range_t fps_ranges_tbl[MAX_SIZES_CNT];          /* fps ranges table */
72
73    uint8_t livesnapshot_sizes_tbl_cnt;                     /* livesnapshot sizes table size */
74    cam_dimension_t livesnapshot_sizes_tbl[MAX_SIZES_CNT];  /* livesnapshot sizes table */
75
76    uint8_t hfr_tbl_cnt;                                    /* table size for HFR */
77    cam_hfr_info_t hfr_tbl[CAM_HFR_MODE_MAX];               /* HFR table */
78
79    /* supported preview formats */
80    uint8_t supported_preview_fmt_cnt;
81    cam_format_t supported_preview_fmts[CAM_FORMAT_MAX];
82
83    /* supported picture formats */
84    uint8_t supported_picture_fmt_cnt;
85    cam_format_t supported_picture_fmts[CAM_FORMAT_MAX];
86
87    /* dimension and supported output format of raw dump from camif */
88    cam_dimension_t raw_dim;
89    uint8_t supported_raw_fmt_cnt;
90    cam_format_t supported_raw_fmts[CAM_FORMAT_MAX];
91
92    /* supported effect modes */
93    uint8_t supported_effects_cnt;
94    cam_effect_mode_type supported_effects[CAM_EFFECT_MODE_MAX];
95
96    /* supported white balance modes */
97    uint8_t supported_white_balances_cnt;
98    cam_wb_mode_type supported_white_balances[CAM_WB_MODE_MAX];
99
100    /* supported antibanding modes */
101    uint8_t supported_antibandings_cnt;
102    cam_antibanding_mode_type supported_antibandings[CAM_ANTIBANDING_MODE_MAX];
103
104    /* supported scene modes */
105    uint8_t supported_scene_modes_cnt;
106    cam_scene_mode_type supported_scene_modes[CAM_SCENE_MODE_MAX];
107
108    /* supported flash modes */
109    uint8_t supported_flash_modes_cnt;
110    cam_flash_mode_t supported_flash_modes[CAM_FLASH_MODE_MAX];
111
112    /* supported focus modes */
113    uint8_t supported_focus_modes_cnt;
114    cam_focus_mode_type supported_focus_modes[CAM_FOCUS_MODE_MAX];
115
116    /* supported iso modes */
117    uint8_t supported_iso_modes_cnt;
118    cam_iso_mode_type supported_iso_modes[CAM_ISO_MODE_MAX];
119
120    /* supported auto exposure modes */
121    uint8_t supported_aec_modes_cnt;
122    cam_auto_exposure_mode_type supported_aec_modes[CAM_AEC_MODE_MAX];
123
124    /* supported focus algorithms */
125    uint8_t supported_focus_algos_cnt;
126    cam_focus_algorithm_type supported_focus_algos[CAM_FOCUS_ALGO_MAX];
127
128    int exposure_compensation_min;       /* min value of exposure compensation index */
129    int exposure_compensation_max;       /* max value of exposure compensation index */
130    int exposure_compensation_default;   /* default value of exposure compensation index */
131    float exposure_compensation_step;    /* exposure compensation step value */
132
133    uint8_t auto_wb_lock_supported;       /* flag if auto white balance lock is supported */
134    uint8_t zoom_supported;               /* flag if zoom is supported */
135    uint8_t smooth_zoom_supported;        /* flag if smooth zoom is supported */
136    uint8_t auto_exposure_lock_supported; /* flag if auto exposure lock is supported */
137    uint8_t video_snapshot_supported;     /* flag if video snapshot is supported */
138    uint8_t video_stablization_supported; /* flag id video stablization is supported */
139
140    uint8_t max_num_roi;                  /* max number of roi can be detected */
141    uint8_t max_num_focus_areas;          /* max num of focus areas */
142    uint8_t max_num_metering_areas;       /* max num opf metering areas */
143    uint8_t max_zoom_step;                /* max zoom step value */
144
145    /* QCOM specific control */
146    cam_control_range_t brightness_ctrl;  /* brightness */
147    cam_control_range_t sharpness_ctrl;   /* sharpness */
148    cam_control_range_t contrast_ctrl;    /* contrast */
149    cam_control_range_t saturation_ctrl;  /* saturation */
150    cam_control_range_t sce_ctrl;         /* skintone enhancement factor */
151
152    uint32_t qcom_supported_feature_mask; /* mask of qcom specific features supported:
153                                           * such as CAM_QCOM_FEATURE_SUPPORTED_FACE_DETECTION*/
154    cam_padding_info_t padding_info;      /* padding information from PP */
155    int8_t min_num_hdr_bufs;              /* minimum number of buffers needed for HDR by imaging module */
156    int8_t min_num_pp_bufs;               /* minimum number of buffers needed by postproc module */
157    uint32_t min_required_pp_mask;        /* min required pp feature masks for ZSL.
158                                           * depends on hardware limitation, i.e. for 8974,
159                                           * sharpness is required for all ZSL snapshot frames */
160} cam_capability_t;
161
162typedef enum {
163    CAM_STREAM_PARAM_TYPE_DO_REPROCESS,
164    CAM_STREAM_PARAM_TYPE_MAX
165} cam_stream_param_type_e;
166
167typedef struct {
168    uint8_t buf_index;            /* buf index to the source frame buffer that needs reprocess,
169                                    (assume buffer is already mapped)*/
170    uint32_t frame_idx;           /* frame id of source frame to be reprocessed */
171    int32_t ret_val;              /* return value from reprocess. Could have different meanings.
172                                     i.e., faceID in the case of face registration. */
173    uint8_t meta_present;         /* if there is meta data associated with this reprocess frame */
174    uint32_t meta_stream_handle;  /* meta data stream ID. only valid if meta_present != 0 */
175    uint8_t meta_buf_index;       /* buf index to meta data buffer. only valid if meta_present != 0 */
176} cam_reprocess_param;
177
178typedef struct {
179    cam_stream_param_type_e type;
180    union {
181        cam_reprocess_param reprocess; /* do reprocess */
182    };
183} cam_stream_parm_buffer_t;
184
185/* stream info */
186typedef struct {
187    /* stream ID from server */
188    uint32_t stream_svr_id;
189
190    /* stream type */
191    cam_stream_type_t stream_type;
192
193    /* image format */
194    cam_format_t fmt;
195
196    /* image dimension */
197    cam_dimension_t dim;
198
199    /* buffer plane information, will be calc based on stream_type, fmt,
200       dim, and padding_info(from stream config). Info including:
201       offset_x, offset_y, stride, scanline, plane offset */
202    cam_stream_buf_plane_info_t buf_planes;
203
204    /* streaming type */
205    cam_streaming_mode_t streaming_mode;
206    /* num of frames needs to be generated.
207     * only valid when streaming_mode = CAM_STREAMING_MODE_BURST */
208    uint8_t num_of_burst;
209
210    /* stream specific pp config */
211    cam_pp_feature_config_t pp_config;
212
213    /* this section is valid if offline reprocess type stream */
214    cam_stream_reproc_config_t reprocess_config;
215
216    cam_stream_parm_buffer_t parm_buf;    /* stream based parameters */
217} cam_stream_info_t;
218
219/*****************************************************************************
220 *                 Code for Domain Socket Based Parameters                   *
221 ****************************************************************************/
222
223#define POINTER_OF(PARAM_ID,TABLE_PTR)    \
224        (&(TABLE_PTR->entry[PARAM_ID].data))
225
226#define GET_FIRST_PARAM_ID(TABLE_PTR)     \
227        (TABLE_PTR->first_flagged_entry)
228
229#define SET_FIRST_PARAM_ID(TABLE_PTR,PARAM_ID)     \
230        TABLE_PTR->first_flagged_entry=PARAM_ID
231
232#define GET_NEXT_PARAM_ID(CURRENT_PARAM_ID,TABLE_PTR)    \
233        (TABLE_PTR->entry[CURRENT_PARAM_ID].next_flagged_entry)
234
235#define SET_NEXT_PARAM_ID(CURRENT_PARAM_ID,TABLE_PTR,NEXT_PARAM_ID)    \
236        TABLE_PTR->entry[CURRENT_PARAM_ID].next_flagged_entry=NEXT_PARAM_ID;
237
238#define INCLUDE(PARAM_ID,DATATYPE,COUNT)  \
239        DATATYPE member_variable_##PARAM_ID[ COUNT ]
240
241typedef union {
242/**************************************************************************************
243 *          ID from (cam_intf_parm_type_t)          DATATYPE                     COUNT
244 **************************************************************************************/
245    INCLUDE(CAM_INTF_PARM_QUERY_FLASH4SNAP,         int32_t,                     1); //read only
246
247    INCLUDE(CAM_INTF_PARM_EXPOSURE,                 int32_t,                     1);
248    INCLUDE(CAM_INTF_PARM_SHARPNESS,                int32_t,                     1);
249    INCLUDE(CAM_INTF_PARM_CONTRAST,                 int32_t,                     1);
250    INCLUDE(CAM_INTF_PARM_SATURATION,               int32_t,                     1);
251    INCLUDE(CAM_INTF_PARM_BRIGHTNESS,               int32_t,                     1);
252    INCLUDE(CAM_INTF_PARM_WHITE_BALANCE,            int32_t,                     1);
253    INCLUDE(CAM_INTF_PARM_ISO,                      int32_t,                     1);
254    INCLUDE(CAM_INTF_PARM_ZOOM,                     int32_t,                     1);
255    INCLUDE(CAM_INTF_PARM_ANTIBANDING,              int32_t,                     1);
256    INCLUDE(CAM_INTF_PARM_EFFECT,                   int32_t,                     1);
257    INCLUDE(CAM_INTF_PARM_FPS_RANGE,                cam_fps_range_t,             1);
258    INCLUDE(CAM_INTF_PARM_EXPOSURE_COMPENSATION,    int32_t,                     1);
259    INCLUDE(CAM_INTF_PARM_LED_MODE,                 int32_t,                     1);
260    INCLUDE(CAM_INTF_PARM_ROLLOFF,                  int32_t,                     1);
261    INCLUDE(CAM_INTF_PARM_MODE,                     int32_t,                     1);
262    INCLUDE(CAM_INTF_PARM_AEC_ALGO_TYPE,            int32_t,                     1);
263    INCLUDE(CAM_INTF_PARM_FOCUS_ALGO_TYPE,          int32_t,                     1);
264    INCLUDE(CAM_INTF_PARM_AEC_ROI,                  cam_set_aec_roi_t,           1);
265    INCLUDE(CAM_INTF_PARM_AF_ROI,                   cam_roi_info_t,              1);
266    INCLUDE(CAM_INTF_PARM_FOCUS_MODE,               int32_t,                     1);
267    INCLUDE(CAM_INTF_PARM_BESTSHOT_MODE,            int32_t,                     1);
268    INCLUDE(CAM_INTF_PARM_SCE_FACTOR,               int32_t,                     1);
269    INCLUDE(CAM_INTF_PARM_FD,                       cam_fd_set_parm_t,           1);
270    INCLUDE(CAM_INTF_PARM_AEC_LOCK,                 int32_t,                     1);
271    INCLUDE(CAM_INTF_PARM_AWB_LOCK,                 int32_t,                     1);
272    INCLUDE(CAM_INTF_PARM_MCE,                      int32_t,                     1);
273    INCLUDE(CAM_INTF_PARM_HFR,                      int32_t,                     1);
274    INCLUDE(CAM_INTF_PARM_REDEYE_REDUCTION,         int32_t,                     1);
275    INCLUDE(CAM_INTF_PARM_WAVELET_DENOISE,          cam_denoise_param_t,         1);
276    INCLUDE(CAM_INTF_PARM_HISTOGRAM,                int32_t,                     1);
277    INCLUDE(CAM_INTF_PARM_ASD_ENABLE,               int32_t,                     1);
278    INCLUDE(CAM_INTF_PARM_RECORDING_HINT,           int32_t,                     1);
279    INCLUDE(CAM_INTF_PARM_DIS_ENABLE,               int32_t,                     1);
280    INCLUDE(CAM_INTF_PARM_HDR,                      cam_exp_bracketing_t,        1);
281    INCLUDE(CAM_INTF_PARM_SET_BUNDLE,               cam_bundle_config_t,         1);
282    INCLUDE(CAM_INTF_PARM_FRAMESKIP,                int32_t,                     1);
283    INCLUDE(CAM_INTF_PARM_ZSL_MODE,                 int32_t,                     1);
284    INCLUDE(CAM_INTF_PARM_HDR_NEED_1X,              int32_t,                     1);
285    INCLUDE(CAM_INTF_PARM_LOCK_CAF,                 int32_t,                     1);
286    INCLUDE(CAM_INTF_PARM_VIDEO_HDR,                int32_t,                     1);
287} parm_type_t;
288
289/****************************DO NOT MODIFY BELOW THIS LINE!!!!*********************/
290
291typedef struct {
292    parm_type_t data;
293    uint8_t next_flagged_entry;
294} parm_entry_type_t;
295
296typedef struct {
297    uint8_t first_flagged_entry;
298    parm_entry_type_t entry[CAM_INTF_PARM_MAX];
299} parm_buffer_t;
300
301#endif /* __QCAMERA_INTF_H__ */
302