Commit | Line | Data |
---|---|---|
d8cd4c5c WM |
1 | /* |
2 | * Samsung EXYNOS FIMC-IS (Imaging Subsystem) driver | |
3 | * | |
4 | * Copyright (C) 2014 Samsung Electronics Co., Ltd. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | */ | |
10 | ||
11 | #ifndef FIMC_IS_SENSOR_INTERFACE_H | |
12 | #define FIMC_IS_SENSOR_INTERFACE_H | |
13 | ||
14 | #include "fimc-is-core.h" | |
15 | #include "fimc-is-mem.h" | |
16 | #include "fimc-is-config.h" | |
17 | #include "exynos-fimc-is-sensor.h" | |
18 | #include "fimc-is-metadata.h" | |
19 | #include "fimc-is-binary.h" | |
20 | #include "fimc-is-device-sensor.h" | |
21 | #include "fimc-is-interface-preprocessor.h" | |
22 | ||
23 | #define SENSOR_INTERFACE_MAGIC 0xFEDCBA98 | |
24 | ||
25 | #define NUM_OF_DUMMY_FRAME (3) /* N + 2 Frame delay */ | |
26 | #define NUM_FRAMES_DMA (NUM_OF_DUMMY_FRAME + 2 + 1) | |
27 | #define NEXT_NEXT_FRAME_DMA (NUM_OF_DUMMY_FRAME + 2) | |
28 | ||
29 | /* This OFFSET is set to 0 when enable 3AA 3FRAME DELAY, set to 1 in other cases */ | |
30 | #define OTF_VSYNC_3AA_FRAME_DELAY_OFFSET 0 | |
31 | ||
32 | #define NUM_FRAMES_OTF (NEXT_NEXT_FRAME_OTF + 1) | |
33 | #define NEXT_NEXT_FRAME_OTF (2 + OTF_VSYNC_3AA_FRAME_DELAY_OFFSET) | |
34 | ||
35 | #define NEXT_FRAME 1 | |
36 | #define CURRENT_FRAME 0 | |
37 | ||
38 | #define NUM_FRAMES (NUM_OF_DUMMY_FRAME + 2 + 1) | |
39 | ||
40 | #define EXPOSURE_GAIN_INDEX 0 | |
41 | #define LONG_EXPOSURE_GAIN_INDEX 1 | |
42 | #define SHORT_EXPOSURE_GAIN_INDEX 2 | |
43 | #define MAX_EXPOSURE_GAIN_PER_FRAME 3 | |
44 | ||
45 | #define ACTUATOR_MAX_SOFT_LANDING_NUM 32 /* Actuator interface */ | |
46 | #define ACTUATOR_MAX_FOCUS_POSITIONS 1024 | |
47 | ||
9c1effc4 EL |
48 | #define INVALID_LASER_DISTANCE 0 |
49 | ||
d8cd4c5c WM |
50 | #define MIN(a,b) (((a) < (b)) ? (a) : (b)) |
51 | #define MAX(a,b) (((a) > (b)) ? (a) : (b)) | |
52 | ||
53 | #define FPS_TO_DURATION_US(x) ((x == 0) ? (0) : ((1000 * 1000) / x)) | |
54 | #define DURATION_US_TO_FPS(x) ((x == 0) ? (0) : ((1000 * 1000) / x)) | |
55 | ||
4a06d2c3 SS |
56 | /* static memory size for DDK/RTA backup data */ |
57 | #define STATIC_DATA_SIZE 100 | |
58 | ||
d8cd4c5c WM |
59 | enum DIFF_BET_SEN_ISP { /* Set to 0: 3AA 3frame delay, 1: 3AA 4frame delay, 3: M2M */ |
60 | DIFF_OTF_DELAY = 0, | |
61 | DIFF_M2M_DELAY = 3 | |
62 | }; | |
63 | ||
64 | enum SENSOR_CONTROL_DELAY { | |
65 | N_PLUS_TWO_FRAME = 0, | |
66 | N_PLUS_ONE_FRAME = 1, | |
67 | }; | |
68 | ||
4a06d2c3 SS |
69 | enum { |
70 | ITF_CTRL_ID_DDK = 0, | |
71 | ITF_CTRL_ID_RTA = 1, | |
72 | }; | |
73 | ||
d8cd4c5c WM |
74 | /* DEVICE SENSOR INTERFACE */ |
75 | #define SENSOR_REGISTER_FUNC_ADDR (DDK_LIB_ADDR + 0x40) | |
76 | #define SENSOR_REGISTER_FUNC_ADDR_RTA (RTA_LIB_ADDR + 0x40) | |
77 | ||
78 | typedef int (*register_sensor_interface)(void *itf); | |
79 | ||
80 | struct ae_param { | |
81 | union { | |
82 | u32 val; | |
83 | u32 long_val; | |
84 | }; | |
85 | u32 short_val; | |
48412d5f | 86 | u32 middle_val; |
d8cd4c5c WM |
87 | }; |
88 | ||
89 | typedef struct { | |
90 | /* Normal parameter */ | |
91 | /* Each CB has a specific parameter type.(Ex. SetSize Cb has size info param.) */ | |
92 | void *param; | |
93 | unsigned int return_value; | |
94 | } cis_setting_info; | |
95 | ||
96 | enum itf_vc_stat_type { | |
97 | VC_STAT_TYPE_INVALID = -1, | |
98 | ||
d8cd4c5c | 99 | /* Types for SW PDAF(tail mode buffer type) */ |
4a06d2c3 SS |
100 | VC_STAT_TYPE_TAIL_FOR_SW_PDAF = 100, |
101 | ||
102 | /* Types for IMX PDAF sensors */ | |
103 | VC_STAT_TYPE_IMX_FLEXIBLE = 200, | |
104 | VC_STAT_TYPE_IMX_STATIC, | |
d8cd4c5c WM |
105 | |
106 | /* Types for PAF_STAT */ | |
107 | VC_STAT_TYPE_PAFSTAT_FLOATING = 300, | |
108 | VC_STAT_TYPE_PAFSTAT_STATIC, | |
4a06d2c3 SS |
109 | |
110 | /* Types for PDP 1.0 in Lhotse/Makalu EVT0 */ | |
111 | VC_STAT_TYPE_PDP_1_0_PDAF_STAT0 = 400, | |
112 | VC_STAT_TYPE_PDP_1_0_PDAF_STAT1, | |
113 | ||
114 | /* Types for PDP 1.1 in Makalu EVT1 */ | |
115 | VC_STAT_TYPE_PDP_1_1_PDAF_STAT0 = 500, | |
116 | VC_STAT_TYPE_PDP_1_1_PDAF_STAT1, | |
29edaf6f WK |
117 | |
118 | /* Types for 3HDR */ | |
119 | VC_STAT_TYPE_TAIL_FOR_3HDR_LSI = 600, | |
120 | VC_STAT_TYPE_TAIL_FOR_3HDR_IMX, | |
4a06d2c3 SS |
121 | }; |
122 | ||
123 | enum itf_vc_sensor_mode { | |
124 | VC_SENSOR_MODE_INVALID = -1, | |
125 | ||
126 | /* 2PD */ | |
127 | VC_SENSOR_MODE_2PD_MODE1 = 100, | |
128 | VC_SENSOR_MODE_2PD_MODE2, | |
129 | VC_SENSOR_MODE_2PD_MODE3, | |
130 | VC_SENSOR_MODE_2PD_MODE4, | |
131 | VC_SENSOR_MODE_2PD_MODE1_HDR, | |
132 | VC_SENSOR_MODE_2PD_MODE2_HDR, | |
133 | VC_SENSOR_MODE_2PD_MODE3_HDR, | |
134 | VC_SENSOR_MODE_2PD_MODE4_HDR, | |
135 | ||
136 | /* MSPD */ | |
137 | VC_SENSOR_MODE_MSPD_NORMAL = 200, | |
138 | VC_SENSOR_MODE_MSPD_TAIL, | |
139 | VC_SENSOR_MODE_MSPD_GLOBAL_NORMAL, | |
140 | VC_SENSOR_MODE_MSPD_GLOBAL_TAIL, | |
141 | ||
142 | /* Ultra PD */ | |
143 | VC_SENSOR_MODE_ULTRA_PD_NORMAL = 300, | |
144 | VC_SENSOR_MODE_ULTRA_PD_TAIL, | |
145 | ||
146 | /* Super PD */ | |
147 | VC_SENSOR_MODE_SUPER_PD_NORMAL = 400, | |
148 | VC_SENSOR_MODE_SUPER_PD_TAIL, | |
149 | ||
150 | /* IMX PDAF */ | |
151 | VC_SENSOR_MODE_IMX_PDAF = 500, | |
29edaf6f WK |
152 | |
153 | /* 3HDR */ | |
154 | VC_SENSOR_MODE_3HDR_LSI = 600, | |
155 | VC_SENSOR_MODE_3HDR_IMX, | |
a1b1650d DK |
156 | |
157 | /* OV PDAF */ | |
158 | VC_SENSOR_MODE_OV_PDAF = 700, | |
d8cd4c5c WM |
159 | }; |
160 | ||
161 | struct vc_buf_info_t { | |
162 | enum itf_vc_stat_type stat_type; | |
4a06d2c3 | 163 | enum itf_vc_sensor_mode sensor_mode; |
d8cd4c5c WM |
164 | u32 width; |
165 | u32 height; | |
166 | u32 element_size; | |
167 | }; | |
168 | ||
169 | typedef struct { | |
48412d5f | 170 | unsigned int exposure; |
d8cd4c5c WM |
171 | unsigned int analog_gain; |
172 | unsigned int digital_gain; | |
48412d5f | 173 | unsigned int long_exposure; |
d8cd4c5c WM |
174 | unsigned int long_analog_gain; |
175 | unsigned int long_digital_gain; | |
48412d5f | 176 | unsigned int short_exposure; |
d8cd4c5c WM |
177 | unsigned int short_analog_gain; |
178 | unsigned int short_digital_gain; | |
48412d5f WK |
179 | unsigned int middle_exposure; |
180 | unsigned int middle_analog_gain; | |
181 | unsigned int middle_digital_gain; | |
d8cd4c5c WM |
182 | } ae_setting; |
183 | ||
184 | typedef struct { | |
185 | unsigned int long_exposure_coarse; | |
186 | unsigned int long_exposure_fine; | |
187 | unsigned int long_exposure_analog_gain; | |
188 | unsigned int long_exposure_digital_gain; | |
189 | unsigned int long_exposure_companion_digital_gain; | |
190 | unsigned int short_exposure_coarse; | |
191 | unsigned int short_exposure_fine; | |
192 | unsigned int short_exposure_analog_gain; | |
193 | unsigned int short_exposure_digital_gain; | |
194 | unsigned int short_exposure_companion_digital_gain; | |
195 | } preprocessor_ae_setting; | |
196 | ||
197 | ||
198 | typedef struct { | |
199 | bool stream_on; | |
200 | ||
201 | unsigned int config_idx; | |
202 | bool bypass; | |
203 | bool paf_stat_enable; | |
204 | bool caf_stat_enable; | |
205 | bool wdr_enable; | |
206 | bool enable_lsc; | |
207 | bool enable_drc; | |
208 | bool enable_pdaf_bpc; | |
209 | bool enable_xtalk; | |
210 | ||
211 | enum camera2_wdr_mode wdr_mode; | |
212 | enum camera2_wdr_mode pre_wdr_mode; | |
213 | enum camera2_disparity_mode disparity_mode; | |
214 | enum camera2_paf_mode paf_mode; | |
215 | } is_shared_data; | |
216 | ||
217 | typedef struct { | |
218 | bool ois_available; | |
219 | unsigned int mode; | |
220 | unsigned int factory_step; | |
221 | } ois_shared_data; | |
222 | ||
7ccd8b59 WK |
223 | struct wb_gains { |
224 | u32 gr; | |
225 | u32 r; | |
226 | u32 b; | |
227 | u32 gb; | |
228 | }; | |
229 | ||
29edaf6f WK |
230 | struct roi_setting_t { |
231 | bool update; | |
232 | u16 roi_start_x; | |
233 | u16 roi_start_y; | |
234 | u16 roi_end_x; | |
235 | u16 roi_end_y; | |
236 | }; | |
237 | ||
238 | struct sensor_lsi_3hdr_stat_control_mode_change { | |
239 | int r_weight; | |
240 | int b_weight; | |
241 | int g_weight; | |
242 | int low_gate_thr; | |
243 | int high_gate_thr; | |
244 | struct roi_setting_t y_sum_roi; | |
245 | }; | |
246 | ||
247 | struct sensor_lsi_3hdr_stat_control_per_frame { | |
248 | int r_weight; | |
249 | int b_weight; | |
250 | int g_weight; | |
bfcb84be WK |
251 | |
252 | /* stat for 3dhdr motion */ | |
253 | u32 motion_indication; | |
254 | u32 motion_high_end_ty2ty1; | |
255 | u32 motion_high_start_ty2ty1; | |
256 | u32 motion_low_end_ty2ty1; | |
257 | u32 motion_low_start_ty2ty1; | |
258 | u32 motion_high_end_ty3ty2; | |
259 | u32 motion_high_start_ty3ty2; | |
260 | u32 motion_low_end_ty3ty2; | |
261 | u32 motion_low_start_ty3ty2; | |
262 | u32 decision_thresh_override; | |
263 | u32 motion_abs_high_ty3ty2; | |
264 | u32 motion_abs_low_ty3ty2; | |
265 | u32 motion_abs_high_ty2ty1; | |
266 | u32 motion_abs_low_ty2ty1; | |
29edaf6f WK |
267 | }; |
268 | ||
d8cd4c5c WM |
269 | typedef struct { |
270 | /** The length of a frame is specified as a number of lines, frame_length_lines. | |
271 | @remarks | |
272 | 'frame length lines' is changed in dynamic AE mode. | |
273 | */ | |
274 | unsigned int frame_length_lines; | |
275 | unsigned int frame_time; // unit: ms | |
276 | ||
277 | /** The length of a line is specified as a number of pixel clocks, line_length_pck. */ | |
278 | unsigned int line_length_pck; | |
279 | unsigned int line_readOut_time; // unit: ns | |
280 | unsigned long long rolling_shutter_skew; | |
281 | ||
282 | /** Video Timing Pixel Clock, vt_pix_clk_freq. */ | |
283 | unsigned int pclk; | |
284 | unsigned int min_frame_us_time; | |
285 | #ifdef CAMERA_REAR2 | |
286 | unsigned int min_sync_frame_us_time; | |
287 | #endif | |
288 | ||
289 | /** Frame valid time */ | |
290 | unsigned int frame_valid_us_time; | |
291 | ||
292 | unsigned int min_coarse_integration_time; | |
293 | unsigned int max_coarse_integration_time; | |
294 | unsigned int min_fine_integration_time; | |
295 | unsigned int max_fine_integration_time; | |
296 | unsigned int max_margin_coarse_integration_time; | |
297 | unsigned int max_margin_fine_integration_time; | |
298 | unsigned int min_analog_gain[2]; // 0: code, 1: times | |
299 | unsigned int max_analog_gain[2]; | |
300 | unsigned int min_digital_gain[2]; | |
301 | unsigned int max_digital_gain[2]; | |
302 | unsigned int cur_coarse_integration_time_step; | |
303 | ||
304 | unsigned int cur_frame_us_time; | |
a1b1650d DK |
305 | unsigned int cur_pos_x; |
306 | unsigned int cur_pos_y; | |
d8cd4c5c WM |
307 | unsigned int cur_width; |
308 | unsigned int cur_height; | |
309 | unsigned int pre_width; | |
310 | unsigned int pre_height; | |
311 | ||
312 | /** Current analogue_gain_code_global */ | |
313 | unsigned int cur_exposure_coarse; | |
314 | unsigned int cur_exposure_fine; | |
315 | unsigned int cur_analog_gain; | |
316 | unsigned int cur_analog_gain_permille; | |
317 | unsigned int cur_digital_gain; | |
318 | unsigned int cur_digital_gain_permille; | |
319 | unsigned int cur_long_exposure_coarse; | |
320 | unsigned int cur_long_exposure_fine; | |
321 | unsigned int cur_long_analog_gain; | |
322 | unsigned int cur_long_analog_gain_permille; | |
323 | unsigned int cur_long_digital_gain; | |
324 | unsigned int cur_long_digital_gain_permille; | |
325 | unsigned int cur_short_exposure_coarse; | |
326 | unsigned int cur_short_exposure_fine; | |
327 | unsigned int cur_short_analog_gain; | |
328 | unsigned int cur_short_analog_gain_permille; | |
329 | unsigned int cur_short_digital_gain; | |
330 | unsigned int cur_short_digital_gain_permille; | |
331 | ||
332 | unsigned int stream_on; | |
333 | ||
334 | /* Moved from SensorEntry.cpp Jong 20121008 */ | |
335 | unsigned int sen_vsync_count; | |
336 | ||
337 | unsigned int stream_id; | |
338 | unsigned int product_name; /* sensor names such as IMX134, IMX135, and S5K3L2 */ | |
339 | unsigned int sens_config_index_cur; | |
340 | unsigned int sens_config_index_pre; | |
341 | unsigned int cur_frame_rate; | |
342 | unsigned int pre_frame_rate; | |
343 | bool is_active_area; | |
344 | ||
345 | /* bool bFirstRegSet; */ | |
346 | unsigned int low_expo_start; | |
347 | ||
348 | /* To deal with N + 1 or N +2 setting timing, 0: Previous input, 1: Current input */ | |
349 | unsigned int analog_gain[2]; | |
350 | unsigned int digital_gain[2]; | |
351 | ||
352 | unsigned int max_fps; | |
353 | ||
354 | unsigned int mipi_err_int_cnt[10]; | |
355 | unsigned int mipi_err_print_out_cnt[10]; | |
356 | ||
357 | bool called_common_sensor_setting; /* [hc0105.kim, 2013/09/13] Added to avoid calling common sensor register setting again. */ | |
358 | /* #ifdef C1_LSC_CHANGE // [ist.song 2014.08.19] Added to inform videomode to sensor. */ | |
359 | bool video_mode; | |
360 | #ifdef USE_NEW_PER_FRAME_CONTROL | |
361 | unsigned int num_of_frame; | |
362 | #endif | |
363 | /* #endif */ | |
364 | unsigned int actuator_position; | |
365 | ||
366 | is_shared_data is_data; | |
367 | ois_shared_data ois_data; | |
368 | ae_setting auto_exposure[2]; | |
369 | preprocessor_ae_setting preproc_auto_exposure[2]; | |
370 | ||
371 | /* SysSema_t pFlashCtrl_IsrSema; //[2014.08.13, kh14.koo] to add for sema of KTD2692 (flash dirver) */ | |
372 | ||
373 | bool binning; /* If binning is set, sensor should binning for size */ | |
374 | ||
375 | u32 cis_rev; | |
376 | u32 group_param_hold; | |
377 | ||
378 | /* set low noise mode */ | |
379 | u32 cur_lownoise_mode; | |
380 | u32 pre_lownoise_mode; | |
381 | ||
382 | #ifdef CAMERA_REAR2_SENSOR_SHIFT_CROP | |
383 | u32 sensor_shifted_num; | |
384 | #endif | |
41bfc54c | 385 | bool dual_sync_enable; |
d8cd4c5c WM |
386 | } cis_shared_data; |
387 | ||
388 | struct v4l2_subdev; | |
389 | typedef int (*cis_func_type)(struct v4l2_subdev *subdev, cis_setting_info *info); | |
390 | struct fimc_is_cis_ops { | |
391 | int (*cis_init)(struct v4l2_subdev *subdev); | |
392 | int (*cis_log_status)(struct v4l2_subdev *subdev); | |
393 | int (*cis_group_param_hold)(struct v4l2_subdev *subdev, bool hold); | |
394 | int (*cis_set_global_setting)(struct v4l2_subdev *subdev); | |
395 | int (*cis_mode_change)(struct v4l2_subdev *subdev, u32 mode); | |
396 | int (*cis_set_size)(struct v4l2_subdev *subdev, cis_shared_data *cis_data); | |
397 | int (*cis_stream_on)(struct v4l2_subdev *subdev); | |
398 | int (*cis_stream_off)(struct v4l2_subdev *subdev); | |
399 | int (*cis_adjust_frame_duration)(struct v4l2_subdev *subdev, | |
400 | u32 input_exposure_time, | |
401 | u32 *target_duration); | |
402 | /* Set dynamic frame duration value */ | |
403 | int (*cis_set_frame_duration)(struct v4l2_subdev *subdev, u32 frame_duration); | |
404 | /* Set min fps value */ | |
405 | int (*cis_set_frame_rate)(struct v4l2_subdev *subdev, u32 min_fps); | |
406 | int (*cis_get_min_exposure_time)(struct v4l2_subdev *subdev, u32 *min_expo); | |
407 | int (*cis_get_max_exposure_time)(struct v4l2_subdev *subdev, u32 *max_expo); | |
408 | cis_func_type cis_adjust_expoure_time; /* TBD */ | |
409 | int (*cis_set_exposure_time)(struct v4l2_subdev *subdev, struct ae_param *target_exposure); | |
410 | int (*cis_get_min_analog_gain)(struct v4l2_subdev *subdev, u32 *min_again); | |
411 | int (*cis_get_max_analog_gain)(struct v4l2_subdev *subdev, u32 *max_again); | |
412 | int (*cis_adjust_analog_gain)(struct v4l2_subdev *subdev, u32 input_again, u32 *target_permile); | |
413 | int (*cis_set_analog_gain)(struct v4l2_subdev *subdev, struct ae_param *again); | |
414 | int (*cis_get_analog_gain)(struct v4l2_subdev *subdev, u32 *again); | |
415 | int (*cis_get_min_digital_gain)(struct v4l2_subdev *subdev, u32 *min_dgain); | |
416 | int (*cis_get_max_digital_gain)(struct v4l2_subdev *subdev, u32 *max_dgain); | |
417 | cis_func_type cis_adjust_digital_gain; /* TBD */ | |
418 | int (*cis_set_digital_gain)(struct v4l2_subdev *subdev, struct ae_param *dgain); | |
419 | int (*cis_get_digital_gain)(struct v4l2_subdev *subdev, u32 *dgain); | |
420 | int (*cis_compensate_gain_for_extremely_br)(struct v4l2_subdev *subdev, u32 expo, u32 *again, u32 *dgain); | |
421 | cis_func_type cis_get_line_readout_time_ns; /* TBD */ | |
422 | cis_func_type cis_read_sysreg; /* TBD */ | |
423 | cis_func_type cis_read_userreg; /* TBD */ | |
424 | int (*cis_wait_streamoff)(struct v4l2_subdev *subdev); | |
425 | int (*cis_wait_streamon)(struct v4l2_subdev *subdev); | |
426 | void (*cis_data_calculation)(struct v4l2_subdev *subdev, u32 mode); | |
427 | int (*cis_set_long_term_exposure)(struct v4l2_subdev *subdev); | |
428 | int (*cis_set_adjust_sync)(struct v4l2_subdev *subdev, u32 adjust_sync); | |
429 | #ifdef CONFIG_SENSOR_RETENTION_USE | |
430 | int (*cis_retention_prepare)(struct v4l2_subdev *subdev); | |
431 | int (*cis_retention_crc_check)(struct v4l2_subdev *subdev); | |
432 | #endif | |
433 | int (*cis_set_frs_control)(struct v4l2_subdev *subdev, u32 command); | |
434 | int (*cis_set_super_slow_motion_roi)(struct v4l2_subdev *subdev, struct v4l2_rect *ssm_roi); | |
435 | #ifdef CAMERA_REAR2_SENSOR_SHIFT_CROP | |
436 | int (*cis_update_pdaf_tail_size)(struct v4l2_subdev *subdev, struct fimc_is_sensor_cfg *select); | |
437 | #endif | |
8ff1a098 | 438 | int (*cis_set_initial_exposure)(struct v4l2_subdev *subdev); |
4a06d2c3 SS |
439 | int (*cis_check_rev)(struct v4l2_subdev *subdev); |
440 | int (*cis_set_super_slow_motion_threshold)(struct v4l2_subdev *subdev, u32 threshold); | |
441 | int (*cis_get_super_slow_motion_threshold)(struct v4l2_subdev *subdev, u32 *threshold); | |
6c7b5111 | 442 | int (*cis_factory_test)(struct v4l2_subdev *subdev); |
7ccd8b59 | 443 | int (*cis_set_wb_gains)(struct v4l2_subdev *subdev, struct wb_gains wb_gains); |
29edaf6f WK |
444 | int (*cis_set_roi_stat)(struct v4l2_subdev *subdev, struct roi_setting_t roi_control); |
445 | int (*cis_set_3hdr_stat)(struct v4l2_subdev *subdev, bool streaming, void *data); | |
3cea618d | 446 | void (*cis_check_wdr_mode)(struct v4l2_subdev *subdev, u32 mode_idx); |
69b44952 | 447 | int (*cis_set_dual_setting)(struct v4l2_subdev *subdev); |
27d028de | 448 | int (*cis_mode_change_throttling)(struct v4l2_subdev *subdev); |
d8cd4c5c WM |
449 | }; |
450 | ||
451 | struct fimc_is_sensor_ctl | |
452 | { | |
453 | //===================================================================================// | |
454 | // Ctl updtate timing | |
455 | // (01) ~ (04) are updated by "SensorEntry::CopyCam2P0Ctl" when "SIRC_ISP_CAMERA_EVENT_FRAME_START" interrupt is occured. | |
456 | ||
457 | /* (01) */ u32 ctl_frame_number; | |
458 | /* (02) */ camera2_sensor_ctl_t cur_cam20_sensor_ctrl; | |
459 | bool valid_sensor_ctrl; | |
460 | /* (03) */ camera2_flash_ctl_t cur_cam20_flash_ctrl; | |
461 | bool valid_flash_ctrl; | |
462 | /* (04) */ camera2_lens_ctl_t cur_cam20_lens_ctrl; | |
463 | bool is_valid_lens_ctrl; | |
464 | //===================================================================================// | |
465 | ||
466 | //===================================================================================// | |
467 | // UCtl update timing | |
468 | ||
469 | // Sensor | |
470 | // (05) ~ (07) are updated by "SensorEntry::ReportCam2P0SensorDone" when "SIRC_ISP_CAMERA_EVENT_FRAME_END" interrupt is occured. | |
471 | /* (05) */ u32 sensor_frame_number; | |
472 | /* (06) */ bool is_sensor_request; | |
473 | /* (07) */ camera2_sensor_uctl_t cur_cam20_sensor_udctrl; | |
474 | bool is_valid_sensor_udctrl; | |
475 | ||
476 | // Flash | |
477 | // (08) ~ (10) are updated by "SensorEntry::ReportCam2P0FlashDone" when "SircSenHal_RequestFlash" function is called. | |
478 | /* (08) */ u32 flash_frame_number; | |
479 | /* (09) */ bool is_flash_request; | |
480 | /* (10) */ camera2_flash_uctl_t cur_cam20_flash_udctrl; | |
481 | bool valid_flash_udctrl; | |
482 | ||
483 | // Lens | |
484 | // (11) ~ (13) are updated by "SensorEntry::ReportCam2P0LensDone" when "SircSenHal_SetActuatorPosition" function is called | |
485 | // or "SIRC_ISP_CAMERA_EVENT_FRAME_END" interrupt is occured. | |
486 | /* (11) */ u32 lens_frame_number; | |
487 | /* (12) */ bool is_lens_request; | |
488 | /* (13) */ camera2_lens_uctl_t cur_cam20_lens_udctrl; | |
489 | bool is_valid_lens_udctrl; | |
490 | //===================================================================================// | |
491 | ||
492 | bool alg_reset_flag; | |
493 | ||
494 | // Frame number that indicating shot. Currntly, it is not used. | |
495 | /* (14) */ bool shot_frame_number; | |
7ccd8b59 | 496 | |
36400a56 | 497 | /* For WB(White Balance) gain update */ |
4fe1ae7f | 498 | struct wb_gains wb_gains; |
7ccd8b59 | 499 | bool update_wb_gains; |
36400a56 WK |
500 | |
501 | /* force_update set when need to update w/o DDK or RTA */ | |
502 | bool force_update; | |
29edaf6f WK |
503 | |
504 | /* for update 3DHDR sensor stats */ | |
505 | struct roi_setting_t roi_control; | |
506 | bool update_roi; | |
507 | struct sensor_lsi_3hdr_stat_control_per_frame stat_control; | |
508 | bool update_3hdr_stat; | |
d8cd4c5c WM |
509 | }; |
510 | ||
511 | typedef enum fimc_is_sensor_adjust_direction_ { | |
512 | SENSOR_ADJUST_TO_SHORT = 1, | |
513 | SENSOR_ADJUST_TO_LONG = 2, | |
514 | } fimc_is_sensor_adjust_direction; | |
515 | ||
516 | /* If companion statistics are used, then 3A algorithms need to know whether current stat. are ready to use or not. */ | |
517 | enum itf_cis_hdr_stat_status { | |
518 | SENSOR_STAT_STATUS_NO_DATA = 0, | |
519 | SENSOR_STAT_STATUS_DONE = 1, | |
520 | }; | |
521 | ||
522 | enum itf_cis_interface { | |
523 | ITF_CIS_SMIA = 0, | |
524 | ITF_CIS_SMIA_WDR, | |
525 | ITF_CIS_MAX, | |
526 | }; | |
527 | ||
528 | enum itf_param_type { | |
529 | ITF_CIS_PARAM_TOTAL_GAIN, | |
530 | ITF_CIS_PARAM_ANALOG_GAIN, | |
531 | ITF_CIS_PARAM_DIGITAL_GAIN, | |
532 | ITF_CIS_PARAM_EXPOSURE, | |
533 | ITF_CIS_PARAM_FLASH_INTENSITY, | |
534 | ITF_CIS_PARAM_MAX, | |
535 | }; | |
536 | ||
537 | /* This peri state is check available each sensor device. */ | |
538 | enum fimc_is_sensor_peri_state { | |
539 | FIMC_IS_SENSOR_ACTUATOR_AVAILABLE, | |
540 | FIMC_IS_SENSOR_FLASH_AVAILABLE, | |
541 | FIMC_IS_SENSOR_PREPROCESSOR_AVAILABLE, | |
542 | FIMC_IS_SENSOR_OIS_AVAILABLE, | |
543 | FIMC_IS_SENSOR_PDP_AVAILABLE, | |
544 | FIMC_IS_SENSOR_APERTURE_AVAILABLE, | |
545 | FIMC_IS_SENSOR_PAFSTAT_AVAILABLE, | |
7c38fac0 | 546 | FIMC_IS_SENSOR_EEPROM_AVAILABLE, |
d8cd4c5c WM |
547 | }; |
548 | ||
549 | enum fimc_is_actuator_pos_size_bit { | |
550 | ACTUATOR_POS_SIZE_8BIT = 8, | |
551 | ACTUATOR_POS_SIZE_9BIT = 9, | |
552 | ACTUATOR_POS_SIZE_10BIT = 10, | |
553 | }; | |
554 | ||
555 | enum fimc_is_actuator_direction { | |
556 | ACTUATOR_RANGE_INF_TO_MAC = 0, | |
557 | ACTUATOR_RANGE_MAC_TO_INF, | |
558 | }; | |
559 | ||
560 | enum fimc_is_actuator_status { | |
561 | ACTUATOR_STATUS_NO_BUSY = 0, | |
562 | ACTUATOR_STATUS_BUSY | |
563 | }; | |
564 | ||
565 | enum fimc_is_cis_lownoise_mode { | |
566 | FIMC_IS_CIS_LNOFF = 0, /* Low Noise Off */ | |
567 | FIMC_IS_CIS_LN2, /* Low Noise 2 */ | |
568 | FIMC_IS_CIS_LN4, /* Low Noise 4 */ | |
4a06d2c3 SS |
569 | FIMC_IS_CIS_LN2_PEDESTAL128, /* Low Noise 2 + pedestal 128 */ |
570 | FIMC_IS_CIS_LN4_PEDESTAL128, /* Low Noise 4 + pedestal 128 */ | |
d8cd4c5c WM |
571 | FIMC_IS_CIS_LOWNOISE_MODE_MAX, |
572 | }; | |
573 | ||
48412d5f WK |
574 | enum fimc_is_exposure_gain_count { |
575 | EXPOSURE_GAIN_COUNT_INVALID = 0, | |
576 | EXPOSURE_GAIN_COUNT_1, | |
577 | EXPOSURE_GAIN_COUNT_2, | |
578 | EXPOSURE_GAIN_COUNT_3, | |
579 | EXPOSURE_GAIN_COUNT_END | |
580 | }; | |
581 | ||
582 | enum fimc_is_exposure_gain_type { | |
583 | EXPOSURE_GAIN_LONG = 0, | |
584 | EXPOSURE_GAIN_SHORT, | |
585 | EXPOSURE_GAIN_MIDDLE, | |
586 | EXPOSURE_GAIN_MAX | |
587 | }; | |
588 | ||
29edaf6f WK |
589 | enum fimc_is_sensor_stat_control { |
590 | SENSOR_STAT_NOTHING = 0, /* Default */ | |
591 | SENSOR_STAT_LSI_3DHDR, /* LSI 3DHDR stat control */ | |
592 | SENSOR_STAT_CONTROL_MAX, | |
593 | }; | |
594 | ||
d8cd4c5c WM |
595 | enum fimc_is_aperture_control_step { |
596 | APERTURE_STEP_STATIONARY = 0, | |
597 | APERTURE_STEP_PREPARE, | |
598 | APERTURE_STEP_MOVING, | |
599 | }; | |
600 | ||
601 | typedef int (*actuator_func_type)(struct v4l2_subdev *subdev, u32 *info); | |
602 | struct fimc_is_actuator_ops { | |
603 | actuator_func_type actuator_init; | |
604 | actuator_func_type actuator_get_status; | |
605 | actuator_func_type actuator_set_pos; | |
606 | actuator_func_type actuator_cal_data; | |
607 | #ifdef USE_AF_SLEEP_MODE | |
608 | int (*set_active)(struct v4l2_subdev *subdev, int enable); | |
609 | #endif | |
610 | }; | |
611 | ||
612 | struct fimc_is_aperture_ops { | |
613 | int (*set_aperture_value)(struct v4l2_subdev *subdev, int value); | |
4a06d2c3 | 614 | #ifndef CONFIG_CAMERA_USE_MCU |
d8cd4c5c WM |
615 | int (*set_aperture_start_value_step1)(struct v4l2_subdev *subdev, int value); |
616 | int (*set_aperture_start_value_step2)(struct v4l2_subdev *subdev, int value); | |
617 | int (*prepare_ois_autotest)(struct v4l2_subdev *subdev); | |
4a06d2c3 | 618 | #endif |
d8cd4c5c WM |
619 | int (*aperture_deinit)(struct v4l2_subdev *subdev, int value); |
620 | }; | |
621 | ||
622 | /* for SetAlgResFlag API */ | |
623 | struct fimc_is_3a_res_to_sensor { | |
624 | u32 hdr_ratio; | |
625 | u32 red_gain; | |
626 | u32 green_gain; | |
627 | u32 blue_gain; | |
628 | u32 hdr_enabled; | |
629 | u32 hdr_state; | |
630 | u32 thermal_mode; | |
631 | bool video_mode; | |
632 | }; | |
633 | ||
634 | /* Flash */ | |
635 | struct fimc_is_flash_ops { | |
636 | int (*flash_control)(struct v4l2_subdev *subdev, enum flash_mode mode, u32 intensity); | |
637 | }; | |
638 | ||
639 | struct fimc_is_preproc_lemode_set{ | |
640 | u16 lemode; | |
641 | bool every_frame; | |
642 | }; | |
643 | ||
644 | /* Long Term Exposure mode(LTE mode) interface */ | |
645 | struct fimc_is_long_term_expo_mode { | |
646 | u32 expo[2]; | |
647 | u32 tgain[2]; | |
648 | u32 again[2]; | |
649 | u32 dgain[2]; | |
650 | bool sen_strm_off_on_enable; | |
651 | u32 sen_strm_off_on_step; | |
652 | u32 frm_num_strm_off_on[2]; | |
653 | u32 frm_num_strm_off_on_interval; | |
654 | struct fimc_is_preproc_lemode_set lemode_set; | |
655 | /* Back up now line_length_pck when start LTE mode */ | |
656 | u32 pre_line_length_pck; | |
657 | /* Control to frame_interval in sensor driver when LTE mode */ | |
658 | u32 frame_interval; | |
659 | }; | |
660 | ||
661 | /* OIS */ | |
662 | struct fimc_is_ois_ops { | |
663 | int (*ois_init)(struct v4l2_subdev *subdev); | |
4a06d2c3 | 664 | #if defined (CONFIG_OIS_USE_RUMBA_S6) || defined (CONFIG_CAMERA_USE_MCU) |
d8cd4c5c WM |
665 | int (*ois_deinit)(struct v4l2_subdev *subdev); |
666 | #endif | |
667 | #ifdef USE_OIS_SLEEP_MODE | |
668 | int (*ois_start)(struct v4l2_subdev *subdev); | |
669 | int (*ois_stop)(struct v4l2_subdev *subdev); | |
670 | #endif | |
671 | int (*ois_set_mode)(struct v4l2_subdev *subdev, int mode); | |
672 | int (*ois_shift_compensation)(struct v4l2_subdev *subdev, int position, int resolution); | |
673 | #ifdef CONFIG_OIS_DIRECT_FW_CONTROL | |
20266d60 | 674 | #ifdef CONFIG_CAMERA_OIS_BU24218GWL_OBJ |
675 | int (*ois_fw_update)(struct v4l2_subdev *subdev, struct v4l2_subdev *eeprom_subdev); | |
676 | #else | |
d8cd4c5c | 677 | int (*ois_fw_update)(struct v4l2_subdev *subdev); |
20266d60 | 678 | #endif |
d8cd4c5c WM |
679 | #else |
680 | void (*ois_fw_update)(struct fimc_is_core *core); | |
681 | #endif | |
682 | int (*ois_self_test)(struct fimc_is_core *core); | |
4a06d2c3 | 683 | #ifndef CONFIG_CAMERA_USE_MCU |
d8cd4c5c | 684 | bool (*ois_diff_test)(struct fimc_is_core *core, int *x_diff, int *y_diff); |
4a06d2c3 | 685 | #endif |
d8cd4c5c WM |
686 | bool (*ois_auto_test)(struct fimc_is_core *core, |
687 | int threshold, bool *x_result, bool *y_result, int *sin_x, int *sin_y); | |
688 | #ifdef CAMERA_REAR2_OIS | |
689 | bool (*ois_auto_test_rear2)(struct fimc_is_core *core, | |
690 | int threshold, bool *x_result, bool *y_result, int *sin_x, int *sin_y, | |
691 | bool *x_result_2nd, bool *y_result_2nd, int *sin_x_2nd, int *sin_y_2nd); | |
4a06d2c3 | 692 | int (*ois_set_power_mode)(struct v4l2_subdev *subdev); |
d8cd4c5c WM |
693 | #endif |
694 | bool (*ois_check_fw)(struct fimc_is_core *core); | |
695 | void (*ois_enable)(struct fimc_is_core *core); | |
696 | void (*ois_offset_test)(struct fimc_is_core *core, long *raw_data_x, long *raw_data_y); | |
697 | void (*ois_get_offset_data)(struct fimc_is_core *core, long *raw_data_x, long *raw_data_y); | |
698 | void (*ois_gyro_sleep)(struct fimc_is_core *core); | |
699 | void (*ois_exif_data)(struct fimc_is_core *core); | |
700 | u8 (*ois_read_status)(struct fimc_is_core *core); | |
701 | u8 (*ois_read_cal_checksum)(struct fimc_is_core *core); | |
702 | int (*ois_set_coef)(struct v4l2_subdev *subdev, u8 coef); | |
703 | int (*ois_read_fw_ver)(char *name, char *ver); | |
4a06d2c3 SS |
704 | int (*ois_center_shift)(struct v4l2_subdev *subdev); |
705 | int (*ois_set_center)(struct v4l2_subdev *subdev); | |
706 | u8 (*ois_read_mode)(struct v4l2_subdev *subdev); | |
d1517738 XM |
707 | #ifdef CONFIG_OIS_BU24218_FACTORY_TEST |
708 | int (*ois_factory_fw_ver)(struct v4l2_subdev *subdev, u32* result); | |
709 | int (*ois_factory_hea)(struct v4l2_subdev *subdev, u32* result); | |
710 | #endif | |
d8cd4c5c WM |
711 | }; |
712 | ||
713 | struct fimc_is_sensor_interface; | |
714 | ||
715 | /* new APIs */ | |
716 | struct fimc_is_cis_interface_ops { | |
717 | int (*get_)(struct fimc_is_sensor_interface *itf); | |
718 | ||
719 | int (*request_reset_interface)(struct fimc_is_sensor_interface *itf, | |
720 | u32 exposure, | |
721 | u32 total_gain, | |
722 | u32 analog_gain, | |
723 | u32 digital_gain); | |
724 | ||
725 | int (*get_calibrated_size)(struct fimc_is_sensor_interface *itf, | |
726 | u32 *width, | |
727 | u32 *height); | |
728 | ||
729 | int (*get_bayer_order)(struct fimc_is_sensor_interface *itf, | |
730 | u32 *bayer_order); | |
731 | ||
732 | u32 (*get_min_exposure_time)(struct fimc_is_sensor_interface *itf); | |
733 | u32 (*get_max_exposure_time)(struct fimc_is_sensor_interface *itf); | |
734 | u32 (*get_min_analog_gain)(struct fimc_is_sensor_interface *itf); | |
735 | u32 (*get_max_analog_gain)(struct fimc_is_sensor_interface *itf); | |
736 | u32 (*get_min_digital_gain)(struct fimc_is_sensor_interface *itf); | |
737 | u32 (*get_max_digital_gain)(struct fimc_is_sensor_interface *itf); | |
738 | ||
739 | u32 (*get_vsync_count)(struct fimc_is_sensor_interface *itf); | |
740 | u32 (*get_vblank_count)(struct fimc_is_sensor_interface *itf); | |
741 | bool (*is_vvalid_period)(struct fimc_is_sensor_interface *itf); | |
742 | ||
743 | int (*request_exposure)(struct fimc_is_sensor_interface *itf, | |
48412d5f | 744 | enum fimc_is_exposure_gain_count num_data, u32 *exposure); |
d8cd4c5c WM |
745 | |
746 | int (*adjust_exposure)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
747 | enum fimc_is_exposure_gain_count num_data, |
748 | u32 *exposure, | |
749 | u32 *available_exposure, | |
d8cd4c5c WM |
750 | fimc_is_sensor_adjust_direction adjust_direction); |
751 | ||
752 | int (*get_next_frame_timing)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
753 | enum fimc_is_exposure_gain_count num_data, |
754 | u32 *exposure, | |
755 | u32 *frame_period, | |
756 | u64 *line_period); | |
d8cd4c5c WM |
757 | |
758 | int (*get_frame_timing)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
759 | enum fimc_is_exposure_gain_count num_data, |
760 | u32 *exposure, | |
761 | u32 *frame_period, | |
762 | u64 *line_period); | |
d8cd4c5c WM |
763 | |
764 | int (*request_analog_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
765 | enum fimc_is_exposure_gain_count num_data, |
766 | u32 *analog_gain); | |
d8cd4c5c WM |
767 | |
768 | int (*request_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
769 | enum fimc_is_exposure_gain_count num_data, |
770 | u32 *total_gain, | |
771 | u32 *analog_gain, | |
772 | u32 *digital_gain); | |
d8cd4c5c WM |
773 | |
774 | int (*adjust_analog_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
775 | enum fimc_is_exposure_gain_count num_data, |
776 | u32 *desired_analog_gain, | |
777 | u32 *actual_gain, | |
778 | fimc_is_sensor_adjust_direction adjust_direction); | |
d8cd4c5c WM |
779 | |
780 | int (*get_next_analog_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
781 | enum fimc_is_exposure_gain_count num_data, |
782 | u32 *analog_gain); | |
d8cd4c5c WM |
783 | |
784 | int (*get_analog_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
785 | enum fimc_is_exposure_gain_count num_data, |
786 | u32 *analog_gain); | |
d8cd4c5c WM |
787 | |
788 | int (*get_next_digital_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
789 | enum fimc_is_exposure_gain_count num_data, |
790 | u32 *digital_gain); | |
d8cd4c5c WM |
791 | |
792 | int (*get_digital_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
793 | enum fimc_is_exposure_gain_count num_data, |
794 | u32 *digital_gain); | |
d8cd4c5c WM |
795 | |
796 | bool (*is_actuator_available)(struct fimc_is_sensor_interface *itf); | |
797 | bool (*is_flash_available)(struct fimc_is_sensor_interface *itf); | |
798 | bool (*is_companion_available)(struct fimc_is_sensor_interface *itf); | |
799 | bool (*is_ois_available)(struct fimc_is_sensor_interface *itf); | |
800 | bool (*is_aperture_available)(struct fimc_is_sensor_interface *itf); | |
801 | ||
802 | int (*get_sensor_frame_timing)(struct fimc_is_sensor_interface *itf, | |
803 | u32 *pclk, | |
804 | u32 *line_length_pck, | |
805 | u32 *frame_length_lines, | |
806 | u32 *max_margin_cit); | |
807 | ||
808 | int (*get_sensor_cur_size)(struct fimc_is_sensor_interface *itf, | |
a1b1650d DK |
809 | u32 *cur_pos_x, |
810 | u32 *cur_pos_y, | |
d8cd4c5c WM |
811 | u32 *cur_width, |
812 | u32 *cur_height); | |
813 | ||
814 | int (*get_sensor_max_fps)(struct fimc_is_sensor_interface *itf, | |
815 | u32 *max_fps); | |
816 | ||
817 | int (*get_sensor_cur_fps)(struct fimc_is_sensor_interface *itf, | |
818 | u32 *cur_fps); | |
819 | ||
820 | int (*get_hdr_ratio_ctl_by_again)(struct fimc_is_sensor_interface *itf, | |
821 | u32 *ctrl_by_again); | |
822 | ||
823 | int (*get_sensor_use_dgain)(struct fimc_is_sensor_interface *itf, | |
824 | u32 *use_dgain); | |
825 | ||
826 | int (*set_alg_reset_flag)(struct fimc_is_sensor_interface *itf, | |
827 | bool executed); | |
828 | ||
829 | int (*get_sensor_initial_aperture)(struct fimc_is_sensor_interface *itf, | |
830 | u32 *aperture); | |
831 | ||
832 | int (*set_initial_exposure_of_setfile)(struct fimc_is_sensor_interface *itf, | |
833 | u32 expo); | |
834 | ||
835 | #ifdef USE_NEW_PER_FRAME_CONTROL | |
836 | int (*reserved0)(struct fimc_is_sensor_interface *itf, | |
837 | bool reserved0); | |
838 | ||
839 | int (*set_num_of_frame_per_one_3aa)(struct fimc_is_sensor_interface *itf, | |
840 | u32 *num_of_frame); | |
841 | ||
842 | int (*reserved1)(struct fimc_is_sensor_interface *itf, | |
843 | u32 *reserved1); | |
844 | #else | |
845 | int (*set_video_mode_of_setfile)(struct fimc_is_sensor_interface *itf, | |
846 | bool video_mode); | |
847 | ||
848 | int (*get_num_of_frame_per_one_3aa)(struct fimc_is_sensor_interface *itf, | |
849 | u32 *num_of_frame); | |
850 | ||
851 | int (*get_offset_from_cur_result)(struct fimc_is_sensor_interface *itf, | |
852 | u32 *offset); | |
853 | #endif | |
854 | int (*set_cur_uctl_list)(struct fimc_is_sensor_interface *itf); | |
855 | ||
856 | int (*apply_sensor_setting)(struct fimc_is_sensor_interface *itf); | |
857 | ||
858 | /* reset exposure and gain for Flash */ | |
859 | int (*request_reset_expo_gain)(struct fimc_is_sensor_interface *itf, | |
48412d5f WK |
860 | enum fimc_is_exposure_gain_count num_data, |
861 | u32 *expo, | |
862 | u32 *tgain, | |
863 | u32 *again, | |
864 | u32 *dgain); | |
d8cd4c5c | 865 | int (*set_sensor_info_mode_change)(struct fimc_is_sensor_interface *itf, |
48412d5f WK |
866 | enum fimc_is_exposure_gain_count num_data, |
867 | u32 *expo, | |
868 | u32 *again, | |
869 | u32 *dgain); | |
d8cd4c5c WM |
870 | int (*update_sensor_dynamic_meta)(struct fimc_is_sensor_interface *itf, |
871 | u32 frame_count, | |
872 | camera2_ctl_t *ctrl, | |
873 | camera2_dm_t *dm, | |
874 | camera2_udm_t *udm); | |
875 | int (*copy_sensor_ctl)(struct fimc_is_sensor_interface *itf, | |
876 | u32 frame_count, | |
877 | camera2_shot_t *shot); | |
878 | ||
879 | /* Get sensor module id */ | |
880 | int (*get_module_id)(struct fimc_is_sensor_interface *itf, | |
881 | u32 *module_id); | |
882 | ||
883 | /* Get sensor module position */ | |
884 | int (*get_module_position)(struct fimc_is_sensor_interface *itf, | |
885 | enum exynos_sensor_position *real_module); | |
886 | ||
887 | /* Set sensor 3a mode - OTF/M2M */ | |
888 | int (*set_sensor_3a_mode)(struct fimc_is_sensor_interface *itf, | |
889 | u32 mode); | |
8ff1a098 | 890 | int (*get_initial_exposure_gain_of_sensor)(struct fimc_is_sensor_interface *itf, |
48412d5f WK |
891 | enum fimc_is_exposure_gain_count num_data, |
892 | u32 *expo, | |
893 | u32 *again, | |
894 | u32 *dgain); | |
d8cd4c5c WM |
895 | }; |
896 | ||
897 | struct fimc_is_cis_ext_interface_ops { | |
898 | int (*get_sensor_hdr_stat)(struct fimc_is_sensor_interface *itf, | |
899 | enum itf_cis_hdr_stat_status *status); | |
900 | ||
901 | int (*set_3a_alg_res_to_sens)(struct fimc_is_sensor_interface *itf, | |
902 | struct fimc_is_3a_res_to_sensor *sensor_setting); | |
903 | ||
904 | /* In order to change a current CIS mode when an user select the WDR (long and short exposure) mode or the normal AE mo */ | |
905 | int (*change_cis_mode)(struct fimc_is_sensor_interface *itf, | |
906 | enum itf_cis_interface cis_mode); | |
907 | u32(*set_adjust_sync)(struct fimc_is_sensor_interface *itf, u32 setsync); | |
908 | u32(*request_frame_length_line)(struct fimc_is_sensor_interface *itf, u32 framelengthline); | |
909 | int (*request_sensitivity)(struct fimc_is_sensor_interface *itf, | |
910 | u32 sensitivity); | |
29edaf6f WK |
911 | int (*get_sensor_flag)(struct fimc_is_sensor_interface *itf, |
912 | enum fimc_is_sensor_stat_control *stat_control_type, | |
913 | u32 *exposure_count); | |
914 | int (*set_sensor_stat_control_mode_change)(struct fimc_is_sensor_interface *itf, | |
915 | enum fimc_is_sensor_stat_control stat_control_type, | |
916 | void *stat_control); | |
917 | int (*set_sensor_roi_control)(struct fimc_is_sensor_interface *itf, | |
918 | enum fimc_is_sensor_stat_control stat_control_type, | |
919 | void *roi_control); | |
920 | int (*set_sensor_stat_control_per_frame)(struct fimc_is_sensor_interface *itf, | |
921 | enum fimc_is_sensor_stat_control stat_control_type, | |
922 | void *stat_control); | |
d8cd4c5c WM |
923 | }; |
924 | ||
925 | struct fimc_is_cis_ext2_interface_ops { | |
926 | int (*set_long_term_expo_mode)(struct fimc_is_sensor_interface *itf, | |
927 | struct fimc_is_long_term_expo_mode *long_term_expo_mode); | |
928 | int (*set_low_noise_mode)(struct fimc_is_sensor_interface *itf, u32 mode); | |
633851e5 | 929 | int (*get_sensor_max_dynamic_fps)(struct fimc_is_sensor_interface *itf, u32 *max_dynamic_fps); |
4a06d2c3 SS |
930 | /* Get static memory address for DDK/RTA backup data */ |
931 | int (*get_static_mem)(int ctrl_id, void **mem, int *size); | |
633851e5 WK |
932 | int (*request_wb_gain)(struct fimc_is_sensor_interface *itf, |
933 | u32 gr_gain, u32 r_gain, u32 b_gain, u32 gb_gain); | |
934 | int (*set_sensor_info_mfhdr_mode_change)(struct fimc_is_sensor_interface *itf, | |
935 | u32 count, u32 *long_expo, u32 *long_again, u32 *long_dgain, | |
936 | u32 *expo, u32 *again, u32 *dgain); | |
937 | void *reserved[15]; | |
d8cd4c5c WM |
938 | }; |
939 | ||
940 | struct fimc_is_cis_event_ops { | |
941 | int (*start_of_frame)(struct fimc_is_sensor_interface *itf); | |
942 | int (*end_of_frame)(struct fimc_is_sensor_interface *itf); | |
943 | int (*apply_frame_settings)(struct fimc_is_sensor_interface *itf); | |
944 | }; | |
945 | ||
946 | /* end of new APIs */ | |
947 | ||
948 | /* Actuator interface */ | |
949 | struct fimc_is_actuator_softlanding_table { | |
950 | bool enable; | |
951 | u32 step_delay; | |
952 | u32 position_num; | |
953 | u32 virtual_table[ACTUATOR_MAX_SOFT_LANDING_NUM]; | |
954 | u32 hw_table[ACTUATOR_MAX_SOFT_LANDING_NUM]; | |
955 | }; | |
956 | ||
957 | struct fimc_is_actuator_position_table { | |
958 | bool enable; | |
959 | u32 hw_table[ACTUATOR_MAX_FOCUS_POSITIONS]; | |
960 | }; | |
961 | ||
962 | struct fimc_is_actuator_interface { | |
963 | /* ToDo: consider M2M scenario */ | |
964 | u32 virtual_pos; | |
965 | u32 hw_pos; | |
966 | ||
967 | /* | |
968 | * This values are specific information for AF Tick noise | |
969 | * when turning on a camera. | |
970 | */ | |
971 | bool initialized; | |
972 | ||
973 | struct fimc_is_actuator_position_table position_table; | |
974 | struct fimc_is_actuator_softlanding_table soft_landing_table; | |
975 | }; | |
976 | ||
977 | struct fimc_is_actuator_interface_ops { | |
978 | int (*set_actuator_position_table) (struct fimc_is_sensor_interface *itf, | |
979 | u32 *position_table); | |
980 | int (*set_soft_landing_config) (struct fimc_is_sensor_interface *itf, | |
981 | u32 step_delay, | |
982 | u32 position_num, | |
983 | u32 *position_table); | |
984 | int (*set_position) (struct fimc_is_sensor_interface *itf, u32 position); | |
985 | ||
986 | int (*get_cur_frame_position) (struct fimc_is_sensor_interface *itf, u32 *position); | |
987 | int (*get_applied_actual_position) (struct fimc_is_sensor_interface *itf, u32 *position); | |
988 | int (*get_prev_frame_position) (struct fimc_is_sensor_interface *itf, | |
989 | u32 *position, u32 frame_diff); | |
990 | ||
991 | int (*set_af_window_position) (struct fimc_is_sensor_interface *itf, | |
992 | u32 left_x, u32 left_y, | |
993 | u32 right_x, u32 right_y); | |
994 | ||
995 | int (*get_status) (struct fimc_is_sensor_interface *itf, u32 *status); | |
996 | int (*copy_lens_ctl)(struct fimc_is_sensor_interface *itf, | |
997 | u32 frame_count, | |
998 | camera2_shot_t *shot); | |
999 | }; | |
1000 | ||
1001 | struct fimc_is_apature_info_t { | |
1002 | int cur_value; | |
1003 | bool zoom_running; | |
1004 | }; | |
1005 | ||
1006 | struct fimc_is_aperture_interface_ops { | |
1007 | int (*set_aperture_value)(struct fimc_is_sensor_interface *itf, int value); | |
1008 | int (*get_aperture_value)(struct fimc_is_sensor_interface *itf, struct fimc_is_apature_info_t *param); | |
1009 | }; | |
1010 | ||
1011 | /* Flash interface */ | |
1012 | struct fimc_is_flash_expo_gain { | |
1013 | u32 expo[2]; | |
1014 | u32 tgain[2]; | |
1015 | u32 again[2]; | |
1016 | u32 dgain[2]; | |
1017 | u32 long_expo[2]; | |
1018 | u32 long_tgain[2]; | |
1019 | u32 long_again[2]; | |
1020 | u32 long_dgain[2]; | |
1021 | u32 short_expo[2]; | |
1022 | u32 short_tgain[2]; | |
1023 | u32 short_again[2]; | |
1024 | u32 short_dgain[2]; | |
1025 | bool pre_fls_ae_reset; /* true: Pre-flash off */ | |
1026 | u32 frm_num_pre_fls; /* If it is set to 100, then Pre-flash is automatically turned off at 100-th frame. */ | |
1027 | bool main_fls_ae_reset; /* true: Main-flash on/off */ | |
1028 | /* If they are set to 200 and 201, then Main-flash sensor settings are applied to a sensor, and the flash is fired at 200-th frame. | |
1029 | After the Main-flash, ambient exposure and gains are set to the sensor at 201-th frame. */ | |
1030 | u32 frm_num_main_fls[2]; | |
1031 | u32 main_fls_strm_on_off_step; /* 0: main/pre-flash exposure and gains, 1: ambient exposure and gains */ | |
1032 | }; | |
1033 | ||
d8cd4c5c WM |
1034 | struct fimc_is_flash_interface_ops { |
1035 | int (*request_flash)(struct fimc_is_sensor_interface *itf, | |
1036 | u32 mode, | |
1037 | bool on, | |
1038 | u32 intensity, | |
1039 | u32 time); | |
1040 | int (*request_flash_expo_gain)(struct fimc_is_sensor_interface *itf, | |
1041 | struct fimc_is_flash_expo_gain *flash_ae); | |
1042 | int (*update_flash_dynamic_meta)(struct fimc_is_sensor_interface *itf, | |
1043 | u32 frame_count, | |
1044 | camera2_ctl_t *ctrl, | |
1045 | camera2_dm_t *dm, | |
1046 | camera2_udm_t *udm); | |
1047 | int (*copy_flash_ctl)(struct fimc_is_sensor_interface *itf, | |
1048 | u32 frame_count, | |
1049 | camera2_shot_t *shot); | |
1050 | }; | |
1051 | ||
9bf64039 WK |
1052 | /* arguments: stat_type, frame_count, notifier_data */ |
1053 | typedef int (*vc_dma_notifier_t)(int, unsigned int, void *); | |
1054 | ||
d8cd4c5c WM |
1055 | struct fimc_is_csi_interface_ops { |
1056 | int (*get_vc_dma_buf)(struct fimc_is_sensor_interface *itf, | |
1057 | enum itf_vc_buf_data_type request_data_type, | |
4a06d2c3 | 1058 | u32 frame_count, |
d8cd4c5c | 1059 | u32 *buf_index, |
4a06d2c3 | 1060 | u64 *buf_addr); |
d8cd4c5c WM |
1061 | int (*put_vc_dma_buf)(struct fimc_is_sensor_interface *itf, |
1062 | enum itf_vc_buf_data_type request_data_type, | |
1063 | u32 index); | |
1064 | int (*get_vc_dma_buf_info)(struct fimc_is_sensor_interface *itf, | |
1065 | enum itf_vc_buf_data_type request_data_type, | |
4a06d2c3 | 1066 | struct vc_buf_info_t *buf_info); |
d8cd4c5c WM |
1067 | int (*get_vc_dma_buf_max_size)(struct fimc_is_sensor_interface *itf, |
1068 | enum itf_vc_buf_data_type request_data_type, | |
1069 | u32 *width, | |
1070 | u32 *height, | |
1071 | u32 *element_size); | |
4a06d2c3 SS |
1072 | #ifdef CAMERA_REAR2_SENSOR_SHIFT_CROP |
1073 | int (*get_sensor_shifted_num)(struct fimc_is_sensor_interface *itf, | |
1074 | u32 *sensor_shifted_num); | |
1075 | int (*reserved[3])(struct fimc_is_sensor_interface *itf); | |
1076 | #else | |
9bf64039 WK |
1077 | int (*register_vc_dma_notifier)(struct fimc_is_sensor_interface *itf, |
1078 | enum itf_vc_stat_type type, | |
1079 | vc_dma_notifier_t notifier, void *data); | |
1080 | int (*unregister_vc_dma_notifier)(struct fimc_is_sensor_interface *itf, | |
1081 | enum itf_vc_stat_type type, | |
1082 | vc_dma_notifier_t notifier); | |
1083 | int (*reserved[2])(struct fimc_is_sensor_interface *itf); | |
4a06d2c3 | 1084 | #endif |
d8cd4c5c WM |
1085 | }; |
1086 | ||
4a06d2c3 | 1087 | struct paf_setting_t { |
d8cd4c5c WM |
1088 | u32 reg_addr; |
1089 | u32 reg_data; | |
1090 | }; | |
1091 | ||
d8cd4c5c | 1092 | struct fimc_is_paf_interface_ops { |
4a06d2c3 SS |
1093 | int (*set_paf_param)(struct fimc_is_sensor_interface *itf, |
1094 | struct paf_setting_t *regs, u32 regs_size); | |
1095 | int (*get_paf_ready)(struct fimc_is_sensor_interface *itf, u32 *ready); | |
9bf64039 | 1096 | int (*reserved[6])(struct fimc_is_sensor_interface *itf); |
d8cd4c5c WM |
1097 | }; |
1098 | ||
1099 | struct fimc_is_dual_interface_ops { | |
1100 | int (*get_sensor_state)(struct fimc_is_sensor_interface *itf); | |
1101 | int (*get_reuse_3a_state)(struct fimc_is_sensor_interface *itf, | |
1102 | u32 *position, u32 *ae_exposure, u32 *ae_deltaev, bool is_clear); | |
1103 | int (*set_reuse_ae_exposure)(struct fimc_is_sensor_interface *itf, | |
1104 | u32 ae_exposure, u32 ae_deltaev); | |
1105 | int (*reserved[2])(struct fimc_is_sensor_interface *itf); | |
1106 | }; | |
1107 | ||
7c38fac0 | 1108 | struct fimc_is_eeprom_ops { |
1109 | int (*eeprom_read)(struct v4l2_subdev *subdev); | |
1110 | int (*eeprom_check_all_crc)(struct v4l2_subdev *subdev); | |
291c5cf6 | 1111 | int (*eeprom_check_address)(struct v4l2_subdev *subdev); |
7c38fac0 | 1112 | int (*eeprom_check_info)(struct v4l2_subdev *subdev); |
1113 | int (*eeprom_check_awb)(struct v4l2_subdev *subdev); | |
1114 | int (*eeprom_check_af)(struct v4l2_subdev *subdev); | |
1115 | int (*eeprom_check_ae)(struct v4l2_subdev *subdev); | |
1116 | int (*eeprom_check_lsc)(struct v4l2_subdev *subdev); | |
1117 | int (*eeprom_check_ois)(struct v4l2_subdev *subdev); | |
1118 | int (*eeprom_check_pdaf)(struct v4l2_subdev *subdev); | |
1119 | int (*eeprom_check_dual)(struct v4l2_subdev *subdev); | |
291c5cf6 | 1120 | int (*eeprom_check_sfr)(struct v4l2_subdev *subdev); |
7c38fac0 | 1121 | }; |
1122 | ||
d8cd4c5c WM |
1123 | struct fimc_is_sensor_interface { |
1124 | u32 magic; | |
1125 | struct fimc_is_cis_interface_ops cis_itf_ops; | |
1126 | struct fimc_is_cis_event_ops cis_evt_ops; | |
1127 | struct fimc_is_actuator_interface actuator_itf; | |
1128 | struct fimc_is_actuator_interface_ops actuator_itf_ops; | |
1129 | struct fimc_is_flash_interface_ops flash_itf_ops; | |
1130 | struct fimc_is_aperture_interface_ops aperture_itf_ops; | |
d8cd4c5c WM |
1131 | struct fimc_is_paf_interface_ops paf_itf_ops; |
1132 | ||
1133 | bool vsync_flag; | |
1134 | bool otf_flag_3aa; | |
1135 | /* Different frame count between sensor and ISP */ | |
1136 | enum DIFF_BET_SEN_ISP diff_bet_sen_isp; | |
1137 | enum itf_cis_interface cis_mode; | |
1138 | ||
48412d5f WK |
1139 | u32 total_gain[EXPOSURE_GAIN_MAX][NUM_FRAMES]; |
1140 | u32 analog_gain[EXPOSURE_GAIN_MAX][NUM_FRAMES]; | |
1141 | u32 digital_gain[EXPOSURE_GAIN_MAX][NUM_FRAMES]; | |
1142 | u32 exposure[EXPOSURE_GAIN_MAX][NUM_FRAMES]; | |
d8cd4c5c WM |
1143 | |
1144 | u32 flash_mode[NUM_FRAMES]; | |
1145 | u32 flash_intensity[NUM_FRAMES]; | |
1146 | u32 flash_firing_duration[NUM_FRAMES]; | |
1147 | struct fimc_is_cis_ext_interface_ops cis_ext_itf_ops; | |
1148 | struct fimc_is_csi_interface_ops csi_itf_ops; | |
1149 | /* Add interface for LTE mode */ | |
1150 | struct fimc_is_cis_ext2_interface_ops cis_ext2_itf_ops; | |
1151 | /* Add interface for DUAL scenario */ | |
1152 | struct fimc_is_dual_interface_ops dual_itf_ops; | |
1153 | }; | |
1154 | ||
1155 | ||
1156 | int init_sensor_interface(struct fimc_is_sensor_interface *itf); | |
1157 | ||
1158 | /* Sensor interface helper function */ | |
d8cd4c5c WM |
1159 | struct fimc_is_actuator *get_subdev_actuator(struct fimc_is_sensor_interface *itf); |
1160 | u32 get_frame_count(struct fimc_is_sensor_interface *itf); | |
1161 | ||
1162 | int sensor_get_ctrl(struct fimc_is_sensor_interface *itf, u32 ctrl_id, u32 *val); | |
1163 | ||
1164 | /* Actuator interface function */ | |
1165 | int set_actuator_position_table(struct fimc_is_sensor_interface *itf, | |
1166 | u32 *position_table); | |
1167 | int set_soft_landing_config(struct fimc_is_sensor_interface *itf, | |
1168 | u32 step_delay, u32 position_num, u32 *hw_pos_table); | |
1169 | int set_position(struct fimc_is_sensor_interface *itf, u32 position); | |
1170 | int get_cur_frame_position(struct fimc_is_sensor_interface *itf, u32 *position); | |
1171 | int get_applied_actual_position(struct fimc_is_sensor_interface *itf, u32 *position); | |
1172 | int get_prev_frame_position(struct fimc_is_sensor_interface *itf, | |
1173 | u32 *position, u32 frame_diff); | |
1174 | int set_af_window_position(struct fimc_is_sensor_interface *itf, | |
1175 | u32 left_x, u32 left_y, | |
1176 | u32 right_x, u32 right_y); | |
1177 | int get_status(struct fimc_is_sensor_interface *itf, u32 *status); | |
1178 | ||
1179 | #endif |