Lines Matching full:sensor
13 * Based on smia-sensor.c by Tuukka Toivonen <tuukkat76@gmail.com>
90 static int ccs_limit_ptr(struct ccs_sensor *sensor, unsigned int limit, in ccs_limit_ptr() argument
100 if (WARN_ON(!sensor->ccs_limits) || in ccs_limit_ptr()
105 *__ptr = sensor->ccs_limits + ccs_limit_offsets[limit].lim + offset; in ccs_limit_ptr()
110 void ccs_replace_limit(struct ccs_sensor *sensor, in ccs_replace_limit() argument
113 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_replace_limit()
118 ret = ccs_limit_ptr(sensor, limit, offset, &ptr); in ccs_replace_limit()
130 u32 ccs_get_limit(struct ccs_sensor *sensor, unsigned int limit, in ccs_get_limit() argument
137 ret = ccs_limit_ptr(sensor, limit, offset, &ptr); in ccs_get_limit()
156 return ccs_reg_conv(sensor, ccs_limits[limit].reg, val); in ccs_get_limit()
159 static int ccs_read_all_limits(struct ccs_sensor *sensor) in ccs_read_all_limits() argument
161 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_read_all_limits()
166 kfree(sensor->ccs_limits); in ccs_read_all_limits()
167 sensor->ccs_limits = NULL; in ccs_read_all_limits()
191 ret = ccs_read_addr_noconv(sensor, reg, &val); in ccs_read_all_limits()
225 sensor->ccs_limits = alloc; in ccs_read_all_limits()
227 if (CCS_LIM(sensor, SCALER_N_MIN) < 16) in ccs_read_all_limits()
228 ccs_replace_limit(sensor, CCS_L_SCALER_N_MIN, 0, 16); in ccs_read_all_limits()
238 static int ccs_read_frame_fmt(struct ccs_sensor *sensor) in ccs_read_frame_fmt() argument
240 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_read_frame_fmt()
246 fmt_model_type = CCS_LIM(sensor, FRAME_FORMAT_MODEL_TYPE); in ccs_read_frame_fmt()
247 fmt_model_subtype = CCS_LIM(sensor, FRAME_FORMAT_MODEL_SUBTYPE); in ccs_read_frame_fmt()
272 desc = CCS_LIM_AT(sensor, FRAME_FORMAT_DESCRIPTOR, i); in ccs_read_frame_fmt()
281 desc = CCS_LIM_AT(sensor, FRAME_FORMAT_DESCRIPTOR_4, i); in ccs_read_frame_fmt()
329 sensor->visible_pixel_start = pixel_count; in ccs_read_frame_fmt()
337 if (sensor->embedded_end) in ccs_read_frame_fmt()
339 sensor->embedded_start = line_count; in ccs_read_frame_fmt()
340 sensor->embedded_end = line_count + pixels; in ccs_read_frame_fmt()
343 sensor->image_start = line_count; in ccs_read_frame_fmt()
349 if (sensor->embedded_end > sensor->image_start) { in ccs_read_frame_fmt()
352 sensor->embedded_end, sensor->image_start); in ccs_read_frame_fmt()
353 sensor->image_start = sensor->embedded_end; in ccs_read_frame_fmt()
357 sensor->embedded_start, sensor->embedded_end); in ccs_read_frame_fmt()
359 sensor->image_start); in ccs_read_frame_fmt()
364 static int ccs_pll_configure(struct ccs_sensor *sensor) in ccs_pll_configure() argument
366 struct ccs_pll *pll = &sensor->pll; in ccs_pll_configure()
369 rval = ccs_write(sensor, VT_PIX_CLK_DIV, pll->vt_bk.pix_clk_div); in ccs_pll_configure()
373 rval = ccs_write(sensor, VT_SYS_CLK_DIV, pll->vt_bk.sys_clk_div); in ccs_pll_configure()
377 rval = ccs_write(sensor, PRE_PLL_CLK_DIV, pll->vt_fr.pre_pll_clk_div); in ccs_pll_configure()
381 rval = ccs_write(sensor, PLL_MULTIPLIER, pll->vt_fr.pll_multiplier); in ccs_pll_configure()
385 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_pll_configure()
388 rval = ccs_write(sensor, REQUESTED_LINK_RATE, in ccs_pll_configure()
392 sensor->pll.csi2.lanes : 1) << in ccs_pll_configure()
399 if (sensor->pll.flags & CCS_PLL_FLAG_NO_OP_CLOCKS) in ccs_pll_configure()
402 rval = ccs_write(sensor, OP_PIX_CLK_DIV, pll->op_bk.pix_clk_div); in ccs_pll_configure()
406 rval = ccs_write(sensor, OP_SYS_CLK_DIV, pll->op_bk.sys_clk_div); in ccs_pll_configure()
413 rval = ccs_write(sensor, PLL_MODE, CCS_PLL_MODE_DUAL); in ccs_pll_configure()
417 rval = ccs_write(sensor, OP_PRE_PLL_CLK_DIV, in ccs_pll_configure()
422 return ccs_write(sensor, OP_PLL_MULTIPLIER, pll->op_fr.pll_multiplier); in ccs_pll_configure()
425 static int ccs_pll_try(struct ccs_sensor *sensor, struct ccs_pll *pll) in ccs_pll_try() argument
427 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pll_try()
430 .min_pre_pll_clk_div = CCS_LIM(sensor, MIN_PRE_PLL_CLK_DIV), in ccs_pll_try()
431 .max_pre_pll_clk_div = CCS_LIM(sensor, MAX_PRE_PLL_CLK_DIV), in ccs_pll_try()
432 .min_pll_ip_clk_freq_hz = CCS_LIM(sensor, MIN_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
433 .max_pll_ip_clk_freq_hz = CCS_LIM(sensor, MAX_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
434 .min_pll_multiplier = CCS_LIM(sensor, MIN_PLL_MULTIPLIER), in ccs_pll_try()
435 .max_pll_multiplier = CCS_LIM(sensor, MAX_PLL_MULTIPLIER), in ccs_pll_try()
436 .min_pll_op_clk_freq_hz = CCS_LIM(sensor, MIN_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
437 .max_pll_op_clk_freq_hz = CCS_LIM(sensor, MAX_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
440 .min_pre_pll_clk_div = CCS_LIM(sensor, MIN_OP_PRE_PLL_CLK_DIV), in ccs_pll_try()
441 .max_pre_pll_clk_div = CCS_LIM(sensor, MAX_OP_PRE_PLL_CLK_DIV), in ccs_pll_try()
442 .min_pll_ip_clk_freq_hz = CCS_LIM(sensor, MIN_OP_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
443 .max_pll_ip_clk_freq_hz = CCS_LIM(sensor, MAX_OP_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
444 .min_pll_multiplier = CCS_LIM(sensor, MIN_OP_PLL_MULTIPLIER), in ccs_pll_try()
445 .max_pll_multiplier = CCS_LIM(sensor, MAX_OP_PLL_MULTIPLIER), in ccs_pll_try()
446 .min_pll_op_clk_freq_hz = CCS_LIM(sensor, MIN_OP_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
447 .max_pll_op_clk_freq_hz = CCS_LIM(sensor, MAX_OP_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
450 .min_sys_clk_div = CCS_LIM(sensor, MIN_OP_SYS_CLK_DIV), in ccs_pll_try()
451 .max_sys_clk_div = CCS_LIM(sensor, MAX_OP_SYS_CLK_DIV), in ccs_pll_try()
452 .min_pix_clk_div = CCS_LIM(sensor, MIN_OP_PIX_CLK_DIV), in ccs_pll_try()
453 .max_pix_clk_div = CCS_LIM(sensor, MAX_OP_PIX_CLK_DIV), in ccs_pll_try()
454 .min_sys_clk_freq_hz = CCS_LIM(sensor, MIN_OP_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
455 .max_sys_clk_freq_hz = CCS_LIM(sensor, MAX_OP_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
456 .min_pix_clk_freq_hz = CCS_LIM(sensor, MIN_OP_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
457 .max_pix_clk_freq_hz = CCS_LIM(sensor, MAX_OP_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
460 .min_sys_clk_div = CCS_LIM(sensor, MIN_VT_SYS_CLK_DIV), in ccs_pll_try()
461 .max_sys_clk_div = CCS_LIM(sensor, MAX_VT_SYS_CLK_DIV), in ccs_pll_try()
462 .min_pix_clk_div = CCS_LIM(sensor, MIN_VT_PIX_CLK_DIV), in ccs_pll_try()
463 .max_pix_clk_div = CCS_LIM(sensor, MAX_VT_PIX_CLK_DIV), in ccs_pll_try()
464 .min_sys_clk_freq_hz = CCS_LIM(sensor, MIN_VT_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
465 .max_sys_clk_freq_hz = CCS_LIM(sensor, MAX_VT_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
466 .min_pix_clk_freq_hz = CCS_LIM(sensor, MIN_VT_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
467 .max_pix_clk_freq_hz = CCS_LIM(sensor, MAX_VT_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
469 .min_line_length_pck_bin = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN), in ccs_pll_try()
470 .min_line_length_pck = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK), in ccs_pll_try()
476 static int ccs_pll_update(struct ccs_sensor *sensor) in ccs_pll_update() argument
478 struct ccs_pll *pll = &sensor->pll; in ccs_pll_update()
481 pll->binning_horizontal = sensor->binning_horizontal; in ccs_pll_update()
482 pll->binning_vertical = sensor->binning_vertical; in ccs_pll_update()
484 sensor->link_freq->qmenu_int[sensor->link_freq->val]; in ccs_pll_update()
485 pll->scale_m = sensor->scale_m; in ccs_pll_update()
486 pll->bits_per_pixel = sensor->csi_format->compressed; in ccs_pll_update()
488 rval = ccs_pll_try(sensor, pll); in ccs_pll_update()
492 __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_parray, in ccs_pll_update()
494 __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_csi, pll->pixel_rate_csi); in ccs_pll_update()
506 static void __ccs_update_exposure_limits(struct ccs_sensor *sensor) in __ccs_update_exposure_limits() argument
508 struct v4l2_ctrl *ctrl = sensor->exposure; in __ccs_update_exposure_limits()
511 max = sensor->pixel_array->crop[CCS_PA_PAD_SRC].height in __ccs_update_exposure_limits()
512 + sensor->vblank->val in __ccs_update_exposure_limits()
513 - CCS_LIM(sensor, COARSE_INTEGRATION_TIME_MAX_MARGIN); in __ccs_update_exposure_limits()
559 static u32 ccs_pixel_order(struct ccs_sensor *sensor) in ccs_pixel_order() argument
561 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pixel_order()
564 if (sensor->hflip) { in ccs_pixel_order()
565 if (sensor->hflip->val) in ccs_pixel_order()
568 if (sensor->vflip->val) in ccs_pixel_order()
572 flip ^= sensor->hvflip_inv_mask; in ccs_pixel_order()
575 return sensor->default_pixel_order ^ flip; in ccs_pixel_order()
578 static void ccs_update_mbus_formats(struct ccs_sensor *sensor) in ccs_update_mbus_formats() argument
580 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_update_mbus_formats()
582 to_csi_format_idx(sensor->csi_format) & ~3; in ccs_update_mbus_formats()
584 to_csi_format_idx(sensor->internal_csi_format) & ~3; in ccs_update_mbus_formats()
585 unsigned int pixel_order = ccs_pixel_order(sensor); in ccs_update_mbus_formats()
591 sensor->mbus_frame_fmts = in ccs_update_mbus_formats()
592 sensor->default_mbus_frame_fmts << pixel_order; in ccs_update_mbus_formats()
593 sensor->csi_format = in ccs_update_mbus_formats()
595 sensor->internal_csi_format = in ccs_update_mbus_formats()
613 struct ccs_sensor *sensor = in ccs_set_ctrl() local
615 ->sensor; in ccs_set_ctrl()
616 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_set_ctrl()
626 if (sensor->streaming) in ccs_set_ctrl()
629 if (sensor->hflip->val) in ccs_set_ctrl()
632 if (sensor->vflip->val) in ccs_set_ctrl()
635 orient ^= sensor->hvflip_inv_mask; in ccs_set_ctrl()
637 ccs_update_mbus_formats(sensor); in ccs_set_ctrl()
641 exposure = sensor->exposure->val; in ccs_set_ctrl()
643 __ccs_update_exposure_limits(sensor); in ccs_set_ctrl()
645 if (exposure > sensor->exposure->maximum) { in ccs_set_ctrl()
646 sensor->exposure->val = sensor->exposure->maximum; in ccs_set_ctrl()
647 rval = ccs_set_ctrl(sensor->exposure); in ccs_set_ctrl()
654 if (sensor->streaming) in ccs_set_ctrl()
657 rval = ccs_pll_update(sensor); in ccs_set_ctrl()
663 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) in ccs_set_ctrl()
665 sensor->test_data[i], in ccs_set_ctrl()
678 rval = ccs_write(sensor, ANALOG_GAIN_CODE_GLOBAL, ctrl->val); in ccs_set_ctrl()
683 rval = ccs_write(sensor, ANALOG_LINEAR_GAIN_GLOBAL, ctrl->val); in ccs_set_ctrl()
688 rval = ccs_write(sensor, ANALOG_EXPONENTIAL_GAIN_GLOBAL, in ccs_set_ctrl()
694 if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_set_ctrl()
696 rval = ccs_write(sensor, DIGITAL_GAIN_GLOBAL, in ccs_set_ctrl()
701 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
707 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
713 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
719 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
725 rval = ccs_write(sensor, COARSE_INTEGRATION_TIME, ctrl->val); in ccs_set_ctrl()
730 rval = ccs_write(sensor, IMAGE_ORIENTATION, orient); in ccs_set_ctrl()
734 rval = ccs_write(sensor, FRAME_LENGTH_LINES, in ccs_set_ctrl()
735 sensor->pixel_array->crop[ in ccs_set_ctrl()
741 rval = ccs_write(sensor, LINE_LENGTH_PCK, in ccs_set_ctrl()
742 sensor->pixel_array->crop[CCS_PA_PAD_SRC].width in ccs_set_ctrl()
747 rval = ccs_write(sensor, TEST_PATTERN_MODE, ctrl->val); in ccs_set_ctrl()
751 rval = ccs_write(sensor, TEST_DATA_RED, ctrl->val); in ccs_set_ctrl()
755 rval = ccs_write(sensor, TEST_DATA_GREENR, ctrl->val); in ccs_set_ctrl()
759 rval = ccs_write(sensor, TEST_DATA_BLUE, ctrl->val); in ccs_set_ctrl()
763 rval = ccs_write(sensor, TEST_DATA_GREENB, ctrl->val); in ccs_set_ctrl()
767 rval = ccs_write(sensor, SHADING_CORRECTION_EN, in ccs_set_ctrl()
771 if (!rval && sensor->luminance_level) in ccs_set_ctrl()
772 v4l2_ctrl_activate(sensor->luminance_level, ctrl->val); in ccs_set_ctrl()
776 rval = ccs_write(sensor, LUMINANCE_CORRECTION_LEVEL, ctrl->val); in ccs_set_ctrl()
800 static int ccs_init_controls(struct ccs_sensor *sensor) in ccs_init_controls() argument
802 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_init_controls()
805 rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 17); in ccs_init_controls()
809 sensor->pixel_array->ctrl_handler.lock = &sensor->mutex; in ccs_init_controls()
811 switch (CCS_LIM(sensor, ANALOG_GAIN_CAPABILITY)) { in ccs_init_controls()
819 CCS_LIM(sensor, ANALOG_GAIN_M0), }, in ccs_init_controls()
821 CCS_LIM(sensor, ANALOG_GAIN_C0), }, in ccs_init_controls()
823 CCS_LIM(sensor, ANALOG_GAIN_M1), }, in ccs_init_controls()
825 CCS_LIM(sensor, ANALOG_GAIN_C1), }, in ccs_init_controls()
841 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
845 v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
847 CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN), in ccs_init_controls()
848 CCS_LIM(sensor, ANALOG_GAIN_CODE_MAX), in ccs_init_controls()
849 max(CCS_LIM(sensor, ANALOG_GAIN_CODE_STEP), in ccs_init_controls()
851 CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN)); in ccs_init_controls()
864 CCS_LIM(sensor, ANALOG_LINEAR_GAIN_MIN), in ccs_init_controls()
865 CCS_LIM(sensor, ANALOG_LINEAR_GAIN_MAX), in ccs_init_controls()
866 max(CCS_LIM(sensor, in ccs_init_controls()
873 CCS_LIM(sensor, ANALOG_EXPONENTIAL_GAIN_MIN), in ccs_init_controls()
874 CCS_LIM(sensor, ANALOG_EXPONENTIAL_GAIN_MAX), in ccs_init_controls()
875 max(CCS_LIM(sensor, in ccs_init_controls()
893 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
899 if (CCS_LIM(sensor, SHADING_CORRECTION_CAPABILITY) & in ccs_init_controls()
911 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
915 if (CCS_LIM(sensor, SHADING_CORRECTION_CAPABILITY) & in ccs_init_controls()
927 sensor->luminance_level = in ccs_init_controls()
928 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
932 if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_init_controls()
934 CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_init_controls()
936 v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
938 CCS_LIM(sensor, DIGITAL_GAIN_MIN), in ccs_init_controls()
939 CCS_LIM(sensor, DIGITAL_GAIN_MAX), in ccs_init_controls()
940 max(CCS_LIM(sensor, DIGITAL_GAIN_STEP_SIZE), in ccs_init_controls()
945 sensor->exposure = v4l2_ctrl_new_std( in ccs_init_controls()
946 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
949 sensor->hflip = v4l2_ctrl_new_std( in ccs_init_controls()
950 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
952 sensor->vflip = v4l2_ctrl_new_std( in ccs_init_controls()
953 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
956 sensor->vblank = v4l2_ctrl_new_std( in ccs_init_controls()
957 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
960 if (sensor->vblank) in ccs_init_controls()
961 sensor->vblank->flags |= V4L2_CTRL_FLAG_UPDATE; in ccs_init_controls()
963 sensor->hblank = v4l2_ctrl_new_std( in ccs_init_controls()
964 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
967 if (sensor->hblank) in ccs_init_controls()
968 sensor->hblank->flags |= V4L2_CTRL_FLAG_UPDATE; in ccs_init_controls()
970 sensor->pixel_rate_parray = v4l2_ctrl_new_std( in ccs_init_controls()
971 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
974 v4l2_ctrl_new_std_menu_items(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
979 if (sensor->pixel_array->ctrl_handler.error) { in ccs_init_controls()
982 sensor->pixel_array->ctrl_handler.error); in ccs_init_controls()
983 return sensor->pixel_array->ctrl_handler.error; in ccs_init_controls()
986 sensor->pixel_array->sd.ctrl_handler = in ccs_init_controls()
987 &sensor->pixel_array->ctrl_handler; in ccs_init_controls()
989 v4l2_ctrl_cluster(2, &sensor->hflip); in ccs_init_controls()
991 rval = v4l2_ctrl_handler_init(&sensor->src->ctrl_handler, 0); in ccs_init_controls()
995 sensor->src->ctrl_handler.lock = &sensor->mutex; in ccs_init_controls()
997 sensor->pixel_rate_csi = v4l2_ctrl_new_std( in ccs_init_controls()
998 &sensor->src->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
1001 if (sensor->src->ctrl_handler.error) { in ccs_init_controls()
1004 sensor->src->ctrl_handler.error); in ccs_init_controls()
1005 return sensor->src->ctrl_handler.error; in ccs_init_controls()
1008 sensor->src->sd.ctrl_handler = &sensor->src->ctrl_handler; in ccs_init_controls()
1017 static int ccs_init_late_controls(struct ccs_sensor *sensor) in ccs_init_late_controls() argument
1019 unsigned long *valid_link_freqs = &sensor->valid_link_freqs[ in ccs_init_late_controls()
1020 sensor->csi_format->compressed - sensor->compressed_min_bpp]; in ccs_init_late_controls()
1023 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) { in ccs_init_late_controls()
1024 int max_value = (1 << sensor->csi_format->width) - 1; in ccs_init_late_controls()
1026 sensor->test_data[i] = v4l2_ctrl_new_std( in ccs_init_late_controls()
1027 &sensor->pixel_array->ctrl_handler, in ccs_init_late_controls()
1032 sensor->link_freq = v4l2_ctrl_new_int_menu( in ccs_init_late_controls()
1033 &sensor->src->ctrl_handler, &ccs_ctrl_ops, in ccs_init_late_controls()
1035 __ffs(*valid_link_freqs), sensor->hwcfg.op_sys_clock); in ccs_init_late_controls()
1037 return sensor->src->ctrl_handler.error; in ccs_init_late_controls()
1040 static void ccs_free_controls(struct ccs_sensor *sensor) in ccs_free_controls() argument
1044 for (i = 0; i < sensor->ssds_used; i++) in ccs_free_controls()
1045 v4l2_ctrl_handler_free(&sensor->ssds[i].ctrl_handler); in ccs_free_controls()
1048 static int ccs_get_mbus_formats(struct ccs_sensor *sensor) in ccs_get_mbus_formats() argument
1050 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_get_mbus_formats()
1051 struct ccs_pll *pll = &sensor->pll; in ccs_get_mbus_formats()
1057 type = CCS_LIM(sensor, DATA_FORMAT_MODEL_TYPE); in ccs_get_mbus_formats()
1061 rval = ccs_read(sensor, PIXEL_ORDER, &pixel_order); in ccs_get_mbus_formats()
1084 sensor->default_pixel_order = pixel_order; in ccs_get_mbus_formats()
1085 sensor->mbus_frame_fmts = 0; in ccs_get_mbus_formats()
1090 fmt = CCS_LIM_AT(sensor, DATA_FORMAT_DESCRIPTOR, i); in ccs_get_mbus_formats()
1110 sensor->default_mbus_frame_fmts |= 1 << j; in ccs_get_mbus_formats()
1117 pll->scale_m = sensor->scale_m; in ccs_get_mbus_formats()
1120 sensor->compressed_min_bpp = in ccs_get_mbus_formats()
1122 sensor->compressed_min_bpp); in ccs_get_mbus_formats()
1128 sensor->valid_link_freqs = devm_kcalloc( in ccs_get_mbus_formats()
1130 compressed_max_bpp - sensor->compressed_min_bpp + 1, in ccs_get_mbus_formats()
1131 sizeof(*sensor->valid_link_freqs), GFP_KERNEL); in ccs_get_mbus_formats()
1132 if (!sensor->valid_link_freqs) in ccs_get_mbus_formats()
1139 &sensor->valid_link_freqs[ in ccs_get_mbus_formats()
1140 f->compressed - sensor->compressed_min_bpp]; in ccs_get_mbus_formats()
1143 if (!(sensor->default_mbus_frame_fmts & 1 << i)) in ccs_get_mbus_formats()
1148 for (j = 0; sensor->hwcfg.op_sys_clock[j]; j++) { in ccs_get_mbus_formats()
1149 pll->link_freq = sensor->hwcfg.op_sys_clock[j]; in ccs_get_mbus_formats()
1151 rval = ccs_pll_try(sensor, pll); in ccs_get_mbus_formats()
1165 sensor->default_mbus_frame_fmts &= ~BIT(i); in ccs_get_mbus_formats()
1169 if (!sensor->csi_format in ccs_get_mbus_formats()
1170 || f->width > sensor->csi_format->width in ccs_get_mbus_formats()
1171 || (f->width == sensor->csi_format->width in ccs_get_mbus_formats()
1172 && f->compressed > sensor->csi_format->compressed)) { in ccs_get_mbus_formats()
1173 sensor->csi_format = f; in ccs_get_mbus_formats()
1174 sensor->internal_csi_format = f; in ccs_get_mbus_formats()
1178 if (!sensor->csi_format) { in ccs_get_mbus_formats()
1183 ccs_update_mbus_formats(sensor); in ccs_get_mbus_formats()
1188 static void ccs_update_blanking(struct ccs_sensor *sensor) in ccs_update_blanking() argument
1190 struct v4l2_ctrl *vblank = sensor->vblank; in ccs_update_blanking()
1191 struct v4l2_ctrl *hblank = sensor->hblank; in ccs_update_blanking()
1195 if (sensor->binning_vertical > 1 || sensor->binning_horizontal > 1) { in ccs_update_blanking()
1196 min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES_BIN); in ccs_update_blanking()
1197 max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES_BIN); in ccs_update_blanking()
1198 min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN); in ccs_update_blanking()
1199 max_llp = CCS_LIM(sensor, MAX_LINE_LENGTH_PCK_BIN); in ccs_update_blanking()
1200 min_lbp = CCS_LIM(sensor, MIN_LINE_BLANKING_PCK_BIN); in ccs_update_blanking()
1202 min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES); in ccs_update_blanking()
1203 max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES); in ccs_update_blanking()
1204 min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK); in ccs_update_blanking()
1205 max_llp = CCS_LIM(sensor, MAX_LINE_LENGTH_PCK); in ccs_update_blanking()
1206 min_lbp = CCS_LIM(sensor, MIN_LINE_BLANKING_PCK); in ccs_update_blanking()
1210 CCS_LIM(sensor, MIN_FRAME_BLANKING_LINES), in ccs_update_blanking()
1211 min_fll - sensor->pixel_array->crop[CCS_PA_PAD_SRC].height); in ccs_update_blanking()
1212 max = max_fll - sensor->pixel_array->crop[CCS_PA_PAD_SRC].height; in ccs_update_blanking()
1217 min_llp - sensor->pixel_array->crop[CCS_PA_PAD_SRC].width, in ccs_update_blanking()
1219 max = max_llp - sensor->pixel_array->crop[CCS_PA_PAD_SRC].width; in ccs_update_blanking()
1223 __ccs_update_exposure_limits(sensor); in ccs_update_blanking()
1226 static int ccs_pll_blanking_update(struct ccs_sensor *sensor) in ccs_pll_blanking_update() argument
1228 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pll_blanking_update()
1231 rval = ccs_pll_update(sensor); in ccs_pll_blanking_update()
1236 ccs_update_blanking(sensor); in ccs_pll_blanking_update()
1238 dev_dbg(&client->dev, "vblank\t\t%d\n", sensor->vblank->val); in ccs_pll_blanking_update()
1239 dev_dbg(&client->dev, "hblank\t\t%d\n", sensor->hblank->val); in ccs_pll_blanking_update()
1242 sensor->pll.pixel_rate_pixel_array / in ccs_pll_blanking_update()
1243 ((sensor->pixel_array->crop[CCS_PA_PAD_SRC].width in ccs_pll_blanking_update()
1244 + sensor->hblank->val) * in ccs_pll_blanking_update()
1245 (sensor->pixel_array->crop[CCS_PA_PAD_SRC].height in ccs_pll_blanking_update()
1246 + sensor->vblank->val) / 100)); in ccs_pll_blanking_update()
1257 static int ccs_read_nvm_page(struct ccs_sensor *sensor, u32 p, u8 *nvm, in ccs_read_nvm_page() argument
1266 rval = ccs_write(sensor, DATA_TRANSFER_IF_1_PAGE_SELECT, p); in ccs_read_nvm_page()
1270 rval = ccs_write(sensor, DATA_TRANSFER_IF_1_CTRL, in ccs_read_nvm_page()
1275 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_STATUS, &s); in ccs_read_nvm_page()
1284 if (CCS_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & in ccs_read_nvm_page()
1290 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_STATUS, &s); in ccs_read_nvm_page()
1302 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_DATA(i), &v); in ccs_read_nvm_page()
1312 static int ccs_read_nvm(struct ccs_sensor *sensor, unsigned char *nvm, in ccs_read_nvm() argument
1321 rval = ccs_read_nvm_page(sensor, p, nvm, &status); in ccs_read_nvm()
1329 rval2 = ccs_write(sensor, DATA_TRANSFER_IF_1_CTRL, 0); in ccs_read_nvm()
1341 static int ccs_change_cci_addr(struct ccs_sensor *sensor) in ccs_change_cci_addr() argument
1343 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_change_cci_addr()
1347 client->addr = sensor->hwcfg.i2c_addr_dfl; in ccs_change_cci_addr()
1349 rval = ccs_write(sensor, CCI_ADDRESS_CTRL, in ccs_change_cci_addr()
1350 sensor->hwcfg.i2c_addr_alt << 1); in ccs_change_cci_addr()
1354 client->addr = sensor->hwcfg.i2c_addr_alt; in ccs_change_cci_addr()
1357 rval = ccs_read(sensor, CCI_ADDRESS_CTRL, &val); in ccs_change_cci_addr()
1361 if (val != sensor->hwcfg.i2c_addr_alt << 1) in ccs_change_cci_addr()
1372 static int ccs_setup_flash_strobe(struct ccs_sensor *sensor) in ccs_setup_flash_strobe() argument
1375 unsigned int ext_freq = sensor->hwcfg.ext_clk; in ccs_setup_flash_strobe()
1381 strobe_setup = sensor->hwcfg.strobe_setup; in ccs_setup_flash_strobe()
1463 rval = ccs_write(sensor, FLASH_MODE_RS, strobe_setup->mode); in ccs_setup_flash_strobe()
1467 rval = ccs_write(sensor, FLASH_STROBE_ADJUSTMENT, strobe_adjustment); in ccs_setup_flash_strobe()
1471 rval = ccs_write(sensor, TFLASH_STROBE_WIDTH_HIGH_RS_CTRL, in ccs_setup_flash_strobe()
1476 rval = ccs_write(sensor, TFLASH_STROBE_DELAY_RS_CTRL, in ccs_setup_flash_strobe()
1481 rval = ccs_write(sensor, FLASH_STROBE_START_POINT, in ccs_setup_flash_strobe()
1486 rval = ccs_write(sensor, FLASH_TRIGGER_RS, strobe_setup->trigger); in ccs_setup_flash_strobe()
1489 sensor->hwcfg.strobe_setup->trigger = 0; in ccs_setup_flash_strobe()
1498 static int ccs_write_msr_regs(struct ccs_sensor *sensor) in ccs_write_msr_regs() argument
1502 rval = ccs_write_data_regs(sensor, in ccs_write_msr_regs()
1503 sensor->sdata.sensor_manufacturer_regs, in ccs_write_msr_regs()
1504 sensor->sdata.num_sensor_manufacturer_regs); in ccs_write_msr_regs()
1508 return ccs_write_data_regs(sensor, in ccs_write_msr_regs()
1509 sensor->mdata.module_manufacturer_regs, in ccs_write_msr_regs()
1510 sensor->mdata.num_module_manufacturer_regs); in ccs_write_msr_regs()
1513 static int ccs_update_phy_ctrl(struct ccs_sensor *sensor) in ccs_update_phy_ctrl() argument
1515 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_update_phy_ctrl()
1518 if (!sensor->ccs_limits) in ccs_update_phy_ctrl()
1521 if (CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_update_phy_ctrl()
1524 } else if (CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_update_phy_ctrl()
1532 return ccs_write(sensor, PHY_CTRL, val); in ccs_update_phy_ctrl()
1543 struct ccs_sensor *sensor = in ccs_power_on() local
1549 sensor->regulators); in ccs_power_on()
1555 if (sensor->reset || sensor->xshutdown || sensor->ext_clk) { in ccs_power_on()
1558 rval = clk_prepare_enable(sensor->ext_clk); in ccs_power_on()
1564 gpiod_set_value(sensor->reset, 0); in ccs_power_on()
1565 gpiod_set_value(sensor->xshutdown, 1); in ccs_power_on()
1568 sleep = SMIAPP_RESET_DELAY(sensor->hwcfg.ext_clk); in ccs_power_on()
1577 * Those failures seem to be caused by the sensor requiring a longer in ccs_power_on()
1586 if (!sensor->reset && !sensor->xshutdown) { in ccs_power_on()
1590 rval = ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); in ccs_power_on()
1597 rval = ccs_read(sensor, SOFTWARE_RESET, &reset); in ccs_power_on()
1612 if (sensor->hwcfg.i2c_addr_alt) { in ccs_power_on()
1613 rval = ccs_change_cci_addr(sensor); in ccs_power_on()
1620 rval = ccs_write(sensor, COMPRESSION_MODE, in ccs_power_on()
1627 rval = ccs_write(sensor, EXTCLK_FREQUENCY_MHZ, in ccs_power_on()
1628 sensor->hwcfg.ext_clk / (1000000 / (1 << 8))); in ccs_power_on()
1634 rval = ccs_write(sensor, CSI_LANE_MODE, sensor->hwcfg.lanes - 1); in ccs_power_on()
1640 rval = ccs_write(sensor, FAST_STANDBY_CTRL, in ccs_power_on()
1647 rval = ccs_write(sensor, CSI_SIGNALING_MODE, in ccs_power_on()
1648 sensor->hwcfg.csi_signalling_mode); in ccs_power_on()
1654 rval = ccs_update_phy_ctrl(sensor); in ccs_power_on()
1658 rval = ccs_write_msr_regs(sensor); in ccs_power_on()
1662 rval = ccs_call_quirk(sensor, post_poweron); in ccs_power_on()
1671 gpiod_set_value(sensor->reset, 1); in ccs_power_on()
1672 gpiod_set_value(sensor->xshutdown, 0); in ccs_power_on()
1673 clk_disable_unprepare(sensor->ext_clk); in ccs_power_on()
1677 sensor->regulators); in ccs_power_on()
1686 struct ccs_sensor *sensor = in ccs_power_off() local
1691 * but they are essentially the same signals. So if the sensor is in ccs_power_off()
1692 * powered off while the lens is powered on the sensor does not in ccs_power_off()
1696 if (sensor->hwcfg.i2c_addr_alt) in ccs_power_off()
1697 ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); in ccs_power_off()
1699 gpiod_set_value(sensor->reset, 1); in ccs_power_off()
1700 gpiod_set_value(sensor->xshutdown, 0); in ccs_power_off()
1701 clk_disable_unprepare(sensor->ext_clk); in ccs_power_off()
1704 sensor->regulators); in ccs_power_off()
1705 sensor->streaming = false; in ccs_power_off()
1714 static int ccs_start_streaming(struct ccs_sensor *sensor) in ccs_start_streaming() argument
1716 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_start_streaming()
1720 mutex_lock(&sensor->mutex); in ccs_start_streaming()
1722 rval = ccs_write(sensor, CSI_DATA_FORMAT, in ccs_start_streaming()
1723 (sensor->csi_format->width << 8) | in ccs_start_streaming()
1724 sensor->csi_format->compressed); in ccs_start_streaming()
1729 if (sensor->binning_horizontal == 1 && in ccs_start_streaming()
1730 sensor->binning_vertical == 1) { in ccs_start_streaming()
1734 (sensor->binning_horizontal << 4) in ccs_start_streaming()
1735 | sensor->binning_vertical; in ccs_start_streaming()
1737 rval = ccs_write(sensor, BINNING_TYPE, binning_type); in ccs_start_streaming()
1743 rval = ccs_write(sensor, BINNING_MODE, binning_mode); in ccs_start_streaming()
1748 rval = ccs_pll_configure(sensor); in ccs_start_streaming()
1753 rval = ccs_write(sensor, X_ADDR_START, in ccs_start_streaming()
1754 sensor->pixel_array->crop[CCS_PA_PAD_SRC].left); in ccs_start_streaming()
1758 rval = ccs_write(sensor, Y_ADDR_START, in ccs_start_streaming()
1759 sensor->pixel_array->crop[CCS_PA_PAD_SRC].top); in ccs_start_streaming()
1765 sensor, X_ADDR_END, in ccs_start_streaming()
1766 sensor->pixel_array->crop[CCS_PA_PAD_SRC].left in ccs_start_streaming()
1767 + sensor->pixel_array->crop[CCS_PA_PAD_SRC].width - 1); in ccs_start_streaming()
1772 sensor, Y_ADDR_END, in ccs_start_streaming()
1773 sensor->pixel_array->crop[CCS_PA_PAD_SRC].top in ccs_start_streaming()
1774 + sensor->pixel_array->crop[CCS_PA_PAD_SRC].height - 1); in ccs_start_streaming()
1784 if (CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in ccs_start_streaming()
1787 sensor, DIGITAL_CROP_X_OFFSET, in ccs_start_streaming()
1788 sensor->scaler->crop[CCS_PAD_SINK].left); in ccs_start_streaming()
1793 sensor, DIGITAL_CROP_Y_OFFSET, in ccs_start_streaming()
1794 sensor->scaler->crop[CCS_PAD_SINK].top); in ccs_start_streaming()
1799 sensor, DIGITAL_CROP_IMAGE_WIDTH, in ccs_start_streaming()
1800 sensor->scaler->crop[CCS_PAD_SINK].width); in ccs_start_streaming()
1805 sensor, DIGITAL_CROP_IMAGE_HEIGHT, in ccs_start_streaming()
1806 sensor->scaler->crop[CCS_PAD_SINK].height); in ccs_start_streaming()
1812 if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_start_streaming()
1814 rval = ccs_write(sensor, SCALING_MODE, sensor->scaling_mode); in ccs_start_streaming()
1818 rval = ccs_write(sensor, SCALE_M, sensor->scale_m); in ccs_start_streaming()
1823 /* Output size from sensor */ in ccs_start_streaming()
1824 rval = ccs_write(sensor, X_OUTPUT_SIZE, in ccs_start_streaming()
1825 sensor->src->crop[CCS_PAD_SRC].width); in ccs_start_streaming()
1828 rval = ccs_write(sensor, Y_OUTPUT_SIZE, in ccs_start_streaming()
1829 sensor->src->crop[CCS_PAD_SRC].height); in ccs_start_streaming()
1833 if (CCS_LIM(sensor, FLASH_MODE_CAPABILITY) & in ccs_start_streaming()
1836 sensor->hwcfg.strobe_setup != NULL && in ccs_start_streaming()
1837 sensor->hwcfg.strobe_setup->trigger != 0) { in ccs_start_streaming()
1838 rval = ccs_setup_flash_strobe(sensor); in ccs_start_streaming()
1843 rval = ccs_call_quirk(sensor, pre_streamon); in ccs_start_streaming()
1849 rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_STREAMING); in ccs_start_streaming()
1852 mutex_unlock(&sensor->mutex); in ccs_start_streaming()
1857 static int ccs_stop_streaming(struct ccs_sensor *sensor) in ccs_stop_streaming() argument
1859 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_stop_streaming()
1862 mutex_lock(&sensor->mutex); in ccs_stop_streaming()
1863 rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_SOFTWARE_STANDBY); in ccs_stop_streaming()
1867 rval = ccs_call_quirk(sensor, post_streamoff); in ccs_stop_streaming()
1872 mutex_unlock(&sensor->mutex); in ccs_stop_streaming()
1880 static int ccs_pm_get_init(struct ccs_sensor *sensor) in ccs_pm_get_init() argument
1882 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pm_get_init()
1899 rval = v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler); in ccs_pm_get_init()
1903 rval = v4l2_ctrl_handler_setup(&sensor->src->ctrl_handler); in ccs_pm_get_init()
1916 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_stream() local
1917 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_set_stream()
1920 if (sensor->streaming == enable) in ccs_set_stream()
1924 ccs_stop_streaming(sensor); in ccs_set_stream()
1925 sensor->streaming = false; in ccs_set_stream()
1932 rval = ccs_pm_get_init(sensor); in ccs_set_stream()
1936 sensor->streaming = true; in ccs_set_stream()
1938 rval = ccs_start_streaming(sensor); in ccs_set_stream()
1940 sensor->streaming = false; in ccs_set_stream()
1950 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_pre_streamon() local
1951 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pre_streamon()
1955 switch (sensor->hwcfg.csi_signalling_mode) { in ccs_pre_streamon()
1957 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) & in ccs_pre_streamon()
1962 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) & in ccs_pre_streamon()
1971 rval = ccs_pm_get_init(sensor); in ccs_pre_streamon()
1976 rval = ccs_write(sensor, MANUAL_LP_CTRL, in ccs_pre_streamon()
1987 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_post_streamoff() local
1988 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_post_streamoff()
1998 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_enum_mbus_code() local
2003 mutex_lock(&sensor->mutex); in ccs_enum_mbus_code()
2008 if (subdev != &sensor->src->sd || code->pad != CCS_PAD_SRC) { in ccs_enum_mbus_code()
2012 code->code = sensor->internal_csi_format->code; in ccs_enum_mbus_code()
2018 if (sensor->mbus_frame_fmts & (1 << i)) in ccs_enum_mbus_code()
2031 mutex_unlock(&sensor->mutex); in ccs_enum_mbus_code()
2038 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in __ccs_get_mbus_code() local
2040 if (subdev == &sensor->src->sd && pad == CCS_PAD_SRC) in __ccs_get_mbus_code()
2041 return sensor->csi_format->code; in __ccs_get_mbus_code()
2043 return sensor->internal_csi_format->code; in __ccs_get_mbus_code()
2076 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_format() local
2079 mutex_lock(&sensor->mutex); in ccs_get_format()
2081 mutex_unlock(&sensor->mutex); in ccs_get_format()
2118 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_propagate() local
2129 if (ssd == sensor->scaler) { in ccs_propagate()
2130 sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_propagate()
2131 sensor->scaling_mode = in ccs_propagate()
2133 } else if (ssd == sensor->binner) { in ccs_propagate()
2134 sensor->binning_horizontal = 1; in ccs_propagate()
2135 sensor->binning_vertical = 1; in ccs_propagate()
2148 *ccs_validate_csi_data_format(struct ccs_sensor *sensor, u32 code) in ccs_validate_csi_data_format() argument
2153 if (sensor->mbus_frame_fmts & (1 << i) && in ccs_validate_csi_data_format()
2158 return sensor->csi_format; in ccs_validate_csi_data_format()
2165 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_format_source() local
2167 *old_csi_format = sensor->csi_format; in ccs_set_format_source()
2181 if (subdev != &sensor->src->sd) in ccs_set_format_source()
2184 csi_format = ccs_validate_csi_data_format(sensor, code); in ccs_set_format_source()
2191 sensor->csi_format = csi_format; in ccs_set_format_source()
2194 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) in ccs_set_format_source()
2196 sensor->test_data[i], 0, in ccs_set_format_source()
2203 &sensor->valid_link_freqs[sensor->csi_format->compressed in ccs_set_format_source()
2204 - sensor->compressed_min_bpp]; in ccs_set_format_source()
2207 sensor->link_freq, 0, in ccs_set_format_source()
2211 return ccs_pll_update(sensor); in ccs_set_format_source()
2218 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_format() local
2222 mutex_lock(&sensor->mutex); in ccs_set_format()
2229 mutex_unlock(&sensor->mutex); in ccs_set_format()
2242 CCS_LIM(sensor, MIN_X_OUTPUT_SIZE), in ccs_set_format()
2243 CCS_LIM(sensor, MAX_X_OUTPUT_SIZE)); in ccs_set_format()
2246 CCS_LIM(sensor, MIN_Y_OUTPUT_SIZE), in ccs_set_format()
2247 CCS_LIM(sensor, MAX_Y_OUTPUT_SIZE)); in ccs_set_format()
2259 mutex_unlock(&sensor->mutex); in ccs_set_format()
2273 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in scaling_goodness() local
2299 if (w < CCS_LIM(sensor, MIN_X_OUTPUT_SIZE)) in scaling_goodness()
2314 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose_binner() local
2322 for (i = 0; i < sensor->nbinning_subtypes; i++) { in ccs_set_compose_binner()
2326 / sensor->binning_subtypes[i].horizontal, in ccs_set_compose_binner()
2329 / sensor->binning_subtypes[i].vertical, in ccs_set_compose_binner()
2333 binh = sensor->binning_subtypes[i].horizontal; in ccs_set_compose_binner()
2334 binv = sensor->binning_subtypes[i].vertical; in ccs_set_compose_binner()
2339 sensor->binning_vertical = binv; in ccs_set_compose_binner()
2340 sensor->binning_horizontal = binh; in ccs_set_compose_binner()
2363 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose_scaler() local
2365 u32 scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_set_compose_scaler()
2378 * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.width; in ccs_set_compose_scaler()
2380 * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height; in ccs_set_compose_scaler()
2382 * CCS_LIM(sensor, SCALER_N_MIN) in ccs_set_compose_scaler()
2383 / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE); in ccs_set_compose_scaler()
2385 a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2386 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2387 b = clamp(b, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2388 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2389 max_m = clamp(max_m, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2390 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2416 / try[i] * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2430 if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_set_compose_scaler()
2437 * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2441 * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2455 * CCS_LIM(sensor, SCALER_N_MIN)) & ~1; in ccs_set_compose_scaler()
2460 * CCS_LIM(sensor, SCALER_N_MIN)) in ccs_set_compose_scaler()
2466 sensor->scale_m = scale_m; in ccs_set_compose_scaler()
2467 sensor->scaling_mode = mode; in ccs_set_compose_scaler()
2475 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose() local
2484 if (ssd == sensor->binner) in ccs_set_compose()
2493 return ccs_pll_blanking_update(sensor); in ccs_set_compose()
2501 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in __ccs_sel_supported() local
2508 if (ssd == sensor->pixel_array && sel->pad == CCS_PA_PAD_SRC) in __ccs_sel_supported()
2510 if (ssd == sensor->src && sel->pad == CCS_PAD_SRC) in __ccs_sel_supported()
2512 if (ssd == sensor->scaler && sel->pad == CCS_PAD_SINK && in __ccs_sel_supported()
2513 CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in __ccs_sel_supported()
2518 if (ssd == sensor->pixel_array && sel->pad == CCS_PA_PAD_SRC) in __ccs_sel_supported()
2525 if (ssd == sensor->binner) in __ccs_sel_supported()
2527 if (ssd == sensor->scaler && CCS_LIM(sensor, SCALING_CAPABILITY) in __ccs_sel_supported()
2540 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_crop() local
2571 if (ssd == sensor->src && sel->pad == CCS_PAD_SRC) { in ccs_set_crop()
2584 if (ssd != sensor->pixel_array && sel->pad == CCS_PAD_SINK) in ccs_set_crop()
2594 r->width = CCS_LIM(ssd->sensor, X_ADDR_MAX) + 1; in ccs_get_native_size()
2595 r->height = CCS_LIM(ssd->sensor, Y_ADDR_MAX) + 1; in ccs_get_native_size()
2602 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in __ccs_get_selection() local
2630 if (ssd == sensor->pixel_array) in __ccs_get_selection()
2653 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_selection() local
2656 mutex_lock(&sensor->mutex); in ccs_get_selection()
2658 mutex_unlock(&sensor->mutex); in ccs_get_selection()
2667 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_selection() local
2674 mutex_lock(&sensor->mutex); in ccs_set_selection()
2681 sel->r.width = max_t(unsigned int, CCS_LIM(sensor, MIN_X_OUTPUT_SIZE), in ccs_set_selection()
2683 sel->r.height = max_t(unsigned int, CCS_LIM(sensor, MIN_Y_OUTPUT_SIZE), in ccs_set_selection()
2697 mutex_unlock(&sensor->mutex); in ccs_set_selection()
2703 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_skip_frames() local
2705 *frames = sensor->frame_skip; in ccs_get_skip_frames()
2711 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_skip_top_lines() local
2713 *lines = sensor->image_start; in ccs_get_skip_top_lines()
2727 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in nvm_show() local
2730 if (!sensor->dev_init_done) in nvm_show()
2733 rval = ccs_pm_get_init(sensor); in nvm_show()
2737 rval = ccs_read_nvm(sensor, buf, PAGE_SIZE); in nvm_show()
2759 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ident_show() local
2760 struct ccs_module_info *minfo = &sensor->minfo; in ident_show()
2777 static int ccs_identify_module(struct ccs_sensor *sensor) in ccs_identify_module() argument
2779 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_identify_module()
2780 struct ccs_module_info *minfo = &sensor->minfo; in ccs_identify_module()
2786 rval = ccs_read(sensor, MODULE_MANUFACTURER_ID, in ccs_identify_module()
2789 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2793 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_MODEL_ID, in ccs_identify_module()
2796 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2800 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2806 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_DATE_YEAR, in ccs_identify_module()
2809 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_DATE_MONTH, in ccs_identify_module()
2812 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_DATE_DAY, in ccs_identify_module()
2815 /* Sensor info */ in ccs_identify_module()
2817 rval = ccs_read(sensor, SENSOR_MANUFACTURER_ID, in ccs_identify_module()
2820 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2824 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2828 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2832 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2838 rval = ccs_read(sensor, MIPI_CCS_VERSION, &minfo->ccs_version); in ccs_identify_module()
2840 rval = ccs_read_addr_8only(sensor, SMIAPP_REG_U8_SMIA_VERSION, in ccs_identify_module()
2843 rval = ccs_read_addr_8only(sensor, SMIAPP_REG_U8_SMIAPP_VERSION, in ccs_identify_module()
2847 dev_err(&client->dev, "sensor detection failed\n"); in ccs_identify_module()
2864 dev_dbg(&client->dev, "MIPI CCS sensor 0x%4.4x-0x%4.4x\n", in ccs_identify_module()
2868 dev_dbg(&client->dev, "SMIA sensor 0x%2.2x-0x%4.4x\n", in ccs_identify_module()
2873 "sensor revision 0x%2.2x firmware version 0x%2.2x\n", in ccs_identify_module()
2892 * parameters whereas the rvalues are sensor parameters. in ccs_identify_module()
2933 dev_dbg(&client->dev, "the sensor is called %s\n", minfo->name); in ccs_identify_module()
2942 static int ccs_register_subdev(struct ccs_sensor *sensor, in ccs_register_subdev() argument
2947 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_register_subdev()
2959 rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, &ssd->sd); in ccs_register_subdev()
2979 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_unregistered() local
2982 for (i = 1; i < sensor->ssds_used; i++) in ccs_unregistered()
2983 v4l2_device_unregister_subdev(&sensor->ssds[i].sd); in ccs_unregistered()
2988 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_registered() local
2991 if (sensor->scaler) { in ccs_registered()
2992 rval = ccs_register_subdev(sensor, sensor->binner, in ccs_registered()
2993 sensor->scaler, in ccs_registered()
3001 rval = ccs_register_subdev(sensor, sensor->pixel_array, sensor->binner, in ccs_registered()
3016 static void ccs_cleanup(struct ccs_sensor *sensor) in ccs_cleanup() argument
3018 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_cleanup()
3023 ccs_free_controls(sensor); in ccs_cleanup()
3026 static void ccs_create_subdev(struct ccs_sensor *sensor, in ccs_create_subdev() argument
3030 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_create_subdev()
3035 if (ssd != sensor->src) in ccs_create_subdev()
3040 ssd->sensor = sensor; in ccs_create_subdev()
3045 v4l2_i2c_subdev_set_name(&ssd->sd, client, sensor->minfo.name, name); in ccs_create_subdev()
3053 if (ssd != sensor->pixel_array) { in ccs_create_subdev()
3060 if (ssd == sensor->src) in ccs_create_subdev()
3072 struct ccs_sensor *sensor = ssd->sensor; in ccs_open() local
3075 mutex_lock(&sensor->mutex); in ccs_open()
3088 try_fmt->code = sensor->internal_csi_format->code; in ccs_open()
3091 if (ssd != sensor->pixel_array) in ccs_open()
3098 mutex_unlock(&sensor->mutex); in ccs_open()
3125 .sensor = &ccs_sensor_ops,
3150 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_suspend() local
3151 bool streaming = sensor->streaming; in ccs_suspend()
3158 if (sensor->streaming) in ccs_suspend()
3159 ccs_stop_streaming(sensor); in ccs_suspend()
3162 sensor->streaming = streaming; in ccs_suspend()
3171 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_resume() local
3176 if (sensor->streaming) in ccs_resume()
3177 rval = ccs_start_streaming(sensor); in ccs_resume()
3182 static int ccs_get_hwconfig(struct ccs_sensor *sensor, struct device *dev) in ccs_get_hwconfig() argument
3184 struct ccs_hwconfig *hwcfg = &sensor->hwcfg; in ccs_get_hwconfig()
3284 struct ccs_sensor *sensor; in ccs_probe() local
3290 sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); in ccs_probe()
3291 if (sensor == NULL) in ccs_probe()
3294 rval = ccs_get_hwconfig(sensor, &client->dev); in ccs_probe()
3298 sensor->src = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3300 v4l2_i2c_subdev_init(&sensor->src->sd, client, &ccs_ops); in ccs_probe()
3301 sensor->src->sd.internal_ops = &ccs_internal_src_ops; in ccs_probe()
3303 sensor->regulators = devm_kcalloc(&client->dev, in ccs_probe()
3305 sizeof(*sensor->regulators), in ccs_probe()
3307 if (!sensor->regulators) in ccs_probe()
3311 sensor->regulators[i].supply = ccs_regulators[i]; in ccs_probe()
3314 sensor->regulators); in ccs_probe()
3320 sensor->ext_clk = devm_clk_get(&client->dev, NULL); in ccs_probe()
3321 if (PTR_ERR(sensor->ext_clk) == -ENOENT) { in ccs_probe()
3323 sensor->ext_clk = NULL; in ccs_probe()
3324 } else if (IS_ERR(sensor->ext_clk)) { in ccs_probe()
3326 PTR_ERR(sensor->ext_clk)); in ccs_probe()
3330 if (sensor->ext_clk) { in ccs_probe()
3331 if (sensor->hwcfg.ext_clk) { in ccs_probe()
3334 rval = clk_set_rate(sensor->ext_clk, in ccs_probe()
3335 sensor->hwcfg.ext_clk); in ccs_probe()
3339 sensor->hwcfg.ext_clk); in ccs_probe()
3343 rate = clk_get_rate(sensor->ext_clk); in ccs_probe()
3344 if (rate != sensor->hwcfg.ext_clk) { in ccs_probe()
3347 sensor->hwcfg.ext_clk, rate); in ccs_probe()
3351 sensor->hwcfg.ext_clk = clk_get_rate(sensor->ext_clk); in ccs_probe()
3353 sensor->hwcfg.ext_clk); in ccs_probe()
3355 } else if (sensor->hwcfg.ext_clk) { in ccs_probe()
3357 sensor->hwcfg.ext_clk); in ccs_probe()
3363 if (!sensor->hwcfg.ext_clk) { in ccs_probe()
3368 sensor->reset = devm_gpiod_get_optional(&client->dev, "reset", in ccs_probe()
3370 if (IS_ERR(sensor->reset)) in ccs_probe()
3371 return PTR_ERR(sensor->reset); in ccs_probe()
3373 if (!sensor->reset) in ccs_probe()
3374 sensor->xshutdown = devm_gpiod_get_optional(&client->dev, in ccs_probe()
3377 if (IS_ERR(sensor->xshutdown)) in ccs_probe()
3378 return PTR_ERR(sensor->xshutdown); in ccs_probe()
3384 mutex_init(&sensor->mutex); in ccs_probe()
3386 rval = ccs_identify_module(sensor); in ccs_probe()
3393 "ccs/ccs-sensor-%4.4x-%4.4x-%4.4x.fw", in ccs_probe()
3394 sensor->minfo.sensor_mipi_manufacturer_id, in ccs_probe()
3395 sensor->minfo.sensor_model_id, in ccs_probe()
3396 sensor->minfo.sensor_revision_number); in ccs_probe()
3404 ccs_data_parse(&sensor->sdata, fw->data, fw->size, &client->dev, in ccs_probe()
3411 sensor->minfo.mipi_manufacturer_id, in ccs_probe()
3412 sensor->minfo.model_id, in ccs_probe()
3413 sensor->minfo.revision_number); in ccs_probe()
3421 ccs_data_parse(&sensor->mdata, fw->data, fw->size, &client->dev, in ccs_probe()
3426 rval = ccs_read_all_limits(sensor); in ccs_probe()
3430 rval = ccs_read_frame_fmt(sensor); in ccs_probe()
3436 rval = ccs_update_phy_ctrl(sensor); in ccs_probe()
3441 * Handle Sensor Module orientation on the board. in ccs_probe()
3443 * The application of H-FLIP and V-FLIP on the sensor is modified by in ccs_probe()
3444 * the sensor orientation on the board. in ccs_probe()
3453 if (sensor->hwcfg.module_board_orient == in ccs_probe()
3455 sensor->hvflip_inv_mask = in ccs_probe()
3459 rval = ccs_call_quirk(sensor, limits); in ccs_probe()
3465 if (CCS_LIM(sensor, BINNING_CAPABILITY)) { in ccs_probe()
3466 sensor->nbinning_subtypes = in ccs_probe()
3467 min_t(u8, CCS_LIM(sensor, BINNING_SUB_TYPES), in ccs_probe()
3470 for (i = 0; i < sensor->nbinning_subtypes; i++) { in ccs_probe()
3471 sensor->binning_subtypes[i].horizontal = in ccs_probe()
3472 CCS_LIM_AT(sensor, BINNING_SUB_TYPE, i) >> in ccs_probe()
3474 sensor->binning_subtypes[i].vertical = in ccs_probe()
3475 CCS_LIM_AT(sensor, BINNING_SUB_TYPE, i) & in ccs_probe()
3479 sensor->binning_subtypes[i].horizontal, in ccs_probe()
3480 sensor->binning_subtypes[i].vertical); in ccs_probe()
3483 sensor->binning_horizontal = 1; in ccs_probe()
3484 sensor->binning_vertical = 1; in ccs_probe()
3492 if (sensor->minfo.smiapp_version && in ccs_probe()
3493 CCS_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & in ccs_probe()
3502 if (!CCS_LIM(sensor, MIN_OP_SYS_CLK_DIV) || in ccs_probe()
3503 !CCS_LIM(sensor, MAX_OP_SYS_CLK_DIV) || in ccs_probe()
3504 !CCS_LIM(sensor, MIN_OP_PIX_CLK_DIV) || in ccs_probe()
3505 !CCS_LIM(sensor, MAX_OP_PIX_CLK_DIV)) { in ccs_probe()
3507 sensor->pll.flags |= CCS_PLL_FLAG_NO_OP_CLOCKS; in ccs_probe()
3508 } else if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_probe()
3510 CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in ccs_probe()
3513 sensor->scaler = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3514 sensor->ssds_used++; in ccs_probe()
3516 sensor->binner = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3517 sensor->ssds_used++; in ccs_probe()
3518 sensor->pixel_array = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3519 sensor->ssds_used++; in ccs_probe()
3521 sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_probe()
3524 sensor->pll.bus_type = CCS_PLL_BUS_TYPE_CSI2_DPHY; in ccs_probe()
3525 sensor->pll.csi2.lanes = sensor->hwcfg.lanes; in ccs_probe()
3526 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3528 sensor->pll.flags |= CCS_PLL_FLAG_LANE_SPEED_MODEL; in ccs_probe()
3529 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3531 sensor->pll.vt_lanes = in ccs_probe()
3532 CCS_LIM(sensor, NUM_OF_VT_LANES) + 1; in ccs_probe()
3533 sensor->pll.op_lanes = in ccs_probe()
3534 CCS_LIM(sensor, NUM_OF_OP_LANES) + 1; in ccs_probe()
3535 sensor->pll.flags |= CCS_PLL_FLAG_LINK_DECOUPLED; in ccs_probe()
3537 sensor->pll.vt_lanes = sensor->pll.csi2.lanes; in ccs_probe()
3538 sensor->pll.op_lanes = sensor->pll.csi2.lanes; in ccs_probe()
3541 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3543 sensor->pll.flags |= CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER; in ccs_probe()
3544 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3546 sensor->pll.flags |= CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV; in ccs_probe()
3547 if (CCS_LIM(sensor, FIFO_SUPPORT_CAPABILITY) & in ccs_probe()
3549 sensor->pll.flags |= CCS_PLL_FLAG_FIFO_DERATING; in ccs_probe()
3550 if (CCS_LIM(sensor, FIFO_SUPPORT_CAPABILITY) & in ccs_probe()
3552 sensor->pll.flags |= CCS_PLL_FLAG_FIFO_DERATING | in ccs_probe()
3554 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3556 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3560 /* Use sensor default in PLL mode selection */ in ccs_probe()
3561 rval = ccs_read(sensor, PLL_MODE, &v); in ccs_probe()
3566 sensor->pll.flags |= CCS_PLL_FLAG_DUAL_PLL; in ccs_probe()
3568 sensor->pll.flags |= CCS_PLL_FLAG_DUAL_PLL; in ccs_probe()
3570 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3572 sensor->pll.flags |= CCS_PLL_FLAG_OP_SYS_DDR; in ccs_probe()
3573 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3575 sensor->pll.flags |= CCS_PLL_FLAG_OP_PIX_DDR; in ccs_probe()
3577 sensor->pll.op_bits_per_lane = CCS_LIM(sensor, OP_BITS_PER_LANE); in ccs_probe()
3578 sensor->pll.ext_clk_freq_hz = sensor->hwcfg.ext_clk; in ccs_probe()
3579 sensor->pll.scale_n = CCS_LIM(sensor, SCALER_N_MIN); in ccs_probe()
3581 ccs_create_subdev(sensor, sensor->scaler, " scaler", 2, in ccs_probe()
3583 ccs_create_subdev(sensor, sensor->binner, " binner", 2, in ccs_probe()
3585 ccs_create_subdev(sensor, sensor->pixel_array, " pixel_array", 1, in ccs_probe()
3588 rval = ccs_init_controls(sensor); in ccs_probe()
3592 rval = ccs_call_quirk(sensor, init); in ccs_probe()
3596 rval = ccs_get_mbus_formats(sensor); in ccs_probe()
3602 rval = ccs_init_late_controls(sensor); in ccs_probe()
3608 mutex_lock(&sensor->mutex); in ccs_probe()
3609 rval = ccs_pll_blanking_update(sensor); in ccs_probe()
3610 mutex_unlock(&sensor->mutex); in ccs_probe()
3616 sensor->streaming = false; in ccs_probe()
3617 sensor->dev_init_done = true; in ccs_probe()
3619 rval = media_entity_pads_init(&sensor->src->sd.entity, 2, in ccs_probe()
3620 sensor->src->pads); in ccs_probe()
3624 rval = ccs_write_msr_regs(sensor); in ccs_probe()
3632 rval = v4l2_async_register_subdev_sensor(&sensor->src->sd); in ccs_probe()
3647 media_entity_cleanup(&sensor->src->sd.entity); in ccs_probe()
3650 ccs_cleanup(sensor); in ccs_probe()
3653 kvfree(sensor->mdata.backing); in ccs_probe()
3656 kvfree(sensor->sdata.backing); in ccs_probe()
3659 kfree(sensor->ccs_limits); in ccs_probe()
3663 mutex_destroy(&sensor->mutex); in ccs_probe()
3671 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_remove() local
3681 for (i = 0; i < sensor->ssds_used; i++) { in ccs_remove()
3682 v4l2_device_unregister_subdev(&sensor->ssds[i].sd); in ccs_remove()
3683 media_entity_cleanup(&sensor->ssds[i].sd.entity); in ccs_remove()
3685 ccs_cleanup(sensor); in ccs_remove()
3686 mutex_destroy(&sensor->mutex); in ccs_remove()
3687 kfree(sensor->ccs_limits); in ccs_remove()
3688 kvfree(sensor->sdata.backing); in ccs_remove()
3689 kvfree(sensor->mdata.backing); in ccs_remove()
3764 MODULE_DESCRIPTION("Generic MIPI CCS/SMIA/SMIA++ camera sensor driver");