Lines Matching full:sensor
13 * Based on smia-sensor.c by Tuukka Toivonen <tuukkat76@gmail.com>
91 static int ccs_limit_ptr(struct ccs_sensor *sensor, unsigned int limit, in ccs_limit_ptr() argument
101 if (WARN_ON(!sensor->ccs_limits) || in ccs_limit_ptr()
106 *__ptr = sensor->ccs_limits + ccs_limit_offsets[limit].lim + offset; in ccs_limit_ptr()
111 void ccs_replace_limit(struct ccs_sensor *sensor, in ccs_replace_limit() argument
114 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_replace_limit()
119 ret = ccs_limit_ptr(sensor, limit, offset, &ptr); in ccs_replace_limit()
131 u32 ccs_get_limit(struct ccs_sensor *sensor, unsigned int limit, in ccs_get_limit() argument
138 ret = ccs_limit_ptr(sensor, limit, offset, &ptr); in ccs_get_limit()
157 return ccs_reg_conv(sensor, ccs_limits[limit].reg, val); in ccs_get_limit()
160 static int ccs_read_all_limits(struct ccs_sensor *sensor) in ccs_read_all_limits() argument
162 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_read_all_limits()
167 kfree(sensor->ccs_limits); in ccs_read_all_limits()
168 sensor->ccs_limits = NULL; in ccs_read_all_limits()
176 sensor->ccs_limits = alloc; in ccs_read_all_limits()
195 ret = ccs_read_addr_noconv(sensor, reg, &val); in ccs_read_all_limits()
214 ccs_reg_conv(sensor, reg, val)); in ccs_read_all_limits()
236 if (CCS_LIM(sensor, SCALER_N_MIN) < 16) in ccs_read_all_limits()
237 ccs_replace_limit(sensor, CCS_L_SCALER_N_MIN, 0, 16); in ccs_read_all_limits()
242 sensor->ccs_limits = NULL; in ccs_read_all_limits()
248 static int ccs_read_frame_fmt(struct ccs_sensor *sensor) in ccs_read_frame_fmt() argument
250 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_read_frame_fmt()
256 fmt_model_type = CCS_LIM(sensor, FRAME_FORMAT_MODEL_TYPE); in ccs_read_frame_fmt()
257 fmt_model_subtype = CCS_LIM(sensor, FRAME_FORMAT_MODEL_SUBTYPE); in ccs_read_frame_fmt()
282 desc = CCS_LIM_AT(sensor, FRAME_FORMAT_DESCRIPTOR, i); in ccs_read_frame_fmt()
291 desc = CCS_LIM_AT(sensor, FRAME_FORMAT_DESCRIPTOR_4, i); in ccs_read_frame_fmt()
339 sensor->visible_pixel_start = pixel_count; in ccs_read_frame_fmt()
347 if (sensor->embedded_end) in ccs_read_frame_fmt()
349 sensor->embedded_start = line_count; in ccs_read_frame_fmt()
350 sensor->embedded_end = line_count + pixels; in ccs_read_frame_fmt()
353 sensor->image_start = line_count; in ccs_read_frame_fmt()
359 if (sensor->embedded_end > sensor->image_start) { in ccs_read_frame_fmt()
362 sensor->embedded_end, sensor->image_start); in ccs_read_frame_fmt()
363 sensor->image_start = sensor->embedded_end; in ccs_read_frame_fmt()
367 sensor->embedded_start, sensor->embedded_end); in ccs_read_frame_fmt()
369 sensor->image_start); in ccs_read_frame_fmt()
374 static int ccs_pll_configure(struct ccs_sensor *sensor) in ccs_pll_configure() argument
376 struct ccs_pll *pll = &sensor->pll; in ccs_pll_configure()
379 rval = ccs_write(sensor, VT_PIX_CLK_DIV, pll->vt_bk.pix_clk_div); in ccs_pll_configure()
383 rval = ccs_write(sensor, VT_SYS_CLK_DIV, pll->vt_bk.sys_clk_div); in ccs_pll_configure()
387 rval = ccs_write(sensor, PRE_PLL_CLK_DIV, pll->vt_fr.pre_pll_clk_div); in ccs_pll_configure()
391 rval = ccs_write(sensor, PLL_MULTIPLIER, pll->vt_fr.pll_multiplier); in ccs_pll_configure()
395 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_pll_configure()
398 rval = ccs_write(sensor, REQUESTED_LINK_RATE, in ccs_pll_configure()
402 sensor->pll.csi2.lanes : 1) << in ccs_pll_configure()
409 if (sensor->pll.flags & CCS_PLL_FLAG_NO_OP_CLOCKS) in ccs_pll_configure()
412 rval = ccs_write(sensor, OP_PIX_CLK_DIV, pll->op_bk.pix_clk_div); in ccs_pll_configure()
416 rval = ccs_write(sensor, OP_SYS_CLK_DIV, pll->op_bk.sys_clk_div); in ccs_pll_configure()
423 rval = ccs_write(sensor, PLL_MODE, CCS_PLL_MODE_DUAL); in ccs_pll_configure()
427 rval = ccs_write(sensor, OP_PRE_PLL_CLK_DIV, in ccs_pll_configure()
432 return ccs_write(sensor, OP_PLL_MULTIPLIER, pll->op_fr.pll_multiplier); in ccs_pll_configure()
435 static int ccs_pll_try(struct ccs_sensor *sensor, struct ccs_pll *pll) in ccs_pll_try() argument
437 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pll_try()
440 .min_pre_pll_clk_div = CCS_LIM(sensor, MIN_PRE_PLL_CLK_DIV), in ccs_pll_try()
441 .max_pre_pll_clk_div = CCS_LIM(sensor, MAX_PRE_PLL_CLK_DIV), in ccs_pll_try()
442 .min_pll_ip_clk_freq_hz = CCS_LIM(sensor, MIN_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
443 .max_pll_ip_clk_freq_hz = CCS_LIM(sensor, MAX_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
444 .min_pll_multiplier = CCS_LIM(sensor, MIN_PLL_MULTIPLIER), in ccs_pll_try()
445 .max_pll_multiplier = CCS_LIM(sensor, MAX_PLL_MULTIPLIER), in ccs_pll_try()
446 .min_pll_op_clk_freq_hz = CCS_LIM(sensor, MIN_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
447 .max_pll_op_clk_freq_hz = CCS_LIM(sensor, MAX_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
450 .min_pre_pll_clk_div = CCS_LIM(sensor, MIN_OP_PRE_PLL_CLK_DIV), in ccs_pll_try()
451 .max_pre_pll_clk_div = CCS_LIM(sensor, MAX_OP_PRE_PLL_CLK_DIV), in ccs_pll_try()
452 .min_pll_ip_clk_freq_hz = CCS_LIM(sensor, MIN_OP_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
453 .max_pll_ip_clk_freq_hz = CCS_LIM(sensor, MAX_OP_PLL_IP_CLK_FREQ_MHZ), in ccs_pll_try()
454 .min_pll_multiplier = CCS_LIM(sensor, MIN_OP_PLL_MULTIPLIER), in ccs_pll_try()
455 .max_pll_multiplier = CCS_LIM(sensor, MAX_OP_PLL_MULTIPLIER), in ccs_pll_try()
456 .min_pll_op_clk_freq_hz = CCS_LIM(sensor, MIN_OP_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
457 .max_pll_op_clk_freq_hz = CCS_LIM(sensor, MAX_OP_PLL_OP_CLK_FREQ_MHZ), in ccs_pll_try()
460 .min_sys_clk_div = CCS_LIM(sensor, MIN_OP_SYS_CLK_DIV), in ccs_pll_try()
461 .max_sys_clk_div = CCS_LIM(sensor, MAX_OP_SYS_CLK_DIV), in ccs_pll_try()
462 .min_pix_clk_div = CCS_LIM(sensor, MIN_OP_PIX_CLK_DIV), in ccs_pll_try()
463 .max_pix_clk_div = CCS_LIM(sensor, MAX_OP_PIX_CLK_DIV), in ccs_pll_try()
464 .min_sys_clk_freq_hz = CCS_LIM(sensor, MIN_OP_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
465 .max_sys_clk_freq_hz = CCS_LIM(sensor, MAX_OP_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
466 .min_pix_clk_freq_hz = CCS_LIM(sensor, MIN_OP_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
467 .max_pix_clk_freq_hz = CCS_LIM(sensor, MAX_OP_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
470 .min_sys_clk_div = CCS_LIM(sensor, MIN_VT_SYS_CLK_DIV), in ccs_pll_try()
471 .max_sys_clk_div = CCS_LIM(sensor, MAX_VT_SYS_CLK_DIV), in ccs_pll_try()
472 .min_pix_clk_div = CCS_LIM(sensor, MIN_VT_PIX_CLK_DIV), in ccs_pll_try()
473 .max_pix_clk_div = CCS_LIM(sensor, MAX_VT_PIX_CLK_DIV), in ccs_pll_try()
474 .min_sys_clk_freq_hz = CCS_LIM(sensor, MIN_VT_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
475 .max_sys_clk_freq_hz = CCS_LIM(sensor, MAX_VT_SYS_CLK_FREQ_MHZ), in ccs_pll_try()
476 .min_pix_clk_freq_hz = CCS_LIM(sensor, MIN_VT_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
477 .max_pix_clk_freq_hz = CCS_LIM(sensor, MAX_VT_PIX_CLK_FREQ_MHZ), in ccs_pll_try()
479 .min_line_length_pck_bin = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN), in ccs_pll_try()
480 .min_line_length_pck = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK), in ccs_pll_try()
486 static int ccs_pll_update(struct ccs_sensor *sensor) in ccs_pll_update() argument
488 struct ccs_pll *pll = &sensor->pll; in ccs_pll_update()
491 pll->binning_horizontal = sensor->binning_horizontal; in ccs_pll_update()
492 pll->binning_vertical = sensor->binning_vertical; in ccs_pll_update()
494 sensor->link_freq->qmenu_int[sensor->link_freq->val]; in ccs_pll_update()
495 pll->scale_m = sensor->scale_m; in ccs_pll_update()
496 pll->bits_per_pixel = sensor->csi_format->compressed; in ccs_pll_update()
498 rval = ccs_pll_try(sensor, pll); in ccs_pll_update()
502 __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_parray, in ccs_pll_update()
504 __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate_csi, pll->pixel_rate_csi); in ccs_pll_update()
516 static void __ccs_update_exposure_limits(struct ccs_sensor *sensor) in __ccs_update_exposure_limits() argument
518 struct v4l2_ctrl *ctrl = sensor->exposure; in __ccs_update_exposure_limits()
521 max = sensor->pa_src.height + sensor->vblank->val - in __ccs_update_exposure_limits()
522 CCS_LIM(sensor, COARSE_INTEGRATION_TIME_MAX_MARGIN); in __ccs_update_exposure_limits()
568 static u32 ccs_pixel_order(struct ccs_sensor *sensor) in ccs_pixel_order() argument
570 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pixel_order()
573 if (sensor->hflip) { in ccs_pixel_order()
574 if (sensor->hflip->val) in ccs_pixel_order()
577 if (sensor->vflip->val) in ccs_pixel_order()
582 return sensor->default_pixel_order ^ flip; in ccs_pixel_order()
585 static void ccs_update_mbus_formats(struct ccs_sensor *sensor) in ccs_update_mbus_formats() argument
587 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_update_mbus_formats()
589 to_csi_format_idx(sensor->csi_format) & ~3; in ccs_update_mbus_formats()
591 to_csi_format_idx(sensor->internal_csi_format) & ~3; in ccs_update_mbus_formats()
592 unsigned int pixel_order = ccs_pixel_order(sensor); in ccs_update_mbus_formats()
598 sensor->mbus_frame_fmts = in ccs_update_mbus_formats()
599 sensor->default_mbus_frame_fmts << pixel_order; in ccs_update_mbus_formats()
600 sensor->csi_format = in ccs_update_mbus_formats()
602 sensor->internal_csi_format = in ccs_update_mbus_formats()
620 struct ccs_sensor *sensor = in ccs_set_ctrl() local
622 ->sensor; in ccs_set_ctrl()
623 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_set_ctrl()
633 if (sensor->streaming) in ccs_set_ctrl()
636 if (sensor->hflip->val) in ccs_set_ctrl()
639 if (sensor->vflip->val) in ccs_set_ctrl()
642 ccs_update_mbus_formats(sensor); in ccs_set_ctrl()
646 exposure = sensor->exposure->val; in ccs_set_ctrl()
648 __ccs_update_exposure_limits(sensor); in ccs_set_ctrl()
650 if (exposure > sensor->exposure->maximum) { in ccs_set_ctrl()
651 sensor->exposure->val = sensor->exposure->maximum; in ccs_set_ctrl()
652 rval = ccs_set_ctrl(sensor->exposure); in ccs_set_ctrl()
659 if (sensor->streaming) in ccs_set_ctrl()
662 rval = ccs_pll_update(sensor); in ccs_set_ctrl()
668 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) in ccs_set_ctrl()
670 sensor->test_data[i], in ccs_set_ctrl()
683 rval = ccs_write(sensor, ANALOG_GAIN_CODE_GLOBAL, ctrl->val); in ccs_set_ctrl()
688 rval = ccs_write(sensor, ANALOG_LINEAR_GAIN_GLOBAL, ctrl->val); in ccs_set_ctrl()
693 rval = ccs_write(sensor, ANALOG_EXPONENTIAL_GAIN_GLOBAL, in ccs_set_ctrl()
699 if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_set_ctrl()
701 rval = ccs_write(sensor, DIGITAL_GAIN_GLOBAL, in ccs_set_ctrl()
706 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
712 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
718 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
724 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
730 rval = ccs_write(sensor, COARSE_INTEGRATION_TIME, ctrl->val); in ccs_set_ctrl()
735 rval = ccs_write(sensor, IMAGE_ORIENTATION, orient); in ccs_set_ctrl()
739 rval = ccs_write(sensor, FRAME_LENGTH_LINES, in ccs_set_ctrl()
740 sensor->pa_src.height + ctrl->val); in ccs_set_ctrl()
744 rval = ccs_write(sensor, LINE_LENGTH_PCK, in ccs_set_ctrl()
745 sensor->pa_src.width + ctrl->val); in ccs_set_ctrl()
749 rval = ccs_write(sensor, TEST_PATTERN_MODE, ctrl->val); in ccs_set_ctrl()
753 rval = ccs_write(sensor, TEST_DATA_RED, ctrl->val); in ccs_set_ctrl()
757 rval = ccs_write(sensor, TEST_DATA_GREENR, ctrl->val); in ccs_set_ctrl()
761 rval = ccs_write(sensor, TEST_DATA_BLUE, ctrl->val); in ccs_set_ctrl()
765 rval = ccs_write(sensor, TEST_DATA_GREENB, ctrl->val); in ccs_set_ctrl()
769 rval = ccs_write(sensor, SHADING_CORRECTION_EN, in ccs_set_ctrl()
773 if (!rval && sensor->luminance_level) in ccs_set_ctrl()
774 v4l2_ctrl_activate(sensor->luminance_level, ctrl->val); in ccs_set_ctrl()
778 rval = ccs_write(sensor, LUMINANCE_CORRECTION_LEVEL, ctrl->val); in ccs_set_ctrl()
802 static int ccs_init_controls(struct ccs_sensor *sensor) in ccs_init_controls() argument
804 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_init_controls()
808 rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 19); in ccs_init_controls()
812 sensor->pixel_array->ctrl_handler.lock = &sensor->mutex; in ccs_init_controls()
818 rval = v4l2_ctrl_new_fwnode_properties(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
823 switch (CCS_LIM(sensor, ANALOG_GAIN_CAPABILITY)) { in ccs_init_controls()
831 CCS_LIM(sensor, ANALOG_GAIN_M0), }, in ccs_init_controls()
833 CCS_LIM(sensor, ANALOG_GAIN_C0), }, in ccs_init_controls()
835 CCS_LIM(sensor, ANALOG_GAIN_M1), }, in ccs_init_controls()
837 CCS_LIM(sensor, ANALOG_GAIN_C1), }, in ccs_init_controls()
853 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
857 v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
859 CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN), in ccs_init_controls()
860 CCS_LIM(sensor, ANALOG_GAIN_CODE_MAX), in ccs_init_controls()
861 max(CCS_LIM(sensor, ANALOG_GAIN_CODE_STEP), in ccs_init_controls()
863 CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN)); in ccs_init_controls()
876 CCS_LIM(sensor, ANALOG_LINEAR_GAIN_MIN), in ccs_init_controls()
877 CCS_LIM(sensor, ANALOG_LINEAR_GAIN_MAX), in ccs_init_controls()
878 max(CCS_LIM(sensor, in ccs_init_controls()
885 CCS_LIM(sensor, ANALOG_EXPONENTIAL_GAIN_MIN), in ccs_init_controls()
886 CCS_LIM(sensor, ANALOG_EXPONENTIAL_GAIN_MAX), in ccs_init_controls()
887 max(CCS_LIM(sensor, in ccs_init_controls()
905 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
911 if (CCS_LIM(sensor, SHADING_CORRECTION_CAPABILITY) & in ccs_init_controls()
923 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
927 if (CCS_LIM(sensor, SHADING_CORRECTION_CAPABILITY) & in ccs_init_controls()
939 sensor->luminance_level = in ccs_init_controls()
940 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
944 if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_init_controls()
946 CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_init_controls()
948 v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
950 CCS_LIM(sensor, DIGITAL_GAIN_MIN), in ccs_init_controls()
951 CCS_LIM(sensor, DIGITAL_GAIN_MAX), in ccs_init_controls()
952 max(CCS_LIM(sensor, DIGITAL_GAIN_STEP_SIZE), in ccs_init_controls()
957 sensor->exposure = v4l2_ctrl_new_std( in ccs_init_controls()
958 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
961 sensor->hflip = v4l2_ctrl_new_std( in ccs_init_controls()
962 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
964 sensor->vflip = v4l2_ctrl_new_std( in ccs_init_controls()
965 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
968 sensor->vblank = v4l2_ctrl_new_std( in ccs_init_controls()
969 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
972 if (sensor->vblank) in ccs_init_controls()
973 sensor->vblank->flags |= V4L2_CTRL_FLAG_UPDATE; in ccs_init_controls()
975 sensor->hblank = v4l2_ctrl_new_std( in ccs_init_controls()
976 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
979 if (sensor->hblank) in ccs_init_controls()
980 sensor->hblank->flags |= V4L2_CTRL_FLAG_UPDATE; in ccs_init_controls()
982 sensor->pixel_rate_parray = v4l2_ctrl_new_std( in ccs_init_controls()
983 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
986 v4l2_ctrl_new_std_menu_items(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
991 if (sensor->pixel_array->ctrl_handler.error) { in ccs_init_controls()
994 sensor->pixel_array->ctrl_handler.error); in ccs_init_controls()
995 return sensor->pixel_array->ctrl_handler.error; in ccs_init_controls()
998 sensor->pixel_array->sd.ctrl_handler = in ccs_init_controls()
999 &sensor->pixel_array->ctrl_handler; in ccs_init_controls()
1001 v4l2_ctrl_cluster(2, &sensor->hflip); in ccs_init_controls()
1003 rval = v4l2_ctrl_handler_init(&sensor->src->ctrl_handler, 0); in ccs_init_controls()
1007 sensor->src->ctrl_handler.lock = &sensor->mutex; in ccs_init_controls()
1009 sensor->pixel_rate_csi = v4l2_ctrl_new_std( in ccs_init_controls()
1010 &sensor->src->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
1013 if (sensor->src->ctrl_handler.error) { in ccs_init_controls()
1016 sensor->src->ctrl_handler.error); in ccs_init_controls()
1017 return sensor->src->ctrl_handler.error; in ccs_init_controls()
1020 sensor->src->sd.ctrl_handler = &sensor->src->ctrl_handler; in ccs_init_controls()
1029 static int ccs_init_late_controls(struct ccs_sensor *sensor) in ccs_init_late_controls() argument
1031 unsigned long *valid_link_freqs = &sensor->valid_link_freqs[ in ccs_init_late_controls()
1032 sensor->csi_format->compressed - sensor->compressed_min_bpp]; in ccs_init_late_controls()
1035 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) { in ccs_init_late_controls()
1036 int max_value = (1 << sensor->csi_format->width) - 1; in ccs_init_late_controls()
1038 sensor->test_data[i] = v4l2_ctrl_new_std( in ccs_init_late_controls()
1039 &sensor->pixel_array->ctrl_handler, in ccs_init_late_controls()
1044 sensor->link_freq = v4l2_ctrl_new_int_menu( in ccs_init_late_controls()
1045 &sensor->src->ctrl_handler, &ccs_ctrl_ops, in ccs_init_late_controls()
1047 __ffs(*valid_link_freqs), sensor->hwcfg.op_sys_clock); in ccs_init_late_controls()
1049 return sensor->src->ctrl_handler.error; in ccs_init_late_controls()
1052 static void ccs_free_controls(struct ccs_sensor *sensor) in ccs_free_controls() argument
1056 for (i = 0; i < sensor->ssds_used; i++) in ccs_free_controls()
1057 v4l2_ctrl_handler_free(&sensor->ssds[i].ctrl_handler); in ccs_free_controls()
1060 static int ccs_get_mbus_formats(struct ccs_sensor *sensor) in ccs_get_mbus_formats() argument
1062 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_get_mbus_formats()
1063 struct ccs_pll *pll = &sensor->pll; in ccs_get_mbus_formats()
1069 type = CCS_LIM(sensor, DATA_FORMAT_MODEL_TYPE); in ccs_get_mbus_formats()
1073 rval = ccs_read(sensor, PIXEL_ORDER, &pixel_order); in ccs_get_mbus_formats()
1096 sensor->default_pixel_order = pixel_order; in ccs_get_mbus_formats()
1097 sensor->mbus_frame_fmts = 0; in ccs_get_mbus_formats()
1102 fmt = CCS_LIM_AT(sensor, DATA_FORMAT_DESCRIPTOR, i); in ccs_get_mbus_formats()
1122 sensor->default_mbus_frame_fmts |= 1 << j; in ccs_get_mbus_formats()
1129 pll->scale_m = sensor->scale_m; in ccs_get_mbus_formats()
1132 sensor->compressed_min_bpp = in ccs_get_mbus_formats()
1134 sensor->compressed_min_bpp); in ccs_get_mbus_formats()
1140 sensor->valid_link_freqs = devm_kcalloc( in ccs_get_mbus_formats()
1142 compressed_max_bpp - sensor->compressed_min_bpp + 1, in ccs_get_mbus_formats()
1143 sizeof(*sensor->valid_link_freqs), GFP_KERNEL); in ccs_get_mbus_formats()
1144 if (!sensor->valid_link_freqs) in ccs_get_mbus_formats()
1151 &sensor->valid_link_freqs[ in ccs_get_mbus_formats()
1152 f->compressed - sensor->compressed_min_bpp]; in ccs_get_mbus_formats()
1155 if (!(sensor->default_mbus_frame_fmts & 1 << i)) in ccs_get_mbus_formats()
1160 for (j = 0; sensor->hwcfg.op_sys_clock[j]; j++) { in ccs_get_mbus_formats()
1161 pll->link_freq = sensor->hwcfg.op_sys_clock[j]; in ccs_get_mbus_formats()
1163 rval = ccs_pll_try(sensor, pll); in ccs_get_mbus_formats()
1177 sensor->default_mbus_frame_fmts &= ~BIT(i); in ccs_get_mbus_formats()
1181 if (!sensor->csi_format in ccs_get_mbus_formats()
1182 || f->width > sensor->csi_format->width in ccs_get_mbus_formats()
1183 || (f->width == sensor->csi_format->width in ccs_get_mbus_formats()
1184 && f->compressed > sensor->csi_format->compressed)) { in ccs_get_mbus_formats()
1185 sensor->csi_format = f; in ccs_get_mbus_formats()
1186 sensor->internal_csi_format = f; in ccs_get_mbus_formats()
1190 if (!sensor->csi_format) { in ccs_get_mbus_formats()
1195 ccs_update_mbus_formats(sensor); in ccs_get_mbus_formats()
1200 static void ccs_update_blanking(struct ccs_sensor *sensor) in ccs_update_blanking() argument
1202 struct v4l2_ctrl *vblank = sensor->vblank; in ccs_update_blanking()
1203 struct v4l2_ctrl *hblank = sensor->hblank; in ccs_update_blanking()
1207 if (sensor->binning_vertical > 1 || sensor->binning_horizontal > 1) { in ccs_update_blanking()
1208 min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES_BIN); in ccs_update_blanking()
1209 max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES_BIN); in ccs_update_blanking()
1210 min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN); in ccs_update_blanking()
1211 max_llp = CCS_LIM(sensor, MAX_LINE_LENGTH_PCK_BIN); in ccs_update_blanking()
1212 min_lbp = CCS_LIM(sensor, MIN_LINE_BLANKING_PCK_BIN); in ccs_update_blanking()
1214 min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES); in ccs_update_blanking()
1215 max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES); in ccs_update_blanking()
1216 min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK); in ccs_update_blanking()
1217 max_llp = CCS_LIM(sensor, MAX_LINE_LENGTH_PCK); in ccs_update_blanking()
1218 min_lbp = CCS_LIM(sensor, MIN_LINE_BLANKING_PCK); in ccs_update_blanking()
1222 CCS_LIM(sensor, MIN_FRAME_BLANKING_LINES), in ccs_update_blanking()
1223 min_fll - sensor->pa_src.height); in ccs_update_blanking()
1224 max = max_fll - sensor->pa_src.height; in ccs_update_blanking()
1228 min = max_t(int, min_llp - sensor->pa_src.width, min_lbp); in ccs_update_blanking()
1229 max = max_llp - sensor->pa_src.width; in ccs_update_blanking()
1233 __ccs_update_exposure_limits(sensor); in ccs_update_blanking()
1236 static int ccs_pll_blanking_update(struct ccs_sensor *sensor) in ccs_pll_blanking_update() argument
1238 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pll_blanking_update()
1241 rval = ccs_pll_update(sensor); in ccs_pll_blanking_update()
1246 ccs_update_blanking(sensor); in ccs_pll_blanking_update()
1248 dev_dbg(&client->dev, "vblank\t\t%d\n", sensor->vblank->val); in ccs_pll_blanking_update()
1249 dev_dbg(&client->dev, "hblank\t\t%d\n", sensor->hblank->val); in ccs_pll_blanking_update()
1252 sensor->pll.pixel_rate_pixel_array / in ccs_pll_blanking_update()
1253 ((sensor->pa_src.width + sensor->hblank->val) * in ccs_pll_blanking_update()
1254 (sensor->pa_src.height + sensor->vblank->val) / 100)); in ccs_pll_blanking_update()
1265 static int ccs_read_nvm_page(struct ccs_sensor *sensor, u32 p, u8 *nvm, in ccs_read_nvm_page() argument
1274 rval = ccs_write(sensor, DATA_TRANSFER_IF_1_PAGE_SELECT, p); in ccs_read_nvm_page()
1278 rval = ccs_write(sensor, DATA_TRANSFER_IF_1_CTRL, in ccs_read_nvm_page()
1283 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_STATUS, &s); in ccs_read_nvm_page()
1292 if (CCS_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & in ccs_read_nvm_page()
1298 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_STATUS, &s); in ccs_read_nvm_page()
1310 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_DATA(i), &v); in ccs_read_nvm_page()
1320 static int ccs_read_nvm(struct ccs_sensor *sensor, unsigned char *nvm, in ccs_read_nvm() argument
1329 rval = ccs_read_nvm_page(sensor, p, nvm, &status); in ccs_read_nvm()
1337 rval2 = ccs_write(sensor, DATA_TRANSFER_IF_1_CTRL, 0); in ccs_read_nvm()
1349 static int ccs_change_cci_addr(struct ccs_sensor *sensor) in ccs_change_cci_addr() argument
1351 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_change_cci_addr()
1355 client->addr = sensor->hwcfg.i2c_addr_dfl; in ccs_change_cci_addr()
1357 rval = ccs_write(sensor, CCI_ADDRESS_CTRL, in ccs_change_cci_addr()
1358 sensor->hwcfg.i2c_addr_alt << 1); in ccs_change_cci_addr()
1362 client->addr = sensor->hwcfg.i2c_addr_alt; in ccs_change_cci_addr()
1365 rval = ccs_read(sensor, CCI_ADDRESS_CTRL, &val); in ccs_change_cci_addr()
1369 if (val != sensor->hwcfg.i2c_addr_alt << 1) in ccs_change_cci_addr()
1380 static int ccs_setup_flash_strobe(struct ccs_sensor *sensor) in ccs_setup_flash_strobe() argument
1383 unsigned int ext_freq = sensor->hwcfg.ext_clk; in ccs_setup_flash_strobe()
1389 strobe_setup = sensor->hwcfg.strobe_setup; in ccs_setup_flash_strobe()
1471 rval = ccs_write(sensor, FLASH_MODE_RS, strobe_setup->mode); in ccs_setup_flash_strobe()
1475 rval = ccs_write(sensor, FLASH_STROBE_ADJUSTMENT, strobe_adjustment); in ccs_setup_flash_strobe()
1479 rval = ccs_write(sensor, TFLASH_STROBE_WIDTH_HIGH_RS_CTRL, in ccs_setup_flash_strobe()
1484 rval = ccs_write(sensor, TFLASH_STROBE_DELAY_RS_CTRL, in ccs_setup_flash_strobe()
1489 rval = ccs_write(sensor, FLASH_STROBE_START_POINT, in ccs_setup_flash_strobe()
1494 rval = ccs_write(sensor, FLASH_TRIGGER_RS, strobe_setup->trigger); in ccs_setup_flash_strobe()
1497 sensor->hwcfg.strobe_setup->trigger = 0; in ccs_setup_flash_strobe()
1506 static int ccs_write_msr_regs(struct ccs_sensor *sensor) in ccs_write_msr_regs() argument
1510 rval = ccs_write_data_regs(sensor, in ccs_write_msr_regs()
1511 sensor->sdata.sensor_manufacturer_regs, in ccs_write_msr_regs()
1512 sensor->sdata.num_sensor_manufacturer_regs); in ccs_write_msr_regs()
1516 return ccs_write_data_regs(sensor, in ccs_write_msr_regs()
1517 sensor->mdata.module_manufacturer_regs, in ccs_write_msr_regs()
1518 sensor->mdata.num_module_manufacturer_regs); in ccs_write_msr_regs()
1521 static int ccs_update_phy_ctrl(struct ccs_sensor *sensor) in ccs_update_phy_ctrl() argument
1523 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_update_phy_ctrl()
1526 if (!sensor->ccs_limits) in ccs_update_phy_ctrl()
1529 if (CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_update_phy_ctrl()
1532 } else if (CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_update_phy_ctrl()
1540 return ccs_write(sensor, PHY_CTRL, val); in ccs_update_phy_ctrl()
1551 struct ccs_sensor *sensor = in ccs_power_on() local
1557 sensor->regulators); in ccs_power_on()
1563 if (sensor->reset || sensor->xshutdown || sensor->ext_clk) { in ccs_power_on()
1566 rval = clk_prepare_enable(sensor->ext_clk); in ccs_power_on()
1572 gpiod_set_value(sensor->reset, 0); in ccs_power_on()
1573 gpiod_set_value(sensor->xshutdown, 1); in ccs_power_on()
1576 sleep = SMIAPP_RESET_DELAY(sensor->hwcfg.ext_clk); in ccs_power_on()
1585 * Those failures seem to be caused by the sensor requiring a longer in ccs_power_on()
1594 if (!sensor->reset && !sensor->xshutdown) { in ccs_power_on()
1598 rval = ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); in ccs_power_on()
1605 rval = ccs_read(sensor, SOFTWARE_RESET, &reset); in ccs_power_on()
1620 if (sensor->hwcfg.i2c_addr_alt) { in ccs_power_on()
1621 rval = ccs_change_cci_addr(sensor); in ccs_power_on()
1628 rval = ccs_write(sensor, COMPRESSION_MODE, in ccs_power_on()
1635 rval = ccs_write(sensor, EXTCLK_FREQUENCY_MHZ, in ccs_power_on()
1636 sensor->hwcfg.ext_clk / (1000000 / (1 << 8))); in ccs_power_on()
1642 rval = ccs_write(sensor, CSI_LANE_MODE, sensor->hwcfg.lanes - 1); in ccs_power_on()
1648 rval = ccs_write(sensor, FAST_STANDBY_CTRL, in ccs_power_on()
1655 rval = ccs_write(sensor, CSI_SIGNALING_MODE, in ccs_power_on()
1656 sensor->hwcfg.csi_signalling_mode); in ccs_power_on()
1662 rval = ccs_update_phy_ctrl(sensor); in ccs_power_on()
1666 rval = ccs_write_msr_regs(sensor); in ccs_power_on()
1670 rval = ccs_call_quirk(sensor, post_poweron); in ccs_power_on()
1679 gpiod_set_value(sensor->reset, 1); in ccs_power_on()
1680 gpiod_set_value(sensor->xshutdown, 0); in ccs_power_on()
1681 clk_disable_unprepare(sensor->ext_clk); in ccs_power_on()
1685 sensor->regulators); in ccs_power_on()
1694 struct ccs_sensor *sensor = in ccs_power_off() local
1699 * but they are essentially the same signals. So if the sensor is in ccs_power_off()
1700 * powered off while the lens is powered on the sensor does not in ccs_power_off()
1704 if (sensor->hwcfg.i2c_addr_alt) in ccs_power_off()
1705 ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); in ccs_power_off()
1707 gpiod_set_value(sensor->reset, 1); in ccs_power_off()
1708 gpiod_set_value(sensor->xshutdown, 0); in ccs_power_off()
1709 clk_disable_unprepare(sensor->ext_clk); in ccs_power_off()
1712 sensor->regulators); in ccs_power_off()
1713 sensor->streaming = false; in ccs_power_off()
1722 static int ccs_start_streaming(struct ccs_sensor *sensor) in ccs_start_streaming() argument
1724 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_start_streaming()
1728 mutex_lock(&sensor->mutex); in ccs_start_streaming()
1730 rval = ccs_write(sensor, CSI_DATA_FORMAT, in ccs_start_streaming()
1731 (sensor->csi_format->width << 8) | in ccs_start_streaming()
1732 sensor->csi_format->compressed); in ccs_start_streaming()
1737 if (sensor->binning_horizontal == 1 && in ccs_start_streaming()
1738 sensor->binning_vertical == 1) { in ccs_start_streaming()
1742 (sensor->binning_horizontal << 4) in ccs_start_streaming()
1743 | sensor->binning_vertical; in ccs_start_streaming()
1745 rval = ccs_write(sensor, BINNING_TYPE, binning_type); in ccs_start_streaming()
1751 rval = ccs_write(sensor, BINNING_MODE, binning_mode); in ccs_start_streaming()
1756 rval = ccs_pll_configure(sensor); in ccs_start_streaming()
1761 rval = ccs_write(sensor, X_ADDR_START, sensor->pa_src.left); in ccs_start_streaming()
1765 rval = ccs_write(sensor, Y_ADDR_START, sensor->pa_src.top); in ccs_start_streaming()
1770 rval = ccs_write(sensor, X_ADDR_END, in ccs_start_streaming()
1771 sensor->pa_src.left + sensor->pa_src.width - 1); in ccs_start_streaming()
1775 rval = ccs_write(sensor, Y_ADDR_END, in ccs_start_streaming()
1776 sensor->pa_src.top + sensor->pa_src.height - 1); in ccs_start_streaming()
1786 if (CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in ccs_start_streaming()
1788 rval = ccs_write(sensor, DIGITAL_CROP_X_OFFSET, in ccs_start_streaming()
1789 sensor->scaler_sink.left); in ccs_start_streaming()
1793 rval = ccs_write(sensor, DIGITAL_CROP_Y_OFFSET, in ccs_start_streaming()
1794 sensor->scaler_sink.top); in ccs_start_streaming()
1798 rval = ccs_write(sensor, DIGITAL_CROP_IMAGE_WIDTH, in ccs_start_streaming()
1799 sensor->scaler_sink.width); in ccs_start_streaming()
1803 rval = ccs_write(sensor, DIGITAL_CROP_IMAGE_HEIGHT, in ccs_start_streaming()
1804 sensor->scaler_sink.height); in ccs_start_streaming()
1810 if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_start_streaming()
1812 rval = ccs_write(sensor, SCALING_MODE, sensor->scaling_mode); in ccs_start_streaming()
1816 rval = ccs_write(sensor, SCALE_M, sensor->scale_m); in ccs_start_streaming()
1821 /* Output size from sensor */ in ccs_start_streaming()
1822 rval = ccs_write(sensor, X_OUTPUT_SIZE, sensor->src_src.width); in ccs_start_streaming()
1825 rval = ccs_write(sensor, Y_OUTPUT_SIZE, sensor->src_src.height); in ccs_start_streaming()
1829 if (CCS_LIM(sensor, FLASH_MODE_CAPABILITY) & in ccs_start_streaming()
1832 sensor->hwcfg.strobe_setup != NULL && in ccs_start_streaming()
1833 sensor->hwcfg.strobe_setup->trigger != 0) { in ccs_start_streaming()
1834 rval = ccs_setup_flash_strobe(sensor); in ccs_start_streaming()
1839 rval = ccs_call_quirk(sensor, pre_streamon); in ccs_start_streaming()
1845 rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_STREAMING); in ccs_start_streaming()
1848 mutex_unlock(&sensor->mutex); in ccs_start_streaming()
1853 static int ccs_stop_streaming(struct ccs_sensor *sensor) in ccs_stop_streaming() argument
1855 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_stop_streaming()
1858 mutex_lock(&sensor->mutex); in ccs_stop_streaming()
1859 rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_SOFTWARE_STANDBY); in ccs_stop_streaming()
1863 rval = ccs_call_quirk(sensor, post_streamoff); in ccs_stop_streaming()
1868 mutex_unlock(&sensor->mutex); in ccs_stop_streaming()
1876 static int ccs_pm_get_init(struct ccs_sensor *sensor) in ccs_pm_get_init() argument
1878 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pm_get_init()
1891 if (rval == 1 && !sensor->handler_setup_needed) in ccs_pm_get_init()
1894 sensor->handler_setup_needed = false; in ccs_pm_get_init()
1897 rval = v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler); in ccs_pm_get_init()
1901 rval = v4l2_ctrl_handler_setup(&sensor->src->ctrl_handler); in ccs_pm_get_init()
1914 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_stream() local
1915 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_set_stream()
1919 ccs_stop_streaming(sensor); in ccs_set_stream()
1920 sensor->streaming = false; in ccs_set_stream()
1927 rval = ccs_pm_get_init(sensor); in ccs_set_stream()
1931 sensor->streaming = true; in ccs_set_stream()
1933 rval = ccs_start_streaming(sensor); in ccs_set_stream()
1935 sensor->streaming = false; in ccs_set_stream()
1945 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_pre_streamon() local
1946 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pre_streamon()
1950 switch (sensor->hwcfg.csi_signalling_mode) { in ccs_pre_streamon()
1952 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) & in ccs_pre_streamon()
1957 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) & in ccs_pre_streamon()
1966 rval = ccs_pm_get_init(sensor); in ccs_pre_streamon()
1971 rval = ccs_write(sensor, MANUAL_LP_CTRL, in ccs_pre_streamon()
1982 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_post_streamoff() local
1983 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_post_streamoff()
1993 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_enum_mbus_code() local
1998 mutex_lock(&sensor->mutex); in ccs_enum_mbus_code()
2003 if (subdev != &sensor->src->sd || code->pad != CCS_PAD_SRC) { in ccs_enum_mbus_code()
2007 code->code = sensor->internal_csi_format->code; in ccs_enum_mbus_code()
2013 if (sensor->mbus_frame_fmts & (1 << i)) in ccs_enum_mbus_code()
2026 mutex_unlock(&sensor->mutex); in ccs_enum_mbus_code()
2033 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in __ccs_get_mbus_code() local
2035 if (subdev == &sensor->src->sd && pad == CCS_PAD_SRC) in __ccs_get_mbus_code()
2036 return sensor->csi_format->code; in __ccs_get_mbus_code()
2038 return sensor->internal_csi_format->code; in __ccs_get_mbus_code()
2055 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_format() local
2058 mutex_lock(&sensor->mutex); in ccs_get_format()
2060 mutex_unlock(&sensor->mutex); in ccs_get_format()
2087 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_propagate() local
2099 if (ssd == sensor->scaler) { in ccs_propagate()
2100 sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_propagate()
2101 sensor->scaling_mode = in ccs_propagate()
2103 sensor->scaler_sink = *comp; in ccs_propagate()
2104 } else if (ssd == sensor->binner) { in ccs_propagate()
2105 sensor->binning_horizontal = 1; in ccs_propagate()
2106 sensor->binning_vertical = 1; in ccs_propagate()
2115 if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src) in ccs_propagate()
2116 sensor->src_src = *crops[CCS_PAD_SRC]; in ccs_propagate()
2124 *ccs_validate_csi_data_format(struct ccs_sensor *sensor, u32 code) in ccs_validate_csi_data_format() argument
2129 if (sensor->mbus_frame_fmts & (1 << i) && in ccs_validate_csi_data_format()
2134 return sensor->csi_format; in ccs_validate_csi_data_format()
2141 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_format_source() local
2143 *old_csi_format = sensor->csi_format; in ccs_set_format_source()
2157 if (subdev != &sensor->src->sd) in ccs_set_format_source()
2160 csi_format = ccs_validate_csi_data_format(sensor, code); in ccs_set_format_source()
2167 sensor->csi_format = csi_format; in ccs_set_format_source()
2170 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) in ccs_set_format_source()
2172 sensor->test_data[i], 0, in ccs_set_format_source()
2179 &sensor->valid_link_freqs[sensor->csi_format->compressed in ccs_set_format_source()
2180 - sensor->compressed_min_bpp]; in ccs_set_format_source()
2183 sensor->link_freq, 0, in ccs_set_format_source()
2187 return ccs_pll_update(sensor); in ccs_set_format_source()
2194 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_format() local
2198 mutex_lock(&sensor->mutex); in ccs_set_format()
2205 mutex_unlock(&sensor->mutex); in ccs_set_format()
2218 CCS_LIM(sensor, MIN_X_OUTPUT_SIZE), in ccs_set_format()
2219 CCS_LIM(sensor, MAX_X_OUTPUT_SIZE)); in ccs_set_format()
2222 CCS_LIM(sensor, MIN_Y_OUTPUT_SIZE), in ccs_set_format()
2223 CCS_LIM(sensor, MAX_Y_OUTPUT_SIZE)); in ccs_set_format()
2233 mutex_unlock(&sensor->mutex); in ccs_set_format()
2247 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in scaling_goodness() local
2273 if (w < CCS_LIM(sensor, MIN_X_OUTPUT_SIZE)) in scaling_goodness()
2288 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose_binner() local
2296 for (i = 0; i < sensor->nbinning_subtypes; i++) { in ccs_set_compose_binner()
2300 / sensor->binning_subtypes[i].horizontal, in ccs_set_compose_binner()
2303 / sensor->binning_subtypes[i].vertical, in ccs_set_compose_binner()
2307 binh = sensor->binning_subtypes[i].horizontal; in ccs_set_compose_binner()
2308 binv = sensor->binning_subtypes[i].vertical; in ccs_set_compose_binner()
2313 sensor->binning_vertical = binv; in ccs_set_compose_binner()
2314 sensor->binning_horizontal = binh; in ccs_set_compose_binner()
2337 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose_scaler() local
2339 u32 scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_set_compose_scaler()
2352 * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.width; in ccs_set_compose_scaler()
2354 * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height; in ccs_set_compose_scaler()
2356 * CCS_LIM(sensor, SCALER_N_MIN) in ccs_set_compose_scaler()
2357 / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE); in ccs_set_compose_scaler()
2359 a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2360 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2361 b = clamp(b, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2362 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2363 max_m = clamp(max_m, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2364 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2390 / try[i] * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2404 if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_set_compose_scaler()
2411 * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2415 * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2429 * CCS_LIM(sensor, SCALER_N_MIN)) & ~1; in ccs_set_compose_scaler()
2434 * CCS_LIM(sensor, SCALER_N_MIN)) in ccs_set_compose_scaler()
2440 sensor->scale_m = scale_m; in ccs_set_compose_scaler()
2441 sensor->scaling_mode = mode; in ccs_set_compose_scaler()
2449 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose() local
2458 if (ssd == sensor->binner) in ccs_set_compose()
2467 return ccs_pll_blanking_update(sensor); in ccs_set_compose()
2475 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_sel_supported() local
2482 if (ssd == sensor->pixel_array && sel->pad == CCS_PA_PAD_SRC) in ccs_sel_supported()
2484 if (ssd == sensor->src && sel->pad == CCS_PAD_SRC) in ccs_sel_supported()
2486 if (ssd == sensor->scaler && sel->pad == CCS_PAD_SINK && in ccs_sel_supported()
2487 CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in ccs_sel_supported()
2492 if (ssd == sensor->pixel_array && sel->pad == CCS_PA_PAD_SRC) in ccs_sel_supported()
2499 if (ssd == sensor->binner) in ccs_sel_supported()
2501 if (ssd == sensor->scaler && CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_sel_supported()
2514 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_crop() local
2530 if (ssd == sensor->src && sel->pad == CCS_PAD_SRC) { in ccs_set_crop()
2543 if (ssd != sensor->pixel_array && sel->pad == CCS_PAD_SINK) in ccs_set_crop()
2546 ssd == sensor->pixel_array) in ccs_set_crop()
2547 sensor->pa_src = sel->r; in ccs_set_crop()
2556 r->width = CCS_LIM(ssd->sensor, X_ADDR_MAX) + 1; in ccs_get_native_size()
2557 r->height = CCS_LIM(ssd->sensor, Y_ADDR_MAX) + 1; in ccs_get_native_size()
2564 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_selection() local
2578 if (ssd == sensor->pixel_array) { in ccs_get_selection()
2607 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_selection() local
2614 mutex_lock(&sensor->mutex); in ccs_set_selection()
2621 sel->r.width = max_t(unsigned int, CCS_LIM(sensor, MIN_X_OUTPUT_SIZE), in ccs_set_selection()
2623 sel->r.height = max_t(unsigned int, CCS_LIM(sensor, MIN_Y_OUTPUT_SIZE), in ccs_set_selection()
2637 mutex_unlock(&sensor->mutex); in ccs_set_selection()
2643 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_skip_frames() local
2645 *frames = sensor->frame_skip; in ccs_get_skip_frames()
2651 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_skip_top_lines() local
2653 *lines = sensor->image_start; in ccs_get_skip_top_lines()
2667 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in nvm_show() local
2670 if (!sensor->dev_init_done) in nvm_show()
2673 rval = ccs_pm_get_init(sensor); in nvm_show()
2677 rval = ccs_read_nvm(sensor, buf, PAGE_SIZE); in nvm_show()
2699 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ident_show() local
2700 struct ccs_module_info *minfo = &sensor->minfo; in ident_show()
2717 static int ccs_identify_module(struct ccs_sensor *sensor) in ccs_identify_module() argument
2719 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_identify_module()
2720 struct ccs_module_info *minfo = &sensor->minfo; in ccs_identify_module()
2726 rval = ccs_read(sensor, MODULE_MANUFACTURER_ID, in ccs_identify_module()
2729 rval = ccs_read_addr(sensor, SMIAPP_REG_U8_MANUFACTURER_ID, in ccs_identify_module()
2732 rval = ccs_read(sensor, MODULE_MODEL_ID, &minfo->model_id); in ccs_identify_module()
2734 rval = ccs_read(sensor, MODULE_REVISION_NUMBER_MAJOR, &rev); in ccs_identify_module()
2736 rval = ccs_read(sensor, MODULE_REVISION_NUMBER_MINOR, in ccs_identify_module()
2741 rval = ccs_read(sensor, MODULE_DATE_YEAR, &minfo->module_year); in ccs_identify_module()
2743 rval = ccs_read(sensor, MODULE_DATE_MONTH, in ccs_identify_module()
2746 rval = ccs_read(sensor, MODULE_DATE_DAY, &minfo->module_day); in ccs_identify_module()
2748 /* Sensor info */ in ccs_identify_module()
2750 rval = ccs_read(sensor, SENSOR_MANUFACTURER_ID, in ccs_identify_module()
2753 rval = ccs_read(sensor, SENSOR_MANUFACTURER_ID, in ccs_identify_module()
2756 rval = ccs_read(sensor, SENSOR_MODEL_ID, in ccs_identify_module()
2759 rval = ccs_read(sensor, SENSOR_REVISION_NUMBER, in ccs_identify_module()
2762 rval = ccs_read(sensor, SENSOR_REVISION_NUMBER_16, in ccs_identify_module()
2765 rval = ccs_read(sensor, SENSOR_FIRMWARE_VERSION, in ccs_identify_module()
2770 rval = ccs_read(sensor, MIPI_CCS_VERSION, &minfo->ccs_version); in ccs_identify_module()
2772 rval = ccs_read_addr(sensor, SMIAPP_REG_U8_SMIA_VERSION, in ccs_identify_module()
2775 rval = ccs_read_addr(sensor, SMIAPP_REG_U8_SMIAPP_VERSION, in ccs_identify_module()
2779 dev_err(&client->dev, "sensor detection failed\n"); in ccs_identify_module()
2796 dev_dbg(&client->dev, "MIPI CCS sensor 0x%4.4x-0x%4.4x\n", in ccs_identify_module()
2800 dev_dbg(&client->dev, "SMIA sensor 0x%2.2x-0x%4.4x\n", in ccs_identify_module()
2805 "sensor revision 0x%4.4x firmware version 0x%2.2x\n", in ccs_identify_module()
2822 * parameters whereas the rvalues are sensor parameters. in ccs_identify_module()
2864 dev_dbg(&client->dev, "the sensor is called %s\n", minfo->name); in ccs_identify_module()
2872 static int ccs_register_subdev(struct ccs_sensor *sensor, in ccs_register_subdev() argument
2877 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_register_subdev()
2883 rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, &ssd->sd); in ccs_register_subdev()
2903 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_unregistered() local
2906 for (i = 1; i < sensor->ssds_used; i++) in ccs_unregistered()
2907 v4l2_device_unregister_subdev(&sensor->ssds[i].sd); in ccs_unregistered()
2912 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_registered() local
2915 if (sensor->scaler) { in ccs_registered()
2916 rval = ccs_register_subdev(sensor, sensor->binner, in ccs_registered()
2917 sensor->scaler, in ccs_registered()
2925 rval = ccs_register_subdev(sensor, sensor->pixel_array, sensor->binner, in ccs_registered()
2940 static void ccs_cleanup(struct ccs_sensor *sensor) in ccs_cleanup() argument
2942 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_cleanup()
2945 for (i = 0; i < sensor->ssds_used; i++) { in ccs_cleanup()
2946 v4l2_subdev_cleanup(&sensor->ssds[2].sd); in ccs_cleanup()
2947 media_entity_cleanup(&sensor->ssds[i].sd.entity); in ccs_cleanup()
2953 ccs_free_controls(sensor); in ccs_cleanup()
2956 static int ccs_init_subdev(struct ccs_sensor *sensor, in ccs_init_subdev() argument
2962 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_init_subdev()
2968 if (ssd != sensor->src) in ccs_init_subdev()
2973 ssd->sensor = sensor; in ccs_init_subdev()
2978 v4l2_i2c_subdev_set_name(&ssd->sd, client, sensor->minfo.name, name); in ccs_init_subdev()
2981 if (ssd != sensor->pixel_array) in ccs_init_subdev()
2986 if (ssd != sensor->src) { in ccs_init_subdev()
3011 struct ccs_sensor *sensor = ssd->sensor; in ccs_init_state() local
3012 unsigned int pad = ssd == sensor->pixel_array ? in ccs_init_state()
3020 mutex_lock(&sensor->mutex); in ccs_init_state()
3026 fmt->code = sensor->internal_csi_format->code; in ccs_init_state()
3029 if (ssd == sensor->pixel_array) { in ccs_init_state()
3031 sensor->pa_src = *crop; in ccs_init_state()
3033 mutex_unlock(&sensor->mutex); in ccs_init_state()
3038 fmt->code = ssd == sensor->src ? in ccs_init_state()
3039 sensor->csi_format->code : sensor->internal_csi_format->code; in ccs_init_state()
3044 mutex_unlock(&sensor->mutex); in ccs_init_state()
3071 .sensor = &ccs_sensor_ops,
3088 static int ccs_get_hwconfig(struct ccs_sensor *sensor, struct device *dev) in ccs_get_hwconfig() argument
3090 struct ccs_hwconfig *hwcfg = &sensor->hwcfg; in ccs_get_hwconfig()
3172 struct ccs_sensor *sensor, char *filename, in ccs_firmware_name() argument
3177 bool is_smiapp = sensor->minfo.smiapp_version; in ccs_firmware_name()
3183 * Old SMIA is module-agnostic. Its sensor identification is based on in ccs_firmware_name()
3188 sensor->minfo.mipi_manufacturer_id : in ccs_firmware_name()
3189 sensor->minfo.smia_manufacturer_id; in ccs_firmware_name()
3190 model_id = sensor->minfo.model_id; in ccs_firmware_name()
3191 revision_number = sensor->minfo.revision_number; in ccs_firmware_name()
3194 sensor->minfo.sensor_mipi_manufacturer_id : in ccs_firmware_name()
3195 sensor->minfo.sensor_smia_manufacturer_id; in ccs_firmware_name()
3196 model_id = sensor->minfo.sensor_model_id; in ccs_firmware_name()
3197 revision_number = sensor->minfo.sensor_revision_number; in ccs_firmware_name()
3204 "module" : "sensor", in ccs_firmware_name()
3214 struct ccs_sensor *sensor; in ccs_probe() local
3220 sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); in ccs_probe()
3221 if (sensor == NULL) in ccs_probe()
3224 rval = ccs_get_hwconfig(sensor, &client->dev); in ccs_probe()
3228 sensor->src = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3230 v4l2_i2c_subdev_init(&sensor->src->sd, client, &ccs_ops); in ccs_probe()
3231 sensor->src->sd.internal_ops = &ccs_internal_src_ops; in ccs_probe()
3233 sensor->regulators = devm_kcalloc(&client->dev, in ccs_probe()
3235 sizeof(*sensor->regulators), in ccs_probe()
3237 if (!sensor->regulators) in ccs_probe()
3241 sensor->regulators[i].supply = ccs_regulators[i]; in ccs_probe()
3244 sensor->regulators); in ccs_probe()
3250 sensor->ext_clk = devm_clk_get(&client->dev, NULL); in ccs_probe()
3251 if (PTR_ERR(sensor->ext_clk) == -ENOENT) { in ccs_probe()
3253 sensor->ext_clk = NULL; in ccs_probe()
3254 } else if (IS_ERR(sensor->ext_clk)) { in ccs_probe()
3256 PTR_ERR(sensor->ext_clk)); in ccs_probe()
3260 if (sensor->ext_clk) { in ccs_probe()
3261 if (sensor->hwcfg.ext_clk) { in ccs_probe()
3264 rval = clk_set_rate(sensor->ext_clk, in ccs_probe()
3265 sensor->hwcfg.ext_clk); in ccs_probe()
3269 sensor->hwcfg.ext_clk); in ccs_probe()
3273 rate = clk_get_rate(sensor->ext_clk); in ccs_probe()
3274 if (rate != sensor->hwcfg.ext_clk) { in ccs_probe()
3277 sensor->hwcfg.ext_clk, rate); in ccs_probe()
3281 sensor->hwcfg.ext_clk = clk_get_rate(sensor->ext_clk); in ccs_probe()
3283 sensor->hwcfg.ext_clk); in ccs_probe()
3285 } else if (sensor->hwcfg.ext_clk) { in ccs_probe()
3287 sensor->hwcfg.ext_clk); in ccs_probe()
3293 if (!sensor->hwcfg.ext_clk) { in ccs_probe()
3298 sensor->reset = devm_gpiod_get_optional(&client->dev, "reset", in ccs_probe()
3300 if (IS_ERR(sensor->reset)) in ccs_probe()
3301 return PTR_ERR(sensor->reset); in ccs_probe()
3303 if (!sensor->reset) in ccs_probe()
3304 sensor->xshutdown = devm_gpiod_get_optional(&client->dev, in ccs_probe()
3307 if (IS_ERR(sensor->xshutdown)) in ccs_probe()
3308 return PTR_ERR(sensor->xshutdown); in ccs_probe()
3310 sensor->regmap = devm_cci_regmap_init_i2c(client, 16); in ccs_probe()
3311 if (IS_ERR(sensor->regmap)) { in ccs_probe()
3313 PTR_ERR(sensor->regmap)); in ccs_probe()
3314 return PTR_ERR(sensor->regmap); in ccs_probe()
3321 mutex_init(&sensor->mutex); in ccs_probe()
3323 rval = ccs_identify_module(sensor); in ccs_probe()
3329 rval = ccs_firmware_name(client, sensor, filename, sizeof(filename), in ccs_probe()
3338 ccs_data_parse(&sensor->sdata, fw->data, fw->size, &client->dev, in ccs_probe()
3344 sensor->minfo.smiapp_version) { in ccs_probe()
3345 rval = ccs_firmware_name(client, sensor, filename, in ccs_probe()
3354 ccs_data_parse(&sensor->mdata, fw->data, fw->size, in ccs_probe()
3360 rval = ccs_read_all_limits(sensor); in ccs_probe()
3364 rval = ccs_read_frame_fmt(sensor); in ccs_probe()
3370 rval = ccs_update_phy_ctrl(sensor); in ccs_probe()
3374 rval = ccs_call_quirk(sensor, limits); in ccs_probe()
3380 if (CCS_LIM(sensor, BINNING_CAPABILITY)) { in ccs_probe()
3381 sensor->nbinning_subtypes = in ccs_probe()
3382 min_t(u8, CCS_LIM(sensor, BINNING_SUB_TYPES), in ccs_probe()
3385 for (i = 0; i < sensor->nbinning_subtypes; i++) { in ccs_probe()
3386 sensor->binning_subtypes[i].horizontal = in ccs_probe()
3387 CCS_LIM_AT(sensor, BINNING_SUB_TYPE, i) >> in ccs_probe()
3389 sensor->binning_subtypes[i].vertical = in ccs_probe()
3390 CCS_LIM_AT(sensor, BINNING_SUB_TYPE, i) & in ccs_probe()
3394 sensor->binning_subtypes[i].horizontal, in ccs_probe()
3395 sensor->binning_subtypes[i].vertical); in ccs_probe()
3398 sensor->binning_horizontal = 1; in ccs_probe()
3399 sensor->binning_vertical = 1; in ccs_probe()
3407 if (sensor->minfo.smiapp_version && in ccs_probe()
3408 CCS_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & in ccs_probe()
3417 if (!CCS_LIM(sensor, MIN_OP_SYS_CLK_DIV) || in ccs_probe()
3418 !CCS_LIM(sensor, MAX_OP_SYS_CLK_DIV) || in ccs_probe()
3419 !CCS_LIM(sensor, MIN_OP_PIX_CLK_DIV) || in ccs_probe()
3420 !CCS_LIM(sensor, MAX_OP_PIX_CLK_DIV)) { in ccs_probe()
3422 sensor->pll.flags |= CCS_PLL_FLAG_NO_OP_CLOCKS; in ccs_probe()
3423 } else if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_probe()
3425 CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in ccs_probe()
3428 sensor->scaler = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3429 sensor->ssds_used++; in ccs_probe()
3431 sensor->binner = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3432 sensor->ssds_used++; in ccs_probe()
3433 sensor->pixel_array = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3434 sensor->ssds_used++; in ccs_probe()
3436 sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_probe()
3439 sensor->pll.bus_type = CCS_PLL_BUS_TYPE_CSI2_DPHY; in ccs_probe()
3440 sensor->pll.csi2.lanes = sensor->hwcfg.lanes; in ccs_probe()
3441 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3443 sensor->pll.flags |= CCS_PLL_FLAG_LANE_SPEED_MODEL; in ccs_probe()
3444 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3446 sensor->pll.vt_lanes = in ccs_probe()
3447 CCS_LIM(sensor, NUM_OF_VT_LANES) + 1; in ccs_probe()
3448 sensor->pll.op_lanes = in ccs_probe()
3449 CCS_LIM(sensor, NUM_OF_OP_LANES) + 1; in ccs_probe()
3450 sensor->pll.flags |= CCS_PLL_FLAG_LINK_DECOUPLED; in ccs_probe()
3452 sensor->pll.vt_lanes = sensor->pll.csi2.lanes; in ccs_probe()
3453 sensor->pll.op_lanes = sensor->pll.csi2.lanes; in ccs_probe()
3456 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3458 sensor->pll.flags |= CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER; in ccs_probe()
3459 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3461 sensor->pll.flags |= CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV; in ccs_probe()
3462 if (CCS_LIM(sensor, FIFO_SUPPORT_CAPABILITY) & in ccs_probe()
3464 sensor->pll.flags |= CCS_PLL_FLAG_FIFO_DERATING; in ccs_probe()
3465 if (CCS_LIM(sensor, FIFO_SUPPORT_CAPABILITY) & in ccs_probe()
3467 sensor->pll.flags |= CCS_PLL_FLAG_FIFO_DERATING | in ccs_probe()
3469 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3471 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3475 /* Use sensor default in PLL mode selection */ in ccs_probe()
3476 rval = ccs_read(sensor, PLL_MODE, &v); in ccs_probe()
3481 sensor->pll.flags |= CCS_PLL_FLAG_DUAL_PLL; in ccs_probe()
3483 sensor->pll.flags |= CCS_PLL_FLAG_DUAL_PLL; in ccs_probe()
3485 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3487 sensor->pll.flags |= CCS_PLL_FLAG_OP_SYS_DDR; in ccs_probe()
3488 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3490 sensor->pll.flags |= CCS_PLL_FLAG_OP_PIX_DDR; in ccs_probe()
3492 sensor->pll.op_bits_per_lane = CCS_LIM(sensor, OP_BITS_PER_LANE); in ccs_probe()
3493 sensor->pll.ext_clk_freq_hz = sensor->hwcfg.ext_clk; in ccs_probe()
3494 sensor->pll.scale_n = CCS_LIM(sensor, SCALER_N_MIN); in ccs_probe()
3496 rval = ccs_get_mbus_formats(sensor); in ccs_probe()
3502 rval = ccs_init_subdev(sensor, sensor->scaler, " scaler", 2, in ccs_probe()
3507 rval = ccs_init_subdev(sensor, sensor->binner, " binner", 2, in ccs_probe()
3512 rval = ccs_init_subdev(sensor, sensor->pixel_array, " pixel_array", 1, in ccs_probe()
3518 rval = ccs_init_controls(sensor); in ccs_probe()
3522 rval = ccs_call_quirk(sensor, init); in ccs_probe()
3526 rval = ccs_init_late_controls(sensor); in ccs_probe()
3532 mutex_lock(&sensor->mutex); in ccs_probe()
3533 rval = ccs_pll_blanking_update(sensor); in ccs_probe()
3534 mutex_unlock(&sensor->mutex); in ccs_probe()
3540 sensor->streaming = false; in ccs_probe()
3541 sensor->dev_init_done = true; in ccs_probe()
3542 sensor->handler_setup_needed = true; in ccs_probe()
3544 rval = ccs_write_msr_regs(sensor); in ccs_probe()
3552 rval = v4l2_async_register_subdev_sensor(&sensor->src->sd); in ccs_probe()
3567 ccs_cleanup(sensor); in ccs_probe()
3570 kvfree(sensor->mdata.backing); in ccs_probe()
3573 kvfree(sensor->sdata.backing); in ccs_probe()
3576 kfree(sensor->ccs_limits); in ccs_probe()
3580 mutex_destroy(&sensor->mutex); in ccs_probe()
3588 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_remove() local
3598 for (i = 0; i < sensor->ssds_used; i++) in ccs_remove()
3599 v4l2_device_unregister_subdev(&sensor->ssds[i].sd); in ccs_remove()
3600 ccs_cleanup(sensor); in ccs_remove()
3601 mutex_destroy(&sensor->mutex); in ccs_remove()
3602 kfree(sensor->ccs_limits); in ccs_remove()
3603 kvfree(sensor->sdata.backing); in ccs_remove()
3604 kvfree(sensor->mdata.backing); in ccs_remove()
3682 MODULE_DESCRIPTION("Generic MIPI CCS/SMIA/SMIA++ camera sensor driver");