Lines Matching +full:clip +full:- +full:x +full:- +full:high
1 // SPDX-License-Identifier: GPL-2.0
22 #include <media/media-entity.h>
23 #include <media/v4l2-async.h>
24 #include <media/v4l2-common.h>
25 #include <media/v4l2-ctrls.h>
26 #include <media/v4l2-device.h>
27 #include <media/v4l2-event.h>
28 #include <media/v4l2-fwnode.h>
29 #include <media/v4l2-mediabus.h>
30 #include <media/v4l2-subdev.h>
404 * AM19 : 3617 <- 0xC0
460 {0x3031, 0x0a}, /* MIPI 10-bit mode */
581 {0x3800, 0x00}, /* x start H */
582 {0x3801, 0x0c}, /* x start L */
585 {0x3804, 0x0c}, /* x end H */
586 {0x3805, 0xd3}, /* x end L */
589 {0x3808, 0x06}, /* x output size H */
590 {0x3809, 0x60}, /* x output size L */
597 {0x3810, 0x00}, /* ISP x win H */
598 {0x3811, 0x04}, /* ISP x win L */
600 {0x3814, 0x03}, /* x odd inc */
601 {0x3815, 0x01}, /* x even inc */
612 {0x3d8c, 0x73}, /* OTP setting start High */
640 {0x401f, 0x00}, /* interpolation x/y disable, Anchor one disable */
643 {0x4300, 0xff}, /* clip max H */
644 {0x4301, 0x00}, /* clip min H */
645 {0x4302, 0x0f}, /* clip min L, clip max L */
730 * AM19 : 3617 <- 0xC0
737 {0x3808, 0x06}, /* x output size H */
738 {0x3809, 0x60}, /* x output size L */
745 {0x3814, 0x03}, /* x odd inc */
776 {0x3808, 0x0c}, /* x output size H */
777 {0x3809, 0xc0}, /* x output size L */
784 {0x3814, 0x01}, /* x odd inc */
808 * AM19 : 3617 <- 0xC0
865 {0x3031, 0x0a}, /* MIPI 10-bit mode */
986 {0x3800, 0x00}, /* x start H */
987 {0x3801, 0x0c}, /* x start L */
990 {0x3804, 0x0c}, /* x end H */
991 {0x3805, 0xd3}, /* x end L */
994 {0x3808, 0x06}, /* x output size H */
995 {0x3809, 0x60}, /* x output size L */
1002 {0x3810, 0x00}, /* ISP x win H */
1003 {0x3811, 0x04}, /* ISP x win L */
1005 {0x3814, 0x03}, /* x odd inc */
1006 {0x3815, 0x01}, /* x even inc */
1017 {0x3d8c, 0x73}, /* OTP setting start High */
1045 {0x401f, 0x00}, /* interpolation x/y disable, Anchor one disable */
1048 {0x4300, 0xff}, /* clip max H */
1049 {0x4301, 0x00}, /* clip min H */
1050 {0x4302, 0x0f}, /* clip min L, clip max L */
1135 {0x3808, 0x06}, /* x output size H */
1136 {0x3809, 0x60}, /* x output size L */
1143 {0x3814, 0x03}, /* x odd inc */
1173 {0x3808, 0x0c}, /* x output size H */
1174 {0x3809, 0xc0}, /* x output size L */
1181 {0x3814, 0x01}, /* x odd inc */
1193 {0x402f, 0x08}, /* interpolation x/y disable, Anchor one disable */
1238 /* ----------------------------------------------------------------------------
1244 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_write()
1254 put_unaligned_be32(val << (8 * (4 - len)), buf + 2); in ov8858_write()
1258 ret = ret < 0 ? ret : -EIO; in ov8858_write()
1262 dev_err(&client->dev, in ov8858_write()
1285 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_read()
1296 msgs[0].addr = client->addr; in ov8858_read()
1302 msgs[1].addr = client->addr; in ov8858_read()
1305 msgs[1].buf = &data_be_p[4 - len]; in ov8858_read()
1307 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in ov8858_read()
1309 ret = ret < 0 ? ret : -EIO; in ov8858_read()
1310 dev_err(&client->dev, in ov8858_read()
1320 /* ----------------------------------------------------------------------------
1332 ret = ov8858_write_array(ov8858, ov8858->global_regs); in ov8858_start_stream()
1338 width, height, format->width, in ov8858_start_stream()
1339 format->height); in ov8858_start_stream()
1341 reg_list = ov8858->num_lanes == 4 in ov8858_start_stream()
1342 ? mode->reg_modes.mode_4lanes in ov8858_start_stream()
1343 : mode->reg_modes.mode_2lanes; in ov8858_start_stream()
1352 ret = __v4l2_ctrl_handler_setup(&ov8858->ctrl_handler); in ov8858_start_stream()
1383 ret = pm_runtime_resume_and_get(&client->dev); in ov8858_s_stream()
1389 dev_err(&client->dev, "Failed to start streaming\n"); in ov8858_s_stream()
1390 pm_runtime_put_sync(&client->dev); in ov8858_s_stream()
1395 pm_runtime_mark_last_busy(&client->dev); in ov8858_s_stream()
1396 pm_runtime_put_autosuspend(&client->dev); in ov8858_s_stream()
1409 /* ----------------------------------------------------------------------------
1422 width, height, fmt->format.width, in ov8858_set_fmt()
1423 fmt->format.height); in ov8858_set_fmt()
1425 fmt->format.code = MEDIA_BUS_FMT_SBGGR10_1X10; in ov8858_set_fmt()
1426 fmt->format.width = mode->width; in ov8858_set_fmt()
1427 fmt->format.height = mode->height; in ov8858_set_fmt()
1428 fmt->format.field = V4L2_FIELD_NONE; in ov8858_set_fmt()
1431 *v4l2_subdev_state_get_format(state, 0) = fmt->format; in ov8858_set_fmt()
1433 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) in ov8858_set_fmt()
1437 h_blank = mode->hts_def - mode->width; in ov8858_set_fmt()
1438 __v4l2_ctrl_modify_range(ov8858->hblank, h_blank, h_blank, 1, in ov8858_set_fmt()
1441 vblank_def = mode->vts_def - mode->height; in ov8858_set_fmt()
1442 __v4l2_ctrl_modify_range(ov8858->vblank, vblank_def, in ov8858_set_fmt()
1443 OV8858_VTS_MAX - mode->height, 1, in ov8858_set_fmt()
1453 if (fse->index >= ARRAY_SIZE(ov8858_modes)) in ov8858_enum_frame_sizes()
1454 return -EINVAL; in ov8858_enum_frame_sizes()
1456 if (fse->code != MEDIA_BUS_FMT_SBGGR10_1X10) in ov8858_enum_frame_sizes()
1457 return -EINVAL; in ov8858_enum_frame_sizes()
1459 fse->min_width = ov8858_modes[fse->index].width; in ov8858_enum_frame_sizes()
1460 fse->max_width = ov8858_modes[fse->index].width; in ov8858_enum_frame_sizes()
1461 fse->max_height = ov8858_modes[fse->index].height; in ov8858_enum_frame_sizes()
1462 fse->min_height = ov8858_modes[fse->index].height; in ov8858_enum_frame_sizes()
1471 if (code->index != 0) in ov8858_enum_mbus_code()
1472 return -EINVAL; in ov8858_enum_mbus_code()
1474 code->code = MEDIA_BUS_FMT_SBGGR10_1X10; in ov8858_enum_mbus_code()
1486 .width = def_mode->width, in ov8858_init_state()
1487 .height = def_mode->height, in ov8858_init_state()
1518 /* ----------------------------------------------------------------------------
1527 val = (pattern - 1) | OV8858_TEST_PATTERN_ENABLE; in ov8858_enable_test_pattern()
1536 struct ov8858 *ov8858 = container_of(ctrl->handler, in ov8858_set_ctrl()
1539 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_set_ctrl()
1549 * - by the core when s_ctrl is called int the VIDIOC_S_CTRL call path in ov8858_set_ctrl()
1550 * - by the driver when s_ctrl is called in the s_stream(1) call path in ov8858_set_ctrl()
1552 state = v4l2_subdev_get_locked_active_state(&ov8858->subdev); in ov8858_set_ctrl()
1556 switch (ctrl->id) { in ov8858_set_ctrl()
1559 max_exp = format->height + ctrl->val - OV8858_EXPOSURE_MARGIN; 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()
1567 if (!pm_runtime_get_if_in_use(&client->dev)) in ov8858_set_ctrl()
1570 switch (ctrl->id) { in ov8858_set_ctrl()
1574 ctrl->val << 4, NULL); in ov8858_set_ctrl()
1578 ctrl->val, NULL); in ov8858_set_ctrl()
1587 digi_gain = (ctrl->val & OV8858_LONG_DIGIGAIN_L_MASK) in ov8858_set_ctrl()
1588 | ((ctrl->val & OV8858_LONG_DIGIGAIN_H_MASK) << in ov8858_set_ctrl()
1595 ctrl->val + format->height, NULL); in ov8858_set_ctrl()
1598 ret = ov8858_enable_test_pattern(ov8858, ctrl->val); in ov8858_set_ctrl()
1601 ret = -EINVAL; in ov8858_set_ctrl()
1602 dev_warn(&client->dev, "%s Unhandled id: 0x%x\n", in ov8858_set_ctrl()
1603 __func__, ctrl->id); in ov8858_set_ctrl()
1607 pm_runtime_put(&client->dev); in ov8858_set_ctrl()
1616 /* ----------------------------------------------------------------------------
1622 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_power_on()
1623 struct device *dev = &client->dev; 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()
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()
1698 /* ----------------------------------------------------------------------------
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()
1721 ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; in ov8858_init_ctrls()
1724 pixel_rate = OV8858_LINK_FREQ * 2 * ov8858->num_lanes / 10; in ov8858_init_ctrls()
1728 h_blank = mode->hts_def - mode->width; 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()
1734 vblank_def = mode->vts_def - mode->height; in ov8858_init_ctrls()
1735 ov8858->vblank = v4l2_ctrl_new_std(handler, &ov8858_ctrl_ops, in ov8858_init_ctrls()
1737 OV8858_VTS_MAX - mode->height, in ov8858_init_ctrls()
1740 exposure_max = mode->vts_def - OV8858_EXPOSURE_MARGIN; in ov8858_init_ctrls()
1741 ov8858->exposure = v4l2_ctrl_new_std(handler, &ov8858_ctrl_ops, in ov8858_init_ctrls()
1745 mode->exp_def); in ov8858_init_ctrls()
1758 ARRAY_SIZE(ov8858_test_pattern_menu) - 1, in ov8858_init_ctrls()
1761 if (handler->error) { in ov8858_init_ctrls()
1762 ret = handler->error; in ov8858_init_ctrls()
1766 ret = v4l2_fwnode_device_parse(&client->dev, &props); in ov8858_init_ctrls()
1775 ov8858->subdev.ctrl_handler = handler; in ov8858_init_ctrls()
1780 dev_err(&client->dev, "Failed to init controls: %d\n", ret); in ov8858_init_ctrls()
1788 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_check_sensor_id()
1797 dev_err(&client->dev, "Unexpected sensor id 0x%x\n", id); in ov8858_check_sensor_id()
1798 return -ENODEV; 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()
1818 dev_warn(&client->dev, "R1A may not work well!\n"); in ov8858_check_sensor_id()
1820 dev_err(&client->dev, in ov8858_check_sensor_id()
1822 return -EINVAL; in ov8858_check_sensor_id()
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()
1836 return devm_regulator_bulk_get(&client->dev, in ov8858_configure_regulators()
1838 ov8858->supplies); in ov8858_configure_regulators()
1844 struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev); in ov8858_parse_of()
1845 struct device *dev = &client->dev; in ov8858_parse_of()
1852 return -EINVAL; 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()
1870 return -EINVAL; in ov8858_parse_of()
1878 struct device *dev = &client->dev; in ov8858_probe()
1885 return -ENOMEM; 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()
1919 sd = &ov8858->subdev; in ov8858_probe()
1920 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; in ov8858_probe()
1921 ov8858->pad.flags = MEDIA_PAD_FL_SOURCE; in ov8858_probe()
1922 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; 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()
1930 dev_err(&client->dev, "Subdev initialization error %d\n", ret); in ov8858_probe()
1965 media_entity_cleanup(&sd->entity); in ov8858_probe()
1967 v4l2_ctrl_handler_free(&ov8858->ctrl_handler); in ov8858_probe()
1978 media_entity_cleanup(&sd->entity); in ov8858_remove()
1979 v4l2_ctrl_handler_free(&ov8858->ctrl_handler); in ov8858_remove()
1981 pm_runtime_disable(&client->dev); in ov8858_remove()
1982 if (!pm_runtime_status_suspended(&client->dev)) in ov8858_remove()
1984 pm_runtime_set_suspended(&client->dev); in ov8858_remove()