[v1,4/7] staging: media: starfive: Add multi streams for ISP

Message ID 20240306093334.9321-5-changhuang.liang@starfivetech.com (mailing list archive)
State New
Headers
Series Add ISP RAW for StarFive |

Commit Message

Changhuang Liang March 6, 2024, 9:33 a.m. UTC
  ISP support multi streams output. Add stream_count to save the number
of stream on.

Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
---
 .../staging/media/starfive/camss/stf-isp.c    | 28 +++++++++++++------
 .../staging/media/starfive/camss/stf-isp.h    |  1 +
 2 files changed, 21 insertions(+), 8 deletions(-)
  

Comments

Dan Carpenter March 6, 2024, 2:24 p.m. UTC | #1
On Wed, Mar 06, 2024 at 01:33:31AM -0800, Changhuang Liang wrote:
> ISP support multi streams output. Add stream_count to save the number
> of stream on.
> 

The ISP can support multiple output streams.  Introduce stream_count to
store the number of streams.  No functional change.

> Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
> ---
>  .../staging/media/starfive/camss/stf-isp.c    | 28 +++++++++++++------
>  .../staging/media/starfive/camss/stf-isp.h    |  1 +
>  2 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c
> index 9b5745669fa6..1bfd336b14a1 100644
> --- a/drivers/staging/media/starfive/camss/stf-isp.c
> +++ b/drivers/staging/media/starfive/camss/stf-isp.c
> @@ -92,15 +92,27 @@ static int isp_set_stream(struct v4l2_subdev *sd, int enable)
>  	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
>  
>  	if (enable) {
> -		stf_isp_reset(isp_dev);
> -		stf_isp_init_cfg(isp_dev);
> -		stf_isp_settings(isp_dev, crop, fmt->code);
> -		stf_isp_config_yuv_out_stride(isp_dev, crop->width,
> -					      fmt_t_src->fmts[src].bpp);
> -		stf_isp_stream_set(isp_dev);
> -	}
> +		if (!isp_dev->stream_count) {
> +			stf_isp_reset(isp_dev);
> +			stf_isp_init_cfg(isp_dev);
> +			stf_isp_settings(isp_dev, crop, fmt->code);
> +			stf_isp_config_yuv_out_stride(isp_dev, crop->width,
> +						      fmt_t_src->fmts[src].bpp);
> +			stf_isp_stream_set(isp_dev);
> +
> +			v4l2_subdev_call(isp_dev->source_subdev, video,
> +					 s_stream, enable);

s/enable/true/

> +		}
> +
> +		isp_dev->stream_count++;
> +	} else {
> +		isp_dev->stream_count--;
>  
> -	v4l2_subdev_call(isp_dev->source_subdev, video, s_stream, enable);
> +		if (!isp_dev->stream_count) {
> +			v4l2_subdev_call(isp_dev->source_subdev, video,
> +					 s_stream, enable);

s/enable/false/

> +		}
> +	}

regards,
dan carpenter
  

Patch

diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c
index 9b5745669fa6..1bfd336b14a1 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.c
+++ b/drivers/staging/media/starfive/camss/stf-isp.c
@@ -92,15 +92,27 @@  static int isp_set_stream(struct v4l2_subdev *sd, int enable)
 	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
 
 	if (enable) {
-		stf_isp_reset(isp_dev);
-		stf_isp_init_cfg(isp_dev);
-		stf_isp_settings(isp_dev, crop, fmt->code);
-		stf_isp_config_yuv_out_stride(isp_dev, crop->width,
-					      fmt_t_src->fmts[src].bpp);
-		stf_isp_stream_set(isp_dev);
-	}
+		if (!isp_dev->stream_count) {
+			stf_isp_reset(isp_dev);
+			stf_isp_init_cfg(isp_dev);
+			stf_isp_settings(isp_dev, crop, fmt->code);
+			stf_isp_config_yuv_out_stride(isp_dev, crop->width,
+						      fmt_t_src->fmts[src].bpp);
+			stf_isp_stream_set(isp_dev);
+
+			v4l2_subdev_call(isp_dev->source_subdev, video,
+					 s_stream, enable);
+		}
+
+		isp_dev->stream_count++;
+	} else {
+		isp_dev->stream_count--;
 
-	v4l2_subdev_call(isp_dev->source_subdev, video, s_stream, enable);
+		if (!isp_dev->stream_count) {
+			v4l2_subdev_call(isp_dev->source_subdev, video,
+					 s_stream, enable);
+		}
+	}
 
 	v4l2_subdev_unlock_state(sd_state);
 	return 0;
diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h
index 4fc5cfac115c..30e4eb29f077 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.h
+++ b/drivers/staging/media/starfive/camss/stf-isp.h
@@ -414,6 +414,7 @@  struct stf_isp_dev {
 	const struct stf_isp_format_table *formats;
 	unsigned int nformats;
 	struct v4l2_subdev *source_subdev;
+	unsigned int stream_count;
 };
 
 int stf_isp_reset(struct stf_isp_dev *isp_dev);