ov5670           1836 drivers/media/i2c/ov5670.c #define to_ov5670(_sd)	container_of(_sd, struct ov5670, sd)
ov5670           1839 drivers/media/i2c/ov5670.c static int ov5670_read_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
ov5670           1842 drivers/media/i2c/ov5670.c 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
ov5670           1875 drivers/media/i2c/ov5670.c static int ov5670_write_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
ov5670           1878 drivers/media/i2c/ov5670.c 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
ov5670           1906 drivers/media/i2c/ov5670.c static int ov5670_write_regs(struct ov5670 *ov5670,
ov5670           1909 drivers/media/i2c/ov5670.c 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
ov5670           1914 drivers/media/i2c/ov5670.c 		ret = ov5670_write_reg(ov5670, regs[i].address, 1, regs[i].val);
ov5670           1928 drivers/media/i2c/ov5670.c static int ov5670_write_reg_list(struct ov5670 *ov5670,
ov5670           1931 drivers/media/i2c/ov5670.c 	return ov5670_write_regs(ov5670, r_list->regs, r_list->num_of_regs);
ov5670           1937 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = to_ov5670(sd);
ov5670           1941 drivers/media/i2c/ov5670.c 	mutex_lock(&ov5670->mutex);
ov5670           1944 drivers/media/i2c/ov5670.c 	try_fmt->width = ov5670->cur_mode->width;
ov5670           1945 drivers/media/i2c/ov5670.c 	try_fmt->height = ov5670->cur_mode->height;
ov5670           1950 drivers/media/i2c/ov5670.c 	mutex_unlock(&ov5670->mutex);
ov5670           1955 drivers/media/i2c/ov5670.c static int ov5670_update_digital_gain(struct ov5670 *ov5670, u32 d_gain)
ov5670           1959 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg(ov5670, OV5670_REG_R_DGTL_GAIN,
ov5670           1964 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg(ov5670, OV5670_REG_G_DGTL_GAIN,
ov5670           1969 drivers/media/i2c/ov5670.c 	return ov5670_write_reg(ov5670, OV5670_REG_B_DGTL_GAIN,
ov5670           1973 drivers/media/i2c/ov5670.c static int ov5670_enable_test_pattern(struct ov5670 *ov5670, u32 pattern)
ov5670           1979 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN_CTRL,
ov5670           1984 drivers/media/i2c/ov5670.c 	ret = ov5670_read_reg(ov5670, OV5670_REG_TEST_PATTERN,
ov5670           1994 drivers/media/i2c/ov5670.c 	return ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN,
ov5670           2001 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = container_of(ctrl->handler,
ov5670           2002 drivers/media/i2c/ov5670.c 					     struct ov5670, ctrl_handler);
ov5670           2003 drivers/media/i2c/ov5670.c 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
ov5670           2011 drivers/media/i2c/ov5670.c 		max = ov5670->cur_mode->height + ctrl->val - 8;
ov5670           2012 drivers/media/i2c/ov5670.c 		__v4l2_ctrl_modify_range(ov5670->exposure,
ov5670           2013 drivers/media/i2c/ov5670.c 					 ov5670->exposure->minimum, max,
ov5670           2014 drivers/media/i2c/ov5670.c 					 ov5670->exposure->step, max);
ov5670           2024 drivers/media/i2c/ov5670.c 		ret = ov5670_write_reg(ov5670, OV5670_REG_ANALOG_GAIN,
ov5670           2028 drivers/media/i2c/ov5670.c 		ret = ov5670_update_digital_gain(ov5670, ctrl->val);
ov5670           2032 drivers/media/i2c/ov5670.c 		ret = ov5670_write_reg(ov5670, OV5670_REG_EXPOSURE,
ov5670           2037 drivers/media/i2c/ov5670.c 		ret = ov5670_write_reg(ov5670, OV5670_REG_VTS,
ov5670           2039 drivers/media/i2c/ov5670.c 				       ov5670->cur_mode->height + ctrl->val);
ov5670           2042 drivers/media/i2c/ov5670.c 		ret = ov5670_enable_test_pattern(ov5670, ctrl->val);
ov5670           2060 drivers/media/i2c/ov5670.c static int ov5670_init_controls(struct ov5670 *ov5670)
ov5670           2069 drivers/media/i2c/ov5670.c 	ctrl_hdlr = &ov5670->ctrl_handler;
ov5670           2074 drivers/media/i2c/ov5670.c 	ctrl_hdlr->lock = &ov5670->mutex;
ov5670           2075 drivers/media/i2c/ov5670.c 	ov5670->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
ov5670           2079 drivers/media/i2c/ov5670.c 	if (ov5670->link_freq)
ov5670           2080 drivers/media/i2c/ov5670.c 		ov5670->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
ov5670           2083 drivers/media/i2c/ov5670.c 	ov5670->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
ov5670           2089 drivers/media/i2c/ov5670.c 	vblank_max = OV5670_VTS_MAX - ov5670->cur_mode->height;
ov5670           2090 drivers/media/i2c/ov5670.c 	vblank_def = ov5670->cur_mode->vts_def - ov5670->cur_mode->height;
ov5670           2091 drivers/media/i2c/ov5670.c 	vblank_min = ov5670->cur_mode->vts_min - ov5670->cur_mode->height;
ov5670           2092 drivers/media/i2c/ov5670.c 	ov5670->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
ov5670           2096 drivers/media/i2c/ov5670.c 	ov5670->hblank = v4l2_ctrl_new_std(
ov5670           2098 drivers/media/i2c/ov5670.c 				OV5670_FIXED_PPL - ov5670->cur_mode->width,
ov5670           2099 drivers/media/i2c/ov5670.c 				OV5670_FIXED_PPL - ov5670->cur_mode->width, 1,
ov5670           2100 drivers/media/i2c/ov5670.c 				OV5670_FIXED_PPL - ov5670->cur_mode->width);
ov5670           2101 drivers/media/i2c/ov5670.c 	if (ov5670->hblank)
ov5670           2102 drivers/media/i2c/ov5670.c 		ov5670->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
ov5670           2115 drivers/media/i2c/ov5670.c 	exposure_max = ov5670->cur_mode->vts_def - 8;
ov5670           2116 drivers/media/i2c/ov5670.c 	ov5670->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
ov5670           2132 drivers/media/i2c/ov5670.c 	ov5670->sd.ctrl_handler = ctrl_hdlr;
ov5670           2182 drivers/media/i2c/ov5670.c static int ov5670_do_get_pad_format(struct ov5670 *ov5670,
ov5670           2187 drivers/media/i2c/ov5670.c 		fmt->format = *v4l2_subdev_get_try_format(&ov5670->sd, cfg,
ov5670           2190 drivers/media/i2c/ov5670.c 		ov5670_update_pad_format(ov5670->cur_mode, fmt);
ov5670           2199 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = to_ov5670(sd);
ov5670           2202 drivers/media/i2c/ov5670.c 	mutex_lock(&ov5670->mutex);
ov5670           2203 drivers/media/i2c/ov5670.c 	ret = ov5670_do_get_pad_format(ov5670, cfg, fmt);
ov5670           2204 drivers/media/i2c/ov5670.c 	mutex_unlock(&ov5670->mutex);
ov5670           2213 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = to_ov5670(sd);
ov5670           2218 drivers/media/i2c/ov5670.c 	mutex_lock(&ov5670->mutex);
ov5670           2230 drivers/media/i2c/ov5670.c 		ov5670->cur_mode = mode;
ov5670           2231 drivers/media/i2c/ov5670.c 		__v4l2_ctrl_s_ctrl(ov5670->link_freq, mode->link_freq_index);
ov5670           2233 drivers/media/i2c/ov5670.c 			ov5670->pixel_rate,
ov5670           2236 drivers/media/i2c/ov5670.c 		vblank_def = ov5670->cur_mode->vts_def -
ov5670           2237 drivers/media/i2c/ov5670.c 			     ov5670->cur_mode->height;
ov5670           2239 drivers/media/i2c/ov5670.c 			ov5670->vblank,
ov5670           2240 drivers/media/i2c/ov5670.c 			ov5670->cur_mode->vts_min - ov5670->cur_mode->height,
ov5670           2241 drivers/media/i2c/ov5670.c 			OV5670_VTS_MAX - ov5670->cur_mode->height, 1,
ov5670           2243 drivers/media/i2c/ov5670.c 		__v4l2_ctrl_s_ctrl(ov5670->vblank, vblank_def);
ov5670           2244 drivers/media/i2c/ov5670.c 		h_blank = OV5670_FIXED_PPL - ov5670->cur_mode->width;
ov5670           2245 drivers/media/i2c/ov5670.c 		__v4l2_ctrl_modify_range(ov5670->hblank, h_blank, h_blank, 1,
ov5670           2249 drivers/media/i2c/ov5670.c 	mutex_unlock(&ov5670->mutex);
ov5670           2262 drivers/media/i2c/ov5670.c static int ov5670_start_streaming(struct ov5670 *ov5670)
ov5670           2264 drivers/media/i2c/ov5670.c 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
ov5670           2270 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg(ov5670, OV5670_REG_SOFTWARE_RST,
ov5670           2279 drivers/media/i2c/ov5670.c 	link_freq_index = ov5670->cur_mode->link_freq_index;
ov5670           2281 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg_list(ov5670, reg_list);
ov5670           2288 drivers/media/i2c/ov5670.c 	reg_list = &ov5670->cur_mode->reg_list;
ov5670           2289 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg_list(ov5670, reg_list);
ov5670           2295 drivers/media/i2c/ov5670.c 	ret = __v4l2_ctrl_handler_setup(ov5670->sd.ctrl_handler);
ov5670           2300 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
ov5670           2310 drivers/media/i2c/ov5670.c static int ov5670_stop_streaming(struct ov5670 *ov5670)
ov5670           2312 drivers/media/i2c/ov5670.c 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
ov5670           2315 drivers/media/i2c/ov5670.c 	ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
ov5670           2328 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = to_ov5670(sd);
ov5670           2332 drivers/media/i2c/ov5670.c 	mutex_lock(&ov5670->mutex);
ov5670           2333 drivers/media/i2c/ov5670.c 	if (ov5670->streaming == enable)
ov5670           2343 drivers/media/i2c/ov5670.c 		ret = ov5670_start_streaming(ov5670);
ov5670           2347 drivers/media/i2c/ov5670.c 		ret = ov5670_stop_streaming(ov5670);
ov5670           2350 drivers/media/i2c/ov5670.c 	ov5670->streaming = enable;
ov5670           2357 drivers/media/i2c/ov5670.c 	mutex_unlock(&ov5670->mutex);
ov5670           2366 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = to_ov5670(sd);
ov5670           2368 drivers/media/i2c/ov5670.c 	if (ov5670->streaming)
ov5670           2369 drivers/media/i2c/ov5670.c 		ov5670_stop_streaming(ov5670);
ov5670           2378 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = to_ov5670(sd);
ov5670           2381 drivers/media/i2c/ov5670.c 	if (ov5670->streaming) {
ov5670           2382 drivers/media/i2c/ov5670.c 		ret = ov5670_start_streaming(ov5670);
ov5670           2384 drivers/media/i2c/ov5670.c 			ov5670_stop_streaming(ov5670);
ov5670           2393 drivers/media/i2c/ov5670.c static int ov5670_identify_module(struct ov5670 *ov5670)
ov5670           2395 drivers/media/i2c/ov5670.c 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
ov5670           2399 drivers/media/i2c/ov5670.c 	ret = ov5670_read_reg(ov5670, OV5670_REG_CHIP_ID,
ov5670           2444 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670;
ov5670           2453 drivers/media/i2c/ov5670.c 	ov5670 = devm_kzalloc(&client->dev, sizeof(*ov5670), GFP_KERNEL);
ov5670           2454 drivers/media/i2c/ov5670.c 	if (!ov5670) {
ov5670           2461 drivers/media/i2c/ov5670.c 	v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops);
ov5670           2464 drivers/media/i2c/ov5670.c 	ret = ov5670_identify_module(ov5670);
ov5670           2470 drivers/media/i2c/ov5670.c 	mutex_init(&ov5670->mutex);
ov5670           2473 drivers/media/i2c/ov5670.c 	ov5670->cur_mode = &supported_modes[0];
ov5670           2475 drivers/media/i2c/ov5670.c 	ret = ov5670_init_controls(ov5670);
ov5670           2481 drivers/media/i2c/ov5670.c 	ov5670->sd.internal_ops = &ov5670_internal_ops;
ov5670           2482 drivers/media/i2c/ov5670.c 	ov5670->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
ov5670           2483 drivers/media/i2c/ov5670.c 	ov5670->sd.entity.ops = &ov5670_subdev_entity_ops;
ov5670           2484 drivers/media/i2c/ov5670.c 	ov5670->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
ov5670           2487 drivers/media/i2c/ov5670.c 	ov5670->pad.flags = MEDIA_PAD_FL_SOURCE;
ov5670           2488 drivers/media/i2c/ov5670.c 	ret = media_entity_pads_init(&ov5670->sd.entity, 1, &ov5670->pad);
ov5670           2495 drivers/media/i2c/ov5670.c 	ret = v4l2_async_register_subdev_sensor_common(&ov5670->sd);
ov5670           2501 drivers/media/i2c/ov5670.c 	ov5670->streaming = false;
ov5670           2514 drivers/media/i2c/ov5670.c 	media_entity_cleanup(&ov5670->sd.entity);
ov5670           2517 drivers/media/i2c/ov5670.c 	v4l2_ctrl_handler_free(ov5670->sd.ctrl_handler);
ov5670           2520 drivers/media/i2c/ov5670.c 	mutex_destroy(&ov5670->mutex);
ov5670           2531 drivers/media/i2c/ov5670.c 	struct ov5670 *ov5670 = to_ov5670(sd);
ov5670           2536 drivers/media/i2c/ov5670.c 	mutex_destroy(&ov5670->mutex);