diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-04-17 06:44:31 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-05-23 14:16:53 -0300 |
commit | a3f415abe08552ece58f3ada553482423296c46a (patch) | |
tree | ec0a2797ed54ffc4468f7e531daaffd7f5049aee /drivers/media/pci/saa7134/saa7134-video.c | |
parent | 2ada815fc48bb0267876c2c24b275bd06485f746 (diff) |
[media] saa7134: add saa7134_userptr module option to enable USERPTR
If the saa7134 module is loaded with the saa7134_userptr set to 1,
then USERPTR support is enabled. A check in buffer_prepare
verifies that the pointer is page-aligned.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/pci/saa7134/saa7134-video.c')
-rw-r--r-- | drivers/media/pci/saa7134/saa7134-video.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 1f63f95c9a8..f1452da0a76 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -885,6 +885,10 @@ static int buffer_prepare(struct vb2_buffer *vb2) unsigned int size; int ret; + if (dma->sgl->offset) { + pr_err("The buffer is not page-aligned\n"); + return -EINVAL; + } size = (dev->width * dev->height * dev->fmt->depth) >> 3; if (vb2_plane_size(vb2, 0) < size) return -EINVAL; @@ -2092,11 +2096,15 @@ int saa7134_video_init1(struct saa7134_dev *dev) q = &dev->video_vbq; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; /* - * Do not add VB2_USERPTR: the saa7134 DMA engine cannot handle - * transfers that do not start at the beginning of a page. A USERPTR - * can start anywhere in a page, so USERPTR support is a no-go. + * Do not add VB2_USERPTR unless explicitly requested: the saa7134 DMA + * engine cannot handle transfers that do not start at the beginning + * of a page. A user-provided pointer can start anywhere in a page, so + * USERPTR support is a no-go unless the application knows about these + * limitations and has special support for this. */ q->io_modes = VB2_MMAP | VB2_READ; + if (saa7134_userptr) + q->io_modes |= VB2_USERPTR; q->drv_priv = &dev->video_q; q->ops = &vb2_qops; q->gfp_flags = GFP_DMA32; @@ -2113,6 +2121,8 @@ int saa7134_video_init1(struct saa7134_dev *dev) q->type = V4L2_BUF_TYPE_VBI_CAPTURE; /* Don't add VB2_USERPTR, see comment above */ q->io_modes = VB2_MMAP | VB2_READ; + if (saa7134_userptr) + q->io_modes |= VB2_USERPTR; q->drv_priv = &dev->vbi_q; q->ops = &saa7134_vbi_qops; q->gfp_flags = GFP_DMA32; |