cam_types.h revision 3f92cbaa5bde0dba1e4a9a67e5aa60fc0af2dfa0
1/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above
9 *       copyright notice, this list of conditions and the following
10 *       disclaimer in the documentation and/or other materials provided
11 *       with the distribution.
12 *     * Neither the name of The Linux Foundation nor the names of its
13 *       contributors may be used to endorse or promote products derived
14 *       from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#ifndef __QCAMERA_TYPES_H__
31#define __QCAMERA_TYPES_H__
32
33#include <stdint.h>
34#include <pthread.h>
35#include <inttypes.h>
36#include <media/msmb_camera.h>
37
38#define CAM_MAX_NUM_BUFS_PER_STREAM 24
39
40#define CEILING32(X) (((X) + 0x0001F) & 0xFFFFFFE0)
41#define CEILING16(X) (((X) + 0x000F) & 0xFFF0)
42#define CEILING4(X)  (((X) + 0x0003) & 0xFFFC)
43#define CEILING2(X)  (((X) + 0x0001) & 0xFFFE)
44
45#define MAX_ZOOMS_CNT 64
46#define MAX_SIZES_CNT 24
47#define MAX_EXP_BRACKETING_LENGTH 32
48#define MAX_ROI 5
49#define MAX_STREAM_NUM_IN_BUNDLE 4
50#define MAX_NUM_STREAMS          8
51
52typedef enum {
53    CAM_STATUS_SUCCESS,       /* Operation Succeded */
54    CAM_STATUS_FAILED,        /* Failure in doing operation */
55    CAM_STATUS_INVALID_PARM,  /* Inavlid parameter provided */
56    CAM_STATUS_NOT_SUPPORTED, /* Parameter/operation not supported */
57    CAM_STATUS_ACCEPTED,      /* Parameter accepted */
58    CAM_STATUS_MAX,
59} cam_status_t;
60
61typedef enum {
62    CAM_POSITION_BACK,
63    CAM_POSITION_FRONT
64} cam_position_t;
65
66typedef enum {
67    CAM_FORMAT_JPEG = 0,
68    CAM_FORMAT_YUV_420_NV12 = 1,
69    CAM_FORMAT_YUV_420_NV21,
70    CAM_FORMAT_YUV_420_NV21_ADRENO,
71    CAM_FORMAT_YUV_420_YV12,
72    CAM_FORMAT_YUV_422_NV16,
73    CAM_FORMAT_YUV_422_NV61,
74
75    /* Please note below are the defintions for raw image.
76     * Any format other than raw image format should be declared
77     * before this line!!!!!!!!!!!!! */
78
79    /* Note: For all raw formats, each scanline needs to be 16 bytes aligned */
80
81    /* Packed YUV/YVU raw format, 16 bpp: 8 bits Y and 8 bits UV.
82     * U and V are interleaved with Y: YUYV or YVYV */
83    CAM_FORMAT_YUV_RAW_8BIT_YUYV,
84    CAM_FORMAT_YUV_RAW_8BIT_YVYU,
85    CAM_FORMAT_YUV_RAW_8BIT_UYVY,
86    CAM_FORMAT_YUV_RAW_8BIT_VYUY,
87
88    /* QCOM RAW formats where data is packed into 64bit word.
89     * 8BPP: 1 64-bit word contains 8 pixels p0 - p7, where p0 is
90     *       stored at LSB.
91     * 10BPP: 1 64-bit word contains 6 pixels p0 - p5, where most
92     *       significant 4 bits are set to 0. P0 is stored at LSB.
93     * 12BPP: 1 64-bit word contains 5 pixels p0 - p4, where most
94     *       significant 4 bits are set to 0. P0 is stored at LSB. */
95    CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG,
96    CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GRBG,
97    CAM_FORMAT_BAYER_QCOM_RAW_8BPP_RGGB,
98    CAM_FORMAT_BAYER_QCOM_RAW_8BPP_BGGR,
99    CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG,
100    CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GRBG,
101    CAM_FORMAT_BAYER_QCOM_RAW_10BPP_RGGB,
102    CAM_FORMAT_BAYER_QCOM_RAW_10BPP_BGGR,
103    CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG,
104    CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GRBG,
105    CAM_FORMAT_BAYER_QCOM_RAW_12BPP_RGGB,
106    CAM_FORMAT_BAYER_QCOM_RAW_12BPP_BGGR,
107    /* MIPI RAW formats based on MIPI CSI-2 specifiction.
108     * 8BPP: Each pixel occupies one bytes, starting at LSB.
109     *       Output with of image has no restrictons.
110     * 10BPP: Four pixels are held in every 5 bytes. The output
111     *       with of image must be a multiple of 4 pixels.
112     * 12BPP: Two pixels are held in every 3 bytes. The output
113     *       width of image must be a multiple of 2 pixels. */
114    CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG,
115    CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GRBG,
116    CAM_FORMAT_BAYER_MIPI_RAW_8BPP_RGGB,
117    CAM_FORMAT_BAYER_MIPI_RAW_8BPP_BGGR,
118    CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG,
119    CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GRBG,
120    CAM_FORMAT_BAYER_MIPI_RAW_10BPP_RGGB,
121    CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR,
122    CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG,
123    CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GRBG,
124    CAM_FORMAT_BAYER_MIPI_RAW_12BPP_RGGB,
125    CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR,
126    /* Ideal raw formats where image data has gone through black
127     * correction, lens rolloff, demux/channel gain, bad pixel
128     * correction, and ABF.
129     * Ideal raw formats could output any of QCOM_RAW and MIPI_RAW
130     * formats, plus plain8 8bbp, plain16 800, plain16 10bpp, and
131     * plain 16 12bpp */
132    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GBRG,
133    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GRBG,
134    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_RGGB,
135    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_BGGR,
136    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GBRG,
137    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GRBG,
138    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_RGGB,
139    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_BGGR,
140    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GBRG,
141    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GRBG,
142    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_RGGB,
143    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_BGGR,
144    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GBRG,
145    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GRBG,
146    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_RGGB,
147    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_BGGR,
148    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GBRG,
149    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GRBG,
150    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_RGGB,
151    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_BGGR,
152    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GBRG,
153    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GRBG,
154    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_RGGB,
155    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_BGGR,
156    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GBRG,
157    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GRBG,
158    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_RGGB,
159    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_BGGR,
160    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG,
161    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GRBG,
162    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_RGGB,
163    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_BGGR,
164    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GBRG,
165    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GRBG,
166    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_RGGB,
167    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_BGGR,
168    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GBRG,
169    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GRBG,
170    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_RGGB,
171    CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR,
172
173    CAM_FORMAT_MAX
174} cam_format_t;
175
176typedef enum {
177    CAM_STREAM_TYPE_DEFAULT,       /* default stream type */
178    CAM_STREAM_TYPE_PREVIEW,       /* preview */
179    CAM_STREAM_TYPE_POSTVIEW,      /* postview */
180    CAM_STREAM_TYPE_SNAPSHOT,      /* snapshot */
181    CAM_STREAM_TYPE_VIDEO,         /* video */
182    CAM_STREAM_TYPE_RAW,           /* raw dump from camif */
183    CAM_STREAM_TYPE_METADATA,      /* meta data */
184    CAM_STREAM_TYPE_OFFLINE_PROC,  /* offline process */
185    CAM_STREAM_TYPE_MAX,
186} cam_stream_type_t;
187
188typedef enum {
189    CAM_PAD_NONE = 1,
190    CAM_PAD_TO_2 = 2,
191    CAM_PAD_TO_4 = 4,
192    CAM_PAD_TO_WORD = CAM_PAD_TO_4,
193    CAM_PAD_TO_8 = 8,
194    CAM_PAD_TO_16 = 16,
195    CAM_PAD_TO_32 = 32,
196    CAM_PAD_TO_64 = 64,
197    CAM_PAD_TO_1K = 1024,
198    CAM_PAD_TO_2K = 2048,
199    CAM_PAD_TO_4K = 4096,
200    CAM_PAD_TO_8K = 8192
201} cam_pad_format_t;
202
203typedef enum {
204    /* followings are per camera */
205    CAM_MAPPING_BUF_TYPE_CAPABILITY,  /* mapping camera capability buffer */
206    CAM_MAPPING_BUF_TYPE_PARM_BUF,    /* mapping parameters buffer */
207
208    /* followings are per stream */
209    CAM_MAPPING_BUF_TYPE_STREAM_BUF,        /* mapping stream buffers */
210    CAM_MAPPING_BUF_TYPE_STREAM_INFO,       /* mapping stream information buffer */
211    CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF, /* mapping offline process input buffer */
212    CAM_MAPPING_BUF_TYPE_MAX
213} cam_mapping_buf_type;
214
215typedef struct {
216    cam_mapping_buf_type type;
217    uint32_t stream_id;   /* stream id: valid if STREAM_BUF */
218    uint32_t frame_idx;   /* frame index: valid if type is STREAM_BUF */
219    int32_t plane_idx;    /* planner index. valid if type is STREAM_BUF.
220                           * -1 means all planners shanre the same fd;
221                           * otherwise, each planner has its own fd */
222    unsigned long cookie; /* could be job_id(uint32_t) to identify mapping job */
223    int fd;               /* origin fd */
224    uint32_t size;        /* size of the buffer */
225} cam_buf_map_type;
226
227typedef struct {
228    cam_mapping_buf_type type;
229    uint32_t stream_id;   /* stream id: valid if STREAM_BUF */
230    uint32_t frame_idx;   /* frame index: valid if STREAM_BUF or HIST_BUF */
231    int32_t plane_idx;    /* planner index. valid if type is STREAM_BUF.
232                           * -1 means all planners shanre the same fd;
233                           * otherwise, each planner has its own fd */
234    unsigned long cookie; /* could be job_id(uint32_t) to identify unmapping job */
235} cam_buf_unmap_type;
236
237typedef enum {
238    CAM_MAPPING_TYPE_FD_MAPPING,
239    CAM_MAPPING_TYPE_FD_UNMAPPING,
240    CAM_MAPPING_TYPE_MAX
241} cam_mapping_type;
242
243typedef struct {
244    cam_mapping_type msg_type;
245    union {
246        cam_buf_map_type buf_map;
247        cam_buf_unmap_type buf_unmap;
248    } payload;
249} cam_sock_packet_t;
250
251typedef enum {
252    CAM_MODE_2D = (1<<0),
253    CAM_MODE_3D = (1<<1)
254} cam_mode_t;
255
256typedef struct {
257    uint32_t len;
258    uint32_t y_offset;
259    uint32_t cbcr_offset;
260} cam_sp_len_offset_t;
261
262typedef struct{
263    uint32_t len;
264    uint32_t offset;
265    int32_t offset_x;
266    int32_t offset_y;
267    int32_t stride;
268    int32_t scanline;
269} cam_mp_len_offset_t;
270
271typedef struct {
272    uint32_t width_padding;
273    uint32_t height_padding;
274    uint32_t plane_padding;
275} cam_padding_info_t;
276
277typedef struct {
278    int num_planes;
279    union {
280        cam_sp_len_offset_t sp;
281        cam_mp_len_offset_t mp[VIDEO_MAX_PLANES];
282    };
283    uint32_t frame_len;
284} cam_frame_len_offset_t;
285
286typedef struct {
287    int32_t width;
288    int32_t height;
289} cam_dimension_t;
290
291typedef struct {
292    cam_frame_len_offset_t plane_info;
293} cam_stream_buf_plane_info_t;
294
295typedef struct {
296    float min_fps;
297    float max_fps;
298} cam_fps_range_t;
299
300typedef enum {
301    CAM_HFR_MODE_OFF,
302    CAM_HFR_MODE_60FPS,
303    CAM_HFR_MODE_90FPS,
304    CAM_HFR_MODE_120FPS,
305    CAM_HFR_MODE_150FPS,
306    CAM_HFR_MODE_MAX
307} cam_hfr_mode_t;
308
309typedef struct {
310    cam_hfr_mode_t mode;
311    cam_dimension_t dim;
312    uint8_t frame_skip;
313    uint8_t livesnapshot_sizes_tbl_cnt;                     /* livesnapshot sizes table size */
314    cam_dimension_t livesnapshot_sizes_tbl[MAX_SIZES_CNT];  /* livesnapshot sizes table */
315} cam_hfr_info_t;
316
317typedef enum {
318    CAM_WB_MODE_AUTO,
319    CAM_WB_MODE_CUSTOM,
320    CAM_WB_MODE_INCANDESCENT,
321    CAM_WB_MODE_FLUORESCENT,
322    CAM_WB_MODE_WARM_FLUORESCENT,
323    CAM_WB_MODE_DAYLIGHT,
324    CAM_WB_MODE_CLOUDY_DAYLIGHT,
325    CAM_WB_MODE_TWILIGHT,
326    CAM_WB_MODE_SHADE,
327    CAM_WB_MODE_MAX
328} cam_wb_mode_type;
329
330typedef enum {
331    CAM_ANTIBANDING_MODE_OFF,
332    CAM_ANTIBANDING_MODE_60HZ,
333    CAM_ANTIBANDING_MODE_50HZ,
334    CAM_ANTIBANDING_MODE_AUTO,
335    CAM_ANTIBANDING_MODE_AUTO_50HZ,
336    CAM_ANTIBANDING_MODE_AUTO_60HZ,
337    CAM_ANTIBANDING_MODE_MAX,
338} cam_antibanding_mode_type;
339
340/* Enum Type for different ISO Mode supported */
341typedef enum {
342    CAM_ISO_MODE_AUTO,
343    CAM_ISO_MODE_DEBLUR,
344    CAM_ISO_MODE_100,
345    CAM_ISO_MODE_200,
346    CAM_ISO_MODE_400,
347    CAM_ISO_MODE_800,
348    CAM_ISO_MODE_1600,
349    CAM_ISO_MODE_MAX
350} cam_iso_mode_type;
351
352typedef enum {
353    CAM_AEC_MODE_FRAME_AVERAGE,
354    CAM_AEC_MODE_CENTER_WEIGHTED,
355    CAM_AEC_MODE_SPOT_METERING,
356    CAM_AEC_MODE_SMART_METERING,
357    CAM_AEC_MODE_USER_METERING,
358    CAM_AEC_MODE_SPOT_METERING_ADV,
359    CAM_AEC_MODE_CENTER_WEIGHTED_ADV,
360    CAM_AEC_MODE_MAX
361} cam_auto_exposure_mode_type;
362
363typedef enum {
364    CAM_FOCUS_ALGO_AUTO,
365    CAM_FOCUS_ALGO_SPOT,
366    CAM_FOCUS_ALGO_CENTER_WEIGHTED,
367    CAM_FOCUS_ALGO_AVERAGE,
368    CAM_FOCUS_ALGO_MAX
369} cam_focus_algorithm_type;
370
371/* Auto focus mode */
372typedef enum {
373    CAM_FOCUS_MODE_AUTO,
374    CAM_FOCUS_MODE_INFINITY,
375    CAM_FOCUS_MODE_MACRO,
376    CAM_FOCUS_MODE_FIXED,
377    CAM_FOCUS_MODE_EDOF,
378    CAM_FOCUS_MODE_CONTINOUS_VIDEO,
379    CAM_FOCUS_MODE_CONTINOUS_PICTURE,
380    CAM_FOCUS_MODE_MAX
381} cam_focus_mode_type;
382
383typedef enum {
384    CAM_SCENE_MODE_OFF,
385    CAM_SCENE_MODE_AUTO,
386    CAM_SCENE_MODE_LANDSCAPE,
387    CAM_SCENE_MODE_SNOW,
388    CAM_SCENE_MODE_BEACH,
389    CAM_SCENE_MODE_SUNSET,
390    CAM_SCENE_MODE_NIGHT,
391    CAM_SCENE_MODE_PORTRAIT,
392    CAM_SCENE_MODE_BACKLIGHT,
393    CAM_SCENE_MODE_SPORTS,
394    CAM_SCENE_MODE_ANTISHAKE,
395    CAM_SCENE_MODE_FLOWERS,
396    CAM_SCENE_MODE_CANDLELIGHT,
397    CAM_SCENE_MODE_FIREWORKS,
398    CAM_SCENE_MODE_PARTY,
399    CAM_SCENE_MODE_NIGHT_PORTRAIT,
400    CAM_SCENE_MODE_THEATRE,
401    CAM_SCENE_MODE_ACTION,
402    CAM_SCENE_MODE_AR,
403    CAM_SCENE_MODE_MAX
404} cam_scene_mode_type;
405
406typedef enum {
407    CAM_EFFECT_MODE_OFF,
408    CAM_EFFECT_MODE_MONO,
409    CAM_EFFECT_MODE_NEGATIVE,
410    CAM_EFFECT_MODE_SOLARIZE,
411    CAM_EFFECT_MODE_SEPIA,
412    CAM_EFFECT_MODE_POSTERIZE,
413    CAM_EFFECT_MODE_WHITEBOARD,
414    CAM_EFFECT_MODE_BLACKBOARD,
415    CAM_EFFECT_MODE_AQUA,
416    CAM_EFFECT_MODE_EMBOSS,
417    CAM_EFFECT_MODE_SKETCH,
418    CAM_EFFECT_MODE_NEON,
419    CAM_EFFECT_MODE_MAX
420} cam_effect_mode_type;
421
422typedef enum {
423    CAM_FLASH_MODE_OFF,
424    CAM_FLASH_MODE_AUTO,
425    CAM_FLASH_MODE_ON,
426    CAM_FLASH_MODE_TORCH,
427    CAM_FLASH_MODE_MAX
428} cam_flash_mode_t;
429
430typedef struct  {
431    int32_t left;
432    int32_t top;
433    int32_t width;
434    int32_t height;
435} cam_rect_t;
436
437typedef struct  {
438    cam_rect_t rect;
439    int32_t weight; /* weight of the area, valid for focusing/metering areas */
440} cam_area_t;
441
442typedef enum {
443    CAM_STREAMING_MODE_CONTINUOUS, /* continous streaming */
444    CAM_STREAMING_MODE_BURST,      /* burst streaming */
445    CAM_STREAMING_MODE_MAX
446} cam_streaming_mode_t;
447
448#define CAM_REPROCESS_MASK_TYPE_WNR (1<<0)
449
450/* event from server */
451typedef enum {
452    CAM_EVENT_TYPE_MAP_UNMAP_DONE  = (1<<0),
453    CAM_EVENT_TYPE_AUTO_FOCUS_DONE = (1<<1),
454    CAM_EVENT_TYPE_ZOOM_DONE       = (1<<2),
455    CAM_EVENT_TYPE_MAX
456} cam_event_type_t;
457
458typedef enum {
459    CAM_EXP_BRACKETING_OFF,
460    CAM_EXP_BRACKETING_ON
461} cam_bracket_mode;
462
463typedef struct {
464    cam_bracket_mode mode;
465    char values[MAX_EXP_BRACKETING_LENGTH];  /* user defined values */
466} cam_exp_bracketing_t;
467
468typedef enum {
469    CAM_AEC_ROI_OFF,
470    CAM_AEC_ROI_ON
471} cam_aec_roi_ctrl_t;
472
473typedef enum {
474    CAM_AEC_ROI_BY_INDEX,
475    CAM_AEC_ROI_BY_COORDINATE,
476} cam_aec_roi_type_t;
477
478typedef struct {
479    uint32_t x;
480    uint32_t y;
481} cam_coordinate_type_t;
482
483typedef struct {
484    cam_aec_roi_ctrl_t aec_roi_enable;
485    cam_aec_roi_type_t aec_roi_type;
486    union {
487        cam_coordinate_type_t coordinate[MAX_ROI];
488        uint32_t aec_roi_idx[MAX_ROI];
489    } cam_aec_roi_position;
490} cam_set_aec_roi_t;
491
492typedef struct {
493    uint32_t frm_id;
494    uint8_t num_roi;
495    cam_rect_t roi[MAX_ROI];
496    int32_t weight[MAX_ROI];
497    uint8_t is_multiwindow;
498} cam_roi_info_t;
499
500typedef enum {
501    CAM_WAVELET_DENOISE_YCBCR_PLANE,
502    CAM_WAVELET_DENOISE_CBCR_ONLY,
503    CAM_WAVELET_DENOISE_STREAMLINE_YCBCR,
504    CAM_WAVELET_DENOISE_STREAMLINED_CBCR
505} cam_denoise_process_type_t;
506
507typedef struct {
508    int denoise_enable;
509    cam_denoise_process_type_t process_plates;
510} cam_denoise_param_t;
511
512#define CAM_FACE_PROCESS_MASK_DETECTION    (1<<0)
513#define CAM_FACE_PROCESS_MASK_RECOGNITION  (1<<1)
514typedef struct {
515    int fd_mode;               /* mask of face process */
516    int num_fd;
517} cam_fd_set_parm_t;
518
519typedef struct {
520    int8_t face_id;            /* unique id for face tracking within view unless view changes */
521    int8_t score;              /* score of confidence (0, -100) */
522    cam_rect_t face_boundary;  /* boundary of face detected */
523    cam_coordinate_type_t left_eye_center;  /* coordinate of center of left eye */
524    cam_coordinate_type_t right_eye_center; /* coordinate of center of right eye */
525    cam_coordinate_type_t mouth_center;     /* coordinate of center of mouth */
526    uint8_t smile_degree;      /* smile degree (0, -100) */
527    uint8_t smile_confidence;  /* smile confidence (0, 100) */
528    uint8_t face_recognised;   /* if face is recognised */
529    int8_t gaze_angle;         /* -90 -45 0 45 90 for head left to rigth tilt */
530    int8_t updown_dir;         /* up down direction (-90, 90) */
531    int8_t leftright_dir;      /* left right direction (-90, 90) */
532    int8_t roll_dir;           /* roll direction (-90, 90) */
533    int8_t left_right_gaze;    /* left right gaze degree (-50, 50) */
534    int8_t top_bottom_gaze;    /* up down gaze degree (-50, 50) */
535    uint8_t blink_detected;    /* if blink is detected */
536    uint8_t left_blink;        /* left eye blink degeree (0, -100) */
537    uint8_t right_blink;       /* right eye blink degree (0, - 100) */
538} cam_face_detection_info_t;
539
540typedef struct {
541    uint32_t frame_id;                         /* frame index of which faces are detected */
542    uint8_t num_faces_detected;                /* number of faces detected */
543    cam_face_detection_info_t faces[MAX_ROI];  /* detailed information of faces detected */
544} cam_face_detection_data_t;
545
546#define CAM_HISTOGRAM_STATS_SIZE 256
547typedef struct {
548    uint32_t max_hist_value;
549    uint32_t hist_buf[CAM_HISTOGRAM_STATS_SIZE]; /* buf holding histogram stats data */
550} cam_histogram_data_t;
551
552typedef struct {
553    cam_histogram_data_t r_stats;
554    cam_histogram_data_t b_stats;
555    cam_histogram_data_t gr_stats;
556    cam_histogram_data_t gb_stats;
557} cam_bayer_hist_stats_t;
558
559typedef enum {
560    CAM_HISTOGRAM_TYPE_BAYER,
561    CAM_HISTOGRAM_TYPE_YUV
562} cam_histogram_type_t;
563
564typedef struct {
565    cam_histogram_type_t type;
566    union {
567        cam_bayer_hist_stats_t bayer_stats;
568        cam_histogram_data_t yuv_stats;
569    };
570} cam_hist_stats_t;
571
572enum cam_focus_distance_index{
573  CAM_FOCUS_DISTANCE_NEAR_INDEX,  /* 0 */
574  CAM_FOCUS_DISTANCE_OPTIMAL_INDEX,
575  CAM_FOCUS_DISTANCE_FAR_INDEX,
576  CAM_FOCUS_DISTANCE_MAX_INDEX
577};
578
579typedef struct {
580  float focus_distance[CAM_FOCUS_DISTANCE_MAX_INDEX];
581} cam_focus_distances_info_t;
582
583/* Different autofocus cycle when calling do_autoFocus
584 * CAM_AF_COMPLETE_EXISTING_SWEEP: Complete existing sweep
585 * if one is ongoing, and lock.
586 * CAM_AF_DO_ONE_FULL_SWEEP: Do one full sweep, regardless
587 * of the current state, and lock.
588 * CAM_AF_START_CONTINUOUS_SWEEP: Start continous sweep.
589 * After do_autoFocus, HAL receives an event: CAM_AF_FOCUSED,
590 * or CAM_AF_NOT_FOCUSED.
591 * cancel_autoFocus stops any lens movement.
592 * Each do_autoFocus call only produces 1 FOCUSED/NOT_FOCUSED
593 * event, not both.
594 */
595typedef enum {
596    CAM_AF_COMPLETE_EXISTING_SWEEP,
597    CAM_AF_DO_ONE_FULL_SWEEP,
598    CAM_AF_START_CONTINUOUS_SWEEP
599} cam_autofocus_cycle_t;
600
601typedef enum {
602    CAM_AF_SCANNING,
603    CAM_AF_FOCUSED,
604    CAM_AF_NOT_FOCUSED
605} cam_autofocus_state_t;
606
607typedef struct {
608    cam_autofocus_state_t focus_state;           /* state of focus */
609    cam_focus_distances_info_t focus_dist;       /* focus distance */
610} cam_auto_focus_data_t;
611
612typedef struct {
613    uint32_t stream_id;
614    cam_rect_t crop;
615} cam_stream_crop_info_t;
616
617typedef struct {
618    uint8_t num_of_streams;
619    cam_stream_crop_info_t crop_info[MAX_NUM_STREAMS];
620} cam_crop_data_t;
621
622typedef enum {
623    DO_NOT_NEED_FUTURE_FRAME,
624    NEED_FUTURE_FRAME,
625} cam_prep_snapshot_state_t;
626
627typedef struct {
628    uint32_t min_frame_idx;
629    uint32_t max_frame_idx;
630} cam_frame_idx_range_t;
631
632typedef  struct {
633    uint8_t is_stats_valid;               /* if histgram data is valid */
634    cam_hist_stats_t stats_data;          /* histogram data */
635
636    uint8_t is_faces_valid;               /* if face detection data is valid */
637    cam_face_detection_data_t faces_data; /* face detection result */
638
639    uint8_t is_focus_valid;               /* if focus data is valid */
640    cam_auto_focus_data_t focus_data;     /* focus data */
641
642    uint8_t is_crop_valid;                /* if crop data is valid */
643    cam_crop_data_t crop_data;            /* crop data */
644
645    uint8_t is_prep_snapshot_done_valid;  /* if prep snapshot done is valid */
646    cam_prep_snapshot_state_t prep_snapshot_done_state;  /* prepare snapshot done state */
647
648    /* if good frame idx range is valid */
649    uint8_t is_good_frame_idx_range_valid;
650    /* good frame idx range, make sure:
651     * 1. good_frame_idx_range.min_frame_idx > current_frame_idx
652     * 2. good_frame_idx_range.min_frame_idx - current_frame_idx < 100 */
653    cam_frame_idx_range_t good_frame_idx_range;
654
655} cam_metadata_info_t;
656
657typedef enum {
658    CAM_INTF_PARM_QUERY_FLASH4SNAP,
659    CAM_INTF_PARM_EXPOSURE,
660    CAM_INTF_PARM_SHARPNESS,
661    CAM_INTF_PARM_CONTRAST,
662    CAM_INTF_PARM_SATURATION,
663    CAM_INTF_PARM_BRIGHTNESS,
664    CAM_INTF_PARM_WHITE_BALANCE,
665    CAM_INTF_PARM_ISO,
666    CAM_INTF_PARM_ZOOM,
667    CAM_INTF_PARM_ANTIBANDING,
668    CAM_INTF_PARM_EFFECT,
669    CAM_INTF_PARM_FPS_RANGE,
670    CAM_INTF_PARM_EXPOSURE_COMPENSATION,
671    CAM_INTF_PARM_LED_MODE,
672    CAM_INTF_PARM_ROLLOFF,
673    CAM_INTF_PARM_MODE,             /* camera mode */
674    CAM_INTF_PARM_AEC_ALGO_TYPE,    /* auto exposure algorithm */
675    CAM_INTF_PARM_FOCUS_ALGO_TYPE,  /* focus algorithm */
676    CAM_INTF_PARM_AEC_ROI,
677    CAM_INTF_PARM_AF_ROI,
678    CAM_INTF_PARM_FOCUS_MODE,
679    CAM_INTF_PARM_BESTSHOT_MODE,
680    CAM_INTF_PARM_SCE_FACTOR,
681    CAM_INTF_PARM_FD,
682    CAM_INTF_PARM_AEC_LOCK,
683    CAM_INTF_PARM_AWB_LOCK,
684    CAM_INTF_PARM_MCE,
685    CAM_INTF_PARM_HFR,
686    CAM_INTF_PARM_REDEYE_REDUCTION,
687    CAM_INTF_PARM_WAVELET_DENOISE,
688    CAM_INTF_PARM_HISTOGRAM,
689    CAM_INTF_PARM_ASD_ENABLE,
690    CAM_INTF_PARM_RECORDING_HINT,
691    CAM_INTF_PARM_DIS_ENABLE,
692    CAM_INTF_PARM_HDR,
693    CAM_INTF_PARM_SET_BUNDLE,
694    CAM_INTF_PARM_FRAMESKIP,
695    CAM_INTF_PARM_ZSL_MODE,  /* indicating if it's running in ZSL mode */
696    CAM_INTF_PARM_HDR_NEED_1X, /* if HDR needs 1x output */
697    CAM_INTF_PARM_LOCK_CAF,
698    CAM_INTF_PARM_VIDEO_HDR,
699    CAM_INTF_PARM_MAX
700} cam_intf_parm_type_t;
701
702typedef struct {
703    int32_t min_value;
704    int32_t max_value;
705    int32_t def_value;
706    int32_t step;
707} cam_control_range_t;
708
709#define CAM_QCOM_FEATURE_FACE_DETECTION (1<<0)
710#define CAM_QCOM_FEATURE_DENOISE2D      (1<<1)
711#define CAM_QCOM_FEATURE_CROP           (1<<2)
712#define CAM_QCOM_FEATURE_ROTATION       (1<<3)
713#define CAM_QCOM_FEATURE_FLIP           (1<<4)
714#define CAM_QCOM_FEATURE_HDR            (1<<5)
715#define CAM_QCOM_FEATURE_REGISTER_FACE  (1<<6)
716#define CAM_QCOM_FEATURE_SHARPNESS      (1<<7)
717#define CAM_QCOM_FEATURE_VIDEO_HDR      (1<<8)
718
719// Counter clock wise
720typedef enum {
721    ROTATE_0 = 1<<0,
722    ROTATE_90 = 1<<1,
723    ROTATE_180 = 1<<2,
724    ROTATE_270 = 1<<3,
725} cam_rotation_t;
726
727typedef enum {
728    FLIP_H = 1<<0,
729    FLIP_V = 1<<1,
730} cam_flip_t;
731
732typedef struct {
733    uint32_t bundle_id;                            /* bundle id */
734    uint8_t num_of_streams;                        /* number of streams in the bundle */
735    uint32_t stream_ids[MAX_STREAM_NUM_IN_BUNDLE]; /* array of stream ids to be bundled */
736} cam_bundle_config_t;
737
738typedef enum {
739    CAM_ONLINE_REPROCESS_TYPE,    /* online reprocess, frames from running streams */
740    CAM_OFFLINE_REPROCESS_TYPE,   /* offline reprocess, frames from external source */
741} cam_reprocess_type_enum_t;
742
743typedef struct {
744    /* reprocess feature mask */
745    uint32_t feature_mask;
746
747    /* individual setting for features to be reprocessed */
748    cam_denoise_param_t denoise2d;
749    cam_rect_t input_crop;
750    cam_rotation_t rotation;
751    uint32_t flip;
752    int32_t sharpness;
753    int32_t hdr_need_1x; /* when CAM_QCOM_FEATURE_HDR enabled, indicate if 1x is needed for output */
754} cam_pp_feature_config_t;
755
756typedef struct {
757    uint32_t input_stream_id;
758    /* input source stream type */
759    cam_stream_type_t input_stream_type;
760} cam_pp_online_src_config_t;
761
762typedef struct {
763    /* image format */
764    cam_format_t input_fmt;
765
766    /* image dimension */
767    cam_dimension_t input_dim;
768
769    /* buffer plane information, will be calc based on stream_type, fmt,
770       dim, and padding_info(from stream config). Info including:
771       offset_x, offset_y, stride, scanline, plane offset */
772    cam_stream_buf_plane_info_t input_buf_planes;
773
774    /* number of input reprocess buffers */
775    uint8_t num_of_bufs;
776} cam_pp_offline_src_config_t;
777
778/* reprocess stream input configuration */
779typedef struct {
780    /* input source config */
781    cam_reprocess_type_enum_t pp_type;
782    union {
783        cam_pp_online_src_config_t online;
784        cam_pp_offline_src_config_t offline;
785    };
786
787    /* pp feature config */
788    cam_pp_feature_config_t pp_feature_config;
789} cam_stream_reproc_config_t;
790
791#endif /* __QCAMERA_TYPES_H__ */
792