Lines Matching defs:ov13855

3  * ov13855 camera driver
86 #define OV13855_NAME "ov13855"
114 struct ov13855 {
147 #define to_ov13855(sd) container_of(sd, struct ov13855, subdev)
1190 struct ov13855 *ov13855 = to_ov13855(sd);
1196 mutex_lock(&ov13855->mutex);
1207 mutex_unlock(&ov13855->mutex);
1211 ov13855->cur_mode = mode;
1213 __v4l2_ctrl_modify_range(ov13855->hblank, h_blank,
1216 __v4l2_ctrl_modify_range(ov13855->vblank, vblank_def,
1221 __v4l2_ctrl_s_ctrl_int64(ov13855->pixel_rate,
1223 __v4l2_ctrl_s_ctrl(ov13855->link_freq,
1227 mutex_unlock(&ov13855->mutex);
1236 struct ov13855 *ov13855 = to_ov13855(sd);
1237 const struct ov13855_mode *mode = ov13855->cur_mode;
1239 mutex_lock(&ov13855->mutex);
1244 mutex_unlock(&ov13855->mutex);
1253 mutex_unlock(&ov13855->mutex);
1287 static int ov13855_enable_test_pattern(struct ov13855 *ov13855, u32 pattern)
1296 return ov13855_write_reg(ov13855->client,
1305 struct ov13855 *ov13855 = to_ov13855(sd);
1306 const struct ov13855_mode *mode = ov13855->cur_mode;
1308 mutex_lock(&ov13855->mutex);
1310 mutex_unlock(&ov13855->mutex);
1315 static void ov13855_get_module_inf(struct ov13855 *ov13855,
1320 strscpy(inf->base.module, ov13855->module_name,
1322 strscpy(inf->base.lens, ov13855->len_name, sizeof(inf->base.lens));
1327 struct ov13855 *ov13855 = to_ov13855(sd);
1333 ov13855_get_module_inf(ov13855, (struct rkmodule_inf *)arg);
1340 ret = ov13855_write_reg(ov13855->client,
1345 ret = ov13855_write_reg(ov13855->client,
1414 static int __ov13855_start_stream(struct ov13855 *ov13855)
1418 ret = ov13855_write_array(ov13855->client, ov13855->cur_mode->reg_list);
1423 mutex_unlock(&ov13855->mutex);
1424 ret = v4l2_ctrl_handler_setup(&ov13855->ctrl_handler);
1425 mutex_lock(&ov13855->mutex);
1429 return ov13855_write_reg(ov13855->client,
1435 static int __ov13855_stop_stream(struct ov13855 *ov13855)
1437 return ov13855_write_reg(ov13855->client,
1445 struct ov13855 *ov13855 = to_ov13855(sd);
1446 struct i2c_client *client = ov13855->client;
1449 mutex_lock(&ov13855->mutex);
1451 if (on == ov13855->streaming)
1461 ret = __ov13855_start_stream(ov13855);
1468 __ov13855_stop_stream(ov13855);
1472 ov13855->streaming = on;
1475 mutex_unlock(&ov13855->mutex);
1482 struct ov13855 *ov13855 = to_ov13855(sd);
1483 struct i2c_client *client = ov13855->client;
1486 mutex_lock(&ov13855->mutex);
1489 if (ov13855->power_on == !!on)
1499 ret = ov13855_write_array(ov13855->client, ov13855_global_regs);
1506 ov13855->power_on = true;
1509 ov13855->power_on = false;
1513 mutex_unlock(&ov13855->mutex);
1524 static int __ov13855_power_on(struct ov13855 *ov13855)
1528 struct device *dev = &ov13855->client->dev;
1530 if (!IS_ERR(ov13855->power_gpio))
1531 gpiod_set_value_cansleep(ov13855->power_gpio, 1);
1535 if (!IS_ERR_OR_NULL(ov13855->pins_default)) {
1536 ret = pinctrl_select_state(ov13855->pinctrl,
1537 ov13855->pins_default);
1541 ret = clk_set_rate(ov13855->xvclk, OV13855_XVCLK_FREQ);
1544 if (clk_get_rate(ov13855->xvclk) != OV13855_XVCLK_FREQ)
1546 ret = clk_prepare_enable(ov13855->xvclk);
1551 if (!IS_ERR(ov13855->reset_gpio))
1552 gpiod_set_value_cansleep(ov13855->reset_gpio, 0);
1554 ret = regulator_bulk_enable(OV13855_NUM_SUPPLIES, ov13855->supplies);
1560 if (!IS_ERR(ov13855->reset_gpio))
1561 gpiod_set_value_cansleep(ov13855->reset_gpio, 1);
1564 if (!IS_ERR(ov13855->pwdn_gpio))
1565 gpiod_set_value_cansleep(ov13855->pwdn_gpio, 1);
1574 clk_disable_unprepare(ov13855->xvclk);
1579 static void __ov13855_power_off(struct ov13855 *ov13855)
1582 struct device *dev = &ov13855->client->dev;
1584 if (!IS_ERR(ov13855->pwdn_gpio))
1585 gpiod_set_value_cansleep(ov13855->pwdn_gpio, 0);
1586 clk_disable_unprepare(ov13855->xvclk);
1587 if (!IS_ERR(ov13855->reset_gpio))
1588 gpiod_set_value_cansleep(ov13855->reset_gpio, 0);
1590 if (!IS_ERR_OR_NULL(ov13855->pins_sleep)) {
1591 ret = pinctrl_select_state(ov13855->pinctrl,
1592 ov13855->pins_sleep);
1596 if (!IS_ERR(ov13855->power_gpio))
1597 gpiod_set_value_cansleep(ov13855->power_gpio, 0);
1599 regulator_bulk_disable(OV13855_NUM_SUPPLIES, ov13855->supplies);
1606 struct ov13855 *ov13855 = to_ov13855(sd);
1608 return __ov13855_power_on(ov13855);
1615 struct ov13855 *ov13855 = to_ov13855(sd);
1617 __ov13855_power_off(ov13855);
1625 struct ov13855 *ov13855 = to_ov13855(sd);
1630 mutex_lock(&ov13855->mutex);
1637 mutex_unlock(&ov13855->mutex);
1683 struct ov13855 *ov13855 = to_ov13855(sd);
1687 sel->r.width = ov13855->cur_mode->width;
1689 sel->r.height = ov13855->cur_mode->height;
1738 struct ov13855 *ov13855 = container_of(ctrl->handler,
1739 struct ov13855, ctrl_handler);
1740 struct i2c_client *client = ov13855->client;
1748 max = ov13855->cur_mode->height + ctrl->val - 4;
1749 __v4l2_ctrl_modify_range(ov13855->exposure,
1750 ov13855->exposure->minimum, max,
1751 ov13855->exposure->step,
1752 ov13855->exposure->default_value);
1762 ret = ov13855_write_reg(ov13855->client,
1768 ret = ov13855_write_reg(ov13855->client,
1773 ret |= ov13855_write_reg(ov13855->client,
1779 ret = ov13855_write_reg(ov13855->client,
1782 ctrl->val + ov13855->cur_mode->height);
1785 ret = ov13855_enable_test_pattern(ov13855, ctrl->val);
1802 static int ov13855_initialize_controls(struct ov13855 *ov13855)
1812 handler = &ov13855->ctrl_handler;
1813 mode = ov13855->cur_mode;
1817 handler->lock = &ov13855->mutex;
1819 ov13855->link_freq = v4l2_ctrl_new_int_menu(handler, NULL,
1825 ov13855->pixel_rate = v4l2_ctrl_new_std(handler, NULL,
1830 __v4l2_ctrl_s_ctrl(ov13855->link_freq,
1834 ov13855->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK,
1836 if (ov13855->hblank)
1837 ov13855->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
1840 ov13855->vblank = v4l2_ctrl_new_std(handler, &ov13855_ctrl_ops,
1846 ov13855->exposure = v4l2_ctrl_new_std(handler, &ov13855_ctrl_ops,
1851 ov13855->anal_gain = v4l2_ctrl_new_std(handler, &ov13855_ctrl_ops,
1856 ov13855->test_pattern = v4l2_ctrl_new_std_menu_items(handler,
1863 dev_err(&ov13855->client->dev,
1868 ov13855->subdev.ctrl_handler = handler;
1878 static int ov13855_check_sensor_id(struct ov13855 *ov13855,
1881 struct device *dev = &ov13855->client->dev;
1904 static int ov13855_configure_regulators(struct ov13855 *ov13855)
1909 ov13855->supplies[i].supply = ov13855_supply_names[i];
1911 return devm_regulator_bulk_get(&ov13855->client->dev,
1913 ov13855->supplies);
1921 struct ov13855 *ov13855;
1931 ov13855 = devm_kzalloc(dev, sizeof(*ov13855), GFP_KERNEL);
1932 if (!ov13855)
1936 &ov13855->module_index);
1938 &ov13855->module_facing);
1940 &ov13855->module_name);
1942 &ov13855->len_name);
1948 ov13855->client = client;
1949 ov13855->cur_mode = &supported_modes[0];
1951 ov13855->xvclk = devm_clk_get(dev, "xvclk");
1952 if (IS_ERR(ov13855->xvclk)) {
1957 ov13855->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW);
1958 if (IS_ERR(ov13855->power_gpio))
1961 ov13855->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
1962 if (IS_ERR(ov13855->reset_gpio))
1965 ov13855->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW);
1966 if (IS_ERR(ov13855->pwdn_gpio))
1969 ret = ov13855_configure_regulators(ov13855);
1975 ov13855->pinctrl = devm_pinctrl_get(dev);
1976 if (!IS_ERR(ov13855->pinctrl)) {
1977 ov13855->pins_default =
1978 pinctrl_lookup_state(ov13855->pinctrl,
1980 if (IS_ERR(ov13855->pins_default))
1983 ov13855->pins_sleep =
1984 pinctrl_lookup_state(ov13855->pinctrl,
1986 if (IS_ERR(ov13855->pins_sleep))
1990 mutex_init(&ov13855->mutex);
1992 sd = &ov13855->subdev;
1994 ret = ov13855_initialize_controls(ov13855);
1998 ret = __ov13855_power_on(ov13855);
2002 ret = ov13855_check_sensor_id(ov13855, client);
2011 ov13855->pad.flags = MEDIA_PAD_FL_SOURCE;
2013 ret = media_entity_pads_init(&sd->entity, 1, &ov13855->pad);
2019 if (strcmp(ov13855->module_facing, "back") == 0)
2025 ov13855->module_index, facing,
2044 __ov13855_power_off(ov13855);
2046 v4l2_ctrl_handler_free(&ov13855->ctrl_handler);
2048 mutex_destroy(&ov13855->mutex);
2056 struct ov13855 *ov13855 = to_ov13855(sd);
2062 v4l2_ctrl_handler_free(&ov13855->ctrl_handler);
2063 mutex_destroy(&ov13855->mutex);
2067 __ov13855_power_off(ov13855);
2075 { .compatible = "ovti,ov13855" },
2082 { "ovti,ov13855", 0 },
2110 MODULE_DESCRIPTION("OmniVision ov13855 sensor driver");