cam_types.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_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} cam_hfr_info_t;
314
315typedef enum {
316    CAM_WB_MODE_AUTO,
317    CAM_WB_MODE_CUSTOM,
318    CAM_WB_MODE_INCANDESCENT,
319    CAM_WB_MODE_FLUORESCENT,
320    CAM_WB_MODE_WARM_FLUORESCENT,
321    CAM_WB_MODE_DAYLIGHT,
322    CAM_WB_MODE_CLOUDY_DAYLIGHT,
323    CAM_WB_MODE_TWILIGHT,
324    CAM_WB_MODE_SHADE,
325    CAM_WB_MODE_MAX
326} cam_wb_mode_type;
327
328typedef enum {
329    CAM_ANTIBANDING_MODE_OFF,
330    CAM_ANTIBANDING_MODE_60HZ,
331    CAM_ANTIBANDING_MODE_50HZ,
332    CAM_ANTIBANDING_MODE_AUTO,
333    CAM_ANTIBANDING_MODE_AUTO_50HZ,
334    CAM_ANTIBANDING_MODE_AUTO_60HZ,
335    CAM_ANTIBANDING_MODE_MAX,
336} cam_antibanding_mode_type;
337
338/* Enum Type for different ISO Mode supported */
339typedef enum {
340    CAM_ISO_MODE_AUTO,
341    CAM_ISO_MODE_DEBLUR,
342    CAM_ISO_MODE_100,
343    CAM_ISO_MODE_200,
344    CAM_ISO_MODE_400,
345    CAM_ISO_MODE_800,
346    CAM_ISO_MODE_1600,
347    CAM_ISO_MODE_MAX
348} cam_iso_mode_type;
349
350typedef enum {
351    CAM_AEC_MODE_FRAME_AVERAGE,
352    CAM_AEC_MODE_CENTER_WEIGHTED,
353    CAM_AEC_MODE_SPOT_METERING,
354    CAM_AEC_MODE_SMART_METERING,
355    CAM_AEC_MODE_USER_METERING,
356    CAM_AEC_MODE_SPOT_METERING_ADV,
357    CAM_AEC_MODE_CENTER_WEIGHTED_ADV,
358    CAM_AEC_MODE_MAX
359} cam_auto_exposure_mode_type;
360
361typedef enum {
362    CAM_FOCUS_ALGO_AUTO,
363    CAM_FOCUS_ALGO_SPOT,
364    CAM_FOCUS_ALGO_CENTER_WEIGHTED,
365    CAM_FOCUS_ALGO_AVERAGE,
366    CAM_FOCUS_ALGO_MAX
367} cam_focus_algorithm_type;
368
369/* Auto focus mode */
370typedef enum {
371    CAM_FOCUS_MODE_AUTO,
372    CAM_FOCUS_MODE_INFINITY,
373    CAM_FOCUS_MODE_MACRO,
374    CAM_FOCUS_MODE_FIXED,
375    CAM_FOCUS_MODE_EDOF,
376    CAM_FOCUS_MODE_CONTINOUS_VIDEO,
377    CAM_FOCUS_MODE_CONTINOUS_PICTURE,
378    CAM_FOCUS_MODE_MAX
379} cam_focus_mode_type;
380
381typedef enum {
382    CAM_SCENE_MODE_OFF,
383    CAM_SCENE_MODE_AUTO,
384    CAM_SCENE_MODE_LANDSCAPE,
385    CAM_SCENE_MODE_SNOW,
386    CAM_SCENE_MODE_BEACH,
387    CAM_SCENE_MODE_SUNSET,
388    CAM_SCENE_MODE_NIGHT,
389    CAM_SCENE_MODE_PORTRAIT,
390    CAM_SCENE_MODE_BACKLIGHT,
391    CAM_SCENE_MODE_SPORTS,
392    CAM_SCENE_MODE_ANTISHAKE,
393    CAM_SCENE_MODE_FLOWERS,
394    CAM_SCENE_MODE_CANDLELIGHT,
395    CAM_SCENE_MODE_FIREWORKS,
396    CAM_SCENE_MODE_PARTY,
397    CAM_SCENE_MODE_NIGHT_PORTRAIT,
398    CAM_SCENE_MODE_THEATRE,
399    CAM_SCENE_MODE_ACTION,
400    CAM_SCENE_MODE_AR,
401    CAM_SCENE_MODE_MAX
402} cam_scene_mode_type;
403
404typedef enum {
405    CAM_EFFECT_MODE_OFF,
406    CAM_EFFECT_MODE_MONO,
407    CAM_EFFECT_MODE_NEGATIVE,
408    CAM_EFFECT_MODE_SOLARIZE,
409    CAM_EFFECT_MODE_SEPIA,
410    CAM_EFFECT_MODE_POSTERIZE,
411    CAM_EFFECT_MODE_WHITEBOARD,
412    CAM_EFFECT_MODE_BLACKBOARD,
413    CAM_EFFECT_MODE_AQUA,
414    CAM_EFFECT_MODE_EMBOSS,
415    CAM_EFFECT_MODE_SKETCH,
416    CAM_EFFECT_MODE_NEON,
417    CAM_EFFECT_MODE_MAX
418} cam_effect_mode_type;
419
420typedef enum {
421    CAM_FLASH_MODE_OFF,
422    CAM_FLASH_MODE_AUTO,
423    CAM_FLASH_MODE_ON,
424    CAM_FLASH_MODE_TORCH,
425    CAM_FLASH_MODE_MAX
426} cam_flash_mode_t;
427
428typedef struct  {
429    int32_t left;
430    int32_t top;
431    int32_t width;
432    int32_t height;
433} cam_rect_t;
434
435typedef struct  {
436    cam_rect_t rect;
437    int32_t weight; /* weight of the area, valid for focusing/metering areas */
438} cam_area_t;
439
440typedef enum {
441    CAM_STREAMING_MODE_CONTINUOUS, /* continous streaming */
442    CAM_STREAMING_MODE_BURST,      /* burst streaming */
443    CAM_STREAMING_MODE_MAX
444} cam_streaming_mode_t;
445
446#define CAM_REPROCESS_MASK_TYPE_WNR (1<<0)
447
448/* event from server */
449typedef enum {
450    CAM_EVENT_TYPE_MAP_UNMAP_DONE  = (1<<0),
451    CAM_EVENT_TYPE_AUTO_FOCUS_DONE = (1<<1),
452    CAM_EVENT_TYPE_ZOOM_DONE       = (1<<2),
453    CAM_EVENT_TYPE_MAX
454} cam_event_type_t;
455
456typedef enum {
457    CAM_EXP_BRACKETING_OFF,
458    CAM_EXP_BRACKETING_ON
459} cam_bracket_mode;
460
461typedef struct {
462    cam_bracket_mode mode;
463    char values[MAX_EXP_BRACKETING_LENGTH];  /* user defined values */
464} cam_exp_bracketing_t;
465
466typedef enum {
467    CAM_AEC_ROI_OFF,
468    CAM_AEC_ROI_ON
469} cam_aec_roi_ctrl_t;
470
471typedef enum {
472    CAM_AEC_ROI_BY_INDEX,
473    CAM_AEC_ROI_BY_COORDINATE,
474} cam_aec_roi_type_t;
475
476typedef struct {
477    uint32_t x;
478    uint32_t y;
479} cam_coordinate_type_t;
480
481typedef struct {
482    cam_aec_roi_ctrl_t aec_roi_enable;
483    cam_aec_roi_type_t aec_roi_type;
484    union {
485        cam_coordinate_type_t coordinate[MAX_ROI];
486        uint32_t aec_roi_idx[MAX_ROI];
487    } cam_aec_roi_position;
488} cam_set_aec_roi_t;
489
490typedef struct {
491    uint32_t frm_id;
492    uint8_t num_roi;
493    cam_rect_t roi[MAX_ROI];
494    int32_t weight[MAX_ROI];
495    uint8_t is_multiwindow;
496} cam_roi_info_t;
497
498typedef enum {
499    CAM_WAVELET_DENOISE_YCBCR_PLANE,
500    CAM_WAVELET_DENOISE_CBCR_ONLY,
501    CAM_WAVELET_DENOISE_STREAMLINE_YCBCR,
502    CAM_WAVELET_DENOISE_STREAMLINED_CBCR
503} cam_denoise_process_type_t;
504
505typedef struct {
506    int denoise_enable;
507    cam_denoise_process_type_t process_plates;
508} cam_denoise_param_t;
509
510#define CAM_FACE_PROCESS_MASK_DETECTION    (1<<0)
511#define CAM_FACE_PROCESS_MASK_RECOGNITION  (1<<1)
512typedef struct {
513    int fd_mode;               /* mask of face process */
514    int num_fd;
515} cam_fd_set_parm_t;
516
517typedef struct {
518    int8_t face_id;            /* unique id for face tracking within view unless view changes */
519    int8_t score;              /* score of confidence (0, -100) */
520    cam_rect_t face_boundary;  /* boundary of face detected */
521    cam_coordinate_type_t left_eye_center;  /* coordinate of center of left eye */
522    cam_coordinate_type_t right_eye_center; /* coordinate of center of right eye */
523    cam_coordinate_type_t mouth_center;     /* coordinate of center of mouth */
524    uint8_t smile_degree;      /* smile degree (0, -100) */
525    uint8_t smile_confidence;  /* smile confidence (0, 100) */
526    uint8_t face_recognised;   /* if face is recognised */
527    int8_t gaze_angle;         /* -90 -45 0 45 90 for head left to rigth tilt */
528    int8_t updown_dir;         /* up down direction (-90, 90) */
529    int8_t leftright_dir;      /* left right direction (-90, 90) */
530    int8_t roll_dir;           /* roll direction (-90, 90) */
531    int8_t left_right_gaze;    /* left right gaze degree (-50, 50) */
532    int8_t top_bottom_gaze;    /* up down gaze degree (-50, 50) */
533    uint8_t blink_detected;    /* if blink is detected */
534    uint8_t left_blink;        /* left eye blink degeree (0, -100) */
535    uint8_t right_blink;       /* right eye blink degree (0, - 100) */
536} cam_face_detection_info_t;
537
538typedef struct {
539    uint32_t frame_id;                         /* frame index of which faces are detected */
540    uint8_t num_faces_detected;                /* number of faces detected */
541    cam_face_detection_info_t faces[MAX_ROI];  /* detailed information of faces detected */
542} cam_face_detection_data_t;
543
544#define CAM_HISTOGRAM_STATS_SIZE 256
545typedef struct {
546    uint32_t max_hist_value;
547    uint32_t hist_buf[CAM_HISTOGRAM_STATS_SIZE]; /* buf holding histogram stats data */
548} cam_histogram_data_t;
549
550typedef struct {
551    cam_histogram_data_t r_stats;
552    cam_histogram_data_t b_stats;
553    cam_histogram_data_t gr_stats;
554    cam_histogram_data_t gb_stats;
555} cam_bayer_hist_stats_t;
556
557typedef enum {
558    CAM_HISTOGRAM_TYPE_BAYER,
559    CAM_HISTOGRAM_TYPE_YUV
560} cam_histogram_type_t;
561
562typedef struct {
563    cam_histogram_type_t type;
564    union {
565        cam_bayer_hist_stats_t bayer_stats;
566        cam_histogram_data_t yuv_stats;
567    };
568} cam_hist_stats_t;
569
570enum cam_focus_distance_index{
571  CAM_FOCUS_DISTANCE_NEAR_INDEX,  /* 0 */
572  CAM_FOCUS_DISTANCE_OPTIMAL_INDEX,
573  CAM_FOCUS_DISTANCE_FAR_INDEX,
574  CAM_FOCUS_DISTANCE_MAX_INDEX
575};
576
577typedef struct {
578  float focus_distance[CAM_FOCUS_DISTANCE_MAX_INDEX];
579} cam_focus_distances_info_t;
580
581/* Different autofocus cycle when calling do_autoFocus
582 * CAM_AF_COMPLETE_EXISTING_SWEEP: Complete existing sweep
583 * if one is ongoing, and lock.
584 * CAM_AF_DO_ONE_FULL_SWEEP: Do one full sweep, regardless
585 * of the current state, and lock.
586 * CAM_AF_START_CONTINUOUS_SWEEP: Start continous sweep.
587 * After do_autoFocus, HAL receives an event: CAM_AF_FOCUSED,
588 * or CAM_AF_NOT_FOCUSED.
589 * cancel_autoFocus stops any lens movement.
590 * Each do_autoFocus call only produces 1 FOCUSED/NOT_FOCUSED
591 * event, not both.
592 */
593typedef enum {
594    CAM_AF_COMPLETE_EXISTING_SWEEP,
595    CAM_AF_DO_ONE_FULL_SWEEP,
596    CAM_AF_START_CONTINUOUS_SWEEP
597} cam_autofocus_cycle_t;
598
599typedef enum {
600    CAM_AF_SCANNING,
601    CAM_AF_FOCUSED,
602    CAM_AF_NOT_FOCUSED
603} cam_autofocus_state_t;
604
605typedef struct {
606    cam_autofocus_state_t focus_state;           /* state of focus */
607    cam_focus_distances_info_t focus_dist;       /* focus distance */
608} cam_auto_focus_data_t;
609
610typedef struct {
611    uint32_t stream_id;
612    cam_rect_t crop;
613} cam_stream_crop_info_t;
614
615typedef struct {
616    uint8_t num_of_streams;
617    cam_stream_crop_info_t crop_info[MAX_NUM_STREAMS];
618} cam_crop_data_t;
619
620typedef enum {
621    DO_NOT_NEED_FUTURE_FRAME,
622    NEED_FUTURE_FRAME,
623} cam_prep_snapshot_state_t;
624
625typedef struct {
626    uint32_t min_frame_idx;
627    uint32_t max_frame_idx;
628} cam_frame_idx_range_t;
629
630typedef  struct {
631    uint8_t is_stats_valid;               /* if histgram data is valid */
632    cam_hist_stats_t stats_data;          /* histogram data */
633
634    uint8_t is_faces_valid;               /* if face detection data is valid */
635    cam_face_detection_data_t faces_data; /* face detection result */
636
637    uint8_t is_focus_valid;               /* if focus data is valid */
638    cam_auto_focus_data_t focus_data;     /* focus data */
639
640    uint8_t is_crop_valid;                /* if crop data is valid */
641    cam_crop_data_t crop_data;            /* crop data */
642
643    uint8_t is_prep_snapshot_done_valid;  /* if prep snapshot done is valid */
644    cam_prep_snapshot_state_t prep_snapshot_done_state;  /* prepare snapshot done state */
645
646    /* if good frame idx range is valid */
647    uint8_t is_good_frame_idx_range_valid;
648    /* good frame idx range, make sure:
649     * 1. good_frame_idx_range.min_frame_idx > current_frame_idx
650     * 2. good_frame_idx_range.min_frame_idx - current_frame_idx < 100 */
651    cam_frame_idx_range_t good_frame_idx_range;
652
653} cam_metadata_info_t;
654
655typedef enum {
656    CAM_INTF_PARM_QUERY_FLASH4SNAP,
657    CAM_INTF_PARM_EXPOSURE,
658    CAM_INTF_PARM_SHARPNESS,
659    CAM_INTF_PARM_CONTRAST,
660    CAM_INTF_PARM_SATURATION,
661    CAM_INTF_PARM_BRIGHTNESS,
662    CAM_INTF_PARM_WHITE_BALANCE,
663    CAM_INTF_PARM_ISO,
664    CAM_INTF_PARM_ZOOM,
665    CAM_INTF_PARM_ANTIBANDING,
666    CAM_INTF_PARM_EFFECT,
667    CAM_INTF_PARM_FPS_RANGE,
668    CAM_INTF_PARM_EXPOSURE_COMPENSATION,
669    CAM_INTF_PARM_LED_MODE,
670    CAM_INTF_PARM_ROLLOFF,
671    CAM_INTF_PARM_MODE,             /* camera mode */
672    CAM_INTF_PARM_AEC_ALGO_TYPE,    /* auto exposure algorithm */
673    CAM_INTF_PARM_FOCUS_ALGO_TYPE,  /* focus algorithm */
674    CAM_INTF_PARM_AEC_ROI,
675    CAM_INTF_PARM_AF_ROI,
676    CAM_INTF_PARM_FOCUS_MODE,
677    CAM_INTF_PARM_BESTSHOT_MODE,
678    CAM_INTF_PARM_SCE_FACTOR,
679    CAM_INTF_PARM_FD,
680    CAM_INTF_PARM_AEC_LOCK,
681    CAM_INTF_PARM_AWB_LOCK,
682    CAM_INTF_PARM_MCE,
683    CAM_INTF_PARM_HFR,
684    CAM_INTF_PARM_REDEYE_REDUCTION,
685    CAM_INTF_PARM_WAVELET_DENOISE,
686    CAM_INTF_PARM_HISTOGRAM,
687    CAM_INTF_PARM_ASD_ENABLE,
688    CAM_INTF_PARM_RECORDING_HINT,
689    CAM_INTF_PARM_DIS_ENABLE,
690    CAM_INTF_PARM_HDR,
691    CAM_INTF_PARM_SET_BUNDLE,
692    CAM_INTF_PARM_FRAMESKIP,
693    CAM_INTF_PARM_ZSL_MODE,  /* indicating if it's running in ZSL mode */
694    CAM_INTF_PARM_HDR_NEED_1X, /* if HDR needs 1x output */
695    CAM_INTF_PARM_LOCK_CAF,
696    CAM_INTF_PARM_VIDEO_HDR,
697    CAM_INTF_PARM_MAX
698} cam_intf_parm_type_t;
699
700typedef struct {
701    int32_t min_value;
702    int32_t max_value;
703    int32_t def_value;
704    int32_t step;
705} cam_control_range_t;
706
707#define CAM_QCOM_FEATURE_FACE_DETECTION (1<<0)
708#define CAM_QCOM_FEATURE_DENOISE2D      (1<<1)
709#define CAM_QCOM_FEATURE_CROP           (1<<2)
710#define CAM_QCOM_FEATURE_ROTATION       (1<<3)
711#define CAM_QCOM_FEATURE_FLIP           (1<<4)
712#define CAM_QCOM_FEATURE_HDR            (1<<5)
713#define CAM_QCOM_FEATURE_REGISTER_FACE  (1<<6)
714#define CAM_QCOM_FEATURE_SHARPNESS      (1<<7)
715#define CAM_QCOM_FEATURE_VIDEO_HDR      (1<<8)
716
717// Counter clock wise
718typedef enum {
719    ROTATE_0 = 1<<0,
720    ROTATE_90 = 1<<1,
721    ROTATE_180 = 1<<2,
722    ROTATE_270 = 1<<3,
723} cam_rotation_t;
724
725typedef enum {
726    FLIP_H = 1<<0,
727    FLIP_V = 1<<1,
728} cam_flip_t;
729
730typedef struct {
731    uint32_t bundle_id;                            /* bundle id */
732    uint8_t num_of_streams;                        /* number of streams in the bundle */
733    uint32_t stream_ids[MAX_STREAM_NUM_IN_BUNDLE]; /* array of stream ids to be bundled */
734} cam_bundle_config_t;
735
736typedef enum {
737    CAM_ONLINE_REPROCESS_TYPE,    /* online reprocess, frames from running streams */
738    CAM_OFFLINE_REPROCESS_TYPE,   /* offline reprocess, frames from external source */
739} cam_reprocess_type_enum_t;
740
741typedef struct {
742    /* reprocess feature mask */
743    uint32_t feature_mask;
744
745    /* individual setting for features to be reprocessed */
746    cam_denoise_param_t denoise2d;
747    cam_rect_t input_crop;
748    cam_rotation_t rotation;
749    uint32_t flip;
750    int32_t sharpness;
751    int32_t hdr_need_1x; /* when CAM_QCOM_FEATURE_HDR enabled, indicate if 1x is needed for output */
752} cam_pp_feature_config_t;
753
754typedef struct {
755    uint32_t input_stream_id;
756    /* input source stream type */
757    cam_stream_type_t input_stream_type;
758} cam_pp_online_src_config_t;
759
760typedef struct {
761    /* image format */
762    cam_format_t input_fmt;
763
764    /* image dimension */
765    cam_dimension_t input_dim;
766
767    /* buffer plane information, will be calc based on stream_type, fmt,
768       dim, and padding_info(from stream config). Info including:
769       offset_x, offset_y, stride, scanline, plane offset */
770    cam_stream_buf_plane_info_t input_buf_planes;
771
772    /* number of input reprocess buffers */
773    uint8_t num_of_bufs;
774} cam_pp_offline_src_config_t;
775
776/* reprocess stream input configuration */
777typedef struct {
778    /* input source config */
779    cam_reprocess_type_enum_t pp_type;
780    union {
781        cam_pp_online_src_config_t online;
782        cam_pp_offline_src_config_t offline;
783    };
784
785    /* pp feature config */
786    cam_pp_feature_config_t pp_feature_config;
787} cam_stream_reproc_config_t;
788
789#endif /* __QCAMERA_TYPES_H__ */
790