diff mbox series

[v2] au0828: stop video streaming only when last user stops

Message ID 4f9f2e84-f053-b84d-b3c7-6abe22bddf5d@xs4all.nl (mailing list archive)
State New, archived
Headers show
Series [v2] au0828: stop video streaming only when last user stops | expand

Commit Message

Hans Verkuil April 2, 2019, 7:24 a.m. UTC
If the application was streaming from both videoX and vbiX, and streaming
from videoX was stopped, then the vbi streaming also stopped.

The cause being that stop_streaming for video stopped the subdevs as well,
instead of only doing that if dev->streaming_users reached 0.

au0828_stop_vbi_streaming was also wrong since it didn't stop the subdevs
at all when dev->streaming_users reached 0.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
Change since v1: v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 1)
was done for video only, not for vbi. This is obviously wrong when starting
vbi first, but also caused weird behavior since attempting to start a second
vbi capture would stop the first.
---

Comments

Shuah April 2, 2019, 2:36 p.m. UTC | #1
On 4/2/19 1:24 AM, Hans Verkuil wrote:
> If the application was streaming from both videoX and vbiX, and streaming
> from videoX was stopped, then the vbi streaming also stopped.
> 
> The cause being that stop_streaming for video stopped the subdevs as well,
> instead of only doing that if dev->streaming_users reached 0.
> 
> au0828_stop_vbi_streaming was also wrong since it didn't stop the subdevs
> at all when dev->streaming_users reached 0.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
> Change since v1: v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 1)
> was done for video only, not for vbi. This is obviously wrong when starting
> vbi first, but also caused weird behavior since attempting to start a second
> vbi capture would stop the first.
> ---

Looks good. Attempting to start the second VBI stream capture doesn't
stop the active VBI stream.

Tested-by: Shuah Khan <shuah@kernel.org>

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 536bd8bbb624..4bde3db83aa2 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -842,9 +842,9 @@  int au0828_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
 			return rc;
 		}

+		v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 1);
+
 		if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-			v4l2_device_call_all(&dev->v4l2_dev, 0, video,
-						s_stream, 1);
 			dev->vid_timeout_running = 1;
 			mod_timer(&dev->vid_timeout, jiffies + (HZ / 10));
 		} else if (vq->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
@@ -864,10 +864,11 @@  static void au0828_stop_streaming(struct vb2_queue *vq)

 	dprintk(1, "au0828_stop_streaming called %d\n", dev->streaming_users);

-	if (dev->streaming_users-- == 1)
+	if (dev->streaming_users-- == 1) {
 		au0828_uninit_isoc(dev);
+		v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
+	}

-	v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
 	dev->vid_timeout_running = 0;
 	del_timer_sync(&dev->vid_timeout);

@@ -896,8 +897,10 @@  void au0828_stop_vbi_streaming(struct vb2_queue *vq)
 	dprintk(1, "au0828_stop_vbi_streaming called %d\n",
 		dev->streaming_users);

-	if (dev->streaming_users-- == 1)
+	if (dev->streaming_users-- == 1) {
 		au0828_uninit_isoc(dev);
+		v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
+	}

 	spin_lock_irqsave(&dev->slock, flags);
 	if (dev->isoc_ctl.vbi_buf != NULL) {