ov5695            115 drivers/media/i2c/ov5695.c #define to_ov5695(sd) container_of(sd, struct ov5695, subdev)
ov5695            812 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = to_ov5695(sd);
ov5695            816 drivers/media/i2c/ov5695.c 	mutex_lock(&ov5695->mutex);
ov5695            828 drivers/media/i2c/ov5695.c 		ov5695->cur_mode = mode;
ov5695            830 drivers/media/i2c/ov5695.c 		__v4l2_ctrl_modify_range(ov5695->hblank, h_blank,
ov5695            833 drivers/media/i2c/ov5695.c 		__v4l2_ctrl_modify_range(ov5695->vblank, vblank_def,
ov5695            838 drivers/media/i2c/ov5695.c 	mutex_unlock(&ov5695->mutex);
ov5695            847 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = to_ov5695(sd);
ov5695            848 drivers/media/i2c/ov5695.c 	const struct ov5695_mode *mode = ov5695->cur_mode;
ov5695            850 drivers/media/i2c/ov5695.c 	mutex_lock(&ov5695->mutex);
ov5695            855 drivers/media/i2c/ov5695.c 		mutex_unlock(&ov5695->mutex);
ov5695            864 drivers/media/i2c/ov5695.c 	mutex_unlock(&ov5695->mutex);
ov5695            898 drivers/media/i2c/ov5695.c static int ov5695_enable_test_pattern(struct ov5695 *ov5695, u32 pattern)
ov5695            907 drivers/media/i2c/ov5695.c 	return ov5695_write_reg(ov5695->client, OV5695_REG_TEST_PATTERN,
ov5695            911 drivers/media/i2c/ov5695.c static int __ov5695_start_stream(struct ov5695 *ov5695)
ov5695            915 drivers/media/i2c/ov5695.c 	ret = ov5695_write_array(ov5695->client, ov5695_global_regs);
ov5695            918 drivers/media/i2c/ov5695.c 	ret = ov5695_write_array(ov5695->client, ov5695->cur_mode->reg_list);
ov5695            923 drivers/media/i2c/ov5695.c 	ret = __v4l2_ctrl_handler_setup(&ov5695->ctrl_handler);
ov5695            927 drivers/media/i2c/ov5695.c 	return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE,
ov5695            931 drivers/media/i2c/ov5695.c static int __ov5695_stop_stream(struct ov5695 *ov5695)
ov5695            933 drivers/media/i2c/ov5695.c 	return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE,
ov5695            939 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = to_ov5695(sd);
ov5695            940 drivers/media/i2c/ov5695.c 	struct i2c_client *client = ov5695->client;
ov5695            943 drivers/media/i2c/ov5695.c 	mutex_lock(&ov5695->mutex);
ov5695            945 drivers/media/i2c/ov5695.c 	if (on == ov5695->streaming)
ov5695            955 drivers/media/i2c/ov5695.c 		ret = __ov5695_start_stream(ov5695);
ov5695            962 drivers/media/i2c/ov5695.c 		__ov5695_stop_stream(ov5695);
ov5695            966 drivers/media/i2c/ov5695.c 	ov5695->streaming = on;
ov5695            969 drivers/media/i2c/ov5695.c 	mutex_unlock(&ov5695->mutex);
ov5695            974 drivers/media/i2c/ov5695.c static int __ov5695_power_on(struct ov5695 *ov5695)
ov5695            977 drivers/media/i2c/ov5695.c 	struct device *dev = &ov5695->client->dev;
ov5695            979 drivers/media/i2c/ov5695.c 	ret = clk_prepare_enable(ov5695->xvclk);
ov5695            985 drivers/media/i2c/ov5695.c 	gpiod_set_value_cansleep(ov5695->reset_gpio, 1);
ov5695            992 drivers/media/i2c/ov5695.c 		ret = regulator_enable(ov5695->supplies[i].consumer);
ov5695            995 drivers/media/i2c/ov5695.c 				ov5695->supplies[i].supply, ret);
ov5695           1000 drivers/media/i2c/ov5695.c 	gpiod_set_value_cansleep(ov5695->reset_gpio, 0);
ov5695           1008 drivers/media/i2c/ov5695.c 		regulator_disable(ov5695->supplies[i].consumer);
ov5695           1009 drivers/media/i2c/ov5695.c 	clk_disable_unprepare(ov5695->xvclk);
ov5695           1014 drivers/media/i2c/ov5695.c static void __ov5695_power_off(struct ov5695 *ov5695)
ov5695           1016 drivers/media/i2c/ov5695.c 	struct device *dev = &ov5695->client->dev;
ov5695           1019 drivers/media/i2c/ov5695.c 	clk_disable_unprepare(ov5695->xvclk);
ov5695           1020 drivers/media/i2c/ov5695.c 	gpiod_set_value_cansleep(ov5695->reset_gpio, 1);
ov5695           1027 drivers/media/i2c/ov5695.c 		ret = regulator_disable(ov5695->supplies[i].consumer);
ov5695           1030 drivers/media/i2c/ov5695.c 				ov5695->supplies[i].supply, ret);
ov5695           1038 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = to_ov5695(sd);
ov5695           1040 drivers/media/i2c/ov5695.c 	return __ov5695_power_on(ov5695);
ov5695           1047 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = to_ov5695(sd);
ov5695           1049 drivers/media/i2c/ov5695.c 	__ov5695_power_off(ov5695);
ov5695           1057 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = to_ov5695(sd);
ov5695           1062 drivers/media/i2c/ov5695.c 	mutex_lock(&ov5695->mutex);
ov5695           1069 drivers/media/i2c/ov5695.c 	mutex_unlock(&ov5695->mutex);
ov5695           1105 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = container_of(ctrl->handler,
ov5695           1106 drivers/media/i2c/ov5695.c 					     struct ov5695, ctrl_handler);
ov5695           1107 drivers/media/i2c/ov5695.c 	struct i2c_client *client = ov5695->client;
ov5695           1115 drivers/media/i2c/ov5695.c 		max = ov5695->cur_mode->height + ctrl->val - 4;
ov5695           1116 drivers/media/i2c/ov5695.c 		__v4l2_ctrl_modify_range(ov5695->exposure,
ov5695           1117 drivers/media/i2c/ov5695.c 					 ov5695->exposure->minimum, max,
ov5695           1118 drivers/media/i2c/ov5695.c 					 ov5695->exposure->step,
ov5695           1119 drivers/media/i2c/ov5695.c 					 ov5695->exposure->default_value);
ov5695           1129 drivers/media/i2c/ov5695.c 		ret = ov5695_write_reg(ov5695->client, OV5695_REG_EXPOSURE,
ov5695           1133 drivers/media/i2c/ov5695.c 		ret = ov5695_write_reg(ov5695->client, OV5695_REG_ANALOG_GAIN,
ov5695           1137 drivers/media/i2c/ov5695.c 		ret = ov5695_write_reg(ov5695->client, OV5695_REG_DIGI_GAIN_L,
ov5695           1140 drivers/media/i2c/ov5695.c 		ret = ov5695_write_reg(ov5695->client, OV5695_REG_DIGI_GAIN_H,
ov5695           1145 drivers/media/i2c/ov5695.c 		ret = ov5695_write_reg(ov5695->client, OV5695_REG_VTS,
ov5695           1147 drivers/media/i2c/ov5695.c 				       ctrl->val + ov5695->cur_mode->height);
ov5695           1150 drivers/media/i2c/ov5695.c 		ret = ov5695_enable_test_pattern(ov5695, ctrl->val);
ov5695           1167 drivers/media/i2c/ov5695.c static int ov5695_initialize_controls(struct ov5695 *ov5695)
ov5695           1176 drivers/media/i2c/ov5695.c 	handler = &ov5695->ctrl_handler;
ov5695           1177 drivers/media/i2c/ov5695.c 	mode = ov5695->cur_mode;
ov5695           1181 drivers/media/i2c/ov5695.c 	handler->lock = &ov5695->mutex;
ov5695           1192 drivers/media/i2c/ov5695.c 	ov5695->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK,
ov5695           1194 drivers/media/i2c/ov5695.c 	if (ov5695->hblank)
ov5695           1195 drivers/media/i2c/ov5695.c 		ov5695->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
ov5695           1198 drivers/media/i2c/ov5695.c 	ov5695->vblank = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops,
ov5695           1204 drivers/media/i2c/ov5695.c 	ov5695->exposure = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops,
ov5695           1209 drivers/media/i2c/ov5695.c 	ov5695->anal_gain = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops,
ov5695           1215 drivers/media/i2c/ov5695.c 	ov5695->digi_gain = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops,
ov5695           1220 drivers/media/i2c/ov5695.c 	ov5695->test_pattern = v4l2_ctrl_new_std_menu_items(handler,
ov5695           1227 drivers/media/i2c/ov5695.c 		dev_err(&ov5695->client->dev,
ov5695           1232 drivers/media/i2c/ov5695.c 	ov5695->subdev.ctrl_handler = handler;
ov5695           1242 drivers/media/i2c/ov5695.c static int ov5695_check_sensor_id(struct ov5695 *ov5695,
ov5695           1245 drivers/media/i2c/ov5695.c 	struct device *dev = &ov5695->client->dev;
ov5695           1261 drivers/media/i2c/ov5695.c static int ov5695_configure_regulators(struct ov5695 *ov5695)
ov5695           1266 drivers/media/i2c/ov5695.c 		ov5695->supplies[i].supply = ov5695_supply_names[i];
ov5695           1268 drivers/media/i2c/ov5695.c 	return devm_regulator_bulk_get(&ov5695->client->dev,
ov5695           1270 drivers/media/i2c/ov5695.c 				       ov5695->supplies);
ov5695           1277 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695;
ov5695           1281 drivers/media/i2c/ov5695.c 	ov5695 = devm_kzalloc(dev, sizeof(*ov5695), GFP_KERNEL);
ov5695           1282 drivers/media/i2c/ov5695.c 	if (!ov5695)
ov5695           1285 drivers/media/i2c/ov5695.c 	ov5695->client = client;
ov5695           1286 drivers/media/i2c/ov5695.c 	ov5695->cur_mode = &supported_modes[0];
ov5695           1288 drivers/media/i2c/ov5695.c 	ov5695->xvclk = devm_clk_get(dev, "xvclk");
ov5695           1289 drivers/media/i2c/ov5695.c 	if (IS_ERR(ov5695->xvclk)) {
ov5695           1293 drivers/media/i2c/ov5695.c 	ret = clk_set_rate(ov5695->xvclk, OV5695_XVCLK_FREQ);
ov5695           1298 drivers/media/i2c/ov5695.c 	if (clk_get_rate(ov5695->xvclk) != OV5695_XVCLK_FREQ)
ov5695           1301 drivers/media/i2c/ov5695.c 	ov5695->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
ov5695           1302 drivers/media/i2c/ov5695.c 	if (IS_ERR(ov5695->reset_gpio)) {
ov5695           1307 drivers/media/i2c/ov5695.c 	ret = ov5695_configure_regulators(ov5695);
ov5695           1313 drivers/media/i2c/ov5695.c 	mutex_init(&ov5695->mutex);
ov5695           1315 drivers/media/i2c/ov5695.c 	sd = &ov5695->subdev;
ov5695           1317 drivers/media/i2c/ov5695.c 	ret = ov5695_initialize_controls(ov5695);
ov5695           1321 drivers/media/i2c/ov5695.c 	ret = __ov5695_power_on(ov5695);
ov5695           1325 drivers/media/i2c/ov5695.c 	ret = ov5695_check_sensor_id(ov5695, client);
ov5695           1334 drivers/media/i2c/ov5695.c 	ov5695->pad.flags = MEDIA_PAD_FL_SOURCE;
ov5695           1336 drivers/media/i2c/ov5695.c 	ret = media_entity_pads_init(&sd->entity, 1, &ov5695->pad);
ov5695           1358 drivers/media/i2c/ov5695.c 	__ov5695_power_off(ov5695);
ov5695           1360 drivers/media/i2c/ov5695.c 	v4l2_ctrl_handler_free(&ov5695->ctrl_handler);
ov5695           1362 drivers/media/i2c/ov5695.c 	mutex_destroy(&ov5695->mutex);
ov5695           1370 drivers/media/i2c/ov5695.c 	struct ov5695 *ov5695 = to_ov5695(sd);
ov5695           1376 drivers/media/i2c/ov5695.c 	v4l2_ctrl_handler_free(&ov5695->ctrl_handler);
ov5695           1377 drivers/media/i2c/ov5695.c 	mutex_destroy(&ov5695->mutex);
ov5695           1381 drivers/media/i2c/ov5695.c 		__ov5695_power_off(ov5695);