Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795975682; b=YcEcMe3IbZo8+Ne4mjx7mjMjvAvrVmjqx1u3XYZZavipwSFizwISi9qcQoLVJnzimsnp MrLAVmdG7azPumHBMuPYGoxqgMoLE7g1JSirE6/WHI0SKbQ5i2zPjl4M39o0J+lGYHvDh 99XUJqwpwLsk1izjRaBfm6J2S8efXTIJk1MjSL9Z3duMpdAkvoQsFUrP9yY9AzgfT0e0C 7qhv/uPO29aAp9lwY4UlAUV6aZR6Te9uAa8Ib3BHypoJDLTWnzsDjSIbQm5Q50ai82eUI ZWmuTe5W2vISBUFhMmKkiQA0WFP9YF0ESFN6TibBQ+/aRa+94etEFmoCLyjXwUitx5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795975682; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=RA48dTDHVI9bHRqRD3KcQC9oXBMus0z1Ne0VR0wJ9Uk=; b=rAwUKNo5uAYbtWRVpLSOgxnL0V1NZnKWzb6tzTpzfVecK/cSb9evKeEUuJ/ScU/YMtbK SVYrhdLMgfhgCyRm071xBAQikhAHvk9+lNcA4IXOC0SP+YigxkmH29+jHKN/1Qo2rNwCO mVc+B7hqVL4kE48xDXY1yiwTTIEHSCHQ8n6djyOMhL6TgwNoe8Xc2MDlNpijspm5z6/Dl tCj/LZEJcQYwvftx4xng+ZBJHsrsq3WMC2Q7l7CB4LF57rmVl2yHcXrhYwHa2aNhaGNpD 90geAXzuzIonrbgDkz7IPrMKenHAfD8fSX1GuDFgfFcuBCWY1xR2daKCL1XyvGO+UMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yC8PTzuB; arc=none smtp.remote-ip=209.85.218.53 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C897D606A6BD for ; Sun, 29 Nov 2026 18:08:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C897D606A6BD Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yC8PTzuB Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-c4203bbb1e9so1614842166b.3 for ; Sun, 29 Nov 2026 10:08:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795975680; x=1796580480; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RA48dTDHVI9bHRqRD3KcQC9oXBMus0z1Ne0VR0wJ9Uk=; b=yC8PTzuBCisDnERWZBrCHVUeAoyEj/Lbxhla8j8LxrBIhTsMSVgHCYOixdTDScVhCG LiGtFNsNYmAJLVFkgF7ETDzDz/5/002yDnSe+XVDZW/3nJZ2ZTjUJTow1Z0pYJNsxYJv KAwhzBsESEhMSmzWEzHJ/vVyAUqyySA2zbJktKJ80OSHOoj1JyfpGyMjElXJ8PvNdrVK KZ5ndga8ktv9cdKB6uR3gUAbrpNbP5DNDS3xO7G3d4Eeee3rLHSXlbMt5n70LyPp9KNr goeI/MGQ3WX58uowQHmbLEzf8sfhx3xxwHd5lagBdA1TNneugzzpaK+VundmJMo1tnR6 +KDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795975680; x=1796580480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RA48dTDHVI9bHRqRD3KcQC9oXBMus0z1Ne0VR0wJ9Uk=; b=21H/YxpG3at5HSd154GJs6mqN0bPwRKo21IZhcj4hs2+qQiNEGBj82LOEh/WTOpOO+ w5KlM93X0VA+QIOgFEPKkTyIrIuF2srw1WKVWpocBQSaB8EJcMa6X5k5adG2922cd8lk sZu0Q7yUxg1Ud3JvQvOIJOHPmQXox4Nz+VnoVHw1ucM//v4iEijRavQCZNoppmIWEnv2 hkoMogNk5eMhqHGG0Xu+clbng5MUv0mo4rZxKG2FLnO012ZwR2F3Xo38vOzh8Pqf7fXq wCQj4HFONPjdcOHAAvgJvi62Z1YlVEvnFaBGhqIXKutRr7lU86cSlCO9YJ/U0NONc+9e Endg== X-Forwarded-Encrypted: i=1; AL+hErEckmoFy91b1Go6v0fu0XM7GIyBU5IGc5MN3NkjB86NP7S+OitMEiDYLabBIvmY4HKwCSdSWwuKOxK58Q==@vger.kernel.org X-Gm-Message-State: APuU4Z/j+fD9d7a9llCVUuFw0VlGEtNXnSKhe2kCvWlEp2JpMPSC+y/5 HywkCMrViGa+oAhFbTV42bBrTEtQbOXUNtcyOW6JDF0L5uYIZ4PULchb X-Gm-Gg: AZFdTZdDmq2IJJR1sWlXzl9YcqyfOpYRBUHtgqZeoRRGNCEZYIKk4HCH5R2fAC1uawk R4ZO794Um7EClC0GhHojnFaM20XCz+ldJNy9IE2gu/DYTyXe5LPr79k7MdtH9KNOqiI5vEY4CfT bqF+kPnpmKLvVvkGnvGsm0d6UjqESAWQIOkqM4i0iGEgzuth6S+XcJGuysZgyJsael2MsPqgNwi 2eIPBPMeSGg0ERHG7M8YrlbNTToPcK9HC/0P/7G50Yz1GAv9GqBJy/F/DnSKV19DHkliszgdTwA UJaPCDQ+2mYuU74ucEcJ4E7BsHZ+ghwUNtbxg+bXUHoeZQDSu0lcuJYQT9D7fLK3SFPk7IOq4VP k6mnXeVIzUt/mmlDpMF9PB8zZSGb3VLLLLVs94Nt3xN98Ow8UHiC090XD+S7JAq+k3MEQX16Kmg I1S4n3TDS6kJo4z/mJ2z4Xsqc45D2jwgSv6dOzL10fwIDs/XDaLVVw7K6vI4Jic3FgOo38TQX+U u3X81utEI3Uz1gokXRfkd0GHnKq8PlbtlqKjKu2GLNOaUboZQC482Ojjupu3idqT/T7Z+Es6STO CaI02VvUctMH6HD5QUrrDN2gGmdjErw+oO8qceA8amTCS/LaHKAvLEWKkt4WWkGawkuBHz7FPcO 0ZRE4/M6jUw== X-Received: by 2002:a17:906:2a17:b0:c50:f28a:8407 with SMTP id a640c23a62f3a-c513aac6733mr2135981866b.42.1795975680109; Sun, 29 Nov 2026 10:08:00 -0800 (PST) Received: from xeon ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ae8ce16sm1061518266b.37.2026.11.29.10.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 10:07:59 -0800 (PST) From: Svyatoslav Ryhel To: Mauro Carvalho Chehab , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Greg Kroah-Hartman , Svyatoslav Ryhel , Hans Verkuil , Mikko Perttunen Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 12/15] media: tegra-video: Remove remote source subdev helper Date: Sun, 29 Nov 2026 20:07:19 +0200 Message-ID: <20261129180722.142186-13-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261129180722.142186-1-clamor95@gmail.com> References: <20261129180722.142186-1-clamor95@gmail.com> X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Look up the remote source subdevice directly via media_entity_remote_source_pad_unique() in csi_get_pixel_rate(), tegra_csi_enable_stream(), and tegra_csi_disable_stream(), allowing tegra_channel_get_remote_source_subdev() and its subdev hostdata setup in VI to be removed. Signed-off-by: Svyatoslav Ryhel --- .../media/platform/nvidia/tegra-video/csi.c | 31 ++++++++++++++----- .../media/platform/nvidia/tegra-video/vi.c | 30 ------------------ .../media/platform/nvidia/tegra-video/vi.h | 2 -- 3 files changed, 23 insertions(+), 40 deletions(-) diff --git a/drivers/media/platform/nvidia/tegra-video/csi.c b/drivers/media/platform/nvidia/tegra-video/csi.c index add526de536f9..30c547d57c479 100644 --- a/drivers/media/platform/nvidia/tegra-video/csi.c +++ b/drivers/media/platform/nvidia/tegra-video/csi.c @@ -282,12 +282,18 @@ static int csi_init_state(struct v4l2_subdev *sd, static unsigned int csi_get_pixel_rate(struct tegra_csi_channel *csi_chan) { - struct tegra_vi_channel *chan; + struct v4l2_subdev *subdev = &csi_chan->subdev; struct v4l2_subdev *src_subdev; struct v4l2_ctrl *ctrl; + struct media_pad *pad; - chan = v4l2_get_subdev_hostdata(&csi_chan->subdev); - src_subdev = tegra_channel_get_remote_source_subdev(chan); + pad = media_entity_remote_source_pad_unique(&subdev->entity); + if (IS_ERR(pad) || !is_media_entity_v4l2_subdev(pad->entity)) { + dev_err(csi_chan->csi->dev, "failed to get source entity\n"); + return 0; + } + + src_subdev = media_entity_to_v4l2_subdev(pad->entity); ctrl = v4l2_ctrl_find(src_subdev->ctrl_handler, V4L2_CID_PIXEL_RATE); if (ctrl) return v4l2_ctrl_g_ctrl_int64(ctrl); @@ -383,6 +389,8 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) if (csi_chan->mipi) { struct v4l2_subdev *src_subdev; + struct media_pad *pad; + /* * TRM has incorrectly documented to wait for done status from * calibration logic after CSI interface power on. @@ -392,9 +400,12 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) * CSI subdev stream-on triggers start of MIPI pads calibration. * Wait for calibration to finish here after sensor subdev stream-on. */ - src_subdev = tegra_channel_get_remote_source_subdev(chan); - ret = v4l2_subdev_call(src_subdev, video, s_stream, true); + pad = media_entity_remote_source_pad_unique(&subdev->entity); + if (IS_ERR(pad) || !is_media_entity_v4l2_subdev(pad->entity)) + goto disable_csi_stream; + src_subdev = media_entity_to_v4l2_subdev(pad->entity); + ret = v4l2_subdev_call(src_subdev, video, s_stream, true); if (ret < 0 && ret != -ENOIOCTLCMD) goto disable_csi_stream; @@ -425,7 +436,6 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) static int tegra_csi_disable_stream(struct v4l2_subdev *subdev) { - struct tegra_vi_channel *chan = v4l2_get_subdev_hostdata(subdev); struct tegra_csi_channel *csi_chan = to_csi_chan(subdev); struct tegra_csi *csi = csi_chan->csi; int err; @@ -436,11 +446,16 @@ static int tegra_csi_disable_stream(struct v4l2_subdev *subdev) */ if (csi_chan->mipi) { struct v4l2_subdev *src_subdev; + struct media_pad *pad; + + pad = media_entity_remote_source_pad_unique(&subdev->entity); + if (IS_ERR(pad) || !is_media_entity_v4l2_subdev(pad->entity)) + dev_err(csi->dev, "failed to get source entity\n"); - src_subdev = tegra_channel_get_remote_source_subdev(chan); + src_subdev = media_entity_to_v4l2_subdev(pad->entity); err = v4l2_subdev_call(src_subdev, video, s_stream, false); if (err < 0 && err != -ENOIOCTLCMD) - dev_err_probe(csi->dev, err, "source subdev stream off failed\n"); + dev_err(csi->dev, "source subdev stream off failed: %d\n", err); } csi->ops->csi_stop_streaming(csi_chan); diff --git a/drivers/media/platform/nvidia/tegra-video/vi.c b/drivers/media/platform/nvidia/tegra-video/vi.c index f9d50d7571e10..56aa289a288bd 100644 --- a/drivers/media/platform/nvidia/tegra-video/vi.c +++ b/drivers/media/platform/nvidia/tegra-video/vi.c @@ -181,33 +181,6 @@ tegra_channel_get_remote_bridge_subdev(struct tegra_vi_channel *chan) return media_entity_to_v4l2_subdev(pad->entity); } -/* - * Walk up the chain until the initial source (e.g. image sensor) - */ -struct v4l2_subdev * -tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan) -{ - struct media_pad *pad; - struct v4l2_subdev *subdev; - struct media_entity *entity; - - subdev = tegra_channel_get_remote_bridge_subdev(chan); - if (!subdev) - return NULL; - - pad = &subdev->entity.pads[0]; - while (!(pad->flags & MEDIA_PAD_FL_SOURCE)) { - pad = media_pad_remote_pad_first(pad); - if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) - break; - entity = pad->entity; - pad = &entity->pads[0]; - subdev = media_entity_to_v4l2_subdev(entity); - } - - return subdev; -} - static int tegra_channel_enable_stream(struct tegra_vi_channel *chan) { struct v4l2_subdev *subdev; @@ -1285,9 +1258,6 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier) v4l2_set_subdev_hostdata(subdev, chan); - subdev = tegra_channel_get_remote_source_subdev(chan); - v4l2_set_subdev_hostdata(subdev, chan); - ret = v4l2_device_register_subdev_nodes(&vid->v4l2_dev); if (ret) { dev_err(vi->dev, "failed to register subdev nodes\n"); diff --git a/drivers/media/platform/nvidia/tegra-video/vi.h b/drivers/media/platform/nvidia/tegra-video/vi.h index 8788a88b9528f..0e2a32ecef7df 100644 --- a/drivers/media/platform/nvidia/tegra-video/vi.h +++ b/drivers/media/platform/nvidia/tegra-video/vi.h @@ -303,8 +303,6 @@ extern const struct tegra_vi_soc tegra210_vi_soc; struct v4l2_subdev * tegra_channel_get_remote_csi_subdev(struct tegra_vi_channel *chan); -struct v4l2_subdev * -tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan); int tegra_channel_set_stream(struct tegra_vi_channel *chan, bool on); void tegra_channel_release_buffers(struct tegra_vi_channel *chan, enum vb2_buffer_state state); -- 2.53.0