diff mbox series

[v3,1/2] rcar-vin: Stop stream when subdevice signal EOS

Message ID 20210310164527.3631395-2-niklas.soderlund+renesas@ragnatech.se
State New
Headers show
Series rcar-csi2: Update handling of transfer error | expand

Commit Message

Niklas Söderlund March 10, 2021, 4:45 p.m. UTC
When a subdevice signals end of stream stop the VIN in addition to
informing user-space of the event.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
* Changes since v2
- Log using vin_dbg() instead of v4l2_info().
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Hans Verkuil March 16, 2021, 8:11 a.m. UTC | #1
Hi Niklas,

On 10/03/2021 17:45, Niklas Söderlund wrote:
> When a subdevice signals end of stream stop the VIN in addition to

> informing user-space of the event.

> 

> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

> ---

> * Changes since v2

> - Log using vin_dbg() instead of v4l2_info().

> ---

>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 16 +++++++++++++++-

>  1 file changed, 15 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c

> index 457a65bf6b664f05..76f6f46799e95791 100644

> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c

> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c

> @@ -969,9 +969,23 @@ void rvin_v4l2_unregister(struct rvin_dev *vin)

>  static void rvin_notify_video_device(struct rvin_dev *vin,

>  				     unsigned int notification, void *arg)

>  {

> +	const struct v4l2_event *event;

> +

>  	switch (notification) {

>  	case V4L2_DEVICE_NOTIFY_EVENT:

> -		v4l2_event_queue(&vin->vdev, arg);

> +		event = arg;

> +

> +		switch (event->type) {

> +		case V4L2_EVENT_EOS:


This is not the right event for this. EVENT_EOS is specific to codecs and does
not signal an error condition.

I think we need a new event for this, I've seen similar situations with HDMI
receivers. The SOURCE_CHANGE event was (ab)used for that, but I think a new
event (V4L2_EVENT_XFER_ERROR?) should be created for these situations.

> +			rvin_stop_streaming(vin);


In addition to this you should call vb2_queue_error(), that's typically used
in situations where there is an unrecoverable transfer error.

Regards,

	Hans

> +			vin_dbg(vin,

> +				"Subdevice signaled end of stream, stopping.\n");

> +			break;

> +		default:

> +			break;

> +		}

> +

> +		v4l2_event_queue(&vin->vdev, event);

>  		break;

>  	default:

>  		break;

>
diff mbox series

Patch

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 457a65bf6b664f05..76f6f46799e95791 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -969,9 +969,23 @@  void rvin_v4l2_unregister(struct rvin_dev *vin)
 static void rvin_notify_video_device(struct rvin_dev *vin,
 				     unsigned int notification, void *arg)
 {
+	const struct v4l2_event *event;
+
 	switch (notification) {
 	case V4L2_DEVICE_NOTIFY_EVENT:
-		v4l2_event_queue(&vin->vdev, arg);
+		event = arg;
+
+		switch (event->type) {
+		case V4L2_EVENT_EOS:
+			rvin_stop_streaming(vin);
+			vin_dbg(vin,
+				"Subdevice signaled end of stream, stopping.\n");
+			break;
+		default:
+			break;
+		}
+
+		v4l2_event_queue(&vin->vdev, event);
 		break;
 	default:
 		break;