Lines Matching refs:ov5695
95 struct ov5695 { struct
115 #define to_ov5695(sd) container_of(sd, struct ov5695, subdev) argument
812 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_set_fmt() local
816 mutex_lock(&ov5695->mutex); in ov5695_set_fmt()
828 ov5695->cur_mode = mode; in ov5695_set_fmt()
830 __v4l2_ctrl_modify_range(ov5695->hblank, h_blank, in ov5695_set_fmt()
833 __v4l2_ctrl_modify_range(ov5695->vblank, vblank_def, in ov5695_set_fmt()
838 mutex_unlock(&ov5695->mutex); in ov5695_set_fmt()
847 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_get_fmt() local
848 const struct ov5695_mode *mode = ov5695->cur_mode; in ov5695_get_fmt()
850 mutex_lock(&ov5695->mutex); in ov5695_get_fmt()
856 mutex_unlock(&ov5695->mutex); in ov5695_get_fmt()
865 mutex_unlock(&ov5695->mutex); in ov5695_get_fmt()
899 static int ov5695_enable_test_pattern(struct ov5695 *ov5695, u32 pattern) in ov5695_enable_test_pattern() argument
908 return ov5695_write_reg(ov5695->client, OV5695_REG_TEST_PATTERN, in ov5695_enable_test_pattern()
912 static int __ov5695_start_stream(struct ov5695 *ov5695) in __ov5695_start_stream() argument
916 ret = ov5695_write_array(ov5695->client, ov5695_global_regs); in __ov5695_start_stream()
919 ret = ov5695_write_array(ov5695->client, ov5695->cur_mode->reg_list); in __ov5695_start_stream()
924 ret = __v4l2_ctrl_handler_setup(&ov5695->ctrl_handler); in __ov5695_start_stream()
928 return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE, in __ov5695_start_stream()
932 static int __ov5695_stop_stream(struct ov5695 *ov5695) in __ov5695_stop_stream() argument
934 return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE, in __ov5695_stop_stream()
940 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_s_stream() local
941 struct i2c_client *client = ov5695->client; in ov5695_s_stream()
944 mutex_lock(&ov5695->mutex); in ov5695_s_stream()
946 if (on == ov5695->streaming) in ov5695_s_stream()
954 ret = __ov5695_start_stream(ov5695); in ov5695_s_stream()
961 __ov5695_stop_stream(ov5695); in ov5695_s_stream()
965 ov5695->streaming = on; in ov5695_s_stream()
968 mutex_unlock(&ov5695->mutex); in ov5695_s_stream()
973 static int __ov5695_power_on(struct ov5695 *ov5695) in __ov5695_power_on() argument
976 struct device *dev = &ov5695->client->dev; in __ov5695_power_on()
978 ret = clk_prepare_enable(ov5695->xvclk); in __ov5695_power_on()
984 gpiod_set_value_cansleep(ov5695->reset_gpio, 1); in __ov5695_power_on()
991 ret = regulator_enable(ov5695->supplies[i].consumer); in __ov5695_power_on()
994 ov5695->supplies[i].supply, ret); in __ov5695_power_on()
999 gpiod_set_value_cansleep(ov5695->reset_gpio, 0); in __ov5695_power_on()
1007 regulator_disable(ov5695->supplies[i].consumer); in __ov5695_power_on()
1008 clk_disable_unprepare(ov5695->xvclk); in __ov5695_power_on()
1013 static void __ov5695_power_off(struct ov5695 *ov5695) in __ov5695_power_off() argument
1015 struct device *dev = &ov5695->client->dev; in __ov5695_power_off()
1018 clk_disable_unprepare(ov5695->xvclk); in __ov5695_power_off()
1019 gpiod_set_value_cansleep(ov5695->reset_gpio, 1); in __ov5695_power_off()
1026 ret = regulator_disable(ov5695->supplies[i].consumer); in __ov5695_power_off()
1029 ov5695->supplies[i].supply, ret); in __ov5695_power_off()
1036 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_runtime_resume() local
1038 return __ov5695_power_on(ov5695); in ov5695_runtime_resume()
1044 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_runtime_suspend() local
1046 __ov5695_power_off(ov5695); in ov5695_runtime_suspend()
1054 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_open() local
1059 mutex_lock(&ov5695->mutex); in ov5695_open()
1066 mutex_unlock(&ov5695->mutex); in ov5695_open()
1102 struct ov5695 *ov5695 = container_of(ctrl->handler, in ov5695_set_ctrl() local
1103 struct ov5695, ctrl_handler); in ov5695_set_ctrl()
1104 struct i2c_client *client = ov5695->client; in ov5695_set_ctrl()
1112 max = ov5695->cur_mode->height + ctrl->val - 4; in ov5695_set_ctrl()
1113 __v4l2_ctrl_modify_range(ov5695->exposure, in ov5695_set_ctrl()
1114 ov5695->exposure->minimum, max, in ov5695_set_ctrl()
1115 ov5695->exposure->step, in ov5695_set_ctrl()
1116 ov5695->exposure->default_value); in ov5695_set_ctrl()
1126 ret = ov5695_write_reg(ov5695->client, OV5695_REG_EXPOSURE, in ov5695_set_ctrl()
1130 ret = ov5695_write_reg(ov5695->client, OV5695_REG_ANALOG_GAIN, in ov5695_set_ctrl()
1134 ret = ov5695_write_reg(ov5695->client, OV5695_REG_DIGI_GAIN_L, in ov5695_set_ctrl()
1137 ret = ov5695_write_reg(ov5695->client, OV5695_REG_DIGI_GAIN_H, in ov5695_set_ctrl()
1142 ret = ov5695_write_reg(ov5695->client, OV5695_REG_VTS, in ov5695_set_ctrl()
1144 ctrl->val + ov5695->cur_mode->height); in ov5695_set_ctrl()
1147 ret = ov5695_enable_test_pattern(ov5695, ctrl->val); in ov5695_set_ctrl()
1164 static int ov5695_initialize_controls(struct ov5695 *ov5695) in ov5695_initialize_controls() argument
1173 handler = &ov5695->ctrl_handler; in ov5695_initialize_controls()
1174 mode = ov5695->cur_mode; in ov5695_initialize_controls()
1178 handler->lock = &ov5695->mutex; in ov5695_initialize_controls()
1189 ov5695->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov5695_initialize_controls()
1191 if (ov5695->hblank) in ov5695_initialize_controls()
1192 ov5695->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov5695_initialize_controls()
1195 ov5695->vblank = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1201 ov5695->exposure = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1206 ov5695->anal_gain = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1212 ov5695->digi_gain = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1217 ov5695->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in ov5695_initialize_controls()
1224 dev_err(&ov5695->client->dev, in ov5695_initialize_controls()
1229 ov5695->subdev.ctrl_handler = handler; in ov5695_initialize_controls()
1239 static int ov5695_check_sensor_id(struct ov5695 *ov5695, in ov5695_check_sensor_id() argument
1242 struct device *dev = &ov5695->client->dev; in ov5695_check_sensor_id()
1258 static int ov5695_configure_regulators(struct ov5695 *ov5695) in ov5695_configure_regulators() argument
1263 ov5695->supplies[i].supply = ov5695_supply_names[i]; in ov5695_configure_regulators()
1265 return devm_regulator_bulk_get(&ov5695->client->dev, in ov5695_configure_regulators()
1267 ov5695->supplies); in ov5695_configure_regulators()
1273 struct ov5695 *ov5695; in ov5695_probe() local
1277 ov5695 = devm_kzalloc(dev, sizeof(*ov5695), GFP_KERNEL); in ov5695_probe()
1278 if (!ov5695) in ov5695_probe()
1281 ov5695->client = client; in ov5695_probe()
1282 ov5695->cur_mode = &supported_modes[0]; in ov5695_probe()
1284 ov5695->xvclk = devm_clk_get(dev, "xvclk"); in ov5695_probe()
1285 if (IS_ERR(ov5695->xvclk)) { in ov5695_probe()
1289 ret = clk_set_rate(ov5695->xvclk, OV5695_XVCLK_FREQ); in ov5695_probe()
1294 if (clk_get_rate(ov5695->xvclk) != OV5695_XVCLK_FREQ) in ov5695_probe()
1297 ov5695->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in ov5695_probe()
1298 if (IS_ERR(ov5695->reset_gpio)) { in ov5695_probe()
1303 ret = ov5695_configure_regulators(ov5695); in ov5695_probe()
1309 mutex_init(&ov5695->mutex); in ov5695_probe()
1311 sd = &ov5695->subdev; in ov5695_probe()
1313 ret = ov5695_initialize_controls(ov5695); in ov5695_probe()
1317 ret = __ov5695_power_on(ov5695); in ov5695_probe()
1321 ret = ov5695_check_sensor_id(ov5695, client); in ov5695_probe()
1330 ov5695->pad.flags = MEDIA_PAD_FL_SOURCE; in ov5695_probe()
1332 ret = media_entity_pads_init(&sd->entity, 1, &ov5695->pad); in ov5695_probe()
1354 __ov5695_power_off(ov5695); in ov5695_probe()
1356 v4l2_ctrl_handler_free(&ov5695->ctrl_handler); in ov5695_probe()
1358 mutex_destroy(&ov5695->mutex); in ov5695_probe()
1366 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_remove() local
1372 v4l2_ctrl_handler_free(&ov5695->ctrl_handler); in ov5695_remove()
1373 mutex_destroy(&ov5695->mutex); in ov5695_remove()
1377 __ov5695_power_off(ov5695); in ov5695_remove()