Lines Matching refs:ov16a10

144 struct ov16a10 {  struct
180 #define to_ov16a10(sd) container_of(sd, struct ov16a10, subdev) argument
1061 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_set_fmt() local
1067 mutex_lock(&ov16a10->mutex); in ov16a10_set_fmt()
1078 mutex_unlock(&ov16a10->mutex); in ov16a10_set_fmt()
1082 ov16a10->cur_mode = mode; in ov16a10_set_fmt()
1084 __v4l2_ctrl_modify_range(ov16a10->hblank, h_blank, in ov16a10_set_fmt()
1087 __v4l2_ctrl_modify_range(ov16a10->vblank, vblank_def, in ov16a10_set_fmt()
1090 __v4l2_ctrl_s_ctrl(ov16a10->vblank, vblank_def); in ov16a10_set_fmt()
1093 __v4l2_ctrl_s_ctrl_int64(ov16a10->pixel_rate, in ov16a10_set_fmt()
1095 __v4l2_ctrl_s_ctrl(ov16a10->link_freq, in ov16a10_set_fmt()
1098 dev_info(&ov16a10->client->dev, "%s: mode->link_freq_idx(%d)", in ov16a10_set_fmt()
1101 mutex_unlock(&ov16a10->mutex); in ov16a10_set_fmt()
1110 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_get_fmt() local
1111 const struct ov16a10_mode *mode = ov16a10->cur_mode; in ov16a10_get_fmt()
1113 mutex_lock(&ov16a10->mutex); in ov16a10_get_fmt()
1118 mutex_unlock(&ov16a10->mutex); in ov16a10_get_fmt()
1131 mutex_unlock(&ov16a10->mutex); in ov16a10_get_fmt()
1151 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_enum_frame_sizes() local
1153 if (fse->index >= ov16a10->cfg_num) in ov16a10_enum_frame_sizes()
1167 static int ov16a10_enable_test_pattern(struct ov16a10 *ov16a10, u32 pattern) in ov16a10_enable_test_pattern() argument
1176 return ov16a10_write_reg(ov16a10->client, in ov16a10_enable_test_pattern()
1185 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_g_frame_interval() local
1186 const struct ov16a10_mode *mode = ov16a10->cur_mode; in ov16a10_g_frame_interval()
1193 static void ov16a10_get_module_inf(struct ov16a10 *ov16a10, in ov16a10_get_module_inf() argument
1198 strscpy(inf->base.module, ov16a10->module_name, in ov16a10_get_module_inf()
1200 strscpy(inf->base.lens, ov16a10->len_name, sizeof(inf->base.lens)); in ov16a10_get_module_inf()
1205 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_ioctl() local
1214 w = ov16a10->cur_mode->width; in ov16a10_ioctl()
1215 h = ov16a10->cur_mode->height; in ov16a10_ioctl()
1216 for (i = 0; i < ov16a10->cfg_num; i++) { in ov16a10_ioctl()
1220 ov16a10->cur_mode = &supported_modes[i]; in ov16a10_ioctl()
1224 if (i == ov16a10->cfg_num) { in ov16a10_ioctl()
1225 dev_err(&ov16a10->client->dev, in ov16a10_ioctl()
1230 w = ov16a10->cur_mode->hts_def - ov16a10->cur_mode->width; in ov16a10_ioctl()
1231 h = ov16a10->cur_mode->vts_def - ov16a10->cur_mode->height; in ov16a10_ioctl()
1232 __v4l2_ctrl_modify_range(ov16a10->hblank, w, w, 1, w); in ov16a10_ioctl()
1233 __v4l2_ctrl_modify_range(ov16a10->vblank, h, in ov16a10_ioctl()
1234 OV16A10_VTS_MAX - ov16a10->cur_mode->height, in ov16a10_ioctl()
1236 dev_info(&ov16a10->client->dev, in ov16a10_ioctl()
1238 ov16a10->cur_mode->hdr_mode); in ov16a10_ioctl()
1244 hdr_cfg->hdr_mode = ov16a10->cur_mode->hdr_mode; in ov16a10_ioctl()
1247 ov16a10_get_module_inf(ov16a10, (struct rkmodule_inf *)arg); in ov16a10_ioctl()
1254 ret = ov16a10_write_reg(ov16a10->client, in ov16a10_ioctl()
1259 ret = ov16a10_write_reg(ov16a10->client, in ov16a10_ioctl()
1359 static int __ov16a10_start_stream(struct ov16a10 *ov16a10) in __ov16a10_start_stream() argument
1363 ret = ov16a10_write_array(ov16a10->client, ov16a10->cur_mode->reg_list); in __ov16a10_start_stream()
1368 mutex_unlock(&ov16a10->mutex); in __ov16a10_start_stream()
1369 ret = v4l2_ctrl_handler_setup(&ov16a10->ctrl_handler); in __ov16a10_start_stream()
1370 mutex_lock(&ov16a10->mutex); in __ov16a10_start_stream()
1374 return ov16a10_write_reg(ov16a10->client, in __ov16a10_start_stream()
1380 static int __ov16a10_stop_stream(struct ov16a10 *ov16a10) in __ov16a10_stop_stream() argument
1382 return ov16a10_write_reg(ov16a10->client, in __ov16a10_stop_stream()
1390 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_s_stream() local
1391 struct i2c_client *client = ov16a10->client; in ov16a10_s_stream()
1395 ov16a10->cur_mode->width, in ov16a10_s_stream()
1396 ov16a10->cur_mode->height, in ov16a10_s_stream()
1397 DIV_ROUND_CLOSEST(ov16a10->cur_mode->max_fps.denominator, in ov16a10_s_stream()
1398 ov16a10->cur_mode->max_fps.numerator)); in ov16a10_s_stream()
1400 mutex_lock(&ov16a10->mutex); in ov16a10_s_stream()
1402 if (on == ov16a10->streaming) in ov16a10_s_stream()
1412 ret = __ov16a10_start_stream(ov16a10); in ov16a10_s_stream()
1419 __ov16a10_stop_stream(ov16a10); in ov16a10_s_stream()
1423 ov16a10->streaming = on; in ov16a10_s_stream()
1426 mutex_unlock(&ov16a10->mutex); in ov16a10_s_stream()
1433 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_s_power() local
1434 struct i2c_client *client = ov16a10->client; in ov16a10_s_power()
1437 mutex_lock(&ov16a10->mutex); in ov16a10_s_power()
1440 if (ov16a10->power_on == !!on) in ov16a10_s_power()
1450 ret = ov16a10_write_array(ov16a10->client, ov16a10_global_regs); in ov16a10_s_power()
1457 ov16a10->power_on = true; in ov16a10_s_power()
1460 ov16a10->power_on = false; in ov16a10_s_power()
1464 mutex_unlock(&ov16a10->mutex); in ov16a10_s_power()
1475 static int __ov16a10_power_on(struct ov16a10 *ov16a10) in __ov16a10_power_on() argument
1479 struct device *dev = &ov16a10->client->dev; in __ov16a10_power_on()
1481 if (!IS_ERR(ov16a10->power_gpio)) in __ov16a10_power_on()
1482 gpiod_set_value_cansleep(ov16a10->power_gpio, 1); in __ov16a10_power_on()
1486 if (!IS_ERR_OR_NULL(ov16a10->pins_default)) { in __ov16a10_power_on()
1487 ret = pinctrl_select_state(ov16a10->pinctrl, in __ov16a10_power_on()
1488 ov16a10->pins_default); in __ov16a10_power_on()
1492 ret = clk_set_rate(ov16a10->xvclk, OV16A10_XVCLK_FREQ); in __ov16a10_power_on()
1495 if (clk_get_rate(ov16a10->xvclk) != OV16A10_XVCLK_FREQ) in __ov16a10_power_on()
1497 ret = clk_prepare_enable(ov16a10->xvclk); in __ov16a10_power_on()
1502 if (!IS_ERR(ov16a10->reset_gpio)) in __ov16a10_power_on()
1503 gpiod_set_value_cansleep(ov16a10->reset_gpio, 0); in __ov16a10_power_on()
1505 ret = regulator_bulk_enable(OV16A10_NUM_SUPPLIES, ov16a10->supplies); in __ov16a10_power_on()
1511 if (!IS_ERR(ov16a10->reset_gpio)) in __ov16a10_power_on()
1512 gpiod_set_value_cansleep(ov16a10->reset_gpio, 1); in __ov16a10_power_on()
1515 if (!IS_ERR(ov16a10->pwdn_gpio)) in __ov16a10_power_on()
1516 gpiod_set_value_cansleep(ov16a10->pwdn_gpio, 1); in __ov16a10_power_on()
1525 clk_disable_unprepare(ov16a10->xvclk); in __ov16a10_power_on()
1530 static void __ov16a10_power_off(struct ov16a10 *ov16a10) in __ov16a10_power_off() argument
1533 struct device *dev = &ov16a10->client->dev; in __ov16a10_power_off()
1535 if (!IS_ERR(ov16a10->pwdn_gpio)) in __ov16a10_power_off()
1536 gpiod_set_value_cansleep(ov16a10->pwdn_gpio, 0); in __ov16a10_power_off()
1537 clk_disable_unprepare(ov16a10->xvclk); in __ov16a10_power_off()
1538 if (!IS_ERR(ov16a10->reset_gpio)) in __ov16a10_power_off()
1539 gpiod_set_value_cansleep(ov16a10->reset_gpio, 0); in __ov16a10_power_off()
1541 if (!IS_ERR_OR_NULL(ov16a10->pins_sleep)) { in __ov16a10_power_off()
1542 ret = pinctrl_select_state(ov16a10->pinctrl, in __ov16a10_power_off()
1543 ov16a10->pins_sleep); in __ov16a10_power_off()
1547 if (!IS_ERR(ov16a10->power_gpio)) in __ov16a10_power_off()
1548 gpiod_set_value_cansleep(ov16a10->power_gpio, 0); in __ov16a10_power_off()
1550 regulator_bulk_disable(OV16A10_NUM_SUPPLIES, ov16a10->supplies); in __ov16a10_power_off()
1557 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_runtime_resume() local
1559 return __ov16a10_power_on(ov16a10); in ov16a10_runtime_resume()
1566 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_runtime_suspend() local
1568 __ov16a10_power_off(ov16a10); in ov16a10_runtime_suspend()
1576 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_open() local
1581 mutex_lock(&ov16a10->mutex); in ov16a10_open()
1588 mutex_unlock(&ov16a10->mutex); in ov16a10_open()
1645 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_get_selection() local
1648 if (ov16a10->cur_mode->width == 2328) { in ov16a10_get_selection()
1649 sel->r.left = CROP_START(ov16a10->cur_mode->width, DST_WIDTH_2320); in ov16a10_get_selection()
1651 sel->r.top = CROP_START(ov16a10->cur_mode->height, DST_HEIGHT_1744); in ov16a10_get_selection()
1655 sel->r.width = ov16a10->cur_mode->width; in ov16a10_get_selection()
1657 sel->r.height = ov16a10->cur_mode->height; in ov16a10_get_selection()
1707 struct ov16a10 *ov16a10 = container_of(ctrl->handler, in ov16a10_set_ctrl() local
1708 struct ov16a10, ctrl_handler); in ov16a10_set_ctrl()
1709 struct i2c_client *client = ov16a10->client; in ov16a10_set_ctrl()
1719 max = ov16a10->cur_mode->height + ctrl->val - 4; in ov16a10_set_ctrl()
1720 __v4l2_ctrl_modify_range(ov16a10->exposure, in ov16a10_set_ctrl()
1721 ov16a10->exposure->minimum, max, in ov16a10_set_ctrl()
1722 ov16a10->exposure->step, in ov16a10_set_ctrl()
1723 ov16a10->exposure->default_value); in ov16a10_set_ctrl()
1733 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1748 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1752 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1761 ret = ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1764 ctrl->val + ov16a10->cur_mode->height); in ov16a10_set_ctrl()
1767 ret = ov16a10_enable_test_pattern(ov16a10, ctrl->val); in ov16a10_set_ctrl()
1770 ret = ov16a10_read_reg(ov16a10->client, OV16A10_MIRROR_REG, in ov16a10_set_ctrl()
1778 ret |= ov16a10_read_reg(ov16a10->client, OV16A10_REG_ISP_X_WIN, in ov16a10_set_ctrl()
1787 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1792 ret |= ov16a10_write_reg(ov16a10->client, OV16A10_MIRROR_REG, in ov16a10_set_ctrl()
1795 ret |= ov16a10_write_reg(ov16a10->client, OV16A10_REG_ISP_X_WIN, in ov16a10_set_ctrl()
1799 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1803 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1809 ret = ov16a10_read_reg(ov16a10->client, OV16A10_FLIP_REG, in ov16a10_set_ctrl()
1817 ret |= ov16a10_read_reg(ov16a10->client, OV16A10_REG_ISP_Y_WIN, in ov16a10_set_ctrl()
1826 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1831 ret |= ov16a10_write_reg(ov16a10->client, OV16A10_FLIP_REG, in ov16a10_set_ctrl()
1834 ret |= ov16a10_write_reg(ov16a10->client, OV16A10_REG_ISP_Y_WIN, in ov16a10_set_ctrl()
1838 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1842 ret |= ov16a10_write_reg(ov16a10->client, in ov16a10_set_ctrl()
1862 static int ov16a10_initialize_controls(struct ov16a10 *ov16a10) in ov16a10_initialize_controls() argument
1872 handler = &ov16a10->ctrl_handler; in ov16a10_initialize_controls()
1873 mode = ov16a10->cur_mode; in ov16a10_initialize_controls()
1877 handler->lock = &ov16a10->mutex; in ov16a10_initialize_controls()
1879 ov16a10->link_freq = v4l2_ctrl_new_int_menu(handler, NULL, in ov16a10_initialize_controls()
1885 ov16a10->pixel_rate = v4l2_ctrl_new_std(handler, NULL, in ov16a10_initialize_controls()
1890 __v4l2_ctrl_s_ctrl(ov16a10->link_freq, in ov16a10_initialize_controls()
1894 ov16a10->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in ov16a10_initialize_controls()
1896 if (ov16a10->hblank) in ov16a10_initialize_controls()
1897 ov16a10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov16a10_initialize_controls()
1900 ov16a10->vblank = v4l2_ctrl_new_std(handler, &ov16a10_ctrl_ops, in ov16a10_initialize_controls()
1906 ov16a10->exposure = v4l2_ctrl_new_std(handler, &ov16a10_ctrl_ops, in ov16a10_initialize_controls()
1911 ov16a10->anal_gain = v4l2_ctrl_new_std(handler, &ov16a10_ctrl_ops, in ov16a10_initialize_controls()
1916 ov16a10->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in ov16a10_initialize_controls()
1921 ov16a10->h_flip = v4l2_ctrl_new_std(handler, &ov16a10_ctrl_ops, in ov16a10_initialize_controls()
1924 ov16a10->v_flip = v4l2_ctrl_new_std(handler, &ov16a10_ctrl_ops, in ov16a10_initialize_controls()
1929 dev_err(&ov16a10->client->dev, in ov16a10_initialize_controls()
1934 ov16a10->subdev.ctrl_handler = handler; in ov16a10_initialize_controls()
1944 static int ov16a10_check_sensor_id(struct ov16a10 *ov16a10, in ov16a10_check_sensor_id() argument
1947 struct device *dev = &ov16a10->client->dev; in ov16a10_check_sensor_id()
1963 static int ov16a10_configure_regulators(struct ov16a10 *ov16a10) in ov16a10_configure_regulators() argument
1968 ov16a10->supplies[i].supply = ov16a10_supply_names[i]; in ov16a10_configure_regulators()
1970 return devm_regulator_bulk_get(&ov16a10->client->dev, in ov16a10_configure_regulators()
1972 ov16a10->supplies); in ov16a10_configure_regulators()
1980 struct ov16a10 *ov16a10; in ov16a10_probe() local
1991 ov16a10 = devm_kzalloc(dev, sizeof(*ov16a10), GFP_KERNEL); in ov16a10_probe()
1992 if (!ov16a10) in ov16a10_probe()
1996 &ov16a10->module_index); in ov16a10_probe()
1998 &ov16a10->module_facing); in ov16a10_probe()
2000 &ov16a10->module_name); in ov16a10_probe()
2002 &ov16a10->len_name); in ov16a10_probe()
2014 ov16a10->cfg_num = ARRAY_SIZE(supported_modes); in ov16a10_probe()
2015 for (i = 0; i < ov16a10->cfg_num; i++) { in ov16a10_probe()
2017 ov16a10->cur_mode = &supported_modes[i]; in ov16a10_probe()
2022 ov16a10->client = client; in ov16a10_probe()
2024 ov16a10->xvclk = devm_clk_get(dev, "xvclk"); in ov16a10_probe()
2025 if (IS_ERR(ov16a10->xvclk)) { in ov16a10_probe()
2030 ov16a10->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in ov16a10_probe()
2031 if (IS_ERR(ov16a10->power_gpio)) in ov16a10_probe()
2034 ov16a10->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in ov16a10_probe()
2035 if (IS_ERR(ov16a10->reset_gpio)) in ov16a10_probe()
2038 ov16a10->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in ov16a10_probe()
2039 if (IS_ERR(ov16a10->pwdn_gpio)) in ov16a10_probe()
2042 ret = ov16a10_configure_regulators(ov16a10); in ov16a10_probe()
2048 ov16a10->pinctrl = devm_pinctrl_get(dev); in ov16a10_probe()
2049 if (!IS_ERR(ov16a10->pinctrl)) { in ov16a10_probe()
2050 ov16a10->pins_default = in ov16a10_probe()
2051 pinctrl_lookup_state(ov16a10->pinctrl, in ov16a10_probe()
2053 if (IS_ERR(ov16a10->pins_default)) in ov16a10_probe()
2056 ov16a10->pins_sleep = in ov16a10_probe()
2057 pinctrl_lookup_state(ov16a10->pinctrl, in ov16a10_probe()
2059 if (IS_ERR(ov16a10->pins_sleep)) in ov16a10_probe()
2063 mutex_init(&ov16a10->mutex); in ov16a10_probe()
2065 sd = &ov16a10->subdev; in ov16a10_probe()
2067 ret = ov16a10_initialize_controls(ov16a10); in ov16a10_probe()
2071 ret = __ov16a10_power_on(ov16a10); in ov16a10_probe()
2075 ret = ov16a10_check_sensor_id(ov16a10, client); in ov16a10_probe()
2084 ov16a10->pad.flags = MEDIA_PAD_FL_SOURCE; in ov16a10_probe()
2086 ret = media_entity_pads_init(&sd->entity, 1, &ov16a10->pad); in ov16a10_probe()
2092 if (strcmp(ov16a10->module_facing, "back") == 0) in ov16a10_probe()
2098 ov16a10->module_index, facing, in ov16a10_probe()
2117 __ov16a10_power_off(ov16a10); in ov16a10_probe()
2119 v4l2_ctrl_handler_free(&ov16a10->ctrl_handler); in ov16a10_probe()
2121 mutex_destroy(&ov16a10->mutex); in ov16a10_probe()
2129 struct ov16a10 *ov16a10 = to_ov16a10(sd); in ov16a10_remove() local
2135 v4l2_ctrl_handler_free(&ov16a10->ctrl_handler); in ov16a10_remove()
2136 mutex_destroy(&ov16a10->mutex); in ov16a10_remove()
2140 __ov16a10_power_off(ov16a10); in ov16a10_remove()