Message ID | 1596231144-12554-1-git-send-email-skomatineni@nvidia.com |
---|---|
Headers | show |
Series | Support for Tegra video capture from external sensor | expand |
01.08.2020 00:32, Sowjanya Komatineni пишет: ... > +static int tegra_csi_channels_alloc(struct tegra_csi *csi) > +{ > + struct device_node *node = csi->dev->of_node; > + struct v4l2_fwnode_endpoint v4l2_ep = { > + .bus_type = V4L2_MBUS_CSI2_DPHY > + }; > + struct fwnode_handle *fwh; > + struct device_node *channel; > + struct device_node *ep; > + unsigned int lanes, portno, num_pads; > + int ret; > + > + for_each_child_of_node(node, channel) { > + if (!of_node_name_eq(channel, "channel")) > + continue; > + > + ret = of_property_read_u32(channel, "reg", &portno); > + if (ret < 0) > + continue; > + > + if (portno >= csi->soc->csi_max_channels) { > + dev_err(csi->dev, "invalid port num %d\n", portno); The "channel" node should be put on error. > + return -EINVAL; > + } > + > + ep = of_graph_get_endpoint_by_regs(channel, 0, 0); > + if (!ep) > + continue; > + > + fwh = of_fwnode_handle(ep); > + ret = v4l2_fwnode_endpoint_parse(fwh, &v4l2_ep); > + of_node_put(ep); > + if (ret) { > + dev_err(csi->dev, > + "failed to parse v4l2 endpoint: %d\n", ret); > + return ret; > + } > + > + lanes = v4l2_ep.bus.mipi_csi2.num_data_lanes; > + if (!lanes || ((lanes & (lanes - 1)) != 0)) { > + dev_err(csi->dev, "invalid data-lanes %d\n", lanes); > + return -EINVAL; > + } > + > + num_pads = of_graph_get_endpoint_count(channel); > + if (num_pads == TEGRA_CSI_PADS_NUM) { > + ret = tegra_csi_channel_alloc(csi, channel, portno, > + lanes, num_pads); > + if (ret < 0) > + return ret; > + } > } ... > +static int tegra_vi_channels_alloc(struct tegra_vi *vi) > +{ > + struct device_node *node = vi->dev->of_node; > + struct device_node *ep = NULL; > + struct device_node *ports; > + struct device_node *port; > + unsigned int port_num; > + int ret; > + > + ports = of_get_child_by_name(node, "ports"); > + if (!ports) > + return -ENODEV; > + > + for_each_child_of_node(ports, port) { > + if (!of_node_name_eq(port, "port")) > + continue; > + > + ret = of_property_read_u32(port, "reg", &port_num); > + if (ret < 0) > + continue; > + > + if (port_num > vi->soc->vi_max_channels) { > + of_node_put(ports); s/ports/port/ > + dev_err(vi->dev, "invalid port num %d\n", port_num); > + return -EINVAL; > + } > + > + ep = of_get_child_by_name(port, "endpoint"); > + if (!ep) > + continue; > + > + of_node_put(ep); > + ret = tegra_vi_channel_alloc(vi, port_num, port); > + if (ret < 0) { > + of_node_put(ports); s/ports/port/ > + return ret; > + } > }
01.08.2020 00:32, Sowjanya Komatineni пишет: > CSI MIPI pads need to be enabled and calibrated for capturing from > the external sensor or transmitter. > > MIPI CAL unit calibrates MIPI pads pull-up, pull-down and termination > impedances. Calibration is done by co-work of MIPI BIAS pad and MIPI > CAL control unit. > > Triggering calibration start can happen any time after MIPI pads are > enabled but calibration results will be latched and applied to MIPI > pads by MIPI CAL unit only when the link is in LP11 state and then > calibration status register gets updated. > > This patch enables CSI MIPI pads and calibrates them during streaming. > > Tegra CSI receiver is able to catch the very first clock transition. > So, CSI receiver is always enabled prior to sensor streaming and > trigger of calibration start is done during CSI subdev streaming and > status of calibration is verified after sensor stream on. > > Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com> > --- > drivers/staging/media/tegra-video/TODO | 1 - > drivers/staging/media/tegra-video/csi.c | 61 +++++++++++++++++++++++++++++++-- > drivers/staging/media/tegra-video/csi.h | 2 ++ > drivers/staging/media/tegra-video/vi.c | 28 ++++++++++++--- > 4 files changed, 84 insertions(+), 8 deletions(-) Reviewed-by: Dmitry Osipenko <digetx@gmail.com>