Lines Matching refs:ov08x

1307 static int ov08x40_read_reg(struct ov08x40 *ov08x,  in ov08x40_read_reg()  argument
1310 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_read_reg()
1342 static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg, in ov08x40_burst_fill_regs() argument
1345 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_burst_fill_regs()
1377 static int ov08x40_write_reg(struct ov08x40 *ov08x, in ov08x40_write_reg() argument
1380 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_write_reg()
1406 static int ov08x40_write_regs(struct ov08x40 *ov08x, in ov08x40_write_regs() argument
1409 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_write_regs()
1414 ret = ov08x40_write_reg(ov08x, regs[i].address, 1, in ov08x40_write_regs()
1429 static int ov08x40_write_reg_list(struct ov08x40 *ov08x, in ov08x40_write_reg_list() argument
1432 return ov08x40_write_regs(ov08x, r_list->regs, r_list->num_of_regs); in ov08x40_write_reg_list()
1438 struct ov08x40 *ov08x = to_ov08x40(sd); in ov08x40_open() local
1442 mutex_lock(&ov08x->mutex); in ov08x40_open()
1451 mutex_unlock(&ov08x->mutex); in ov08x40_open()
1456 static int ov08x40_update_digital_gain(struct ov08x40 *ov08x, u32 d_gain) in ov08x40_update_digital_gain() argument
1466 ret = ov08x40_write_reg(ov08x, OV08X40_REG_DGTL_GAIN_L, in ov08x40_update_digital_gain()
1472 ret = ov08x40_write_reg(ov08x, OV08X40_REG_DGTL_GAIN_M, in ov08x40_update_digital_gain()
1479 return ov08x40_write_reg(ov08x, OV08X40_REG_DGTL_GAIN_H, in ov08x40_update_digital_gain()
1483 static int ov08x40_enable_test_pattern(struct ov08x40 *ov08x, u32 pattern) in ov08x40_enable_test_pattern() argument
1488 ret = ov08x40_read_reg(ov08x, OV08X40_REG_TEST_PATTERN, in ov08x40_enable_test_pattern()
1494 ret = ov08x40_read_reg(ov08x, OV08X40_REG_ISP, in ov08x40_enable_test_pattern()
1499 ret = ov08x40_write_reg(ov08x, OV08X40_REG_ISP, in ov08x40_enable_test_pattern()
1505 ret = ov08x40_read_reg(ov08x, OV08X40_REG_SHORT_TEST_PATTERN, in ov08x40_enable_test_pattern()
1510 ret = ov08x40_write_reg(ov08x, OV08X40_REG_SHORT_TEST_PATTERN, in ov08x40_enable_test_pattern()
1516 ret = ov08x40_read_reg(ov08x, OV08X40_REG_TEST_PATTERN, in ov08x40_enable_test_pattern()
1528 return ov08x40_write_reg(ov08x, OV08X40_REG_TEST_PATTERN, in ov08x40_enable_test_pattern()
1532 static int ov08x40_set_ctrl_hflip(struct ov08x40 *ov08x, u32 ctrl_val) in ov08x40_set_ctrl_hflip() argument
1537 ret = ov08x40_read_reg(ov08x, OV08X40_REG_MIRROR, in ov08x40_set_ctrl_hflip()
1542 return ov08x40_write_reg(ov08x, OV08X40_REG_MIRROR, in ov08x40_set_ctrl_hflip()
1547 static int ov08x40_set_ctrl_vflip(struct ov08x40 *ov08x, u32 ctrl_val) in ov08x40_set_ctrl_vflip() argument
1552 ret = ov08x40_read_reg(ov08x, OV08X40_REG_VFLIP, in ov08x40_set_ctrl_vflip()
1557 return ov08x40_write_reg(ov08x, OV08X40_REG_VFLIP, in ov08x40_set_ctrl_vflip()
1564 struct ov08x40 *ov08x = container_of(ctrl->handler, in ov08x40_set_ctrl() local
1566 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_set_ctrl()
1581 max = ((ov08x->cur_mode->height + ctrl->val) << in ov08x40_set_ctrl()
1582 ov08x->cur_mode->exposure_shift) - in ov08x40_set_ctrl()
1583 ov08x->cur_mode->exposure_margin; in ov08x40_set_ctrl()
1585 __v4l2_ctrl_modify_range(ov08x->exposure, in ov08x40_set_ctrl()
1586 ov08x->exposure->minimum, in ov08x40_set_ctrl()
1587 max, ov08x->exposure->step, max); in ov08x40_set_ctrl()
1600 ret = ov08x40_write_reg(ov08x, OV08X40_REG_ANALOG_GAIN, in ov08x40_set_ctrl()
1605 ret = ov08x40_update_digital_gain(ov08x, ctrl->val); in ov08x40_set_ctrl()
1608 exp = (ctrl->val << ov08x->cur_mode->exposure_shift) - in ov08x40_set_ctrl()
1609 ov08x->cur_mode->exposure_margin; in ov08x40_set_ctrl()
1611 ret = ov08x40_write_reg(ov08x, OV08X40_REG_EXPOSURE, in ov08x40_set_ctrl()
1616 fll = ((ov08x->cur_mode->height + ctrl->val) << in ov08x40_set_ctrl()
1617 ov08x->cur_mode->exposure_shift); in ov08x40_set_ctrl()
1619 ret = ov08x40_write_reg(ov08x, OV08X40_REG_VTS, in ov08x40_set_ctrl()
1624 ret = ov08x40_enable_test_pattern(ov08x, ctrl->val); in ov08x40_set_ctrl()
1627 ov08x40_set_ctrl_hflip(ov08x, ctrl->val); in ov08x40_set_ctrl()
1630 ov08x40_set_ctrl_vflip(ov08x, ctrl->val); in ov08x40_set_ctrl()
1688 static int ov08x40_do_get_pad_format(struct ov08x40 *ov08x, in ov08x40_do_get_pad_format() argument
1698 ov08x40_update_pad_format(ov08x->cur_mode, fmt); in ov08x40_do_get_pad_format()
1708 struct ov08x40 *ov08x = to_ov08x40(sd); in ov08x40_get_pad_format() local
1711 mutex_lock(&ov08x->mutex); in ov08x40_get_pad_format()
1712 ret = ov08x40_do_get_pad_format(ov08x, sd_state, fmt); in ov08x40_get_pad_format()
1713 mutex_unlock(&ov08x->mutex); in ov08x40_get_pad_format()
1723 struct ov08x40 *ov08x = to_ov08x40(sd); in ov08x40_set_pad_format() local
1733 mutex_lock(&ov08x->mutex); in ov08x40_set_pad_format()
1748 ov08x->cur_mode = mode; in ov08x40_set_pad_format()
1749 __v4l2_ctrl_s_ctrl(ov08x->link_freq, mode->link_freq_index); in ov08x40_set_pad_format()
1752 __v4l2_ctrl_s_ctrl_int64(ov08x->pixel_rate, pixel_rate); in ov08x40_set_pad_format()
1755 vblank_def = ov08x->cur_mode->vts_def - in ov08x40_set_pad_format()
1756 ov08x->cur_mode->height; in ov08x40_set_pad_format()
1757 vblank_min = ov08x->cur_mode->vts_min - in ov08x40_set_pad_format()
1758 ov08x->cur_mode->height; in ov08x40_set_pad_format()
1766 __v4l2_ctrl_modify_range(ov08x->vblank, vblank_min, in ov08x40_set_pad_format()
1768 - ov08x->cur_mode->height, in ov08x40_set_pad_format()
1771 __v4l2_ctrl_s_ctrl(ov08x->vblank, vblank_def); in ov08x40_set_pad_format()
1773 h_blank = ov08x->cur_mode->llp - ov08x->cur_mode->width; in ov08x40_set_pad_format()
1775 __v4l2_ctrl_modify_range(ov08x->hblank, h_blank, in ov08x40_set_pad_format()
1779 mutex_unlock(&ov08x->mutex); in ov08x40_set_pad_format()
1784 static int ov08x40_start_streaming(struct ov08x40 *ov08x) in ov08x40_start_streaming() argument
1786 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_start_streaming()
1791 ret = ov08x40_write_reg(ov08x, OV08X40_REG_SOFTWARE_RST, in ov08x40_start_streaming()
1799 link_freq_index = ov08x->cur_mode->link_freq_index; in ov08x40_start_streaming()
1802 ret = ov08x40_write_reg_list(ov08x, reg_list); in ov08x40_start_streaming()
1809 reg_list = &ov08x->cur_mode->reg_list; in ov08x40_start_streaming()
1810 ret = ov08x40_write_reg_list(ov08x, reg_list); in ov08x40_start_streaming()
1817 if (ov08x->cur_mode->exposure_shift == 1) { in ov08x40_start_streaming()
1818 ret = ov08x40_burst_fill_regs(ov08x, OV08X40_REG_XTALK_FIRST_A, in ov08x40_start_streaming()
1821 ret = ov08x40_burst_fill_regs(ov08x, in ov08x40_start_streaming()
1833 ret = __v4l2_ctrl_handler_setup(ov08x->sd.ctrl_handler); in ov08x40_start_streaming()
1837 return ov08x40_write_reg(ov08x, OV08X40_REG_MODE_SELECT, in ov08x40_start_streaming()
1843 static int ov08x40_stop_streaming(struct ov08x40 *ov08x) in ov08x40_stop_streaming() argument
1845 return ov08x40_write_reg(ov08x, OV08X40_REG_MODE_SELECT, in ov08x40_stop_streaming()
1851 struct ov08x40 *ov08x = to_ov08x40(sd); in ov08x40_set_stream() local
1855 mutex_lock(&ov08x->mutex); in ov08x40_set_stream()
1866 ret = ov08x40_start_streaming(ov08x); in ov08x40_set_stream()
1870 ov08x40_stop_streaming(ov08x); in ov08x40_set_stream()
1874 mutex_unlock(&ov08x->mutex); in ov08x40_set_stream()
1881 mutex_unlock(&ov08x->mutex); in ov08x40_set_stream()
1887 static int ov08x40_identify_module(struct ov08x40 *ov08x) in ov08x40_identify_module() argument
1889 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_identify_module()
1893 if (ov08x->identified) in ov08x40_identify_module()
1896 ret = ov08x40_read_reg(ov08x, OV08X40_REG_CHIP_ID, in ov08x40_identify_module()
1907 ov08x->identified = true; in ov08x40_identify_module()
1936 static int ov08x40_init_controls(struct ov08x40 *ov08x) in ov08x40_init_controls() argument
1938 struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); in ov08x40_init_controls()
1951 ctrl_hdlr = &ov08x->ctrl_handler; in ov08x40_init_controls()
1956 mutex_init(&ov08x->mutex); in ov08x40_init_controls()
1957 ctrl_hdlr->lock = &ov08x->mutex; in ov08x40_init_controls()
1959 ov08x->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, in ov08x40_init_controls()
1965 if (ov08x->link_freq) in ov08x40_init_controls()
1966 ov08x->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov08x40_init_controls()
1971 ov08x->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov08x40_ctrl_ops, in ov08x40_init_controls()
1976 mode = ov08x->cur_mode; in ov08x40_init_controls()
1979 ov08x->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov08x40_ctrl_ops, in ov08x40_init_controls()
1985 hblank = ov08x->cur_mode->llp - ov08x->cur_mode->width; in ov08x40_init_controls()
1987 ov08x->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov08x40_ctrl_ops, in ov08x40_init_controls()
1990 if (ov08x->hblank) in ov08x40_init_controls()
1991 ov08x->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov08x40_init_controls()
1994 ov08x->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov08x40_ctrl_ops, in ov08x40_init_controls()
2035 ov08x->sd.ctrl_handler = ctrl_hdlr; in ov08x40_init_controls()
2041 mutex_destroy(&ov08x->mutex); in ov08x40_init_controls()
2046 static void ov08x40_free_controls(struct ov08x40 *ov08x) in ov08x40_free_controls() argument
2048 v4l2_ctrl_handler_free(ov08x->sd.ctrl_handler); in ov08x40_free_controls()
2049 mutex_destroy(&ov08x->mutex); in ov08x40_free_controls()
2124 struct ov08x40 *ov08x; in ov08x40_probe() local
2135 ov08x = devm_kzalloc(&client->dev, sizeof(*ov08x), GFP_KERNEL); in ov08x40_probe()
2136 if (!ov08x) in ov08x40_probe()
2140 v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops); in ov08x40_probe()
2145 ret = ov08x40_identify_module(ov08x); in ov08x40_probe()
2153 ov08x->cur_mode = &supported_modes[0]; in ov08x40_probe()
2155 ret = ov08x40_init_controls(ov08x); in ov08x40_probe()
2160 ov08x->sd.internal_ops = &ov08x40_internal_ops; in ov08x40_probe()
2161 ov08x->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ov08x40_probe()
2162 ov08x->sd.entity.ops = &ov08x40_subdev_entity_ops; in ov08x40_probe()
2163 ov08x->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in ov08x40_probe()
2166 ov08x->pad.flags = MEDIA_PAD_FL_SOURCE; in ov08x40_probe()
2167 ret = media_entity_pads_init(&ov08x->sd.entity, 1, &ov08x->pad); in ov08x40_probe()
2173 ret = v4l2_async_register_subdev_sensor(&ov08x->sd); in ov08x40_probe()
2185 media_entity_cleanup(&ov08x->sd.entity); in ov08x40_probe()
2188 ov08x40_free_controls(ov08x); in ov08x40_probe()
2196 struct ov08x40 *ov08x = to_ov08x40(sd); in ov08x40_remove() local
2200 ov08x40_free_controls(ov08x); in ov08x40_remove()