From patchwork Wed Mar 26 11:09:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 876406 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 E09671DB34C; Wed, 26 Mar 2025 11:10:24 +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=1742987426; cv=none; b=p8kSuB/V8XIaPHC5TZzfA86WWHdwcaq2bpSqR6YZrCtF+vgrTP8uxd+Jft72+CbnGQEjJYVm4MMb89Sl+4oabeEb5QFxx9qo1KfY8skPNGqIQvuOjmul3oQN7AHhyKlX1L1SGrOoXoUBeCb8dcHbQCKKYygEMfvPt3GU0bJe/Zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742987426; c=relaxed/simple; bh=AZEcPeUrIUmHg/tQUpkh5f/1BH5qdAk4lHVIl65W08U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fybR6gFq65JD1GnpJBYJIXIbkMwm+iMI89zRh+ymrA/s1WFey50dpbhv4wewTzFwndQ1kAenYvGjZxBXhBC/kmgOr09UkthkceBE8C/xaIrjNmU+Mw59CQinhVRcTa4xUZ/WJEPnSD0X1ubOONMtHxfzPoL+Zv9wY4yxCg233u8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=gKQWig5v; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="gKQWig5v" 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 572CDA57; Wed, 26 Mar 2025 12:08:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742987307; bh=AZEcPeUrIUmHg/tQUpkh5f/1BH5qdAk4lHVIl65W08U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gKQWig5vupRxJAmrOdQxtbDu4Qbv2GIGOJXFoZWMib+la4UGoGbhkSxt4eCEoOU+j Y1rgMr9Qh8RBLd8yM23Ak/9avHxx+suaPJqQ5S9YCw9In9Hid45l4Yc6vWvnM1NEio TRMPOF4BqeqHXWJBgd9mPPu94gFN+qx+qZHNVDv4= From: Tomi Valkeinen Date: Wed, 26 Mar 2025 13:09:24 +0200 Subject: [PATCH v2 02/15] media: rcar-isp: Improve ISPPROCMODE_DT_PROC_MODE_VC Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-rcar-streams-v2-2-d0d7002c641f@ideasonboard.com> References: <20250326-rcar-streams-v2-0-d0d7002c641f@ideasonboard.com> In-Reply-To: <20250326-rcar-streams-v2-0-d0d7002c641f@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.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1822; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=AZEcPeUrIUmHg/tQUpkh5f/1BH5qdAk4lHVIl65W08U=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBn4+CQtYt9waA/hIz2WDYUD2DU1N3Lzm8gXnq2U MaP4rsscGOJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ+PgkAAKCRD6PaqMvJYe 9Xx/D/9LGpo0IctYLv/8rrz5/qbnGhl20EJSwumV4ME0LLsyA6VgDrTBVLcG1LXmIRsZXvqEdma HGSxRsz55Kko2OntqKL7/AjejJu6RgqN4poteW4dlQEvlTLoCrzPcFRc6osTG59nu84LDQp38cI wvsygS0BKnGkKAVOn/BGAnEmigOzWvyukILtLKBaW06sifBwsAWm58nANR9atK8psOY2R0qNmsC EQSIx9lp+1BB47dxBKcsRYFQM472kNV0BWhDLpfOvfeUdz9iGqCx9BOlmcvrgf0jsF3UCTCEOcp YsoBhBPhhZdUoxV9GfAiI8t+APYMaHtv5Swbf9LyWk0i4AT/Oi4XoEVKhefl/DjkaetEnv5LfPe UVU4SV5UdIe5LCZ4Cpdu6MPFjyKJHFB4314BUL9iBbjO8xYJoxdednIx/z6QOREFNHS1Fg+/phq SpxsTNKZ7VtHP5XVKWg8LaH1mnhggglLEW0myVLr6747FIdOOkgY/8VwXprXI3r3udTeJfhzjgr QdiiFS94EJuleHBAT2eOwvQfYOyQnkC1GyoeCH2Etlnd4HHfcSnw8Mb8G4v/h6kRYPCgq4amWF/ 2dF1WSsZf5w7aNrv/nDPBgQ6ZrSx/a9vwmsm8YZnM8nGLEARZKB/82qeHsg6zz71ILtUFI0HwZu H7kTCWYS62OhuEw== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Instead of having four macros for ISPPROCMODE_DT_PROC_MODE_VC[0123](pm), have just one ISPPROCMODE_DT_PROC_MODE_VCn(vc, pm). Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp.c b/drivers/media/platform/renesas/rcar-isp.c index 4bc89d4757fa..46534a479201 100644 --- a/drivers/media/platform/renesas/rcar-isp.c +++ b/drivers/media/platform/renesas/rcar-isp.c @@ -28,10 +28,7 @@ #define ISPSTART_STOP 0x0000 #define ISPPROCMODE_DT_REG(n) (0x1100 + (0x4 * (n))) -#define ISPPROCMODE_DT_PROC_MODE_VC3(pm) (((pm) & 0x3f) << 24) -#define ISPPROCMODE_DT_PROC_MODE_VC2(pm) (((pm) & 0x3f) << 16) -#define ISPPROCMODE_DT_PROC_MODE_VC1(pm) (((pm) & 0x3f) << 8) -#define ISPPROCMODE_DT_PROC_MODE_VC0(pm) ((pm) & 0x3f) +#define ISPPROCMODE_DT_PROC_MODE_VCn(vc, pm) (((pm) & 0x3f) << (8 * (vc))) #define ISPCS_FILTER_ID_CH_REG(n) (0x3000 + (0x0100 * (n))) @@ -263,10 +260,10 @@ static int risp_start(struct rcar_isp *isp, struct v4l2_subdev_state *state) /* Setup processing method. */ risp_write(isp, ISPPROCMODE_DT_REG(format->datatype), - ISPPROCMODE_DT_PROC_MODE_VC3(format->procmode) | - ISPPROCMODE_DT_PROC_MODE_VC2(format->procmode) | - ISPPROCMODE_DT_PROC_MODE_VC1(format->procmode) | - ISPPROCMODE_DT_PROC_MODE_VC0(format->procmode)); + 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)); /* Start ISP. */ risp_write(isp, ISPSTART_REG, ISPSTART_START); From patchwork Wed Mar 26 11:09:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 876405 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 0BEB21DF963; Wed, 26 Mar 2025 11:10:27 +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=1742987429; cv=none; b=DfTvV+uhRXa4F1OL5fQ3p7/YV4qOSAv7rbvjExdS0UW/n//sR/2iZTIukjcGRgkFG9V2DqJq0Syd3x5oyJLQ/ZOVlawP0xmoQXxlZck6fSerPDHOlx/dsfRg6/LmreefAVyBYJN7Q/cf3MZptIkPsweYBrL0O2u50CUC+nu+mv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742987429; c=relaxed/simple; bh=belfbHJAk/4wDSUWKwSGFsMJp8VqA/wPEL2IyDXlAUU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CAuDBYV5MCWwRDAufCGrR24JPj+yMKWKmG5ZdsKvNA+AyDZxF7q40cT390kH9j4fHVugcl8cdZk/Wti9fjX6T6I84ZUrm3zxO92oOqn7vZW/DqWtV3uu3p1dnZyDB7UtQh9FCg/OnstjasLLIa1OQZM8tTAzlsezPjLSaHLINsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=Gs5WNPsk; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="Gs5WNPsk" 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 B5DD410D4; Wed, 26 Mar 2025 12:08:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742987309; bh=belfbHJAk/4wDSUWKwSGFsMJp8VqA/wPEL2IyDXlAUU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Gs5WNPskCg3GQ/gMl4FSLTba8R85APIXRGEQHmyWXa2BAjJ4DLVaxzzcelGr0BUXw RccZ7ndhy5OlEaWpcjoLrdx9FZvWTZNxsdz+rRNAhrnN6SatgelB8RjHVCVT1dsrwI NCTXG/MqbB5iS/TVEdLZ1p0wKVfUlT99vkp194ek= From: Tomi Valkeinen Date: Wed, 26 Mar 2025 13:09:26 +0200 Subject: [PATCH v2 04/15] media: rcar-csi2: Move {enable|disable}_streams() calls Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-rcar-streams-v2-4-d0d7002c641f@ideasonboard.com> References: <20250326-rcar-streams-v2-0-d0d7002c641f@ideasonboard.com> In-Reply-To: <20250326-rcar-streams-v2-0-d0d7002c641f@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.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1818; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=belfbHJAk/4wDSUWKwSGFsMJp8VqA/wPEL2IyDXlAUU=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBn4+CQSAZGE3pVKkr9kSvEB7xGvUg2Dr/sNdJY0 HVjnlYGLzOJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ+PgkAAKCRD6PaqMvJYe 9XmcEACttX9MdnoK7SqXEl3kAwhldzdi2L8lP7d+RiV/VHy3mJkuzoaRQRxGjMHLuDMvhgSqGCI pB6nGz11CxJp1STmIYWv1HuxgTCQltRJl/SYeWcFO84ZIvMdc3hN3O9KP8t2FLVouBv0O6+jtff PWlE3pBom+gdZOp7/HmMRN/JGDt6ON0T/tomHouwS2Z5ARhg5+ovufUKAmmziVfgn0Wgua5zlj0 D1+c4HJXE8HAtxaoMB63ICwQoJrwBYpM5l/JMxmEEr+SGFUCuueGkgd6+K25ARoFfRrRKZVuGl5 8byyBagxklkVKxQoi9Z/2aJNzml5fuSwVQTUsYE2bd0uf+gfBAjLWiH70nGgibPIaDoHiQc/0BK /cBbvqCN9lIU/98iPpGZUexv7UUrXoPgHdGvd+K64J1smMOegD6tY47w+iEcGj+0xDlYre6jAMd goAuxT41OQAZTx6Av5l+Jf5vYw6uJP/Kp+VcLnoCfK2+7lYZvibugAINBnxkwTC4ehHjbyClvDc a4lIom1flZCj1Kpo90GJ4kWX2pHWeM7NVz06MIgvHXxDr5o1V2DKsFmm62Qc4vxALcc1i4kzW6C LI7nuhUO+jnEEmxHvwEFWqnC8jW9rq8JaWbnIqHH2gvAsSxn5fVJuGxk6WbKWhk80nIBz+EoVR3 5bUOJmoqTMwx6QQ== 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(). Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index ddbdde23c122..698eb0e60f32 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1573,20 +1573,12 @@ static int rcsi2_start(struct rcar_csi2 *priv, struct v4l2_subdev_state *state) return ret; } - ret = v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, - BIT_ULL(0)); - if (ret) { - rcsi2_enter_standby(priv); - return ret; - } - return 0; } static void rcsi2_stop(struct rcar_csi2 *priv) { rcsi2_enter_standby(priv); - v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, BIT_ULL(0)); } static int rcsi2_enable_streams(struct v4l2_subdev *sd, @@ -1608,6 +1600,13 @@ static int rcsi2_enable_streams(struct v4l2_subdev *sd, return ret; } + ret = v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, + BIT_ULL(0)); + if (ret) { + rcsi2_stop(priv); + return ret; + } + priv->stream_count += 1; return ret; @@ -1629,6 +1628,8 @@ static int rcsi2_disable_streams(struct v4l2_subdev *sd, if (priv->stream_count == 1) rcsi2_stop(priv); + v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, BIT_ULL(0)); + priv->stream_count -= 1; return ret; From patchwork Wed Mar 26 11:09:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 876404 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 3D22B1E51EC; Wed, 26 Mar 2025 11:10:30 +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=1742987432; cv=none; b=hYjcUE2sKrADLvQhdMEJ/H8D+E7Yy3WGTH1PSOrrJvV6Le4s7PGS8ybSbLayoZf42gdI1ZQi9PFziZh4dJoE6vywszdp9brgq+BXVxrE4lULXi+Slz9khrFfm4e07wl5o8emfXXHTwxH5xvyXWxhpxlzU+myi0LVQkU5m36tDMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742987432; c=relaxed/simple; bh=f9Zu08iRKcpOonJQPT1z5w861yw0MT1qatoa5Fhmp1w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AUoR6hPNIqJJtdBQHBuU004+cixSI1bfYEM+JPawU8qTOnB1X3Iq7STM8ddYjDHwcAZYypBzdau4aCd4Iv4QNtUZMCLkKSxDjyhcR5dJpnAFaBAmMJ/MuwHrf2PgKEl/17Dmo91HtyZfGkYwdRGQVWbdPsXVMUY9E7iVf1M+3pA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=nQxR0gmD; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="nQxR0gmD" 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 20438158E; Wed, 26 Mar 2025 12:08:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742987310; bh=f9Zu08iRKcpOonJQPT1z5w861yw0MT1qatoa5Fhmp1w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nQxR0gmDTiRf7OoVn1ouyfjXIEecbj+IiAzmfaaFl/xC5RqoQNfVgfx6rSzksPTKe kt8ba3EoeQJqdEGfT3hqE2VQxWBPWeydD9rCB80LkFyw0aQLqWrw9ydcFVPy+Aij6+ MVrBaKaWkZGcTojDZAolpQoQEaF+DPfjZgcHrEWI= From: Tomi Valkeinen Date: Wed, 26 Mar 2025 13:09:28 +0200 Subject: [PATCH v2 06/15] media: rcar-csi2: Simplify rcsi2_calc_mbps() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-rcar-streams-v2-6-d0d7002c641f@ideasonboard.com> References: <20250326-rcar-streams-v2-0-d0d7002c641f@ideasonboard.com> In-Reply-To: <20250326-rcar-streams-v2-0-d0d7002c641f@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.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3595; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=f9Zu08iRKcpOonJQPT1z5w861yw0MT1qatoa5Fhmp1w=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBn4+CROAri9pt2Krcib0/T5aMMUbnAcrpihBWpn IpPQAyfWteJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ+PgkQAKCRD6PaqMvJYe 9bo0D/94/1Hu2maDf6Q4JYLbe2knH52LQwsusChltlw1doHfkBFntoQ3skIjXE7HCZi+uq6wHEE DCzUTs0t5GdeUj1wt2MkwNkYMZ65b/s6ZxVWW0gmCJYf4MDR5nyk7bk7jkACg4ViPjlD9uzrvHg pN/YH/DJ1/d3v8DzpVBK4aaSeQSJZM20dRuKGwGgKRX2zJuqo6fSK21HiqhXaY4j6n2isJOHe1g 1Wp/ugBd3Oxw//PGnw4s/YwsXw/oTKcVtK4CljT0cQbb4YqpXfLaFAJ4+VxlySvDM/i6X2DYG9y 8wZlMM5spsAhuqAxB+nICUGQZNJkdJX2cZCXserqT8s6G3daIefkPqjtXG+GS2xnCwAuGvBtSj9 7UUmNzp4q/+oxb9ydGJlvfYonbhWNHHLa133dUZtGMXu2Gck4wDfEa6/B9mhhZqo+Ck/MgJWHbj 2lX+6YPNZo8faSr/5AYzQmFEx8EWnwK//AQhOAJJde1siClbAOV7K03+GhqLJlmmZLjHpsc8/76 rvOMJ6+Rq42Z84TPeh8OsryvLqrmHFt18jwoIhOCgYWYOLY+DizvB4e5ITjN/4W873ACKjDwB0y B0CqfzlBWRUXAQBrLOyqSnLZoWFOvtf9iYhq6ZADpRi5lvAzGNtWtGgWlkTfL8ECiRVqI3uUSeX HbDA/htNxAHtgEA== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Instead of taking the bpp and the number of lanes as parameters to rcsi2_calc_mbps(), change the function to get those parameters inside the function. This centralizes the code a bit and makes it easier to add streams support. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 45 ++++++++++++++++-------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index 8aca35096408..90973f3cba38 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -998,13 +998,18 @@ static int rcsi2_get_active_lanes(struct rcar_csi2 *priv, return 0; } -static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp, - unsigned int lanes) +static int rcsi2_calc_mbps(struct rcar_csi2 *priv, + struct v4l2_subdev_state *state) { + const struct rcar_csi2_format *format; + struct v4l2_mbus_framefmt *fmt; struct media_pad *remote_pad; struct v4l2_subdev *source; + unsigned int lanes; + unsigned int bpp; s64 freq; u64 mbps; + int ret; if (!priv->remote) return -ENODEV; @@ -1012,6 +1017,20 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp, source = priv->remote; remote_pad = &source->entity.pads[priv->remote_pad]; + ret = rcsi2_get_active_lanes(priv, &lanes); + if (ret) + return ret; + + fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK); + if (!fmt) + return -EINVAL; + + format = rcsi2_code_to_fmt(fmt->code); + if (!format) + return -EINVAL; + + bpp = format->bpp; + freq = v4l2_get_link_freq(remote_pad, bpp, 2 * lanes); if (freq < 0) { int ret = (int)freq; @@ -1092,7 +1111,7 @@ static int rcsi2_start_receiver_gen3(struct rcar_csi2 *priv, phycnt = PHYCNT_ENABLECLK; phycnt |= (1 << lanes) - 1; - mbps = rcsi2_calc_mbps(priv, format->bpp, lanes); + mbps = rcsi2_calc_mbps(priv, state); if (mbps < 0) return mbps; @@ -1300,23 +1319,15 @@ static int rcsi2_c_phy_setting_v4h(struct rcar_csi2 *priv, int msps) static int rcsi2_start_receiver_v4h(struct rcar_csi2 *priv, struct v4l2_subdev_state *state) { - const struct rcar_csi2_format *format; - const struct v4l2_mbus_framefmt *fmt; unsigned int lanes; int msps; int ret; - /* Use the format on the sink pad to compute the receiver config. */ - fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK); - format = rcsi2_code_to_fmt(fmt->code); - if (!format) - return -EINVAL; - ret = rcsi2_get_active_lanes(priv, &lanes); if (ret) return ret; - msps = rcsi2_calc_mbps(priv, format->bpp, lanes); + msps = rcsi2_calc_mbps(priv, state); if (msps < 0) return msps; @@ -1494,23 +1505,15 @@ static int rcsi2_init_common_v4m(struct rcar_csi2 *priv, unsigned int mbps) static int rcsi2_start_receiver_v4m(struct rcar_csi2 *priv, struct v4l2_subdev_state *state) { - const struct rcar_csi2_format *format; - const struct v4l2_mbus_framefmt *fmt; unsigned int lanes; int mbps; int ret; - /* Calculate parameters */ - fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK); - format = rcsi2_code_to_fmt(fmt->code); - if (!format) - return -EINVAL; - ret = rcsi2_get_active_lanes(priv, &lanes); if (ret) return ret; - mbps = rcsi2_calc_mbps(priv, format->bpp, lanes); + mbps = rcsi2_calc_mbps(priv, state); if (mbps < 0) return mbps; From patchwork Wed Mar 26 11:09:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 876403 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 A646B1EEA30; Wed, 26 Mar 2025 11:10:34 +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=1742987437; cv=none; b=MZB8s3Fdqgjyp+rX5fhzOSWIR+MVKL9J9STBShkgPApEnMHdwseEXokO3oXaYl2E5pBu7kDSX/33BK40wLRDTFR5cBQd3Ho0iNAP2L5+hwTzPrBPbX7yKVTiAeuC70uCmUJgTSf8Xmmkjl3YzQ+8UggM+P1U43G26sPCmCoCkwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742987437; c=relaxed/simple; bh=eGxXrbQ8I7Tnu7ZgQwBPljss30FabnTKNMEZW47YvvU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g0XiYR35PqKQ6D4mz6BdT1u3Rugo6HEKrTi3kVO6aqlyTIJY1Cng+YceVikZbCOet6msgalYvbiUXlcApRKeKSAnX5PLY+GtuTrCctBskQgx6cQZNBbdzl6v0z5AihIP/jDEc5NNNaryLuWRVW4OLzHr0B4f2yWLhhZrLDBnrG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=JoEFcUPO; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="JoEFcUPO" 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 7D5BF1955; Wed, 26 Mar 2025 12:08:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742987312; bh=eGxXrbQ8I7Tnu7ZgQwBPljss30FabnTKNMEZW47YvvU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JoEFcUPOLufZP5jw0pDVpdxxTXaRK0CuI5x2uXXjG/bMyzSbTM1n5Nu2JF7nQC4TT XLe8Ebnl5TH5zAVHPXZH6vhxmUKLUyRqFQKaAfMg/ilAJyEQAm9zpJe4lSwhUyD+sh 3CaSK7IfJANLsJJ/Bw7sFzOpriweR+shVg35AYkk= From: Tomi Valkeinen Date: Wed, 26 Mar 2025 13:09:30 +0200 Subject: [PATCH v2 08/15] media: rcar-csi2: Switch to Streams API Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-rcar-streams-v2-8-d0d7002c641f@ideasonboard.com> References: <20250326-rcar-streams-v2-0-d0d7002c641f@ideasonboard.com> In-Reply-To: <20250326-rcar-streams-v2-0-d0d7002c641f@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.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4215; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=eGxXrbQ8I7Tnu7ZgQwBPljss30FabnTKNMEZW47YvvU=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBn4+CSZGpM9Zl3UeMcQfSWRXm0KxJu9Uhz7WICA +w/Ha/PB3qJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ+PgkgAKCRD6PaqMvJYe 9WaVD/0XV6jzJ0T/qnOtJzKZgVvNt22xTAID6NaE9Gk7eRn0VUUykM5/PRTwqSciEow5mRGlQ3e IQLkp1E6+bzQAz45l0OLgqGy1efGirQzC+WqeXnN0QHzoCD8AHWWyyyVeRi2i4vKO7pPGL1Ferd 70cW+fTUhkCPCcexhqxlpOg9/deXL+ZUQkZYwWTllJXr4s/ScunpBPuVTdSdwtmj24zxLUanE68 Q24XAfD6dWy39++PbNMiDG2IKhZEj7+E35wNMiea/bCs6nfABTaq+GnsP8trCUgYCWPustGbIa3 0Ndu3gguqWJe5n+/obRNn52EpMKA/4h2EBdj/lUMLF93wiFThFQOJORYGdPkGXTEeIiJE9plIph 1PNzjmnZ2XlaELuzqF3Kn6P9TdmJ0KCNzPt7eJNXDYqCtNWico2lSTIMKHTSqi0+koysrBoKDUD wE5dsxCPqMNa9HN694DfHplr9MdVqa0ha21vP65dImd1EVXO9RxMV8SZeTxhHsDi/+G4y+jzKz0 DcYbjgdWnZp2ffqyrWb7rG08vfzia7HTXwkLuyzfZM5nIETlSJzTaLgDUnhcGi8Q6k9fC9spEC5 ltFSd5UP2hMXRTMGacLAo6KO9vm38nNx/CojEz7cdvSaEszz7TFeiUkPhZ7FI1EHrkLIOBVkbY4 iadAfdlc5qYsQ0g== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Switch to Streams API with a single hardcoded route. This breaks any existing userspace which depended on the custom rcar streams implementation, but a single camera use case should continue to work. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 47 +++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index e0a0fd96459b..20bd44274bd2 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1028,7 +1028,7 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, if (ret) return ret; - fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK); + fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, 0); if (!fmt) return -EINVAL; @@ -1069,7 +1069,7 @@ static int rcsi2_start_receiver_gen3(struct rcar_csi2 *priv, int mbps, ret; /* Use the format on the sink pad to compute the receiver config. */ - fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK); + fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, 0); dev_dbg(priv->dev, "Input size (%ux%u%c)\n", fmt->width, fmt->height, @@ -1650,8 +1650,7 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct rcar_csi2 *priv = sd_to_csi2(sd); - unsigned int num_pads = rcsi2_num_pads(priv); + struct v4l2_mbus_framefmt *fmt; if (format->pad > RCAR_CSI2_SINK) return v4l2_subdev_get_fmt(sd, state, format); @@ -1659,11 +1658,20 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, if (!rcsi2_code_to_fmt(format->format.code)) format->format.code = rcar_csi2_formats[0].code; - *v4l2_subdev_state_get_format(state, format->pad) = format->format; + /* Set sink format */ + fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream); + if (!fmt) + return -EINVAL; + + *fmt = format->format; + + /* Propagate to source format */ + fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad, + format->stream); + if (!fmt) + return -EINVAL; - /* Propagate the format to the source pads. */ - for (unsigned int i = RCAR_CSI2_SOURCE_VC0; i < num_pads; i++) - *v4l2_subdev_state_get_format(state, i) = format->format; + *fmt = format->format; return 0; } @@ -1683,8 +1691,15 @@ static const struct v4l2_subdev_ops rcar_csi2_subdev_ops = { static int rcsi2_init_state(struct v4l2_subdev *sd, struct v4l2_subdev_state *state) { - struct rcar_csi2 *priv = sd_to_csi2(sd); - unsigned int num_pads = rcsi2_num_pads(priv); + static struct v4l2_subdev_route routes[] = { + { + .sink_pad = RCAR_CSI2_SINK, + .sink_stream = 0, + .source_pad = RCAR_CSI2_SOURCE_VC0, + .source_stream = 0, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, + }, + }; static const struct v4l2_mbus_framefmt rcar_csi2_default_fmt = { .width = 1920, @@ -1697,10 +1712,13 @@ static int rcsi2_init_state(struct v4l2_subdev *sd, .xfer_func = V4L2_XFER_FUNC_DEFAULT, }; - for (unsigned int i = RCAR_CSI2_SINK; i < num_pads; i++) - *v4l2_subdev_state_get_format(state, i) = rcar_csi2_default_fmt; + static const struct v4l2_subdev_krouting routing = { + .num_routes = ARRAY_SIZE(routes), + .routes = routes, + }; - return 0; + return v4l2_subdev_set_routing_with_fmt(sd, state, &routing, + &rcar_csi2_default_fmt); } static const struct v4l2_subdev_internal_ops rcar_csi2_internal_ops = { @@ -2356,7 +2374,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 = V4L2_SUBDEV_FL_HAS_DEVNODE; + priv->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_STREAMS; priv->subdev.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER; priv->subdev.entity.ops = &rcar_csi2_entity_ops; From patchwork Wed Mar 26 11:09:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 876402 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 AA1CA1F1927; Wed, 26 Mar 2025 11:10: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=1742987440; cv=none; b=T8y23RDjEZxLOQQXF2KmWKGhjuH3r6LYiJWboElsk8MIrGBk1t2x/0/j/7f80N+55vir42srz6HNUC9nKxND13qnGapRtHsK836ybViCSJ2sVPrP80wZP4QXjk6SQpSiJJJKED5EHB6bVDT76e7X38TE4P9KDqpSD/EliLPME04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742987440; c=relaxed/simple; bh=AAoZrLKhCu46h4eqW0AD+WoWoaATspJrEVsuJ1Kip4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rttQ2TKx0dz2gqzDG7oERPsBKQlqGBimmCmHhrrfhnfKibb342fUMuS4pTe+FWkV7WH7xeLFmeMFrEng+eqJbKhSIn4hgFAY9jicsAEmXBp86fiHXPwMJJnDBWSt6uGJqbTwuBto0r3KF/jK6XAz0d6g3kjINttuaiyT2nnoHDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=owGd6asi; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="owGd6asi" 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 90663198D; Wed, 26 Mar 2025 12:08:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742987314; bh=AAoZrLKhCu46h4eqW0AD+WoWoaATspJrEVsuJ1Kip4g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=owGd6asiZvm8V+trWzTTnqjakE0pLhte/jpR+75E1AxEIog3mdRVbhpJwTSwQ7bjW 8Opprxl6vieoC8/ohmenyzR/D3BmhtRkDDb1+wWQJ9H4UU0EF4rcCAmPdy+Vqh6qNE Z7I/SiesviG82dEMJZqnzlLXqo0aUMFtw4WCX7G0= From: Tomi Valkeinen Date: Wed, 26 Mar 2025 13:09:33 +0200 Subject: [PATCH v2 11/15] media: rcar-isp: Call get_frame_desc to find out VC & DT Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-rcar-streams-v2-11-d0d7002c641f@ideasonboard.com> References: <20250326-rcar-streams-v2-0-d0d7002c641f@ideasonboard.com> In-Reply-To: <20250326-rcar-streams-v2-0-d0d7002c641f@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.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4530; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=AAoZrLKhCu46h4eqW0AD+WoWoaATspJrEVsuJ1Kip4g=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBn4+CTSeOhmR6vyrQHamdBuTa0I6L/A08uiih1f 7NOxc+oWBmJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ+PgkwAKCRD6PaqMvJYe 9aygD/0ZrSer5dk/P04kIIIoNeKU250r8G6kDebkoW94BqQTTO/iLr3B94gdO4pcxipmvxvmwLX bkIEADShOwkhkAuRKI9K5DseVjIjoX7BdUqvziIgW2opVlp2nx0QiDMq2POzWVo89eS+xl4CYtt Br9oQJhE4uL/kxwG35L2Pxni+udtmB6XdhJpUiMrjAsyHdz0XKVoOfSTVjEoak2Gjmo4jBnvL16 UD6/RX/GFkMG8jB6yST7vDQP8dyTFLj+uVQd8lqNbvGMlvK5aNU3VOJ4admKdXI+kbNUKjfKSFl AwjJ6cKxiRbA/HaeXImQwiAiQ2ddWSmY7UInkSnaszvgiZrsOiqWECLSByuFdt1+8N5EaMx41OD A1aeH/jqxLD6UtOxnW9x9TBidbFFnIamSRtr1iFDjAMpmTtZbOMW1MloHHKL5uadbVcme/2qDDp Hi+75HgzXxd8umaztWxHEdGVha2Q4uhRHJJYB5mVPggKzCvS+kjI6MLvgv3Pp8NEx4B9G8QNq6L ejDj0PgnhUNy+bqsfZLoXZui7ICoamLZ/o+Bx07CWr6GxpCaGBmfLROw51dRUE5CI5Pn7yL+NJD bOeaeBBlB8G/JO8TjDgQFvLhIIxK8OwpzW66Ab7UuRNds/+2U1hY76Dbg1mxzyAB1se2Ep1JUT4 3OxtWIq7P27mLyQ== 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. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp.c | 108 +++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp.c b/drivers/media/platform/renesas/rcar-isp.c index 5f3fcdb7e37e..53927954ba73 100644 --- a/drivers/media/platform/renesas/rcar-isp.c +++ b/drivers/media/platform/renesas/rcar-isp.c @@ -225,24 +225,86 @@ static void risp_power_off(struct rcar_isp *isp) pm_runtime_put(isp->dev); } -static int risp_start(struct rcar_isp *isp, struct v4l2_subdev_state *state) +static int risp_configure_routing(struct rcar_isp *isp, + struct v4l2_subdev_state *state) { - const struct v4l2_mbus_framefmt *fmt; - const struct rcar_isp_format *format; - unsigned int vc; - u32 sel_csi = 0; + struct v4l2_mbus_frame_desc source_fd; + struct v4l2_subdev_route *route; int ret; - fmt = v4l2_subdev_state_get_format(state, RCAR_ISP_SINK, 0); - if (!fmt) - return -EINVAL; + ret = v4l2_subdev_call(isp->remote, pad, get_frame_desc, + isp->remote_pad, &source_fd); + if (ret) + return ret; - format = risp_code_to_fmt(fmt->code); - if (!format) { - dev_err(isp->dev, "Unsupported bus format\n"); - return -EINVAL; + /* Clear the channel registers */ + for (unsigned int ch = 0; ch < 12; ++ch) { + risp_write(isp, ISPCS_FILTER_ID_CH_REG(ch), 0); + risp_write(isp, ISPCS_DT_CODE03_CH_REG(ch), 0); } + /* Clear the proc mode registers */ + for (unsigned int dt = 0; dt < 64; ++dt) + risp_write(isp, ISPPROCMODE_DT_REG(dt), 0); + + for_each_active_route(&state->routing, route) { + struct v4l2_mbus_frame_desc_entry *source_entry = NULL; + const struct rcar_isp_format *format; + const struct v4l2_mbus_framefmt *fmt; + unsigned int i; + u8 vc, dt, ch; + u32 v; + + for (i = 0; i < source_fd.num_entries; i++) { + if (source_fd.entry[i].stream == route->sink_stream) { + source_entry = &source_fd.entry[i]; + break; + } + } + + if (!source_entry) { + dev_err(isp->dev, + "Failed to find stream from source frame desc\n"); + return -EPIPE; + } + + vc = source_entry->bus.csi2.vc; + dt = source_entry->bus.csi2.dt; + /* Channels 4 - 11 go to VIN */ + ch = route->source_pad - 1 + 4; + + fmt = v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); + if (!fmt) + return -EINVAL; + + format = risp_code_to_fmt(fmt->code); + if (!format) { + dev_err(isp->dev, "Unsupported bus format\n"); + return -EINVAL; + } + + /* VC Filtering */ + risp_write(isp, ISPCS_FILTER_ID_CH_REG(ch), BIT(vc)); + + /* DT Filtering */ + risp_write(isp, ISPCS_DT_CODE03_CH_REG(ch), + ISPCS_DT_CODE03_EN0 | ISPCS_DT_CODE03_DT0(dt)); + + /* Proc mode */ + v = risp_read(isp, ISPPROCMODE_DT_REG(dt)); + v |= ISPPROCMODE_DT_PROC_MODE_VCn(vc, format->procmode); + risp_write(isp, ISPPROCMODE_DT_REG(dt), v); + } + + return 0; +} + +static int risp_start(struct rcar_isp *isp, struct v4l2_subdev_state *state) +{ + u32 sel_csi = 0; + int ret; + ret = risp_power_on(isp); if (ret) { dev_err(isp->dev, "Failed to power on ISP\n"); @@ -256,25 +318,9 @@ static int risp_start(struct rcar_isp *isp, struct v4l2_subdev_state *state) risp_write(isp, ISPINPUTSEL0_REG, risp_read(isp, ISPINPUTSEL0_REG) | sel_csi); - /* Configure Channel Selector. */ - for (vc = 0; vc < 4; vc++) { - u8 ch = vc + 4; - u8 dt = format->datatype; - - risp_write(isp, ISPCS_FILTER_ID_CH_REG(ch), BIT(vc)); - risp_write(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(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 = risp_configure_routing(isp, state); + if (ret) + return ret; /* Start ISP. */ risp_write(isp, ISPSTART_REG, ISPSTART_START); From patchwork Wed Mar 26 11:09:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 876401 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 1DACD1F3D52; Wed, 26 Mar 2025 11:10: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=1742987443; cv=none; b=WpTc2obJ6fxnbJ83BXFigUV5NzCuT+zzS8XQMyqVfThAF/ziv651ndlzy69Yr9LQemGImMDxc3xTtRScdcPP6JehqCbJuc1NIpU2YHbwa3SPHAR4EbxenH/3fAr42Xm0OxM6zeRm2duNoO+XQSl5iOMwZC/EL9rRMi/po1fXthE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742987443; c=relaxed/simple; bh=1yNv+grbVzrmbxkX3x9jX6k84if16DwukMHTWu1HlLs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kYHmLbndNEZjiqFK6Qe9E8c21MvY1nznoezLN65EUnPvOC5owg+e6f/LmJqYYWVEzwrnmFOusD6TxyssGwITkxoi0Zrd6yhbTjl9ktfsMAKFDuTdsFxUzY21Yq2tprTBA3Jo8ZZCsseaZoIIORMZBX2jMil+aTXuBOEGMxpt5wA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=FfSj0dxf; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="FfSj0dxf" 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 473701AE0; Wed, 26 Mar 2025 12:08:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742987314; bh=1yNv+grbVzrmbxkX3x9jX6k84if16DwukMHTWu1HlLs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FfSj0dxfN+i7W+LjTQge1Esvdffoo0JQgukLBSbqQEpX76YLoZvFjLeq3KU8LEPT6 P9eWEVwcJKyzkPp1G0R7Nw2u2bmtEX50UM5KtDoUEJDOiMsQWoAx4sr9uMlJhAdx8l YN654qDseVgI6Utow22og9VFouOyiHQcFwnPYF/Q= From: Tomi Valkeinen Date: Wed, 26 Mar 2025 13:09:34 +0200 Subject: [PATCH v2 12/15] media: rcar-csi2: Add more stream support to rcsi2_calc_mbps() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-rcar-streams-v2-12-d0d7002c641f@ideasonboard.com> References: <20250326-rcar-streams-v2-0-d0d7002c641f@ideasonboard.com> In-Reply-To: <20250326-rcar-streams-v2-0-d0d7002c641f@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.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1321; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=1yNv+grbVzrmbxkX3x9jX6k84if16DwukMHTWu1HlLs=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBn4+CTpkr+AeePQIy3m87F0at2iziPWv6UwMpHv NIZMwd7YHWJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ+PgkwAKCRD6PaqMvJYe 9TZ9D/470bP+2SBUdU/iehrjicTKU2FuAklgtR/7aHaXVk1cnQJFoGcWPQ587cG/b8Y2G/i2ZPt FALgPtQWovPXIneNXHQwblOyGZFKIo/Q0QHq9hKJt+ASjPN4GSfSSWtw0WjgT2ImjqHx1vybNG2 qu8bKJMYd9bPEBXS0NrJlpZW3SMRYFm5tGBAPcZOYxQBGm5mO8rpIpC7cNzIcnHfVyWWQ31zoFm KPts3z0fs+/5xGteRSx0gvHcpuIUS6qPtNYF6McGmuvFjowwWnI5ks76xClx2Cbj/wbDreKnqMy W4wHHHZix70c1fH8CMFBQgr+Y/GarfMQs6Xi3iA1hNMzFRlz14KQbUFShlZ9mOSLYZCfqdOms8p Izqkk9/FACRGU3oxuvNmiR/F7h8bqOy/EjWxOmZeGtNBfSSW5uf6cjiluIEJj/YDU2iA0BV7oJV dTL1hVuvwA8Y39G33zxtBCDP1yy+K0DiMdEPwfWmlTCuojGicsZANG2Na+dc4eJmdcarL6KTwVH EJqnojFtjnbtOyFemi7SK0b83M+mcTXsIGyjJw9zesgl7K7U8kcfQ1UGozzdZlNnV1dyKkF4O4K UJNsiAJc020TKOqy28x/gxV2O6nh85l6fS4OEuwVNUe01sjWm/Jop/XwYfgqHMIFaKCVsmoE7xT Tzz4+G7jZsCmRGA== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 In the case where link-freq is not available, make sure we fail if there are more than one stream configured, and also use the correct stream number for that single stream. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index 65c7f3040696..b9f83aae725a 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1018,17 +1018,22 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, */ freq = v4l2_get_link_freq(remote_pad, 0, 0); if (freq < 0) { + struct v4l2_subdev_route *route = &state->routing.routes[0]; const struct rcar_csi2_format *format; struct v4l2_mbus_framefmt *fmt; unsigned int lanes; unsigned int bpp; int ret; + if (state->routing.num_routes > 1) + return -EINVAL; + ret = rcsi2_get_active_lanes(priv, &lanes); if (ret) return ret; - fmt = v4l2_subdev_state_get_format(state, RCAR_CSI2_SINK, 0); + fmt = v4l2_subdev_state_get_format(state, route->sink_pad, + route->sink_stream); if (!fmt) return -EINVAL; From patchwork Wed Mar 26 11:09:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 876400 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 EAEC51F4194; Wed, 26 Mar 2025 11:10:44 +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=1742987446; cv=none; b=IyhymHghEgsfVq+5W+Rzu55VGEMlw6jfY3wwqZ4Gdf4ZYATSSLn8XWtoQWp6z3UHsP+THcP1BCHoS2CPohj3MK9m4n1I9LeyF0yE9at9zxJq0WkI4yhpmKTG4+Rwe0TFe/CkaxQcDB2A1sEq2QBBdAuv7UYDSAyW16sbt5W3F9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742987446; c=relaxed/simple; bh=AouKTtyjiq8170T9Uqjk+tvVIEns+KuUJ+h/sOoyHuA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Di1GnmD+QbGp/M/y52egLeL1DnlyDW2QhrSXTiiLCCxlz0s2BfJqCrPZfXsWzfOnJe/p8GoL/dgwkHWIZ37oOCewAdfiEkLjb8MmlBSfKuE8Jwv4pPJ97mIA/ynPBFKoBtC9psb3VNoCRV8gIbujGwJ5onjOUs9IIsD3guRcU9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=gsLN+Ddf; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="gsLN+Ddf" 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 A4E4D1F1C; Wed, 26 Mar 2025 12:08:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742987316; bh=AouKTtyjiq8170T9Uqjk+tvVIEns+KuUJ+h/sOoyHuA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gsLN+Ddf37+AnUwMzQWylJNMGXWqgPx3juZE9T/26dufXtCn2j7hJVn55BlSK7wMn SLu9ivuWK+xx5WP1Wm9iQB1RquIpY0kLKxYWXTkwh8ucFhhFYcxnz2x3UQ41IctZHT +gRT+lQvwe5HfcScda3s8ysI6e9+LOrnxRPF54u8= From: Tomi Valkeinen Date: Wed, 26 Mar 2025 13:09:36 +0200 Subject: [PATCH v2 14/15] media: rcar-csi2: Add full streams support Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-rcar-streams-v2-14-d0d7002c641f@ideasonboard.com> References: <20250326-rcar-streams-v2-0-d0d7002c641f@ideasonboard.com> In-Reply-To: <20250326-rcar-streams-v2-0-d0d7002c641f@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.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4751; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=AouKTtyjiq8170T9Uqjk+tvVIEns+KuUJ+h/sOoyHuA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBn4+CUXlUDGfuY4SDfPIFYuT1FKrHh+qWCZjoa5 g1lkpk658SJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ+PglAAKCRD6PaqMvJYe 9Xb4D/0Xj9Ik/1jpkJJVZqlh5Nkl1Es/SCcglgrhyyDsAaPdoN+JT6Xf47QBYES/rmrLGtGtZdn rH0OtZnobKx9Aq/hwevw576IASCQHKVywqoyJ2HHbQnwHpugGdcqWeIVT7cKNYZyIa1jFP3jgMl 0YrabVnIFAfwCinecihAzHS6VzCW7eMl04R24efwnaCLH5xvLkcyF5A2ik3+UL7sAcMtvO2ca1W 4PZq5iaYrQXFwycAwSSrSxZsBVf5odS6CppUdGWZV/VVUPLYY5LPJxCATwg3GvCBNIk2V6pqvcS q961R8coPZwUJE3lkG+cBenfPjG0YV32PK+H1QEx3fhizHpyK1MUXAE+Jmr8/Rw3DEi3pv0dfEe udyCWWTXH8K4ibzI6IxLA22WStk33k02+/GRJ25eVU0ZUwlhPgSaOJHMoekYmVpBjhDp0ueaJpE rIMwQ0lRyPZxpPSj92onA8g98BHippvv3A7mtXLTZbxVgAb8LuyMm9WLVUhhX0jmna+LaV5zZ2h 19W4B7vdqqNa5ducTei9LipADPPSI668saLBQTpJjIloQ6yKe9BK6maoTOhg8aolzTCoxDU5DFm 3iLJDon5aJXpEbvEuQGli3DsoDPR6F22nFCJ8VjNnr005w5M+z7T+UZpGNW8XqmfjmEBNunhUfS 89zhVr7wUbHwawg== 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. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 85 ++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index 8f708196ef49..4a73d223229c 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -694,6 +694,17 @@ static const struct rcar_csi2_format rcar_csi2_formats[] = { }, }; +static const struct v4l2_mbus_framefmt rcar_csi2_default_fmt = { + .width = 1920, + .height = 1080, + .code = MEDIA_BUS_FMT_RGB888_1X24, + .colorspace = V4L2_COLORSPACE_SRGB, + .field = V4L2_FIELD_NONE, + .ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT, + .quantization = V4L2_QUANTIZATION_DEFAULT, + .xfer_func = V4L2_XFER_FUNC_DEFAULT, +}; + static const struct rcar_csi2_format *rcsi2_code_to_fmt(unsigned int code) { unsigned int i; @@ -1641,10 +1652,8 @@ static int rcsi2_enable_streams(struct v4l2_subdev *sd, u64 source_streams_mask) { struct rcar_csi2 *priv = sd_to_csi2(sd); - int ret = 0; - - if (source_streams_mask != 1) - return -EINVAL; + u64 sink_streams; + int ret; if (!priv->remote) return -ENODEV; @@ -1655,8 +1664,13 @@ static int rcsi2_enable_streams(struct v4l2_subdev *sd, return ret; } + sink_streams = v4l2_subdev_state_xlate_streams(state, + RCAR_CSI2_SOURCE_VC0, + RCAR_CSI2_SINK, + &source_streams_mask); + ret = v4l2_subdev_enable_streams(priv->remote, priv->remote_pad, - BIT_ULL(0)); + sink_streams); if (ret) { rcsi2_stop(priv); return ret; @@ -1672,10 +1686,7 @@ static int rcsi2_disable_streams(struct v4l2_subdev *sd, u32 source_pad, u64 source_streams_mask) { struct rcar_csi2 *priv = sd_to_csi2(sd); - int ret = 0; - - if (source_streams_mask != 1) - return -EINVAL; + u64 sink_streams; if (!priv->remote) return -ENODEV; @@ -1683,11 +1694,17 @@ static int rcsi2_disable_streams(struct v4l2_subdev *sd, if (priv->stream_count == 1) rcsi2_stop(priv); - v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, BIT_ULL(0)); + sink_streams = v4l2_subdev_state_xlate_streams(state, + RCAR_CSI2_SOURCE_VC0, + RCAR_CSI2_SINK, + &source_streams_mask); + + v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, + sink_streams); priv->stream_count -= 1; - return ret; + return 0; } static int rcsi2_set_pad_format(struct v4l2_subdev *sd, @@ -1720,6 +1737,40 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, return 0; } +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 = sd_to_csi2(sd); + int ret; + + if (!priv->info->use_isp) + return -ENOTTY; + + if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX) + return -EINVAL; + + if (priv->info->use_isp) { + ret = v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1); + } else { + ret = v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 | + V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING); + } + + if (ret) + return ret; + + ret = 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) @@ -1781,6 +1832,7 @@ static const struct v4l2_subdev_pad_ops rcar_csi2_pad_ops = { .set_fmt = rcsi2_set_pad_format, .get_fmt = v4l2_subdev_get_fmt, + .set_routing = rcsi2_set_routing, .get_frame_desc = rcsi2_get_frame_desc, }; @@ -1801,17 +1853,6 @@ static int rcsi2_init_state(struct v4l2_subdev *sd, }, }; - static const struct v4l2_mbus_framefmt rcar_csi2_default_fmt = { - .width = 1920, - .height = 1080, - .code = MEDIA_BUS_FMT_RGB888_1X24, - .colorspace = V4L2_COLORSPACE_SRGB, - .field = V4L2_FIELD_NONE, - .ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT, - .quantization = V4L2_QUANTIZATION_DEFAULT, - .xfer_func = V4L2_XFER_FUNC_DEFAULT, - }; - static const struct v4l2_subdev_krouting routing = { .num_routes = ARRAY_SIZE(routes), .routes = routes,