/* This function implements video queue polling and is intended to be used by the device poll handler.  */
unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file, poll_table *wait)
/* This function implements video queue polling and is intended to be used by the device poll handler.  */
unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file, poll_table *wait)
{
	struct uvc_buffer *buf;
	unsigned int mask = 0;
	mutex_lock(&queue->mutex);
	if (list_empty(&queue->mainqueue)) {
		mask |= POLLERR;
		goto done;
	}
	buf = list_first_entry(&queue->mainqueue, struct uvc_buffer, stream);
	poll_wait(file, &buf->wait, wait);
	if (buf->state == UVC_BUF_STATE_DONE ||
	    buf->state == UVC_BUF_STATE_ERROR)
		mask |= POLLIN | POLLRDNORM;
done:
	mutex_unlock(&queue->mutex);
	return mask;
}