linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Sowjanya Komatineni <skomatineni@nvidia.com>,
	thierry.reding@gmail.com, jonathanh@nvidia.com,
	frankc@nvidia.com, hverkuil@xs4all.nl, sakari.ailus@iki.fi,
	robh+dt@kernel.org, helen.koike@collabora.com
Cc: gregkh@linuxfoundation.org, linux-media@vger.kernel.org,
	devicetree@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 06/10] media: tegra-video: Add support for external sensor capture
Date: Sat, 1 Aug 2020 03:59:10 +0300	[thread overview]
Message-ID: <08acaeff-7819-07a3-69ca-adfbdb872ee3@gmail.com> (raw)
In-Reply-To: <1596231144-12554-7-git-send-email-skomatineni@nvidia.com>

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;
> +		}
>  	}

  reply	other threads:[~2020-08-01  0:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 21:32 [PATCH v7 00/10] Support for Tegra video capture from external sensor Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 01/10] media: tegra-video: Fix channel format alignment Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 02/10] media: tegra-video: Enable TPG based on kernel config Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 03/10] media: tegra-video: Update format lookup to offset based Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 04/10] dt-bindings: tegra: Update VI and CSI bindings with port info Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 05/10] media: tegra-video: Separate CSI stream enable and disable implementations Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 06/10] media: tegra-video: Add support for external sensor capture Sowjanya Komatineni
2020-08-01  0:59   ` Dmitry Osipenko [this message]
2020-07-31 21:32 ` [PATCH v7 07/10] media: tegra-video: Add support for selection ioctl ops Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done Sowjanya Komatineni
2020-07-31 21:32 ` [PATCH v7 09/10] media: tegra-video: Add CSI MIPI pads calibration Sowjanya Komatineni
2020-08-01  1:04   ` Dmitry Osipenko
2020-07-31 21:32 ` [PATCH v7 10/10] media: tegra-video: Compute settle times based on the clock rate Sowjanya Komatineni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08acaeff-7819-07a3-69ca-adfbdb872ee3@gmail.com \
    --to=digetx@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frankc@nvidia.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=skomatineni@nvidia.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).