[v2,2/3] media: staging: rkisp1: use v4l2_pipeline_stream_{enable,disable} helpers
diff mbox series

Message ID 20200403213312.1863876-3-helen.koike@collabora.com
State New
Headers show
Series
  • media: add v4l2_pipeline_stream_{enable,disable} helpers
Related show

Commit Message

Helen Koike April 3, 2020, 9:33 p.m. UTC
Use v4l2_pipeline_stream_{enable,disable} to call .s_stream() subdevice
callbacks through the pipeline.

Tested by streaming on RockPi4 with imx219 and on Scarlet Chromebook.

Signed-off-by: Helen Koike <helen.koike@collabora.com>

---

Changes in v2:
- rebase on top of new helpers prototypes

 drivers/staging/media/rkisp1/rkisp1-capture.c | 76 +------------------
 1 file changed, 3 insertions(+), 73 deletions(-)

Comments

kbuild test robot April 4, 2020, 11:54 p.m. UTC | #1
Hi Helen,

I love your patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v5.6 next-20200404]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Helen-Koike/media-add-v4l2_pipeline_stream_-enable-disable-helpers/20200405-050004
base:   git://linuxtv.org/media_tree.git master
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.3.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/staging/media/rkisp1/rkisp1-capture.c: In function 'rkisp1_vb2_start_streaming':
>> drivers/staging/media/rkisp1/rkisp1-capture.c:952:31: error: passing argument 1 of 'v4l2_pipeline_stream_disable' from incompatible pointer type [-Werror=incompatible-pointer-types]
     952 |  v4l2_pipeline_stream_disable(entity, &cap->rkisp1->pipe);
         |                               ^~~~~~
         |                               |
         |                               struct media_entity *
   In file included from drivers/staging/media/rkisp1/rkisp1-capture.c:13:
   include/media/v4l2-common.h:548:56: note: expected 'struct video_device *' but argument is of type 'struct media_entity *'
     548 | void v4l2_pipeline_stream_disable(struct video_device *vdev);
         |                                   ~~~~~~~~~~~~~~~~~~~~~^~~~
>> drivers/staging/media/rkisp1/rkisp1-capture.c:952:2: error: too many arguments to function 'v4l2_pipeline_stream_disable'
     952 |  v4l2_pipeline_stream_disable(entity, &cap->rkisp1->pipe);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/staging/media/rkisp1/rkisp1-capture.c:13:
   include/media/v4l2-common.h:548:6: note: declared here
     548 | void v4l2_pipeline_stream_disable(struct video_device *vdev);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/v4l2_pipeline_stream_disable +952 drivers/staging/media/rkisp1/rkisp1-capture.c

   913	
   914	static int
   915	rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
   916	{
   917		struct rkisp1_capture *cap = queue->drv_priv;
   918		struct media_entity *entity = &cap->vnode.vdev.entity;
   919		int ret;
   920	
   921		ret = rkisp1_dummy_buf_create(cap);
   922		if (ret)
   923			goto err_ret_buffers;
   924	
   925		ret = pm_runtime_get_sync(cap->rkisp1->dev);
   926		if (ret) {
   927			dev_err(cap->rkisp1->dev, "power up failed %d\n", ret);
   928			goto err_destroy_dummy;
   929		}
   930		ret = v4l2_pipeline_pm_get(entity);
   931		if (ret) {
   932			dev_err(cap->rkisp1->dev, "open cif pipeline failed %d\n", ret);
   933			goto err_pipe_pm_put;
   934		}
   935	
   936		rkisp1_stream_start(cap);
   937	
   938		/* start sub-devices */
   939		ret = v4l2_pipeline_stream_enable(&cap->vnode.vdev);
   940		if (ret)
   941			goto err_stop_stream;
   942	
   943		ret = media_pipeline_start(entity, &cap->rkisp1->pipe);
   944		if (ret) {
   945			dev_err(cap->rkisp1->dev, "start pipeline failed %d\n", ret);
   946			goto err_pipe_disable;
   947		}
   948	
   949		return 0;
   950	
   951	err_pipe_disable:
 > 952		v4l2_pipeline_stream_disable(entity, &cap->rkisp1->pipe);
   953	err_stop_stream:
   954		rkisp1_stream_stop(cap);
   955		v4l2_pipeline_pm_put(entity);
   956	err_pipe_pm_put:
   957		pm_runtime_put(cap->rkisp1->dev);
   958	err_destroy_dummy:
   959		rkisp1_dummy_buf_destroy(cap);
   960	err_ret_buffers:
   961		rkisp1_return_all_buffers(cap, VB2_BUF_STATE_QUEUED);
   962	
   963		return ret;
   964	}
   965	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Niklas Söderlund April 7, 2020, 7:34 p.m. UTC | #2
