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()
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()
1522 static int ov8858_enable_test_pattern(struct ov8858 *ov8858, u32 pattern) in ov8858_enable_test_pattern() argument
1531 return ov8858_write(ov8858, OV8858_REG_TEST_PATTERN, val, NULL); in ov8858_enable_test_pattern()
1536 struct ov8858 *ov8858 = container_of(ctrl->handler, in ov8858_set_ctrl() local
1537 struct ov8858, ctrl_handler); in ov8858_set_ctrl()
1539 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_set_ctrl()
1552 state = v4l2_subdev_get_locked_active_state(&ov8858->subdev); in ov8858_set_ctrl()
1560 __v4l2_ctrl_modify_range(ov8858->exposure, in ov8858_set_ctrl()
1561 ov8858->exposure->minimum, max_exp, in ov8858_set_ctrl()
1562 ov8858->exposure->step, in ov8858_set_ctrl()
1563 ov8858->exposure->default_value); in ov8858_set_ctrl()
1573 ret = ov8858_write(ov8858, OV8858_REG_LONG_EXPO, in ov8858_set_ctrl()
1577 ret = ov8858_write(ov8858, OV8858_REG_LONG_GAIN, in ov8858_set_ctrl()
1590 ret = ov8858_write(ov8858, OV8858_REG_LONG_DIGIGAIN, in ov8858_set_ctrl()
1594 ret = ov8858_write(ov8858, OV8858_REG_VTS, in ov8858_set_ctrl()
1598 ret = ov8858_enable_test_pattern(ov8858, ctrl->val); in ov8858_set_ctrl()
1620 static int ov8858_power_on(struct ov8858 *ov8858) in ov8858_power_on() argument
1622 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_power_on()
1627 if (clk_get_rate(ov8858->xvclk) != OV8858_XVCLK_FREQ) in ov8858_power_on()
1630 ret = clk_prepare_enable(ov8858->xvclk); in ov8858_power_on()
1637 ov8858->supplies); in ov8858_power_on()
1650 gpiod_set_value_cansleep(ov8858->reset_gpio, 0); in ov8858_power_on()
1652 gpiod_set_value_cansleep(ov8858->pwdn_gpio, 0); in ov8858_power_on()
1658 clk_disable_unprepare(ov8858->xvclk); in ov8858_power_on()
1663 static void ov8858_power_off(struct ov8858 *ov8858) in ov8858_power_off() argument
1665 gpiod_set_value_cansleep(ov8858->pwdn_gpio, 1); in ov8858_power_off()
1666 clk_disable_unprepare(ov8858->xvclk); in ov8858_power_off()
1667 gpiod_set_value_cansleep(ov8858->reset_gpio, 1); in ov8858_power_off()
1670 ov8858->supplies); in ov8858_power_off()
1677 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_runtime_resume() local
1679 return ov8858_power_on(ov8858); in ov8858_runtime_resume()
1686 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_runtime_suspend() local
1688 ov8858_power_off(ov8858); in ov8858_runtime_suspend()
1702 static int ov8858_init_ctrls(struct ov8858 *ov8858) in ov8858_init_ctrls() argument
1704 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_init_ctrls()
1705 struct v4l2_ctrl_handler *handler = &ov8858->ctrl_handler; in ov8858_init_ctrls()
1724 pixel_rate = OV8858_LINK_FREQ * 2 * ov8858->num_lanes / 10; in ov8858_init_ctrls()
1729 ov8858->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov8858_init_ctrls()
1731 if (ov8858->hblank) in ov8858_init_ctrls()
1732 ov8858->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov8858_init_ctrls()
1735 ov8858->vblank = v4l2_ctrl_new_std(handler, &ov8858_ctrl_ops, in ov8858_init_ctrls()
1741 ov8858->exposure = v4l2_ctrl_new_std(handler, &ov8858_ctrl_ops, in ov8858_init_ctrls()
1775 ov8858->subdev.ctrl_handler = handler; in ov8858_init_ctrls()
1786 static int ov8858_check_sensor_id(struct ov8858 *ov8858) in ov8858_check_sensor_id() argument
1788 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_check_sensor_id()
1792 ret = ov8858_read(ov8858, OV8858_REG_CHIP_ID, &id); in ov8858_check_sensor_id()
1801 ret = ov8858_read(ov8858, OV8858_REG_SUB_ID, &id); in ov8858_check_sensor_id()
1805 dev_info(&client->dev, "Detected OV8858 sensor, revision 0x%x\n", id); in ov8858_check_sensor_id()
1809 ov8858->global_regs = ov8858->num_lanes == 4 in ov8858_check_sensor_id()
1812 } else if (ov8858->num_lanes == 2) { in ov8858_check_sensor_id()
1817 ov8858->global_regs = ov8858_global_regs_r1a; in ov8858_check_sensor_id()
1828 static int ov8858_configure_regulators(struct ov8858 *ov8858) in ov8858_configure_regulators() argument
1830 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_configure_regulators()
1834 ov8858->supplies[i].supply = ov8858_supply_names[i]; in ov8858_configure_regulators()
1838 ov8858->supplies); in ov8858_configure_regulators()
1841 static int ov8858_parse_of(struct ov8858 *ov8858) in ov8858_parse_of() argument
1844 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_parse_of()
1862 ov8858->num_lanes = vep.bus.mipi_csi2.num_data_lanes; in ov8858_parse_of()
1863 switch (ov8858->num_lanes) { in ov8858_parse_of()
1869 ov8858->num_lanes); in ov8858_parse_of()
1880 struct ov8858 *ov8858; in ov8858_probe() local
1883 ov8858 = devm_kzalloc(dev, sizeof(*ov8858), GFP_KERNEL); in ov8858_probe()
1884 if (!ov8858) in ov8858_probe()
1887 ov8858->xvclk = devm_clk_get(dev, "xvclk"); in ov8858_probe()
1888 if (IS_ERR(ov8858->xvclk)) in ov8858_probe()
1889 return dev_err_probe(dev, PTR_ERR(ov8858->xvclk), in ov8858_probe()
1892 ov8858->reset_gpio = devm_gpiod_get_optional(dev, "reset", in ov8858_probe()
1894 if (IS_ERR(ov8858->reset_gpio)) in ov8858_probe()
1895 return dev_err_probe(dev, PTR_ERR(ov8858->reset_gpio), in ov8858_probe()
1898 ov8858->pwdn_gpio = devm_gpiod_get_optional(dev, "powerdown", in ov8858_probe()
1900 if (IS_ERR(ov8858->pwdn_gpio)) in ov8858_probe()
1901 return dev_err_probe(dev, PTR_ERR(ov8858->pwdn_gpio), in ov8858_probe()
1904 v4l2_i2c_subdev_init(&ov8858->subdev, client, &ov8858_subdev_ops); in ov8858_probe()
1905 ov8858->subdev.internal_ops = &ov8858_internal_ops; in ov8858_probe()
1907 ret = ov8858_configure_regulators(ov8858); in ov8858_probe()
1911 ret = ov8858_parse_of(ov8858); in ov8858_probe()
1915 ret = ov8858_init_ctrls(ov8858); in ov8858_probe()
1919 sd = &ov8858->subdev; in ov8858_probe()
1921 ov8858->pad.flags = MEDIA_PAD_FL_SOURCE; in ov8858_probe()
1923 ret = media_entity_pads_init(&sd->entity, 1, &ov8858->pad); in ov8858_probe()
1927 sd->state_lock = ov8858->ctrl_handler.lock; in ov8858_probe()
1934 ret = ov8858_power_on(ov8858); in ov8858_probe()
1942 ret = ov8858_check_sensor_id(ov8858); in ov8858_probe()
1963 ov8858_power_off(ov8858); in ov8858_probe()
1967 v4l2_ctrl_handler_free(&ov8858->ctrl_handler); in ov8858_probe()
1975 struct ov8858 *ov8858 = sd_to_ov8858(sd); in ov8858_remove() local
1979 v4l2_ctrl_handler_free(&ov8858->ctrl_handler); in ov8858_remove()
1983 ov8858_power_off(ov8858); in ov8858_remove()
1988 { .compatible = "ovti,ov8858" },
1995 .name = "ov8858",
2005 MODULE_DESCRIPTION("OmniVision OV8858 sensor driver");