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()
573 return sensor->default_pixel_order ^ flip; in ccs_pixel_order()
576 static void ccs_update_mbus_formats(struct ccs_sensor *sensor) in ccs_update_mbus_formats() argument
578 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_update_mbus_formats()
580 to_csi_format_idx(sensor->csi_format) & ~3; in ccs_update_mbus_formats()
582 to_csi_format_idx(sensor->internal_csi_format) & ~3; in ccs_update_mbus_formats()
583 unsigned int pixel_order = ccs_pixel_order(sensor); in ccs_update_mbus_formats()
589 sensor->mbus_frame_fmts = in ccs_update_mbus_formats()
590 sensor->default_mbus_frame_fmts << pixel_order; in ccs_update_mbus_formats()
591 sensor->csi_format = in ccs_update_mbus_formats()
593 sensor->internal_csi_format = in ccs_update_mbus_formats()
611 struct ccs_sensor *sensor = in ccs_set_ctrl() local
613 ->sensor; in ccs_set_ctrl()
614 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_set_ctrl()
624 if (sensor->streaming) in ccs_set_ctrl()
627 if (sensor->hflip->val) in ccs_set_ctrl()
630 if (sensor->vflip->val) in ccs_set_ctrl()
633 ccs_update_mbus_formats(sensor); in ccs_set_ctrl()
637 exposure = sensor->exposure->val; in ccs_set_ctrl()
639 __ccs_update_exposure_limits(sensor); in ccs_set_ctrl()
641 if (exposure > sensor->exposure->maximum) { in ccs_set_ctrl()
642 sensor->exposure->val = sensor->exposure->maximum; in ccs_set_ctrl()
643 rval = ccs_set_ctrl(sensor->exposure); in ccs_set_ctrl()
650 if (sensor->streaming) in ccs_set_ctrl()
653 rval = ccs_pll_update(sensor); in ccs_set_ctrl()
659 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) in ccs_set_ctrl()
661 sensor->test_data[i], in ccs_set_ctrl()
674 rval = ccs_write(sensor, ANALOG_GAIN_CODE_GLOBAL, ctrl->val); in ccs_set_ctrl()
679 rval = ccs_write(sensor, ANALOG_LINEAR_GAIN_GLOBAL, ctrl->val); in ccs_set_ctrl()
684 rval = ccs_write(sensor, ANALOG_EXPONENTIAL_GAIN_GLOBAL, in ccs_set_ctrl()
690 if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_set_ctrl()
692 rval = ccs_write(sensor, DIGITAL_GAIN_GLOBAL, in ccs_set_ctrl()
697 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
703 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
709 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
715 rval = ccs_write_addr(sensor, in ccs_set_ctrl()
721 rval = ccs_write(sensor, COARSE_INTEGRATION_TIME, ctrl->val); in ccs_set_ctrl()
726 rval = ccs_write(sensor, IMAGE_ORIENTATION, orient); in ccs_set_ctrl()
730 rval = ccs_write(sensor, FRAME_LENGTH_LINES, in ccs_set_ctrl()
731 sensor->pixel_array->crop[ in ccs_set_ctrl()
737 rval = ccs_write(sensor, LINE_LENGTH_PCK, in ccs_set_ctrl()
738 sensor->pixel_array->crop[CCS_PA_PAD_SRC].width in ccs_set_ctrl()
743 rval = ccs_write(sensor, TEST_PATTERN_MODE, ctrl->val); in ccs_set_ctrl()
747 rval = ccs_write(sensor, TEST_DATA_RED, ctrl->val); in ccs_set_ctrl()
751 rval = ccs_write(sensor, TEST_DATA_GREENR, ctrl->val); in ccs_set_ctrl()
755 rval = ccs_write(sensor, TEST_DATA_BLUE, ctrl->val); in ccs_set_ctrl()
759 rval = ccs_write(sensor, TEST_DATA_GREENB, ctrl->val); in ccs_set_ctrl()
763 rval = ccs_write(sensor, SHADING_CORRECTION_EN, in ccs_set_ctrl()
767 if (!rval && sensor->luminance_level) in ccs_set_ctrl()
768 v4l2_ctrl_activate(sensor->luminance_level, ctrl->val); in ccs_set_ctrl()
772 rval = ccs_write(sensor, LUMINANCE_CORRECTION_LEVEL, ctrl->val); in ccs_set_ctrl()
796 static int ccs_init_controls(struct ccs_sensor *sensor) in ccs_init_controls() argument
798 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_init_controls()
802 rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 19); in ccs_init_controls()
806 sensor->pixel_array->ctrl_handler.lock = &sensor->mutex; in ccs_init_controls()
812 rval = v4l2_ctrl_new_fwnode_properties(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
817 switch (CCS_LIM(sensor, ANALOG_GAIN_CAPABILITY)) { in ccs_init_controls()
825 CCS_LIM(sensor, ANALOG_GAIN_M0), }, in ccs_init_controls()
827 CCS_LIM(sensor, ANALOG_GAIN_C0), }, in ccs_init_controls()
829 CCS_LIM(sensor, ANALOG_GAIN_M1), }, in ccs_init_controls()
831 CCS_LIM(sensor, ANALOG_GAIN_C1), }, in ccs_init_controls()
847 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
851 v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
853 CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN), in ccs_init_controls()
854 CCS_LIM(sensor, ANALOG_GAIN_CODE_MAX), in ccs_init_controls()
855 max(CCS_LIM(sensor, ANALOG_GAIN_CODE_STEP), in ccs_init_controls()
857 CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN)); in ccs_init_controls()
870 CCS_LIM(sensor, ANALOG_LINEAR_GAIN_MIN), in ccs_init_controls()
871 CCS_LIM(sensor, ANALOG_LINEAR_GAIN_MAX), in ccs_init_controls()
872 max(CCS_LIM(sensor, in ccs_init_controls()
879 CCS_LIM(sensor, ANALOG_EXPONENTIAL_GAIN_MIN), in ccs_init_controls()
880 CCS_LIM(sensor, ANALOG_EXPONENTIAL_GAIN_MAX), in ccs_init_controls()
881 max(CCS_LIM(sensor, in ccs_init_controls()
899 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
905 if (CCS_LIM(sensor, SHADING_CORRECTION_CAPABILITY) & in ccs_init_controls()
917 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
921 if (CCS_LIM(sensor, SHADING_CORRECTION_CAPABILITY) & in ccs_init_controls()
933 sensor->luminance_level = in ccs_init_controls()
934 v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
938 if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_init_controls()
940 CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == in ccs_init_controls()
942 v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
944 CCS_LIM(sensor, DIGITAL_GAIN_MIN), in ccs_init_controls()
945 CCS_LIM(sensor, DIGITAL_GAIN_MAX), in ccs_init_controls()
946 max(CCS_LIM(sensor, DIGITAL_GAIN_STEP_SIZE), in ccs_init_controls()
951 sensor->exposure = v4l2_ctrl_new_std( in ccs_init_controls()
952 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
955 sensor->hflip = v4l2_ctrl_new_std( in ccs_init_controls()
956 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
958 sensor->vflip = v4l2_ctrl_new_std( in ccs_init_controls()
959 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
962 sensor->vblank = v4l2_ctrl_new_std( in ccs_init_controls()
963 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
966 if (sensor->vblank) in ccs_init_controls()
967 sensor->vblank->flags |= V4L2_CTRL_FLAG_UPDATE; in ccs_init_controls()
969 sensor->hblank = v4l2_ctrl_new_std( in ccs_init_controls()
970 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
973 if (sensor->hblank) in ccs_init_controls()
974 sensor->hblank->flags |= V4L2_CTRL_FLAG_UPDATE; in ccs_init_controls()
976 sensor->pixel_rate_parray = v4l2_ctrl_new_std( in ccs_init_controls()
977 &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
980 v4l2_ctrl_new_std_menu_items(&sensor->pixel_array->ctrl_handler, in ccs_init_controls()
985 if (sensor->pixel_array->ctrl_handler.error) { in ccs_init_controls()
988 sensor->pixel_array->ctrl_handler.error); in ccs_init_controls()
989 return sensor->pixel_array->ctrl_handler.error; in ccs_init_controls()
992 sensor->pixel_array->sd.ctrl_handler = in ccs_init_controls()
993 &sensor->pixel_array->ctrl_handler; in ccs_init_controls()
995 v4l2_ctrl_cluster(2, &sensor->hflip); in ccs_init_controls()
997 rval = v4l2_ctrl_handler_init(&sensor->src->ctrl_handler, 0); in ccs_init_controls()
1001 sensor->src->ctrl_handler.lock = &sensor->mutex; in ccs_init_controls()
1003 sensor->pixel_rate_csi = v4l2_ctrl_new_std( in ccs_init_controls()
1004 &sensor->src->ctrl_handler, &ccs_ctrl_ops, in ccs_init_controls()
1007 if (sensor->src->ctrl_handler.error) { in ccs_init_controls()
1010 sensor->src->ctrl_handler.error); in ccs_init_controls()
1011 return sensor->src->ctrl_handler.error; in ccs_init_controls()
1014 sensor->src->sd.ctrl_handler = &sensor->src->ctrl_handler; in ccs_init_controls()
1023 static int ccs_init_late_controls(struct ccs_sensor *sensor) in ccs_init_late_controls() argument
1025 unsigned long *valid_link_freqs = &sensor->valid_link_freqs[ in ccs_init_late_controls()
1026 sensor->csi_format->compressed - sensor->compressed_min_bpp]; in ccs_init_late_controls()
1029 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) { in ccs_init_late_controls()
1030 int max_value = (1 << sensor->csi_format->width) - 1; in ccs_init_late_controls()
1032 sensor->test_data[i] = v4l2_ctrl_new_std( in ccs_init_late_controls()
1033 &sensor->pixel_array->ctrl_handler, in ccs_init_late_controls()
1038 sensor->link_freq = v4l2_ctrl_new_int_menu( in ccs_init_late_controls()
1039 &sensor->src->ctrl_handler, &ccs_ctrl_ops, in ccs_init_late_controls()
1041 __ffs(*valid_link_freqs), sensor->hwcfg.op_sys_clock); in ccs_init_late_controls()
1043 return sensor->src->ctrl_handler.error; in ccs_init_late_controls()
1046 static void ccs_free_controls(struct ccs_sensor *sensor) in ccs_free_controls() argument
1050 for (i = 0; i < sensor->ssds_used; i++) in ccs_free_controls()
1051 v4l2_ctrl_handler_free(&sensor->ssds[i].ctrl_handler); in ccs_free_controls()
1054 static int ccs_get_mbus_formats(struct ccs_sensor *sensor) in ccs_get_mbus_formats() argument
1056 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_get_mbus_formats()
1057 struct ccs_pll *pll = &sensor->pll; in ccs_get_mbus_formats()
1063 type = CCS_LIM(sensor, DATA_FORMAT_MODEL_TYPE); in ccs_get_mbus_formats()
1067 rval = ccs_read(sensor, PIXEL_ORDER, &pixel_order); in ccs_get_mbus_formats()
1090 sensor->default_pixel_order = pixel_order; in ccs_get_mbus_formats()
1091 sensor->mbus_frame_fmts = 0; in ccs_get_mbus_formats()
1096 fmt = CCS_LIM_AT(sensor, DATA_FORMAT_DESCRIPTOR, i); in ccs_get_mbus_formats()
1116 sensor->default_mbus_frame_fmts |= 1 << j; in ccs_get_mbus_formats()
1123 pll->scale_m = sensor->scale_m; in ccs_get_mbus_formats()
1126 sensor->compressed_min_bpp = in ccs_get_mbus_formats()
1128 sensor->compressed_min_bpp); in ccs_get_mbus_formats()
1134 sensor->valid_link_freqs = devm_kcalloc( in ccs_get_mbus_formats()
1136 compressed_max_bpp - sensor->compressed_min_bpp + 1, in ccs_get_mbus_formats()
1137 sizeof(*sensor->valid_link_freqs), GFP_KERNEL); in ccs_get_mbus_formats()
1138 if (!sensor->valid_link_freqs) in ccs_get_mbus_formats()
1145 &sensor->valid_link_freqs[ in ccs_get_mbus_formats()
1146 f->compressed - sensor->compressed_min_bpp]; in ccs_get_mbus_formats()
1149 if (!(sensor->default_mbus_frame_fmts & 1 << i)) in ccs_get_mbus_formats()
1154 for (j = 0; sensor->hwcfg.op_sys_clock[j]; j++) { in ccs_get_mbus_formats()
1155 pll->link_freq = sensor->hwcfg.op_sys_clock[j]; in ccs_get_mbus_formats()
1157 rval = ccs_pll_try(sensor, pll); in ccs_get_mbus_formats()
1171 sensor->default_mbus_frame_fmts &= ~BIT(i); in ccs_get_mbus_formats()
1175 if (!sensor->csi_format in ccs_get_mbus_formats()
1176 || f->width > sensor->csi_format->width in ccs_get_mbus_formats()
1177 || (f->width == sensor->csi_format->width in ccs_get_mbus_formats()
1178 && f->compressed > sensor->csi_format->compressed)) { in ccs_get_mbus_formats()
1179 sensor->csi_format = f; in ccs_get_mbus_formats()
1180 sensor->internal_csi_format = f; in ccs_get_mbus_formats()
1184 if (!sensor->csi_format) { in ccs_get_mbus_formats()
1189 ccs_update_mbus_formats(sensor); in ccs_get_mbus_formats()
1194 static void ccs_update_blanking(struct ccs_sensor *sensor) in ccs_update_blanking() argument
1196 struct v4l2_ctrl *vblank = sensor->vblank; in ccs_update_blanking()
1197 struct v4l2_ctrl *hblank = sensor->hblank; in ccs_update_blanking()
1201 if (sensor->binning_vertical > 1 || sensor->binning_horizontal > 1) { in ccs_update_blanking()
1202 min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES_BIN); in ccs_update_blanking()
1203 max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES_BIN); in ccs_update_blanking()
1204 min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN); in ccs_update_blanking()
1205 max_llp = CCS_LIM(sensor, MAX_LINE_LENGTH_PCK_BIN); in ccs_update_blanking()
1206 min_lbp = CCS_LIM(sensor, MIN_LINE_BLANKING_PCK_BIN); in ccs_update_blanking()
1208 min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES); in ccs_update_blanking()
1209 max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES); in ccs_update_blanking()
1210 min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK); in ccs_update_blanking()
1211 max_llp = CCS_LIM(sensor, MAX_LINE_LENGTH_PCK); in ccs_update_blanking()
1212 min_lbp = CCS_LIM(sensor, MIN_LINE_BLANKING_PCK); in ccs_update_blanking()
1216 CCS_LIM(sensor, MIN_FRAME_BLANKING_LINES), in ccs_update_blanking()
1217 min_fll - sensor->pixel_array->crop[CCS_PA_PAD_SRC].height); in ccs_update_blanking()
1218 max = max_fll - sensor->pixel_array->crop[CCS_PA_PAD_SRC].height; in ccs_update_blanking()
1223 min_llp - sensor->pixel_array->crop[CCS_PA_PAD_SRC].width, in ccs_update_blanking()
1225 max = max_llp - sensor->pixel_array->crop[CCS_PA_PAD_SRC].width; in ccs_update_blanking()
1229 __ccs_update_exposure_limits(sensor); in ccs_update_blanking()
1232 static int ccs_pll_blanking_update(struct ccs_sensor *sensor) in ccs_pll_blanking_update() argument
1234 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pll_blanking_update()
1237 rval = ccs_pll_update(sensor); in ccs_pll_blanking_update()
1242 ccs_update_blanking(sensor); in ccs_pll_blanking_update()
1244 dev_dbg(&client->dev, "vblank\t\t%d\n", sensor->vblank->val); in ccs_pll_blanking_update()
1245 dev_dbg(&client->dev, "hblank\t\t%d\n", sensor->hblank->val); in ccs_pll_blanking_update()
1248 sensor->pll.pixel_rate_pixel_array / in ccs_pll_blanking_update()
1249 ((sensor->pixel_array->crop[CCS_PA_PAD_SRC].width in ccs_pll_blanking_update()
1250 + sensor->hblank->val) * in ccs_pll_blanking_update()
1251 (sensor->pixel_array->crop[CCS_PA_PAD_SRC].height in ccs_pll_blanking_update()
1252 + sensor->vblank->val) / 100)); in ccs_pll_blanking_update()
1263 static int ccs_read_nvm_page(struct ccs_sensor *sensor, u32 p, u8 *nvm, in ccs_read_nvm_page() argument
1272 rval = ccs_write(sensor, DATA_TRANSFER_IF_1_PAGE_SELECT, p); in ccs_read_nvm_page()
1276 rval = ccs_write(sensor, DATA_TRANSFER_IF_1_CTRL, in ccs_read_nvm_page()
1281 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_STATUS, &s); in ccs_read_nvm_page()
1290 if (CCS_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & in ccs_read_nvm_page()
1296 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_STATUS, &s); in ccs_read_nvm_page()
1308 rval = ccs_read(sensor, DATA_TRANSFER_IF_1_DATA(i), &v); in ccs_read_nvm_page()
1318 static int ccs_read_nvm(struct ccs_sensor *sensor, unsigned char *nvm, in ccs_read_nvm() argument
1327 rval = ccs_read_nvm_page(sensor, p, nvm, &status); in ccs_read_nvm()
1335 rval2 = ccs_write(sensor, DATA_TRANSFER_IF_1_CTRL, 0); in ccs_read_nvm()
1347 static int ccs_change_cci_addr(struct ccs_sensor *sensor) in ccs_change_cci_addr() argument
1349 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_change_cci_addr()
1353 client->addr = sensor->hwcfg.i2c_addr_dfl; in ccs_change_cci_addr()
1355 rval = ccs_write(sensor, CCI_ADDRESS_CTRL, in ccs_change_cci_addr()
1356 sensor->hwcfg.i2c_addr_alt << 1); in ccs_change_cci_addr()
1360 client->addr = sensor->hwcfg.i2c_addr_alt; in ccs_change_cci_addr()
1363 rval = ccs_read(sensor, CCI_ADDRESS_CTRL, &val); in ccs_change_cci_addr()
1367 if (val != sensor->hwcfg.i2c_addr_alt << 1) in ccs_change_cci_addr()
1378 static int ccs_setup_flash_strobe(struct ccs_sensor *sensor) in ccs_setup_flash_strobe() argument
1381 unsigned int ext_freq = sensor->hwcfg.ext_clk; in ccs_setup_flash_strobe()
1387 strobe_setup = sensor->hwcfg.strobe_setup; in ccs_setup_flash_strobe()
1469 rval = ccs_write(sensor, FLASH_MODE_RS, strobe_setup->mode); in ccs_setup_flash_strobe()
1473 rval = ccs_write(sensor, FLASH_STROBE_ADJUSTMENT, strobe_adjustment); in ccs_setup_flash_strobe()
1477 rval = ccs_write(sensor, TFLASH_STROBE_WIDTH_HIGH_RS_CTRL, in ccs_setup_flash_strobe()
1482 rval = ccs_write(sensor, TFLASH_STROBE_DELAY_RS_CTRL, in ccs_setup_flash_strobe()
1487 rval = ccs_write(sensor, FLASH_STROBE_START_POINT, in ccs_setup_flash_strobe()
1492 rval = ccs_write(sensor, FLASH_TRIGGER_RS, strobe_setup->trigger); in ccs_setup_flash_strobe()
1495 sensor->hwcfg.strobe_setup->trigger = 0; in ccs_setup_flash_strobe()
1504 static int ccs_write_msr_regs(struct ccs_sensor *sensor) in ccs_write_msr_regs() argument
1508 rval = ccs_write_data_regs(sensor, in ccs_write_msr_regs()
1509 sensor->sdata.sensor_manufacturer_regs, in ccs_write_msr_regs()
1510 sensor->sdata.num_sensor_manufacturer_regs); in ccs_write_msr_regs()
1514 return ccs_write_data_regs(sensor, in ccs_write_msr_regs()
1515 sensor->mdata.module_manufacturer_regs, in ccs_write_msr_regs()
1516 sensor->mdata.num_module_manufacturer_regs); in ccs_write_msr_regs()
1519 static int ccs_update_phy_ctrl(struct ccs_sensor *sensor) in ccs_update_phy_ctrl() argument
1521 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_update_phy_ctrl()
1524 if (!sensor->ccs_limits) in ccs_update_phy_ctrl()
1527 if (CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_update_phy_ctrl()
1530 } else if (CCS_LIM(sensor, PHY_CTRL_CAPABILITY) & in ccs_update_phy_ctrl()
1538 return ccs_write(sensor, PHY_CTRL, val); in ccs_update_phy_ctrl()
1549 struct ccs_sensor *sensor = in ccs_power_on() local
1555 sensor->regulators); in ccs_power_on()
1561 if (sensor->reset || sensor->xshutdown || sensor->ext_clk) { in ccs_power_on()
1564 rval = clk_prepare_enable(sensor->ext_clk); in ccs_power_on()
1570 gpiod_set_value(sensor->reset, 0); in ccs_power_on()
1571 gpiod_set_value(sensor->xshutdown, 1); in ccs_power_on()
1574 sleep = SMIAPP_RESET_DELAY(sensor->hwcfg.ext_clk); in ccs_power_on()
1583 * Those failures seem to be caused by the sensor requiring a longer in ccs_power_on()
1592 if (!sensor->reset && !sensor->xshutdown) { in ccs_power_on()
1596 rval = ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); in ccs_power_on()
1603 rval = ccs_read(sensor, SOFTWARE_RESET, &reset); in ccs_power_on()
1618 if (sensor->hwcfg.i2c_addr_alt) { in ccs_power_on()
1619 rval = ccs_change_cci_addr(sensor); in ccs_power_on()
1626 rval = ccs_write(sensor, COMPRESSION_MODE, in ccs_power_on()
1633 rval = ccs_write(sensor, EXTCLK_FREQUENCY_MHZ, in ccs_power_on()
1634 sensor->hwcfg.ext_clk / (1000000 / (1 << 8))); in ccs_power_on()
1640 rval = ccs_write(sensor, CSI_LANE_MODE, sensor->hwcfg.lanes - 1); in ccs_power_on()
1646 rval = ccs_write(sensor, FAST_STANDBY_CTRL, in ccs_power_on()
1653 rval = ccs_write(sensor, CSI_SIGNALING_MODE, in ccs_power_on()
1654 sensor->hwcfg.csi_signalling_mode); in ccs_power_on()
1660 rval = ccs_update_phy_ctrl(sensor); in ccs_power_on()
1664 rval = ccs_write_msr_regs(sensor); in ccs_power_on()
1668 rval = ccs_call_quirk(sensor, post_poweron); in ccs_power_on()
1677 gpiod_set_value(sensor->reset, 1); in ccs_power_on()
1678 gpiod_set_value(sensor->xshutdown, 0); in ccs_power_on()
1679 clk_disable_unprepare(sensor->ext_clk); in ccs_power_on()
1683 sensor->regulators); in ccs_power_on()
1692 struct ccs_sensor *sensor = in ccs_power_off() local
1697 * but they are essentially the same signals. So if the sensor is in ccs_power_off()
1698 * powered off while the lens is powered on the sensor does not in ccs_power_off()
1702 if (sensor->hwcfg.i2c_addr_alt) in ccs_power_off()
1703 ccs_write(sensor, SOFTWARE_RESET, CCS_SOFTWARE_RESET_ON); in ccs_power_off()
1705 gpiod_set_value(sensor->reset, 1); in ccs_power_off()
1706 gpiod_set_value(sensor->xshutdown, 0); in ccs_power_off()
1707 clk_disable_unprepare(sensor->ext_clk); in ccs_power_off()
1710 sensor->regulators); in ccs_power_off()
1711 sensor->streaming = false; in ccs_power_off()
1720 static int ccs_start_streaming(struct ccs_sensor *sensor) in ccs_start_streaming() argument
1722 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_start_streaming()
1726 mutex_lock(&sensor->mutex); in ccs_start_streaming()
1728 rval = ccs_write(sensor, CSI_DATA_FORMAT, in ccs_start_streaming()
1729 (sensor->csi_format->width << 8) | in ccs_start_streaming()
1730 sensor->csi_format->compressed); in ccs_start_streaming()
1735 if (sensor->binning_horizontal == 1 && in ccs_start_streaming()
1736 sensor->binning_vertical == 1) { in ccs_start_streaming()
1740 (sensor->binning_horizontal << 4) in ccs_start_streaming()
1741 | sensor->binning_vertical; in ccs_start_streaming()
1743 rval = ccs_write(sensor, BINNING_TYPE, binning_type); in ccs_start_streaming()
1749 rval = ccs_write(sensor, BINNING_MODE, binning_mode); in ccs_start_streaming()
1754 rval = ccs_pll_configure(sensor); in ccs_start_streaming()
1759 rval = ccs_write(sensor, X_ADDR_START, in ccs_start_streaming()
1760 sensor->pixel_array->crop[CCS_PA_PAD_SRC].left); in ccs_start_streaming()
1764 rval = ccs_write(sensor, Y_ADDR_START, in ccs_start_streaming()
1765 sensor->pixel_array->crop[CCS_PA_PAD_SRC].top); in ccs_start_streaming()
1771 sensor, X_ADDR_END, in ccs_start_streaming()
1772 sensor->pixel_array->crop[CCS_PA_PAD_SRC].left in ccs_start_streaming()
1773 + sensor->pixel_array->crop[CCS_PA_PAD_SRC].width - 1); in ccs_start_streaming()
1778 sensor, Y_ADDR_END, in ccs_start_streaming()
1779 sensor->pixel_array->crop[CCS_PA_PAD_SRC].top in ccs_start_streaming()
1780 + sensor->pixel_array->crop[CCS_PA_PAD_SRC].height - 1); in ccs_start_streaming()
1790 if (CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in ccs_start_streaming()
1793 sensor, DIGITAL_CROP_X_OFFSET, in ccs_start_streaming()
1794 sensor->scaler->crop[CCS_PAD_SINK].left); in ccs_start_streaming()
1799 sensor, DIGITAL_CROP_Y_OFFSET, in ccs_start_streaming()
1800 sensor->scaler->crop[CCS_PAD_SINK].top); in ccs_start_streaming()
1805 sensor, DIGITAL_CROP_IMAGE_WIDTH, in ccs_start_streaming()
1806 sensor->scaler->crop[CCS_PAD_SINK].width); in ccs_start_streaming()
1811 sensor, DIGITAL_CROP_IMAGE_HEIGHT, in ccs_start_streaming()
1812 sensor->scaler->crop[CCS_PAD_SINK].height); in ccs_start_streaming()
1818 if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_start_streaming()
1820 rval = ccs_write(sensor, SCALING_MODE, sensor->scaling_mode); in ccs_start_streaming()
1824 rval = ccs_write(sensor, SCALE_M, sensor->scale_m); in ccs_start_streaming()
1829 /* Output size from sensor */ in ccs_start_streaming()
1830 rval = ccs_write(sensor, X_OUTPUT_SIZE, in ccs_start_streaming()
1831 sensor->src->crop[CCS_PAD_SRC].width); in ccs_start_streaming()
1834 rval = ccs_write(sensor, Y_OUTPUT_SIZE, in ccs_start_streaming()
1835 sensor->src->crop[CCS_PAD_SRC].height); in ccs_start_streaming()
1839 if (CCS_LIM(sensor, FLASH_MODE_CAPABILITY) & in ccs_start_streaming()
1842 sensor->hwcfg.strobe_setup != NULL && in ccs_start_streaming()
1843 sensor->hwcfg.strobe_setup->trigger != 0) { in ccs_start_streaming()
1844 rval = ccs_setup_flash_strobe(sensor); in ccs_start_streaming()
1849 rval = ccs_call_quirk(sensor, pre_streamon); in ccs_start_streaming()
1855 rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_STREAMING); in ccs_start_streaming()
1858 mutex_unlock(&sensor->mutex); in ccs_start_streaming()
1863 static int ccs_stop_streaming(struct ccs_sensor *sensor) in ccs_stop_streaming() argument
1865 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_stop_streaming()
1868 mutex_lock(&sensor->mutex); in ccs_stop_streaming()
1869 rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_SOFTWARE_STANDBY); in ccs_stop_streaming()
1873 rval = ccs_call_quirk(sensor, post_streamoff); in ccs_stop_streaming()
1878 mutex_unlock(&sensor->mutex); in ccs_stop_streaming()
1886 static int ccs_pm_get_init(struct ccs_sensor *sensor) in ccs_pm_get_init() argument
1888 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pm_get_init()
1905 rval = v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler); in ccs_pm_get_init()
1909 rval = v4l2_ctrl_handler_setup(&sensor->src->ctrl_handler); in ccs_pm_get_init()
1922 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_stream() local
1923 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_set_stream()
1926 if (sensor->streaming == enable) in ccs_set_stream()
1930 ccs_stop_streaming(sensor); in ccs_set_stream()
1931 sensor->streaming = false; in ccs_set_stream()
1938 rval = ccs_pm_get_init(sensor); in ccs_set_stream()
1942 sensor->streaming = true; in ccs_set_stream()
1944 rval = ccs_start_streaming(sensor); in ccs_set_stream()
1946 sensor->streaming = false; in ccs_set_stream()
1956 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_pre_streamon() local
1957 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_pre_streamon()
1961 switch (sensor->hwcfg.csi_signalling_mode) { in ccs_pre_streamon()
1963 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) & in ccs_pre_streamon()
1968 if (!(CCS_LIM(sensor, PHY_CTRL_CAPABILITY_2) & in ccs_pre_streamon()
1977 rval = ccs_pm_get_init(sensor); in ccs_pre_streamon()
1982 rval = ccs_write(sensor, MANUAL_LP_CTRL, in ccs_pre_streamon()
1993 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_post_streamoff() local
1994 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_post_streamoff()
2004 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_enum_mbus_code() local
2009 mutex_lock(&sensor->mutex); in ccs_enum_mbus_code()
2014 if (subdev != &sensor->src->sd || code->pad != CCS_PAD_SRC) { in ccs_enum_mbus_code()
2018 code->code = sensor->internal_csi_format->code; in ccs_enum_mbus_code()
2024 if (sensor->mbus_frame_fmts & (1 << i)) in ccs_enum_mbus_code()
2037 mutex_unlock(&sensor->mutex); in ccs_enum_mbus_code()
2044 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in __ccs_get_mbus_code() local
2046 if (subdev == &sensor->src->sd && pad == CCS_PAD_SRC) in __ccs_get_mbus_code()
2047 return sensor->csi_format->code; in __ccs_get_mbus_code()
2049 return sensor->internal_csi_format->code; in __ccs_get_mbus_code()
2082 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_format() local
2085 mutex_lock(&sensor->mutex); in ccs_get_format()
2087 mutex_unlock(&sensor->mutex); in ccs_get_format()
2124 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_propagate() local
2135 if (ssd == sensor->scaler) { in ccs_propagate()
2136 sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_propagate()
2137 sensor->scaling_mode = in ccs_propagate()
2139 } else if (ssd == sensor->binner) { in ccs_propagate()
2140 sensor->binning_horizontal = 1; in ccs_propagate()
2141 sensor->binning_vertical = 1; in ccs_propagate()
2154 *ccs_validate_csi_data_format(struct ccs_sensor *sensor, u32 code) in ccs_validate_csi_data_format() argument
2159 if (sensor->mbus_frame_fmts & (1 << i) && in ccs_validate_csi_data_format()
2164 return sensor->csi_format; in ccs_validate_csi_data_format()
2171 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_format_source() local
2173 *old_csi_format = sensor->csi_format; in ccs_set_format_source()
2187 if (subdev != &sensor->src->sd) in ccs_set_format_source()
2190 csi_format = ccs_validate_csi_data_format(sensor, code); in ccs_set_format_source()
2197 sensor->csi_format = csi_format; in ccs_set_format_source()
2200 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) in ccs_set_format_source()
2202 sensor->test_data[i], 0, in ccs_set_format_source()
2209 &sensor->valid_link_freqs[sensor->csi_format->compressed in ccs_set_format_source()
2210 - sensor->compressed_min_bpp]; in ccs_set_format_source()
2213 sensor->link_freq, 0, in ccs_set_format_source()
2217 return ccs_pll_update(sensor); in ccs_set_format_source()
2224 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_format() local
2228 mutex_lock(&sensor->mutex); in ccs_set_format()
2235 mutex_unlock(&sensor->mutex); in ccs_set_format()
2248 CCS_LIM(sensor, MIN_X_OUTPUT_SIZE), in ccs_set_format()
2249 CCS_LIM(sensor, MAX_X_OUTPUT_SIZE)); in ccs_set_format()
2252 CCS_LIM(sensor, MIN_Y_OUTPUT_SIZE), in ccs_set_format()
2253 CCS_LIM(sensor, MAX_Y_OUTPUT_SIZE)); in ccs_set_format()
2265 mutex_unlock(&sensor->mutex); in ccs_set_format()
2279 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in scaling_goodness() local
2305 if (w < CCS_LIM(sensor, MIN_X_OUTPUT_SIZE)) in scaling_goodness()
2320 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose_binner() local
2328 for (i = 0; i < sensor->nbinning_subtypes; i++) { in ccs_set_compose_binner()
2332 / sensor->binning_subtypes[i].horizontal, in ccs_set_compose_binner()
2335 / sensor->binning_subtypes[i].vertical, in ccs_set_compose_binner()
2339 binh = sensor->binning_subtypes[i].horizontal; in ccs_set_compose_binner()
2340 binv = sensor->binning_subtypes[i].vertical; in ccs_set_compose_binner()
2345 sensor->binning_vertical = binv; in ccs_set_compose_binner()
2346 sensor->binning_horizontal = binh; in ccs_set_compose_binner()
2369 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose_scaler() local
2371 u32 scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_set_compose_scaler()
2384 * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.width; in ccs_set_compose_scaler()
2386 * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height; in ccs_set_compose_scaler()
2388 * CCS_LIM(sensor, SCALER_N_MIN) in ccs_set_compose_scaler()
2389 / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE); in ccs_set_compose_scaler()
2391 a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2392 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2393 b = clamp(b, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2394 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2395 max_m = clamp(max_m, CCS_LIM(sensor, SCALER_M_MIN), in ccs_set_compose_scaler()
2396 CCS_LIM(sensor, SCALER_M_MAX)); in ccs_set_compose_scaler()
2422 / try[i] * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2436 if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_set_compose_scaler()
2443 * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2447 * CCS_LIM(sensor, SCALER_N_MIN), in ccs_set_compose_scaler()
2461 * CCS_LIM(sensor, SCALER_N_MIN)) & ~1; in ccs_set_compose_scaler()
2466 * CCS_LIM(sensor, SCALER_N_MIN)) in ccs_set_compose_scaler()
2472 sensor->scale_m = scale_m; in ccs_set_compose_scaler()
2473 sensor->scaling_mode = mode; in ccs_set_compose_scaler()
2481 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_compose() local
2490 if (ssd == sensor->binner) in ccs_set_compose()
2499 return ccs_pll_blanking_update(sensor); in ccs_set_compose()
2507 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in __ccs_sel_supported() local
2514 if (ssd == sensor->pixel_array && sel->pad == CCS_PA_PAD_SRC) in __ccs_sel_supported()
2516 if (ssd == sensor->src && sel->pad == CCS_PAD_SRC) in __ccs_sel_supported()
2518 if (ssd == sensor->scaler && sel->pad == CCS_PAD_SINK && in __ccs_sel_supported()
2519 CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in __ccs_sel_supported()
2524 if (ssd == sensor->pixel_array && sel->pad == CCS_PA_PAD_SRC) in __ccs_sel_supported()
2531 if (ssd == sensor->binner) in __ccs_sel_supported()
2533 if (ssd == sensor->scaler && CCS_LIM(sensor, SCALING_CAPABILITY) in __ccs_sel_supported()
2546 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_crop() local
2577 if (ssd == sensor->src && sel->pad == CCS_PAD_SRC) { in ccs_set_crop()
2590 if (ssd != sensor->pixel_array && sel->pad == CCS_PAD_SINK) in ccs_set_crop()
2600 r->width = CCS_LIM(ssd->sensor, X_ADDR_MAX) + 1; in ccs_get_native_size()
2601 r->height = CCS_LIM(ssd->sensor, Y_ADDR_MAX) + 1; in ccs_get_native_size()
2608 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in __ccs_get_selection() local
2636 if (ssd == sensor->pixel_array) in __ccs_get_selection()
2659 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_selection() local
2662 mutex_lock(&sensor->mutex); in ccs_get_selection()
2664 mutex_unlock(&sensor->mutex); in ccs_get_selection()
2673 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_set_selection() local
2680 mutex_lock(&sensor->mutex); in ccs_set_selection()
2687 sel->r.width = max_t(unsigned int, CCS_LIM(sensor, MIN_X_OUTPUT_SIZE), in ccs_set_selection()
2689 sel->r.height = max_t(unsigned int, CCS_LIM(sensor, MIN_Y_OUTPUT_SIZE), in ccs_set_selection()
2703 mutex_unlock(&sensor->mutex); in ccs_set_selection()
2709 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_skip_frames() local
2711 *frames = sensor->frame_skip; in ccs_get_skip_frames()
2717 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_get_skip_top_lines() local
2719 *lines = sensor->image_start; in ccs_get_skip_top_lines()
2733 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in nvm_show() local
2736 if (!sensor->dev_init_done) in nvm_show()
2739 rval = ccs_pm_get_init(sensor); in nvm_show()
2743 rval = ccs_read_nvm(sensor, buf, PAGE_SIZE); in nvm_show()
2765 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ident_show() local
2766 struct ccs_module_info *minfo = &sensor->minfo; in ident_show()
2783 static int ccs_identify_module(struct ccs_sensor *sensor) in ccs_identify_module() argument
2785 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_identify_module()
2786 struct ccs_module_info *minfo = &sensor->minfo; in ccs_identify_module()
2792 rval = ccs_read(sensor, MODULE_MANUFACTURER_ID, in ccs_identify_module()
2795 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2799 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_MODEL_ID, in ccs_identify_module()
2802 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2806 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2812 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_DATE_YEAR, in ccs_identify_module()
2815 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_DATE_MONTH, in ccs_identify_module()
2818 rval = ccs_read_addr_8only(sensor, CCS_R_MODULE_DATE_DAY, in ccs_identify_module()
2821 /* Sensor info */ in ccs_identify_module()
2823 rval = ccs_read(sensor, SENSOR_MANUFACTURER_ID, in ccs_identify_module()
2826 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2830 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2834 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2838 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2842 rval = ccs_read_addr_8only(sensor, in ccs_identify_module()
2848 rval = ccs_read(sensor, MIPI_CCS_VERSION, &minfo->ccs_version); in ccs_identify_module()
2850 rval = ccs_read_addr_8only(sensor, SMIAPP_REG_U8_SMIA_VERSION, in ccs_identify_module()
2853 rval = ccs_read_addr_8only(sensor, SMIAPP_REG_U8_SMIAPP_VERSION, in ccs_identify_module()
2857 dev_err(&client->dev, "sensor detection failed\n"); in ccs_identify_module()
2874 dev_dbg(&client->dev, "MIPI CCS sensor 0x%4.4x-0x%4.4x\n", in ccs_identify_module()
2878 dev_dbg(&client->dev, "SMIA sensor 0x%2.2x-0x%4.4x\n", in ccs_identify_module()
2883 "sensor revision 0x%4.4x firmware version 0x%2.2x\n", in ccs_identify_module()
2900 * parameters whereas the rvalues are sensor parameters. in ccs_identify_module()
2942 dev_dbg(&client->dev, "the sensor is called %s\n", minfo->name); in ccs_identify_module()
2951 static int ccs_register_subdev(struct ccs_sensor *sensor, in ccs_register_subdev() argument
2956 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_register_subdev()
2968 rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, &ssd->sd); in ccs_register_subdev()
2988 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_unregistered() local
2991 for (i = 1; i < sensor->ssds_used; i++) in ccs_unregistered()
2992 v4l2_device_unregister_subdev(&sensor->ssds[i].sd); in ccs_unregistered()
2997 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_registered() local
3000 if (sensor->scaler) { in ccs_registered()
3001 rval = ccs_register_subdev(sensor, sensor->binner, in ccs_registered()
3002 sensor->scaler, in ccs_registered()
3010 rval = ccs_register_subdev(sensor, sensor->pixel_array, sensor->binner, in ccs_registered()
3025 static void ccs_cleanup(struct ccs_sensor *sensor) in ccs_cleanup() argument
3027 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_cleanup()
3032 ccs_free_controls(sensor); in ccs_cleanup()
3035 static void ccs_create_subdev(struct ccs_sensor *sensor, in ccs_create_subdev() argument
3039 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); in ccs_create_subdev()
3044 if (ssd != sensor->src) in ccs_create_subdev()
3049 ssd->sensor = sensor; in ccs_create_subdev()
3054 v4l2_i2c_subdev_set_name(&ssd->sd, client, sensor->minfo.name, name); in ccs_create_subdev()
3062 if (ssd != sensor->pixel_array) { in ccs_create_subdev()
3069 if (ssd == sensor->src) in ccs_create_subdev()
3081 struct ccs_sensor *sensor = ssd->sensor; in ccs_open() local
3084 mutex_lock(&sensor->mutex); in ccs_open()
3097 try_fmt->code = sensor->internal_csi_format->code; in ccs_open()
3100 if (ssd == sensor->pixel_array) in ccs_open()
3107 mutex_unlock(&sensor->mutex); in ccs_open()
3134 .sensor = &ccs_sensor_ops,
3159 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_suspend() local
3160 bool streaming = sensor->streaming; in ccs_suspend()
3167 if (sensor->streaming) in ccs_suspend()
3168 ccs_stop_streaming(sensor); in ccs_suspend()
3171 sensor->streaming = streaming; in ccs_suspend()
3180 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_resume() local
3185 if (sensor->streaming) in ccs_resume()
3186 rval = ccs_start_streaming(sensor); in ccs_resume()
3191 static int ccs_get_hwconfig(struct ccs_sensor *sensor, struct device *dev) in ccs_get_hwconfig() argument
3193 struct ccs_hwconfig *hwcfg = &sensor->hwcfg; in ccs_get_hwconfig()
3275 struct ccs_sensor *sensor, char *filename, in ccs_firmware_name() argument
3280 bool is_smiapp = sensor->minfo.smiapp_version; in ccs_firmware_name()
3286 * Old SMIA is module-agnostic. Its sensor identification is based on in ccs_firmware_name()
3291 sensor->minfo.mipi_manufacturer_id : in ccs_firmware_name()
3292 sensor->minfo.smia_manufacturer_id; in ccs_firmware_name()
3293 model_id = sensor->minfo.model_id; in ccs_firmware_name()
3294 revision_number = sensor->minfo.revision_number; in ccs_firmware_name()
3297 sensor->minfo.sensor_mipi_manufacturer_id : in ccs_firmware_name()
3298 sensor->minfo.sensor_smia_manufacturer_id; in ccs_firmware_name()
3299 model_id = sensor->minfo.sensor_model_id; in ccs_firmware_name()
3300 revision_number = sensor->minfo.sensor_revision_number; in ccs_firmware_name()
3307 "module" : "sensor", in ccs_firmware_name()
3315 struct ccs_sensor *sensor; in ccs_probe() local
3321 sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); in ccs_probe()
3322 if (sensor == NULL) in ccs_probe()
3325 rval = ccs_get_hwconfig(sensor, &client->dev); in ccs_probe()
3329 sensor->src = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3331 v4l2_i2c_subdev_init(&sensor->src->sd, client, &ccs_ops); in ccs_probe()
3332 sensor->src->sd.internal_ops = &ccs_internal_src_ops; in ccs_probe()
3334 sensor->regulators = devm_kcalloc(&client->dev, in ccs_probe()
3336 sizeof(*sensor->regulators), in ccs_probe()
3338 if (!sensor->regulators) in ccs_probe()
3342 sensor->regulators[i].supply = ccs_regulators[i]; in ccs_probe()
3345 sensor->regulators); in ccs_probe()
3351 sensor->ext_clk = devm_clk_get(&client->dev, NULL); in ccs_probe()
3352 if (PTR_ERR(sensor->ext_clk) == -ENOENT) { in ccs_probe()
3354 sensor->ext_clk = NULL; in ccs_probe()
3355 } else if (IS_ERR(sensor->ext_clk)) { in ccs_probe()
3357 PTR_ERR(sensor->ext_clk)); in ccs_probe()
3361 if (sensor->ext_clk) { in ccs_probe()
3362 if (sensor->hwcfg.ext_clk) { in ccs_probe()
3365 rval = clk_set_rate(sensor->ext_clk, in ccs_probe()
3366 sensor->hwcfg.ext_clk); in ccs_probe()
3370 sensor->hwcfg.ext_clk); in ccs_probe()
3374 rate = clk_get_rate(sensor->ext_clk); in ccs_probe()
3375 if (rate != sensor->hwcfg.ext_clk) { in ccs_probe()
3378 sensor->hwcfg.ext_clk, rate); in ccs_probe()
3382 sensor->hwcfg.ext_clk = clk_get_rate(sensor->ext_clk); in ccs_probe()
3384 sensor->hwcfg.ext_clk); in ccs_probe()
3386 } else if (sensor->hwcfg.ext_clk) { in ccs_probe()
3388 sensor->hwcfg.ext_clk); in ccs_probe()
3394 if (!sensor->hwcfg.ext_clk) { in ccs_probe()
3399 sensor->reset = devm_gpiod_get_optional(&client->dev, "reset", in ccs_probe()
3401 if (IS_ERR(sensor->reset)) in ccs_probe()
3402 return PTR_ERR(sensor->reset); in ccs_probe()
3404 if (!sensor->reset) in ccs_probe()
3405 sensor->xshutdown = devm_gpiod_get_optional(&client->dev, in ccs_probe()
3408 if (IS_ERR(sensor->xshutdown)) in ccs_probe()
3409 return PTR_ERR(sensor->xshutdown); in ccs_probe()
3415 mutex_init(&sensor->mutex); in ccs_probe()
3417 rval = ccs_identify_module(sensor); in ccs_probe()
3423 rval = ccs_firmware_name(client, sensor, filename, sizeof(filename), in ccs_probe()
3432 ccs_data_parse(&sensor->sdata, fw->data, fw->size, &client->dev, in ccs_probe()
3438 sensor->minfo.smiapp_version) { in ccs_probe()
3439 rval = ccs_firmware_name(client, sensor, filename, in ccs_probe()
3448 ccs_data_parse(&sensor->mdata, fw->data, fw->size, in ccs_probe()
3454 rval = ccs_read_all_limits(sensor); in ccs_probe()
3458 rval = ccs_read_frame_fmt(sensor); in ccs_probe()
3464 rval = ccs_update_phy_ctrl(sensor); in ccs_probe()
3468 rval = ccs_call_quirk(sensor, limits); in ccs_probe()
3474 if (CCS_LIM(sensor, BINNING_CAPABILITY)) { in ccs_probe()
3475 sensor->nbinning_subtypes = in ccs_probe()
3476 min_t(u8, CCS_LIM(sensor, BINNING_SUB_TYPES), in ccs_probe()
3479 for (i = 0; i < sensor->nbinning_subtypes; i++) { in ccs_probe()
3480 sensor->binning_subtypes[i].horizontal = in ccs_probe()
3481 CCS_LIM_AT(sensor, BINNING_SUB_TYPE, i) >> in ccs_probe()
3483 sensor->binning_subtypes[i].vertical = in ccs_probe()
3484 CCS_LIM_AT(sensor, BINNING_SUB_TYPE, i) & in ccs_probe()
3488 sensor->binning_subtypes[i].horizontal, in ccs_probe()
3489 sensor->binning_subtypes[i].vertical); in ccs_probe()
3492 sensor->binning_horizontal = 1; in ccs_probe()
3493 sensor->binning_vertical = 1; in ccs_probe()
3501 if (sensor->minfo.smiapp_version && in ccs_probe()
3502 CCS_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & in ccs_probe()
3511 if (!CCS_LIM(sensor, MIN_OP_SYS_CLK_DIV) || in ccs_probe()
3512 !CCS_LIM(sensor, MAX_OP_SYS_CLK_DIV) || in ccs_probe()
3513 !CCS_LIM(sensor, MIN_OP_PIX_CLK_DIV) || in ccs_probe()
3514 !CCS_LIM(sensor, MAX_OP_PIX_CLK_DIV)) { in ccs_probe()
3516 sensor->pll.flags |= CCS_PLL_FLAG_NO_OP_CLOCKS; in ccs_probe()
3517 } else if (CCS_LIM(sensor, SCALING_CAPABILITY) in ccs_probe()
3519 CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) in ccs_probe()
3522 sensor->scaler = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3523 sensor->ssds_used++; in ccs_probe()
3525 sensor->binner = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3526 sensor->ssds_used++; in ccs_probe()
3527 sensor->pixel_array = &sensor->ssds[sensor->ssds_used]; in ccs_probe()
3528 sensor->ssds_used++; in ccs_probe()
3530 sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); in ccs_probe()
3533 sensor->pll.bus_type = CCS_PLL_BUS_TYPE_CSI2_DPHY; in ccs_probe()
3534 sensor->pll.csi2.lanes = sensor->hwcfg.lanes; in ccs_probe()
3535 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3537 sensor->pll.flags |= CCS_PLL_FLAG_LANE_SPEED_MODEL; in ccs_probe()
3538 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3540 sensor->pll.vt_lanes = in ccs_probe()
3541 CCS_LIM(sensor, NUM_OF_VT_LANES) + 1; in ccs_probe()
3542 sensor->pll.op_lanes = in ccs_probe()
3543 CCS_LIM(sensor, NUM_OF_OP_LANES) + 1; in ccs_probe()
3544 sensor->pll.flags |= CCS_PLL_FLAG_LINK_DECOUPLED; in ccs_probe()
3546 sensor->pll.vt_lanes = sensor->pll.csi2.lanes; in ccs_probe()
3547 sensor->pll.op_lanes = sensor->pll.csi2.lanes; in ccs_probe()
3550 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3552 sensor->pll.flags |= CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER; in ccs_probe()
3553 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3555 sensor->pll.flags |= CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV; in ccs_probe()
3556 if (CCS_LIM(sensor, FIFO_SUPPORT_CAPABILITY) & in ccs_probe()
3558 sensor->pll.flags |= CCS_PLL_FLAG_FIFO_DERATING; in ccs_probe()
3559 if (CCS_LIM(sensor, FIFO_SUPPORT_CAPABILITY) & in ccs_probe()
3561 sensor->pll.flags |= CCS_PLL_FLAG_FIFO_DERATING | in ccs_probe()
3563 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3565 if (CCS_LIM(sensor, CLOCK_TREE_PLL_CAPABILITY) & in ccs_probe()
3569 /* Use sensor default in PLL mode selection */ in ccs_probe()
3570 rval = ccs_read(sensor, PLL_MODE, &v); in ccs_probe()
3575 sensor->pll.flags |= CCS_PLL_FLAG_DUAL_PLL; in ccs_probe()
3577 sensor->pll.flags |= CCS_PLL_FLAG_DUAL_PLL; in ccs_probe()
3579 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3581 sensor->pll.flags |= CCS_PLL_FLAG_OP_SYS_DDR; in ccs_probe()
3582 if (CCS_LIM(sensor, CLOCK_CALCULATION) & in ccs_probe()
3584 sensor->pll.flags |= CCS_PLL_FLAG_OP_PIX_DDR; in ccs_probe()
3586 sensor->pll.op_bits_per_lane = CCS_LIM(sensor, OP_BITS_PER_LANE); in ccs_probe()
3587 sensor->pll.ext_clk_freq_hz = sensor->hwcfg.ext_clk; in ccs_probe()
3588 sensor->pll.scale_n = CCS_LIM(sensor, SCALER_N_MIN); in ccs_probe()
3590 ccs_create_subdev(sensor, sensor->scaler, " scaler", 2, in ccs_probe()
3592 ccs_create_subdev(sensor, sensor->binner, " binner", 2, in ccs_probe()
3594 ccs_create_subdev(sensor, sensor->pixel_array, " pixel_array", 1, in ccs_probe()
3597 rval = ccs_init_controls(sensor); in ccs_probe()
3601 rval = ccs_call_quirk(sensor, init); in ccs_probe()
3605 rval = ccs_get_mbus_formats(sensor); in ccs_probe()
3611 rval = ccs_init_late_controls(sensor); in ccs_probe()
3617 mutex_lock(&sensor->mutex); in ccs_probe()
3618 rval = ccs_pll_blanking_update(sensor); in ccs_probe()
3619 mutex_unlock(&sensor->mutex); in ccs_probe()
3625 sensor->streaming = false; in ccs_probe()
3626 sensor->dev_init_done = true; in ccs_probe()
3628 rval = media_entity_pads_init(&sensor->src->sd.entity, 2, in ccs_probe()
3629 sensor->src->pads); in ccs_probe()
3633 rval = ccs_write_msr_regs(sensor); in ccs_probe()
3641 rval = v4l2_async_register_subdev_sensor(&sensor->src->sd); in ccs_probe()
3656 media_entity_cleanup(&sensor->src->sd.entity); in ccs_probe()
3659 ccs_cleanup(sensor); in ccs_probe()
3662 kvfree(sensor->mdata.backing); in ccs_probe()
3665 kvfree(sensor->sdata.backing); in ccs_probe()
3668 kfree(sensor->ccs_limits); in ccs_probe()
3672 mutex_destroy(&sensor->mutex); in ccs_probe()
3680 struct ccs_sensor *sensor = to_ccs_sensor(subdev); in ccs_remove() local
3690 for (i = 0; i < sensor->ssds_used; i++) { in ccs_remove()
3691 v4l2_device_unregister_subdev(&sensor->ssds[i].sd); in ccs_remove()
3692 media_entity_cleanup(&sensor->ssds[i].sd.entity); in ccs_remove()
3694 ccs_cleanup(sensor); in ccs_remove()
3695 mutex_destroy(&sensor->mutex); in ccs_remove()
3696 kfree(sensor->ccs_limits); in ccs_remove()
3697 kvfree(sensor->sdata.backing); in ccs_remove()
3698 kvfree(sensor->mdata.backing); in ccs_remove()
3773 MODULE_DESCRIPTION("Generic MIPI CCS/SMIA/SMIA++ camera sensor driver");