Lines Matching +full:llp +full:- +full:based

1 // SPDX-License-Identifier: GPL-2.0
9 #include <media/v4l2-ctrls.h>
10 #include <media/v4l2-device.h>
11 #include <media/v4l2-event.h>
12 #include <media/v4l2-fwnode.h>
80 /* V-timing */
84 /* H-timing */
85 u32 llp; member
895 .llp = 3672,
907 .llp = 3672,
919 .llp = 3672,
931 .llp = 3672,
943 .llp = 3672,
955 .llp = 3672,
967 .llp = 3672,
979 .llp = 1836,
991 .llp = 1836,
1003 .llp = 1836,
1015 .llp = 1836,
1027 .llp = 1836,
1039 .llp = 1836,
1051 .llp = 3672,
1065 /* Get bayer order based on flip setting. */
1078 lockdep_assert_held(&imx355->mutex); in imx355_get_format_code()
1079 code = codes[imx355->vflip->val][imx355->hflip->val]; in imx355_get_format_code()
1087 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_read_reg()
1094 return -EINVAL; in imx355_read_reg()
1098 msgs[0].addr = client->addr; in imx355_read_reg()
1104 msgs[1].addr = client->addr; in imx355_read_reg()
1107 msgs[1].buf = &data_buf[4 - len]; in imx355_read_reg()
1109 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in imx355_read_reg()
1111 return -EIO; in imx355_read_reg()
1121 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_write_reg()
1125 return -EINVAL; in imx355_write_reg()
1128 put_unaligned_be32(val << (8 * (4 - len)), buf + 2); in imx355_write_reg()
1130 return -EIO; in imx355_write_reg()
1139 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_write_regs()
1146 dev_err_ratelimited(&client->dev, in imx355_write_regs()
1157 /* Open sub-device */
1162 v4l2_subdev_state_get_format(fh->state, 0); in imx355_open()
1164 mutex_lock(&imx355->mutex); in imx355_open()
1167 try_fmt->width = imx355->cur_mode->width; in imx355_open()
1168 try_fmt->height = imx355->cur_mode->height; in imx355_open()
1169 try_fmt->code = imx355_get_format_code(imx355); in imx355_open()
1170 try_fmt->field = V4L2_FIELD_NONE; in imx355_open()
1172 mutex_unlock(&imx355->mutex); in imx355_open()
1179 struct imx355 *imx355 = container_of(ctrl->handler, in imx355_set_ctrl()
1181 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_set_ctrl()
1186 switch (ctrl->id) { in imx355_set_ctrl()
1189 max = imx355->cur_mode->height + ctrl->val - 10; in imx355_set_ctrl()
1190 __v4l2_ctrl_modify_range(imx355->exposure, in imx355_set_ctrl()
1191 imx355->exposure->minimum, in imx355_set_ctrl()
1192 max, imx355->exposure->step, max); in imx355_set_ctrl()
1200 if (!pm_runtime_get_if_in_use(&client->dev)) in imx355_set_ctrl()
1203 switch (ctrl->id) { in imx355_set_ctrl()
1205 /* Analog gain = 1024/(1024 - ctrl->val) times */ in imx355_set_ctrl()
1207 ctrl->val); in imx355_set_ctrl()
1211 ctrl->val); in imx355_set_ctrl()
1215 ctrl->val); in imx355_set_ctrl()
1220 imx355->cur_mode->height + ctrl->val); in imx355_set_ctrl()
1224 2, ctrl->val); in imx355_set_ctrl()
1229 imx355->hflip->val | in imx355_set_ctrl()
1230 imx355->vflip->val << 1); in imx355_set_ctrl()
1233 ret = -EINVAL; in imx355_set_ctrl()
1234 dev_info(&client->dev, "ctrl(id:0x%x,val:0x%x) is not handled", in imx355_set_ctrl()
1235 ctrl->id, ctrl->val); in imx355_set_ctrl()
1239 pm_runtime_put(&client->dev); in imx355_set_ctrl()
1254 if (code->index > 0) in imx355_enum_mbus_code()
1255 return -EINVAL; in imx355_enum_mbus_code()
1257 mutex_lock(&imx355->mutex); in imx355_enum_mbus_code()
1258 code->code = imx355_get_format_code(imx355); in imx355_enum_mbus_code()
1259 mutex_unlock(&imx355->mutex); in imx355_enum_mbus_code()
1270 if (fse->index >= ARRAY_SIZE(supported_modes)) in imx355_enum_frame_size()
1271 return -EINVAL; in imx355_enum_frame_size()
1273 mutex_lock(&imx355->mutex); in imx355_enum_frame_size()
1274 if (fse->code != imx355_get_format_code(imx355)) { in imx355_enum_frame_size()
1275 mutex_unlock(&imx355->mutex); in imx355_enum_frame_size()
1276 return -EINVAL; in imx355_enum_frame_size()
1278 mutex_unlock(&imx355->mutex); in imx355_enum_frame_size()
1280 fse->min_width = supported_modes[fse->index].width; in imx355_enum_frame_size()
1281 fse->max_width = fse->min_width; in imx355_enum_frame_size()
1282 fse->min_height = supported_modes[fse->index].height; in imx355_enum_frame_size()
1283 fse->max_height = fse->min_height; in imx355_enum_frame_size()
1292 fmt->format.width = mode->width; in imx355_update_pad_format()
1293 fmt->format.height = mode->height; in imx355_update_pad_format()
1294 fmt->format.code = imx355_get_format_code(imx355); in imx355_update_pad_format()
1295 fmt->format.field = V4L2_FIELD_NONE; in imx355_update_pad_format()
1304 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { in imx355_do_get_pad_format()
1305 framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad); in imx355_do_get_pad_format()
1306 fmt->format = *framefmt; in imx355_do_get_pad_format()
1308 imx355_update_pad_format(imx355, imx355->cur_mode, fmt); in imx355_do_get_pad_format()
1321 mutex_lock(&imx355->mutex); in imx355_get_pad_format()
1323 mutex_unlock(&imx355->mutex); in imx355_get_pad_format()
1342 mutex_lock(&imx355->mutex); in imx355_set_pad_format()
1348 fmt->format.code = imx355_get_format_code(imx355); in imx355_set_pad_format()
1353 fmt->format.width, fmt->format.height); in imx355_set_pad_format()
1355 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { in imx355_set_pad_format()
1356 framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad); in imx355_set_pad_format()
1357 *framefmt = fmt->format; in imx355_set_pad_format()
1359 imx355->cur_mode = mode; in imx355_set_pad_format()
1362 __v4l2_ctrl_s_ctrl_int64(imx355->pixel_rate, pixel_rate); in imx355_set_pad_format()
1364 height = imx355->cur_mode->height; in imx355_set_pad_format()
1365 vblank_def = imx355->cur_mode->fll_def - height; in imx355_set_pad_format()
1366 vblank_min = imx355->cur_mode->fll_min - height; in imx355_set_pad_format()
1367 height = IMX355_FLL_MAX - height; in imx355_set_pad_format()
1368 __v4l2_ctrl_modify_range(imx355->vblank, vblank_min, height, 1, in imx355_set_pad_format()
1370 __v4l2_ctrl_s_ctrl(imx355->vblank, vblank_def); in imx355_set_pad_format()
1371 h_blank = mode->llp - imx355->cur_mode->width; in imx355_set_pad_format()
1376 __v4l2_ctrl_modify_range(imx355->hblank, h_blank, in imx355_set_pad_format()
1380 mutex_unlock(&imx355->mutex); in imx355_set_pad_format()
1388 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_start_streaming()
1394 ret = imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); in imx355_start_streaming()
1396 dev_err(&client->dev, "failed to set global settings"); in imx355_start_streaming()
1401 reg_list = &imx355->cur_mode->reg_list; in imx355_start_streaming()
1402 ret = imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); in imx355_start_streaming()
1404 dev_err(&client->dev, "failed to set mode"); in imx355_start_streaming()
1414 ret = __v4l2_ctrl_handler_setup(imx355->sd.ctrl_handler); in imx355_start_streaming()
1435 mutex_lock(&imx355->mutex); in imx355_set_stream()
1438 ret = pm_runtime_resume_and_get(&client->dev); in imx355_set_stream()
1451 pm_runtime_put(&client->dev); in imx355_set_stream()
1455 __v4l2_ctrl_grab(imx355->vflip, enable); in imx355_set_stream()
1456 __v4l2_ctrl_grab(imx355->hflip, enable); in imx355_set_stream()
1458 mutex_unlock(&imx355->mutex); in imx355_set_stream()
1463 pm_runtime_put(&client->dev); in imx355_set_stream()
1465 mutex_unlock(&imx355->mutex); in imx355_set_stream()
1473 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_identify_module()
1482 dev_err(&client->dev, "chip id mismatch: %x!=%x", in imx355_identify_module()
1484 return -EIO; in imx355_identify_module()
1522 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_init_controls()
1534 ctrl_hdlr = &imx355->ctrl_handler; in imx355_init_controls()
1539 ctrl_hdlr->lock = &imx355->mutex; in imx355_init_controls()
1540 max = ARRAY_SIZE(link_freq_menu_items) - 1; in imx355_init_controls()
1541 imx355->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1544 if (imx355->link_freq) in imx355_init_controls()
1545 imx355->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in imx355_init_controls()
1551 imx355->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1555 /* Initialize vblank/hblank/exposure parameters based on current mode */ in imx355_init_controls()
1556 mode = imx355->cur_mode; in imx355_init_controls()
1557 vblank_def = mode->fll_def - mode->height; in imx355_init_controls()
1558 vblank_min = mode->fll_min - mode->height; in imx355_init_controls()
1559 imx355->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1561 IMX355_FLL_MAX - mode->height, in imx355_init_controls()
1564 hblank = mode->llp - mode->width; in imx355_init_controls()
1565 imx355->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1568 if (imx355->hblank) in imx355_init_controls()
1569 imx355->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in imx355_init_controls()
1572 exposure_max = mode->fll_def - 10; in imx355_init_controls()
1573 imx355->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1579 imx355->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1581 if (imx355->hflip) in imx355_init_controls()
1582 imx355->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; in imx355_init_controls()
1583 imx355->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1585 if (imx355->vflip) in imx355_init_controls()
1586 imx355->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; in imx355_init_controls()
1599 ARRAY_SIZE(imx355_test_pattern_menu) - 1, in imx355_init_controls()
1601 if (ctrl_hdlr->error) { in imx355_init_controls()
1602 ret = ctrl_hdlr->error; in imx355_init_controls()
1603 dev_err(&client->dev, "control init failed: %d", ret); in imx355_init_controls()
1607 ret = v4l2_fwnode_device_parse(&client->dev, &props); in imx355_init_controls()
1616 imx355->sd.ctrl_handler = ctrl_hdlr; in imx355_init_controls()
1651 ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", in imx355_get_hwcfg()
1652 &cfg->ext_clk); in imx355_get_hwcfg()
1658 dev_dbg(dev, "ext clk: %d", cfg->ext_clk); in imx355_get_hwcfg()
1659 if (cfg->ext_clk != IMX355_EXT_CLK) { in imx355_get_hwcfg()
1661 cfg->ext_clk); in imx355_get_hwcfg()
1669 &cfg->link_freq_bitmap); in imx355_get_hwcfg()
1688 imx355 = devm_kzalloc(&client->dev, sizeof(*imx355), GFP_KERNEL); in imx355_probe()
1690 return -ENOMEM; in imx355_probe()
1692 mutex_init(&imx355->mutex); in imx355_probe()
1695 v4l2_i2c_subdev_init(&imx355->sd, client, &imx355_subdev_ops); in imx355_probe()
1700 dev_err(&client->dev, "failed to find sensor: %d", ret); in imx355_probe()
1704 imx355->hwcfg = imx355_get_hwcfg(&client->dev); in imx355_probe()
1705 if (!imx355->hwcfg) { in imx355_probe()
1706 dev_err(&client->dev, "failed to get hwcfg"); in imx355_probe()
1707 ret = -ENODEV; in imx355_probe()
1712 imx355->cur_mode = &supported_modes[0]; in imx355_probe()
1716 dev_err(&client->dev, "failed to init controls: %d", ret); in imx355_probe()
1721 imx355->sd.internal_ops = &imx355_internal_ops; in imx355_probe()
1722 imx355->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in imx355_probe()
1724 imx355->sd.entity.ops = &imx355_subdev_entity_ops; in imx355_probe()
1725 imx355->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in imx355_probe()
1728 imx355->pad.flags = MEDIA_PAD_FL_SOURCE; in imx355_probe()
1729 ret = media_entity_pads_init(&imx355->sd.entity, 1, &imx355->pad); in imx355_probe()
1731 dev_err(&client->dev, "failed to init entity pads: %d", ret); in imx355_probe()
1736 * Device is already turned on by i2c-core with ACPI domain PM. in imx355_probe()
1739 pm_runtime_set_active(&client->dev); in imx355_probe()
1740 pm_runtime_enable(&client->dev); in imx355_probe()
1741 pm_runtime_idle(&client->dev); in imx355_probe()
1743 ret = v4l2_async_register_subdev_sensor(&imx355->sd); in imx355_probe()
1750 pm_runtime_disable(&client->dev); in imx355_probe()
1751 pm_runtime_set_suspended(&client->dev); in imx355_probe()
1752 media_entity_cleanup(&imx355->sd.entity); in imx355_probe()
1755 v4l2_ctrl_handler_free(imx355->sd.ctrl_handler); in imx355_probe()
1758 mutex_destroy(&imx355->mutex); in imx355_probe()
1769 media_entity_cleanup(&sd->entity); in imx355_remove()
1770 v4l2_ctrl_handler_free(sd->ctrl_handler); in imx355_remove()
1772 pm_runtime_disable(&client->dev); in imx355_remove()
1773 pm_runtime_set_suspended(&client->dev); in imx355_remove()
1775 mutex_destroy(&imx355->mutex); in imx355_remove()