Lines Matching full:ov8858
106 struct ov8858 { struct
125 static inline struct ov8858 *sd_to_ov8858(struct v4l2_subdev *sd) in sd_to_ov8858() argument
127 return container_of(sd, struct ov8858, subdev); in sd_to_ov8858()
1242 static int ov8858_write(struct ov8858 *ov8858, u32 reg, u32 val, int *err) in ov8858_write() argument
1244 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_write()
1270 static int ov8858_write_array(struct ov8858 *ov8858, const struct regval *regs) in ov8858_write_array() argument
1276 ov8858_write(ov8858, OV8858_REG_8BIT(regs[i].addr), in ov8858_write_array()
1283 static int ov8858_read(struct ov8858 *ov8858, u32 reg, u32 *val) in ov8858_read() argument
1285 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_read()
1324 static int ov8858_start_stream(struct ov8858 *ov8858, in ov8858_start_stream() argument
1332 ret = ov8858_write_array(ov8858, ov8858->global_regs); in ov8858_start_stream()
1336 format = v4l2_subdev_get_pad_format(&ov8858->subdev, state, 0); in ov8858_start_stream()
1341 reg_list = ov8858->num_lanes == 4 in ov8858_start_stream()
1345 ret = ov8858_write_array(ov8858, reg_list); in ov8858_start_stream()
1352 ret = __v4l2_ctrl_handler_setup(&ov8858->ctrl_handler); in ov8858_start_stream()
1356 ret = ov8858_write(ov8858, OV8858_REG_SC_CTRL0100, in ov8858_start_stream()
1367 static int ov8858_stop_stream(struct ov8858 *ov8858) in ov8858_stop_stream() argument
1369 return ov8858_write(ov8858, OV8858_REG_SC_CTRL0100, in ov8858_stop_stream()
1376 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_s_stream() local
1387 ret = ov8858_start_stream(ov8858, state); in ov8858_s_stream()
1394 ov8858_stop_stream(ov8858); in ov8858_s_stream()
1417 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_set_fmt() local
1438 __v4l2_ctrl_modify_range(ov8858->hblank, h_blank, h_blank, 1, in ov8858_set_fmt()
1442 __v4l2_ctrl_modify_range(ov8858->vblank, vblank_def, in ov8858_set_fmt()
1519 static int ov8858_enable_test_pattern(struct ov8858 *ov8858, u32 pattern) in ov8858_enable_test_pattern() argument
1528 return ov8858_write(ov8858, OV8858_REG_TEST_PATTERN, val, NULL); in ov8858_enable_test_pattern()
1533 struct ov8858 *ov8858 = container_of(ctrl->handler, in ov8858_set_ctrl() local
1534 struct ov8858, ctrl_handler); in ov8858_set_ctrl()
1536 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_set_ctrl()
1549 state = v4l2_subdev_get_locked_active_state(&ov8858->subdev); in ov8858_set_ctrl()
1550 format = v4l2_subdev_get_pad_format(&ov8858->subdev, state, 0); in ov8858_set_ctrl()
1557 __v4l2_ctrl_modify_range(ov8858->exposure, in ov8858_set_ctrl()
1558 ov8858->exposure->minimum, max_exp, in ov8858_set_ctrl()
1559 ov8858->exposure->step, in ov8858_set_ctrl()
1560 ov8858->exposure->default_value); in ov8858_set_ctrl()
1570 ret = ov8858_write(ov8858, OV8858_REG_LONG_EXPO, in ov8858_set_ctrl()
1574 ret = ov8858_write(ov8858, OV8858_REG_LONG_GAIN, in ov8858_set_ctrl()
1587 ret = ov8858_write(ov8858, OV8858_REG_LONG_DIGIGAIN, in ov8858_set_ctrl()
1591 ret = ov8858_write(ov8858, OV8858_REG_VTS, in ov8858_set_ctrl()
1595 ret = ov8858_enable_test_pattern(ov8858, ctrl->val); in ov8858_set_ctrl()
1617 static int ov8858_power_on(struct ov8858 *ov8858) in ov8858_power_on() argument
1619 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_power_on()
1624 if (clk_get_rate(ov8858->xvclk) != OV8858_XVCLK_FREQ) in ov8858_power_on()
1627 ret = clk_prepare_enable(ov8858->xvclk); in ov8858_power_on()
1634 ov8858->supplies); in ov8858_power_on()
1647 gpiod_set_value_cansleep(ov8858->reset_gpio, 0); in ov8858_power_on()
1649 gpiod_set_value_cansleep(ov8858->pwdn_gpio, 0); in ov8858_power_on()
1655 clk_disable_unprepare(ov8858->xvclk); in ov8858_power_on()
1660 static void ov8858_power_off(struct ov8858 *ov8858) in ov8858_power_off() argument
1662 gpiod_set_value_cansleep(ov8858->pwdn_gpio, 1); in ov8858_power_off()
1663 clk_disable_unprepare(ov8858->xvclk); in ov8858_power_off()
1664 gpiod_set_value_cansleep(ov8858->reset_gpio, 1); in ov8858_power_off()
1667 ov8858->supplies); in ov8858_power_off()
1674 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_runtime_resume() local
1676 return ov8858_power_on(ov8858); in ov8858_runtime_resume()
1683 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_runtime_suspend() local
1685 ov8858_power_off(ov8858); in ov8858_runtime_suspend()
1699 static int ov8858_init_ctrls(struct ov8858 *ov8858) in ov8858_init_ctrls() argument
1701 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_init_ctrls()
1702 struct v4l2_ctrl_handler *handler = &ov8858->ctrl_handler; in ov8858_init_ctrls()
1721 pixel_rate = OV8858_LINK_FREQ * 2 * ov8858->num_lanes / 10; in ov8858_init_ctrls()
1726 ov8858->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov8858_init_ctrls()
1728 if (ov8858->hblank) in ov8858_init_ctrls()
1729 ov8858->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov8858_init_ctrls()
1732 ov8858->vblank = v4l2_ctrl_new_std(handler, &ov8858_ctrl_ops, in ov8858_init_ctrls()
1738 ov8858->exposure = v4l2_ctrl_new_std(handler, &ov8858_ctrl_ops, in ov8858_init_ctrls()
1772 ov8858->subdev.ctrl_handler = handler; in ov8858_init_ctrls()
1783 static int ov8858_check_sensor_id(struct ov8858 *ov8858) in ov8858_check_sensor_id() argument
1785 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_check_sensor_id()
1789 ret = ov8858_read(ov8858, OV8858_REG_CHIP_ID, &id); in ov8858_check_sensor_id()
1798 ret = ov8858_read(ov8858, OV8858_REG_SUB_ID, &id); in ov8858_check_sensor_id()
1802 dev_info(&client->dev, "Detected OV8858 sensor, revision 0x%x\n", id); in ov8858_check_sensor_id()
1806 ov8858->global_regs = ov8858->num_lanes == 4 in ov8858_check_sensor_id()
1809 } else if (ov8858->num_lanes == 2) { in ov8858_check_sensor_id()
1814 ov8858->global_regs = ov8858_global_regs_r1a; in ov8858_check_sensor_id()
1825 static int ov8858_configure_regulators(struct ov8858 *ov8858) in ov8858_configure_regulators() argument
1827 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_configure_regulators()
1831 ov8858->supplies[i].supply = ov8858_supply_names[i]; in ov8858_configure_regulators()
1835 ov8858->supplies); in ov8858_configure_regulators()
1838 static int ov8858_parse_of(struct ov8858 *ov8858) in ov8858_parse_of() argument
1841 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_parse_of()
1859 ov8858->num_lanes = vep.bus.mipi_csi2.num_data_lanes; in ov8858_parse_of()
1860 switch (ov8858->num_lanes) { in ov8858_parse_of()
1866 ov8858->num_lanes); in ov8858_parse_of()
1877 struct ov8858 *ov8858; in ov8858_probe() local
1880 ov8858 = devm_kzalloc(dev, sizeof(*ov8858), GFP_KERNEL); in ov8858_probe()
1881 if (!ov8858) in ov8858_probe()
1884 ov8858->xvclk = devm_clk_get(dev, "xvclk"); in ov8858_probe()
1885 if (IS_ERR(ov8858->xvclk)) in ov8858_probe()
1886 return dev_err_probe(dev, PTR_ERR(ov8858->xvclk), in ov8858_probe()
1889 ov8858->reset_gpio = devm_gpiod_get_optional(dev, "reset", in ov8858_probe()
1891 if (IS_ERR(ov8858->reset_gpio)) in ov8858_probe()
1892 return dev_err_probe(dev, PTR_ERR(ov8858->reset_gpio), in ov8858_probe()
1895 ov8858->pwdn_gpio = devm_gpiod_get_optional(dev, "powerdown", in ov8858_probe()
1897 if (IS_ERR(ov8858->pwdn_gpio)) in ov8858_probe()
1898 return dev_err_probe(dev, PTR_ERR(ov8858->pwdn_gpio), in ov8858_probe()
1901 v4l2_i2c_subdev_init(&ov8858->subdev, client, &ov8858_subdev_ops); in ov8858_probe()
1903 ret = ov8858_configure_regulators(ov8858); in ov8858_probe()
1907 ret = ov8858_parse_of(ov8858); in ov8858_probe()
1911 ret = ov8858_init_ctrls(ov8858); in ov8858_probe()
1915 sd = &ov8858->subdev; in ov8858_probe()
1917 ov8858->pad.flags = MEDIA_PAD_FL_SOURCE; in ov8858_probe()
1919 ret = media_entity_pads_init(&sd->entity, 1, &ov8858->pad); in ov8858_probe()
1923 sd->state_lock = ov8858->ctrl_handler.lock; in ov8858_probe()
1930 ret = ov8858_power_on(ov8858); in ov8858_probe()
1938 ret = ov8858_check_sensor_id(ov8858); in ov8858_probe()
1959 ov8858_power_off(ov8858); in ov8858_probe()
1963 v4l2_ctrl_handler_free(&ov8858->ctrl_handler); in ov8858_probe()
1971 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_remove() local
1975 v4l2_ctrl_handler_free(&ov8858->ctrl_handler); in ov8858_remove()
1979 ov8858_power_off(ov8858); in ov8858_remove()
1984 { .compatible = "ovti,ov8858" },
1991 .name = "ov8858",
2001 MODULE_DESCRIPTION("OmniVision OV8858 sensor driver");