2 * Samsung Exynos5 SoC series Sensor driver
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/i2c.h>
13 #include <linux/slab.h>
14 #include <linux/irq.h>
15 #include <linux/interrupt.h>
16 #include <linux/delay.h>
17 #include <linux/version.h>
18 #include <linux/gpio.h>
19 #include <linux/clk.h>
20 #include <linux/regulator/consumer.h>
21 #include <linux/videodev2.h>
22 #include <linux/videodev2_exynos_camera.h>
23 #include <linux/module.h>
24 #include <linux/moduleparam.h>
25 #include <linux/platform_device.h>
26 #include <linux/of_gpio.h>
27 #include <media/v4l2-ctrls.h>
28 #include <media/v4l2-device.h>
29 #include <media/v4l2-subdev.h>
31 #include <exynos-fimc-is-sensor.h>
32 #include "fimc-is-hw.h"
33 #include "fimc-is-core.h"
34 #include "fimc-is-param.h"
35 #include "fimc-is-device-sensor.h"
36 #include "fimc-is-device-sensor-peri.h"
37 #include "fimc-is-resourcemgr.h"
38 #include "fimc-is-dt.h"
39 #include "fimc-is-cis-2x5sp.h"
40 #include "fimc-is-cis-2x5sp-setA.h"
41 #include "fimc-is-cis-2x5sp-setB.h"
43 #include "fimc-is-helper-i2c.h"
45 #define SENSOR_NAME "S5K2X5SP"
46 /* #define DEBUG_2X5SP_PLL */
48 static const struct v4l2_subdev_ops subdev_ops
;
50 static const u32
*sensor_2x5sp_global
;
51 static u32 sensor_2x5sp_global_size
;
52 static const u32
**sensor_2x5sp_setfiles
;
53 static const u32
*sensor_2x5sp_setfile_sizes
;
54 static const u32
*sensor_2x5sp_otp_initial
;
55 static u32 sensor_2x5sp_otp_initial_size
;
56 static const struct sensor_pll_info_compact
**sensor_2x5sp_pllinfos
;
57 static u32 sensor_2x5sp_max_setfile_num
;
59 static const u32
*sensor_2x5sp_setfile_throttling
;
60 static u32 sensor_2x5sp_setfile_throttling_size
;
61 static const struct sensor_pll_info_compact
*sensor_2x5sp_pllinfo_throttling
;
63 static void sensor_2x5sp_cis_data_calculation(const struct sensor_pll_info_compact
*pll_info_compact
, cis_shared_data
*cis_data
)
65 u32 vt_pix_clk_hz
= 0;
66 u32 frame_rate
= 0, max_fps
= 0, frame_valid_us
= 0;
68 FIMC_BUG_VOID(!pll_info_compact
);
70 /* 1. get pclk value from pll info */
71 vt_pix_clk_hz
= pll_info_compact
->pclk
;
73 dbg_sensor(1, "ext_clock(%d), mipi_datarate(%d), pclk(%d)\n",
74 pll_info_compact
->ext_clk
, pll_info_compact
->mipi_datarate
, pll_info_compact
->pclk
);
76 /* 2. the time of processing one frame calculation (us) */
77 cis_data
->min_frame_us_time
= (pll_info_compact
->frame_length_lines
* pll_info_compact
->line_length_pck
78 / (vt_pix_clk_hz
/ (1000 * 1000)));
79 cis_data
->cur_frame_us_time
= cis_data
->min_frame_us_time
;
81 /* 3. FPS calculation */
82 frame_rate
= vt_pix_clk_hz
/ (pll_info_compact
->frame_length_lines
* pll_info_compact
->line_length_pck
);
83 dbg_sensor(1, "frame_rate (%d) = vt_pix_clk_hz(%d) / "
84 KERN_CONT
"(pll_info_compact->frame_length_lines(%d) * pll_info_compact->line_length_pck(%d))\n",
85 frame_rate
, vt_pix_clk_hz
, pll_info_compact
->frame_length_lines
, pll_info_compact
->line_length_pck
);
87 /* calculate max fps */
88 max_fps
= (vt_pix_clk_hz
* 10) / (pll_info_compact
->frame_length_lines
* pll_info_compact
->line_length_pck
);
89 max_fps
= (max_fps
% 10 >= 5 ? frame_rate
+ 1 : frame_rate
);
91 cis_data
->pclk
= vt_pix_clk_hz
;
92 cis_data
->max_fps
= max_fps
;
93 cis_data
->frame_length_lines
= pll_info_compact
->frame_length_lines
;
94 cis_data
->line_length_pck
= pll_info_compact
->line_length_pck
;
95 cis_data
->line_readOut_time
= sensor_cis_do_div64((u64
)cis_data
->line_length_pck
* (u64
)(1000 * 1000 * 1000), cis_data
->pclk
);
96 cis_data
->rolling_shutter_skew
= (cis_data
->cur_height
- 1) * cis_data
->line_readOut_time
;
97 cis_data
->stream_on
= false;
99 /* Frame valid time calcuration */
100 frame_valid_us
= sensor_cis_do_div64((u64
)cis_data
->cur_height
* (u64
)cis_data
->line_length_pck
* (u64
)(1000 * 1000), cis_data
->pclk
);
101 cis_data
->frame_valid_us_time
= (int)frame_valid_us
;
103 dbg_sensor(1, "%s\n", __func__
);
104 dbg_sensor(1, "Sensor size(%d x %d) setting: SUCCESS!\n",
105 cis_data
->cur_width
, cis_data
->cur_height
);
106 dbg_sensor(1, "Frame Valid(us): %d\n", frame_valid_us
);
107 dbg_sensor(1, "rolling_shutter_skew: %lld\n", cis_data
->rolling_shutter_skew
);
109 dbg_sensor(1, "Fps: %d, max fps(%d)\n", frame_rate
, cis_data
->max_fps
);
110 dbg_sensor(1, "min_frame_time(%d us)\n", cis_data
->min_frame_us_time
);
111 dbg_sensor(1, "Pixel rate(Mbps): %d\n", cis_data
->pclk
/ 1000000);
113 /* Frame period calculation */
114 cis_data
->frame_time
= (cis_data
->line_readOut_time
* cis_data
->cur_height
/ 1000);
115 cis_data
->rolling_shutter_skew
= (cis_data
->cur_height
- 1) * cis_data
->line_readOut_time
;
117 dbg_sensor(1, "[%s] frame_time(%d), rolling_shutter_skew(%lld)\n", __func__
,
118 cis_data
->frame_time
, cis_data
->rolling_shutter_skew
);
120 /* Constant values */
121 cis_data
->min_fine_integration_time
= SENSOR_2X5SP_FINE_INTEGRATION_TIME_MIN
;
122 cis_data
->max_fine_integration_time
= cis_data
->cur_width
;
123 cis_data
->min_coarse_integration_time
= SENSOR_2X5SP_COARSE_INTEGRATION_TIME_MIN
;
124 cis_data
->max_margin_coarse_integration_time
= SENSOR_2X5SP_COARSE_INTEGRATION_TIME_MAX_MARGIN
;
127 int sensor_2x5sp_cis_check_rev(struct v4l2_subdev
*subdev
)
131 struct i2c_client
*client
;
132 struct fimc_is_cis
*cis
= NULL
;
136 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
138 WARN_ON(!cis
->cis_data
);
140 client
= cis
->client
;
141 if (unlikely(!client
)) {
142 err("client is NULL");
146 memset(cis
->cis_data
, 0, sizeof(cis_shared_data
));
147 cis
->rev_flag
= false;
149 I2C_MUTEX_LOCK(cis
->i2c_lock
);
151 ret
= fimc_is_sensor_read8(client
, 0x0002, &rev
);
153 cis
->rev_flag
= true;
156 cis
->cis_data
->cis_rev
= rev
;
157 pr_info("%s : Rev. 0x%X\n", __func__
, rev
);
160 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
165 int sensor_2x5sp_cis_otp_check_awb_ratio(char *unit
, char *golden
, char *limit
)
169 float r_g_min
= (float)(limit
[0]) / 1000;
170 float r_g_max
= (float)(limit
[1]) / 1000;
171 float b_g_min
= (float)(limit
[2]) / 1000;
172 float b_g_max
= (float)(limit
[3]) / 1000;
174 float rg
= (float) ((unit
[1]) | (unit
[0] << 8)) / 16384;
175 float bg
= (float) ((unit
[3]) | (unit
[2] << 8)) / 16384;
177 float golden_rg
= (float) ((golden
[1]) | (golden
[0] << 8)) / 16384;
178 float golden_bg
= (float) ((golden
[3]) | (golden
[2] << 8)) / 16384;
180 if (rg
< (golden_rg
- r_g_min
) || rg
> (golden_rg
+ r_g_max
)) {
181 err("%s(): Final RG calibration factors out of range! rg=0x%x golden_rg=0x%x",
182 __func__
, (unit
[1] | unit
[0] << 8), (golden
[1] | golden
[0] << 8));
186 if (bg
< (golden_bg
- b_g_min
) || bg
> (golden_bg
+ b_g_max
)) {
187 err("%s(): Final BG calibration factors out of range! bg=0x%x, golden_bg=0x%x",
188 __func__
, (unit
[3] | unit
[2] << 8), (golden
[3] | golden
[2] << 8));
195 int sensor_2x5sp_cis_otp_check_crc(struct v4l2_subdev
*subdev
,
196 struct fimc_is_device_sensor
*device
, int group
)
201 char *check_buf
= (char *)&device
->otp_cal_buf
[0][0];
205 /* OTP Group1 CRC check */
206 crc_value
= ((device
->otp_cal_buf
[254][60] << 8) | (device
->otp_cal_buf
[254][61]));
207 crc16
= sensor_cis_otp_get_crc16(&check_buf
[OTP_GRP1_AWB_CRC_START
], OTP_GRP1_AWB_CRC_SIZE
);
208 if (crc_value
!= crc16
) {
209 sensor_cis_otp_data_set(&check_buf
[OTP_GRP1_AWB_CRC_START
], "awb",
210 OTP_GRP1_AWB_CRC_SIZE
, 0xff);
211 err("GR1: Error to AWB CRC16 : 0x%x, cal buffer CRC: 0x%x", crc16
, crc_value
);
214 info("GR1: AWB CRC16 : 0x%x, cal buffer CRC: 0x%x\n", crc16
, crc_value
);
216 crc_value
= ((device
->otp_cal_buf
[254][62] << 8) | (device
->otp_cal_buf
[254][63]));
217 crc16
= sensor_cis_otp_get_crc16(&check_buf
[OTP_GRP1_LSC_XTC_CRC_START
], OTP_GRP1_LSC_XTC_CRC_SIZE
);
218 if (crc_value
!= crc16
) {
219 sensor_cis_otp_data_set(&check_buf
[OTP_GRP1_LSC_XTC_CRC_START
], "lsc_xtc",
220 OTP_GRP1_LSC_XTC_CRC_SIZE
, 0xff);
221 err("GR1: Error to LSC & XTC CRC16 : 0x%x, cal buffer CRC: 0x%x", crc16
, crc_value
);
224 info("GR1: LSC & XTC CRC16 : 0x%x, cal buffer CRC: 0x%x\n", crc16
, crc_value
);
227 /* OTP Group2 CRC check */
228 crc_value
= ((device
->otp_cal_buf
[255][60] << 8) | (device
->otp_cal_buf
[255][61]));
229 crc16
= sensor_cis_otp_get_crc16(&check_buf
[OTP_GRP2_AWB_CRC_START
], OTP_GRP2_AWB_CRC_SIZE
);
230 if (crc_value
!= crc16
) {
231 sensor_cis_otp_data_set(&check_buf
[OTP_GRP2_AWB_CRC_START
], "awb",
232 OTP_GRP2_AWB_CRC_SIZE
, 0xff);
233 err("GR2: Error to AWB CRC16 : 0x%x, cal buffer CRC: 0x%x", crc16
, crc_value
);
236 info("GR2: AWB CRC16 : 0x%x, cal buffer CRC: 0x%x\n", crc16
, crc_value
);
238 crc_value
= ((device
->otp_cal_buf
[255][62] << 8) | (device
->otp_cal_buf
[255][63]));
239 crc16
= sensor_cis_otp_get_crc16(&check_buf
[OTP_GRP2_LSC_XTC_CRC_START
], OTP_GRP2_LSC_XTC_CRC_SIZE
);
240 if (crc_value
!= crc16
) {
241 sensor_cis_otp_data_set(&check_buf
[OTP_GRP2_LSC_XTC_CRC_START
], "lsc_xtc",
242 OTP_GRP2_LSC_XTC_CRC_SIZE
, 0xff);
243 err("GR2: Error to LSC & XTC CRC16 : 0x%x, cal buffer CRC: 0x%x", crc16
, crc_value
);
246 info("GR2: LSC & XTC CRC16 : 0x%x, cal buffer CRC: 0x%x\n", crc16
, crc_value
);
249 err("invalid OTP group when crc check(%d), check map data", group
);
256 static int sensor_2x5sp_cis_otp_check(struct fimc_is_device_sensor
*device
, int group
)
263 /* Group1 valid check */
264 group_flag
= device
->otp_cal_buf
[254][0];
265 if (group_flag
!= OTP_DATA_VALID
) {
266 err("error Group1 OTP data invalid(0x%x)", group_flag
);
274 /* First check Group2 data valid */
275 group_flag
= device
->otp_cal_buf
[255][0];
276 if (group_flag
!= OTP_DATA_VALID
) {
277 err("error Group2 OTP data invalid(0x%x)", group_flag
);
286 err("invalid OTP group when invalid check(%d), check map data", group
);
293 int sensor_2x5sp_cis_otp_read(struct v4l2_subdev
*subdev
, struct fimc_is_device_sensor
*device
)
296 struct fimc_is_cis
*cis
;
297 struct i2c_client
*client
;
304 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
310 client
= cis
->client
;
311 if (unlikely(!client
)) {
312 err("client is NULL");
316 info("OTP read start\n");
317 dbg_sensor(1, "%s, 1. sensor initial setting", __func__
);
319 I2C_MUTEX_LOCK(cis
->i2c_lock
);
321 /* Basic settings for OTP R/W */
322 fimc_is_sensor_write16(client
, 0x6028, 0x4000);
323 fimc_is_sensor_write16(client
, 0x6018, 0x0001);
324 fimc_is_sensor_write16(client
, 0x7002, 0x020C);
325 fimc_is_sensor_write16(client
, 0x6014, 0x0001);
327 usleep_range(3000, 3001);
329 fimc_is_sensor_write16(client
, 0x0136, 0x1A00);
330 fimc_is_sensor_write16(client
, 0x0300, 0x0003);
331 fimc_is_sensor_write16(client
, 0x0302, 0x0001);
332 fimc_is_sensor_write16(client
, 0x0304, 0x0004);
333 fimc_is_sensor_write16(client
, 0x0306, 0x00DD);
334 fimc_is_sensor_write16(client
, 0x030C, 0x0001);
335 fimc_is_sensor_write16(client
, 0x0308, 0x0008);
336 fimc_is_sensor_write16(client
, 0x030A, 0x0001);
337 fimc_is_sensor_write16(client
, 0x030E, 0x0004);
338 fimc_is_sensor_write16(client
, 0x0310, 0x014A);
339 fimc_is_sensor_write16(client
, 0x0312, 0x0000);
341 dbg_sensor(1, "%s, 2. sensor stream on", __func__
);
342 fimc_is_sensor_write16(client
, 0x6028, 0x4000);
343 fimc_is_sensor_write8(client
, 0x0100, 0x01);
346 CALL_CISOPS(cis
, cis_wait_streamon
, subdev
);
348 dbg_sensor(1, "%s, 3. page select & read cal", __func__
);
349 for (page
= OTP_PAGE_START
; page
<= OTP_PAGE_END
; page
++) {
350 /* page select & read start */
351 fimc_is_sensor_write16(client
, OTP_PAGE_SELECT
, page
);
352 fimc_is_sensor_write16(client
, OTP_PAGE_CTRL
, 0x0100);
354 /* wait 0x0A00 == 0 [0]: read completed with no errors */
356 while (retry
> 0 && val
) {
357 fimc_is_sensor_read16(client
, OTP_PAGE_CTRL
, &val
);
361 usleep_range(100, 100);
366 err("%s: OTP page[%d] read fail with err(%d)\n",
367 __func__
, page
, val
);
369 for (i
= 0; i
< OTP_PAGE_SIZE
; i
++) {
370 fimc_is_sensor_read8(client
, OTP_PAGE_BASE
+ i
, &device
->otp_cal_buf
[page
][i
]);
371 dbg_sensor(2, "cal: [%d][0x%x]: %x\n", page
, OTP_PAGE_BASE
+ i
, device
->otp_cal_buf
[page
][i
]);
374 /* make initial state */
375 fimc_is_sensor_write16(client
, OTP_PAGE_CTRL
, 0x0000);
378 fimc_is_sensor_write8(client
, 0x0100, 0x00);
380 info("OTP read end\n");
382 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
387 int sensor_2x5sp_cis_otp(struct v4l2_subdev
*subdev
, struct fimc_is_device_sensor
*device
)
392 char *otp_buf
= (char *)&device
->otp_cal_buf
[0][0];
394 ret
= sensor_cis_otp_read_file(OTP_DATA_PATH
, (void *)device
->otp_cal_buf
, OTP_PAGE_SIZE
* 256);
397 ret
= sensor_2x5sp_cis_otp_read(subdev
, device
);
399 sensor_cis_otp_data_set(&otp_buf
[0], "all", OTP_PAGE_SIZE
* 256, 0xff);
400 err("Don't read to 2x5 OTP data");
404 /* Write to OTP data at file */
405 ret
= sensor_cis_otp_write_file(OTP_DATA_PATH
, (void *)device
->otp_cal_buf
, OTP_PAGE_SIZE
* 256);
407 sensor_cis_otp_data_set(&otp_buf
[0], "all", OTP_PAGE_SIZE
* 256, 0xff);
408 err("2x5 OTP data don't file write");
413 /* Need to first check GROUP2 */
414 for (i
= OTP_GROUP_MAX
- 1; i
>= OTP_GROUP_ONE
; i
--) {
415 /* OTP valid check */
416 otp_group
= sensor_2x5sp_cis_otp_check(device
, i
);
418 if (i
== OTP_GROUP_ONE
) {
419 sensor_cis_otp_data_set(&otp_buf
[0], "all", OTP_PAGE_SIZE
* 256, 0xff);
420 err("All OTP data are invalid, check module");
431 ret
= sensor_2x5sp_cis_otp_check_crc(subdev
, device
, otp_group
);
433 err("All OTP data CRC check fail, check module");
435 device
->cal_status
[CAMERA_CRC_INDEX_AWB
] = CRC_ERROR
;
438 err("%s: OTP group%d data availble\n", __func__
, otp_group
);
440 device
->cal_status
[CAMERA_CRC_INDEX_AWB
] = CRC_NO_ERROR
;
442 ret
= sensor_2x5sp_cis_otp_check_awb_ratio(&otp_buf
[(253 + otp_group
) * OTP_PAGE_SIZE
+ OTP_AWB_UNIT_OFFSET
],
443 &otp_buf
[(253 + otp_group
) * OTP_PAGE_SIZE
+ OTP_AWB_GOLDEN_OFFSET
],
444 &otp_buf
[(253 + otp_group
) * OTP_PAGE_SIZE
+ OTP_AWB_LIMIT_OFFSET
]);
447 err("%s(): 2X5 OTP AWB Group%d ratio out of limit(%d)", __func__
, otp_group
, ret
);
448 device
->cal_status
[CAMERA_CRC_INDEX_AWB
] = LIMIT_FAILURE
;
458 int sensor_2x5sp_cis_init(struct v4l2_subdev
*subdev
)
461 struct fimc_is_cis
*cis
;
462 struct fimc_is_module_enum
*module
;
463 struct fimc_is_device_sensor
*device
= NULL
;
464 u32 setfile_index
= 0;
465 cis_setting_info setinfo
;
467 setinfo
.return_value
= 0;
469 setinfo
.param
= NULL
;
473 module
= (struct fimc_is_module_enum
*)v4l2_get_subdev_hostdata(subdev
);
475 device
= (struct fimc_is_device_sensor
*)v4l2_get_subdev_hostdata(module
->subdev
);
477 err("device sensor is NULL");
482 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
489 FIMC_BUG(!cis
->cis_data
);
490 memset(cis
->cis_data
, 0, sizeof(cis_shared_data
));
492 cis
->cis_data
->cur_width
= SENSOR_2X5SP_MAX_WIDTH
;
493 cis
->cis_data
->cur_height
= SENSOR_2X5SP_MAX_HEIGHT
;
494 cis
->cis_data
->low_expo_start
= 33000;
495 cis
->need_mode_change
= false;
497 sensor_2x5sp_cis_data_calculation(sensor_2x5sp_pllinfos
[setfile_index
], cis
->cis_data
);
499 setinfo
.return_value
= 0;
500 CALL_CISOPS(cis
, cis_get_min_exposure_time
, subdev
, &setinfo
.return_value
);
501 dbg_sensor(1, "[%s] min exposure time : %d\n", __func__
, setinfo
.return_value
);
502 setinfo
.return_value
= 0;
503 CALL_CISOPS(cis
, cis_get_max_exposure_time
, subdev
, &setinfo
.return_value
);
504 dbg_sensor(1, "[%s] max exposure time : %d\n", __func__
, setinfo
.return_value
);
505 setinfo
.return_value
= 0;
506 CALL_CISOPS(cis
, cis_get_min_analog_gain
, subdev
, &setinfo
.return_value
);
507 dbg_sensor(1, "[%s] min again : %d\n", __func__
, setinfo
.return_value
);
508 setinfo
.return_value
= 0;
509 CALL_CISOPS(cis
, cis_get_max_analog_gain
, subdev
, &setinfo
.return_value
);
510 dbg_sensor(1, "[%s] max again : %d\n", __func__
, setinfo
.return_value
);
511 setinfo
.return_value
= 0;
512 CALL_CISOPS(cis
, cis_get_min_digital_gain
, subdev
, &setinfo
.return_value
);
513 dbg_sensor(1, "[%s] min dgain : %d\n", __func__
, setinfo
.return_value
);
514 setinfo
.return_value
= 0;
515 CALL_CISOPS(cis
, cis_get_max_digital_gain
, subdev
, &setinfo
.return_value
);
516 dbg_sensor(1, "[%s] max dgain : %d\n", __func__
, setinfo
.return_value
);
518 #ifdef DEBUG_SENSOR_TIME
519 do_gettimeofday(&end
);
520 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
)*1000000 + (end
.tv_usec
- st
.tv_usec
));
523 if (device
->use_otp_cal
) {
524 ret
= sensor_2x5sp_cis_otp(subdev
, device
);
526 err("2x5sp OTP data have probelm, check module");
535 int sensor_2x5sp_cis_log_status(struct v4l2_subdev
*subdev
)
538 struct fimc_is_cis
*cis
;
539 struct i2c_client
*client
= NULL
;
545 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
551 client
= cis
->client
;
552 if (unlikely(!client
)) {
553 err("client is NULL");
557 I2C_MUTEX_LOCK(cis
->i2c_lock
);
559 pr_err("[SEN:DUMP] *******************************\n");
560 fimc_is_sensor_read16(client
, 0x0000, &data16
);
561 pr_err("[SEN:DUMP] model_id(%x)\n", data16
);
562 fimc_is_sensor_read8(client
, 0x0002, &data8
);
563 pr_err("[SEN:DUMP] revision_number(%x)\n", data8
);
564 fimc_is_sensor_read8(client
, 0x0005, &data8
);
565 pr_err("[SEN:DUMP] frame_count(%x)\n", data8
);
566 fimc_is_sensor_read8(client
, 0x0100, &data8
);
567 pr_err("[SEN:DUMP] mode_select(%x)\n", data8
);
569 sensor_cis_dump_registers(subdev
, sensor_2x5sp_setfiles
[0], sensor_2x5sp_setfile_sizes
[0]);
571 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
573 pr_err("[SEN:DUMP] *******************************\n");
578 #if USE_GROUP_PARAM_HOLD
579 static int sensor_2x5sp_cis_group_param_hold_func(struct v4l2_subdev
*subdev
, unsigned int hold
)
582 struct fimc_is_cis
*cis
= NULL
;
583 struct i2c_client
*client
= NULL
;
587 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
590 FIMC_BUG(!cis
->cis_data
);
592 client
= cis
->client
;
593 if (unlikely(!client
)) {
594 err("client is NULL");
599 if (hold
== cis
->cis_data
->group_param_hold
) {
600 pr_debug("already group_param_hold (%d)\n", cis
->cis_data
->group_param_hold
);
604 ret
= fimc_is_sensor_write8(client
, 0x0104, hold
);
608 cis
->cis_data
->group_param_hold
= hold
;
614 static inline int sensor_2x5sp_cis_group_param_hold_func(struct v4l2_subdev
*subdev
, unsigned int hold
)
619 * hold : true - hold, flase - no hold
621 * return: 0 - no effect(already hold or no hold)
622 * positive - setted by request
623 * negative - ERROR value
625 int sensor_2x5sp_cis_group_param_hold(struct v4l2_subdev
*subdev
, bool hold
)
628 struct fimc_is_cis
*cis
= NULL
;
632 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
635 FIMC_BUG(!cis
->cis_data
);
637 I2C_MUTEX_LOCK(cis
->i2c_lock
);
639 ret
= sensor_2x5sp_cis_group_param_hold_func(subdev
, hold
);
644 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
649 int sensor_2x5sp_cis_set_global_setting(struct v4l2_subdev
*subdev
)
652 struct fimc_is_cis
*cis
= NULL
;
656 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
659 I2C_MUTEX_LOCK(cis
->i2c_lock
);
661 ret
= sensor_cis_set_registers(subdev
, sensor_2x5sp_global
, sensor_2x5sp_global_size
);
664 err("sensor_3p8sp_set_registers fail!!");
668 dbg_sensor(1, "[%s] global setting done\n", __func__
);
671 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
676 int sensor_2x5sp_cis_mode_change(struct v4l2_subdev
*subdev
, u32 mode
)
679 struct fimc_is_cis
*cis
= NULL
;
683 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
685 FIMC_BUG(!cis
->cis_data
);
687 if (mode
> sensor_2x5sp_max_setfile_num
) {
688 err("invalid mode(%d)!!", mode
);
692 sensor_2x5sp_cis_data_calculation(sensor_2x5sp_pllinfos
[mode
], cis
->cis_data
);
694 I2C_MUTEX_LOCK(cis
->i2c_lock
);
696 ret
= sensor_cis_set_registers(subdev
, sensor_2x5sp_setfiles
[mode
], sensor_2x5sp_setfile_sizes
[mode
]);
698 err("sensor_2x5sp_set_registers fail!!");
702 cis
->cis_data
->frame_time
= (cis
->cis_data
->line_readOut_time
* cis
->cis_data
->cur_height
/ 1000);
703 cis
->cis_data
->rolling_shutter_skew
= (cis
->cis_data
->cur_height
- 1) * cis
->cis_data
->line_readOut_time
;
704 dbg_sensor(1, "[%s] frame_time(%d), rolling_shutter_skew(%lld)\n", __func__
,
705 cis
->cis_data
->frame_time
, cis
->cis_data
->rolling_shutter_skew
);
707 dbg_sensor(1, "[%s] mode changed(%d)\n", __func__
, mode
);
710 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
715 int sensor_2x5sp_cis_mode_change_throttling(struct v4l2_subdev
*subdev
)
718 struct fimc_is_cis
*cis
= NULL
;
722 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
724 FIMC_BUG(!cis
->cis_data
);
726 sensor_2x5sp_cis_data_calculation(sensor_2x5sp_pllinfo_throttling
, cis
->cis_data
);
728 I2C_MUTEX_LOCK(cis
->i2c_lock
);
730 ret
= sensor_cis_set_registers(subdev
, sensor_2x5sp_setfile_throttling
,
731 sensor_2x5sp_setfile_throttling_size
);
733 err("sensor_gm1sp_set_registers fail!!");
737 cis
->cis_data
->frame_time
= (cis
->cis_data
->line_readOut_time
* cis
->cis_data
->cur_height
/ 1000);
738 cis
->cis_data
->rolling_shutter_skew
= (cis
->cis_data
->cur_height
- 1) * cis
->cis_data
->line_readOut_time
;
739 dbg_sensor(1, "[%s] frame_time(%d), rolling_shutter_skew(%lld)\n", __func__
,
740 cis
->cis_data
->frame_time
, cis
->cis_data
->rolling_shutter_skew
);
742 dbg_sensor(1, "[%s] throttling mode changed\n", __func__
);
745 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
751 int sensor_2x5sp_cis_set_size(struct v4l2_subdev
*subdev
, cis_shared_data
*cis_data
)
756 int sensor_2x5sp_cis_stream_on(struct v4l2_subdev
*subdev
)
759 struct fimc_is_cis
*cis
;
760 struct i2c_client
*client
;
761 cis_shared_data
*cis_data
;
763 #ifdef DEBUG_SENSOR_TIME
764 struct timeval st
, end
;
766 do_gettimeofday(&st
);
771 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
774 FIMC_BUG(!cis
->cis_data
);
776 client
= cis
->client
;
777 if (unlikely(!client
)) {
778 err("client is NULL");
782 cis_data
= cis
->cis_data
;
784 dbg_sensor(1, "[MOD:D:%d] %s\n", cis
->id
, __func__
);
786 I2C_MUTEX_LOCK(cis
->i2c_lock
);
788 ret
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
790 err("group_param_hold_func failed at stream on");
792 #ifdef DEBUG_2X5SP_PLL
796 fimc_is_sensor_read16(client
, 0x0300, &pll
);
797 dbg_sensor(1, "______ vt_pix_clk_div(%x)\n", pll
);
798 fimc_is_sensor_read16(client
, 0x0302, &pll
);
799 dbg_sensor(1, "______ vt_sys_clk_div(%x)\n", pll
);
800 fimc_is_sensor_read16(client
, 0x0304, &pll
);
801 dbg_sensor(1, "______ pre_pll_clk_div(%x)\n", pll
);
802 fimc_is_sensor_read16(client
, 0x0306, &pll
);
803 dbg_sensor(1, "______ pll_multiplier(%x)\n", pll
);
804 fimc_is_sensor_read16(client
, 0x0308, &pll
);
805 dbg_sensor(1, "______ op_pix_clk_div(%x)\n", pll
);
806 fimc_is_sensor_read16(client
, 0x030a, &pll
);
807 dbg_sensor(1, "______ op_sys_clk_div(%x)\n", pll
);
809 fimc_is_sensor_read16(client
, 0x030c, &pll
);
810 dbg_sensor(1, "______ secnd_pre_pll_clk_div(%x)\n", pll
);
811 fimc_is_sensor_read16(client
, 0x030e, &pll
);
812 dbg_sensor(1, "______ secnd_pll_multiplier(%x)\n", pll
);
813 fimc_is_sensor_read16(client
, 0x0340, &pll
);
814 dbg_sensor(1, "______ frame_length_lines(%x)\n", pll
);
815 fimc_is_sensor_read16(client
, 0x0342, &pll
);
816 dbg_sensor(1, "______ line_length_pck(%x)\n", pll
);
820 /* Sensor stream on */
821 fimc_is_sensor_write16(client
, 0x6028, 0x4000);
822 fimc_is_sensor_write8(client
, 0x0100, 0x01);
824 cis_data
->stream_on
= true;
826 #ifdef DEBUG_SENSOR_TIME
827 do_gettimeofday(&end
);
828 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
831 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
836 int sensor_2x5sp_cis_stream_off(struct v4l2_subdev
*subdev
)
839 struct fimc_is_cis
*cis
;
840 struct i2c_client
*client
;
841 cis_shared_data
*cis_data
;
843 #ifdef DEBUG_SENSOR_TIME
844 struct timeval st
, end
;
846 do_gettimeofday(&st
);
851 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
854 FIMC_BUG(!cis
->cis_data
);
856 client
= cis
->client
;
857 if (unlikely(!client
)) {
858 err("client is NULL");
862 cis_data
= cis
->cis_data
;
864 dbg_sensor(1, "[MOD:D:%d] %s\n", cis
->id
, __func__
);
866 I2C_MUTEX_LOCK(cis
->i2c_lock
);
868 ret
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
870 err("group_param_hold_func failed at stream off");
872 fimc_is_sensor_write16(client
, 0x6028, 0x4000);
874 /* during LEC mode, clear 0x0BCC before stream off for next frame
875 * After cancelled, restore value
877 if (cis
->long_term_mode
.sen_strm_off_on_enable
)
878 fimc_is_sensor_write8(client
, 0x0BCC, 0);
880 fimc_is_sensor_write8(client
, 0x0BCC, 0x1);
882 /* Sensor stream off */
883 fimc_is_sensor_write8(client
, 0x0100, 0x00);
885 cis_data
->stream_on
= false;
887 #ifdef DEBUG_SENSOR_TIME
888 do_gettimeofday(&end
);
889 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
892 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
897 int sensor_2x5sp_cis_set_exposure_time(struct v4l2_subdev
*subdev
, struct ae_param
*target_exposure
)
901 struct fimc_is_cis
*cis
;
902 struct i2c_client
*client
;
903 cis_shared_data
*cis_data
;
905 u32 vt_pic_clk_freq_mhz
= 0;
906 u16 long_coarse_int
= 0;
907 u16 short_coarse_int
= 0;
908 u16 middle_coarse_int
= 0;
909 u32 line_length_pck
= 0;
910 u32 min_fine_int
= 0;
913 u32 multiple_ratio
= 1;
914 #ifdef DEBUG_SENSOR_TIME
915 struct timeval st
, end
;
917 do_gettimeofday(&st
);
921 FIMC_BUG(!target_exposure
);
923 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
926 FIMC_BUG(!cis
->cis_data
);
928 client
= cis
->client
;
929 if (unlikely(!client
)) {
930 err("client is NULL");
934 if ((target_exposure
->long_val
<= 0) || (target_exposure
->short_val
<= 0)) {
935 err("[%s] invalid target exposure(%d, %d)\n", __func__
,
936 target_exposure
->long_val
, target_exposure
->short_val
);
940 cis_data
= cis
->cis_data
;
942 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), target long(%d), short(%d), middle(%d)\n", cis
->id
, __func__
,
943 cis_data
->sen_vsync_count
,
944 target_exposure
->long_val
, target_exposure
->short_val
, target_exposure
->middle_val
);
946 vt_pic_clk_freq_mhz
= cis_data
->pclk
/ (1000 * 1000);
947 line_length_pck
= cis_data
->line_length_pck
;
948 min_fine_int
= cis_data
->min_fine_integration_time
;
950 lte_shifter
= cis
->long_term_mode
.sen_strm_off_on_enable
?
951 GET_2X5SP_LTE_SHIFT_CNT(target_exposure
->long_val
) : 0;
953 /* In 24M remosaic mode, set 4 times of exposure val */
954 if (cis_data
->sens_config_index_cur
== SENSOR_2X5SP_5760X4320_24FPS
) {
956 dbg_sensor(1, "[mod:d:%d] %s, Set 4 times of coarse_int for 24M mode\n", cis
->id
, __func__
);
959 numerator
= (u64
)cis_data
->pclk
* target_exposure
->long_val
* multiple_ratio
;
960 long_coarse_int
= (numerator
- min_fine_int
)
961 /(1000 * 1000) / line_length_pck
/ (1 << lte_shifter
);
962 numerator
= (u64
)cis_data
->pclk
* target_exposure
->short_val
* multiple_ratio
;
963 short_coarse_int
= (numerator
- min_fine_int
)
964 /(1000 * 1000) / line_length_pck
/ (1 << lte_shifter
);
965 numerator
= (u64
)cis_data
->pclk
* target_exposure
->middle_val
* multiple_ratio
;
966 middle_coarse_int
= (numerator
- min_fine_int
)
967 /(1000 * 1000) / line_length_pck
/ (1 << lte_shifter
);
969 /* 4FDSUM mode should be set half of coarse integration */
970 if (cis_data
->sens_config_index_cur
== SENSOR_2X5SP_2880X2160_30FPS
971 || cis_data
->sens_config_index_cur
== SENSOR_2X5SP_1920X1080_120FPS
972 || cis_data
->sens_config_index_cur
== SENSOR_2X5SP_1280X720_240FPS
) {
973 long_coarse_int
/= 2;
974 short_coarse_int
/= 2;
975 middle_coarse_int
/= 2;
978 if (long_coarse_int
> cis_data
->max_coarse_integration_time
) {
979 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), long coarse(%d) max(%d)\n", cis
->id
, __func__
,
980 cis_data
->sen_vsync_count
, long_coarse_int
, cis_data
->max_coarse_integration_time
);
981 long_coarse_int
= cis_data
->max_coarse_integration_time
;
984 if (short_coarse_int
> cis_data
->max_coarse_integration_time
) {
985 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), short coarse(%d) max(%d)\n", cis
->id
, __func__
,
986 cis_data
->sen_vsync_count
, short_coarse_int
, cis_data
->max_coarse_integration_time
);
987 short_coarse_int
= cis_data
->max_coarse_integration_time
;
990 if (middle_coarse_int
> cis_data
->max_coarse_integration_time
) {
991 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), middle coarse(%d) max(%d)\n", cis
->id
, __func__
,
992 cis_data
->sen_vsync_count
, middle_coarse_int
, cis_data
->max_coarse_integration_time
);
993 middle_coarse_int
= cis_data
->max_coarse_integration_time
;
996 if (long_coarse_int
< cis_data
->min_coarse_integration_time
) {
997 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), long coarse(%d) min(%d)\n", cis
->id
, __func__
,
998 cis_data
->sen_vsync_count
, long_coarse_int
, cis_data
->min_coarse_integration_time
);
999 long_coarse_int
= cis_data
->min_coarse_integration_time
;
1002 if (short_coarse_int
< cis_data
->min_coarse_integration_time
) {
1003 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), short coarse(%d) min(%d)\n", cis
->id
, __func__
,
1004 cis_data
->sen_vsync_count
, short_coarse_int
, cis_data
->min_coarse_integration_time
);
1005 short_coarse_int
= cis_data
->min_coarse_integration_time
;
1008 if (middle_coarse_int
< cis_data
->min_coarse_integration_time
) {
1009 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), middle coarse(%d) min(%d)\n", cis
->id
, __func__
,
1010 cis_data
->sen_vsync_count
, middle_coarse_int
, cis_data
->min_coarse_integration_time
);
1011 middle_coarse_int
= cis_data
->min_coarse_integration_time
;
1014 I2C_MUTEX_LOCK(cis
->i2c_lock
);
1016 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
1022 /* Short exposure */
1023 ret
= fimc_is_sensor_write16(client
, 0x0202, short_coarse_int
);
1028 if (cis_data
->is_data
.wdr_mode
!= CAMERA_WDR_OFF
) {
1029 ret
= fimc_is_sensor_write16(client
, 0x0226, long_coarse_int
);
1033 ret
= fimc_is_sensor_write16(client
, 0x022C, middle_coarse_int
);
1038 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), vt_pic_clk_freq_mhz (%d), line_length_pck(%d), min_fine_int (%d)\n",
1039 cis
->id
, __func__
, cis_data
->sen_vsync_count
, vt_pic_clk_freq_mhz
, line_length_pck
, min_fine_int
);
1040 dbg_sensor(1, "[MOD:D:%d] %s, vsync_cnt(%d), frame_length_lines(%#x), coarse_int (L:%#x, S:%#x, M:%#x)\n",
1041 cis
->id
, __func__
, cis_data
->sen_vsync_count
, cis_data
->frame_length_lines
,
1042 long_coarse_int
, short_coarse_int
, middle_coarse_int
);
1044 #ifdef DEBUG_SENSOR_TIME
1045 do_gettimeofday(&end
);
1046 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1051 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
1056 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
1061 int sensor_2x5sp_cis_get_min_exposure_time(struct v4l2_subdev
*subdev
, u32
*min_expo
)
1064 struct fimc_is_cis
*cis
= NULL
;
1065 cis_shared_data
*cis_data
= NULL
;
1066 u32 min_integration_time
= 0;
1069 u32 vt_pic_clk_freq_mhz
= 0;
1070 u32 line_length_pck
= 0;
1072 #ifdef DEBUG_SENSOR_TIME
1073 struct timeval st
, end
;
1075 do_gettimeofday(&st
);
1079 FIMC_BUG(!min_expo
);
1081 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1084 FIMC_BUG(!cis
->cis_data
);
1086 cis_data
= cis
->cis_data
;
1088 vt_pic_clk_freq_mhz
= cis_data
->pclk
/ (1000 * 1000);
1089 if (vt_pic_clk_freq_mhz
== 0) {
1090 pr_err("[MOD:D:%d] %s, Invalid vt_pic_clk_freq_mhz(%d)\n", cis
->id
, __func__
, vt_pic_clk_freq_mhz
);
1093 line_length_pck
= cis_data
->line_length_pck
;
1094 min_coarse
= cis_data
->min_coarse_integration_time
;
1095 min_fine
= cis_data
->min_fine_integration_time
;
1097 min_integration_time
= ((line_length_pck
* min_coarse
) + min_fine
) / vt_pic_clk_freq_mhz
;
1098 *min_expo
= min_integration_time
;
1100 dbg_sensor(1, "[%s] min integration time %d\n", __func__
, min_integration_time
);
1102 #ifdef DEBUG_SENSOR_TIME
1103 do_gettimeofday(&end
);
1104 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1111 int sensor_2x5sp_cis_get_max_exposure_time(struct v4l2_subdev
*subdev
, u32
*max_expo
)
1114 struct fimc_is_cis
*cis
;
1115 cis_shared_data
*cis_data
;
1116 u32 max_integration_time
= 0;
1117 u32 max_coarse_margin
= 0;
1118 u32 max_fine_margin
= 0;
1121 u32 vt_pic_clk_freq_mhz
= 0;
1122 u32 line_length_pck
= 0;
1123 u32 frame_length_lines
= 0;
1124 u32 multiple_ratio
= 1;
1126 #ifdef DEBUG_SENSOR_TIME
1127 struct timeval st
, end
;
1129 do_gettimeofday(&st
);
1133 FIMC_BUG(!max_expo
);
1135 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1138 FIMC_BUG(!cis
->cis_data
);
1140 cis_data
= cis
->cis_data
;
1142 vt_pic_clk_freq_mhz
= cis_data
->pclk
/ (1000 * 1000);
1143 if (vt_pic_clk_freq_mhz
== 0) {
1144 pr_err("[MOD:D:%d] %s, Invalid vt_pic_clk_freq_mhz(%d)\n", cis
->id
, __func__
, vt_pic_clk_freq_mhz
);
1147 line_length_pck
= cis_data
->line_length_pck
;
1148 frame_length_lines
= cis_data
->frame_length_lines
;
1150 max_coarse_margin
= cis_data
->max_margin_coarse_integration_time
;
1151 max_fine_margin
= line_length_pck
- cis_data
->min_fine_integration_time
;
1152 max_coarse
= frame_length_lines
- max_coarse_margin
;
1153 max_fine
= cis_data
->max_fine_integration_time
;
1155 max_integration_time
= ((line_length_pck
* max_coarse
) + max_fine
) / vt_pic_clk_freq_mhz
;
1157 *max_expo
= max_integration_time
;
1159 /* In 24M remosaic mode, set 4 times of max_coarse_integration_time */
1160 if (cis_data
->sens_config_index_cur
== SENSOR_2X5SP_5760X4320_24FPS
) {
1162 dbg_sensor(1, "[mod:d:%d] %s, Set 4 times of coarse_int for 24M mode\n", cis
->id
, __func__
);
1165 /* TODO: Is this values update here? */
1166 cis_data
->max_margin_fine_integration_time
= max_fine_margin
;
1167 cis_data
->max_coarse_integration_time
= max_coarse
* multiple_ratio
;
1169 dbg_sensor(1, "[%s] max integration time %d, max margin fine integration %d, max coarse integration %d\n",
1170 __func__
, max_integration_time
, cis_data
->max_margin_fine_integration_time
,
1171 cis_data
->max_coarse_integration_time
);
1173 #ifdef DEBUG_SENSOR_TIME
1174 do_gettimeofday(&end
);
1175 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1182 int sensor_2x5sp_cis_adjust_frame_duration(struct v4l2_subdev
*subdev
,
1183 u32 input_exposure_time
,
1184 u32
*target_duration
)
1187 struct fimc_is_cis
*cis
;
1188 cis_shared_data
*cis_data
;
1190 u32 vt_pic_clk_freq_mhz
= 0;
1191 u32 line_length_pck
= 0;
1192 u32 frame_length_lines
= 0;
1193 u32 frame_duration
= 0;
1196 u32 multiple_ratio
= 1;
1198 #ifdef DEBUG_SENSOR_TIME
1199 struct timeval st
, end
;
1201 do_gettimeofday(&st
);
1205 FIMC_BUG(!target_duration
);
1207 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1210 FIMC_BUG(!cis
->cis_data
);
1212 cis_data
= cis
->cis_data
;
1214 lte_shifter
= cis
->long_term_mode
.sen_strm_off_on_enable
?
1215 GET_2X5SP_LTE_SHIFT_CNT(input_exposure_time
) : 0;
1217 /* In 24M remosaic mode, set 4 times of frame_length_lines */
1218 if (cis_data
->sens_config_index_cur
== SENSOR_2X5SP_5760X4320_24FPS
) {
1220 dbg_sensor(1, "[mod:d:%d] %s, Set 4 times of coarse_int for 24M mode\n", cis
->id
, __func__
);
1223 vt_pic_clk_freq_mhz
= cis_data
->pclk
/ (1000 * 1000);
1224 line_length_pck
= cis_data
->line_length_pck
;
1225 numerator
= (u64
)cis_data
->pclk
* input_exposure_time
* multiple_ratio
;
1226 frame_length_lines
= (u16
)((numerator
/ (1000 * 1000))/ line_length_pck
/ (1 << lte_shifter
));
1227 frame_length_lines
+= cis_data
->max_margin_coarse_integration_time
;
1229 numerator
= (u64
)frame_length_lines
* line_length_pck
;
1230 frame_duration
= (numerator
<< lte_shifter
) / vt_pic_clk_freq_mhz
;
1232 dbg_sensor(1, "[%s](vsync cnt = %d) input exp(%d), adj duration, frame duraion(%d), min_frame_us(%d)\n",
1233 __func__
, cis_data
->sen_vsync_count
, input_exposure_time
,
1234 frame_duration
, cis_data
->min_frame_us_time
);
1235 dbg_sensor(1, "[%s](vsync cnt = %d) adj duration, frame duraion(%d), min_frame_us(%d)\n",
1236 __func__
, cis_data
->sen_vsync_count
, frame_duration
, cis_data
->min_frame_us_time
);
1238 *target_duration
= MAX(frame_duration
, cis_data
->min_frame_us_time
);
1240 #ifdef DEBUG_SENSOR_TIME
1241 do_gettimeofday(&end
);
1242 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1248 int sensor_2x5sp_cis_set_frame_duration(struct v4l2_subdev
*subdev
, u32 frame_duration
)
1252 struct fimc_is_cis
*cis
;
1253 struct i2c_client
*client
;
1254 cis_shared_data
*cis_data
;
1256 u32 line_length_pck
= 0;
1257 u16 frame_length_lines
= 0;
1259 u32 max_coarse_integration_time
= 0;
1262 #ifdef DEBUG_SENSOR_TIME
1263 struct timeval st
, end
;
1265 do_gettimeofday(&st
);
1270 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1273 FIMC_BUG(!cis
->cis_data
);
1275 client
= cis
->client
;
1276 if (unlikely(!client
)) {
1277 err("client is NULL");
1281 cis_data
= cis
->cis_data
;
1283 if (frame_duration
< cis_data
->min_frame_us_time
) {
1284 dbg_sensor(1, "frame duration is less than min(%d)\n", frame_duration
);
1285 frame_duration
= cis_data
->min_frame_us_time
;
1288 lte_shifter
= cis
->long_term_mode
.sen_strm_off_on_enable
?
1289 GET_2X5SP_LTE_SHIFT_CNT(frame_duration
) : 0;
1291 line_length_pck
= cis_data
->line_length_pck
;
1292 numerator
= (u64
)cis_data
->pclk
* frame_duration
;
1293 frame_length_lines
= (u16
)((numerator
/ line_length_pck
) / (1000 * 1000) / (1 << lte_shifter
));
1295 dbg_sensor(1, "[MOD:D:%d] %s, vt_pic_clk(%#x) frame_duration = %d us,"
1296 KERN_CONT
"(line_length_pck%#x), frame_length_lines(%#x)\n",
1297 cis
->id
, __func__
, cis_data
->pclk
, frame_duration
, line_length_pck
, frame_length_lines
);
1299 I2C_MUTEX_LOCK(cis
->i2c_lock
);
1301 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
1307 ret
= fimc_is_sensor_write16(client
, 0x0340, frame_length_lines
);
1311 cis_data
->cur_frame_us_time
= frame_duration
;
1312 cis_data
->frame_length_lines
= frame_length_lines
;
1314 max_coarse_integration_time
= cis_data
->frame_length_lines
- cis_data
->max_margin_coarse_integration_time
;
1315 cis_data
->max_coarse_integration_time
= max_coarse_integration_time
;
1317 #ifdef DEBUG_SENSOR_TIME
1318 do_gettimeofday(&end
);
1319 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1324 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
1329 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
1334 int sensor_2x5sp_cis_set_frame_rate(struct v4l2_subdev
*subdev
, u32 min_fps
)
1337 struct fimc_is_cis
*cis
;
1338 cis_shared_data
*cis_data
;
1340 u32 frame_duration
= 0;
1342 #ifdef DEBUG_SENSOR_TIME
1343 struct timeval st
, end
;
1345 do_gettimeofday(&st
);
1350 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1353 FIMC_BUG(!cis
->cis_data
);
1355 cis_data
= cis
->cis_data
;
1357 if (min_fps
> cis_data
->max_fps
) {
1358 err("[MOD:D:%d] %s, request FPS is too high(%d), set to max(%d)\n",
1359 cis
->id
, __func__
, min_fps
, cis_data
->max_fps
);
1360 min_fps
= cis_data
->max_fps
;
1364 err("[MOD:D:%d] %s, request FPS is 0, set to min FPS(1)\n",
1369 frame_duration
= (1 * 1000 * 1000) / min_fps
;
1371 dbg_sensor(1, "[MOD:D:%d] %s, set FPS(%d), frame duration(%d)\n",
1372 cis
->id
, __func__
, min_fps
, frame_duration
);
1374 ret
= sensor_2x5sp_cis_set_frame_duration(subdev
, frame_duration
);
1376 err("[MOD:D:%d] %s, set frame duration is fail(%d)\n",
1377 cis
->id
, __func__
, ret
);
1381 cis_data
->min_frame_us_time
= frame_duration
;
1383 #ifdef DEBUG_SENSOR_TIME
1384 do_gettimeofday(&end
);
1385 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1393 int sensor_2x5sp_cis_adjust_analog_gain(struct v4l2_subdev
*subdev
, u32 input_again
, u32
*target_permile
)
1396 struct fimc_is_cis
*cis
;
1397 cis_shared_data
*cis_data
;
1400 u32 again_permile
= 0;
1402 #ifdef DEBUG_SENSOR_TIME
1403 struct timeval st
, end
;
1405 do_gettimeofday(&st
);
1409 FIMC_BUG(!target_permile
);
1411 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1414 FIMC_BUG(!cis
->cis_data
);
1416 cis_data
= cis
->cis_data
;
1418 again_code
= sensor_cis_calc_again_code(input_again
);
1420 if (again_code
> cis_data
->max_analog_gain
[0])
1421 again_code
= cis_data
->max_analog_gain
[0];
1422 else if (again_code
< cis_data
->min_analog_gain
[0])
1423 again_code
= cis_data
->min_analog_gain
[0];
1425 again_permile
= sensor_cis_calc_again_permile(again_code
);
1427 dbg_sensor(1, "[%s] min again(%d), max(%d), input_again(%d), code(%d), permile(%d)\n", __func__
,
1428 cis_data
->max_analog_gain
[0],
1429 cis_data
->min_analog_gain
[0],
1434 *target_permile
= again_permile
;
1439 int sensor_2x5sp_cis_set_analog_gain(struct v4l2_subdev
*subdev
, struct ae_param
*again
)
1443 struct fimc_is_cis
*cis
;
1444 struct i2c_client
*client
;
1446 u16 analog_gain
= 0;
1448 #ifdef DEBUG_SENSOR_TIME
1449 struct timeval st
, end
;
1451 do_gettimeofday(&st
);
1457 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1461 client
= cis
->client
;
1462 if (unlikely(!client
)) {
1463 err("client is NULL");
1467 analog_gain
= (u16
)sensor_cis_calc_again_code(again
->val
);
1469 if (analog_gain
< cis
->cis_data
->min_analog_gain
[0])
1470 analog_gain
= cis
->cis_data
->min_analog_gain
[0];
1472 if (analog_gain
> cis
->cis_data
->max_analog_gain
[0])
1473 analog_gain
= cis
->cis_data
->max_analog_gain
[0];
1475 dbg_sensor(1, "[MOD:D:%d] %s(vsync cnt = %d), input_again = %d us, analog_gain(%#x)\n",
1476 cis
->id
, __func__
, cis
->cis_data
->sen_vsync_count
, again
->long_val
, analog_gain
);
1478 I2C_MUTEX_LOCK(cis
->i2c_lock
);
1480 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
1486 ret
= fimc_is_sensor_write16(client
, 0x0204, analog_gain
);
1490 #ifdef DEBUG_SENSOR_TIME
1491 do_gettimeofday(&end
);
1492 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1497 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
1502 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
1507 int sensor_2x5sp_cis_get_analog_gain(struct v4l2_subdev
*subdev
, u32
*again
)
1511 struct fimc_is_cis
*cis
;
1512 struct i2c_client
*client
;
1514 u16 analog_gain
= 0;
1516 #ifdef DEBUG_SENSOR_TIME
1517 struct timeval st
, end
;
1519 do_gettimeofday(&st
);
1525 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1529 client
= cis
->client
;
1530 if (unlikely(!client
)) {
1531 err("client is NULL");
1535 I2C_MUTEX_LOCK(cis
->i2c_lock
);
1537 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
1543 ret
= fimc_is_sensor_read16(client
, 0x0204, &analog_gain
);
1547 *again
= sensor_cis_calc_again_permile(analog_gain
);
1549 dbg_sensor(1, "[MOD:D:%d] %s, cur_again = %d us, analog_gain(%#x)\n",
1550 cis
->id
, __func__
, *again
, analog_gain
);
1552 #ifdef DEBUG_SENSOR_TIME
1553 do_gettimeofday(&end
);
1554 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1559 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
1564 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
1569 int sensor_2x5sp_cis_get_min_analog_gain(struct v4l2_subdev
*subdev
, u32
*min_again
)
1572 struct fimc_is_cis
*cis
;
1573 struct i2c_client
*client
;
1574 cis_shared_data
*cis_data
;
1576 #ifdef DEBUG_SENSOR_TIME
1577 struct timeval st
, end
;
1579 do_gettimeofday(&st
);
1583 FIMC_BUG(!min_again
);
1585 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1588 FIMC_BUG(!cis
->cis_data
);
1590 client
= cis
->client
;
1591 if (unlikely(!client
)) {
1592 err("client is NULL");
1596 cis_data
= cis
->cis_data
;
1597 cis_data
->min_analog_gain
[0] = 0x20;
1598 cis_data
->min_analog_gain
[1] = sensor_cis_calc_again_permile(cis_data
->min_analog_gain
[0]);
1600 *min_again
= cis_data
->min_analog_gain
[1];
1602 dbg_sensor(1, "[%s] code %d, permile %d\n", __func__
, cis_data
->min_analog_gain
[0], cis_data
->min_analog_gain
[1]);
1604 #ifdef DEBUG_SENSOR_TIME
1605 do_gettimeofday(&end
);
1606 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1612 int sensor_2x5sp_cis_get_max_analog_gain(struct v4l2_subdev
*subdev
, u32
*max_again
)
1615 struct fimc_is_cis
*cis
;
1616 struct i2c_client
*client
;
1617 cis_shared_data
*cis_data
;
1619 #ifdef DEBUG_SENSOR_TIME
1620 struct timeval st
, end
;
1622 do_gettimeofday(&st
);
1626 FIMC_BUG(!max_again
);
1628 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1631 FIMC_BUG(!cis
->cis_data
);
1633 client
= cis
->client
;
1634 if (unlikely(!client
)) {
1635 err("client is NULL");
1639 cis_data
= cis
->cis_data
;
1640 cis_data
->max_analog_gain
[0] = 0x200;
1641 cis_data
->max_analog_gain
[1] = sensor_cis_calc_again_permile(cis_data
->max_analog_gain
[0]);
1643 *max_again
= cis_data
->max_analog_gain
[1];
1645 dbg_sensor(1, "[%s] code %d, permile %d\n", __func__
, cis_data
->max_analog_gain
[0], cis_data
->max_analog_gain
[1]);
1647 #ifdef DEBUG_SENSOR_TIME
1648 do_gettimeofday(&end
);
1649 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1655 int sensor_2x5sp_cis_set_digital_gain(struct v4l2_subdev
*subdev
, struct ae_param
*dgain
)
1659 struct fimc_is_cis
*cis
;
1660 struct i2c_client
*client
;
1661 cis_shared_data
*cis_data
;
1665 u16 middle_gain
= 0;
1666 u16 dgains
[4] = {0};
1668 #ifdef DEBUG_SENSOR_TIME
1669 struct timeval st
, end
;
1671 do_gettimeofday(&st
);
1677 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1680 FIMC_BUG(!cis
->cis_data
);
1682 client
= cis
->client
;
1683 if (unlikely(!client
)) {
1684 err("client is NULL");
1688 cis_data
= cis
->cis_data
;
1690 long_gain
= (u16
)sensor_cis_calc_dgain_code(dgain
->long_val
);
1691 short_gain
= (u16
)sensor_cis_calc_dgain_code(dgain
->short_val
);
1692 middle_gain
= (u16
)sensor_cis_calc_dgain_code(dgain
->middle_val
);
1694 if (long_gain
< cis
->cis_data
->min_digital_gain
[0])
1695 long_gain
= cis
->cis_data
->min_digital_gain
[0];
1697 if (long_gain
> cis
->cis_data
->max_digital_gain
[0])
1698 long_gain
= cis
->cis_data
->max_digital_gain
[0];
1700 if (short_gain
< cis
->cis_data
->min_digital_gain
[0])
1701 short_gain
= cis
->cis_data
->min_digital_gain
[0];
1703 if (short_gain
> cis
->cis_data
->max_digital_gain
[0])
1704 short_gain
= cis
->cis_data
->max_digital_gain
[0];
1706 if (middle_gain
< cis
->cis_data
->min_digital_gain
[0])
1707 middle_gain
= cis
->cis_data
->min_digital_gain
[0];
1709 if (middle_gain
> cis
->cis_data
->max_digital_gain
[0])
1710 middle_gain
= cis
->cis_data
->max_digital_gain
[0];
1712 dbg_sensor(1, "[MOD:D:%d] %s(vsync cnt = %d), input_dgain = %d/%d/%d us, gain(L:%#x, S:%#x, M:%#x)\n",
1713 cis
->id
, __func__
, cis
->cis_data
->sen_vsync_count
, dgain
->long_val
,
1714 dgain
->short_val
, dgain
->middle_val
, long_gain
, short_gain
, middle_gain
);
1716 I2C_MUTEX_LOCK(cis
->i2c_lock
);
1718 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
1724 dgains
[0] = dgains
[1] = dgains
[2] = dgains
[3] = short_gain
;
1725 /* Short digital gain */
1726 ret
= fimc_is_sensor_write16_array(client
, 0x020E, dgains
, 4);
1730 /* Long & medium digital gain */
1731 if (cis_data
->is_data
.wdr_mode
!= CAMERA_WDR_OFF
) {
1732 dgains
[0] = dgains
[1] = dgains
[2] = dgains
[3] = long_gain
;
1733 /* long digital gain */
1734 ret
= fimc_is_sensor_write16_array(client
, 0x0230, dgains
, 4);
1737 dgains
[0] = dgains
[1] = dgains
[2] = dgains
[3] = middle_gain
;
1738 /* middle digital gain */
1739 ret
= fimc_is_sensor_write16_array(client
, 0x0238, dgains
, 4);
1744 #ifdef DEBUG_SENSOR_TIME
1745 do_gettimeofday(&end
);
1746 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1751 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
1756 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
1761 int sensor_2x5sp_cis_get_digital_gain(struct v4l2_subdev
*subdev
, u32
*dgain
)
1765 struct fimc_is_cis
*cis
;
1766 struct i2c_client
*client
;
1768 u16 digital_gain
= 0;
1770 #ifdef DEBUG_SENSOR_TIME
1771 struct timeval st
, end
;
1773 do_gettimeofday(&st
);
1779 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1783 client
= cis
->client
;
1784 if (unlikely(!client
)) {
1785 err("client is NULL");
1789 I2C_MUTEX_LOCK(cis
->i2c_lock
);
1791 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
1797 ret
= fimc_is_sensor_read16(client
, 0x020E, &digital_gain
);
1801 *dgain
= sensor_cis_calc_dgain_permile(digital_gain
);
1803 dbg_sensor(1, "[MOD:D:%d] %s, cur_dgain = %d us, digital_gain(%#x)\n",
1804 cis
->id
, __func__
, *dgain
, digital_gain
);
1806 #ifdef DEBUG_SENSOR_TIME
1807 do_gettimeofday(&end
);
1808 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1813 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
1818 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
1823 int sensor_2x5sp_cis_get_min_digital_gain(struct v4l2_subdev
*subdev
, u32
*min_dgain
)
1826 struct fimc_is_cis
*cis
;
1827 struct i2c_client
*client
;
1828 cis_shared_data
*cis_data
;
1830 #ifdef DEBUG_SENSOR_TIME
1831 struct timeval st
, end
;
1833 do_gettimeofday(&st
);
1837 FIMC_BUG(!min_dgain
);
1839 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1842 FIMC_BUG(!cis
->cis_data
);
1844 client
= cis
->client
;
1845 if (unlikely(!client
)) {
1846 err("client is NULL");
1850 cis_data
= cis
->cis_data
;
1851 cis_data
->min_digital_gain
[0] = 0x100;
1852 cis_data
->min_digital_gain
[1] = sensor_cis_calc_dgain_permile(cis_data
->min_digital_gain
[0]);
1854 *min_dgain
= cis_data
->min_digital_gain
[1];
1856 dbg_sensor(1, "[%s] code %d, permile %d\n", __func__
,
1857 cis_data
->min_digital_gain
[0], cis_data
->min_digital_gain
[1]);
1859 #ifdef DEBUG_SENSOR_TIME
1860 do_gettimeofday(&end
);
1861 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1867 int sensor_2x5sp_cis_get_max_digital_gain(struct v4l2_subdev
*subdev
, u32
*max_dgain
)
1870 struct fimc_is_cis
*cis
;
1871 struct i2c_client
*client
;
1872 cis_shared_data
*cis_data
;
1874 #ifdef DEBUG_SENSOR_TIME
1875 struct timeval st
, end
;
1877 do_gettimeofday(&st
);
1881 FIMC_BUG(!max_dgain
);
1883 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1886 FIMC_BUG(!cis
->cis_data
);
1888 client
= cis
->client
;
1889 if (unlikely(!client
)) {
1890 err("client is NULL");
1894 cis_data
= cis
->cis_data
;
1895 cis_data
->max_digital_gain
[0] = 0x8000;
1896 cis_data
->max_digital_gain
[1] = sensor_cis_calc_dgain_permile(cis_data
->max_digital_gain
[0]);
1898 *max_dgain
= cis_data
->max_digital_gain
[1];
1900 dbg_sensor(1, "[%s] code %d, permile %d\n", __func__
,
1901 cis_data
->max_digital_gain
[0], cis_data
->max_digital_gain
[1]);
1903 #ifdef DEBUG_SENSOR_TIME
1904 do_gettimeofday(&end
);
1905 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
) * 1000000 + (end
.tv_usec
- st
.tv_usec
));
1911 int sensor_2x5sp_cis_set_wb_gain(struct v4l2_subdev
*subdev
, struct wb_gains wb_gains
)
1915 struct fimc_is_cis
*cis
;
1916 struct i2c_client
*client
;
1917 u16 abs_gains
[4] = {0, }; /* [0]=gr, [1]=r, [2]=b, [3]=gb */
1919 #ifdef DEBUG_SENSOR_TIME
1920 struct timeval st
, end
;
1922 do_gettimeofday(&st
);
1927 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
1930 BUG_ON(!cis
->cis_data
);
1932 if (!cis
->use_wb_gain
)
1935 client
= cis
->client
;
1936 if (unlikely(!client
)) {
1937 err("client is NULL");
1941 dbg_sensor(1, "[SEN:%d]%s:DDK vlaue: wb_gain_gr(%d), wb_gain_r(%d), wb_gain_b(%d)\n",
1942 cis
->id
, __func__
, wb_gains
.gr
, wb_gains
.r
, wb_gains
.b
, wb_gains
.gb
);
1944 if (wb_gains
.gr
== 0 || wb_gains
.r
== 0 || wb_gains
.b
== 0 || wb_gains
.gb
== 0)
1947 abs_gains
[0] = (u16
)((wb_gains
.r
/ 4) & 0xFFFF);
1948 abs_gains
[1] = (u16
)((wb_gains
.gr
/ 4) & 0xFFFF);
1949 abs_gains
[2] = (u16
)((wb_gains
.b
/ 4) & 0xFFFF);
1951 dbg_sensor(1, "[SEN:%d]%s, abs_gain_r(0x%4X), abs_gain_gr(0x%4X), abs_gain_b(0x%4X)\n",
1952 cis
->id
, __func__
, abs_gains
[0], abs_gains
[1], abs_gains
[2]);
1954 I2C_MUTEX_LOCK(cis
->i2c_lock
);
1956 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
1962 /* 0x40000D12 ~ 0x400000D16: api_rw_color_temperature_absolute_gain_red/green/blue */
1963 ret
= fimc_is_sensor_write16(client
, 0x6028, 0x4000);
1964 ret
|= fimc_is_sensor_write16_array(client
, 0x0D12, abs_gains
, 3);
1968 #ifdef DEBUG_SENSOR_TIME
1969 do_gettimeofday(&end
);
1970 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
)*1000000 + (end
.tv_usec
- st
.tv_usec
));
1975 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
1980 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
1985 int sensor_2x5sp_cis_set_3hdr_roi(struct v4l2_subdev
*subdev
, struct roi_setting_t roi_control
)
1989 struct fimc_is_cis
*cis
;
1990 struct i2c_client
*client
;
1992 #ifdef DEBUG_SENSOR_TIME
1993 struct timeval st
, end
;
1995 do_gettimeofday(&st
);
2000 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
2003 BUG_ON(!cis
->cis_data
);
2008 client
= cis
->client
;
2009 if (unlikely(!client
)) {
2010 err("client is NULL");
2014 dbg_sensor(1, "%s: [MOD:%d] roi_control (start_x:%d, start_y:%d, end_x:%d, end_y:%d)\n",
2016 roi_control
.roi_start_x
, roi_control
.roi_start_y
,
2017 roi_control
.roi_end_x
, roi_control
.roi_end_y
);
2019 I2C_MUTEX_LOCK(cis
->i2c_lock
);
2021 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
2028 ret
= fimc_is_sensor_write16(client
, 0x6028, 0x2000);
2032 /* t_isp_rgby_hist_mem_cfg_active_window_percent_14bit */
2033 roi_val
[0] = roi_control
.roi_start_x
; /* 0x20004B26: top_left_x */
2034 roi_val
[1] = roi_control
.roi_start_y
; /* 0x20004B28: top_left_y */
2035 roi_val
[2] = roi_control
.roi_end_x
; /* 0x20004B2A: bot_right_x */
2036 roi_val
[3] = roi_control
.roi_end_y
; /* 0x20004B2C: bot_right_y */
2038 ret
= fimc_is_sensor_write16_array(client
, 0x4B26, roi_val
, 4);
2042 /* t_isp_rgby_hist_grid_grid & thstat_grid_area */
2043 roi_val
[0] = roi_control
.roi_end_x
- roi_control
.roi_start_x
; /* 0x20004BEE & 0x20004E44: width */
2044 roi_val
[1] = roi_control
.roi_end_y
- roi_control
.roi_start_y
; /* 0x20004BF0 & 0x20004E46: height */
2045 roi_val
[2] = (roi_control
.roi_start_x
+ roi_control
.roi_end_x
) / 2; /* center_x */
2046 roi_val
[3] = (roi_control
.roi_start_y
+ roi_control
.roi_end_y
) / 2; /* center_y */
2048 ret
= fimc_is_sensor_write16_array(client
, 0x4BEE, roi_val
, 4);
2052 ret
= fimc_is_sensor_write16_array(client
, 0x4E44, roi_val
, 2);
2056 /* restore 0x4000_XXXX */
2057 ret
= fimc_is_sensor_write16(client
, 0x6028, 0x4000);
2061 #ifdef DEBUG_SENSOR_TIME
2062 do_gettimeofday(&end
);
2063 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
)*1000000 + (end
.tv_usec
- st
.tv_usec
));
2068 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
2073 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
2078 int sensor_2x5sp_cis_set_3hdr_stat(struct v4l2_subdev
*subdev
, bool streaming
, void *data
)
2082 struct fimc_is_cis
*cis
;
2083 struct i2c_client
*client
;
2085 u16 low_gate_thr
, high_gate_thr
;
2086 struct roi_setting_t y_sum_roi
;
2087 struct sensor_lsi_3hdr_stat_control_mode_change mode_change_stat
;
2088 struct sensor_lsi_3hdr_stat_control_per_frame per_frame_stat
;
2089 #ifdef DEBUG_SENSOR_TIME
2090 struct timeval st
, end
;
2092 do_gettimeofday(&st
);
2098 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
2101 BUG_ON(!cis
->cis_data
);
2106 client
= cis
->client
;
2107 if (unlikely(!client
)) {
2108 err("client is NULL");
2112 I2C_MUTEX_LOCK(cis
->i2c_lock
);
2114 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x01);
2121 per_frame_stat
= *(struct sensor_lsi_3hdr_stat_control_per_frame
*)data
;
2123 weight
[0] = per_frame_stat
.r_weight
;
2124 weight
[1] = per_frame_stat
.g_weight
;
2125 weight
[2] = per_frame_stat
.b_weight
;
2127 mode_change_stat
= *(struct sensor_lsi_3hdr_stat_control_mode_change
*)data
;
2129 weight
[0] = mode_change_stat
.r_weight
;
2130 weight
[1] = mode_change_stat
.g_weight
;
2131 weight
[2] = mode_change_stat
.b_weight
;
2133 low_gate_thr
= mode_change_stat
.low_gate_thr
;
2134 high_gate_thr
= mode_change_stat
.high_gate_thr
;
2136 y_sum_roi
= mode_change_stat
.y_sum_roi
;
2139 ret
= fimc_is_sensor_write16(client
, 0x6028, 0x2000);
2143 /* t_isp_rgby_hist_short_exp_weight */
2144 ret
= fimc_is_sensor_write16_array(client
, 0x4BBC, weight
, 3);
2148 /* t_isp_rgby_hist_long_exp_weight */
2149 ret
= fimc_is_sensor_write16_array(client
, 0x4BCA, weight
, 3);
2153 /* t_isp_rgby_hist_medium_exp_weight */
2154 ret
= fimc_is_sensor_write16_array(client
, 0x4BD8, weight
, 3);
2158 /* t_isp_rgby_hist_mixed_exp_weight */
2159 ret
= fimc_is_sensor_write16_array(client
, 0x4BE6, weight
, 3);
2163 /* t_isp_drc_thstat_rgb_weights */
2164 ret
= fimc_is_sensor_write16_array(client
, 0x4E2C, weight
, 3);
2169 /* t_isp_drc_thstat_u_low_tresh_red */
2170 ret
= fimc_is_sensor_write16(client
, 0x4E1A, low_gate_thr
);
2173 /* t_isp_drc_thstat_u_high_tresh_red */
2174 ret
= fimc_is_sensor_write16(client
, 0x4E1C, high_gate_thr
);
2178 /* t_isp_drc_thstat_u_low_tresh_green */
2179 ret
= fimc_is_sensor_write16(client
, 0x4E1E, low_gate_thr
);
2183 /* t_isp_drc_thstat_u_high_tresh_green */
2184 ret
= fimc_is_sensor_write16(client
, 0x4E20, high_gate_thr
);
2188 /* t_isp_drc_thstat_u_low_tresh_blue */
2189 ret
= fimc_is_sensor_write16(client
, 0x4E22, low_gate_thr
);
2193 /* t_isp_drc_thstat_u_high_tresh_blue */
2194 ret
= fimc_is_sensor_write16(client
, 0x4E24, high_gate_thr
);
2198 /* t_isp_y_sum_top_left_x */
2199 ret
= fimc_is_sensor_write16(client
, 0x4E04, y_sum_roi
.roi_start_x
);
2202 ret
= fimc_is_sensor_write16(client
, 0x4E06, y_sum_roi
.roi_start_y
);
2206 /* update 3hdr motion stat */
2207 ret
= fimc_is_sensor_write16(client
, 0x6028, 0x2001);
2211 ret
|= fimc_is_sensor_write16(client
, 0x602A, 0x29D8);
2212 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2213 (u16
)per_frame_stat
.motion_indication
);
2215 ret
|= fimc_is_sensor_write16(client
, 0x602A, 0x2A52);
2216 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2217 (u16
)per_frame_stat
.motion_high_end_ty2ty1
);
2218 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2219 (u16
)per_frame_stat
.motion_high_end_ty3ty2
);
2220 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2221 (u16
)per_frame_stat
.motion_high_start_ty2ty1
);
2222 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2223 (u16
)per_frame_stat
.motion_high_start_ty3ty2
);
2224 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2225 (u16
)per_frame_stat
.motion_low_end_ty2ty1
);
2226 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2227 (u16
)per_frame_stat
.motion_low_end_ty3ty2
);
2228 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2229 (u16
)per_frame_stat
.motion_low_start_ty2ty1
);
2230 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2231 (u16
)per_frame_stat
.motion_low_start_ty3ty2
);
2233 dbg_sensor(2, "[%s] motion idc(%d) high21(e:%d, s:%d), low21(e:%d, s:%d)\n",
2235 (u16
)per_frame_stat
.motion_indication
,
2236 (u16
)per_frame_stat
.motion_high_end_ty2ty1
,
2237 (u16
)per_frame_stat
.motion_high_start_ty2ty1
,
2238 (u16
)per_frame_stat
.motion_low_end_ty2ty1
,
2239 (u16
)per_frame_stat
.motion_low_start_ty2ty1
);
2240 dbg_sensor(2, "[%s] motion high32(e:%d, s:%d), low32(e:%d, s:%d)\n",
2242 (u16
)per_frame_stat
.motion_high_end_ty3ty2
,
2243 (u16
)per_frame_stat
.motion_high_start_ty3ty2
,
2244 (u16
)per_frame_stat
.motion_low_end_ty3ty2
,
2245 (u16
)per_frame_stat
.motion_low_start_ty3ty2
);
2247 ret
|= fimc_is_sensor_write16(client
, 0x602A, 0x2A68);
2248 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2249 (u16
)per_frame_stat
.decision_thresh_override
);
2250 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2251 (u16
)per_frame_stat
.motion_abs_high_ty3ty2
);
2252 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2253 (u16
)per_frame_stat
.motion_abs_low_ty3ty2
);
2254 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2255 (u16
)per_frame_stat
.motion_abs_high_ty2ty1
);
2256 ret
|= fimc_is_sensor_write16(client
, 0x6F12,
2257 (u16
)per_frame_stat
.motion_abs_low_ty2ty1
);
2259 dbg_sensor(2, "[%s] motion DTO(%d), abs(h32:%d, l32:%d), abs(h21:%d, l21:%d)\n",
2261 (u16
)per_frame_stat
.decision_thresh_override
,
2262 (u16
)per_frame_stat
.motion_abs_high_ty3ty2
,
2263 (u16
)per_frame_stat
.motion_abs_low_ty3ty2
,
2264 (u16
)per_frame_stat
.motion_abs_high_ty2ty1
,
2265 (u16
)per_frame_stat
.motion_abs_low_ty2ty1
);
2268 /* restore 0x4000_XXXX */
2269 ret
= fimc_is_sensor_write16(client
, 0x6028, 0x4000);
2273 #ifdef DEBUG_SENSOR_TIME
2274 do_gettimeofday(&end
);
2275 dbg_sensor(1, "[%s] time %lu us\n", __func__
, (end
.tv_sec
- st
.tv_sec
)*1000000 + (end
.tv_usec
- st
.tv_usec
));
2280 hold
= sensor_2x5sp_cis_group_param_hold_func(subdev
, 0x00);
2285 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
2290 void sensor_2x5sp_cis_check_wdr_mode(struct v4l2_subdev
*subdev
, u32 mode_idx
)
2292 struct fimc_is_cis
*cis
;
2294 FIMC_BUG_VOID(!subdev
);
2296 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
2298 FIMC_BUG_VOID(!cis
);
2299 FIMC_BUG_VOID(!cis
->cis_data
);
2301 /* check wdr mode */
2302 if (mode_idx
== SENSOR_2X5SP_2880X2160_30FPS_3DHDR
)
2303 cis
->cis_data
->is_data
.wdr_enable
= true;
2305 cis
->cis_data
->is_data
.wdr_enable
= false;
2307 dbg_sensor(1, "[%s] wdr_enable: %d\n", __func__
,
2308 cis
->cis_data
->is_data
.wdr_enable
);
2311 int sensor_2x5sp_cis_long_term_exposure(struct v4l2_subdev
*subdev
)
2314 struct fimc_is_cis
*cis
;
2315 struct fimc_is_long_term_expo_mode
*lte_mode
;
2320 cis
= (struct fimc_is_cis
*)v4l2_get_subdevdata(subdev
);
2321 lte_mode
= &cis
->long_term_mode
;
2323 I2C_MUTEX_LOCK(cis
->i2c_lock
);
2324 /* LTE mode or normal mode set */
2325 if (lte_mode
->sen_strm_off_on_enable
) {
2326 shift_count
= GET_2X5SP_LTE_SHIFT_CNT(lte_mode
->expo
[0]);
2327 ret
|= fimc_is_sensor_write16(cis
->client
, 0xFCFC, 0x4000);
2328 ret
|= fimc_is_sensor_write8(cis
->client
, 0x0702, shift_count
);
2329 ret
|= fimc_is_sensor_write8(cis
->client
, 0x0704, shift_count
);
2331 ret
|= fimc_is_sensor_write16(cis
->client
, 0xFCFC, 0x4000);
2332 ret
|= fimc_is_sensor_write8(cis
->client
, 0x0702, 0);
2333 ret
|= fimc_is_sensor_write8(cis
->client
, 0x0704, 0);
2336 I2C_MUTEX_UNLOCK(cis
->i2c_lock
);
2338 info("%s enable(%d)", __func__
, lte_mode
->sen_strm_off_on_enable
);
2341 pr_err("ERR[%s]: LTE register setting fail\n", __func__
);
2348 static struct fimc_is_cis_ops cis_ops
= {
2349 .cis_init
= sensor_2x5sp_cis_init
,
2350 .cis_log_status
= sensor_2x5sp_cis_log_status
,
2351 .cis_group_param_hold
= sensor_2x5sp_cis_group_param_hold
,
2352 .cis_set_global_setting
= sensor_2x5sp_cis_set_global_setting
,
2353 .cis_mode_change
= sensor_2x5sp_cis_mode_change
,
2354 .cis_set_size
= sensor_2x5sp_cis_set_size
,
2355 .cis_stream_on
= sensor_2x5sp_cis_stream_on
,
2356 .cis_stream_off
= sensor_2x5sp_cis_stream_off
,
2357 .cis_set_exposure_time
= sensor_2x5sp_cis_set_exposure_time
,
2358 .cis_get_min_exposure_time
= sensor_2x5sp_cis_get_min_exposure_time
,
2359 .cis_get_max_exposure_time
= sensor_2x5sp_cis_get_max_exposure_time
,
2360 .cis_adjust_frame_duration
= sensor_2x5sp_cis_adjust_frame_duration
,
2361 .cis_set_frame_duration
= sensor_2x5sp_cis_set_frame_duration
,
2362 .cis_set_frame_rate
= sensor_2x5sp_cis_set_frame_rate
,
2363 .cis_adjust_analog_gain
= sensor_2x5sp_cis_adjust_analog_gain
,
2364 .cis_set_analog_gain
= sensor_2x5sp_cis_set_analog_gain
,
2365 .cis_get_analog_gain
= sensor_2x5sp_cis_get_analog_gain
,
2366 .cis_get_min_analog_gain
= sensor_2x5sp_cis_get_min_analog_gain
,
2367 .cis_get_max_analog_gain
= sensor_2x5sp_cis_get_max_analog_gain
,
2368 .cis_set_digital_gain
= sensor_2x5sp_cis_set_digital_gain
,
2369 .cis_get_digital_gain
= sensor_2x5sp_cis_get_digital_gain
,
2370 .cis_get_min_digital_gain
= sensor_2x5sp_cis_get_min_digital_gain
,
2371 .cis_get_max_digital_gain
= sensor_2x5sp_cis_get_max_digital_gain
,
2372 .cis_compensate_gain_for_extremely_br
= sensor_cis_compensate_gain_for_extremely_br
,
2373 .cis_wait_streamoff
= sensor_cis_wait_streamoff
,
2374 .cis_wait_streamon
= sensor_cis_wait_streamon
,
2375 .cis_set_initial_exposure
= sensor_cis_set_initial_exposure
,
2376 .cis_check_rev
= sensor_2x5sp_cis_check_rev
,
2377 .cis_factory_test
= sensor_cis_factory_test
,
2378 .cis_set_wb_gains
= sensor_2x5sp_cis_set_wb_gain
,
2379 .cis_set_roi_stat
= sensor_2x5sp_cis_set_3hdr_roi
,
2380 .cis_set_3hdr_stat
= sensor_2x5sp_cis_set_3hdr_stat
,
2381 .cis_check_wdr_mode
= sensor_2x5sp_cis_check_wdr_mode
,
2382 .cis_set_long_term_exposure
= sensor_2x5sp_cis_long_term_exposure
,
2383 .cis_mode_change_throttling
= sensor_2x5sp_cis_mode_change_throttling
,
2386 static int cis_2x5sp_probe(struct i2c_client
*client
,
2387 const struct i2c_device_id
*id
)
2390 struct fimc_is_core
*core
= NULL
;
2391 struct v4l2_subdev
*subdev_cis
= NULL
;
2392 struct fimc_is_cis
*cis
= NULL
;
2393 struct fimc_is_device_sensor
*device
= NULL
;
2394 struct fimc_is_device_sensor_peri
*sensor_peri
= NULL
;
2396 char const *setfile
;
2398 struct device_node
*dnode
;
2401 FIMC_BUG(!fimc_is_dev
);
2403 core
= (struct fimc_is_core
*)dev_get_drvdata(fimc_is_dev
);
2405 probe_info("core device is not yet probed");
2406 return -EPROBE_DEFER
;
2410 dnode
= dev
->of_node
;
2412 ret
= of_property_read_u32(dnode
, "id", &sensor_id
);
2414 err("sensor id read is fail(%d)", ret
);
2418 probe_info("%s sensor id %d\n", __func__
, sensor_id
);
2420 device
= &core
->sensor
[sensor_id
];
2422 sensor_peri
= find_peri_by_cis_id(device
, SENSOR_NAME_S5K2X5SP
);
2424 probe_info("sensor peri is net yet probed");
2425 return -EPROBE_DEFER
;
2428 cis
= &sensor_peri
->cis
;
2435 subdev_cis
= kzalloc(sizeof(struct v4l2_subdev
), GFP_KERNEL
);
2437 probe_err("subdev_cis NULL");
2441 sensor_peri
->subdev_cis
= subdev_cis
;
2443 cis
->id
= SENSOR_NAME_S5K2X5SP
;
2444 cis
->subdev
= subdev_cis
;
2446 cis
->client
= client
;
2447 sensor_peri
->module
->client
= cis
->client
;
2448 cis
->ctrl_delay
= N_PLUS_TWO_FRAME
;
2450 cis
->cis_data
= kzalloc(sizeof(cis_shared_data
), GFP_KERNEL
);
2451 if (!cis
->cis_data
) {
2452 err("cis_data is NULL");
2456 cis
->cis_ops
= &cis_ops
;
2458 /* belows are depend on sensor cis. MUST check sensor spec */
2459 cis
->bayer_order
= OTF_INPUT_ORDER_BAYER_GR_BG
;
2461 if (of_property_read_bool(dnode
, "sensor_f_number")) {
2462 ret
= of_property_read_u32(dnode
, "sensor_f_number", &cis
->aperture_num
);
2464 warn("f-number read is fail(%d)", ret
);
2466 cis
->aperture_num
= F2_2
;
2469 probe_info("%s f-number %d\n", __func__
, cis
->aperture_num
);
2471 cis
->use_dgain
= true;
2472 cis
->hdr_ctrl_by_again
= false;
2473 cis
->use_wb_gain
= true;
2474 cis
->use_3hdr
= true;
2476 ret
= of_property_read_string(dnode
, "setfile", &setfile
);
2478 err("setfile index read fail(%d), take default setfile!!", ret
);
2479 setfile
= "default";
2482 if (strcmp(setfile
, "default") == 0 ||
2483 strcmp(setfile
, "setA") == 0) {
2484 probe_info("%s setfile_A\n", __func__
);
2485 sensor_2x5sp_global
= sensor_2x5sp_setfile_A_Global
;
2486 sensor_2x5sp_global_size
= ARRAY_SIZE(sensor_2x5sp_setfile_A_Global
);
2487 sensor_2x5sp_setfiles
= sensor_2x5sp_setfiles_A
;
2488 sensor_2x5sp_setfile_sizes
= sensor_2x5sp_setfile_A_sizes
;
2489 sensor_2x5sp_otp_initial
= sensor_2x5sp_setfiles_A_otp_initial
;
2490 sensor_2x5sp_otp_initial_size
= ARRAY_SIZE(sensor_2x5sp_setfiles_A_otp_initial
);
2491 sensor_2x5sp_pllinfos
= sensor_2x5sp_pllinfos_A
;
2492 sensor_2x5sp_max_setfile_num
= ARRAY_SIZE(sensor_2x5sp_setfiles_A
);
2493 } else if (strcmp(setfile
, "setB") == 0) {
2494 probe_info("%s setfile_B\n", __func__
);
2495 sensor_2x5sp_global
= sensor_2x5sp_setfile_B_Global
;
2496 sensor_2x5sp_global_size
= ARRAY_SIZE(sensor_2x5sp_setfile_B_Global
);
2497 sensor_2x5sp_setfiles
= sensor_2x5sp_setfiles_B
;
2498 sensor_2x5sp_setfile_sizes
= sensor_2x5sp_setfile_B_sizes
;
2499 sensor_2x5sp_otp_initial
= sensor_2x5sp_setfiles_A_otp_initial
;
2500 sensor_2x5sp_otp_initial_size
= ARRAY_SIZE(sensor_2x5sp_setfiles_A_otp_initial
);
2501 sensor_2x5sp_pllinfos
= sensor_2x5sp_pllinfos_B
;
2502 sensor_2x5sp_max_setfile_num
= ARRAY_SIZE(sensor_2x5sp_setfiles_B
);
2504 /* throttling setting */
2505 sensor_2x5sp_setfile_throttling
= sensor_2x5sp_setfile_B_2880x2160_15fps
;
2506 sensor_2x5sp_setfile_throttling_size
= ARRAY_SIZE(sensor_2x5sp_setfile_B_2880x2160_15fps
);
2507 sensor_2x5sp_pllinfo_throttling
= &sensor_2x5sp_pllinfo_B_2880x2160_15fps
;
2509 err("%s setfile index out of bound, take default (setfile_A)", __func__
);
2510 sensor_2x5sp_global
= sensor_2x5sp_setfile_A_Global
;
2511 sensor_2x5sp_global_size
= ARRAY_SIZE(sensor_2x5sp_setfile_A_Global
);
2512 sensor_2x5sp_setfiles
= sensor_2x5sp_setfiles_A
;
2513 sensor_2x5sp_setfile_sizes
= sensor_2x5sp_setfile_A_sizes
;
2514 sensor_2x5sp_pllinfos
= sensor_2x5sp_pllinfos_A
;
2515 sensor_2x5sp_max_setfile_num
= ARRAY_SIZE(sensor_2x5sp_setfiles_A
);
2518 cis
->use_initial_ae
= of_property_read_bool(dnode
, "use_initial_ae");
2519 probe_info("%s use initial_ae(%d)\n", __func__
, cis
->use_initial_ae
);
2521 device
->use_otp_cal
= of_property_read_bool(dnode
, "use_otp_cal");
2522 probe_info("%s use otp_cal(%d)\n", __func__
, device
->use_otp_cal
);
2524 for (i
= 0; i
< CAMERA_CRC_INDEX_MAX
; i
++)
2525 device
->cal_status
[i
] = CRC_NO_ERROR
;
2527 v4l2_i2c_subdev_init(subdev_cis
, client
, &subdev_ops
);
2528 v4l2_set_subdevdata(subdev_cis
, cis
);
2529 v4l2_set_subdev_hostdata(subdev_cis
, device
);
2530 snprintf(subdev_cis
->name
, V4L2_SUBDEV_NAME_SIZE
, "cis-subdev.%d", cis
->id
);
2532 probe_info("%s done\n", __func__
);
2538 static const struct of_device_id sensor_cis_2x5sp_match
[] = {
2540 .compatible
= "samsung,exynos5-fimc-is-cis-2x5sp",
2544 MODULE_DEVICE_TABLE(of
, sensor_cis_2x5sp_match
);
2546 static const struct i2c_device_id sensor_cis_2x5sp_idt
[] = {
2551 static struct i2c_driver sensor_cis_2x5sp_driver
= {
2552 .probe
= cis_2x5sp_probe
,
2554 .name
= SENSOR_NAME
,
2555 .owner
= THIS_MODULE
,
2556 .of_match_table
= sensor_cis_2x5sp_match
,
2557 .suppress_bind_attrs
= true,
2559 .id_table
= sensor_cis_2x5sp_idt
2562 static int __init
sensor_cis_2x5sp_init(void)
2566 ret
= i2c_add_driver(&sensor_cis_2x5sp_driver
);
2568 err("failed to add %s driver: %d\n",
2569 sensor_cis_2x5sp_driver
.driver
.name
, ret
);
2573 late_initcall_sync(sensor_cis_2x5sp_init
);