Lines Matching defs:ov08d10
68 #define to_ov08d10(_sd) container_of(_sd, struct ov08d10, sd)
517 struct ov08d10 {
615 static u32 ov08d10_get_format_code(struct ov08d10 *ov08d10)
622 return codes[ov08d10->vflip->val][ov08d10->hflip->val];
625 static unsigned int ov08d10_modes_num(const struct ov08d10 *ov08d10)
629 for (i = 0; i < ARRAY_SIZE(ov08d10->priv_lane->sp_modes); i++) {
630 if (ov08d10->priv_lane->sp_modes[i].width == 0)
658 static int ov08d10_write_reg_list(struct ov08d10 *ov08d10,
661 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
679 static int ov08d10_update_analog_gain(struct ov08d10 *ov08d10, u32 a_gain)
681 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
700 static int ov08d10_update_digital_gain(struct ov08d10 *ov08d10, u32 d_gain)
702 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
727 static int ov08d10_set_exposure(struct ov08d10 *ov08d10, u32 exposure)
729 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
735 cur_vts = ov08d10->cur_mode->vts_def;
770 static int ov08d10_set_vblank(struct ov08d10 *ov08d10, u32 vblank)
772 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
796 static int ov08d10_test_pattern(struct ov08d10 *ov08d10, u32 pattern)
798 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
821 static int ov08d10_set_ctrl_flip(struct ov08d10 *ov08d10, u32 ctrl_val)
823 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
853 struct ov08d10 *ov08d10 = container_of(ctrl->handler,
854 struct ov08d10, ctrl_handler);
855 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
862 exposure_max = ov08d10->cur_mode->height + ctrl->val -
864 __v4l2_ctrl_modify_range(ov08d10->exposure,
865 ov08d10->exposure->minimum,
866 exposure_max, ov08d10->exposure->step,
876 ret = ov08d10_update_analog_gain(ov08d10, ctrl->val);
880 ret = ov08d10_update_digital_gain(ov08d10, ctrl->val);
884 ret = ov08d10_set_exposure(ov08d10, ctrl->val);
888 ret = ov08d10_set_vblank(ov08d10, ctrl->val);
892 ret = ov08d10_test_pattern(ov08d10, ctrl->val);
897 ret = ov08d10_set_ctrl_flip(ov08d10,
898 ov08d10->hflip->val |
899 ov08d10->vflip->val << 1);
916 static int ov08d10_init_controls(struct ov08d10 *ov08d10)
928 ctrl_hdlr = &ov08d10->ctrl_handler;
933 ctrl_hdlr->lock = &ov08d10->mutex;
934 link_freq_size = ARRAY_SIZE(ov08d10->priv_lane->link_freq_menu);
935 ov08d10->link_freq =
940 ov08d10->priv_lane->link_freq_menu);
941 if (ov08d10->link_freq)
942 ov08d10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
944 pixel_rate_max = to_rate(ov08d10->priv_lane->link_freq_menu, 0,
945 ov08d10->cur_mode->data_lanes);
946 ov08d10->pixel_rate =
951 mode = ov08d10->cur_mode;
954 ov08d10->vblank =
960 h_blank = to_pixels_per_line(ov08d10->priv_lane->link_freq_menu,
964 ov08d10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov08d10_ctrl_ops,
967 if (ov08d10->hblank)
968 ov08d10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
979 ov08d10->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov08d10_ctrl_ops,
991 ov08d10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov08d10_ctrl_ops,
993 if (ov08d10->hflip)
994 ov08d10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
995 ov08d10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov08d10_ctrl_ops,
997 if (ov08d10->vflip)
998 ov08d10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
1003 ov08d10->sd.ctrl_handler = ctrl_hdlr;
1008 static void ov08d10_update_pad_format(struct ov08d10 *ov08d10,
1014 fmt->code = ov08d10_get_format_code(ov08d10);
1018 static int ov08d10_start_streaming(struct ov08d10 *ov08d10)
1020 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
1024 link_freq_index = ov08d10->cur_mode->link_freq_index;
1026 &ov08d10->priv_lane->link_freq_configs[link_freq_index].reg_list;
1047 ret = ov08d10_write_reg_list(ov08d10, reg_list);
1053 reg_list = &ov08d10->cur_mode->reg_list;
1054 ret = ov08d10_write_reg_list(ov08d10, reg_list);
1060 ret = __v4l2_ctrl_handler_setup(ov08d10->sd.ctrl_handler);
1076 static void ov08d10_stop_streaming(struct ov08d10 *ov08d10)
1078 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
1102 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1106 if (ov08d10->streaming == enable)
1109 mutex_lock(&ov08d10->mutex);
1113 mutex_unlock(&ov08d10->mutex);
1117 ret = ov08d10_start_streaming(ov08d10);
1120 ov08d10_stop_streaming(ov08d10);
1124 ov08d10_stop_streaming(ov08d10);
1128 ov08d10->streaming = enable;
1131 __v4l2_ctrl_grab(ov08d10->vflip, enable);
1132 __v4l2_ctrl_grab(ov08d10->hflip, enable);
1134 mutex_unlock(&ov08d10->mutex);
1143 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1145 mutex_lock(&ov08d10->mutex);
1146 if (ov08d10->streaming)
1147 ov08d10_stop_streaming(ov08d10);
1149 mutex_unlock(&ov08d10->mutex);
1158 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1161 mutex_lock(&ov08d10->mutex);
1163 if (ov08d10->streaming) {
1164 ret = ov08d10_start_streaming(ov08d10);
1166 ov08d10->streaming = false;
1167 ov08d10_stop_streaming(ov08d10);
1168 mutex_unlock(&ov08d10->mutex);
1173 mutex_unlock(&ov08d10->mutex);
1182 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1187 mode = v4l2_find_nearest_size(ov08d10->priv_lane->sp_modes,
1188 ov08d10->modes_size,
1192 mutex_lock(&ov08d10->mutex);
1193 ov08d10_update_pad_format(ov08d10, mode, &fmt->format);
1198 ov08d10->cur_mode = mode;
1199 __v4l2_ctrl_s_ctrl(ov08d10->link_freq, mode->link_freq_index);
1200 pixel_rate = to_rate(ov08d10->priv_lane->link_freq_menu,
1202 ov08d10->cur_mode->data_lanes);
1203 __v4l2_ctrl_s_ctrl_int64(ov08d10->pixel_rate, pixel_rate);
1207 __v4l2_ctrl_modify_range(ov08d10->vblank,
1211 __v4l2_ctrl_s_ctrl(ov08d10->vblank, vblank_def);
1212 h_blank = to_pixels_per_line(ov08d10->priv_lane->link_freq_menu,
1215 ov08d10->cur_mode->data_lanes)
1217 __v4l2_ctrl_modify_range(ov08d10->hblank, h_blank, h_blank, 1,
1221 mutex_unlock(&ov08d10->mutex);
1230 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1232 mutex_lock(&ov08d10->mutex);
1234 fmt->format = *v4l2_subdev_get_try_format(&ov08d10->sd,
1238 ov08d10_update_pad_format(ov08d10, ov08d10->cur_mode,
1241 mutex_unlock(&ov08d10->mutex);
1250 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1255 mutex_lock(&ov08d10->mutex);
1256 code->code = ov08d10_get_format_code(ov08d10);
1257 mutex_unlock(&ov08d10->mutex);
1266 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1268 if (fse->index >= ov08d10->modes_size)
1271 mutex_lock(&ov08d10->mutex);
1272 if (fse->code != ov08d10_get_format_code(ov08d10)) {
1273 mutex_unlock(&ov08d10->mutex);
1276 mutex_unlock(&ov08d10->mutex);
1278 fse->min_width = ov08d10->priv_lane->sp_modes[fse->index].width;
1280 fse->min_height = ov08d10->priv_lane->sp_modes[fse->index].height;
1288 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1290 mutex_lock(&ov08d10->mutex);
1291 ov08d10_update_pad_format(ov08d10, &ov08d10->priv_lane->sp_modes[0],
1293 mutex_unlock(&ov08d10->mutex);
1318 static int ov08d10_identify_module(struct ov08d10 *ov08d10)
1320 struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd);
1352 static int ov08d10_get_hwcfg(struct ov08d10 *ov08d10, struct device *dev)
1391 dev_dbg(dev, "Using %u data lanes\n", ov08d10->cur_mode->data_lanes);
1393 ov08d10->priv_lane = &lane_cfg_2;
1394 ov08d10->modes_size = ov08d10_modes_num(ov08d10);
1402 for (i = 0; i < ARRAY_SIZE(ov08d10->priv_lane->link_freq_menu); i++) {
1404 if (ov08d10->priv_lane->link_freq_menu[i] ==
1411 ov08d10->priv_lane->link_freq_menu[i]);
1426 struct ov08d10 *ov08d10 = to_ov08d10(sd);
1432 mutex_destroy(&ov08d10->mutex);
1437 struct ov08d10 *ov08d10;
1440 ov08d10 = devm_kzalloc(&client->dev, sizeof(*ov08d10), GFP_KERNEL);
1441 if (!ov08d10)
1444 ret = ov08d10_get_hwcfg(ov08d10, &client->dev);
1451 v4l2_i2c_subdev_init(&ov08d10->sd, client, &ov08d10_subdev_ops);
1453 ret = ov08d10_identify_module(ov08d10);
1459 mutex_init(&ov08d10->mutex);
1460 ov08d10->cur_mode = &ov08d10->priv_lane->sp_modes[0];
1461 ret = ov08d10_init_controls(ov08d10);
1467 ov08d10->sd.internal_ops = &ov08d10_internal_ops;
1468 ov08d10->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1469 ov08d10->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
1470 ov08d10->pad.flags = MEDIA_PAD_FL_SOURCE;
1471 ret = media_entity_pads_init(&ov08d10->sd.entity, 1, &ov08d10->pad);
1477 ret = v4l2_async_register_subdev_sensor(&ov08d10->sd);
1495 media_entity_cleanup(&ov08d10->sd.entity);
1498 v4l2_ctrl_handler_free(ov08d10->sd.ctrl_handler);
1499 mutex_destroy(&ov08d10->mutex);
1519 .name = "ov08d10",
1530 MODULE_DESCRIPTION("OmniVision ov08d10 sensor driver");