Hi Helen,

Thanks for your work.

On 2020-04-03 18:33:11 -0300, Helen Koike wrote:
> Use v4l2_pipeline_stream_{enable,disable} to call .s_stream() subdevice
> callbacks through the pipeline.
> 
> Tested by streaming on RockPi4 with imx219 and on Scarlet Chromebook.
> 
> Signed-off-by: Helen Koike <helen.koike@collabora.com>
> 
> ---
> 
> Changes in v2:
> - rebase on top of new helpers prototypes
> 
>  drivers/staging/media/rkisp1/rkisp1-capture.c | 76 +------------------
>  1 file changed, 3 insertions(+), 73 deletions(-)
> 
> diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
> index 24fe6a7888aa4..0c2a357c4a12a 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-capture.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
> @@ -838,71 +838,6 @@ static void rkisp1_return_all_buffers(struct rkisp1_capture *cap,
>  	spin_unlock_irqrestore(&cap->buf.lock, flags);
>  }
>  
> -/*
> - * rkisp1_pipeline_sink_walk - Walk through the pipeline and call cb
> - * @from: entity at which to start pipeline walk
> - * @until: entity at which to stop pipeline walk
> - *
> - * Walk the entities chain starting at the pipeline video node and stop
> - * all subdevices in the chain.
> - *
> - * If the until argument isn't NULL, stop the pipeline walk when reaching the
> - * until entity. This is used to disable a partially started pipeline due to a
> - * subdev start error.
> - */
> -static int rkisp1_pipeline_sink_walk(struct media_entity *from,
> -				     struct media_entity *until,
> -				     int (*cb)(struct media_entity *from,
> -					       struct media_entity *curr))
> -{
> -	struct media_entity *entity = from;
> -	struct media_pad *pad;
> -	unsigned int i;
> -	int ret;
> -
> -	while (1) {
> -		pad = NULL;
> -		/* Find remote source pad */
> -		for (i = 0; i < entity->num_pads; i++) {
> -			struct media_pad *spad = &entity->pads[i];
> -
> -			if (!(spad->flags & MEDIA_PAD_FL_SINK))
> -				continue;
> -			pad = media_entity_remote_pad(spad);
> -			if (pad && is_media_entity_v4l2_subdev(pad->entity))
> -				break;
> -		}
> -		if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> -			break;
> -
> -		entity = pad->entity;
> -		if (entity == until)
> -			break;
> -
> -		ret = cb(from, entity);
> -		if (ret)
> -			return ret;
> -	}
> -
> -	return 0;
> -}
> -
> -static int rkisp1_pipeline_disable_cb(struct media_entity *from,
> -				      struct media_entity *curr)
> -{
> -	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(curr);
> -
> -	return v4l2_subdev_call(sd, video, s_stream, false);
> -}
> -
> -static int rkisp1_pipeline_enable_cb(struct media_entity *from,
> -				     struct media_entity *curr)
> -{
> -	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(curr);
> -
> -	return v4l2_subdev_call(sd, video, s_stream, true);
> -}
> -
>  static void rkisp1_stream_stop(struct rkisp1_capture *cap)
>  {
>  	int ret;
> @@ -929,11 +864,7 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
>  
>  	rkisp1_stream_stop(cap);
>  	media_pipeline_stop(&node->vdev.entity);
> -	ret = rkisp1_pipeline_sink_walk(&node->vdev.entity, NULL,
> -					rkisp1_pipeline_disable_cb);
> -	if (ret)
> -		dev_err(rkisp1->dev,
> -			"pipeline stream-off failed error:%d\n", ret);
> +	v4l2_pipeline_stream_disable(&node->vdev);
>  
>  	rkisp1_return_all_buffers(cap, VB2_BUF_STATE_ERROR);
>  
> @@ -1005,8 +936,7 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
>  	rkisp1_stream_start(cap);
>  
>  	/* start sub-devices */
> -	ret = rkisp1_pipeline_sink_walk(entity, NULL,
> -					rkisp1_pipeline_enable_cb);
> +	ret = v4l2_pipeline_stream_enable(&cap->vnode.vdev);
>  	if (ret)
>  		goto err_stop_stream;
>  
> @@ -1019,7 +949,7 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
>  	return 0;
>  
>  err_pipe_disable:
> -	rkisp1_pipeline_sink_walk(entity, NULL, rkisp1_pipeline_disable_cb);
> +	v4l2_pipeline_stream_disable(entity, &cap->rkisp1->pipe);

This does not match the prototype for v4l2_pipeline_stream_disable() or 
am I missing something ?

>  err_stop_stream:
>  	rkisp1_stream_stop(cap);
>  	v4l2_pipeline_pm_put(entity);
> -- 
> 2.26.0
>
Helen Koike April 7, 2020, 8:51 p.m. UTC | #3
On 4/7/20 4:34 PM, Niklas Söderlund wrote:
> Hi Helen,
> 
> Thanks for your work.
> 
> On 2020-04-03 18:33:11 -0300, Helen Koike wrote:
>> Use v4l2_pipeline_stream_{enable,disable} to call .s_stream() subdevice
>> callbacks through the pipeline.
>>
>> Tested by streaming on RockPi4 with imx219 and on Scarlet Chromebook.
>>
>> Signed-off-by: Helen Koike <helen.koike@collabora.com>
>>
>> ---
>>
>> Changes in v2:
>> - rebase on top of new helpers prototypes
>>
>>  drivers/staging/media/rkisp1/rkisp1-capture.c | 76 +------------------
>>  1 file changed, 3 insertions(+), 73 deletions(-)
>>
>> diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
>> index 24fe6a7888aa4..0c2a357c4a12a 100644
>> --- a/drivers/staging/media/rkisp1/rkisp1-capture.c
>> +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
>> @@ -838,71 +838,6 @@ static void rkisp1_return_all_buffers(struct rkisp1_capture *cap,
>>  	spin_unlock_irqrestore(&cap->buf.lock, flags);
>>  }
>>  
>> -/*
>> - * rkisp1_pipeline_sink_walk - Walk through the pipeline and call cb
>> - * @from: entity at which to start pipeline walk
>> - * @until: entity at which to stop pipeline walk
>> - *
>> - * Walk the entities chain starting at the pipeline video node and stop
>> - * all subdevices in the chain.
>> - *
>> - * If the until argument isn't NULL, stop the pipeline walk when reaching the
>> - * until entity. This is used to disable a partially started pipeline due to a
>> - * subdev start error.
>> - */
>> -static int rkisp1_pipeline_sink_walk(struct media_entity *from,
>> -				     struct media_entity *until,
>> -				     int (*cb)(struct media_entity *from,
>> -					       struct media_entity *curr))
>> -{
>> -	struct media_entity *entity = from;
>> -	struct media_pad *pad;
>> -	unsigned int i;
>> -	int ret;
>> -
>> -	while (1) {
>> -		pad = NULL;
>> -		/* Find remote source pad */
>> -		for (i = 0; i < entity->num_pads; i++) {
>> -			struct media_pad *spad = &entity->pads[i];
>> -
>> -			if (!(spad->flags & MEDIA_PAD_FL_SINK))
>> -				continue;
>> -			pad = media_entity_remote_pad(spad);
>> -			if (pad && is_media_entity_v4l2_subdev(pad->entity))
>> -				break;
>> -		}
>> -		if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
>> -			break;
>> -
>> -		entity = pad->entity;
>> -		if (entity == until)
>> -			break;
>> -
>> -		ret = cb(from, entity);
>> -		if (ret)
>> -			return ret;
>> -	}
>> -
>> -	return 0;
>> -}
>> -
>> -static int rkisp1_pipeline_disable_cb(struct media_entity *from,
>> -				      struct media_entity *curr)
>> -{
>> -	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(curr);
>> -
>> -	return v4l2_subdev_call(sd, video, s_stream, false);
>> -}
>> -
>> -static int rkisp1_pipeline_enable_cb(struct media_entity *from,
>> -				     struct media_entity *curr)
>> -{
>> -	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(curr);
>> -
>> -	return v4l2_subdev_call(sd, video, s_stream, true);
>> -}
>> -
>>  static void rkisp1_stream_stop(struct rkisp1_capture *cap)
>>  {
>>  	int ret;
>> @@ -929,11 +864,7 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
>>  
>>  	rkisp1_stream_stop(cap);
>>  	media_pipeline_stop(&node->vdev.entity);
>> -	ret = rkisp1_pipeline_sink_walk(&node->vdev.entity, NULL,
>> -					rkisp1_pipeline_disable_cb);
>> -	if (ret)
>> -		dev_err(rkisp1->dev,
>> -			"pipeline stream-off failed error:%d\n", ret);
>> +	v4l2_pipeline_stream_disable(&node->vdev);
>>  
>>  	rkisp1_return_all_buffers(cap, VB2_BUF_STATE_ERROR);
>>  
>> @@ -1005,8 +936,7 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
>>  	rkisp1_stream_start(cap);
>>  
>>  	/* start sub-devices */
>> -	ret = rkisp1_pipeline_sink_walk(entity, NULL,
>> -					rkisp1_pipeline_enable_cb);
>> +	ret = v4l2_pipeline_stream_enable(&cap->vnode.vdev);
>>  	if (ret)
>>  		goto err_stop_stream;
>>  
>> @@ -1019,7 +949,7 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
>>  	return 0;
>>  
>>  err_pipe_disable:
>> -	rkisp1_pipeline_sink_walk(entity, NULL, rkisp1_pipeline_disable_cb);
>> +	v4l2_pipeline_stream_disable(entity, &cap->rkisp1->pipe);
> 
> This does not match the prototype for v4l2_pipeline_stream_disable() or 
> am I missing something ?

You are right, I must have messed with my branches, because I'm sure I compiled and tested it.

Thanks for catching this.
Helen

> 
>>  err_stop_stream:
>>  	rkisp1_stream_stop(cap);
>>  	v4l2_pipeline_pm_put(entity);
>> -- 
>> 2.26.0
>>
>

Patch
diff mbox series

diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
index 24fe6a7888aa4..0c2a357c4a12a 100644
--- a/drivers/staging/media/rkisp1/rkisp1-capture.c
+++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
@@ -838,71 +838,6 @@  static void rkisp1_return_all_buffers(struct rkisp1_capture *cap,
 	spin_unlock_irqrestore(&cap->buf.lock, flags);
 }
 
-/*
- * rkisp1_pipeline_sink_walk - Walk through the pipeline and call cb
- * @from: entity at which to start pipeline walk
- * @until: entity at which to stop pipeline walk
- *
- * Walk the entities chain starting at the pipeline video node and stop
- * all subdevices in the chain.
- *
- * If the until argument isn't NULL, stop the pipeline walk when reaching the
- * until entity. This is used to disable a partially started pipeline due to a
- * subdev start error.
- */
-static int rkisp1_pipeline_sink_walk(struct media_entity *from,
-				     struct media_entity *until,
-				     int (*cb)(struct media_entity *from,
-					       struct media_entity *curr))
-{
-	struct media_entity *entity = from;
-	struct media_pad *pad;
-	unsigned int i;
-	int ret;
-
-	while (1) {
-		pad = NULL;
-		/* Find remote source pad */
-		for (i = 0; i < entity->num_pads; i++) {
-			struct media_pad *spad = &entity->pads[i];
-
-			if (!(spad->flags & MEDIA_PAD_FL_SINK))
-				continue;
-			pad = media_entity_remote_pad(spad);
-			if (pad && is_media_entity_v4l2_subdev(pad->entity))
-				break;
-		}
-		if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
-			break;
-
-		entity = pad->entity;
-		if (entity == until)
-			break;
-
-		ret = cb(from, entity);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-
-static int rkisp1_pipeline_disable_cb(struct media_entity *from,
-				      struct media_entity *curr)
-{
-	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(curr);
-
-	return v4l2_subdev_call(sd, video, s_stream, false);
-}
-
-static int rkisp1_pipeline_enable_cb(struct media_entity *from,
-				     struct media_entity *curr)
-{
-	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(curr);
-
-	return v4l2_subdev_call(sd, video, s_stream, true);
-}
-
 static void rkisp1_stream_stop(struct rkisp1_capture *cap)
 {
 	int ret;
@@ -929,11 +864,7 @@  static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
 
 	rkisp1_stream_stop(cap);
 	media_pipeline_stop(&node->vdev.entity);
-	ret = rkisp1_pipeline_sink_walk(&node->vdev.entity, NULL,
-					rkisp1_pipeline_disable_cb);
-	if (ret)
-		dev_err(rkisp1->dev,
-			"pipeline stream-off failed error:%d\n", ret);
+	v4l2_pipeline_stream_disable(&node->vdev);
 
 	rkisp1_return_all_buffers(cap, VB2_BUF_STATE_ERROR);
 
@@ -1005,8 +936,7 @@  rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
 	rkisp1_stream_start(cap);
 
 	/* start sub-devices */
-	ret = rkisp1_pipeline_sink_walk(entity, NULL,
-					rkisp1_pipeline_enable_cb);
+	ret = v4l2_pipeline_stream_enable(&cap->vnode.vdev);
 	if (ret)
 		goto err_stop_stream;
 
@@ -1019,7 +949,7 @@  rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
 	return 0;
 
 err_pipe_disable:
-	rkisp1_pipeline_sink_walk(entity, NULL, rkisp1_pipeline_disable_cb);
+	v4l2_pipeline_stream_disable(entity, &cap->rkisp1->pipe);
 err_stop_stream:
 	rkisp1_stream_stop(cap);
 	v4l2_pipeline_pm_put(entity);