diff mbox

[RFCv1,3/6] videobuf2: only start streaming in poll() if so requested by the poll mask.

Message ID 7fc8ed81f08a0ac8092c5b6a8badc3427df9bc1e.1310549521.git.hans.verkuil@cisco.com (mailing list archive)
State RFC
Headers show

Commit Message

Hans Verkuil July 13, 2011, 9:39 a.m. UTC
From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/video/videobuf2-core.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Comments

Marek Szyprowski July 18, 2011, 6:30 a.m. UTC | #1
Hello,

On Wednesday, July 13, 2011 11:39 AM Hans Verkuil wrote:

> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>  drivers/media/video/videobuf2-core.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/video/videobuf2-core.c
> b/drivers/media/video/videobuf2-core.c
> index 3015e60..1892bb8 100644
> --- a/drivers/media/video/videobuf2-core.c
> +++ b/drivers/media/video/videobuf2-core.c
> @@ -1365,6 +1365,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q);
>   */
>  unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table
> *wait)
>  {
> +	unsigned long req_events = poll_requested_events(wait);
>  	unsigned long flags;
>  	unsigned int ret;
>  	struct vb2_buffer *vb = NULL;
> @@ -1373,12 +1374,14 @@ unsigned int vb2_poll(struct vb2_queue *q, struct
> file *file, poll_table *wait)
>  	 * Start file I/O emulator only if streaming API has not been used
> yet.
>  	 */
>  	if (q->num_buffers == 0 && q->fileio == NULL) {
> -		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ))
> {
> +		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)
> &&
> +				(req_events & (POLLIN | POLLRDNORM))) {
>  			ret = __vb2_init_fileio(q, 1);
>  			if (ret)
>  				return POLLERR;
>  		}
> -		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE))
> {
> +		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)
> &&
> +				(req_events & (POLLOUT | POLLWRNORM))) {
>  			ret = __vb2_init_fileio(q, 0);
>  			if (ret)
>  				return POLLERR;
> --

Best regards
Pawel Osciak July 20, 2011, 3:41 a.m. UTC | #2
Hi Hans,

On Sun, Jul 17, 2011 at 23:30, Marek Szyprowski
<m.szyprowski@samsung.com> wrote:
> Hello,
>
> On Wednesday, July 13, 2011 11:39 AM Hans Verkuil wrote:
>
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>
> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
>

Acked-by: Pawel Osciak <pawel@osciak.com>

I have to say, this is cool stuff!
Pawel

>> ---
>>  drivers/media/video/videobuf2-core.c |    7 +++++--
>>  1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/video/videobuf2-core.c
>> b/drivers/media/video/videobuf2-core.c
>> index 3015e60..1892bb8 100644
>> --- a/drivers/media/video/videobuf2-core.c
>> +++ b/drivers/media/video/videobuf2-core.c
>> @@ -1365,6 +1365,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q);
>>   */
>>  unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table
>> *wait)
>>  {
>> +     unsigned long req_events = poll_requested_events(wait);
>>       unsigned long flags;
>>       unsigned int ret;
>>       struct vb2_buffer *vb = NULL;
>> @@ -1373,12 +1374,14 @@ unsigned int vb2_poll(struct vb2_queue *q, struct
>> file *file, poll_table *wait)
>>        * Start file I/O emulator only if streaming API has not been used
>> yet.
>>        */
>>       if (q->num_buffers == 0 && q->fileio == NULL) {
>> -             if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ))
>> {
>> +             if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)
>> &&
>> +                             (req_events & (POLLIN | POLLRDNORM))) {
>>                       ret = __vb2_init_fileio(q, 1);
>>                       if (ret)
>>                               return POLLERR;
>>               }
>> -             if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE))
>> {
>> +             if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)
>> &&
>> +                             (req_events & (POLLOUT | POLLWRNORM))) {
>>                       ret = __vb2_init_fileio(q, 0);
>>                       if (ret)
>>                               return POLLERR;
>> --
>
> Best regards
> --
> Marek Szyprowski
> Samsung Poland R&D Center
>
>
>
>
diff mbox

Patch

diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index 3015e60..1892bb8 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -1365,6 +1365,7 @@  static int __vb2_cleanup_fileio(struct vb2_queue *q);
  */
 unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 {
+	unsigned long req_events = poll_requested_events(wait);
 	unsigned long flags;
 	unsigned int ret;
 	struct vb2_buffer *vb = NULL;
@@ -1373,12 +1374,14 @@  unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 	 * Start file I/O emulator only if streaming API has not been used yet.
 	 */
 	if (q->num_buffers == 0 && q->fileio == NULL) {
-		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)) {
+		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) &&
+				(req_events & (POLLIN | POLLRDNORM))) {
 			ret = __vb2_init_fileio(q, 1);
 			if (ret)
 				return POLLERR;
 		}
-		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) {
+		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE) &&
+				(req_events & (POLLOUT | POLLWRNORM))) {
 			ret = __vb2_init_fileio(q, 0);
 			if (ret)
 				return POLLERR;