From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BA6F384CCB; Tue, 8 Sep 2026 06:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849220; cv=none; b=FqYnejFKMAjJIF6aGD7XqKwfaR6PZRlHFoayAAZ/K9/MEPpRbu8KpIyRjVAUq3K0xvSJ9ArIgNNkipAGYPnAzQDSR3+6KtxgtGal5kUf/2+3M5UwYX+Sb0bQAaQ7d+enB5lCxV0sPLlBMnQ/wZK+kxcRN1grxjp+MWVoiHSo7XM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849220; c=relaxed/simple; bh=eeZHAc6JvYv71v6f9F61tJrGXk9OvWAasb1iINuuATg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WxezSQnOAkR1wOh+Kyyno0q8ytEFfRuRZ0PDiEtyz0q82gi845SP53brIOEkG1vjvSPnfUIDQOJ+x6qCAuE+2lLN4nz/pWVIalQkYVoayDiiL/TqnxPC9GstxnlgQPhPijQtIWwOZrEcket0Vli7VeyDTzyU7JHz+ge5iDYf+Os= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=D1iDm4R/; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="D1iDm4R/" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 77A9CC31; Tue, 8 Sep 2026 08:32:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849121; bh=eeZHAc6JvYv71v6f9F61tJrGXk9OvWAasb1iINuuATg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=D1iDm4R/z3mQn90WLS9Csz5wWaRdzWxbgljBqCXeLfLOflBIlH02bvzkJeeHXLmUq lmsgniy3CwjrqifUOV+HNEhokQ3YcgAncYegTGYatm1nlK1YZC7F6kIGvHcM/0zdCa vo0lORFZBZfGfamYP32mzKDwa95d6g1dsYW4a3aA= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:05 +0300 Subject: [PATCH v7 01/11] media: rcar-vin: Fix comment related to stride handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-1-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1175; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=eeZHAc6JvYv71v6f9F61tJrGXk9OvWAasb1iINuuATg=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w69l0E5AR4XBP9QXXWjtUnMmYCnnyJxk0ob tbYbHGV0HiJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sOgAKCRD6PaqMvJYe 9eNsD/9bY+yVDv/3JTEl5NEEkZ8VUimJL14yAcmdMsAjwRy74I28atQD/ZMKF2Kr60g9q+ljGDV lKWkzR5vv2zCcGeavR5cGLBikavR8UrxbCycoxJzKly4KzZ7SDGTvFd1dHSMmBH+GZQa27cFWcf kIesVWsgy2Lwiw66v1UU8USCwniG3j6kK089J4vcOwCc1vUdR07yZSlWRdk9UH+7OGsbEkm4Z9a wAX3JSk/dE4CS0qg2jbxETnEu7V5qzPHRXQXsJuqwuNAVc6IyVsJ1O1uXqhcSp+I7RxlnNcBMgE WGTIZMJtBQGNTTLda9IsJYq9lSGCFjUZwzsJQJ4CWjn4y07PJR1FlHivDu3Z2ZMb+eCMOPy1pJY GH6JyIAIcF5ZsgTSeb1DpNvBXr4eSwcljFxaZzPizu3ZnRn2VKcKMrnIXv3aYNFIy02G9AZ92aN 6EKbVfnVyc/24iH8gwl3FgWPVAS0slc01Cb37PVWNPNxj2sVenT6vzNKUwSiAHP2ZymfxqnaJV8 N+P/aKQxc5/csjpS5F1CsKssVoS7fZM7ps+o2RjvYZJHwlDbVPs4WJXsPJsjzW9azT6LOXaLEV2 f/XPbNAzqpPZFq4QNPjrQvaZ9hbfZ+tg9HVgc/t/AGykn+0B8y4ifpTdLb1MZYcD7lnh7kQZdEV qF6fX7V7Pw2307A== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 The comment says the stride has to be aligned to 16 bytes, but it should be 16 pixels, as VNIS_REG register is in pixels. Fixes: 40c6da8a9c0f ("media: renesas: vin: Fix RAW8 (again)") Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/m= edia/platform/renesas/rcar-vin/rcar-dma.c index 73cda0e2d45a..5e515d16c164 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c @@ -678,7 +678,7 @@ void rvin_crop_scale_comp(struct rvin_dev *vin) =20 /* * VNIS_REG has four lowest bits always 0, i.e. the stride has to be - * aligned to 16 bytes. This is done in rvin_format_bytesperline(). + * aligned to 16 pixels. This is done in rvin_format_bytesperline(). */ =20 fmt =3D rvin_format_from_pixel(vin, vin->format.pixelformat); --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 077CA38F633; Tue, 8 Sep 2026 06:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849224; cv=none; b=L0wvD1KoTAhKiz5b5gEy5c4fid4XEt/cDQQ5TywgqH6vjE6VtbNcvRdB2aTwoKzPexwuxsaZRcFOn7jA0IArztsEpSF7LecwXeE/NIlc5eiy1p/3yQJuNuPi+ZxxgsMAMaU1swEO5Nww5HGnN830jFQ/fYotz7BcwfVS82aMcX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849224; c=relaxed/simple; bh=MrTOmImD9QpMyNyc0iatSCfJ+NyYKitfcbouRCqbLC8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QMMGBArpn17PVWs8nCqHxOelmTllLTNGwG6oyq2NKjHug7mnEGe4RN/PhBW7dDRi7JbSCOzKMN+eoPB8tRfbjQMvpcRTtfIQp2rkQ6Bfu3u4Fg9VZyDQxtS0fDEHbdodBV/LbWUfM2zsJDtRFfyTaZY5xlTq9zGGxZmtw528ibo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=kUo0lltS; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kUo0lltS" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 38B6BC48; Tue, 8 Sep 2026 08:32:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849121; bh=MrTOmImD9QpMyNyc0iatSCfJ+NyYKitfcbouRCqbLC8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kUo0lltSCf8kuZwENYOKmYYc+F2kYGue976R6E2D0QzKyhEA0HDo8Jg/6Y+Ip2DtE t5yqavOKKBv+LPe4GvQazWB+c5SnrWqWyfV5u0M6wUVpBCoSXUXZ7Wmc5sISWf4fiI OqYeLW/nCa7Y+JpLna+DemjfxACCvy6aqfYGWEBE= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:06 +0300 Subject: [PATCH v7 02/11] media: rcar-vin: Link VINs on Gen3 to a single channel on each CSI-2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-2-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2578; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=MrTOmImD9QpMyNyc0iatSCfJ+NyYKitfcbouRCqbLC8=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w6dOkGXnzo3s/gcHEvzb32E/bogNGhq8O9t ft8wQL1CTCJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sOgAKCRD6PaqMvJYe 9fipD/4jQpKefaj/v0DfH/tWm1Pj5IRwUoTu+FAFYFuslgJSJufzdiV3qNrjOtgbGU7bOIk2/Rk VfE9vPqBpS0ii7b9bISqy3VVloXt7hB0JBEy7CSFWs+n09zQgsS4bSZa1wgB6M042dLr2VDvckx iTRGwsHvy8tUKHL4fU9K6VQ4TspNyeraBKKxR3B7gZbp/ZEW5SBmHOIGwBOOm9jkG65g7HGw4OW 63XHrZlHo4Z38ctSCgOOVJ2zISkL25nhxCc3SwCcIu3YFyQ/j2+Osx7wP4jEF/k2Z5TYaIzjkK/ iP0PQvV6CILm+MldoFalvXDUA/jcpJVuyT2qpTgY2HMqgO438BDR/1LjjtmKSejcVq3wH1l3JDU wU7n1uB3Z4ufjmFkIUps/PQkW1vX6pqV3mv47JPF3vDxbL1zrUKufoZrnpC/hdyE8bgm1PnYsGN JS690iOY/yDkCdtDTQQyuH2/aP/WLeEFcBPVuJlhVEW2cq1oidx7SpOyokL7wyY7le3JMKSwYdR fKN9rn46cCD67c48NfPT5PK6MM87Ogw4+dOnASHfYX3j0rPB2C1jFhiZ5nZAOLVLQM77T0TpnYP e5Pzngy3FMsiB/R6uRZoCjItB7rAMG0rPCNlkK3gbw2Bo256E4oVKWXaq7/4PlAZuB9nXrfHfem 2/1isxZJQBwctzg== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 The stream routing will be fully configurable when we add full streams support to the rcar pipeline. Thus there is no need for the user to be able to link VINs to different CSI-2 channels. In fact, allowing e.g. VIN0 to be connected to CSI-2 channel 3 would be wrong, as the hardware doesn't allow that. Change rvin_csi2_create_link() so that it creates media links only between matching VINs and CSI-2 channels (VIN0 - channel 0, VIN1 - channel 1, etc.). Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- .../media/platform/renesas/rcar-vin/rcar-core.c | 27 ++++++++++++------= ---- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/= media/platform/renesas/rcar-vin/rcar-core.c index c8d564aa1eba..2fcea715101c 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c @@ -673,23 +673,26 @@ static int rvin_csi2_create_link(struct rvin_group *g= roup, unsigned int id, struct media_entity *source =3D &group->remotes[route->csi].subdev->entit= y; struct media_entity *sink =3D &group->vin[id]->vdev.entity; struct media_pad *sink_pad =3D &sink->pads[0]; + struct media_pad *source_pad; + unsigned int source_idx; unsigned int channel; - int ret; =20 - for (channel =3D 0; channel < 4; channel++) { - unsigned int source_idx =3D rvin_group_csi_channel_to_pad(channel); - struct media_pad *source_pad =3D &source->pads[source_idx]; + /* + * The channels from CSI-2 blocks and the VIN groups have a set of + * hardcoded routing options to choose from. We only support the routing + * where all VINs in a group are connected to the same CSI-2 block, + * and the Nth VIN in the group is connected to the Nth CSI-2 channel. + */ =20 - /* Skip if link already exists. */ - if (media_entity_find_link(source_pad, sink_pad)) - continue; + channel =3D id % 4; + source_idx =3D rvin_group_csi_channel_to_pad(channel); + source_pad =3D &source->pads[source_idx]; =20 - ret =3D media_create_pad_link(source, source_idx, sink, 0, 0); - if (ret) - return ret; - } + /* Skip if link already exists. */ + if (media_entity_find_link(source_pad, sink_pad)) + return 0; =20 - return 0; + return media_create_pad_link(source, source_idx, sink, 0, 0); } =20 static int rvin_parallel_setup_links(struct rvin_group *group) --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0784738F64E; Tue, 8 Sep 2026 06:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849224; cv=none; b=A1JkqrB/7Fl0AwB7OnUPrNqdatzY51RVk2njGL7W4dHvpuRN8EOIEJ+QqfM1mF1OEYRy8tYppMFWgciWMyD3pO+Fo1h2MyladkCUQ++Uo8Wr20aCHIFrc8xaVAAk7oxyuGmzSjVptu+q3EeZkcapLVqSTRV/mdaKoIvlDp1kA8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849224; c=relaxed/simple; bh=/jVIAB1ZwOuEE2lnzrIH/2EVQW4YzOQKZhvoy1j+qpA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u9COE9xD3lZPIkoHZQOYM01kCb6Kg9BbYkitixYUYxlCewqvHjSsoInn0A+7kLL0vhAL3FPCQ5RFFfH5ZUbORvFx7u+SxVIlcy08ZS0fuHR9cmj4MHV1jOT6OjUraNlfaCUB7gFMv7Mbex7UCsrrXKbJfBgEt5COW6MSbilWc7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=D9QXHmWu; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="D9QXHmWu" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 02524EAA; Tue, 8 Sep 2026 08:32:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849122; bh=/jVIAB1ZwOuEE2lnzrIH/2EVQW4YzOQKZhvoy1j+qpA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=D9QXHmWurTJmhd3RFO2kHte2ikMWdMl9Av/SoNXs4PlL3RLZqmOZTzMImEsC7lgRF oFv+r0w9QEigxS4v0v29byZXPaQay1bIdIqk030G/mQsQ26sf+Oq8p+zEi4jMJJvig 9433fJLi9pvuBMwyT0dxnGX1B1JjCpEnJO8hC+Ec= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:07 +0300 Subject: [PATCH v7 03/11] media: rcar-isp: Move {enable|disable}_streams() calls Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-3-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen , Laurent Pinchart X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3099; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=/jVIAB1ZwOuEE2lnzrIH/2EVQW4YzOQKZhvoy1j+qpA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w7A037vP5BiKWa6iFylmWxNMszEHLdiYYiv yAB6WPPJrKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sOwAKCRD6PaqMvJYe 9WCsD/9GDj+v6yLJfhZ67VwUsqWo9vfLAcP63ipCpd7gCPFOXEPwQGWNsSUh3WGUTYv5phOhAR8 aCO9UEqkW4AbbudrJWwO7COcemi9Ka8VvDVw+QyuTA3rq8jJuRy88l04aTMjJSh9VR1IDS17unm 6n4T8aZZArgB7PAE7ROlb9eEwoUcceOxDhi80PD8KgjSil1mzjXY8MpedIS7SQJR+QEE9EYq78g EpiGPInxuLNX0ImMYP+zwzzEUveA9nKiTXfHqjlTWRVKuY/rGvRK3y5ACqAJwqIEhGY8WVjjswU N4gPDSD0aA2dZ2MxQ8FMoBkIRoX7mPThoorRXHU4FNplFZV2gEVWfRbpmXpwwSjfEaBJpwxUKPx yutA7u3U+dgLIROcesPRiACr/l/pxXrNyRrz/MUK1SnygtEC+ThEr7btd0HVZbKVsHlyzrg+ILB 2u920yDyBTi0nSvlmZ045pHvaQ3Mu4RgrCySJiMDY3gxAUv+2H2CPXub8eOaVDMuGAf8mHz2yAM ougLwrq8xPBErD5sh2qSCN+LY7EFtc7YtV68DMFPY0wTIEVaiSFEFob4Ieuavse0ERGu4mjiNRV u/kgxwLfxdmM3GkJmzqIJfwrSN0syQON5GKrA7BexOGvY0uRZcOmBzN9fA1l3ibYEF6LjrVyo7F vuwaU8s6v/qS0Ug== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 With multiple streams the operation to enable the ISP hardware and to call {enable|disable}_streams() on upstream subdev will need to be handled separately. Prepare for that by moving {enable|disable}_streams() calls out from risp_start() and risp_stop(). On Gen4, a side effect of this change is that if the sink side devices call .enable_streams() on rcar-isp multiple times, the second call will fail. This is because we always use stream ID 0, so the second call would attempt to enable the same stream again, leading to an error. In other words, a normal single-stream setup continues to work, but trying to use the current driver's custom VC based routing will fail. Reviewed-by: Laurent Pinchart Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp/csisp.c | 27 ++++++++++++++++-----= ---- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp/csisp.c b/drivers/medi= a/platform/renesas/rcar-isp/csisp.c index 53ce47020d17..97ddae942fe3 100644 --- a/drivers/media/platform/renesas/rcar-isp/csisp.c +++ b/drivers/media/platform/renesas/rcar-isp/csisp.c @@ -268,18 +268,11 @@ static int risp_start(struct rcar_isp *isp, struct v4= l2_subdev_state *state) /* Start ISP. */ risp_write_cs(isp, ISPSTART_REG, ISPSTART_START); =20 - ret =3D v4l2_subdev_enable_streams(isp->remote, isp->remote_pad, - BIT_ULL(0)); - if (ret) - risp_power_off(isp); - - return ret; + return 0; } =20 static void risp_stop(struct rcar_isp *isp) { - v4l2_subdev_disable_streams(isp->remote, isp->remote_pad, BIT_ULL(0)); - /* Stop ISP. */ risp_write_cs(isp, ISPSTART_REG, ISPSTART_STOP); =20 @@ -291,7 +284,7 @@ static int risp_enable_streams(struct v4l2_subdev *sd, u64 source_streams_mask) { struct rcar_isp *isp =3D sd_to_isp(sd); - int ret =3D 0; + int ret; =20 if (source_streams_mask !=3D 1) return -EINVAL; @@ -305,9 +298,17 @@ static int risp_enable_streams(struct v4l2_subdev *sd, return ret; } =20 + ret =3D v4l2_subdev_enable_streams(isp->remote, isp->remote_pad, + BIT_ULL(0)); + if (ret) { + if (isp->stream_count =3D=3D 0) + risp_stop(isp); + return ret; + } + isp->stream_count +=3D 1; =20 - return ret; + return 0; } =20 static int risp_disable_streams(struct v4l2_subdev *sd, @@ -315,6 +316,7 @@ static int risp_disable_streams(struct v4l2_subdev *sd, u64 source_streams_mask) { struct rcar_isp *isp =3D sd_to_isp(sd); + int ret; =20 if (source_streams_mask !=3D 1) return -EINVAL; @@ -322,6 +324,11 @@ static int risp_disable_streams(struct v4l2_subdev *sd, if (!isp->remote) return -ENODEV; =20 + ret =3D v4l2_subdev_disable_streams(isp->remote, isp->remote_pad, + BIT_ULL(0)); + if (ret) + return ret; + if (isp->stream_count =3D=3D 1) risp_stop(isp); =20 --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 048203921FB; Tue, 8 Sep 2026 06:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849227; cv=none; b=hDo4V+lIwCO8ws2g2ZbkDmSinJ2HaqOsepsytPDVgpa8l2VPKSccrUwKAhzJBGIZl+t7ZiBSmGJaNKB449ehO4tTcOIDfMxrZ2d3UUW6V9x7OCZsjJBItnYI0X+D7Ze40q/QWWQm9qnfylhQKhCVUlsJyzwMRb6HZt/0b7QASOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849227; c=relaxed/simple; bh=MjnzrwZKyNWzzunkm36LWNQmaY4qmqELqShZvoRddVw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rhu4Jbye3COo0o+F0mMUvLi/ZjwhvEJt2QeF91ZT/jj0TTwoCDoqjR6NvfAFLx2aV1fmifsRdiR3/QRjltedDLXe1s2yC8Dx5S9q13cKAt3VtEhK6pXXTQak3jCJlrizKIoXT88ZFPCFOOeXQs/VQHpHVKdNFcT7kPUNTxKmI0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=JGpmbJ1v; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JGpmbJ1v" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C964312B2; Tue, 8 Sep 2026 08:32:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849123; bh=MjnzrwZKyNWzzunkm36LWNQmaY4qmqELqShZvoRddVw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JGpmbJ1v7Na6c0wBnxQZpKPyRS83HmtQwEVNkk0Xfng21WlRuB62D4Pveo3CW1vu8 wV2q7Vsqubp142MxqVNfBJRzhWsXovyQ/F7/v0W2ovdrp5spYRqtNf3edpgntvpUBw SpB4IoTr/jLgZy6pnQkqSgwcLoEBFM6FSD2SVWls= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:08 +0300 Subject: [PATCH v7 04/11] media: rcar-csi2: Move {enable|disable}_streams() calls Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-4-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4232; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=MjnzrwZKyNWzzunkm36LWNQmaY4qmqELqShZvoRddVw=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w7AkxfJqlCfC1h2QrVPH/tROW09e6NWTsV5 pGWstBdWJKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sOwAKCRD6PaqMvJYe 9QbzEAChCkQCk7/HXs87xPcDO2NieFRonqUO7keZXTuudFyodvU8WTpS6FRywVA/kV8Vp6Jxy8X 5PM0OL/YLHzpW5Nms2u1t9q7PoR686H37Kom2pu7ik8MNIuFQC3SvyPlpFHWfjhF9yUnAN8vmd7 EdYrNXCWxS1yJ+zp8a4djWMj7n5qFmOR3eg/KhAEdzJ/Q09uJ0DXvGXMGAssyPSt8xqM3SnRNNJ Oy1NBzOyokV1Hn7c8lVUet7HluXRdxxwKfoWxOk57883la4yDCL48FXwKufPDLY4SiwzpHcrp+l IzXO+DuQI68AZosON/ZBURrmHpcFIlVWJCbdq9nMfQkOYpQS/kj0Sn2xHnOMiFu2/NDC0AyMUiR YGDdjiMOOaC3R2pKvmiT/0hSzF+EnWwj8MEmoLV6GieGzOIJNnN8eASzC+GHeyDqmfURnJBcory gyc9I1dFFXjG0I1UdWiaizU1ZLT4QMg6UXJx55E3h7LCJXgfuok2FiKLOn4QC1Kd65ItzQDsUE0 Eqo5bfxym4rNs6cdfeIP/k1wI/d5WRCkzQUYdWP4NizjggGNtJ8sXvJi46OHBJSWbE7/8kJqSzv 8cPmOWzu4SGrP6LOOUgg85Svgg0wTU2uTfZu+bq21qB2wc3vcZuYGNnKQWw/o+moQM2E8al3Lqg N4T9DX5kGCwI0wA== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 With multiple streams the operation to enable the CSI-2 hardware and to call {enable|disable}_streams() on upstream subdev will need to be handled separately. Prepare for that by moving {enable|disable}_streams() calls out from rcsi2_start() and rcsi2_stop(). As the error recovery in rcsi2_irq_thread() relies on rcsi2_start() and rcsi2_stop(), we need to modify rcsi2_irq_thread() accordingly. On Gen3, a side effect of this change is that if the sink side devices call .enable_streams() on rcar-csi2 multiple times, the second call will fail. This is because we always use stream ID 0, so the second call would attempt to enable the same stream again, leading to an error. In other words, a normal single-stream setup continues to work, but trying to use the current driver's custom VC based routing will fail. On Gen4, this doesn't matter as the rcar-isp behaves in a similar way as described above, and thus rcar-csi2 will only get a single .enable_streams() call. Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 59 ++++++++++++++++++++++++--= ---- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/pla= tform/renesas/rcar-csi2.c index 6635f5782175..1c8150af734f 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1822,20 +1822,12 @@ static int rcsi2_start(struct rcar_csi2 *priv, stru= ct v4l2_subdev_state *state) return ret; } =20 - ret =3D v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, - BIT_ULL(0)); - if (ret) { - rcsi2_enter_standby(priv); - return ret; - } - return 0; } =20 static void rcsi2_stop(struct rcar_csi2 *priv) { rcsi2_enter_standby(priv); - v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, BIT_ULL(0)); } =20 static int rcsi2_enable_streams(struct v4l2_subdev *sd, @@ -1857,6 +1849,14 @@ static int rcsi2_enable_streams(struct v4l2_subdev *= sd, return ret; } =20 + ret =3D v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, + BIT_ULL(0)); + if (ret) { + if (priv->stream_count =3D=3D 0) + rcsi2_stop(priv); + return ret; + } + priv->stream_count +=3D 1; =20 return ret; @@ -1867,7 +1867,7 @@ static int rcsi2_disable_streams(struct v4l2_subdev *= sd, u32 source_pad, u64 source_streams_mask) { struct rcar_csi2 *priv =3D sd_to_csi2(sd); - int ret =3D 0; + int ret; =20 if (source_streams_mask !=3D 1) return -EINVAL; @@ -1878,9 +1878,14 @@ static int rcsi2_disable_streams(struct v4l2_subdev = *sd, if (priv->stream_count =3D=3D 1) rcsi2_stop(priv); =20 + ret =3D v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, + BIT_ULL(0)); + if (ret) + return ret; + priv->stream_count -=3D 1; =20 - return ret; + return 0; } =20 static int rcsi2_set_pad_format(struct v4l2_subdev *sd, @@ -1971,14 +1976,44 @@ static irqreturn_t rcsi2_irq_thread(int irq, void *= data) { struct v4l2_subdev_state *state; struct rcar_csi2 *priv =3D data; + int ret; =20 state =3D v4l2_subdev_lock_and_get_active_state(&priv->subdev); =20 + if (priv->stream_count =3D=3D 0) + goto out; + rcsi2_stop(priv); + + ret =3D v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, + BIT_ULL(0)); + if (ret) { + dev_warn(priv->dev, + "Error recovery: failed to disable streams: %d\n", + ret); + goto out; + } + usleep_range(1000, 2000); - if (rcsi2_start(priv, state)) - dev_warn(priv->dev, "Failed to restart CSI-2 receiver\n"); =20 + ret =3D rcsi2_start(priv, state); + if (ret) { + dev_warn(priv->dev, + "Error recovery: failed to start CSI-2 receiver: %d\n", + ret); + goto out; + } + + ret =3D v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, + BIT_ULL(0)); + if (ret) { + dev_warn(priv->dev, + "Error recovery: failed to start streams: %d\n", + ret); + goto out; + } + +out: v4l2_subdev_unlock_state(state); =20 return IRQ_HANDLED; --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04790389455; Tue, 8 Sep 2026 06:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849227; cv=none; b=cE6qzFou441rZZp+nbBfzceD3R+SuffvrzYW4zIq7mEYVkBYQwhr7t5U0N9v1DLSEKaSQXNQf7xFpSoSuU3ThPlwvHBIE7YTlPe8kR0LKhfFgtSytbmVERijGjNXHJdh3BC3HJZNM1yXHZwVK9vzl/SHrECTY0pXjatrjp5JSBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849227; c=relaxed/simple; bh=lCcpNN23SQc2nkY2REOpt9Da3TrhiHkLugZUEy71N54=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C1IrJZ7nBt8of7Y+DAqL2CrHSEuHfs4Jzhly+RjieGmqeiFg8GE4ZvhJLSyROzg5nQG9T3GAe3No7ykyqU4loVV4iMU/sFeOW3iNS8QGAnuzz6OvlR2gVC/oB3JH4sSuhUN47BJ/hMiAjuIADKpe/4YHO6x0HRWaMilc6tfTe9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=cIim/W8K; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cIim/W8K" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 927F2130E; Tue, 8 Sep 2026 08:32:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849124; bh=lCcpNN23SQc2nkY2REOpt9Da3TrhiHkLugZUEy71N54=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cIim/W8KO6H1aasc6211v24zZLdIkn97/HpLe6IqswcJ9mrKi524igTJc99GxqyCY VeLqXOLvNxbY26up4DBq7h2Im57mbIjSSbce48RYSsg0Far52BQBFVoblieiBwhDLg hNlWZcsEbJfaH7ZkDDGighgkWyfJFRQUS1mEM6g4= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:09 +0300 Subject: [PATCH v7 05/11] media: rcar-csi2: Switch to Streams API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-5-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5330; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=lCcpNN23SQc2nkY2REOpt9Da3TrhiHkLugZUEy71N54=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w7kQGFMNS3oPS9ioxU6eBN8KW4TvulF5bnA Ylnk9iJFC2JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sOwAKCRD6PaqMvJYe 9fSQEACc9+gSIhd8nmUXnnnrF0hgEFFx+2w2IcdlB+Z61RMZ/8cJWh4J198zw7DCnqLgtdu+sD/ cFCPgsznLQc53y0lvSrXzlDl+Yeev3t2qf3Rrxb9SjA6hXFM6tY4ejpLSPKeI5jeRHVGtafaoNE XM05EKP+lu3sx/2aGdfoDcq0fEw3+qgn5pcMb1ripO6vGt56EULGyR7hba6LAL+VfG9qqSoECVW vUtq0X8tRAQk+Fe2+eZr2OM8lrF/gtlPUkBXJUGnMh5nytfNEJEBoOltYZaRsZjbwHN+BelNqBl QXdLnOdZHPNozW1wAf2SlYErCpzeg65TkQDwJO2sKJF2Srj4DeLvh/y5XMC6dfDvzn9DpF0KHyC G2S93JtN4x5kpkVM46tpZljS7s43p06UGgL4w3rjdjWib4TKwvLuAWNKY6VODliNJf6Q09sqpmN V6D7Y9Fmb5q3P2DO4SANtCHvMbW3ZmtX38o9EN2dyCbvGV2A2BeaSzogb3wnLIym3bRRpuT7p4K H0vbaPMMyX3Anf//JUV8y9aMu4aVRt4cbgMy3Ec3hcNUVuwh8m83vGy/HR9W8C0D65Bh2p7YzAQ VJdgm4Sh+Q3fmS+C1QVIELsFVNgtazuD6QqX6XVpGpbnjjwJJlr1wdwGELS35AkNmG18heXfyGC g+utK30C4hiLvFg== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Switch to Streams API with a single hardcoded route. For single-stream use case there should be no change in behavior. Reviewed-by: Laurent Pinchart Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 64 +++++++++++++++++++++++---= ---- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/pla= tform/renesas/rcar-csi2.c index 1c8150af734f..c064979003ed 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1023,17 +1023,24 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, */ freq =3D v4l2_get_link_freq(remote_pad, 0, 0); if (freq < 0) { + const struct v4l2_subdev_route *route; const struct rcar_csi2_format *format; const struct v4l2_mbus_framefmt *fmt; unsigned int lanes; unsigned int bpp; int ret; =20 + if (state->routing.num_routes !=3D 1) + return -EINVAL; + ret =3D rcsi2_get_active_lanes(priv, &lanes); if (ret) return ret; =20 - fmt =3D v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK); + route =3D &state->routing.routes[0]; + + fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); if (!fmt) return -EINVAL; =20 @@ -1062,6 +1069,7 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, static int rcsi2_start_receiver_gen3(struct rcar_csi2 *priv, struct v4l2_subdev_state *state) { + const struct v4l2_subdev_route *route; const struct rcar_csi2_format *format; u32 phycnt, vcdt =3D 0, vcdt2 =3D 0, fld =3D 0; const struct v4l2_mbus_framefmt *fmt; @@ -1070,7 +1078,16 @@ static int rcsi2_start_receiver_gen3(struct rcar_csi= 2 *priv, int mbps, ret; =20 /* Use the format on the sink pad to compute the receiver config. */ - fmt =3D v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK); + + if (state->routing.num_routes !=3D 1) + return -EINVAL; + + route =3D &state->routing.routes[0]; + + fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); + if (!fmt) + return -EINVAL; =20 dev_dbg(priv->dev, "Input size (%ux%u%c)\n", fmt->width, fmt->height, @@ -1892,8 +1909,7 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *s= d, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct rcar_csi2 *priv =3D sd_to_csi2(sd); - unsigned int num_pads =3D rcsi2_num_pads(priv); + struct v4l2_mbus_framefmt *fmt; =20 if (format->pad > RCAR_CSI2_SINK) return v4l2_subdev_get_fmt(sd, state, format); @@ -1901,11 +1917,20 @@ static int rcsi2_set_pad_format(struct v4l2_subdev = *sd, if (!rcsi2_code_to_fmt(format->format.code)) format->format.code =3D rcar_csi2_formats[0].code; =20 - *v4l2_subdev_state_get_format(state, format->pad) =3D format->format; + /* Set sink format. */ + fmt =3D v4l2_subdev_state_get_format(state, format->pad, format->stream); + if (!fmt) + return -EINVAL; + + *fmt =3D format->format; + + /* Propagate the format to the source pad. */ + fmt =3D v4l2_subdev_state_get_opposite_stream_format(state, format->pad, + format->stream); + if (!fmt) + return -EINVAL; =20 - /* Propagate the format to the source pads. */ - for (unsigned int i =3D RCAR_CSI2_SOURCE_VC0; i < num_pads; i++) - *v4l2_subdev_state_get_format(state, i) =3D format->format; + *fmt =3D format->format; =20 return 0; } @@ -1925,8 +1950,15 @@ static const struct v4l2_subdev_ops rcar_csi2_subdev= _ops =3D { static int rcsi2_init_state(struct v4l2_subdev *sd, struct v4l2_subdev_state *state) { - struct rcar_csi2 *priv =3D sd_to_csi2(sd); - unsigned int num_pads =3D rcsi2_num_pads(priv); + static struct v4l2_subdev_route routes[] =3D { + { + .sink_pad =3D RCAR_CSI2_SINK, + .sink_stream =3D 0, + .source_pad =3D RCAR_CSI2_SOURCE_VC0, + .source_stream =3D 0, + .flags =3D V4L2_SUBDEV_ROUTE_FL_ACTIVE, + }, + }; =20 static const struct v4l2_mbus_framefmt rcar_csi2_default_fmt =3D { .width =3D 1920, @@ -1939,10 +1971,13 @@ static int rcsi2_init_state(struct v4l2_subdev *sd, .xfer_func =3D V4L2_XFER_FUNC_DEFAULT, }; =20 - for (unsigned int i =3D RCAR_CSI2_SINK; i < num_pads; i++) - *v4l2_subdev_state_get_format(state, i) =3D rcar_csi2_default_fmt; + static const struct v4l2_subdev_krouting routing =3D { + .num_routes =3D ARRAY_SIZE(routes), + .routes =3D routes, + }; =20 - return 0; + return v4l2_subdev_set_routing_with_fmt(sd, state, &routing, + &rcar_csi2_default_fmt); } =20 static const struct v4l2_subdev_internal_ops rcar_csi2_internal_ops =3D { @@ -2625,7 +2660,8 @@ static int rcsi2_probe(struct platform_device *pdev) v4l2_set_subdevdata(&priv->subdev, &pdev->dev); snprintf(priv->subdev.name, sizeof(priv->subdev.name), "%s %s", KBUILD_MODNAME, dev_name(&pdev->dev)); - priv->subdev.flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE; + priv->subdev.flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_STREAMS; =20 priv->subdev.entity.function =3D MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER; priv->subdev.entity.ops =3D &rcar_csi2_entity_ops; --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42A36397935; Tue, 8 Sep 2026 06:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849231; cv=none; b=Foz048DbGcghW0C0Ed1PGllchJoX8sFfuiicLuOD3DWuRFrSLHa9RxJo3hcQAD1HVrH2Fg57BePJXAqn5i2404z/iLdlU2JGnSyFffs1OkYGFDZprM0Xkxok8eiIgTiOpUs9KPW+mnYKIblNZX9TR9sdNIhWobS7ftyeZvn5Bxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849231; c=relaxed/simple; bh=oExGHzPQkKVLZkggt/7Y71gxxJvvo3vKzwtYOseLfik=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FbeAPXX7bwm1x9Vk/wHNIS2jVln/EnmnKzfp9VmBtHDAuefzl5nvXN/0YtVnnpF2n7r7y33zAjlgMKtT4bmXdJkX0BKOD8G9sUIvqgpYMRhoq2sv7thatMcTRyOrNpKw9L4EoyG+RBR/jGUHBKINkCMJBRr8nAndiMiQDUBVmDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=OHYwqqjX; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OHYwqqjX" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5CEDF1583; Tue, 8 Sep 2026 08:32:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849125; bh=oExGHzPQkKVLZkggt/7Y71gxxJvvo3vKzwtYOseLfik=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OHYwqqjXdFp9bhmX4B0Em39xclXv1x1nyR0/KyOVQShRw5c+4SxqnbsINAXO+8nbm M8PlsJ4W+ZFVorb/wXidByGPxvXg7yrGVyFT4usmjgrhjABPSRHm2A//Zg22lh7XiW oQ7rNXt9SxvCFwBV0hdli4tY8gja7pBloszOy5zI= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:10 +0300 Subject: [PATCH v7 06/11] media: rcar-isp: Switch to Streams API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-6-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen , Laurent Pinchart X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4630; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=oExGHzPQkKVLZkggt/7Y71gxxJvvo3vKzwtYOseLfik=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w8SN3Lw1RONhVAybTXYHTScuM0N1Ac+efTt 6bRq8cMVsmJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sPAAKCRD6PaqMvJYe 9TyUEACm2A20okFBNgCnHvYB8J9be0kzesoK+t+dVKVXyCIJtS7XczrZ3EUMlVkqK463e3XXmjX I7ck/kg4XVPx6kxTf7RsTAMZAir1QR8/GcXidThaedLSfZ7IJMMrxV2EqkTfG/A6W8Vf0sXw4+Q L5ePuKw8SUJaWkCVQ+cnUXRuXexBFE4zSBbSUblQCCx8cgmFwxLHeT+//TEiMzHpTwAxHeHDvzB GtO84z7xuVCydTYzpTTm45LiXi51KeIpPuobJmLfRQx+Di/HP0gQLgw+9ZkAEfGIXES6fv6YbNk BaORswR/7D8RIDtYAJbvmalg3zG3LumRSsBKZMxql1kGRtUcl+tE8YCGqkrHoeSIsgSJHWbLo2C CH2/vZRpfYOgPrhLnAbynr+UGjAiFpKuKy2ZtLRAwTFG9dTNjxzJM8JqgYCEPGR1hdF2cJNjy/h rAtSC7ujjBUbbLVV7RhJfIxJVCTG5I2172dR8h6k3Y8BvuN8Dnp5RMeZX4S2uoAaAhIsifZtBi9 TbFQ1fYt3aeDwfy/oame05jOnJT1RqmD7yBpCHDO2S4RmimfSWWCNqfwFR+JrjdY693b5eizG/j 0qhH+EOx88WaWlygFn4d1FFpo3f26JGi3KCjqE0BISzQrNU5sD16+qlgsw6w52iKCI/ek9eFtaV Z+UC0gLFs7JQIOw== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Switch to Streams API with a single hardcoded route. For single-stream use case there should be no change in behavior. Reviewed-by: Laurent Pinchart Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp/csisp.c | 69 +++++++++++++++++++++= +--- 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp/csisp.c b/drivers/medi= a/platform/renesas/rcar-isp/csisp.c index 97ddae942fe3..97465467d047 100644 --- a/drivers/media/platform/renesas/rcar-isp/csisp.c +++ b/drivers/media/platform/renesas/rcar-isp/csisp.c @@ -123,6 +123,17 @@ static const struct rcar_isp_format rcar_isp_formats[]= =3D { }, }; =20 +static const struct v4l2_mbus_framefmt risp_default_fmt =3D { + .width =3D 1920, + .height =3D 1080, + .code =3D MEDIA_BUS_FMT_RGB888_1X24, + .colorspace =3D V4L2_COLORSPACE_SRGB, + .field =3D V4L2_FIELD_NONE, + .ycbcr_enc =3D V4L2_YCBCR_ENC_DEFAULT, + .quantization =3D V4L2_QUANTIZATION_DEFAULT, + .xfer_func =3D V4L2_XFER_FUNC_DEFAULT, +}; + static const struct rcar_isp_format *risp_code_to_fmt(unsigned int code) { unsigned int i; @@ -216,13 +227,20 @@ static void risp_power_off(struct rcar_isp *isp) =20 static int risp_start(struct rcar_isp *isp, struct v4l2_subdev_state *stat= e) { + const struct v4l2_subdev_route *route; const struct v4l2_mbus_framefmt *fmt; const struct rcar_isp_format *format; unsigned int vc; u32 sel_csi =3D 0; int ret; =20 - fmt =3D v4l2_subdev_state_get_format(state, RCAR_ISP_SINK); + if (state->routing.num_routes !=3D 1) + return -EINVAL; + + route =3D &state->routing.routes[0]; + + fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); if (!fmt) return -EINVAL; =20 @@ -341,7 +359,7 @@ static int risp_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct v4l2_mbus_framefmt *framefmt; + struct v4l2_mbus_framefmt *fmt; =20 if (format->pad > RCAR_ISP_SINK) return v4l2_subdev_get_fmt(sd, state, format); @@ -349,10 +367,20 @@ static int risp_set_pad_format(struct v4l2_subdev *sd, if (!risp_code_to_fmt(format->format.code)) format->format.code =3D rcar_isp_formats[0].code; =20 - for (unsigned int i =3D 0; i < RCAR_ISP_NUM_PADS; i++) { - framefmt =3D v4l2_subdev_state_get_format(state, i); - *framefmt =3D format->format; - } + /* Set sink format. */ + fmt =3D v4l2_subdev_state_get_format(state, format->pad, format->stream); + if (!fmt) + return -EINVAL; + + *fmt =3D format->format; + + /* Propagate the format to the source pad. */ + fmt =3D v4l2_subdev_state_get_opposite_stream_format(state, format->pad, + format->stream); + if (!fmt) + return -EINVAL; + + *fmt =3D format->format; =20 return 0; } @@ -369,6 +397,32 @@ static const struct v4l2_subdev_ops rcar_isp_subdev_op= s =3D { .pad =3D &risp_pad_ops, }; =20 +static int risp_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state) +{ + static struct v4l2_subdev_route routes[] =3D { + { + .sink_pad =3D RCAR_ISP_SINK, + .sink_stream =3D 0, + .source_pad =3D RCAR_ISP_PORT0, + .source_stream =3D 0, + .flags =3D V4L2_SUBDEV_ROUTE_FL_ACTIVE, + }, + }; + + static const struct v4l2_subdev_krouting routing =3D { + .num_routes =3D ARRAY_SIZE(routes), + .routes =3D routes, + }; + + return v4l2_subdev_set_routing_with_fmt(sd, state, &routing, + &risp_default_fmt); +} + +static const struct v4l2_subdev_internal_ops risp_internal_ops =3D { + .init_state =3D risp_init_state, +}; + /* -----------------------------------------------------------------------= ------ * Async handling and registration of subdevices and links */ @@ -541,11 +595,12 @@ static int risp_probe(struct platform_device *pdev) =20 isp->subdev.owner =3D THIS_MODULE; isp->subdev.dev =3D &pdev->dev; + isp->subdev.internal_ops =3D &risp_internal_ops; v4l2_subdev_init(&isp->subdev, &rcar_isp_subdev_ops); v4l2_set_subdevdata(&isp->subdev, &pdev->dev); snprintf(isp->subdev.name, sizeof(isp->subdev.name), "%s %s", KBUILD_MODNAME, dev_name(&pdev->dev)); - isp->subdev.flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE; + isp->subdev.flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_STREAMS; =20 isp->subdev.entity.function =3D MEDIA_ENT_F_VID_MUX; isp->subdev.entity.ops =3D &risp_entity_ops; --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48CEE397339; Tue, 8 Sep 2026 06:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849230; cv=none; b=tUHqu4rmq89raa4Kbh8cKSS4p6sR4GjcQ1L7+oZ0jQGZMdfCQSXnRwX5UFMXVaEzA7VW0Dx91GXFdLKyd8aCuDRdJd6FK1D0gHwSigjMaqNQnZtXZMWrAw6FwAY0t/g1jUkXeUlHz5vySQAzPj5WaEIsuTit3aSynp6tjpMtlvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849230; c=relaxed/simple; bh=+thg2XDSoZNWVkecGneALC7noetVEgXK5tnttNWV4Co=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G7VDpr7jtO2jsqgcy3Hficpn1NpNvOt90MgeTFDHlxNNOhs2Ty+CAIC9Uv9hbkaDVwIwfaA96r2aY3bWjdIZPhG+pLcbdnCGpGiJE6NH2mR0ihlQSmF37Y2aNIdwke9TmbJPSEfc6hTqjdv7YRNRg9lgF7HHguoDGmrpCXGDuyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=AP5QJqcI; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AP5QJqcI" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F22A16F9; Tue, 8 Sep 2026 08:32:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849125; bh=+thg2XDSoZNWVkecGneALC7noetVEgXK5tnttNWV4Co=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AP5QJqcIUV7conkY/6yhT85vbgz9aHkGaogE2WRz0HLtlAZafbMTN7DFevtEnWbi4 kUeWz/fdzxlWNWdsqbNizQ0prfcgrromCQnZyDNTOMROXu1NrW9omTjlGxCroHnkfu OXMgiSH+bdRJw3ZlWxNmSkQ6euis8zjKHLjx0Gdg= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:11 +0300 Subject: [PATCH v7 07/11] media: rcar-csi2: Add .get_frame_desc op Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-7-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3261; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=+thg2XDSoZNWVkecGneALC7noetVEgXK5tnttNWV4Co=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w8r+Y47TbLr4AhBtAaMy4JlqCHg1oAVv9l4 2c048psziKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sPAAKCRD6PaqMvJYe 9eSPD/41An3RnqjA6Ymu6bdPc3pi7ygLb/NV+gF26PlFOM9339hUXODCCU62+LeQCb+NcJZS39H FaeozWDJ0IdVjjWpb+n+4CSpodkryJAdAlUtY3nxukmScPj3DukWyKPcmhLeiM1wLzNYBt2DkXR DZ6u9kV0KqgEZuFREOTSBuSAFhYLDF8kbp83Un1bdvL0qwS3w9bY7R+x/p9+LmeEy6QfP2YFP3W 39GnBFZIdAZp/a2lWAfzNXU1jWwzcSlzlu6JK59vLal8Sy6A4a5bO+f5spGM2irGjrEYz1esz7/ O/8oq+jtJgl5McNe5CG9kvE1QsJm4V/RZnqxv2xBHTaFw9n5IQrsoFhR7jlQPMt0S926aD5RLhh 23Tehg5vERlvocsIgPcnwXVYG7Sv2FYN1Vxkii61wGzG4MTIErDMF4lPcJ0eT8xex3/Nl1ye//4 TgWX+0Uj2eETR197RPY0V6N8yp0HU6n2w/lmHx6sfhIE9o6aetInOkgObP8dEW2twprB4Ul/zpd 1RYXDWmpLRoinvIUs1vdyBHVdzuKUEd9IvVeytt4SoBYr1QdwvfKe9qzshFwZkLlGge8W7GzTlm zi1teed5CgDT3t7CZNYsju7DRufioQoUbo1WEQLg+/sZEU6dTLFIuzi9tKVoX0tBToH7TWr1j7H aWRFM+G/GmFiv9Q== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add v4l2_subdev_pad_ops.get_frame_desc() implementation. We also implement a fallback for the case where the upstream subdevice does not implement .get_frame_desc. It assumes a single stream with VC =3D 0 and DT based on the configured stream mbus format. Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 77 ++++++++++++++++++++++++++= ++++ 1 file changed, 77 insertions(+) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/pla= tform/renesas/rcar-csi2.c index c064979003ed..7bff2fe8daad 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1935,12 +1935,89 @@ static int rcsi2_set_pad_format(struct v4l2_subdev = *sd, return 0; } =20 +static int rcsi2_get_frame_desc_fallback(struct v4l2_subdev *sd, + unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct v4l2_subdev_route *route; + const struct rcar_csi2_format *format; + struct v4l2_subdev_state *state; + struct v4l2_mbus_framefmt *fmt; + int ret =3D 0; + + state =3D v4l2_subdev_lock_and_get_active_state(sd); + + if (state->routing.num_routes !=3D 1) { + ret =3D -EINVAL; + goto out; + } + + route =3D &state->routing.routes[0]; + + if (route->source_pad !=3D pad) { + ret =3D -EINVAL; + goto out; + } + + fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); + if (!fmt) { + ret =3D -EINVAL; + goto out; + } + + format =3D rcsi2_code_to_fmt(fmt->code); + if (!format) { + ret =3D -EINVAL; + goto out; + } + + fd->num_entries =3D 1; + fd->type =3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + fd->entry[0].stream =3D route->source_stream; + fd->entry[0].pixelcode =3D fmt->code; + fd->entry[0].bus.csi2.vc =3D 0; + fd->entry[0].bus.csi2.dt =3D format->datatype; + +out: + v4l2_subdev_unlock_state(state); + + return ret; +} + +static int rcsi2_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct rcar_csi2 *priv =3D sd_to_csi2(sd); + int ret; + + /* + * Providing a frame descriptor on the source pad only makes sense on + * Gen4. On Gen3 the CSI-2 IP is used to demux the CSI streams to each + * VIN instance, while on Gen4 this job is done by the Channel Selector + * of the ISP, and that needs the frame descriptors. So WARN if someone + * calls this on Gen3, as it indicates a driver bug. + */ + if (WARN_ON(!priv->info->use_isp)) + return -ENOTTY; + + if (WARN_ON(pad !=3D RCAR_CSI2_SOURCE_VC0)) + return -EINVAL; + + ret =3D v4l2_subdev_get_frame_desc_passthrough(sd, pad, fd); + if (ret =3D=3D -ENOIOCTLCMD) + ret =3D rcsi2_get_frame_desc_fallback(sd, pad, fd); + return ret; +} + static const struct v4l2_subdev_pad_ops rcar_csi2_pad_ops =3D { .enable_streams =3D rcsi2_enable_streams, .disable_streams =3D rcsi2_disable_streams, =20 .set_fmt =3D rcsi2_set_pad_format, .get_fmt =3D v4l2_subdev_get_fmt, + + .get_frame_desc =3D rcsi2_get_frame_desc, }; =20 static const struct v4l2_subdev_ops rcar_csi2_subdev_ops =3D { --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8587739E9CF; Tue, 8 Sep 2026 06:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849234; cv=none; b=Qp7BpuvrSiaDAivilUaaq6+ZZ8ih3REQmLeNVu+dtE3V+EeFdde1RWGlBA7ylVd64igVTAS2wZvce4Dy1hA+zOQUdU74hCZgG4PT/CSFpUzhLn/Ltdfh9y2GPLsik8wzNJD5tIMByvqaiyrQLTn0siaCQLvPvrsZO3B9Kex6QEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849234; c=relaxed/simple; bh=aK/p6GIryzKqvxFx9+qgKNwbn+I5Mz5M38VNWYm5ouk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K13i2P2h61Tc7dygAKBmWsobmkCEaeZKMLCM2jH08pfaXenbkjFz+y6FpkFfztUCK0iKHsSeUml8CLmPfEOoA6JAE7z9IlMGfpEeI3BjGsf0BnKP7ql7CThZAvo3lLkVdlWkbq+PeWkpYGO/RJOgJi3V3ushUFXd9dBvMFEtIgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=egCNGbx2; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="egCNGbx2" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F0E72C25; Tue, 8 Sep 2026 08:32:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849126; bh=aK/p6GIryzKqvxFx9+qgKNwbn+I5Mz5M38VNWYm5ouk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=egCNGbx2uTNMUwM1pw2RatRvt4iXUvP84VYpinS/z4lYSdPKsff3Uq61ZsvOllM3Z 469Z5kQvkmDSABdYov4QPvw5FQoxdWJ+ZYJ7fH2JN9mpbyh9sF4yC72xz7G7HdJpqz oHapQ2a29fxhd1xmPGpYPtP7qj0Kv3TmYZafLThU= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:12 +0300 Subject: [PATCH v7 08/11] media: rcar-isp: Call get_frame_desc to find out VC & DT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-8-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5108; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=aK/p6GIryzKqvxFx9+qgKNwbn+I5Mz5M38VNWYm5ouk=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w9BIvBKl9jgh6fgcbRvvg/tnbvt6r+G4Fd/ 4vUH0StDECJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sPQAKCRD6PaqMvJYe 9aErEACGwz5ZMnwNDIO85Tmus121uiLqR9WninH+7XIfLtx171nF4ED72ckNw9AfyWYEU2powsb m0cDG4fqJXWXUNHio+30tg6om4Yl253F/cY4vBoRMRT/TyMlZ9wYmUFbvlubREeXgsMp576Q5/E rmnqFYI2VjoXviCHKdb7lPZDJ/LTo2iiJNt7VOqKVs1urkh+uiHvaSNwC8GVX252g3xA3AXjROW uMU+j49HSPYlx1ZaAT8vEMZ2KtRAPkrZHnZ8hripPyVWTCO5Zc4tBN6g5+9JhkkUc2uwNWI6Uoa 1I5mThLKW4YF5gSWth0UfP9Of/B3Z+59E+AfNmYJ/GOoAASC3Hgt/FeVkec0wWLeE4+pzYUBZ6M +Ui+LIGUbCCBo0QMc5VQ8s2jQ129zkzVB+84hWVTMsEAO2AmRR9qXskdOhHDZicTwEaDdApW9db wEie235PaTjTBNSOxX3RLJFO2MF0eVk5tPtkg65MgWJcZOiUSEK068SSgmhITU+Toh2rNlOUMOD 2aygpo7RXkI5bSuVQyT4nOM55NILpspMnoYpLYd4MRL+QyvQV3fdaLZdQgB6o9QPzIcC0NFX9nL ApxUnsjsZQQXM6tSgQslvl88Si9uWnIPdcTm7ujBUDgODiw57G6/Fpc/BAT7vx3EP9Q4ZWbyas6 GPmm4TNq1HTGQxA== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Call get_frame_desc to find out VC & DT, instead of hardcoding the VC routing and deducing the DT based on the mbus format. Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp/csisp.c | 110 ++++++++++++++++----= ---- 1 file changed, 74 insertions(+), 36 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp/csisp.c b/drivers/medi= a/platform/renesas/rcar-isp/csisp.c index 97465467d047..6480f6a2a435 100644 --- a/drivers/media/platform/renesas/rcar-isp/csisp.c +++ b/drivers/media/platform/renesas/rcar-isp/csisp.c @@ -41,6 +41,9 @@ #define ISPCS_DT_CODE03_EN0 BIT(7) #define ISPCS_DT_CODE03_DT0(dt) ((dt) & 0x3f) =20 +/* ISP has 12 channels, of which channels 4 to 11 are connected to VINs */ +#define ISPCS_NUM_CHANNELS 12 + struct rcar_isp_format { u32 code; unsigned int datatype; @@ -225,31 +228,82 @@ static void risp_power_off(struct rcar_isp *isp) pm_runtime_put(isp->dev); } =20 -static int risp_start(struct rcar_isp *isp, struct v4l2_subdev_state *stat= e) +static int risp_configure_routing(struct rcar_isp *isp, + struct v4l2_subdev_state *state) { - const struct v4l2_subdev_route *route; - const struct v4l2_mbus_framefmt *fmt; - const struct rcar_isp_format *format; - unsigned int vc; - u32 sel_csi =3D 0; + struct v4l2_mbus_frame_desc source_fd; + struct v4l2_subdev_route *route; int ret; =20 - if (state->routing.num_routes !=3D 1) - return -EINVAL; + ret =3D v4l2_subdev_call(isp->remote, pad, get_frame_desc, + isp->remote_pad, &source_fd); + if (ret) + return ret; =20 - route =3D &state->routing.routes[0]; + /* Clear the channel registers */ + for (unsigned int ch =3D 0; ch < ISPCS_NUM_CHANNELS; ++ch) { + risp_write_cs(isp, ISPCS_FILTER_ID_CH_REG(ch), 0); + risp_write_cs(isp, ISPCS_DT_CODE03_CH_REG(ch), 0); + } =20 - fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, - route->sink_stream); - if (!fmt) - return -EINVAL; + for_each_active_route(&state->routing, route) { + struct v4l2_mbus_frame_desc_entry *source_entry =3D NULL; + const struct rcar_isp_format *format; + const struct v4l2_mbus_framefmt *fmt; + unsigned int i; + u8 vc, dt, ch; + u32 v; + + for (i =3D 0; i < source_fd.num_entries; i++) { + if (source_fd.entry[i].stream =3D=3D route->sink_stream) { + source_entry =3D &source_fd.entry[i]; + break; + } + } + + if (!source_entry) { + dev_err(isp->dev, + "Failed to find source frame desc entry for stream\n"); + return -EPIPE; + } + + vc =3D source_entry->bus.csi2.vc; + dt =3D source_entry->bus.csi2.dt; + /* Channels 4 - 11 go to VIN */ + ch =3D route->source_pad - 1 + 4; + + fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); + if (!fmt) + return -EINVAL; + + format =3D risp_code_to_fmt(fmt->code); + if (!format) { + dev_err(isp->dev, "Unsupported bus format\n"); + return -EINVAL; + } + + /* VC Filtering */ + risp_write_cs(isp, ISPCS_FILTER_ID_CH_REG(ch), BIT(vc)); =20 - format =3D risp_code_to_fmt(fmt->code); - if (!format) { - dev_err(isp->dev, "Unsupported bus format\n"); - return -EINVAL; + /* DT Filtering */ + risp_write_cs(isp, ISPCS_DT_CODE03_CH_REG(ch), + ISPCS_DT_CODE03_EN0 | ISPCS_DT_CODE03_DT0(dt)); + + /* Proc mode */ + v =3D risp_read_cs(isp, ISPPROCMODE_DT_REG(dt)); + v |=3D ISPPROCMODE_DT_PROC_MODE_VCn(vc, format->procmode); + risp_write_cs(isp, ISPPROCMODE_DT_REG(dt), v); } =20 + return 0; +} + +static int risp_start(struct rcar_isp *isp, struct v4l2_subdev_state *stat= e) +{ + u32 sel_csi =3D 0; + int ret; + ret =3D risp_power_on(isp); if (ret) { dev_err(isp->dev, "Failed to power on ISP\n"); @@ -263,25 +317,9 @@ static int risp_start(struct rcar_isp *isp, struct v4l= 2_subdev_state *state) risp_write_cs(isp, ISPINPUTSEL0_REG, risp_read_cs(isp, ISPINPUTSEL0_REG) | sel_csi); =20 - /* Configure Channel Selector. */ - for (vc =3D 0; vc < 4; vc++) { - u8 ch =3D vc + 4; - u8 dt =3D format->datatype; - - risp_write_cs(isp, ISPCS_FILTER_ID_CH_REG(ch), BIT(vc)); - risp_write_cs(isp, ISPCS_DT_CODE03_CH_REG(ch), - ISPCS_DT_CODE03_EN3 | ISPCS_DT_CODE03_DT3(dt) | - ISPCS_DT_CODE03_EN2 | ISPCS_DT_CODE03_DT2(dt) | - ISPCS_DT_CODE03_EN1 | ISPCS_DT_CODE03_DT1(dt) | - ISPCS_DT_CODE03_EN0 | ISPCS_DT_CODE03_DT0(dt)); - } - - /* Setup processing method. */ - risp_write_cs(isp, ISPPROCMODE_DT_REG(format->datatype), - ISPPROCMODE_DT_PROC_MODE_VCn(3, format->procmode) | - ISPPROCMODE_DT_PROC_MODE_VCn(2, format->procmode) | - ISPPROCMODE_DT_PROC_MODE_VCn(1, format->procmode) | - ISPPROCMODE_DT_PROC_MODE_VCn(0, format->procmode)); + ret =3D risp_configure_routing(isp, state); + if (ret) + return ret; =20 /* Start ISP. */ risp_write_cs(isp, ISPSTART_REG, ISPSTART_START); --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 895E43A169F; Tue, 8 Sep 2026 06:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849236; cv=none; b=kOXGymWtW8W/gase+fv7g0b8MQJABR4ILdPzU74LVbUo0Lp66v8aDm7riRkPSbyTRRsTtJAnT3pVK8ZcQoT9C56C4YBdJNm9TE8Hp+eVdDc8gJ7SgpmFKoo8jz4a5r9jhrpI9AOMKlis+p2uxMyVXf7HumuJwBejRC3Mp3E8oFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849236; c=relaxed/simple; bh=2L7ItjWdpW5Ezw4auR2IOLNnDB8iRJaAAVEN9Yzn8L4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t5AypFqb2/CuphRWiImI/D7q/QH0ylp5qDEvHKheW7+IO7+mT8zLFj7uNej7u99hsALFCJ1uJhY73eKD9eTm1vAvPnJ/dqwYIUweDVGp5UfoE8BxyvcnBlRhFG0ptYfMBW7pcj+0LKTl57x9jbuUVAjDiVTjuJqxn00s2tk5JuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=Veo6/mS9; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Veo6/mS9" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B5094C31; Tue, 8 Sep 2026 08:32:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849127; bh=2L7ItjWdpW5Ezw4auR2IOLNnDB8iRJaAAVEN9Yzn8L4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Veo6/mS97d1nFAdRzWvUZXh53r/85dOAEP8+nYhb/7MQ3tR6tQQxDgaPx4RG5gA2Z tTXkh5Xt6TbB/V4onF4juVusXyrQmdbGIZPwIUhI/HfdCZUTuzIvQq7bwn5sqv5NRY QAPWRiiAVhsipcBUTQ93CvC2A4sSqHHj7Y/hrP70= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:13 +0300 Subject: [PATCH v7 09/11] media: rcar-csi2: Call get_frame_desc to find out VC & DT (Gen3) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-9-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5045; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=2L7ItjWdpW5Ezw4auR2IOLNnDB8iRJaAAVEN9Yzn8L4=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w91Xkbt/T7mPMEqHqooqZ1lNcdkFIBbJtii sZ/OHWwtZaJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sPQAKCRD6PaqMvJYe 9fi4D/4wDwY5wwJpMFRuLVbpjgqOHeHBu9JjIIK6CvNXnhDRg5m0/Yw+cONFOHoqwjjdQfEsDd7 1vldFzRjYT5p/IP+UrfyZGl18UQnTx2Gd4V+P5Xean8K9oxam/G6/S3QgNs+J4K0eSgJB+0pJJo tEDcIgoTDAGxsl1QPPferqp8b+5pHhYxYGEEJOFm7j5o138sor2AusYoldhYn4OzXb6hnQJUnLv 5v11/4AFqbEtQv9zmcXS7LQicJNKU+j7AbJ6QK5zuTasiLT5g+Q2fVxgHXB9OaJH4tO5YgKmVjA DCNHf1LVCM76coRn5ys2U2EJMRRY/N5VygFE/dx77814JLqwMTU4wUmtfNQYmtbI2DuKP43eZIM 3E+O8DZ+gZ2kH4aX6s0jWctaIsXr2UvGGx3bO7ZrE0Eu4hhFY3aPiOx6vkrV6hizwdX7FcGjhan +R6GlQKfiAMJbA/XROK4NDY+Saa0TE5tmbqfkDWzkkwF006nsXwn4OjojDB58PtVAqDE62Ui4yK SgRy23WmoXXzteGws0TuNtwZgECaHv37Tl0I2LjTc5AOlI+VgwtYEtvy+fRN4V7x2mYm72CtBBM yZJ/iCQwRWEfSOZXwTFq1U1dDUXNRObtwO4NJIWM84Mbk5O+uxcb4jZL+sb9GoRzmGcTw6gngEf fmtElDZhMEfrtbw== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Call get_frame_desc to find out VC & DT, for Gen3 platforms, instead of hardcoding the VC routing and deducing the DT based on the mbus format. If the source subdevice doesn't implement .get_frame_desc, we use a fallback case where we assume there's a single stream with VC =3D 0 and DT based on the mbus format. Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 111 ++++++++++++++++++-------= ---- 1 file changed, 71 insertions(+), 40 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/pla= tform/renesas/rcar-csi2.c index 7bff2fe8daad..65e3c9decfa4 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1069,62 +1069,93 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, static int rcsi2_start_receiver_gen3(struct rcar_csi2 *priv, struct v4l2_subdev_state *state) { - const struct v4l2_subdev_route *route; - const struct rcar_csi2_format *format; - u32 phycnt, vcdt =3D 0, vcdt2 =3D 0, fld =3D 0; - const struct v4l2_mbus_framefmt *fmt; + u32 phycnt, vcdt =3D 0, vcdt2 =3D 0; + u32 fld =3D FLD_DET_SEL(1); + struct v4l2_mbus_frame_desc source_fd; + struct v4l2_subdev_route *route; unsigned int lanes; - unsigned int i; int mbps, ret; + u8 ch =3D 0; =20 - /* Use the format on the sink pad to compute the receiver config. */ + ret =3D v4l2_subdev_call(priv->remote, pad, get_frame_desc, + priv->remote_pad, &source_fd); + if (ret && ret !=3D -ENOIOCTLCMD) + return ret; =20 - if (state->routing.num_routes !=3D 1) - return -EINVAL; + if (ret =3D=3D -ENOIOCTLCMD) { + /* Create a fallback source_fd */ + struct v4l2_mbus_frame_desc *fd =3D &source_fd; + const struct v4l2_subdev_route *route; + const struct rcar_csi2_format *format; + struct v4l2_mbus_framefmt *fmt; =20 - route =3D &state->routing.routes[0]; + if (state->routing.num_routes !=3D 1) + return -EINVAL; =20 - fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, - route->sink_stream); - if (!fmt) - return -EINVAL; + route =3D &state->routing.routes[0]; =20 - dev_dbg(priv->dev, "Input size (%ux%u%c)\n", - fmt->width, fmt->height, - fmt->field =3D=3D V4L2_FIELD_NONE ? 'p' : 'i'); + fmt =3D v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); + if (!fmt) + return -EINVAL; =20 - /* Code is validated in set_fmt. */ - format =3D rcsi2_code_to_fmt(fmt->code); - if (!format) - return -EINVAL; + format =3D rcsi2_code_to_fmt(fmt->code); + if (!format) + return -EINVAL; =20 - /* - * Enable all supported CSI-2 channels with virtual channel and - * data type matching. - * - * NOTE: It's not possible to get individual datatype for each - * source virtual channel. Once this is possible in V4L2 - * it should be used here. - */ - for (i =3D 0; i < priv->info->num_channels; i++) { + memset(fd, 0, sizeof(*fd)); + + fd->num_entries =3D 1; + fd->type =3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + fd->entry[0].stream =3D 0; + fd->entry[0].pixelcode =3D fmt->code; + fd->entry[0].bus.csi2.vc =3D 0; + fd->entry[0].bus.csi2.dt =3D format->datatype; + } + + for_each_active_route(&state->routing, route) { + const struct v4l2_mbus_frame_desc_entry *source_entry =3D NULL; + const struct v4l2_mbus_framefmt *fmt; + unsigned int i; u32 vcdt_part; =20 - if (priv->channel_vc[i] < 0) - continue; + for (i =3D 0; i < source_fd.num_entries; i++) { + if (source_fd.entry[i].stream =3D=3D route->sink_stream) { + source_entry =3D &source_fd.entry[i]; + break; + } + } =20 - vcdt_part =3D VCDT_SEL_VC(priv->channel_vc[i]) | VCDT_VCDTN_EN | - VCDT_SEL_DTN_ON | VCDT_SEL_DT(format->datatype); + if (!source_entry) { + dev_err(priv->dev, + "Failed to find stream from source frame desc\n"); + return -EPIPE; + } + + vcdt_part =3D VCDT_SEL_VC(source_entry->bus.csi2.vc) | + VCDT_VCDTN_EN | VCDT_SEL_DTN_ON | + VCDT_SEL_DT(source_entry->bus.csi2.dt); =20 /* Store in correct reg and offset. */ - if (i < 2) - vcdt |=3D vcdt_part << ((i % 2) * 16); + if (ch < 2) + vcdt |=3D vcdt_part << ((ch % 2) * 16); else - vcdt2 |=3D vcdt_part << ((i % 2) * 16); - } + vcdt2 |=3D vcdt_part << ((ch % 2) * 16); + + fmt =3D v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, + route->sink_stream); + if (!fmt) + return -EINVAL; + + dev_dbg(priv->dev, "Input size (%ux%u%c)\n", + fmt->width, fmt->height, + fmt->field =3D=3D V4L2_FIELD_NONE ? 'p' : 'i'); =20 - if (fmt->field =3D=3D V4L2_FIELD_ALTERNATE) - fld =3D FLD_DET_SEL(1) | FLD_FLD_EN(3) | FLD_FLD_EN(2) | - FLD_FLD_EN(1) | FLD_FLD_EN(0); + if (fmt->field =3D=3D V4L2_FIELD_ALTERNATE) + fld |=3D FLD_FLD_EN(ch); + + ch++; + } =20 /* * Get the number of active data lanes inspecting the remote mbus --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77C893A9852; Tue, 8 Sep 2026 06:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849239; cv=none; b=dbyhby72SWNYkGj3aRWj0ypcWicggBBGfv4sxEFogfF8nmIGY9H2gqfMIZk2w7UTnRuD0XJ9Jts0VCOff0jW0hR5vXvxME7xRckMrGCGi8jNBGiqmGBIuvw0gWAIbXcTjmH66dxw0zRJQV8LIfgXjxq+7UtejVsGhh9D0ZpNIck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849239; c=relaxed/simple; bh=eAs4xnjoQNGHJHIMUXqPhs8kQxhJyTYvbWqnrmt+u+M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j4S6PoyNUvB4Uz3YdLTEHJ2JrEtODDVi+IQL4Ulf+Eysp09Nc0J0Rd1FP1kQXwziNpv024GTA3HeH8fFZWXa6luRa3bTMyOG3upKYBj5aslu+XhwxUY263EIs7lrk/0cTlEB5u0ACRa6wEmUsNFPfdTqu6yPyBtThGXQHRPwpMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=Q5/RZfen; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Q5/RZfen" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7868E1CBE; Tue, 8 Sep 2026 08:32:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849128; bh=eAs4xnjoQNGHJHIMUXqPhs8kQxhJyTYvbWqnrmt+u+M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Q5/RZfen3KLH8fUcCnDHgjLjar6gojrkkmdCN/3yN8D9OjAnOKllvzn9sYrcwpC0d fZRJvhfuyXSq5atMWF9f7K02e3zqOgZuZk6J6unWI+e890BUrNcZF6wMLA4dAUhv91 66LCVv88pGIihmVBGNJsSa3BsWf3aSYbXKyo9ZuU= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:14 +0300 Subject: [PATCH v7 10/11] media: rcar-csi2: Add full streams support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-10-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6249; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=eAs4xnjoQNGHJHIMUXqPhs8kQxhJyTYvbWqnrmt+u+M=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w9zrciG2LSuaygz/pxFFheZJhOtwFGvuxiP +FyofHjeVCJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sPQAKCRD6PaqMvJYe 9YF2D/9M98pyY+GT785rnhER0e9Dh2ejYLZc+zjLk2H79BkfpjOjeGGgb9/AHDUaG+TzT7Cw27L IGzQAwJOI/ei2SXjrkF8EO+8gRZ1Ci/QY/7JfphrUtSF3q3lIJ3EFwqQAW4lmG4WKdKbv4YhFo0 uPzrs6mFgApA3nxasQUSalywH/KcJ5ZXtE5o8bOu8cZ8BOOoNB8HZ75XvjcVh6n4jBgFHuB8y0y 89CxufArYdILtLMilePthNhhKqqJ0SOKf6uvbcNotL19hpc1MNeQdlULQKQz9KVnIvnUesYYjxl sCZK30VYW4unPZQdW+VzHbGkAzkoISlNK1vgrvD0v6Uo9GSY9ZfbYo1j4FnnVMLQ83SRWeuzXeA K1fKzyN3X+rMORbfbREmFfepo9EQIsnODOXgUPfJizKxDjnynqbggtdO3KNA532/ecbBbyEFYlm oolfD61gWpssYCAtcUhIzypkhLwo6hy9az9kbG/HmIWoWy0gSLnTUxM8kOh+5+nbyrMwuvToaPc DKpt+bsSx0qX54WvbzvEq0g+NpUOntg33Iwgx6Fz0XGctLGmGR8o+nJoVUZZ+6mzIW5ryXtf0JI lqRpxQJM3PUngo6poAydv8iyyF2VOOdXcqX440/hCxwww1azGhgnOKke3OBpzgyylRlkNJpbVnd AGUT4uC6yT+LU2Q== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add the missing pieces to enable full streams support: - Add set_routing - Drop the explicit uses of a single stream, and instead use the streams mask - Track enabled sink streams so that in rcsi2_irq_thread() we can disable and enable all currently enabled streams Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 95 ++++++++++++++++++++------= ---- 1 file changed, 64 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/pla= tform/renesas/rcar-csi2.c index 65e3c9decfa4..41e3c6b2ebb7 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -702,6 +702,17 @@ static const struct rcar_csi2_format rcar_csi2_formats= [] =3D { }, }; =20 +static const struct v4l2_mbus_framefmt rcar_csi2_default_fmt =3D { + .width =3D 1920, + .height =3D 1080, + .code =3D MEDIA_BUS_FMT_RGB888_1X24, + .colorspace =3D V4L2_COLORSPACE_SRGB, + .field =3D V4L2_FIELD_NONE, + .ycbcr_enc =3D V4L2_YCBCR_ENC_DEFAULT, + .quantization =3D V4L2_QUANTIZATION_DEFAULT, + .xfer_func =3D V4L2_XFER_FUNC_DEFAULT, +}; + static const struct rcar_csi2_format *rcsi2_code_to_fmt(unsigned int code) { unsigned int i; @@ -773,7 +784,7 @@ struct rcar_csi2 { =20 int channel_vc[4]; =20 - int stream_count; + u64 enabled_sink_streams_mask; =20 bool cphy; unsigned short lanes; @@ -1883,29 +1894,32 @@ static int rcsi2_enable_streams(struct v4l2_subdev = *sd, u64 source_streams_mask) { struct rcar_csi2 *priv =3D sd_to_csi2(sd); - int ret =3D 0; - - if (source_streams_mask !=3D 1) - return -EINVAL; + u64 sink_streams; + int ret; =20 if (!priv->remote) return -ENODEV; =20 - if (priv->stream_count =3D=3D 0) { + if (!priv->enabled_sink_streams_mask) { ret =3D rcsi2_start(priv, state); if (ret) return ret; } =20 + sink_streams =3D v4l2_subdev_state_xlate_streams(state, + source_pad, + RCAR_CSI2_SINK, + &source_streams_mask); + ret =3D v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, - BIT_ULL(0)); + sink_streams); if (ret) { - if (priv->stream_count =3D=3D 0) + if (!priv->enabled_sink_streams_mask) rcsi2_stop(priv); return ret; } =20 - priv->stream_count +=3D 1; + priv->enabled_sink_streams_mask |=3D sink_streams; =20 return ret; } @@ -1915,23 +1929,26 @@ static int rcsi2_disable_streams(struct v4l2_subdev= *sd, u32 source_pad, u64 source_streams_mask) { struct rcar_csi2 *priv =3D sd_to_csi2(sd); + u64 sink_streams; int ret; =20 - if (source_streams_mask !=3D 1) - return -EINVAL; - if (!priv->remote) return -ENODEV; =20 - if (priv->stream_count =3D=3D 1) + sink_streams =3D v4l2_subdev_state_xlate_streams(state, + source_pad, + RCAR_CSI2_SINK, + &source_streams_mask); + + if (priv->enabled_sink_streams_mask =3D=3D sink_streams) rcsi2_stop(priv); =20 ret =3D v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, - BIT_ULL(0)); + sink_streams); if (ret) return ret; =20 - priv->stream_count -=3D 1; + priv->enabled_sink_streams_mask &=3D ~sink_streams; =20 return 0; } @@ -1966,6 +1983,34 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *= sd, return 0; } =20 +static int rcsi2_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + struct rcar_csi2 *priv =3D sd_to_csi2(sd); + int ret; + + if (priv->info->use_isp) { + ret =3D v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1); + } else { + ret =3D v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 | + V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING); + } + + if (ret) + return ret; + + ret =3D v4l2_subdev_set_routing_with_fmt(sd, state, routing, + &rcar_csi2_default_fmt); + if (ret) + return ret; + + return 0; +} + static int rcsi2_get_frame_desc_fallback(struct v4l2_subdev *sd, unsigned int pad, struct v4l2_mbus_frame_desc *fd) @@ -2048,6 +2093,7 @@ static const struct v4l2_subdev_pad_ops rcar_csi2_pad= _ops =3D { .set_fmt =3D rcsi2_set_pad_format, .get_fmt =3D v4l2_subdev_get_fmt, =20 + .set_routing =3D rcsi2_set_routing, .get_frame_desc =3D rcsi2_get_frame_desc, }; =20 @@ -2068,17 +2114,6 @@ static int rcsi2_init_state(struct v4l2_subdev *sd, }, }; =20 - static const struct v4l2_mbus_framefmt rcar_csi2_default_fmt =3D { - .width =3D 1920, - .height =3D 1080, - .code =3D MEDIA_BUS_FMT_RGB888_1X24, - .colorspace =3D V4L2_COLORSPACE_SRGB, - .field =3D V4L2_FIELD_NONE, - .ycbcr_enc =3D V4L2_YCBCR_ENC_DEFAULT, - .quantization =3D V4L2_QUANTIZATION_DEFAULT, - .xfer_func =3D V4L2_XFER_FUNC_DEFAULT, - }; - static const struct v4l2_subdev_krouting routing =3D { .num_routes =3D ARRAY_SIZE(routes), .routes =3D routes, @@ -2123,13 +2158,13 @@ static irqreturn_t rcsi2_irq_thread(int irq, void *= data) =20 state =3D v4l2_subdev_lock_and_get_active_state(&priv->subdev); =20 - if (priv->stream_count =3D=3D 0) + if (!priv->enabled_sink_streams_mask) goto out; =20 rcsi2_stop(priv); =20 ret =3D v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, - BIT_ULL(0)); + priv->enabled_sink_streams_mask); if (ret) { dev_warn(priv->dev, "Error recovery: failed to disable streams: %d\n", @@ -2148,7 +2183,7 @@ static irqreturn_t rcsi2_irq_thread(int irq, void *da= ta) } =20 ret =3D v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, - BIT_ULL(0)); + priv->enabled_sink_streams_mask); if (ret) { dev_warn(priv->dev, "Error recovery: failed to start streams: %d\n", @@ -2747,8 +2782,6 @@ static int rcsi2_probe(struct platform_device *pdev) =20 priv->dev =3D &pdev->dev; =20 - priv->stream_count =3D 0; - ret =3D rcsi2_probe_resources(priv, pdev); if (ret) { dev_err(priv->dev, "Failed to get resources\n"); --=20 2.43.0 From nobody Fri Sep 25 22:19:32 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DC363AC0CC; Tue, 8 Sep 2026 06:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849240; cv=none; b=J4KPgacJAjMutTnxzdOjtG48XOOBczhe7OIzbhU7pfMTLcFQk2XDI/FOf8Aj6Kck+O+P41j5luxXNnpazv9jBE6N50LTL93GvZ0uMrZadLrSvhLxtJPdkyrnkLYHJ4d4iYnNZZCu/Wanr89OUfVj8WJeTAdFsO7MMXNm4kj0J0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788849240; c=relaxed/simple; bh=4snpnfiRY0hX2v+iIuSNAp8LAGdOUIFZQJ5Kz8Cid4I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LbJfLt2tabkZgUHCRhPgYezfori4hSOwUZ4qAmkTocc8mr255OdIrzksppKr0im5uel9fTvDjbO/lwbxiuUfn6iUzPl6Q0SqF5/CY4oRZcdrpIfXs2OwLZjdTAaSM8UU6vSZRrWJEu1sKZbEqcGpDIjuDwNDrGr3EyUAKCXaCKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=ahpugELj; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ahpugELj" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3C8EF1CF6; Tue, 8 Sep 2026 08:32:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788849128; bh=4snpnfiRY0hX2v+iIuSNAp8LAGdOUIFZQJ5Kz8Cid4I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ahpugELjC3ScRgJ2pU2mpB8hJ+ymZZhqeBVDP3nciYUJcwXdcGKwtU/w20fE2LDua Q6v/p/LNkMqXQ2dDbPvVUIE8RiNvPuELKmgggarTWfosn2UOY7Jeui/yuUCOSXu6Eb Jv5YSHvNd5+NPWKojBpmRuSjDEeu6HJN1Em4QXmI= From: Tomi Valkeinen Date: Tue, 08 Sep 2026 09:33:15 +0300 Subject: [PATCH v7 11/11] media: rcar-isp: Add full streams support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260908-rcar-streams-v7-11-c406a2c2930f@ideasonboard.com> References: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> In-Reply-To: <20260908-rcar-streams-v7-0-c406a2c2930f@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , Tomi Valkeinen X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3167; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=4snpnfiRY0hX2v+iIuSNAp8LAGdOUIFZQJ5Kz8Cid4I=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBqn6w+6CMjxBbbPFoLWKQIeICVBPXrH1v0mfxYo xDrxBRzq5yJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCap+sPgAKCRD6PaqMvJYe 9eL8D/9CW6HVTPLOWS34xQBx+035nCXo0Y8FrbpUSUt4IPnkA5W+zRwPwT4Nb0/dkw8u83rp0uP Y1LttMzW0WMQh3x3w8uRMrDOKPPzC56Ek+HNCXoiyeQ8s3nGsMVu9C29yxqtDPlQ7LTx/obRPvx uLMTekD/6pMZT0h0nl02Dfy2WoERp3JaVjl4LrHbko5T66UgUbeBidN9U2pjIQB32BXecDIWSKv +NPY/LYabve3Aw/yjEHZja40cN2lNNrUR7b7JHjBY02E1a+dGNLK2GlE6GjnDW9ONxZc0INJId4 njCkUUIZZSxZA4lqTS6aaT4/+UYxI6tH5YdLvWLR0w47BNsaLETOKF30OUwuxwq5tj7YPTXqOmp 4Hg48FqRECLyEuiHbg6N44U1wWagw2ExJay9t98BNkBpfPlcmXlDnwr7XS4nCPV7n3ZU6qWVm5d cbqRxgac+tDw++U41AxumizIsasvJHsa9XtaBlwyw8jpkIAI7K+KzS/8IjjOtMKYiwI1nBfvR2Q pcRXAiy2joRQvqGoQebeCJwTOPU6fIBJEG5HruAVN/VNvYyTJDk6dl4A0zVPqdaqqcQw/CVB2AA jQ2rckf78cAR3Ac9HpRn4FGS6Ery7GlpR1+vP0tAl/zsFNHzzujtZvdQSCqyQ3sZb2h0ew7qef9 GKYjI1gjoddyJ/g== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add the missing pieces to enable full streams support: - Add set_routing - Drop the explicit uses of a single stream, and instead use the streams mask. Reviewed-by: Niklas S=C3=B6derlund Tested-by: Niklas S=C3=B6derlund Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp/csisp.c | 39 +++++++++++++++++++++= ++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp/csisp.c b/drivers/medi= a/platform/renesas/rcar-isp/csisp.c index 6480f6a2a435..3adee4e87a9c 100644 --- a/drivers/media/platform/renesas/rcar-isp/csisp.c +++ b/drivers/media/platform/renesas/rcar-isp/csisp.c @@ -340,6 +340,7 @@ static int risp_enable_streams(struct v4l2_subdev *sd, u64 source_streams_mask) { struct rcar_isp *isp =3D sd_to_isp(sd); + u64 sink_streams; int ret; =20 if (source_streams_mask !=3D 1) @@ -354,8 +355,13 @@ static int risp_enable_streams(struct v4l2_subdev *sd, return ret; } =20 + sink_streams =3D v4l2_subdev_state_xlate_streams(state, + source_pad, + RCAR_ISP_SINK, + &source_streams_mask); + ret =3D v4l2_subdev_enable_streams(isp->remote, isp->remote_pad, - BIT_ULL(0)); + sink_streams); if (ret) { if (isp->stream_count =3D=3D 0) risp_stop(isp); @@ -372,6 +378,7 @@ static int risp_disable_streams(struct v4l2_subdev *sd, u64 source_streams_mask) { struct rcar_isp *isp =3D sd_to_isp(sd); + u64 sink_streams; int ret; =20 if (source_streams_mask !=3D 1) @@ -380,8 +387,12 @@ static int risp_disable_streams(struct v4l2_subdev *sd, if (!isp->remote) return -ENODEV; =20 - ret =3D v4l2_subdev_disable_streams(isp->remote, isp->remote_pad, - BIT_ULL(0)); + sink_streams =3D v4l2_subdev_state_xlate_streams(state, + source_pad, + RCAR_ISP_SINK, + &source_streams_mask); + + ret =3D v4l2_subdev_disable_streams(isp->remote, isp->remote_pad, sink_st= reams); if (ret) return ret; =20 @@ -423,12 +434,34 @@ static int risp_set_pad_format(struct v4l2_subdev *sd, return 0; } =20 +static int risp_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + int ret; + + ret =3D v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 | + V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING); + if (ret) + return ret; + + ret =3D v4l2_subdev_set_routing_with_fmt(sd, state, routing, + &risp_default_fmt); + if (ret) + return ret; + + return 0; +} + static const struct v4l2_subdev_pad_ops risp_pad_ops =3D { .enable_streams =3D risp_enable_streams, .disable_streams =3D risp_disable_streams, .set_fmt =3D risp_set_pad_format, .get_fmt =3D v4l2_subdev_get_fmt, .link_validate =3D v4l2_subdev_link_validate_default, + .set_routing =3D risp_set_routing, }; =20 static const struct v4l2_subdev_ops rcar_isp_subdev_ops =3D { --=20 2.43.0