Lines Matching full:ov5670
32 * In OV5670, Time-per-line = HTS/SCLK.
1742 * OV5670 sensor supports following resolutions with full FOV:
1815 struct ov5670 { struct
1837 #define to_ov5670(_sd) container_of(_sd, struct ov5670, sd) argument
1840 static int ov5670_read_reg(struct ov5670 *ov5670, u16 reg, unsigned int len, in ov5670_read_reg() argument
1843 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_read_reg()
1876 static int ov5670_write_reg(struct ov5670 *ov5670, u16 reg, unsigned int len, in ov5670_write_reg() argument
1879 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_write_reg()
1907 static int ov5670_write_regs(struct ov5670 *ov5670, in ov5670_write_regs() argument
1910 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_write_regs()
1915 ret = ov5670_write_reg(ov5670, regs[i].address, 1, regs[i].val); in ov5670_write_regs()
1929 static int ov5670_write_reg_list(struct ov5670 *ov5670, in ov5670_write_reg_list() argument
1932 return ov5670_write_regs(ov5670, r_list->regs, r_list->num_of_regs); in ov5670_write_reg_list()
1938 struct ov5670 *ov5670 = to_ov5670(sd); in ov5670_open() local
1942 mutex_lock(&ov5670->mutex); in ov5670_open()
1945 try_fmt->width = ov5670->cur_mode->width; in ov5670_open()
1946 try_fmt->height = ov5670->cur_mode->height; in ov5670_open()
1951 mutex_unlock(&ov5670->mutex); in ov5670_open()
1956 static int ov5670_update_digital_gain(struct ov5670 *ov5670, u32 d_gain) in ov5670_update_digital_gain() argument
1960 ret = ov5670_write_reg(ov5670, OV5670_REG_R_DGTL_GAIN, in ov5670_update_digital_gain()
1965 ret = ov5670_write_reg(ov5670, OV5670_REG_G_DGTL_GAIN, in ov5670_update_digital_gain()
1970 return ov5670_write_reg(ov5670, OV5670_REG_B_DGTL_GAIN, in ov5670_update_digital_gain()
1974 static int ov5670_enable_test_pattern(struct ov5670 *ov5670, u32 pattern) in ov5670_enable_test_pattern() argument
1980 ret = ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN_CTRL, in ov5670_enable_test_pattern()
1985 ret = ov5670_read_reg(ov5670, OV5670_REG_TEST_PATTERN, in ov5670_enable_test_pattern()
1995 return ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN, in ov5670_enable_test_pattern()
2002 struct ov5670 *ov5670 = container_of(ctrl->handler, in ov5670_set_ctrl() local
2003 struct ov5670, ctrl_handler); in ov5670_set_ctrl()
2004 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_set_ctrl()
2012 max = ov5670->cur_mode->height + ctrl->val - 8; in ov5670_set_ctrl()
2013 __v4l2_ctrl_modify_range(ov5670->exposure, in ov5670_set_ctrl()
2014 ov5670->exposure->minimum, max, in ov5670_set_ctrl()
2015 ov5670->exposure->step, max); in ov5670_set_ctrl()
2025 ret = ov5670_write_reg(ov5670, OV5670_REG_ANALOG_GAIN, in ov5670_set_ctrl()
2029 ret = ov5670_update_digital_gain(ov5670, ctrl->val); in ov5670_set_ctrl()
2033 ret = ov5670_write_reg(ov5670, OV5670_REG_EXPOSURE, in ov5670_set_ctrl()
2038 ret = ov5670_write_reg(ov5670, OV5670_REG_VTS, in ov5670_set_ctrl()
2040 ov5670->cur_mode->height + ctrl->val); in ov5670_set_ctrl()
2043 ret = ov5670_enable_test_pattern(ov5670, ctrl->val); in ov5670_set_ctrl()
2061 static int ov5670_init_controls(struct ov5670 *ov5670) in ov5670_init_controls() argument
2063 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_init_controls()
2072 ctrl_hdlr = &ov5670->ctrl_handler; in ov5670_init_controls()
2077 ctrl_hdlr->lock = &ov5670->mutex; in ov5670_init_controls()
2078 ov5670->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, in ov5670_init_controls()
2082 if (ov5670->link_freq) in ov5670_init_controls()
2083 ov5670->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov5670_init_controls()
2086 ov5670->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, in ov5670_init_controls()
2093 vblank_max = OV5670_VTS_MAX - ov5670->cur_mode->height; in ov5670_init_controls()
2094 vblank_def = ov5670->cur_mode->vts_def - ov5670->cur_mode->height; in ov5670_init_controls()
2095 vblank_min = ov5670->cur_mode->vts_min - ov5670->cur_mode->height; in ov5670_init_controls()
2096 ov5670->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, in ov5670_init_controls()
2100 ov5670->hblank = v4l2_ctrl_new_std( in ov5670_init_controls()
2102 OV5670_FIXED_PPL - ov5670->cur_mode->width, in ov5670_init_controls()
2103 OV5670_FIXED_PPL - ov5670->cur_mode->width, 1, in ov5670_init_controls()
2104 OV5670_FIXED_PPL - ov5670->cur_mode->width); in ov5670_init_controls()
2105 if (ov5670->hblank) in ov5670_init_controls()
2106 ov5670->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov5670_init_controls()
2119 exposure_max = ov5670->cur_mode->vts_def - 8; in ov5670_init_controls()
2120 ov5670->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, in ov5670_init_controls()
2145 ov5670->sd.ctrl_handler = ctrl_hdlr; in ov5670_init_controls()
2195 static int ov5670_do_get_pad_format(struct ov5670 *ov5670, in ov5670_do_get_pad_format() argument
2200 fmt->format = *v4l2_subdev_get_try_format(&ov5670->sd, cfg, in ov5670_do_get_pad_format()
2203 ov5670_update_pad_format(ov5670->cur_mode, fmt); in ov5670_do_get_pad_format()
2212 struct ov5670 *ov5670 = to_ov5670(sd); in ov5670_get_pad_format() local
2215 mutex_lock(&ov5670->mutex); in ov5670_get_pad_format()
2216 ret = ov5670_do_get_pad_format(ov5670, cfg, fmt); in ov5670_get_pad_format()
2217 mutex_unlock(&ov5670->mutex); in ov5670_get_pad_format()
2226 struct ov5670 *ov5670 = to_ov5670(sd); in ov5670_set_pad_format() local
2231 mutex_lock(&ov5670->mutex); in ov5670_set_pad_format()
2243 ov5670->cur_mode = mode; in ov5670_set_pad_format()
2244 __v4l2_ctrl_s_ctrl(ov5670->link_freq, mode->link_freq_index); in ov5670_set_pad_format()
2246 ov5670->pixel_rate, in ov5670_set_pad_format()
2249 vblank_def = ov5670->cur_mode->vts_def - in ov5670_set_pad_format()
2250 ov5670->cur_mode->height; in ov5670_set_pad_format()
2252 ov5670->vblank, in ov5670_set_pad_format()
2253 ov5670->cur_mode->vts_min - ov5670->cur_mode->height, in ov5670_set_pad_format()
2254 OV5670_VTS_MAX - ov5670->cur_mode->height, 1, in ov5670_set_pad_format()
2256 __v4l2_ctrl_s_ctrl(ov5670->vblank, vblank_def); in ov5670_set_pad_format()
2257 h_blank = OV5670_FIXED_PPL - ov5670->cur_mode->width; in ov5670_set_pad_format()
2258 __v4l2_ctrl_modify_range(ov5670->hblank, h_blank, h_blank, 1, in ov5670_set_pad_format()
2262 mutex_unlock(&ov5670->mutex); in ov5670_set_pad_format()
2275 static int ov5670_start_streaming(struct ov5670 *ov5670) in ov5670_start_streaming() argument
2277 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_start_streaming()
2283 ret = ov5670_write_reg(ov5670, OV5670_REG_SOFTWARE_RST, in ov5670_start_streaming()
2292 link_freq_index = ov5670->cur_mode->link_freq_index; in ov5670_start_streaming()
2294 ret = ov5670_write_reg_list(ov5670, reg_list); in ov5670_start_streaming()
2301 reg_list = &ov5670->cur_mode->reg_list; in ov5670_start_streaming()
2302 ret = ov5670_write_reg_list(ov5670, reg_list); in ov5670_start_streaming()
2308 ret = __v4l2_ctrl_handler_setup(ov5670->sd.ctrl_handler); in ov5670_start_streaming()
2313 ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT, in ov5670_start_streaming()
2323 static int ov5670_stop_streaming(struct ov5670 *ov5670) in ov5670_stop_streaming() argument
2325 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_stop_streaming()
2328 ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT, in ov5670_stop_streaming()
2341 struct ov5670 *ov5670 = to_ov5670(sd); in ov5670_set_stream() local
2345 mutex_lock(&ov5670->mutex); in ov5670_set_stream()
2346 if (ov5670->streaming == enable) in ov5670_set_stream()
2356 ret = ov5670_start_streaming(ov5670); in ov5670_set_stream()
2360 ret = ov5670_stop_streaming(ov5670); in ov5670_set_stream()
2363 ov5670->streaming = enable; in ov5670_set_stream()
2370 mutex_unlock(&ov5670->mutex); in ov5670_set_stream()
2379 struct ov5670 *ov5670 = to_ov5670(sd); in ov5670_suspend() local
2381 if (ov5670->streaming) in ov5670_suspend()
2382 ov5670_stop_streaming(ov5670); in ov5670_suspend()
2391 struct ov5670 *ov5670 = to_ov5670(sd); in ov5670_resume() local
2394 if (ov5670->streaming) { in ov5670_resume()
2395 ret = ov5670_start_streaming(ov5670); in ov5670_resume()
2397 ov5670_stop_streaming(ov5670); in ov5670_resume()
2406 static int ov5670_identify_module(struct ov5670 *ov5670) in ov5670_identify_module() argument
2408 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); in ov5670_identify_module()
2412 ret = ov5670_read_reg(ov5670, OV5670_REG_CHIP_ID, in ov5670_identify_module()
2457 struct ov5670 *ov5670; in ov5670_probe() local
2466 ov5670 = devm_kzalloc(&client->dev, sizeof(*ov5670), GFP_KERNEL); in ov5670_probe()
2467 if (!ov5670) { in ov5670_probe()
2474 v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops); in ov5670_probe()
2477 ret = ov5670_identify_module(ov5670); in ov5670_probe()
2483 mutex_init(&ov5670->mutex); in ov5670_probe()
2486 ov5670->cur_mode = &supported_modes[0]; in ov5670_probe()
2488 ret = ov5670_init_controls(ov5670); in ov5670_probe()
2494 ov5670->sd.internal_ops = &ov5670_internal_ops; in ov5670_probe()
2495 ov5670->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ov5670_probe()
2496 ov5670->sd.entity.ops = &ov5670_subdev_entity_ops; in ov5670_probe()
2497 ov5670->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov5670_probe()
2500 ov5670->pad.flags = MEDIA_PAD_FL_SOURCE; in ov5670_probe()
2501 ret = media_entity_pads_init(&ov5670->sd.entity, 1, &ov5670->pad); in ov5670_probe()
2508 ret = v4l2_async_register_subdev_sensor_common(&ov5670->sd); in ov5670_probe()
2514 ov5670->streaming = false; in ov5670_probe()
2527 media_entity_cleanup(&ov5670->sd.entity); in ov5670_probe()
2530 v4l2_ctrl_handler_free(ov5670->sd.ctrl_handler); in ov5670_probe()
2533 mutex_destroy(&ov5670->mutex); in ov5670_probe()
2544 struct ov5670 *ov5670 = to_ov5670(sd); in ov5670_remove() local
2549 mutex_destroy(&ov5670->mutex); in ov5670_remove()
2571 .name = "ov5670",
2583 MODULE_DESCRIPTION("Omnivision ov5670 sensor driver");