Lines Matching refs:isl7998x

511 struct isl7998x {  struct
540 static struct isl7998x *sd_to_isl7998x(struct v4l2_subdev *sd) in sd_to_isl7998x() argument
542 return container_of(sd, struct isl7998x, subdev); in sd_to_isl7998x()
545 static struct isl7998x *i2c_to_isl7998x(const struct i2c_client *client) in i2c_to_isl7998x()
613 static int isl7998x_wait_power_on(struct isl7998x *isl7998x) in isl7998x_wait_power_on() argument
615 struct device *dev = isl7998x->subdev.dev; in isl7998x_wait_power_on()
621 isl7998x->regmap, in isl7998x_wait_power_on()
633 static int isl7998x_set_standard(struct isl7998x *isl7998x, v4l2_std_id norm) in isl7998x_set_standard() argument
642 ret = regmap_write_bits(isl7998x->regmap, in isl7998x_set_standard()
650 ret = regmap_write(isl7998x->regmap, in isl7998x_set_standard()
656 ret = regmap_write(isl7998x->regmap, in isl7998x_set_standard()
665 static int isl7998x_init(struct isl7998x *isl7998x) in isl7998x_init() argument
667 const unsigned int lanes = isl7998x->nr_mipi_lanes; in isl7998x_init()
671 isl7998x_video_in_chan_map[isl7998x->nr_inputs - 1] }, in isl7998x_init()
677 struct device *dev = isl7998x->subdev.dev; in isl7998x_init()
678 struct regmap *regmap = isl7998x->regmap; in isl7998x_init()
682 isl7998x->nr_mipi_lanes, isl7998x->nr_inputs, in isl7998x_init()
683 v4l2_norm_to_name(isl7998x->norm)); in isl7998x_init()
690 mutex_lock(&isl7998x->lock); in isl7998x_init()
691 ret = isl7998x_set_standard(isl7998x, isl7998x->norm); in isl7998x_init()
692 mutex_unlock(&isl7998x->lock); in isl7998x_init()
705 static int isl7998x_set_test_pattern(struct isl7998x *isl7998x) in isl7998x_set_test_pattern() argument
713 isl7998x->test_pattern_bars << 6 }, in isl7998x_set_test_pattern()
715 isl7998x->norm & V4L2_STD_PAL ? BIT(2) : 0 }, in isl7998x_set_test_pattern()
717 (isl7998x->test_pattern_chans << 4) | in isl7998x_set_test_pattern()
718 (isl7998x->test_pattern_color << 2) } in isl7998x_set_test_pattern()
720 struct device *dev = isl7998x->subdev.dev; in isl7998x_set_test_pattern()
721 struct regmap *regmap = isl7998x->regmap; in isl7998x_set_test_pattern()
727 if (isl7998x->test_pattern != 0) { in isl7998x_set_test_pattern()
729 isl7998x->test_pattern_chans, in isl7998x_set_test_pattern()
730 isl7998x_test_pattern_bars[isl7998x->test_pattern_bars], in isl7998x_set_test_pattern()
731 isl7998x_test_pattern_colors[isl7998x->test_pattern_color]); in isl7998x_set_test_pattern()
748 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_g_register() local
752 ret = regmap_read(isl7998x->regmap, reg->reg, &val); in isl7998x_g_register()
765 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_s_register() local
767 return regmap_write(isl7998x->regmap, reg->reg, reg->val); in isl7998x_s_register()
773 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_g_std() local
775 mutex_lock(&isl7998x->lock); in isl7998x_g_std()
776 *norm = isl7998x->norm; in isl7998x_g_std()
777 mutex_unlock(&isl7998x->lock); in isl7998x_g_std()
784 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_s_std() local
789 mutex_lock(&isl7998x->lock); in isl7998x_s_std()
790 if (isl7998x->enabled) { in isl7998x_s_std()
792 mutex_unlock(&isl7998x->lock); in isl7998x_s_std()
795 isl7998x->norm = norm; in isl7998x_s_std()
796 mutex_unlock(&isl7998x->lock); in isl7998x_s_std()
801 ret = isl7998x_set_standard(isl7998x, norm); in isl7998x_s_std()
810 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_querystd() local
824 mutex_lock(&isl7998x->lock); in isl7998x_querystd()
825 if (isl7998x->enabled) { in isl7998x_querystd()
830 ret = isl7998x_set_standard(isl7998x, V4L2_STD_UNKNOWN); in isl7998x_querystd()
835 ret = regmap_write(isl7998x->regmap, in isl7998x_querystd()
843 ret = regmap_read_poll_timeout(isl7998x->regmap, in isl7998x_querystd()
857 for (i = 0; i < isl7998x->nr_inputs; i++) { in isl7998x_querystd()
870 isl7998x_set_standard(isl7998x, isl7998x->norm); in isl7998x_querystd()
872 mutex_unlock(&isl7998x->lock); in isl7998x_querystd()
887 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_g_input_status() local
899 for (i = 0; i < isl7998x->nr_inputs; i++) { in isl7998x_g_input_status()
900 ret = regmap_read(isl7998x->regmap, in isl7998x_g_input_status()
917 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_s_stream() local
925 mutex_lock(&isl7998x->lock); in isl7998x_s_stream()
926 if (isl7998x->enabled == enable) in isl7998x_s_stream()
928 isl7998x->enabled = enable; in isl7998x_s_stream()
931 ret = isl7998x_set_test_pattern(isl7998x); in isl7998x_s_stream()
936 regmap_read(isl7998x->regmap, in isl7998x_s_stream()
942 ret = regmap_write(isl7998x->regmap, in isl7998x_s_stream()
946 mutex_unlock(&isl7998x->lock); in isl7998x_s_stream()
1003 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_get_fmt() local
1007 mutex_lock(&isl7998x->lock); in isl7998x_get_fmt()
1015 mode = isl7998x_norm_to_mode(isl7998x->norm); in isl7998x_get_fmt()
1019 mf->code = isl7998x->fmt->code; in isl7998x_get_fmt()
1024 mutex_unlock(&isl7998x->lock); in isl7998x_get_fmt()
1033 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_set_fmt() local
1037 mutex_lock(&isl7998x->lock); in isl7998x_set_fmt()
1039 mode = isl7998x_norm_to_mode(isl7998x->norm); in isl7998x_set_fmt()
1043 mf->code = isl7998x->fmt->code; in isl7998x_set_fmt()
1049 mutex_unlock(&isl7998x->lock); in isl7998x_set_fmt()
1056 struct isl7998x *isl7998x = container_of(ctrl->handler, in isl7998x_set_ctrl() local
1057 struct isl7998x, ctrl_handler); in isl7998x_set_ctrl()
1062 mutex_lock(&isl7998x->lock); in isl7998x_set_ctrl()
1063 isl7998x->test_pattern_bars = ctrl->val & 0x3; in isl7998x_set_ctrl()
1064 ret = isl7998x_set_test_pattern(isl7998x); in isl7998x_set_ctrl()
1065 mutex_unlock(&isl7998x->lock); in isl7998x_set_ctrl()
1068 mutex_lock(&isl7998x->lock); in isl7998x_set_ctrl()
1069 isl7998x->test_pattern_chans = ctrl->val & 0xf; in isl7998x_set_ctrl()
1070 ret = isl7998x_set_test_pattern(isl7998x); in isl7998x_set_ctrl()
1071 mutex_unlock(&isl7998x->lock); in isl7998x_set_ctrl()
1074 mutex_lock(&isl7998x->lock); in isl7998x_set_ctrl()
1075 isl7998x->test_pattern_color = ctrl->val & 0x3; in isl7998x_set_ctrl()
1076 ret = isl7998x_set_test_pattern(isl7998x); in isl7998x_set_ctrl()
1077 mutex_unlock(&isl7998x->lock); in isl7998x_set_ctrl()
1080 mutex_lock(&isl7998x->lock); in isl7998x_set_ctrl()
1081 isl7998x->test_pattern = ctrl->val; in isl7998x_set_ctrl()
1082 ret = isl7998x_set_test_pattern(isl7998x); in isl7998x_set_ctrl()
1083 mutex_unlock(&isl7998x->lock); in isl7998x_set_ctrl()
1343 static int isl7998x_mc_init(struct isl7998x *isl7998x) in isl7998x_mc_init() argument
1347 isl7998x->subdev.entity.ops = &isl7998x_entity_ops; in isl7998x_mc_init()
1348 isl7998x->subdev.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; in isl7998x_mc_init()
1350 isl7998x->pads[ISL7998X_PAD_OUT].flags = MEDIA_PAD_FL_SOURCE; in isl7998x_mc_init()
1352 isl7998x->pads[i].flags = MEDIA_PAD_FL_SINK; in isl7998x_mc_init()
1354 return media_entity_pads_init(&isl7998x->subdev.entity, in isl7998x_mc_init()
1356 isl7998x->pads); in isl7998x_mc_init()
1386 static void isl7998x_remove_controls(struct isl7998x *isl7998x) in isl7998x_remove_controls() argument
1388 v4l2_ctrl_handler_free(&isl7998x->ctrl_handler); in isl7998x_remove_controls()
1389 mutex_destroy(&isl7998x->ctrl_mutex); in isl7998x_remove_controls()
1392 static int isl7998x_init_controls(struct isl7998x *isl7998x) in isl7998x_init_controls() argument
1394 struct v4l2_subdev *sd = &isl7998x->subdev; in isl7998x_init_controls()
1399 ret = v4l2_ctrl_handler_init(&isl7998x->ctrl_handler, in isl7998x_init_controls()
1404 mutex_init(&isl7998x->ctrl_mutex); in isl7998x_init_controls()
1405 isl7998x->ctrl_handler.lock = &isl7998x->ctrl_mutex; in isl7998x_init_controls()
1406 link_freq_index = get_link_freq_menu_index(isl7998x->nr_mipi_lanes, in isl7998x_init_controls()
1407 isl7998x->nr_inputs); in isl7998x_init_controls()
1412 isl7998x->nr_mipi_lanes, isl7998x->nr_inputs); in isl7998x_init_controls()
1417 isl7998x->link_freq = v4l2_ctrl_new_int_menu(&isl7998x->ctrl_handler, in isl7998x_init_controls()
1423 if (isl7998x->link_freq) in isl7998x_init_controls()
1424 isl7998x->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in isl7998x_init_controls()
1427 v4l2_ctrl_new_custom(&isl7998x->ctrl_handler, in isl7998x_init_controls()
1430 v4l2_ctrl_new_std_menu_items(&isl7998x->ctrl_handler, in isl7998x_init_controls()
1436 ret = isl7998x->ctrl_handler.error; in isl7998x_init_controls()
1440 isl7998x->subdev.ctrl_handler = &isl7998x->ctrl_handler; in isl7998x_init_controls()
1441 v4l2_ctrl_handler_setup(&isl7998x->ctrl_handler); in isl7998x_init_controls()
1446 isl7998x_remove_controls(isl7998x); in isl7998x_init_controls()
1458 struct isl7998x *isl7998x; in isl7998x_probe() local
1470 isl7998x = devm_kzalloc(dev, sizeof(*isl7998x), GFP_KERNEL); in isl7998x_probe()
1471 if (!isl7998x) in isl7998x_probe()
1474 isl7998x->pd_gpio = devm_gpiod_get_optional(dev, "powerdown", in isl7998x_probe()
1476 if (IS_ERR(isl7998x->pd_gpio)) in isl7998x_probe()
1477 return dev_err_probe(dev, PTR_ERR(isl7998x->pd_gpio), in isl7998x_probe()
1480 isl7998x->rstb_gpio = devm_gpiod_get_optional(dev, "reset", in isl7998x_probe()
1482 if (IS_ERR(isl7998x->rstb_gpio)) in isl7998x_probe()
1483 return dev_err_probe(dev, PTR_ERR(isl7998x->rstb_gpio), in isl7998x_probe()
1486 isl7998x->regmap = devm_regmap_init_i2c(client, &isl7998x_regmap); in isl7998x_probe()
1487 if (IS_ERR(isl7998x->regmap)) in isl7998x_probe()
1488 return dev_err_probe(dev, PTR_ERR(isl7998x->regmap), in isl7998x_probe()
1506 isl7998x->nr_mipi_lanes = endpoint.bus.mipi_csi2.num_data_lanes; in isl7998x_probe()
1512 isl7998x->nr_inputs = nr_inputs; in isl7998x_probe()
1514 v4l2_i2c_subdev_init(&isl7998x->subdev, client, &isl7998x_subdev_ops); in isl7998x_probe()
1515 isl7998x->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in isl7998x_probe()
1517 ret = isl7998x_mc_init(isl7998x); in isl7998x_probe()
1521 isl7998x->fmt = &isl7998x_colour_fmts[0]; in isl7998x_probe()
1522 isl7998x->norm = V4L2_STD_NTSC; in isl7998x_probe()
1523 isl7998x->enabled = 0; in isl7998x_probe()
1525 mutex_init(&isl7998x->lock); in isl7998x_probe()
1527 ret = isl7998x_init_controls(isl7998x); in isl7998x_probe()
1531 ret = v4l2_async_register_subdev(&isl7998x->subdev); in isl7998x_probe()
1540 isl7998x_remove_controls(isl7998x); in isl7998x_probe()
1542 media_entity_cleanup(&isl7998x->subdev.entity); in isl7998x_probe()
1549 struct isl7998x *isl7998x = i2c_to_isl7998x(client); in isl7998x_remove() local
1552 v4l2_async_unregister_subdev(&isl7998x->subdev); in isl7998x_remove()
1553 isl7998x_remove_controls(isl7998x); in isl7998x_remove()
1554 media_entity_cleanup(&isl7998x->subdev.entity); in isl7998x_remove()
1572 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_runtime_resume() local
1575 gpiod_set_value(isl7998x->rstb_gpio, 1); in isl7998x_runtime_resume()
1576 gpiod_set_value(isl7998x->pd_gpio, 0); in isl7998x_runtime_resume()
1577 gpiod_set_value(isl7998x->rstb_gpio, 0); in isl7998x_runtime_resume()
1579 ret = isl7998x_wait_power_on(isl7998x); in isl7998x_runtime_resume()
1583 ret = isl7998x_init(isl7998x); in isl7998x_runtime_resume()
1590 gpiod_set_value(isl7998x->pd_gpio, 1); in isl7998x_runtime_resume()
1598 struct isl7998x *isl7998x = sd_to_isl7998x(sd); in isl7998x_runtime_suspend() local
1600 gpiod_set_value(isl7998x->pd_gpio, 1); in isl7998x_runtime_suspend()