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);
631 ret = ov7740_start_streaming(ov7740);
638 ov7740->streaming = enable;
640 mutex_unlock(&ov7740->mutex);
646 mutex_unlock(&ov7740->mutex);
761 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
798 ov7740->format = *fmt;
807 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
815 mutex_lock(&ov7740->mutex);
830 mutex_unlock(&ov7740->mutex);
838 ov7740->fmt = ovfmt;
839 ov7740->frmsize = fsize;
841 mutex_unlock(&ov7740->mutex);
845 mutex_unlock(&ov7740->mutex);
853 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
859 mutex_lock(&ov7740->mutex);
869 format->format = ov7740->format;
871 mutex_unlock(&ov7740->mutex);
893 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
895 format->width = ov7740->frmsize->width;
896 format->height = ov7740->frmsize->height;
897 format->colorspace = ov7740->fmt->colorspace;
898 format->code = ov7740->fmt->mbus_code;
905 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
909 mutex_lock(&ov7740->mutex);
911 mutex_unlock(&ov7740->mutex);
922 struct ov7740 *ov7740)
924 ov7740->resetb_gpio = devm_gpiod_get_optional(&client->dev, "reset",
926 if (IS_ERR(ov7740->resetb_gpio)) {
928 return PTR_ERR(ov7740->resetb_gpio);
931 ov7740->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
933 if (IS_ERR(ov7740->pwdn_gpio)) {
935 return PTR_ERR(ov7740->pwdn_gpio);
941 static int ov7740_detect(struct ov7740 *ov7740)
943 struct regmap *regmap = ov7740->regmap;
974 static int ov7740_init_controls(struct ov7740 *ov7740)
976 struct i2c_client *client = v4l2_get_subdevdata(&ov7740->subdev);
977 struct v4l2_ctrl_handler *ctrl_hdlr = &ov7740->ctrl_handler;
984 ctrl_hdlr->lock = &ov7740->mutex;
985 ov7740->auto_wb = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
988 ov7740->blue_balance = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
991 ov7740->red_balance = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
995 ov7740->brightness = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
998 ov7740->contrast = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1001 ov7740->saturation = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1003 ov7740->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1005 ov7740->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1008 ov7740->gain = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1011 ov7740->auto_gain = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1014 ov7740->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov7740_ctrl_ops,
1017 ov7740->auto_exposure = v4l2_ctrl_new_std_menu(ctrl_hdlr,
1023 v4l2_ctrl_auto_cluster(3, &ov7740->auto_wb, 0, false);
1024 v4l2_ctrl_auto_cluster(2, &ov7740->auto_gain, 0, true);
1025 v4l2_ctrl_auto_cluster(2, &ov7740->auto_exposure,
1042 ov7740->subdev.ctrl_handler = ctrl_hdlr;
1047 mutex_destroy(&ov7740->mutex);
1051 static void ov7740_free_controls(struct ov7740 *ov7740)
1053 v4l2_ctrl_handler_free(ov7740->subdev.ctrl_handler);
1054 mutex_destroy(&ov7740->mutex);
1066 struct ov7740 *ov7740;
1070 ov7740 = devm_kzalloc(&client->dev, sizeof(*ov7740), GFP_KERNEL);
1071 if (!ov7740)
1074 ov7740->xvclk = devm_clk_get(&client->dev, "xvclk");
1075 if (IS_ERR(ov7740->xvclk)) {
1076 ret = PTR_ERR(ov7740->xvclk);
1082 ret = ov7740_probe_dt(client, ov7740);
1086 ov7740->regmap = devm_regmap_init_sccb(client, &ov7740_regmap_config);
1087 if (IS_ERR(ov7740->regmap)) {
1088 ret = PTR_ERR(ov7740->regmap);
1094 sd = &ov7740->subdev;
1103 ov7740->pad.flags = MEDIA_PAD_FL_SOURCE;
1105 ret = media_entity_pads_init(&sd->entity, 1, &ov7740->pad);
1110 ret = ov7740_set_power(ov7740, 1);
1117 ret = ov7740_detect(ov7740);
1121 mutex_init(&ov7740->mutex);
1123 ret = ov7740_init_controls(ov7740);
1130 ov7740->fmt = &ov7740_formats[0];
1131 ov7740->frmsize = &ov7740_framesizes[0];
1133 ov7740_get_default_format(sd, &ov7740->format);
1144 v4l2_ctrl_handler_free(ov7740->subdev.ctrl_handler);
1146 ov7740_free_controls(ov7740);
1150 ov7740_set_power(ov7740, 0);
1151 media_entity_cleanup(&ov7740->subdev.entity);
1159 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
1161 mutex_destroy(&ov7740->mutex);
1162 v4l2_ctrl_handler_free(ov7740->subdev.ctrl_handler);
1163 media_entity_cleanup(&ov7740->subdev.entity);
1165 ov7740_free_controls(ov7740);
1172 ov7740_set_power(ov7740, 0);
1178 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
1180 ov7740_set_power(ov7740, 0);
1188 struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev);
1190 return ov7740_set_power(ov7740, 1);
1194 { "ov7740", 0 },
1204 {.compatible = "ovti,ov7740", },
1211 .name = "ov7740",