Lines Matching refs:ov16a1q

145 struct ov16a1q {  struct
181 #define to_ov16a1q(sd) container_of(sd, struct ov16a1q, subdev) argument
1109 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_set_fmt() local
1115 mutex_lock(&ov16a1q->mutex); in ov16a1q_set_fmt()
1126 mutex_unlock(&ov16a1q->mutex); in ov16a1q_set_fmt()
1130 ov16a1q->cur_mode = mode; in ov16a1q_set_fmt()
1132 __v4l2_ctrl_modify_range(ov16a1q->hblank, h_blank, in ov16a1q_set_fmt()
1135 __v4l2_ctrl_modify_range(ov16a1q->vblank, vblank_def, in ov16a1q_set_fmt()
1138 __v4l2_ctrl_s_ctrl(ov16a1q->vblank, vblank_def); in ov16a1q_set_fmt()
1141 __v4l2_ctrl_s_ctrl_int64(ov16a1q->pixel_rate, in ov16a1q_set_fmt()
1143 __v4l2_ctrl_s_ctrl(ov16a1q->link_freq, in ov16a1q_set_fmt()
1146 dev_info(&ov16a1q->client->dev, "%s: mode->link_freq_idx(%d)", in ov16a1q_set_fmt()
1149 mutex_unlock(&ov16a1q->mutex); in ov16a1q_set_fmt()
1158 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_get_fmt() local
1159 const struct ov16a1q_mode *mode = ov16a1q->cur_mode; in ov16a1q_get_fmt()
1161 mutex_lock(&ov16a1q->mutex); in ov16a1q_get_fmt()
1166 mutex_unlock(&ov16a1q->mutex); in ov16a1q_get_fmt()
1179 mutex_unlock(&ov16a1q->mutex); in ov16a1q_get_fmt()
1199 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_enum_frame_sizes() local
1201 if (fse->index >= ov16a1q->cfg_num) in ov16a1q_enum_frame_sizes()
1215 static int ov16a1q_enable_test_pattern(struct ov16a1q *ov16a1q, u32 pattern) in ov16a1q_enable_test_pattern() argument
1224 return ov16a1q_write_reg(ov16a1q->client, in ov16a1q_enable_test_pattern()
1233 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_g_frame_interval() local
1234 const struct ov16a1q_mode *mode = ov16a1q->cur_mode; in ov16a1q_g_frame_interval()
1241 static void ov16a1q_get_module_inf(struct ov16a1q *ov16a1q, in ov16a1q_get_module_inf() argument
1246 strscpy(inf->base.module, ov16a1q->module_name, in ov16a1q_get_module_inf()
1248 strscpy(inf->base.lens, ov16a1q->len_name, sizeof(inf->base.lens)); in ov16a1q_get_module_inf()
1253 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_ioctl() local
1262 w = ov16a1q->cur_mode->width; in ov16a1q_ioctl()
1263 h = ov16a1q->cur_mode->height; in ov16a1q_ioctl()
1264 for (i = 0; i < ov16a1q->cfg_num; i++) { in ov16a1q_ioctl()
1268 ov16a1q->cur_mode = &supported_modes[i]; in ov16a1q_ioctl()
1272 if (i == ov16a1q->cfg_num) { in ov16a1q_ioctl()
1273 dev_err(&ov16a1q->client->dev, in ov16a1q_ioctl()
1278 w = ov16a1q->cur_mode->hts_def - ov16a1q->cur_mode->width; in ov16a1q_ioctl()
1279 h = ov16a1q->cur_mode->vts_def - ov16a1q->cur_mode->height; in ov16a1q_ioctl()
1280 __v4l2_ctrl_modify_range(ov16a1q->hblank, w, w, 1, w); in ov16a1q_ioctl()
1281 __v4l2_ctrl_modify_range(ov16a1q->vblank, h, in ov16a1q_ioctl()
1282 OV16A1Q_VTS_MAX - ov16a1q->cur_mode->height, in ov16a1q_ioctl()
1284 dev_info(&ov16a1q->client->dev, in ov16a1q_ioctl()
1286 ov16a1q->cur_mode->hdr_mode); in ov16a1q_ioctl()
1292 hdr_cfg->hdr_mode = ov16a1q->cur_mode->hdr_mode; in ov16a1q_ioctl()
1295 ov16a1q_get_module_inf(ov16a1q, (struct rkmodule_inf *)arg); in ov16a1q_ioctl()
1302 ret = ov16a1q_write_reg(ov16a1q->client, in ov16a1q_ioctl()
1307 ret = ov16a1q_write_reg(ov16a1q->client, in ov16a1q_ioctl()
1407 static int __ov16a1q_start_stream(struct ov16a1q *ov16a1q) in __ov16a1q_start_stream() argument
1411 ret = ov16a1q_write_array(ov16a1q->client, ov16a1q->cur_mode->reg_list); in __ov16a1q_start_stream()
1416 mutex_unlock(&ov16a1q->mutex); in __ov16a1q_start_stream()
1417 ret = v4l2_ctrl_handler_setup(&ov16a1q->ctrl_handler); in __ov16a1q_start_stream()
1418 mutex_lock(&ov16a1q->mutex); in __ov16a1q_start_stream()
1422 return ov16a1q_write_reg(ov16a1q->client, in __ov16a1q_start_stream()
1428 static int __ov16a1q_stop_stream(struct ov16a1q *ov16a1q) in __ov16a1q_stop_stream() argument
1430 return ov16a1q_write_reg(ov16a1q->client, in __ov16a1q_stop_stream()
1438 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_s_stream() local
1439 struct i2c_client *client = ov16a1q->client; in ov16a1q_s_stream()
1443 ov16a1q->cur_mode->width, in ov16a1q_s_stream()
1444 ov16a1q->cur_mode->height, in ov16a1q_s_stream()
1445 DIV_ROUND_CLOSEST(ov16a1q->cur_mode->max_fps.denominator, in ov16a1q_s_stream()
1446 ov16a1q->cur_mode->max_fps.numerator)); in ov16a1q_s_stream()
1448 mutex_lock(&ov16a1q->mutex); in ov16a1q_s_stream()
1450 if (on == ov16a1q->streaming) in ov16a1q_s_stream()
1460 ret = __ov16a1q_start_stream(ov16a1q); in ov16a1q_s_stream()
1467 __ov16a1q_stop_stream(ov16a1q); in ov16a1q_s_stream()
1471 ov16a1q->streaming = on; in ov16a1q_s_stream()
1474 mutex_unlock(&ov16a1q->mutex); in ov16a1q_s_stream()
1481 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_s_power() local
1482 struct i2c_client *client = ov16a1q->client; in ov16a1q_s_power()
1485 mutex_lock(&ov16a1q->mutex); in ov16a1q_s_power()
1488 if (ov16a1q->power_on == !!on) in ov16a1q_s_power()
1498 ret = ov16a1q_write_array(ov16a1q->client, ov16a1q_global_regs); in ov16a1q_s_power()
1505 ov16a1q->power_on = true; in ov16a1q_s_power()
1508 ov16a1q->power_on = false; in ov16a1q_s_power()
1512 mutex_unlock(&ov16a1q->mutex); in ov16a1q_s_power()
1523 static int __ov16a1q_power_on(struct ov16a1q *ov16a1q) in __ov16a1q_power_on() argument
1527 struct device *dev = &ov16a1q->client->dev; in __ov16a1q_power_on()
1529 if (!IS_ERR(ov16a1q->power_gpio)) in __ov16a1q_power_on()
1530 gpiod_set_value_cansleep(ov16a1q->power_gpio, 1); in __ov16a1q_power_on()
1534 if (!IS_ERR_OR_NULL(ov16a1q->pins_default)) { in __ov16a1q_power_on()
1535 ret = pinctrl_select_state(ov16a1q->pinctrl, in __ov16a1q_power_on()
1536 ov16a1q->pins_default); in __ov16a1q_power_on()
1540 ret = clk_set_rate(ov16a1q->xvclk, OV16A1Q_XVCLK_FREQ); in __ov16a1q_power_on()
1543 if (clk_get_rate(ov16a1q->xvclk) != OV16A1Q_XVCLK_FREQ) in __ov16a1q_power_on()
1545 ret = clk_prepare_enable(ov16a1q->xvclk); in __ov16a1q_power_on()
1550 if (!IS_ERR(ov16a1q->reset_gpio)) in __ov16a1q_power_on()
1551 gpiod_set_value_cansleep(ov16a1q->reset_gpio, 0); in __ov16a1q_power_on()
1553 ret = regulator_bulk_enable(OV16A1Q_NUM_SUPPLIES, ov16a1q->supplies); in __ov16a1q_power_on()
1559 if (!IS_ERR(ov16a1q->reset_gpio)) in __ov16a1q_power_on()
1560 gpiod_set_value_cansleep(ov16a1q->reset_gpio, 1); in __ov16a1q_power_on()
1563 if (!IS_ERR(ov16a1q->pwdn_gpio)) in __ov16a1q_power_on()
1564 gpiod_set_value_cansleep(ov16a1q->pwdn_gpio, 1); in __ov16a1q_power_on()
1573 clk_disable_unprepare(ov16a1q->xvclk); in __ov16a1q_power_on()
1578 static void __ov16a1q_power_off(struct ov16a1q *ov16a1q) in __ov16a1q_power_off() argument
1581 struct device *dev = &ov16a1q->client->dev; in __ov16a1q_power_off()
1583 if (!IS_ERR(ov16a1q->pwdn_gpio)) in __ov16a1q_power_off()
1584 gpiod_set_value_cansleep(ov16a1q->pwdn_gpio, 0); in __ov16a1q_power_off()
1585 clk_disable_unprepare(ov16a1q->xvclk); in __ov16a1q_power_off()
1586 if (!IS_ERR(ov16a1q->reset_gpio)) in __ov16a1q_power_off()
1587 gpiod_set_value_cansleep(ov16a1q->reset_gpio, 0); in __ov16a1q_power_off()
1589 if (!IS_ERR_OR_NULL(ov16a1q->pins_sleep)) { in __ov16a1q_power_off()
1590 ret = pinctrl_select_state(ov16a1q->pinctrl, in __ov16a1q_power_off()
1591 ov16a1q->pins_sleep); in __ov16a1q_power_off()
1595 if (!IS_ERR(ov16a1q->power_gpio)) in __ov16a1q_power_off()
1596 gpiod_set_value_cansleep(ov16a1q->power_gpio, 0); in __ov16a1q_power_off()
1598 regulator_bulk_disable(OV16A1Q_NUM_SUPPLIES, ov16a1q->supplies); in __ov16a1q_power_off()
1605 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_runtime_resume() local
1607 return __ov16a1q_power_on(ov16a1q); in ov16a1q_runtime_resume()
1614 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_runtime_suspend() local
1616 __ov16a1q_power_off(ov16a1q); in ov16a1q_runtime_suspend()
1624 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_open() local
1629 mutex_lock(&ov16a1q->mutex); in ov16a1q_open()
1636 mutex_unlock(&ov16a1q->mutex); in ov16a1q_open()
1693 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_get_selection() local
1696 if (ov16a1q->cur_mode->width == 2328) { in ov16a1q_get_selection()
1697 sel->r.left = CROP_START(ov16a1q->cur_mode->width, DST_WIDTH_2320); in ov16a1q_get_selection()
1699 sel->r.top = CROP_START(ov16a1q->cur_mode->height, DST_HEIGHT_1744); in ov16a1q_get_selection()
1703 sel->r.width = ov16a1q->cur_mode->width; in ov16a1q_get_selection()
1705 sel->r.height = ov16a1q->cur_mode->height; in ov16a1q_get_selection()
1755 struct ov16a1q *ov16a1q = container_of(ctrl->handler, in ov16a1q_set_ctrl() local
1756 struct ov16a1q, ctrl_handler); in ov16a1q_set_ctrl()
1757 struct i2c_client *client = ov16a1q->client; in ov16a1q_set_ctrl()
1767 max = ov16a1q->cur_mode->height + ctrl->val - 4; in ov16a1q_set_ctrl()
1768 __v4l2_ctrl_modify_range(ov16a1q->exposure, in ov16a1q_set_ctrl()
1769 ov16a1q->exposure->minimum, max, in ov16a1q_set_ctrl()
1770 ov16a1q->exposure->step, in ov16a1q_set_ctrl()
1771 ov16a1q->exposure->default_value); in ov16a1q_set_ctrl()
1781 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1796 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1800 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1809 ret = ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1812 ctrl->val + ov16a1q->cur_mode->height); in ov16a1q_set_ctrl()
1815 ret = ov16a1q_enable_test_pattern(ov16a1q, ctrl->val); in ov16a1q_set_ctrl()
1818 ret = ov16a1q_read_reg(ov16a1q->client, OV16A1Q_MIRROR_REG, in ov16a1q_set_ctrl()
1826 ret |= ov16a1q_read_reg(ov16a1q->client, OV16A1Q_REG_ISP_X_WIN, in ov16a1q_set_ctrl()
1835 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1840 ret |= ov16a1q_write_reg(ov16a1q->client, OV16A1Q_MIRROR_REG, in ov16a1q_set_ctrl()
1843 ret |= ov16a1q_write_reg(ov16a1q->client, OV16A1Q_REG_ISP_X_WIN, in ov16a1q_set_ctrl()
1847 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1851 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1857 ret = ov16a1q_read_reg(ov16a1q->client, OV16A1Q_FLIP_REG, in ov16a1q_set_ctrl()
1865 ret |= ov16a1q_read_reg(ov16a1q->client, OV16A1Q_REG_ISP_Y_WIN, in ov16a1q_set_ctrl()
1874 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1879 ret |= ov16a1q_write_reg(ov16a1q->client, OV16A1Q_FLIP_REG, in ov16a1q_set_ctrl()
1882 ret |= ov16a1q_write_reg(ov16a1q->client, OV16A1Q_REG_ISP_Y_WIN, in ov16a1q_set_ctrl()
1886 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1890 ret |= ov16a1q_write_reg(ov16a1q->client, in ov16a1q_set_ctrl()
1910 static int ov16a1q_initialize_controls(struct ov16a1q *ov16a1q) in ov16a1q_initialize_controls() argument
1920 handler = &ov16a1q->ctrl_handler; in ov16a1q_initialize_controls()
1921 mode = ov16a1q->cur_mode; in ov16a1q_initialize_controls()
1925 handler->lock = &ov16a1q->mutex; in ov16a1q_initialize_controls()
1927 ov16a1q->link_freq = v4l2_ctrl_new_int_menu(handler, NULL, in ov16a1q_initialize_controls()
1933 ov16a1q->pixel_rate = v4l2_ctrl_new_std(handler, NULL, in ov16a1q_initialize_controls()
1938 __v4l2_ctrl_s_ctrl(ov16a1q->link_freq, in ov16a1q_initialize_controls()
1942 ov16a1q->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov16a1q_initialize_controls()
1944 if (ov16a1q->hblank) in ov16a1q_initialize_controls()
1945 ov16a1q->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov16a1q_initialize_controls()
1948 ov16a1q->vblank = v4l2_ctrl_new_std(handler, &ov16a1q_ctrl_ops, in ov16a1q_initialize_controls()
1954 ov16a1q->exposure = v4l2_ctrl_new_std(handler, &ov16a1q_ctrl_ops, in ov16a1q_initialize_controls()
1959 ov16a1q->anal_gain = v4l2_ctrl_new_std(handler, &ov16a1q_ctrl_ops, in ov16a1q_initialize_controls()
1964 ov16a1q->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in ov16a1q_initialize_controls()
1969 ov16a1q->h_flip = v4l2_ctrl_new_std(handler, &ov16a1q_ctrl_ops, in ov16a1q_initialize_controls()
1972 ov16a1q->v_flip = v4l2_ctrl_new_std(handler, &ov16a1q_ctrl_ops, in ov16a1q_initialize_controls()
1977 dev_err(&ov16a1q->client->dev, in ov16a1q_initialize_controls()
1982 ov16a1q->subdev.ctrl_handler = handler; in ov16a1q_initialize_controls()
1992 static int ov16a1q_check_sensor_id(struct ov16a1q *ov16a1q, in ov16a1q_check_sensor_id() argument
1995 struct device *dev = &ov16a1q->client->dev; in ov16a1q_check_sensor_id()
2011 static int ov16a1q_configure_regulators(struct ov16a1q *ov16a1q) in ov16a1q_configure_regulators() argument
2016 ov16a1q->supplies[i].supply = ov16a1q_supply_names[i]; in ov16a1q_configure_regulators()
2018 return devm_regulator_bulk_get(&ov16a1q->client->dev, in ov16a1q_configure_regulators()
2020 ov16a1q->supplies); in ov16a1q_configure_regulators()
2028 struct ov16a1q *ov16a1q; in ov16a1q_probe() local
2039 ov16a1q = devm_kzalloc(dev, sizeof(*ov16a1q), GFP_KERNEL); in ov16a1q_probe()
2040 if (!ov16a1q) in ov16a1q_probe()
2044 &ov16a1q->module_index); in ov16a1q_probe()
2046 &ov16a1q->module_facing); in ov16a1q_probe()
2048 &ov16a1q->module_name); in ov16a1q_probe()
2050 &ov16a1q->len_name); in ov16a1q_probe()
2062 ov16a1q->cfg_num = ARRAY_SIZE(supported_modes); in ov16a1q_probe()
2063 for (i = 0; i < ov16a1q->cfg_num; i++) { in ov16a1q_probe()
2065 ov16a1q->cur_mode = &supported_modes[i]; in ov16a1q_probe()
2070 ov16a1q->client = client; in ov16a1q_probe()
2072 ov16a1q->xvclk = devm_clk_get(dev, "xvclk"); in ov16a1q_probe()
2073 if (IS_ERR(ov16a1q->xvclk)) { in ov16a1q_probe()
2078 ov16a1q->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in ov16a1q_probe()
2079 if (IS_ERR(ov16a1q->power_gpio)) in ov16a1q_probe()
2082 ov16a1q->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in ov16a1q_probe()
2083 if (IS_ERR(ov16a1q->reset_gpio)) in ov16a1q_probe()
2086 ov16a1q->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in ov16a1q_probe()
2087 if (IS_ERR(ov16a1q->pwdn_gpio)) in ov16a1q_probe()
2090 ret = ov16a1q_configure_regulators(ov16a1q); in ov16a1q_probe()
2096 ov16a1q->pinctrl = devm_pinctrl_get(dev); in ov16a1q_probe()
2097 if (!IS_ERR(ov16a1q->pinctrl)) { in ov16a1q_probe()
2098 ov16a1q->pins_default = in ov16a1q_probe()
2099 pinctrl_lookup_state(ov16a1q->pinctrl, in ov16a1q_probe()
2101 if (IS_ERR(ov16a1q->pins_default)) in ov16a1q_probe()
2104 ov16a1q->pins_sleep = in ov16a1q_probe()
2105 pinctrl_lookup_state(ov16a1q->pinctrl, in ov16a1q_probe()
2107 if (IS_ERR(ov16a1q->pins_sleep)) in ov16a1q_probe()
2111 mutex_init(&ov16a1q->mutex); in ov16a1q_probe()
2113 sd = &ov16a1q->subdev; in ov16a1q_probe()
2115 ret = ov16a1q_initialize_controls(ov16a1q); in ov16a1q_probe()
2119 ret = __ov16a1q_power_on(ov16a1q); in ov16a1q_probe()
2123 ret = ov16a1q_check_sensor_id(ov16a1q, client); in ov16a1q_probe()
2132 ov16a1q->pad.flags = MEDIA_PAD_FL_SOURCE; in ov16a1q_probe()
2134 ret = media_entity_pads_init(&sd->entity, 1, &ov16a1q->pad); in ov16a1q_probe()
2140 if (strcmp(ov16a1q->module_facing, "back") == 0) in ov16a1q_probe()
2146 ov16a1q->module_index, facing, in ov16a1q_probe()
2165 __ov16a1q_power_off(ov16a1q); in ov16a1q_probe()
2167 v4l2_ctrl_handler_free(&ov16a1q->ctrl_handler); in ov16a1q_probe()
2169 mutex_destroy(&ov16a1q->mutex); in ov16a1q_probe()
2177 struct ov16a1q *ov16a1q = to_ov16a1q(sd); in ov16a1q_remove() local
2183 v4l2_ctrl_handler_free(&ov16a1q->ctrl_handler); in ov16a1q_remove()
2184 mutex_destroy(&ov16a1q->mutex); in ov16a1q_remove()
2188 __ov16a1q_power_off(ov16a1q); in ov16a1q_remove()