* [PATCH] media: imx-mipi-csis: Use v4l2_subdev_enable_streams()
@ 2024-06-19 23:24 Laurent Pinchart
2024-06-20 6:34 ` Tomi Valkeinen
2024-06-20 9:47 ` Rui Miguel Silva
0 siblings, 2 replies; 3+ messages in thread
From: Laurent Pinchart @ 2024-06-19 23:24 UTC (permalink / raw)
To: linux-media
Cc: Rui Miguel Silva, Martin Kepplinger, Tomi Valkeinen, imx,
Purism Kernel Team
To support sources that implement the .enable_streams() and
.disable_streams() operations, replace the manual calls to the subdev
.s_stream() operation with the v4l2_subdev_enable_streams() and
v4l2_subdev_disable_streams() helpers. The helpers fall back to
.s_stream() if the source doesn't implement the new operations, so
backward compatibility is preserved.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/media/platform/nxp/imx-mipi-csis.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index f49b06978f14..b9729a8883d6 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -320,7 +320,11 @@ struct mipi_csis_device {
struct v4l2_subdev sd;
struct media_pad pads[CSIS_PADS_NUM];
struct v4l2_async_notifier notifier;
- struct v4l2_subdev *src_sd;
+
+ struct {
+ struct v4l2_subdev *sd;
+ const struct media_pad *pad;
+ } source;
struct v4l2_mbus_config_mipi_csi2 bus;
u32 clk_frequency;
@@ -597,7 +601,7 @@ static int mipi_csis_calculate_params(struct mipi_csis_device *csis,
u32 lane_rate;
/* Calculate the line rate from the pixel rate. */
- link_freq = v4l2_get_link_freq(csis->src_sd->ctrl_handler,
+ link_freq = v4l2_get_link_freq(csis->source.sd->ctrl_handler,
csis_fmt->width,
csis->bus.num_data_lanes * 2);
if (link_freq < 0) {
@@ -958,7 +962,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
int ret;
if (!enable) {
- v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
+ v4l2_subdev_disable_streams(csis->source.sd,
+ csis->source.pad->index, BIT(0));
mipi_csis_stop_stream(csis);
if (csis->debug.enable)
@@ -986,7 +991,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
mipi_csis_start_stream(csis, format, csis_fmt);
- ret = v4l2_subdev_call(csis->src_sd, video, s_stream, 1);
+ ret = v4l2_subdev_enable_streams(csis->source.sd,
+ csis->source.pad->index, BIT(0));
if (ret < 0)
goto err_stop;
@@ -1233,12 +1239,14 @@ static int mipi_csis_link_setup(struct media_entity *entity,
remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
if (flags & MEDIA_LNK_FL_ENABLED) {
- if (csis->src_sd)
+ if (csis->source.sd)
return -EBUSY;
- csis->src_sd = remote_sd;
+ csis->source.sd = remote_sd;
+ csis->source.pad = remote_pad;
} else {
- csis->src_sd = NULL;
+ csis->source.sd = NULL;
+ csis->source.pad = NULL;
}
return 0;
base-commit: 6ba59ff4227927d3a8530fc2973b80e94b54d58f
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] media: imx-mipi-csis: Use v4l2_subdev_enable_streams()
2024-06-19 23:24 [PATCH] media: imx-mipi-csis: Use v4l2_subdev_enable_streams() Laurent Pinchart
@ 2024-06-20 6:34 ` Tomi Valkeinen
2024-06-20 9:47 ` Rui Miguel Silva
1 sibling, 0 replies; 3+ messages in thread
From: Tomi Valkeinen @ 2024-06-20 6:34 UTC (permalink / raw)
To: Laurent Pinchart, linux-media
Cc: Rui Miguel Silva, Martin Kepplinger, imx, Purism Kernel Team
On 20/06/2024 02:24, Laurent Pinchart wrote:
> To support sources that implement the .enable_streams() and
> .disable_streams() operations, replace the manual calls to the subdev
> .s_stream() operation with the v4l2_subdev_enable_streams() and
> v4l2_subdev_disable_streams() helpers. The helpers fall back to
> .s_stream() if the source doesn't implement the new operations, so
> backward compatibility is preserved.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/media/platform/nxp/imx-mipi-csis.c | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index f49b06978f14..b9729a8883d6 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -320,7 +320,11 @@ struct mipi_csis_device {
> struct v4l2_subdev sd;
> struct media_pad pads[CSIS_PADS_NUM];
> struct v4l2_async_notifier notifier;
> - struct v4l2_subdev *src_sd;
> +
> + struct {
> + struct v4l2_subdev *sd;
> + const struct media_pad *pad;
> + } source;
>
> struct v4l2_mbus_config_mipi_csi2 bus;
> u32 clk_frequency;
> @@ -597,7 +601,7 @@ static int mipi_csis_calculate_params(struct mipi_csis_device *csis,
> u32 lane_rate;
>
> /* Calculate the line rate from the pixel rate. */
> - link_freq = v4l2_get_link_freq(csis->src_sd->ctrl_handler,
> + link_freq = v4l2_get_link_freq(csis->source.sd->ctrl_handler,
> csis_fmt->width,
> csis->bus.num_data_lanes * 2);
> if (link_freq < 0) {
> @@ -958,7 +962,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
> int ret;
>
> if (!enable) {
> - v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
> + v4l2_subdev_disable_streams(csis->source.sd,
> + csis->source.pad->index, BIT(0));
>
> mipi_csis_stop_stream(csis);
> if (csis->debug.enable)
> @@ -986,7 +991,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
>
> mipi_csis_start_stream(csis, format, csis_fmt);
>
> - ret = v4l2_subdev_call(csis->src_sd, video, s_stream, 1);
> + ret = v4l2_subdev_enable_streams(csis->source.sd,
> + csis->source.pad->index, BIT(0));
> if (ret < 0)
> goto err_stop;
>
> @@ -1233,12 +1239,14 @@ static int mipi_csis_link_setup(struct media_entity *entity,
> remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
>
> if (flags & MEDIA_LNK_FL_ENABLED) {
> - if (csis->src_sd)
> + if (csis->source.sd)
> return -EBUSY;
>
> - csis->src_sd = remote_sd;
> + csis->source.sd = remote_sd;
> + csis->source.pad = remote_pad;
> } else {
> - csis->src_sd = NULL;
> + csis->source.sd = NULL;
> + csis->source.pad = NULL;
> }
>
> return 0;
>
> base-commit: 6ba59ff4227927d3a8530fc2973b80e94b54d58f
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tomi
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] media: imx-mipi-csis: Use v4l2_subdev_enable_streams()
2024-06-19 23:24 [PATCH] media: imx-mipi-csis: Use v4l2_subdev_enable_streams() Laurent Pinchart
2024-06-20 6:34 ` Tomi Valkeinen
@ 2024-06-20 9:47 ` Rui Miguel Silva
1 sibling, 0 replies; 3+ messages in thread
From: Rui Miguel Silva @ 2024-06-20 9:47 UTC (permalink / raw)
To: Laurent Pinchart, linux-media
Cc: Martin Kepplinger, Tomi Valkeinen, imx, Purism Kernel Team
Hey Laurent,
Laurent Pinchart <laurent.pinchart@ideasonboard.com> writes:
> To support sources that implement the .enable_streams() and
> .disable_streams() operations, replace the manual calls to the subdev
> .s_stream() operation with the v4l2_subdev_enable_streams() and
> v4l2_subdev_disable_streams() helpers. The helpers fall back to
> .s_stream() if the source doesn't implement the new operations, so
> backward compatibility is preserved.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Thanks for this, LGTM.
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Cheers,
Rui
> ---
> drivers/media/platform/nxp/imx-mipi-csis.c | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index f49b06978f14..b9729a8883d6 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -320,7 +320,11 @@ struct mipi_csis_device {
> struct v4l2_subdev sd;
> struct media_pad pads[CSIS_PADS_NUM];
> struct v4l2_async_notifier notifier;
> - struct v4l2_subdev *src_sd;
> +
> + struct {
> + struct v4l2_subdev *sd;
> + const struct media_pad *pad;
> + } source;
>
> struct v4l2_mbus_config_mipi_csi2 bus;
> u32 clk_frequency;
> @@ -597,7 +601,7 @@ static int mipi_csis_calculate_params(struct mipi_csis_device *csis,
> u32 lane_rate;
>
> /* Calculate the line rate from the pixel rate. */
> - link_freq = v4l2_get_link_freq(csis->src_sd->ctrl_handler,
> + link_freq = v4l2_get_link_freq(csis->source.sd->ctrl_handler,
> csis_fmt->width,
> csis->bus.num_data_lanes * 2);
> if (link_freq < 0) {
> @@ -958,7 +962,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
> int ret;
>
> if (!enable) {
> - v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
> + v4l2_subdev_disable_streams(csis->source.sd,
> + csis->source.pad->index, BIT(0));
>
> mipi_csis_stop_stream(csis);
> if (csis->debug.enable)
> @@ -986,7 +991,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
>
> mipi_csis_start_stream(csis, format, csis_fmt);
>
> - ret = v4l2_subdev_call(csis->src_sd, video, s_stream, 1);
> + ret = v4l2_subdev_enable_streams(csis->source.sd,
> + csis->source.pad->index, BIT(0));
> if (ret < 0)
> goto err_stop;
>
> @@ -1233,12 +1239,14 @@ static int mipi_csis_link_setup(struct media_entity *entity,
> remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
>
> if (flags & MEDIA_LNK_FL_ENABLED) {
> - if (csis->src_sd)
> + if (csis->source.sd)
> return -EBUSY;
>
> - csis->src_sd = remote_sd;
> + csis->source.sd = remote_sd;
> + csis->source.pad = remote_pad;
> } else {
> - csis->src_sd = NULL;
> + csis->source.sd = NULL;
> + csis->source.pad = NULL;
> }
>
> return 0;
>
> base-commit: 6ba59ff4227927d3a8530fc2973b80e94b54d58f
> --
> Regards,
>
> Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-20 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 23:24 [PATCH] media: imx-mipi-csis: Use v4l2_subdev_enable_streams() Laurent Pinchart
2024-06-20 6:34 ` Tomi Valkeinen
2024-06-20 9:47 ` Rui Miguel Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).