From: Hans Verkuil Date: Sun, 10 Feb 2013 17:37:58 +0000 (-0300) Subject: [media] stk-webcam: implement support for count == 0 when calling REQBUFS X-Git-Tag: firefly_0821_release~3680^2~618^2~561 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9776e17189d33b0ac9235597460d6a22cf1bc6a7;p=firefly-linux-kernel-4.4.55.git [media] stk-webcam: implement support for count == 0 when calling REQBUFS The spec specifies that setting count to 0 in v4l2_requestbuffers should result in releasing any streaming resources and the stream ownership. Implement this. Signed-off-by: Hans Verkuil Tested-by: Arvydas Sidorenko Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c index 45d73e2f3e57..c43c8d32be40 100644 --- a/drivers/media/usb/stkwebcam/stk-webcam.c +++ b/drivers/media/usb/stkwebcam/stk-webcam.c @@ -1046,6 +1046,13 @@ static int stk_vidioc_reqbufs(struct file *filp, if (is_streaming(dev) || (dev->owner && dev->owner != filp)) return -EBUSY; + stk_free_buffers(dev); + if (rb->count == 0) { + stk_camera_write_reg(dev, 0x0, 0x49); /* turn off the LED */ + unset_initialised(dev); + dev->owner = NULL; + return 0; + } dev->owner = filp; /*FIXME If they ask for zero, we must stop streaming and free */