Lines Matching defs:ov7740
84 struct ov7740 {
273 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
274 struct regmap *regmap = ov7740->regmap;
288 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
289 struct regmap *regmap = ov7740->regmap;
297 static int ov7740_set_power(struct ov7740 *ov7740, int on)
302 ret = clk_prepare_enable(ov7740->xvclk);
306 if (ov7740->pwdn_gpio)
307 gpiod_direction_output(ov7740->pwdn_gpio, 0);
309 if (ov7740->resetb_gpio) {
310 gpiod_set_value(ov7740->resetb_gpio, 1);
312 gpiod_set_value(ov7740->resetb_gpio, 0);
316 clk_disable_unprepare(ov7740->xvclk);
318 if (ov7740->pwdn_gpio)
319 gpiod_direction_output(ov7740->pwdn_gpio, 0);
335 static int ov7740_set_white_balance(struct ov7740 *ov7740, int awb)
337 struct regmap *regmap = ov7740->regmap;
354 ov7740->blue_balance->val);
358 ret = regmap_write(regmap, REG_RGAIN, ov7740->red_balance->val);
430 static int ov7740_get_gain(struct ov7740 *ov7740, struct v4l2_ctrl *ctrl)
432 struct regmap *regmap = ov7740->regmap;
446 ov7740->gain->val = (value1 << 8) | (value0 & 0xff);
451 static int ov7740_get_exp(struct ov7740 *ov7740, struct v4l2_ctrl *ctrl)
453 struct regmap *regmap = ov7740->regmap;
467 ov7740->exposure->val = (value1 << 8) | (value0 & 0xff);
510 struct ov7740 *ov7740 = container_of(ctrl->handler,
511 struct ov7740, ctrl_handler);
516 ret = ov7740_get_gain(ov7740, ctrl);
519 ret = ov7740_get_exp(ov7740, ctrl);
530 struct ov7740 *ov7740 = container_of(ctrl->handler,
531 struct ov7740, ctrl_handler);
532 struct i2c_client *client = v4l2_get_subdevdata(&ov7740->subdev);
533 struct regmap *regmap = ov7740->regmap;
542 ret = ov7740_set_white_balance(ov7740, ctrl->val);
565 ret = ov7740_set_gain(regmap, ov7740->gain->val);
572 ret = ov7740_set_exp(regmap, ov7740->exposure->val);
591 static int ov7740_start_streaming(struct ov7740 *ov7740)
595 if (ov7740->fmt) {
596 ret = regmap_multi_reg_write(ov7740->regmap,
597 ov7740->fmt->regs,
598 ov7740->fmt->reg_num);
603 if (ov7740->frmsize) {
604 ret = regmap_multi_reg_write(ov7740->regmap,
605 ov7740->frmsize->regs,
606 ov7740->frmsize->reg_num);
611 return __v4l2_ctrl_handler_setup(ov7740->subdev.ctrl_handler);
616 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
620 mutex_lock(&ov7740->mutex);
621 if (ov7740->streaming == enable) {
622 mutex_unlock(&ov7740->mutex);
633 ret = ov7740_start_streaming(ov7740);
640 ov7740->streaming = enable;
642 mutex_unlock(&ov7740->mutex);
648 mutex_unlock(&ov7740->mutex);
763 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
800 ov7740->format = *fmt;
809 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
817 mutex_lock(&ov7740->mutex);
831 mutex_unlock(&ov7740->mutex);
839 ov7740->fmt = ovfmt;
840 ov7740->frmsize = fsize;
842 mutex_unlock(&ov7740->mutex);
846 mutex_unlock(&ov7740->mutex);
854 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
860 mutex_lock(&ov7740->mutex);
870 format->format = ov7740->format;
872 mutex_unlock(&ov7740->mutex);
894 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
896 format->width = ov7740->frmsize->width;
897 format->height = ov7740->frmsize->height;
898 format->colorspace = ov7740->fmt->colorspace;
899 format->code = ov7740->fmt->mbus_code;
906 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
910 mutex_lock(&ov7740->mutex);
912 mutex_unlock(&ov7740->mutex);
923 struct ov7740 *ov7740)
925 ov7740->resetb_gpio = devm_gpiod_get_optional(&client->dev, "reset",
927 if (IS_ERR(ov7740->resetb_gpio)) {
929 return PTR_ERR(ov7740->resetb_gpio);
932 ov7740->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
934 if (IS_ERR(ov7740->pwdn_gpio)) {
936 return PTR_ERR(ov7740->pwdn_gpio);
942 static int ov7740_detect(struct ov7740 *ov7740)
944 struct regmap *regmap = ov7740->regmap;
975 static int ov7740_init_controls(struct ov7740 *ov7740)
977 struct i2c_client *client = v4l2_get_subdevdata(&ov7740->subdev);
978 struct v4l2_ctrl_handler *ctrl_hdlr = &ov7740->ctrl_handler;
985 ctrl_hdlr->lock = &ov7740->mutex;
986 ov7740->auto_wb = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
989 ov7740->blue_balance = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
992 ov7740->red_balance = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
996 ov7740->brightness = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
999 ov7740->contrast = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1002 ov7740->saturation = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1004 ov7740->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1006 ov7740->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1009 ov7740->gain = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1012 ov7740->auto_gain = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1015 ov7740->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1018 ov7740->auto_exposure = v4l2_ctrl_new_std_menu(ctrl_hdlr,
1024 v4l2_ctrl_auto_cluster(3, &ov7740->auto_wb, 0, false);
1025 v4l2_ctrl_auto_cluster(2, &ov7740->auto_gain, 0, true);
1026 v4l2_ctrl_auto_cluster(2, &ov7740->auto_exposure,
1043 ov7740->subdev.ctrl_handler = ctrl_hdlr;
1048 mutex_destroy(&ov7740->mutex);
1052 static void ov7740_free_controls(struct ov7740 *ov7740)
1054 v4l2_ctrl_handler_free(ov7740->subdev.ctrl_handler);
1055 mutex_destroy(&ov7740->mutex);
1067 struct ov7740 *ov7740;
1071 ov7740 = devm_kzalloc(&client->dev, sizeof(*ov7740), GFP_KERNEL);
1072 if (!ov7740)
1075 ov7740->xvclk = devm_clk_get(&client->dev, "xvclk");
1076 if (IS_ERR(ov7740->xvclk)) {
1077 ret = PTR_ERR(ov7740->xvclk);
1083 ret = ov7740_probe_dt(client, ov7740);
1087 ov7740->regmap = devm_regmap_init_sccb(client, &ov7740_regmap_config);
1088 if (IS_ERR(ov7740->regmap)) {
1089 ret = PTR_ERR(ov7740->regmap);
1095 sd = &ov7740->subdev;
1104 ov7740->pad.flags = MEDIA_PAD_FL_SOURCE;
1106 ret = media_entity_pads_init(&sd->entity, 1, &ov7740->pad);
1111 ret = ov7740_set_power(ov7740, 1);
1118 ret = ov7740_detect(ov7740);
1122 mutex_init(&ov7740->mutex);
1124 ret = ov7740_init_controls(ov7740);
1131 ov7740->fmt = &ov7740_formats[0];
1132 ov7740->frmsize = &ov7740_framesizes[0];
1134 ov7740_get_default_format(sd, &ov7740->format);
1145 v4l2_ctrl_handler_free(ov7740->subdev.ctrl_handler);
1147 ov7740_free_controls(ov7740);
1151 ov7740_set_power(ov7740, 0);
1152 media_entity_cleanup(&ov7740->subdev.entity);
1160 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
1162 mutex_destroy(&ov7740->mutex);
1163 v4l2_ctrl_handler_free(ov7740->subdev.ctrl_handler);
1164 media_entity_cleanup(&ov7740->subdev.entity);
1166 ov7740_free_controls(ov7740);
1173 ov7740_set_power(ov7740, 0);
1181 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
1183 ov7740_set_power(ov7740, 0);
1192 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
1194 return ov7740_set_power(ov7740, 1);
1198 { "ov7740", 0 },
1208 {.compatible = "ovti,ov7740", },
1215 .name = "ov7740",