public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Thierry Reding <treding@nvidia.com>,
	Mikko Perttunen <mperttunen@nvidia.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Sowjanya Komatineni <skomatineni@nvidia.com>,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	Svyatoslav Ryhel <clamor95@gmail.com>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-tegra@vger.kernel.org, linux-media@vger.kernel.org,
	linux-staging@lists.linux.dev
Subject: [PATCH v7 06/15] staging: media: tegra-video: vi: improve logic of source requesting
Date: Tue,  3 Mar 2026 10:42:29 +0200	[thread overview]
Message-ID: <20260303084239.15007-7-clamor95@gmail.com> (raw)
In-Reply-To: <20260303084239.15007-1-clamor95@gmail.com>

By default tegra_channel_get_remote_csi_subdev returns next device in pipe
assuming it is CSI but in case of Tegra20 and Tegra30 it can also be VIP
or even HOST.

Define tegra_channel_get_remote_csi_subdev within CSI and add check if
returned device is actually CSI by comparing subdevice operations.

Previous tegra_channel_get_remote_csi_subdev definition in VI rename to
tegra_channel_get_remote_bridge_subdev and use it only in VI driver since
core VI driver does not care about source and does not call any specific
functions.

Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # tegra20, parallel camera
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/staging/media/tegra-video/csi.c | 16 ++++++++++++++++
 drivers/staging/media/tegra-video/vi.c  | 14 +++++++-------
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/tegra-video/csi.c b/drivers/staging/media/tegra-video/csi.c
index bcaea20c3025..92078a1f9a4e 100644
--- a/drivers/staging/media/tegra-video/csi.c
+++ b/drivers/staging/media/tegra-video/csi.c
@@ -445,6 +445,22 @@ static const struct v4l2_subdev_ops tegra_csi_ops = {
 	.pad    = &tegra_csi_pad_ops,
 };
 
+struct v4l2_subdev *tegra_channel_get_remote_csi_subdev(struct tegra_vi_channel *chan)
+{
+	struct media_pad *pad;
+	struct v4l2_subdev *subdev;
+
+	pad = media_pad_remote_pad_first(&chan->pad);
+	if (!pad)
+		return NULL;
+
+	subdev = media_entity_to_v4l2_subdev(pad->entity);
+	if (!subdev)
+		return NULL;
+
+	return subdev->ops == &tegra_csi_ops ? subdev : NULL;
+}
+
 static int tegra_csi_channel_alloc(struct tegra_csi *csi,
 				   struct device_node *node,
 				   unsigned int port_num, unsigned int lanes,
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index 19eebfdae221..7032c733577d 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -160,8 +160,8 @@ static void tegra_channel_buffer_queue(struct vb2_buffer *vb)
 	wake_up_interruptible(&chan->start_wait);
 }
 
-struct v4l2_subdev *
-tegra_channel_get_remote_csi_subdev(struct tegra_vi_channel *chan)
+static struct v4l2_subdev *
+tegra_channel_get_remote_bridge_subdev(struct tegra_vi_channel *chan)
 {
 	struct media_pad *pad;
 
@@ -182,7 +182,7 @@ tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan)
 	struct v4l2_subdev *subdev;
 	struct media_entity *entity;
 
-	subdev = tegra_channel_get_remote_csi_subdev(chan);
+	subdev = tegra_channel_get_remote_bridge_subdev(chan);
 	if (!subdev)
 		return NULL;
 
@@ -204,7 +204,7 @@ static int tegra_channel_enable_stream(struct tegra_vi_channel *chan)
 	struct v4l2_subdev *subdev;
 	int ret;
 
-	subdev = tegra_channel_get_remote_csi_subdev(chan);
+	subdev = tegra_channel_get_remote_bridge_subdev(chan);
 	ret = v4l2_subdev_call(subdev, video, s_stream, true);
 	if (ret < 0 && ret != -ENOIOCTLCMD)
 		return ret;
@@ -217,7 +217,7 @@ static int tegra_channel_disable_stream(struct tegra_vi_channel *chan)
 	struct v4l2_subdev *subdev;
 	int ret;
 
-	subdev = tegra_channel_get_remote_csi_subdev(chan);
+	subdev = tegra_channel_get_remote_bridge_subdev(chan);
 	ret = v4l2_subdev_call(subdev, video, s_stream, false);
 	if (ret < 0 && ret != -ENOIOCTLCMD)
 		return ret;
@@ -1631,11 +1631,11 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier)
 		goto unregister_video;
 	}
 
-	subdev = tegra_channel_get_remote_csi_subdev(chan);
+	subdev = tegra_channel_get_remote_bridge_subdev(chan);
 	if (!subdev) {
 		ret = -ENODEV;
 		dev_err(vi->dev,
-			"failed to get remote csi subdev: %d\n", ret);
+			"failed to get remote bridge subdev: %d\n", ret);
 		goto unregister_video;
 	}
 
-- 
2.51.0


  parent reply	other threads:[~2026-03-03  8:43 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03  8:42 [PATCH v7 00/15] tegra-video: add CSI support for Tegra20 and Tegra30 Svyatoslav Ryhel
2026-03-03  8:42 ` [PATCH v7 01/15] staging: media: tegra-video: expand VI and VIP support to Tegra30 Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 02/15] staging: media: tegra-video: vi: adjust get_selection operation check Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 03/15] staging: media: tegra-video: vi: add flip controls only if no source controls are provided Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 04/15] staging: media: tegra-video: csi: move CSI helpers to header Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 05/15] gpu: host1x: convert MIPI to use operation function pointers Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` Svyatoslav Ryhel [this message]
2026-03-03 21:48   ` Claude review: staging: media: tegra-video: vi: improve logic of source requesting Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 07/15] staging: media: tegra-video: csi: move avdd-dsi-csi-supply from VI to CSI Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 08/15] staging: media: tegra-video: tegra20: set correct maximum width and height Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 09/15] staging: media: tegra-video: tegra20: add support for second output of VI Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 10/15] staging: media: tegra-video: tegra20: adjust format align calculations Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 11/15] staging: media: tegra-video: tegra20: set VI HW revision Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 12/15] staging: media: tegra-video: tegra20: increase maximum VI clock frequency Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 13/15] staging: media: tegra-video: tegra20: expand format support with RAW8/10 and YUV422/YUV420p 1X16 Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 14/15] staging: media: tegra-video: tegra20: adjust luma buffer stride Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03  8:42 ` [PATCH v7 15/15] staging: media: tegra-video: add CSI support for Tegra20 and Tegra30 Svyatoslav Ryhel
2026-03-03 21:48   ` Claude review: " Claude Code Review Bot
2026-03-03 21:48 ` Claude review: " Claude Code Review Bot

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=20260303084239.15007-7-clamor95@gmail.com \
    --to=clamor95@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hverkuil+cisco@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux-tegra@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=mchehab@kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=simona@ffwll.ch \
    --cc=skomatineni@nvidia.com \
    --cc=thierry.reding@gmail.com \
    --cc=treding@nvidia.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