• Home
  • Raw
  • Download

Lines Matching +full:bias +full:- +full:ctrl +full:- +full:value

27 #include <media/media-entity.h>
28 #include <media/v4l2-async.h>
29 #include <media/v4l2-ctrls.h>
30 #include <media/v4l2-device.h>
31 #include <media/v4l2-event.h>
32 #include <media/v4l2-image-sizes.h>
33 #include <media/v4l2-subdev.h>
34 #include <media/v4l2-mediabus.h>
39 MODULE_PARM_DESC(debug, "Debug level (0-2)");
47 #define REG_BLUE 0x01 /* AWB - Blue chanel gain */
48 #define REG_RED 0x02 /* AWB - Red chanel gain */
49 #define REG_VREF 0x03 /* [7:6] - AGC[9:8], [5:3]/[2:0] */
50 #define VREF_GAIN_MASK 0xc0 /* - VREF end/start low 3 bits */
69 #define REG_AECH 0x10 /* Exposure value, AEC[9:2] */
117 #define REG_BBIAS 0x27 /* B channel output bias */
118 #define REG_GBBIAS 0x28 /* Gb channel output bias */
122 #define REG_RBIAS 0x2c /* R channel output bias */
125 #define REG_YAVE 0x2f /* Y/G channel average value */
135 #define TSLB_YUYV_MASK 0x0c /* UYVY or VYUY - see com13 */
146 #define COM13_UVSWAP 0x01 /* V before U - w/TSLB */
162 #define REG_MTX(__n) (0x4f + (__n) - 1)
165 #define REG_LCC(__n) (0x62 + (__n) - 1)
168 #define REG_MANU 0x67 /* Manual U value */
169 #define REG_MANV 0x68 /* Manual V value */
171 #define REG_MBD 0x6a /* Manual banding filter value */
193 #define REG_AECHM 0xa1 /* Exposure value - bits AEC[15:10] */
194 #define REG_BD50ST 0xa2 /* Banding filter value for 50Hz */
195 #define REG_BD60ST 0xa3 /* Banding filter value for 60Hz */
285 u8 value; member
393 /* REG_TSLB value, only bits [3:2] may be set. */
417 static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl) in ctrl_to_sd() argument
419 return &container_of(ctrl->handler, struct ov965x, ctrls.handler)->sd; in ctrl_to_sd()
431 .addr = client->addr, in ov965x_read()
438 ret = i2c_transfer(client->adapter, &msg, 1); in ov965x_read()
441 ret = i2c_transfer(client->adapter, &msg, 1); in ov965x_read()
471 ret = ov965x_write(client, regs[i].addr, regs[i].value); in ov965x_write_array()
489 int ret = ov965x_write(ov965x->client, addr, gamma_curve[i]); in ov965x_set_default_gamma_curve()
509 int ret = ov965x_write(ov965x->client, addr, mtx[i]); in ov965x_set_color_matrix()
522 int ret = clk_prepare_enable(ov965x->clk); in __ov965x_set_power()
527 gpiod_set_value_cansleep(ov965x->gpios[GPIO_PWDN], 0); in __ov965x_set_power()
528 gpiod_set_value_cansleep(ov965x->gpios[GPIO_RST], 0); in __ov965x_set_power()
531 gpiod_set_value_cansleep(ov965x->gpios[GPIO_RST], 1); in __ov965x_set_power()
532 gpiod_set_value_cansleep(ov965x->gpios[GPIO_PWDN], 1); in __ov965x_set_power()
534 clk_disable_unprepare(ov965x->clk); in __ov965x_set_power()
537 ov965x->streaming = 0; in __ov965x_set_power()
545 struct i2c_client *client = ov965x->client; in ov965x_s_power()
550 mutex_lock(&ov965x->lock); in ov965x_s_power()
551 if (ov965x->power == !on) { in ov965x_s_power()
556 ov965x->apply_frame_fmt = 1; in ov965x_s_power()
557 ov965x->ctrls.update = 1; in ov965x_s_power()
561 ov965x->power += on ? 1 : -1; in ov965x_s_power()
563 WARN_ON(ov965x->power < 0); in ov965x_s_power()
564 mutex_unlock(&ov965x->lock); in ov965x_s_power()
574 struct v4l2_ctrl *ctrl = ov965x->ctrls.exposure; in ov965x_update_exposure_ctrl() local
579 mutex_lock(&ov965x->lock); in ov965x_update_exposure_ctrl()
580 if (WARN_ON(!ctrl || !ov965x->frame_size)) { in ov965x_update_exposure_ctrl()
581 mutex_unlock(&ov965x->lock); in ov965x_update_exposure_ctrl()
584 clkrc = DEF_CLKRC + ov965x->fiv->clkrc_div; in ov965x_update_exposure_ctrl()
586 fint = ov965x->mclk_frequency * ((clkrc >> 7) + 1) / in ov965x_update_exposure_ctrl()
590 max = ov965x->frame_size->max_exp_lines * trow; in ov965x_update_exposure_ctrl()
591 ov965x->exp_row_interval = trow; in ov965x_update_exposure_ctrl()
592 mutex_unlock(&ov965x->lock); in ov965x_update_exposure_ctrl()
594 v4l2_dbg(1, debug, &ov965x->sd, "clkrc: %#x, fi: %lu, tr: %lu, %d\n", in ov965x_update_exposure_ctrl()
599 max = (max - 100) / 100; in ov965x_update_exposure_ctrl()
600 def = min + (max - min) / 2; in ov965x_update_exposure_ctrl()
602 if (v4l2_ctrl_modify_range(ctrl, min, max, 1, def)) in ov965x_update_exposure_ctrl()
603 v4l2_err(&ov965x->sd, "Exposure ctrl range update failed\n"); in ov965x_update_exposure_ctrl()
606 static int ov965x_set_banding_filter(struct ov965x *ov965x, int value) in ov965x_set_banding_filter() argument
612 ret = ov965x_read(ov965x->client, REG_COM8, &reg); in ov965x_set_banding_filter()
614 if (value == V4L2_CID_POWER_LINE_FREQUENCY_DISABLED) in ov965x_set_banding_filter()
618 ret = ov965x_write(ov965x->client, REG_COM8, reg); in ov965x_set_banding_filter()
620 if (value == V4L2_CID_POWER_LINE_FREQUENCY_DISABLED) in ov965x_set_banding_filter()
622 if (WARN_ON(!ov965x->fiv)) in ov965x_set_banding_filter()
623 return -EINVAL; in ov965x_set_banding_filter()
625 if (value == V4L2_CID_POWER_LINE_FREQUENCY_50HZ) in ov965x_set_banding_filter()
629 mbd = (1000UL * ov965x->fiv->interval.denominator * in ov965x_set_banding_filter()
630 ov965x->frame_size->max_exp_lines) / in ov965x_set_banding_filter()
631 ov965x->fiv->interval.numerator; in ov965x_set_banding_filter()
634 return ov965x_write(ov965x->client, REG_MBD, mbd); in ov965x_set_banding_filter()
642 ret = ov965x_read(ov965x->client, REG_COM8, &reg); in ov965x_set_white_balance()
645 ret = ov965x_write(ov965x->client, REG_COM8, reg); in ov965x_set_white_balance()
648 ret = ov965x_write(ov965x->client, REG_BLUE, in ov965x_set_white_balance()
649 ov965x->ctrls.blue_balance->val); in ov965x_set_white_balance()
652 ret = ov965x_write(ov965x->client, REG_RED, in ov965x_set_white_balance()
653 ov965x->ctrls.red_balance->val); in ov965x_set_white_balance()
665 { 0x1c, 0x12, 0x50 }, /* -3 */ in ov965x_set_brightness()
666 { 0x3d, 0x30, 0x71 }, /* -2 */ in ov965x_set_brightness()
667 { 0x50, 0x44, 0x92 }, /* -1 */ in ov965x_set_brightness()
677 return -EINVAL; in ov965x_set_brightness()
680 ret = ov965x_write(ov965x->client, regs[0][i], in ov965x_set_brightness()
687 struct i2c_client *client = ov965x->client; in ov965x_set_gain()
688 struct ov965x_ctrls *ctrls = &ov965x->ctrls; in ov965x_set_gain()
693 * gain value in REG_VREF, REG_GAIN is not overwritten. in ov965x_set_gain()
695 if (ctrls->auto_gain->is_new) { in ov965x_set_gain()
699 if (ctrls->auto_gain->val) in ov965x_set_gain()
708 if (ctrls->gain->is_new && !auto_gain) { in ov965x_set_gain()
709 unsigned int gain = ctrls->gain->val; in ov965x_set_gain()
713 * Convert gain control value to the sensor's gain in ov965x_set_gain()
716 for (m = 6; m >= 0; m--) in ov965x_set_gain()
720 /* Sanity check: don't adjust the gain with a negative value */ in ov965x_set_gain()
722 return -EINVAL; in ov965x_set_gain()
724 rgain = (gain - ((1 << m) * 16)) / (1 << m); in ov965x_set_gain()
725 rgain |= (((1 << m) - 1) << 4); in ov965x_set_gain()
738 /* Return updated control's value to userspace */ in ov965x_set_gain()
739 ctrls->gain->val = (1 << m) * (16 + (rgain & 0xf)); in ov965x_set_gain()
745 static int ov965x_set_sharpness(struct ov965x *ov965x, unsigned int value) in ov965x_set_sharpness() argument
750 ret = ov965x_read(ov965x->client, REG_COM14, &com14); in ov965x_set_sharpness()
753 ret = ov965x_read(ov965x->client, REG_EDGE, &edge); in ov965x_set_sharpness()
756 com14 = value ? com14 | COM14_EDGE_EN : com14 & ~COM14_EDGE_EN; in ov965x_set_sharpness()
757 value--; in ov965x_set_sharpness()
758 if (value > 0x0f) { in ov965x_set_sharpness()
760 value >>= 1; in ov965x_set_sharpness()
764 ret = ov965x_write(ov965x->client, REG_COM14, com14); in ov965x_set_sharpness()
769 edge |= ((u8)value & 0x0f); in ov965x_set_sharpness()
771 return ov965x_write(ov965x->client, REG_EDGE, edge); in ov965x_set_sharpness()
776 struct i2c_client *client = ov965x->client; in ov965x_set_exposure()
777 struct ov965x_ctrls *ctrls = &ov965x->ctrls; in ov965x_set_exposure()
782 if (ctrls->auto_exp->is_new) { in ov965x_set_exposure()
795 if (!auto_exposure && ctrls->exposure->is_new) { in ov965x_set_exposure()
796 unsigned int exposure = (ctrls->exposure->val * 100) in ov965x_set_exposure()
797 / ov965x->exp_row_interval; in ov965x_set_exposure()
799 * Manual exposure value in ov965x_set_exposure()
800 * [b15:b0] - AECHM (b15:b10), AECH (b9:b2), COM1 (b1:b0) in ov965x_set_exposure()
809 /* Update the value to minimize rounding errors */ in ov965x_set_exposure()
810 ctrls->exposure->val = ((exposure * ov965x->exp_row_interval) in ov965x_set_exposure()
816 v4l2_ctrl_activate(ov965x->ctrls.brightness, !exp); in ov965x_set_exposure()
824 if (ov965x->ctrls.hflip->val) in ov965x_set_flip()
827 if (ov965x->ctrls.vflip->val) in ov965x_set_flip()
830 return ov965x_write(ov965x->client, REG_MVFP, mvfp); in ov965x_set_flip()
840 { 0x1d, 0x1f, 0x02, 0x09, 0x13, 0x1c }, /* -2 */ in ov965x_set_saturation()
841 { 0x2e, 0x31, 0x02, 0x0e, 0x1e, 0x2d }, /* -1 */ in ov965x_set_saturation()
851 return -EINVAL; in ov965x_set_saturation()
854 ret = ov965x_write(ov965x->client, addr + i, regs[val][i]); in ov965x_set_saturation()
859 static int ov965x_set_test_pattern(struct ov965x *ov965x, int value) in ov965x_set_test_pattern() argument
864 ret = ov965x_read(ov965x->client, REG_COM23, &reg); in ov965x_set_test_pattern()
867 reg = value ? reg | COM23_TEST_MODE : reg & ~COM23_TEST_MODE; in ov965x_set_test_pattern()
868 return ov965x_write(ov965x->client, REG_COM23, reg); in ov965x_set_test_pattern()
871 static int __g_volatile_ctrl(struct ov965x *ov965x, struct v4l2_ctrl *ctrl) in __g_volatile_ctrl() argument
873 struct i2c_client *client = ov965x->client; in __g_volatile_ctrl()
878 if (!ov965x->power) in __g_volatile_ctrl()
881 switch (ctrl->id) { in __g_volatile_ctrl()
883 if (!ctrl->val) in __g_volatile_ctrl()
893 ov965x->ctrls.gain->val = m * (16 + (gain & 0xf)); in __g_volatile_ctrl()
897 if (ctrl->val == V4L2_EXPOSURE_MANUAL) in __g_volatile_ctrl()
910 ov965x->ctrls.exposure->val = ((exposure * in __g_volatile_ctrl()
911 ov965x->exp_row_interval) + 50) / 100; in __g_volatile_ctrl()
918 static int ov965x_g_volatile_ctrl(struct v4l2_ctrl *ctrl) in ov965x_g_volatile_ctrl() argument
920 struct v4l2_subdev *sd = ctrl_to_sd(ctrl); in ov965x_g_volatile_ctrl()
924 v4l2_dbg(1, debug, sd, "g_ctrl: %s\n", ctrl->name); in ov965x_g_volatile_ctrl()
926 mutex_lock(&ov965x->lock); in ov965x_g_volatile_ctrl()
927 ret = __g_volatile_ctrl(ov965x, ctrl); in ov965x_g_volatile_ctrl()
928 mutex_unlock(&ov965x->lock); in ov965x_g_volatile_ctrl()
932 static int ov965x_s_ctrl(struct v4l2_ctrl *ctrl) in ov965x_s_ctrl() argument
934 struct v4l2_subdev *sd = ctrl_to_sd(ctrl); in ov965x_s_ctrl()
936 int ret = -EINVAL; in ov965x_s_ctrl()
938 v4l2_dbg(1, debug, sd, "s_ctrl: %s, value: %d. power: %d\n", in ov965x_s_ctrl()
939 ctrl->name, ctrl->val, ov965x->power); in ov965x_s_ctrl()
941 mutex_lock(&ov965x->lock); in ov965x_s_ctrl()
944 * value to the hardware, until it is ready to accept commands. in ov965x_s_ctrl()
946 if (ov965x->power == 0) { in ov965x_s_ctrl()
947 mutex_unlock(&ov965x->lock); in ov965x_s_ctrl()
951 switch (ctrl->id) { in ov965x_s_ctrl()
953 ret = ov965x_set_white_balance(ov965x, ctrl->val); in ov965x_s_ctrl()
957 ret = ov965x_set_brightness(ov965x, ctrl->val); in ov965x_s_ctrl()
961 ret = ov965x_set_exposure(ov965x, ctrl->val); in ov965x_s_ctrl()
965 ret = ov965x_set_gain(ov965x, ctrl->val); in ov965x_s_ctrl()
973 ret = ov965x_set_banding_filter(ov965x, ctrl->val); in ov965x_s_ctrl()
977 ret = ov965x_set_saturation(ov965x, ctrl->val); in ov965x_s_ctrl()
981 ret = ov965x_set_sharpness(ov965x, ctrl->val); in ov965x_s_ctrl()
985 ret = ov965x_set_test_pattern(ov965x, ctrl->val); in ov965x_s_ctrl()
989 mutex_unlock(&ov965x->lock); in ov965x_s_ctrl()
1006 struct ov965x_ctrls *ctrls = &ov965x->ctrls; in ov965x_initialize_controls()
1007 struct v4l2_ctrl_handler *hdl = &ctrls->handler; in ov965x_initialize_controls()
1015 ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops, in ov965x_initialize_controls()
1018 ctrls->blue_balance = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BLUE_BALANCE, in ov965x_initialize_controls()
1020 ctrls->red_balance = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_RED_BALANCE, in ov965x_initialize_controls()
1023 ctrls->auto_exp = in ov965x_initialize_controls()
1029 ctrls->exposure = v4l2_ctrl_new_std(hdl, ops, in ov965x_initialize_controls()
1033 ctrls->auto_gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_AUTOGAIN, in ov965x_initialize_controls()
1035 ctrls->gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAIN, in ov965x_initialize_controls()
1038 ctrls->saturation = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SATURATION, in ov965x_initialize_controls()
1039 -2, 2, 1, 0); in ov965x_initialize_controls()
1040 ctrls->brightness = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, in ov965x_initialize_controls()
1041 -3, 3, 1, 0); in ov965x_initialize_controls()
1042 ctrls->sharpness = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SHARPNESS, in ov965x_initialize_controls()
1045 ctrls->hflip = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HFLIP, 0, 1, 1, 0); in ov965x_initialize_controls()
1046 ctrls->vflip = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_VFLIP, 0, 1, 1, 0); in ov965x_initialize_controls()
1048 ctrls->light_freq = in ov965x_initialize_controls()
1055 ARRAY_SIZE(test_pattern_menu) - 1, 0, 0, in ov965x_initialize_controls()
1057 if (hdl->error) { in ov965x_initialize_controls()
1058 ret = hdl->error; in ov965x_initialize_controls()
1063 ctrls->gain->flags |= V4L2_CTRL_FLAG_VOLATILE; in ov965x_initialize_controls()
1064 ctrls->exposure->flags |= V4L2_CTRL_FLAG_VOLATILE; in ov965x_initialize_controls()
1066 v4l2_ctrl_auto_cluster(3, &ctrls->auto_wb, 0, false); in ov965x_initialize_controls()
1067 v4l2_ctrl_auto_cluster(2, &ctrls->auto_gain, 0, true); in ov965x_initialize_controls()
1068 v4l2_ctrl_auto_cluster(2, &ctrls->auto_exp, 1, true); in ov965x_initialize_controls()
1069 v4l2_ctrl_cluster(2, &ctrls->hflip); in ov965x_initialize_controls()
1071 ov965x->sd.ctrl_handler = hdl; in ov965x_initialize_controls()
1080 mf->width = ov965x_framesizes[0].width; in ov965x_get_default_format()
1081 mf->height = ov965x_framesizes[0].height; in ov965x_get_default_format()
1082 mf->colorspace = ov965x_formats[0].colorspace; in ov965x_get_default_format()
1083 mf->code = ov965x_formats[0].code; in ov965x_get_default_format()
1084 mf->field = V4L2_FIELD_NONE; in ov965x_get_default_format()
1091 if (code->index >= ARRAY_SIZE(ov965x_formats)) in ov965x_enum_mbus_code()
1092 return -EINVAL; in ov965x_enum_mbus_code()
1094 code->code = ov965x_formats[code->index].code; in ov965x_enum_mbus_code()
1104 if (fse->index >= ARRAY_SIZE(ov965x_framesizes)) in ov965x_enum_frame_sizes()
1105 return -EINVAL; in ov965x_enum_frame_sizes()
1107 while (--i) in ov965x_enum_frame_sizes()
1108 if (fse->code == ov965x_formats[i].code) in ov965x_enum_frame_sizes()
1111 fse->code = ov965x_formats[i].code; in ov965x_enum_frame_sizes()
1113 fse->min_width = ov965x_framesizes[fse->index].width; in ov965x_enum_frame_sizes()
1114 fse->max_width = fse->min_width; in ov965x_enum_frame_sizes()
1115 fse->max_height = ov965x_framesizes[fse->index].height; in ov965x_enum_frame_sizes()
1116 fse->min_height = fse->max_height; in ov965x_enum_frame_sizes()
1126 mutex_lock(&ov965x->lock); in ov965x_g_frame_interval()
1127 fi->interval = ov965x->fiv->interval; in ov965x_g_frame_interval()
1128 mutex_unlock(&ov965x->lock); in ov965x_g_frame_interval()
1136 struct v4l2_mbus_framefmt *mbus_fmt = &ov965x->format; in __ov965x_set_frame_interval()
1141 if (fi->interval.denominator == 0) in __ov965x_set_frame_interval()
1142 return -EINVAL; in __ov965x_set_frame_interval()
1144 req_int = (u64)fi->interval.numerator * 10000; in __ov965x_set_frame_interval()
1145 do_div(req_int, fi->interval.denominator); in __ov965x_set_frame_interval()
1150 if (mbus_fmt->width != iv->size.width || in __ov965x_set_frame_interval()
1151 mbus_fmt->height != iv->size.height) in __ov965x_set_frame_interval()
1153 err = abs((u64)(iv->interval.numerator * 10000) / in __ov965x_set_frame_interval()
1154 iv->interval.denominator - req_int); in __ov965x_set_frame_interval()
1160 ov965x->fiv = fiv; in __ov965x_set_frame_interval()
1162 v4l2_dbg(1, debug, &ov965x->sd, "Changed frame interval to %u us\n", in __ov965x_set_frame_interval()
1163 fiv->interval.numerator * 1000000 / fiv->interval.denominator); in __ov965x_set_frame_interval()
1175 fi->interval.numerator, fi->interval.denominator); in ov965x_s_frame_interval()
1177 mutex_lock(&ov965x->lock); in ov965x_s_frame_interval()
1179 ov965x->apply_frame_fmt = 1; in ov965x_s_frame_interval()
1180 mutex_unlock(&ov965x->lock); in ov965x_s_frame_interval()
1191 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { in ov965x_get_fmt()
1193 fmt->format = *mf; in ov965x_get_fmt()
1197 mutex_lock(&ov965x->lock); in ov965x_get_fmt()
1198 fmt->format = ov965x->format; in ov965x_get_fmt()
1199 mutex_unlock(&ov965x->lock); in ov965x_get_fmt()
1212 while (i--) { in __ov965x_try_frame_size()
1213 int err = abs(fsize->width - mf->width) in __ov965x_try_frame_size()
1214 + abs(fsize->height - mf->height); in __ov965x_try_frame_size()
1223 mf->width = match->width; in __ov965x_try_frame_size()
1224 mf->height = match->height; in __ov965x_try_frame_size()
1234 struct v4l2_mbus_framefmt *mf = &fmt->format; in ov965x_set_fmt()
1241 while (--index) in ov965x_set_fmt()
1242 if (ov965x_formats[index].code == mf->code) in ov965x_set_fmt()
1245 mf->colorspace = V4L2_COLORSPACE_JPEG; in ov965x_set_fmt()
1246 mf->code = ov965x_formats[index].code; in ov965x_set_fmt()
1247 mf->field = V4L2_FIELD_NONE; in ov965x_set_fmt()
1249 mutex_lock(&ov965x->lock); in ov965x_set_fmt()
1251 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { in ov965x_set_fmt()
1253 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); in ov965x_set_fmt()
1254 *mf = fmt->format; in ov965x_set_fmt()
1257 if (ov965x->streaming) { in ov965x_set_fmt()
1258 ret = -EBUSY; in ov965x_set_fmt()
1260 ov965x->frame_size = size; in ov965x_set_fmt()
1261 ov965x->format = fmt->format; in ov965x_set_fmt()
1262 ov965x->tslb_reg = ov965x_formats[index].tslb_reg; in ov965x_set_fmt()
1263 ov965x->apply_frame_fmt = 1; in ov965x_set_fmt()
1267 if (!ret && fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { in ov965x_set_fmt()
1274 mutex_unlock(&ov965x->lock); in ov965x_set_fmt()
1287 ret = ov965x_write(ov965x->client, frame_size_reg_addr[i], in ov965x_set_frame_size()
1288 ov965x->frame_size->regs[i]); in ov965x_set_frame_size()
1294 struct i2c_client *client = ov965x->client; in __ov965x_set_params()
1295 struct ov965x_ctrls *ctrls = &ov965x->ctrls; in __ov965x_set_params()
1299 if (ov965x->apply_frame_fmt) { in __ov965x_set_params()
1300 reg = DEF_CLKRC + ov965x->fiv->clkrc_div; in __ov965x_set_params()
1311 reg |= ov965x->tslb_reg; in __ov965x_set_params()
1333 * Banding filter (REG_MBD value) needs to match selected in __ov965x_set_params()
1336 return ov965x_set_banding_filter(ov965x, ctrls->light_freq->val); in __ov965x_set_params()
1343 struct ov965x_ctrls *ctrls = &ov965x->ctrls; in ov965x_s_stream()
1348 mutex_lock(&ov965x->lock); in ov965x_s_stream()
1349 if (ov965x->streaming == !on) { in ov965x_s_stream()
1353 if (!ret && ctrls->update) { in ov965x_s_stream()
1358 mutex_unlock(&ov965x->lock); in ov965x_s_stream()
1359 ret = v4l2_ctrl_handler_setup(&ctrls->handler); in ov965x_s_stream()
1361 mutex_lock(&ov965x->lock); in ov965x_s_stream()
1363 ctrls->update = 0; in ov965x_s_stream()
1370 ov965x->streaming += on ? 1 : -1; in ov965x_s_stream()
1372 WARN_ON(ov965x->streaming < 0); in ov965x_s_stream()
1373 mutex_unlock(&ov965x->lock); in ov965x_s_stream()
1384 v4l2_subdev_get_try_format(sd, fh->pad, 0); in ov965x_open()
1430 gpios[GPIO_PWDN] = pdata->gpio_pwdn; in ov965x_configure_gpios_pdata()
1431 gpios[GPIO_RST] = pdata->gpio_reset; in ov965x_configure_gpios_pdata()
1433 for (i = 0; i < ARRAY_SIZE(ov965x->gpios); i++) { in ov965x_configure_gpios_pdata()
1438 ret = devm_gpio_request_one(&ov965x->client->dev, gpio, in ov965x_configure_gpios_pdata()
1442 v4l2_dbg(1, debug, &ov965x->sd, "set gpio %d to 1\n", gpio); in ov965x_configure_gpios_pdata()
1446 ov965x->gpios[i] = gpio_to_desc(gpio); in ov965x_configure_gpios_pdata()
1454 struct device *dev = &ov965x->client->dev; in ov965x_configure_gpios()
1456 ov965x->gpios[GPIO_PWDN] = devm_gpiod_get_optional(dev, "powerdown", in ov965x_configure_gpios()
1458 if (IS_ERR(ov965x->gpios[GPIO_PWDN])) { in ov965x_configure_gpios()
1460 return PTR_ERR(ov965x->gpios[GPIO_PWDN]); in ov965x_configure_gpios()
1463 ov965x->gpios[GPIO_RST] = devm_gpiod_get_optional(dev, "reset", in ov965x_configure_gpios()
1465 if (IS_ERR(ov965x->gpios[GPIO_RST])) { in ov965x_configure_gpios()
1467 return PTR_ERR(ov965x->gpios[GPIO_RST]); in ov965x_configure_gpios()
1480 mutex_lock(&ov965x->lock); in ov965x_detect_sensor()
1495 ov965x->id = OV965X_ID(pid, ver); in ov965x_detect_sensor()
1496 if (ov965x->id == OV9650_ID || ov965x->id == OV9652_ID) { in ov965x_detect_sensor()
1497 v4l2_info(sd, "Found OV%04X sensor\n", ov965x->id); in ov965x_detect_sensor()
1500 ov965x->id, ret); in ov965x_detect_sensor()
1501 ret = -ENODEV; in ov965x_detect_sensor()
1505 mutex_unlock(&ov965x->lock); in ov965x_detect_sensor()
1513 const struct ov9650_platform_data *pdata = client->dev.platform_data; in ov965x_probe()
1518 ov965x = devm_kzalloc(&client->dev, sizeof(*ov965x), GFP_KERNEL); in ov965x_probe()
1520 return -ENOMEM; in ov965x_probe()
1522 ov965x->client = client; in ov965x_probe()
1525 if (pdata->mclk_frequency == 0) { in ov965x_probe()
1526 dev_err(&client->dev, "MCLK frequency not specified\n"); in ov965x_probe()
1527 return -EINVAL; in ov965x_probe()
1529 ov965x->mclk_frequency = pdata->mclk_frequency; in ov965x_probe()
1534 } else if (dev_fwnode(&client->dev)) { in ov965x_probe()
1535 ov965x->clk = devm_clk_get(&ov965x->client->dev, NULL); in ov965x_probe()
1536 if (IS_ERR(ov965x->clk)) in ov965x_probe()
1537 return PTR_ERR(ov965x->clk); in ov965x_probe()
1538 ov965x->mclk_frequency = clk_get_rate(ov965x->clk); in ov965x_probe()
1544 dev_err(&client->dev, in ov965x_probe()
1547 return -EINVAL; in ov965x_probe()
1550 mutex_init(&ov965x->lock); in ov965x_probe()
1552 sd = &ov965x->sd; in ov965x_probe()
1554 strlcpy(sd->name, DRIVER_NAME, sizeof(sd->name)); in ov965x_probe()
1556 sd->internal_ops = &ov965x_sd_internal_ops; in ov965x_probe()
1557 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in ov965x_probe()
1560 ov965x->pad.flags = MEDIA_PAD_FL_SOURCE; in ov965x_probe()
1561 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov965x_probe()
1562 ret = media_entity_pads_init(&sd->entity, 1, &ov965x->pad); in ov965x_probe()
1570 ov965x_get_default_format(&ov965x->format); in ov965x_probe()
1571 ov965x->frame_size = &ov965x_framesizes[0]; in ov965x_probe()
1572 ov965x->fiv = &ov965x_intervals[0]; in ov965x_probe()
1587 v4l2_ctrl_handler_free(sd->ctrl_handler); in ov965x_probe()
1589 media_entity_cleanup(&sd->entity); in ov965x_probe()
1591 mutex_destroy(&ov965x->lock); in ov965x_probe()
1601 v4l2_ctrl_handler_free(sd->ctrl_handler); in ov965x_remove()
1602 media_entity_cleanup(&sd->entity); in ov965x_remove()
1603 mutex_destroy(&ov965x->lock); in ov965x_remove()