/* em28xx_v4l2_poll() will allocate buffers when called for the first time  */
static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table *wait)
/* em28xx_v4l2_poll() will allocate buffers when called for the first time  */
static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table *wait)
{
	struct em28xx_fh *fh = filp->private_data;
	struct em28xx *dev = fh->dev;
	int rc;
	rc = check_dev(dev);
	if (rc < 0)
		return rc;
	if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
		if (!res_get(fh, EM28XX_RESOURCE_VIDEO))
			return POLLERR;
		return videobuf_poll_stream(filp, &fh->vb_vidq, wait);
	} else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
		if (!res_get(fh, EM28XX_RESOURCE_VBI))
			return POLLERR;
		return videobuf_poll_stream(filp, &fh->vb_vbiq, wait);
	} else {
		return POLLERR;
	}
}