Lines Matching full:ov5695

3  * ov5695 driver
95 struct ov5695 { struct
114 #define to_ov5695(sd) container_of(sd, struct ov5695, subdev) argument
811 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_set_fmt() local
815 mutex_lock(&ov5695->mutex); in ov5695_set_fmt()
825 ov5695->cur_mode = mode; in ov5695_set_fmt()
827 __v4l2_ctrl_modify_range(ov5695->hblank, h_blank, in ov5695_set_fmt()
830 __v4l2_ctrl_modify_range(ov5695->vblank, vblank_def, in ov5695_set_fmt()
835 mutex_unlock(&ov5695->mutex); in ov5695_set_fmt()
844 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_get_fmt() local
845 const struct ov5695_mode *mode = ov5695->cur_mode; in ov5695_get_fmt()
847 mutex_lock(&ov5695->mutex); in ov5695_get_fmt()
857 mutex_unlock(&ov5695->mutex); in ov5695_get_fmt()
891 static int ov5695_enable_test_pattern(struct ov5695 *ov5695, u32 pattern) in ov5695_enable_test_pattern() argument
900 return ov5695_write_reg(ov5695->client, OV5695_REG_TEST_PATTERN, in ov5695_enable_test_pattern()
904 static int __ov5695_start_stream(struct ov5695 *ov5695) in __ov5695_start_stream() argument
908 ret = ov5695_write_array(ov5695->client, ov5695_global_regs); in __ov5695_start_stream()
911 ret = ov5695_write_array(ov5695->client, ov5695->cur_mode->reg_list); in __ov5695_start_stream()
916 ret = __v4l2_ctrl_handler_setup(&ov5695->ctrl_handler); in __ov5695_start_stream()
920 return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE, in __ov5695_start_stream()
924 static int __ov5695_stop_stream(struct ov5695 *ov5695) in __ov5695_stop_stream() argument
926 return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE, in __ov5695_stop_stream()
932 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_s_stream() local
933 struct i2c_client *client = ov5695->client; in ov5695_s_stream()
936 mutex_lock(&ov5695->mutex); in ov5695_s_stream()
943 ret = __ov5695_start_stream(ov5695); in ov5695_s_stream()
950 __ov5695_stop_stream(ov5695); in ov5695_s_stream()
955 mutex_unlock(&ov5695->mutex); in ov5695_s_stream()
960 static int __ov5695_power_on(struct ov5695 *ov5695) in __ov5695_power_on() argument
963 struct device *dev = &ov5695->client->dev; in __ov5695_power_on()
965 ret = clk_prepare_enable(ov5695->xvclk); in __ov5695_power_on()
971 gpiod_set_value_cansleep(ov5695->reset_gpio, 1); in __ov5695_power_on()
978 ret = regulator_enable(ov5695->supplies[i].consumer); in __ov5695_power_on()
981 ov5695->supplies[i].supply, ret); in __ov5695_power_on()
986 gpiod_set_value_cansleep(ov5695->reset_gpio, 0); in __ov5695_power_on()
994 regulator_disable(ov5695->supplies[i].consumer); in __ov5695_power_on()
995 clk_disable_unprepare(ov5695->xvclk); in __ov5695_power_on()
1000 static void __ov5695_power_off(struct ov5695 *ov5695) in __ov5695_power_off() argument
1002 struct device *dev = &ov5695->client->dev; in __ov5695_power_off()
1005 clk_disable_unprepare(ov5695->xvclk); in __ov5695_power_off()
1006 gpiod_set_value_cansleep(ov5695->reset_gpio, 1); in __ov5695_power_off()
1013 ret = regulator_disable(ov5695->supplies[i].consumer); in __ov5695_power_off()
1016 ov5695->supplies[i].supply, ret); in __ov5695_power_off()
1023 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_runtime_resume() local
1025 return __ov5695_power_on(ov5695); in ov5695_runtime_resume()
1031 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_runtime_suspend() local
1033 __ov5695_power_off(ov5695); in ov5695_runtime_suspend()
1040 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_open() local
1045 mutex_lock(&ov5695->mutex); in ov5695_open()
1052 mutex_unlock(&ov5695->mutex); in ov5695_open()
1085 struct ov5695 *ov5695 = container_of(ctrl->handler, in ov5695_set_ctrl() local
1086 struct ov5695, ctrl_handler); in ov5695_set_ctrl()
1087 struct i2c_client *client = ov5695->client; in ov5695_set_ctrl()
1095 max = ov5695->cur_mode->height + ctrl->val - 4; in ov5695_set_ctrl()
1096 __v4l2_ctrl_modify_range(ov5695->exposure, in ov5695_set_ctrl()
1097 ov5695->exposure->minimum, max, in ov5695_set_ctrl()
1098 ov5695->exposure->step, in ov5695_set_ctrl()
1099 ov5695->exposure->default_value); in ov5695_set_ctrl()
1109 ret = ov5695_write_reg(ov5695->client, OV5695_REG_EXPOSURE, in ov5695_set_ctrl()
1113 ret = ov5695_write_reg(ov5695->client, OV5695_REG_ANALOG_GAIN, in ov5695_set_ctrl()
1117 ret = ov5695_write_reg(ov5695->client, OV5695_REG_DIGI_GAIN_L, in ov5695_set_ctrl()
1120 ret = ov5695_write_reg(ov5695->client, OV5695_REG_DIGI_GAIN_H, in ov5695_set_ctrl()
1125 ret = ov5695_write_reg(ov5695->client, OV5695_REG_VTS, in ov5695_set_ctrl()
1127 ctrl->val + ov5695->cur_mode->height); in ov5695_set_ctrl()
1130 ret = ov5695_enable_test_pattern(ov5695, ctrl->val); in ov5695_set_ctrl()
1147 static int ov5695_initialize_controls(struct ov5695 *ov5695) in ov5695_initialize_controls() argument
1156 handler = &ov5695->ctrl_handler; in ov5695_initialize_controls()
1157 mode = ov5695->cur_mode; in ov5695_initialize_controls()
1161 handler->lock = &ov5695->mutex; in ov5695_initialize_controls()
1172 ov5695->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov5695_initialize_controls()
1174 if (ov5695->hblank) in ov5695_initialize_controls()
1175 ov5695->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov5695_initialize_controls()
1178 ov5695->vblank = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1184 ov5695->exposure = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1189 ov5695->anal_gain = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1195 ov5695->digi_gain = v4l2_ctrl_new_std(handler, &ov5695_ctrl_ops, in ov5695_initialize_controls()
1200 ov5695->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in ov5695_initialize_controls()
1207 dev_err(&ov5695->client->dev, in ov5695_initialize_controls()
1212 ov5695->subdev.ctrl_handler = handler; in ov5695_initialize_controls()
1222 static int ov5695_check_sensor_id(struct ov5695 *ov5695, in ov5695_check_sensor_id() argument
1225 struct device *dev = &ov5695->client->dev; in ov5695_check_sensor_id()
1241 static int ov5695_configure_regulators(struct ov5695 *ov5695) in ov5695_configure_regulators() argument
1246 ov5695->supplies[i].supply = ov5695_supply_names[i]; in ov5695_configure_regulators()
1248 return devm_regulator_bulk_get(&ov5695->client->dev, in ov5695_configure_regulators()
1250 ov5695->supplies); in ov5695_configure_regulators()
1256 struct ov5695 *ov5695; in ov5695_probe() local
1260 ov5695 = devm_kzalloc(dev, sizeof(*ov5695), GFP_KERNEL); in ov5695_probe()
1261 if (!ov5695) in ov5695_probe()
1264 ov5695->client = client; in ov5695_probe()
1265 ov5695->cur_mode = &supported_modes[0]; in ov5695_probe()
1267 ov5695->xvclk = devm_clk_get(dev, "xvclk"); in ov5695_probe()
1268 if (IS_ERR(ov5695->xvclk)) { in ov5695_probe()
1272 ret = clk_set_rate(ov5695->xvclk, OV5695_XVCLK_FREQ); in ov5695_probe()
1277 if (clk_get_rate(ov5695->xvclk) != OV5695_XVCLK_FREQ) in ov5695_probe()
1280 ov5695->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in ov5695_probe()
1281 if (IS_ERR(ov5695->reset_gpio)) { in ov5695_probe()
1286 ret = ov5695_configure_regulators(ov5695); in ov5695_probe()
1292 mutex_init(&ov5695->mutex); in ov5695_probe()
1294 sd = &ov5695->subdev; in ov5695_probe()
1296 ret = ov5695_initialize_controls(ov5695); in ov5695_probe()
1300 ret = __ov5695_power_on(ov5695); in ov5695_probe()
1304 ret = ov5695_check_sensor_id(ov5695, client); in ov5695_probe()
1310 ov5695->pad.flags = MEDIA_PAD_FL_SOURCE; in ov5695_probe()
1312 ret = media_entity_pads_init(&sd->entity, 1, &ov5695->pad); in ov5695_probe()
1331 __ov5695_power_off(ov5695); in ov5695_probe()
1333 v4l2_ctrl_handler_free(&ov5695->ctrl_handler); in ov5695_probe()
1335 mutex_destroy(&ov5695->mutex); in ov5695_probe()
1343 struct ov5695 *ov5695 = to_ov5695(sd); in ov5695_remove() local
1347 v4l2_ctrl_handler_free(&ov5695->ctrl_handler); in ov5695_remove()
1348 mutex_destroy(&ov5695->mutex); in ov5695_remove()
1352 __ov5695_power_off(ov5695); in ov5695_remove()
1358 { .compatible = "ovti,ov5695" },
1366 .name = "ov5695",
1376 MODULE_DESCRIPTION("OmniVision ov5695 sensor driver");