]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pwc: poll(): Check that the device has not beem claimed for streaming already
authorHans de Goede <hdegoede@redhat.com>
Sun, 9 Oct 2011 13:28:27 +0000 (15:28 +0200)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 8 Nov 2011 19:27:10 +0000 (17:27 -0200)
Some apps which use read() start the streaming through a call to poll(),
this means that if another app has already claimed the device for streaming
(through for example a s_fmt, or a reqbufs), that the poll should fail instead
of getting passed through to vb2_poll.

We only check for this when the app is polling for reads, so that ctrl events
still work.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/pwc/pwc-if.c

index 550ad071a07387610d310f750ca4676be0207c01..6ff981bfa38e3e50b0a7be3f75956e301da18629 100644 (file)
@@ -710,10 +710,19 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
 static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
 {
        struct pwc_device *pdev = video_drvdata(file);
+       unsigned long req_events = poll_requested_events(wait);
 
        if (!pdev->udev)
                return POLL_ERR;
 
+       if ((req_events & (POLLIN | POLLRDNORM)) &&
+           pdev->vb_queue.num_buffers == 0 &&
+           !pdev->iso_init) {
+               /* This poll will start a read stream, check capt_file */
+               if (pwc_test_n_set_capt_file(pdev, file))
+                       return POLL_ERR;
+       }
+
        return vb2_poll(&pdev->vb_queue, file, wait);
 }