From patchwork Mon Jan 20 13:10: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: 858837 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 B555A1E1C3B; Mon, 20 Jan 2025 13:11:36 +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=1737378698; cv=none; b=rIjCCDDVhuV+iYq1mKPN+Ro5hzTAMjJd6noL3Vx227xaFWXHTlhj85iAJC2Zy+GOG5q6wYAmnPG/UVbOnneSkYUgKlqxx25z6phAq+fab+JiJJJGPTU4iOSTCtrQ3JqFcRNzsTRuyRJeyhLrfwXX5b2b8D4y94RP0+Ze/EF7c4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737378698; c=relaxed/simple; bh=Z8jlw8ElRA4Rtp59zIGgryH8jHparWgwOJ0ZRvrMmOU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OAB962tiyCmdfneuYKH6QDQSmgKdk69+MpZpK3T+0LN26qqVGfTg1bpJrhdR6sRp484o3hx+AHDB1CHqBUUUwI5qBZCJLt+7m+u9jwW5Xq7CDpdNjrerBQAU7EgqwoktCka5fEOnkCMhTCO3dOOji4+hb2SFRIFVJS3uipMjYe4= 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=Jm9TUkG2; 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="Jm9TUkG2" 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 275E61193; Mon, 20 Jan 2025 14:10:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1737378624; bh=Z8jlw8ElRA4Rtp59zIGgryH8jHparWgwOJ0ZRvrMmOU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Jm9TUkG27OvnDvZLRMCmsbK56QD+MNpqVb3A+ypU6dmoLOKwF699dHG/BhWKhqkUM et6QjzRNxBZ8vHdbe24HXYwy5gDFiTKQ0Gvjz7hXjkWaOOa6nuu/pRHvMWHFWYuMVs bgj/AyD1gR62We6DtINOQwjELmRturGG5cqbJBT8= From: Tomi Valkeinen Date: Mon, 20 Jan 2025 15:10:36 +0200 Subject: [PATCH 03/10] media: rcar-isp: Add RAW8, RAW10 and RAW12 formats Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-rcar-media-impro-v1-3-043823c3893e@ideasonboard.com> References: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> In-Reply-To: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1942; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=Z8jlw8ElRA4Rtp59zIGgryH8jHparWgwOJ0ZRvrMmOU=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnjkt4QE/p03oaJhdkpmJRZJzrYp4WQUP5QYKT+ IwVdta5YYyJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ45LeAAKCRD6PaqMvJYe 9RPpEACmQBIpe2mu15JfULnnkTEdVO9zEYxcs35k9xLs/z2YR6h6tX5tWbJ5VobUfmzzU0vq2r9 U0GRfYlviYWI1POI/Zqe/rSHPjakp8XUr1lxDQJHwLX/XChiqPfVaO/fXV5HX3aqm841vVpkyJq +Oi1VwwE+jxzijzSb7xsc1RvG/2TT6/7z4uFl5oy+4vPFZU+rhqZKiJsVljtUsTo8dCbxnw292+ XU+D7RNafh7CT+P11NJnzn4gyM4neGRUQ0xgXk8DmIQeMSmTFhzRclZrjkXdpPu5i/0WM+rOw5I /rWJ8hRjBGy4UNpPlxazje4ZZsIsfwRMlAQE0tbWk9BadyeJKmYZqNSICby6YWFwbXrQ7KpdYZq 0YdacNW7yFrEGsRXi5i5NusU7LcTnwNW+PJN8OrFcL/0NDiMgVEQsLBizwaJRCvN2GcGfs+vCkb lJa4j9u38YoiOwpvxthj0JpnoFeiYaq7hvCQk9nyqRoUA62e8BKZ4Z5uEm0m8JG1M54bG93GtmI OdsOkCHXYIEVBpEHWku03WgBfd4HRHT7ZgO5VjVWjIZWNZ7J4VYWTZaQAG7fFk89TvOuARwdXQ2 Kqp1mB9mk9dUqPeR7Hji1Grbb79UT0ymmwfPGFmmgkX38F0Y1//OI6uxbYRDn5LqLImXAvC15h0 iZUDCBcsA9xpLzQ== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add RAW8, RAW10 and RAW12 formats. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp.c | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/media/platform/renesas/rcar-isp.c b/drivers/media/platform/renesas/rcar-isp.c index c515278e3be5..121fa7524ee1 100644 --- a/drivers/media/platform/renesas/rcar-isp.c +++ b/drivers/media/platform/renesas/rcar-isp.c @@ -76,6 +76,54 @@ static const struct rcar_isp_format rcar_isp_formats[] = { .code = MEDIA_BUS_FMT_YUYV10_2X10, .datatype = MIPI_CSI2_DT_YUV422_8B, .procmode = 0x0c, + }, { + .code = MEDIA_BUS_FMT_SBGGR8_1X8, + .datatype = MIPI_CSI2_DT_RAW8, + .procmode = 0x00, + }, { + .code = MEDIA_BUS_FMT_SGBRG8_1X8, + .datatype = MIPI_CSI2_DT_RAW8, + .procmode = 0x00, + }, { + .code = MEDIA_BUS_FMT_SGRBG8_1X8, + .datatype = MIPI_CSI2_DT_RAW8, + .procmode = 0x00, + }, { + .code = MEDIA_BUS_FMT_SRGGB8_1X8, + .datatype = MIPI_CSI2_DT_RAW8, + .procmode = 0x00, + }, { + .code = MEDIA_BUS_FMT_SBGGR10_1X10, + .datatype = MIPI_CSI2_DT_RAW10, + .procmode = 0x01, + }, { + .code = MEDIA_BUS_FMT_SGBRG10_1X10, + .datatype = MIPI_CSI2_DT_RAW10, + .procmode = 0x01, + }, { + .code = MEDIA_BUS_FMT_SGRBG10_1X10, + .datatype = MIPI_CSI2_DT_RAW10, + .procmode = 0x01, + }, { + .code = MEDIA_BUS_FMT_SRGGB10_1X10, + .datatype = MIPI_CSI2_DT_RAW10, + .procmode = 0x01, + }, { + .code = MEDIA_BUS_FMT_SBGGR12_1X12, + .datatype = MIPI_CSI2_DT_RAW12, + .procmode = 0x02, + }, { + .code = MEDIA_BUS_FMT_SGBRG12_1X12, + .datatype = MIPI_CSI2_DT_RAW12, + .procmode = 0x02, + }, { + .code = MEDIA_BUS_FMT_SGRBG12_1X12, + .datatype = MIPI_CSI2_DT_RAW12, + .procmode = 0x02, + }, { + .code = MEDIA_BUS_FMT_SRGGB12_1X12, + .datatype = MIPI_CSI2_DT_RAW12, + .procmode = 0x02, }, }; From patchwork Mon Jan 20 13:10:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 858836 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 D15A21E2843; Mon, 20 Jan 2025 13:11:39 +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=1737378701; cv=none; b=BmNhpiG5ie4ku/fhkUMvR1WRWf7z08YaFi+TCfKWGWsCf65C42wEiid5S2WHtDQPNgXU/v7eN/VaGcY2xENc5CVmM9d+p9++txfl9qEnSnkb4huLq4kKgDn9ctOmBwteWVpDEzDoZJwQf/bTQBL3stdUJ8m8Wxt2AzAoYnqPTMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737378701; c=relaxed/simple; bh=HOC0iwOhFBcP5j1MwMPNRotFW8j1Ia86cs/Eq8KP/9A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h+bO2X6iqNR0K/zBuY0M9oayjBzEJ8+Wh0hDEyPH7Sr6I3KeVqL24UY/99yAdv9grIc+TIgU9oOq9TDsPGnsUK05A9c6IWiJv5ccUsE6x8jMktEc9xpVgQJbo+rwXGBFSp2v/Rf7MXH3VjSL0FKk7HacL7kQdyURy97gvqZHEp8= 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=SFr/5Buu; 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="SFr/5Buu" 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 9EEBC11A1; Mon, 20 Jan 2025 14:10:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1737378624; bh=HOC0iwOhFBcP5j1MwMPNRotFW8j1Ia86cs/Eq8KP/9A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SFr/5BuuVYAeHBLv3RnLVgdsxYr/XmxEn/XNcVHQtGLE5Hh6RdqdB2faCoyAYIdoX gRegpOTMzlDaFKS7/lO/Od02dFmvS2ujxeoSXGUSj8BN0IP7F6xxNNob9zDN7CSm0X H+e9IxTTise3PMx8mKzxYSbYoJycC+xgGZCEUJAc= From: Tomi Valkeinen Date: Mon, 20 Jan 2025 15:10:37 +0200 Subject: [PATCH 04/10] media: rcar-csi2: Use v4l2_get_link_freq() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-rcar-media-impro-v1-4-043823c3893e@ideasonboard.com> References: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> In-Reply-To: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2175; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=HOC0iwOhFBcP5j1MwMPNRotFW8j1Ia86cs/Eq8KP/9A=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnjkt56oCr0WVy8D2Pu1OpmZK4MzT2ojO0Gj0R8 hbJP9UD6wiJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ45LeQAKCRD6PaqMvJYe 9Xj6D/9AVEMlaP7qNsVxHEMYI8pGvNz/7oNxkvVznpqYLB5GblBNTBltyH/t6uycQqblzt0FBFE WKndWD0FOFKjO6Re+or6ClpfO13W+PZMqo7DaO/7NQ+9jwvW8rhE2C8uzHqEVPoOLZmTYw0Ut1e SxCL6vltMD5k8dWZDrx7pUCGaPX/G17ofs26xcQ6bCcPcs0KAluywwNo3Z6+vTORvN0hyf5i1x1 Rcg+YyvbkPrH6sufvQtspZRHNCgi06YjNa3GQY0u8iyKuVtLy0on8k8kNDgbktvJ3G5S6sD/9RK mrAJ9SkyVMPMOna33bfmgPGAU997nIG5jjBml6yZRy4XQRWFl2+iFFd9mjGeRwZ3WqD8h2lFoFa AjttBducPkBmDe3t9kbR1jdAn6zzShTTTUCmNDLOf7nZ2qndbN+uOqPDME/NM7HeU+u+s2QhJmS w1FxctalwPKVHH8fThbFlhqp/i/oPO6EseHC35nFn4GiM545v95yziZuJsAut7LHp2INHVWIrjs rVf8gwwLv2ndQ3ggvvpjTpx82CrSh7IA6hri9rx3VDXWMqo9bC9ag5g6ZYtkJxGmpE+QpMeRUqW dXuBsAt9SUdMWSLVKRy0UrbVbtOxCRlI7uP09hiVoHf/bgnvoXKlp8LDgiC9q+PmMgus5Lh+Ba0 amJD+Tqh98V2NiQ== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Instead of directly using V4L2_CID_PIXEL_RATE and calculating the mbps from that, use v4l2_get_link_freq(), which also supports V4L2_CID_LINK_FREQ. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index 52d4e333c735..84e6194fed6c 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #include #include @@ -953,7 +955,7 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp, unsigned int lanes) { struct v4l2_subdev *source; - struct v4l2_ctrl *ctrl; + s64 freq; u64 mbps; if (!priv->remote) @@ -961,21 +963,17 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp, source = priv->remote; - /* Read the pixel rate control from remote. */ - ctrl = v4l2_ctrl_find(source->ctrl_handler, V4L2_CID_PIXEL_RATE); - if (!ctrl) { - dev_err(priv->dev, "no pixel rate control in subdev %s\n", - source->name); - return -EINVAL; + freq = v4l2_get_link_freq(source->ctrl_handler, bpp, 2 * lanes); + if (freq < 0) { + int ret = (int)freq; + + dev_err(priv->dev, "failed to get link freq for %s: %d\n", + source->name, ret); + + return ret; } - /* - * Calculate the phypll in mbps. - * link_freq = (pixel_rate * bits_per_sample) / (2 * nr_of_lanes) - * bps = link_freq * 2 - */ - mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * bpp; - do_div(mbps, lanes * 1000000); + mbps = div_u64(freq * 2, MEGA); /* Adjust for C-PHY, divide by 2.8. */ if (priv->cphy) From patchwork Mon Jan 20 13:10:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 858835 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 067541E3793; Mon, 20 Jan 2025 13:11:42 +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=1737378704; cv=none; b=KCgjl7u8ORMBD4jUDdeN8ITb2F/nIHb14d3BF5M41Vl7IiRM+e8XStHjSfA1fIMRO9dBp60ilXONCbJtj+rMA1XiKvA2CunfHMUj/JC5tAIbFZT0KNB/QlEaJGim2up67gFrX/jJzNOk5T2QQrQsD5HCc3VMYWddRl+ZoBLWEyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737378704; c=relaxed/simple; bh=X+TlKfpYSyW/I55G4eeXWUbG0Mub9IhXrQ8tx05iH5I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B/sReCtDYtnWHLzCWEbhTG1qo79Tc46VrWpgm6saXa+sQMv00pxlU329sYXrQFplBQRIIn6eFy9mhz9Vyf375YdrqHZjw2XpN97KjZy631OVLUenp20OmmtJASbhCjQtfa0A6905xmD/75fyxFawLBtWHhatEp3Y3QqvZ3WtF4c= 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=l4ORFvvj; 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="l4ORFvvj" 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 989FB11DF; Mon, 20 Jan 2025 14:10:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1737378625; bh=X+TlKfpYSyW/I55G4eeXWUbG0Mub9IhXrQ8tx05iH5I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=l4ORFvvjmBhJvnEpJpIJY6031sgDAR5YTefX91/V4D5hE49Pfkf3N8itTq3ixwG+A 5nv8fIfLwhTbjSo8YX2PSIVjPwciO2euW8qFwEKhm5JiKaa9Z44/6o7zTMC17dSnSN jbsesw/b+FgM8ghL/GNEiqweowReS6vsfic++0ks= From: Tomi Valkeinen Date: Mon, 20 Jan 2025 15:10:39 +0200 Subject: [PATCH 06/10] media: rcar-isp: Use v4l2_subdev_{enable|disable}_streams() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-rcar-media-impro-v1-6-043823c3893e@ideasonboard.com> References: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> In-Reply-To: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1684; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=X+TlKfpYSyW/I55G4eeXWUbG0Mub9IhXrQ8tx05iH5I=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnjkt5OMiy7omIOfdsETsOqDwFYMYq3uRGsrq4w sekkJy7XYaJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ45LeQAKCRD6PaqMvJYe 9XI5D/wI83N2zbRkchmiZIFThu/BdnE3tTNmaTOWT3oWsW6hLL9J0OUtj/X3gZ9FuMgc1yI8OZE UkPEqkoqn63vavpqYegjn128CqkVgTRAIQnwfjwUu10pjTabXppJ2v5UFV+H11HBI2aV7iJ3ge3 gz/tvMSo5ny6btQD537QkECgmnbc3C7nsCt7dSGkymEMngoBlecP5ggZp41+eaxZby0ObojjcCh FwM8f7TeYEa3wbsP/BPIRSjwT7mrBNuyYfn9ip3EiOdTUDqNhOJluL4GdSiJTHceVspAV7cKNzt Jf/L0pBJAbiBUnjwnwbw7T7RftNO8mC4MUs35CdGKJ4lRG0vmwT7n1Arnp8Y+8iS/cKZ+gs8CBi 25XQCTGYqABNIP4bPStH9X9Pq7n/qs2mE/xv4AkX3m2p/j9uyVk/WFceBsWVaJbrnXqRPalwUUT SocD/9Q6l23Bu5qCAjqBNZxRhlwuC1T6t/YNn2YfNeGfmJw3lEgoeaaWpYqRfYQySok4TomlHKY NPKnUjp0zTxNTyQecwRHJYtstRkWtQs9qB9PQ8YrYO4221hHGe7tmH9Gs12n+9BiBJFEUs1PJhy GKjSpqAUwMNriezN0/+FgO3dA4ir3/xckWbvN2WInYogHKug+kg5Glt8VWm75tGhTQXlyFqdHfd wl6LQDvFHgMk7DA== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Use v4l2_subdev_{enable|disable}_streams() instead of calling s_stream op directly. This allows the called subdev to drop the legacy s_stream op. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp.c b/drivers/media/platform/renesas/rcar-isp.c index 121fa7524ee1..385fafb2318f 100644 --- a/drivers/media/platform/renesas/rcar-isp.c +++ b/drivers/media/platform/renesas/rcar-isp.c @@ -169,6 +169,7 @@ struct rcar_isp { struct v4l2_async_notifier notifier; struct v4l2_subdev *remote; + unsigned int remote_pad; struct mutex lock; /* Protects mf and stream_count. */ struct v4l2_mbus_framefmt mf; @@ -267,7 +268,8 @@ static int risp_start(struct rcar_isp *isp) /* Start ISP. */ risp_write(isp, ISPSTART_REG, ISPSTART_START); - ret = v4l2_subdev_call(isp->remote, video, s_stream, 1); + ret = v4l2_subdev_enable_streams(isp->remote, isp->remote_pad, + BIT_ULL(0)); if (ret) risp_power_off(isp); @@ -276,7 +278,7 @@ static int risp_start(struct rcar_isp *isp) static void risp_stop(struct rcar_isp *isp) { - v4l2_subdev_call(isp->remote, video, s_stream, 0); + v4l2_subdev_disable_streams(isp->remote, isp->remote_pad, BIT_ULL(0)); /* Stop ISP. */ risp_write(isp, ISPSTART_REG, ISPSTART_STOP); @@ -387,6 +389,7 @@ static int risp_notify_bound(struct v4l2_async_notifier *notifier, } isp->remote = subdev; + isp->remote_pad = pad; dev_dbg(isp->dev, "Bound %s pad: %d\n", subdev->name, pad); From patchwork Mon Jan 20 13:10:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 858834 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 D71CC1E47B6; Mon, 20 Jan 2025 13:11: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=1737378707; cv=none; b=VovDEH3nne97/T62vCARDOceil4CY9wx4eEuk7bo8bmnOf1/kjVWO9gu8B56ix9CCrZfCmXQ/ngw6h0w5OcSLcJJuwpwfvs0MCxP+m6a3NTg/GHos3p7bhrt6OYcETfx0hsuH93Bdj6iFbR/MwBzMSsR126L0O3PDyKTdUkcdQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737378707; c=relaxed/simple; bh=e4FEE8+Vy6aIBfrj6HCMA0AaO6LCZd0h4tXExYMXGnw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hj7ZcrnaF9P7ohp9rVc4EXMjd0lh+DLHv67QNxBXH3Ve22PmqPTOWS0UHZn4tfGa0Qwp+gQyE5GLj6YZRvdKa19zQVjF++97fMzL3MDc9GoNquNNix/Ad9cX1R9ySKsEM1jjwLIZKrMg537fJKOZ8ryy8LBMB1LDaTagLYGcv3o= 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=d1MLNz3l; 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="d1MLNz3l" 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 94A7911E6; Mon, 20 Jan 2025 14:10:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1737378626; bh=e4FEE8+Vy6aIBfrj6HCMA0AaO6LCZd0h4tXExYMXGnw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=d1MLNz3lkERwNMzZvHKxdib6EfQb6RH/M8Xlp4mN7sfWTcW3rZvKTFFhavb1Z9ZT8 ilYU6EV5VfMppt2n0n9BXsoQv7Chb5CkUfa9O8DJZxie20ZqzybOgnUszBccuSqjgs h8C3BP++B64d90y3Cbt4/gSBvLwLN5Xw1G1bVL2s= From: Tomi Valkeinen Date: Mon, 20 Jan 2025 15:10:41 +0200 Subject: [PATCH 08/10] media: rcar-isp: Convert to subdev state Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-rcar-media-impro-v1-8-043823c3893e@ideasonboard.com> References: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> In-Reply-To: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5282; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=e4FEE8+Vy6aIBfrj6HCMA0AaO6LCZd0h4tXExYMXGnw=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnjkt6BwC2t1+8prZkPsEQzxa5tob2NY79X18GP xrWovEzGfGJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ45LegAKCRD6PaqMvJYe 9TEFD/0fY/2FuxShWJuvvKWzKq7E33E62RS6qQt2tXnUfCld1s4Zceg2il/62O+4XNuuRBHAoxF OuUikCuVP9YXo5TZLy4TrR9OWzyHNqNFr+z1XQWd4Pu/ODdMF/x99YYoKxY1Hh3RrPgpJJP+/hv SVvPPIe0nL6gUQvlrpOtym6C/Hqw/gElDjBsr4XR05AdVgOcGLDOE24SLcYU1DjzKkGU6kzEt16 GDwV7TUgB7tEfp5wp5B0tDZkOrvZL0PSGfuXU/bVGKznBsR4Clk4unKRCmA9An02FD3ySyyo+Ii uhTQwcahicyBW6Hin0yiPufSulZpZUbNWuprK9PZkOpH1g5wSh9OQU57znW6fIjz8gaIjeDuLjK DhE8Kk6zvg2EEPJlhz8zYFGPE6mSjnWSd6ktP5njx/jx9U1+kkwgm4NgVKz0WvtHS3CpkmNhvs9 ny0241dC2Wz2JHKL3jDGXloeyosUeX4BXhY+lkV3JG4EKkXANOuG8fNDKLlpMUR5LTLexU8UEw4 FIMRs+broOIpJtfmKj8JjSAGkbXkJus4lQe/PTySFXw6Bbku/bsLfN0hXyuYMddnf6yUS8wKXlC yHNWzmNBn6rmUR/GD79d92cKvnDaYBCE4Aj17yLQiE10PANpDIqjAPKRlAjoEvYLAQfFBUZj6TH y4/CO3Vk25BlCgg== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Convert to subdev state. This allows us to drop the internal mutex and risp_get_pad_format(), and add streams support in the future. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-isp.c | 70 ++++++++++++------------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp.c b/drivers/media/platform/renesas/rcar-isp.c index 385fafb2318f..d4eaabb45e07 100644 --- a/drivers/media/platform/renesas/rcar-isp.c +++ b/drivers/media/platform/renesas/rcar-isp.c @@ -171,8 +171,6 @@ struct rcar_isp { struct v4l2_subdev *remote; unsigned int remote_pad; - struct mutex lock; /* Protects mf and stream_count. */ - struct v4l2_mbus_framefmt mf; int stream_count; }; @@ -219,14 +217,19 @@ static void risp_power_off(struct rcar_isp *isp) pm_runtime_put(isp->dev); } -static int risp_start(struct rcar_isp *isp) +static int risp_start(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; int ret; - format = risp_code_to_fmt(isp->mf.code); + fmt = v4l2_subdev_state_get_format(state, RCAR_ISP_SINK); + if (!fmt) + return -EINVAL; + + format = risp_code_to_fmt(fmt->code); if (!format) { dev_err(isp->dev, "Unsupported bus format\n"); return -EINVAL; @@ -289,9 +292,10 @@ static void risp_stop(struct rcar_isp *isp) static int risp_s_stream(struct v4l2_subdev *sd, int enable) { struct rcar_isp *isp = sd_to_isp(sd); + struct v4l2_subdev_state *state; int ret = 0; - mutex_lock(&isp->lock); + state = v4l2_subdev_lock_and_get_active_state(sd); if (!isp->remote) { ret = -ENODEV; @@ -299,7 +303,7 @@ static int risp_s_stream(struct v4l2_subdev *sd, int enable) } if (enable && isp->stream_count == 0) { - ret = risp_start(isp); + ret = risp_start(isp, state); if (ret) goto out; } else if (!enable && isp->stream_count == 1) { @@ -308,7 +312,7 @@ static int risp_s_stream(struct v4l2_subdev *sd, int enable) isp->stream_count += enable ? 1 : -1; out: - mutex_unlock(&isp->lock); + v4l2_subdev_unlock_state(state); return ret; } @@ -318,50 +322,28 @@ static const struct v4l2_subdev_video_ops risp_video_ops = { }; static int risp_set_pad_format(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct rcar_isp *isp = sd_to_isp(sd); struct v4l2_mbus_framefmt *framefmt; - mutex_lock(&isp->lock); + if (format->pad > RCAR_ISP_SINK) + return v4l2_subdev_get_fmt(sd, state, format); if (!risp_code_to_fmt(format->format.code)) format->format.code = rcar_isp_formats[0].code; - if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { - isp->mf = format->format; - } else { - framefmt = v4l2_subdev_state_get_format(sd_state, 0); + for (unsigned int i = 0; i < RCAR_ISP_NUM_PADS; i++) { + framefmt = v4l2_subdev_state_get_format(state, i); *framefmt = format->format; } - mutex_unlock(&isp->lock); - - return 0; -} - -static int risp_get_pad_format(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *format) -{ - struct rcar_isp *isp = sd_to_isp(sd); - - mutex_lock(&isp->lock); - - if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) - format->format = isp->mf; - else - format->format = *v4l2_subdev_state_get_format(sd_state, 0); - - mutex_unlock(&isp->lock); - return 0; } static const struct v4l2_subdev_pad_ops risp_pad_ops = { .set_fmt = risp_set_pad_format, - .get_fmt = risp_get_pad_format, + .get_fmt = v4l2_subdev_get_fmt, .link_validate = v4l2_subdev_link_validate_default, }; @@ -500,12 +482,10 @@ static int risp_probe(struct platform_device *pdev) isp->dev = &pdev->dev; - mutex_init(&isp->lock); - ret = risp_probe_resources(isp, pdev); if (ret) { dev_err(isp->dev, "Failed to get resources\n"); - goto error_mutex; + return ret; } platform_set_drvdata(pdev, isp); @@ -536,20 +516,25 @@ static int risp_probe(struct platform_device *pdev) if (ret) goto error_notifier; + ret = v4l2_subdev_init_finalize(&isp->subdev); + if (ret) + goto error_notifier; + ret = v4l2_async_register_subdev(&isp->subdev); if (ret < 0) - goto error_notifier; + goto error_subdev; dev_info(isp->dev, "Using CSI-2 input: %u\n", isp->csi_input); return 0; + +error_subdev: + v4l2_subdev_cleanup(&isp->subdev); error_notifier: v4l2_async_nf_unregister(&isp->notifier); v4l2_async_nf_cleanup(&isp->notifier); error_pm: pm_runtime_disable(&pdev->dev); -error_mutex: - mutex_destroy(&isp->lock); return ret; } @@ -562,10 +547,9 @@ static void risp_remove(struct platform_device *pdev) v4l2_async_nf_cleanup(&isp->notifier); v4l2_async_unregister_subdev(&isp->subdev); + v4l2_subdev_cleanup(&isp->subdev); pm_runtime_disable(&pdev->dev); - - mutex_destroy(&isp->lock); } static struct platform_driver rcar_isp_driver = { From patchwork Mon Jan 20 13:10:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 858833 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 1FDFC1E571F; Mon, 20 Jan 2025 13:11:48 +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=1737378710; cv=none; b=i9ZkpSXiAwNFG14RRYC4ucKrZ8wKJ2YYpXaqe+0iS5WryQoXa1d6bAdEAzH3rkI0V2nYWi4zFpwezadTteVN7/umFth7uYPmbX7pDO6ZR+txpkZis8L5WOfUdo0YmgaYv++SCF3ZuMn9C76PHofCF0j5AA/VtYEm1tHaX4g8yYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737378710; c=relaxed/simple; bh=vb/+NyJJH6WqOf9gan/UQHHHcah8dJBGTn6F9vFZyp8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kNV7Gk1PefVXr+SNYkyGjLr63yVJ4EFrJBOxi3ddUSwyAD31VM5W6uVI2l3D5xyLvJcJT19Da9Dp6X5RcHYou3QoiNlpjf3wUcLP2DZ9KTWIXxXWbE3LV514yBtaxBM5zgKpCYxzhKXFxK06TpEpqf4sbqa/xENSCSFbQr+aO+Y= 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=O66a06qX; 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="O66a06qX" 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 9300311EB; Mon, 20 Jan 2025 14:10:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1737378627; bh=vb/+NyJJH6WqOf9gan/UQHHHcah8dJBGTn6F9vFZyp8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=O66a06qXa8xW7gysP6Az6clEUkDec6f9EAZ7wA35HLKkJ+KMPnPwtQhGaXJUxBjmr flJmP0Ml8rCQsmdGkxWT1/QQxwq6TfqN2lcCXqCsx0Uvj0iQud7i3ERFbYWgYQLkgr z3phtU1gKOtN+7zkQfLRt1J+Lqnn9Kf8RSNfJWfg= From: Tomi Valkeinen Date: Mon, 20 Jan 2025 15:10:43 +0200 Subject: [PATCH 10/10] media: rcar-csi2: Convert to .{enable|disable}_streams Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250120-rcar-media-impro-v1-10-043823c3893e@ideasonboard.com> References: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> In-Reply-To: <20250120-rcar-media-impro-v1-0-043823c3893e@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2555; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=vb/+NyJJH6WqOf9gan/UQHHHcah8dJBGTn6F9vFZyp8=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnjkt79re4sJKQL/QkUuHfQB9fi/MUCrXQ/YlnK Ur0xl1DyfqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ45LewAKCRD6PaqMvJYe 9QmGD/9llK7gc2nNq8wUo8r5bVN3KUqCqZadaqGVCEeL4BzT5ERmxjdRYd5Y0tHyoUR/9BUrGPq 0nNAbEjpCkq2RRkqCY8/gmMO3mvMJ6YldJ4/1ZtRCJrtiEKUsycv2tnALUfM7wFi3WOhy4r/hor LaJzCg0EzODtTyFvkzkfXJkJ1ilp7k/g1PsjNilVYuuoBaLE1/P75UMpoHl1EJ3N0PdPozu9SCE IZJaS8RrACngctkjxHxPwDjr3YawVjj9GML6RtyqdMxjjdZxGj5S1za3NqnSZ2CLBKXqsttVc0k iXmAsf9I1MZVlmf2hTzQLMOVsRvxHYgztb06I2WwPJXvAbPcv4nW8gkKgbeeHXyQrgPCiRzx8HN 4GUZDOChHRfqwwnQH5yIp6T9iguxZH8LpLfwD1pcMwkVeu6geLOUoZ8MmV+I4Wngz3RoZuwtWWy if5x/XRw8quLG2uPt1whzg0B9FXJ+gUfxeV45ZbY+S3TAougYVZkNMwx30M1mYjsnroQpJR0ijf mmWrkPCrzo0GgH6/vak1en7t1iS579LDCsOxjeivyUepPIsLl2Ou6y/7W8wzJWRq+2K4ct3SSZL xLOrjmUd10cU34fEAv4fQ6G4VK03RijMzegQ35nL9cEm7kOHOEw3U7E24geR8U55tYrNkS3iTeb IOS4rLXulKlh+CQ== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Drop the legacy .s_stream and convert to .{enable|disable}_streams. Signed-off-by: Tomi Valkeinen --- drivers/media/platform/renesas/rcar-csi2.c | 49 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index ff27a8845969..38a3149f9724 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1593,28 +1593,47 @@ static void rcsi2_stop(struct rcar_csi2 *priv) v4l2_subdev_disable_streams(priv->remote, priv->remote_pad, BIT_ULL(0)); } -static int rcsi2_s_stream(struct v4l2_subdev *sd, int enable) +static int rcsi2_enable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, u32 source_pad, + u64 source_streams_mask) { struct rcar_csi2 *priv = sd_to_csi2(sd); - struct v4l2_subdev_state *state; int ret = 0; + if (source_streams_mask != 1) + return -EINVAL; + if (!priv->remote) return -ENODEV; - state = v4l2_subdev_lock_and_get_active_state(&priv->subdev); - - if (enable && priv->stream_count == 0) { + if (priv->stream_count == 0) { ret = rcsi2_start(priv, state); if (ret) - goto out; - } else if (!enable && priv->stream_count == 1) { - rcsi2_stop(priv); + return ret; } - priv->stream_count += enable ? 1 : -1; -out: - v4l2_subdev_unlock_state(state); + priv->stream_count += 1; + + return ret; +} + +static int rcsi2_disable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + 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; + + if (!priv->remote) + return -ENODEV; + + if (priv->stream_count == 1) + rcsi2_stop(priv); + + priv->stream_count -= 1; return ret; } @@ -1641,17 +1660,15 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, return 0; } -static const struct v4l2_subdev_video_ops rcar_csi2_video_ops = { - .s_stream = rcsi2_s_stream, -}; - static const struct v4l2_subdev_pad_ops rcar_csi2_pad_ops = { + .enable_streams = rcsi2_enable_streams, + .disable_streams = rcsi2_disable_streams, + .set_fmt = rcsi2_set_pad_format, .get_fmt = v4l2_subdev_get_fmt, }; static const struct v4l2_subdev_ops rcar_csi2_subdev_ops = { - .video = &rcar_csi2_video_ops, .pad = &rcar_csi2_pad_ops, };