Commit a3f415ab authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 2ada815f
...@@ -69,6 +69,10 @@ module_param_named(no_overlay, saa7134_no_overlay, int, 0444); ...@@ -69,6 +69,10 @@ module_param_named(no_overlay, saa7134_no_overlay, int, 0444);
MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)" MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
" [some VIA/SIS chipsets are known to have problem with overlay]"); " [some VIA/SIS chipsets are known to have problem with overlay]");
bool saa7134_userptr;
module_param(saa7134_userptr, bool, 0644);
MODULE_PARM_DESC(saa7134_userptr, "enable page-aligned userptr support");
static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
......
...@@ -122,6 +122,10 @@ static int buffer_prepare(struct vb2_buffer *vb2) ...@@ -122,6 +122,10 @@ static int buffer_prepare(struct vb2_buffer *vb2)
unsigned int size; unsigned int size;
int ret; int ret;
if (dma->sgl->offset) {
pr_err("The buffer is not page-aligned\n");
return -EINVAL;
}
size = dev->vbi_hlen * dev->vbi_vlen * 2; size = dev->vbi_hlen * dev->vbi_vlen * 2;
if (vb2_plane_size(vb2, 0) < size) if (vb2_plane_size(vb2, 0) < size)
return -EINVAL; return -EINVAL;
......
...@@ -885,6 +885,10 @@ static int buffer_prepare(struct vb2_buffer *vb2) ...@@ -885,6 +885,10 @@ static int buffer_prepare(struct vb2_buffer *vb2)
unsigned int size; unsigned int size;
int ret; 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; size = (dev->width * dev->height * dev->fmt->depth) >> 3;
if (vb2_plane_size(vb2, 0) < size) if (vb2_plane_size(vb2, 0) < size)
return -EINVAL; return -EINVAL;
...@@ -2092,11 +2096,15 @@ int saa7134_video_init1(struct saa7134_dev *dev) ...@@ -2092,11 +2096,15 @@ int saa7134_video_init1(struct saa7134_dev *dev)
q = &dev->video_vbq; q = &dev->video_vbq;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
/* /*
* Do not add VB2_USERPTR: the saa7134 DMA engine cannot handle * Do not add VB2_USERPTR unless explicitly requested: the saa7134 DMA
* transfers that do not start at the beginning of a page. A USERPTR * engine cannot handle transfers that do not start at the beginning
* can start anywhere in a page, so USERPTR support is a no-go. * 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; q->io_modes = VB2_MMAP | VB2_READ;
if (saa7134_userptr)
q->io_modes |= VB2_USERPTR;
q->drv_priv = &dev->video_q; q->drv_priv = &dev->video_q;
q->ops = &vb2_qops; q->ops = &vb2_qops;
q->gfp_flags = GFP_DMA32; q->gfp_flags = GFP_DMA32;
...@@ -2113,6 +2121,8 @@ int saa7134_video_init1(struct saa7134_dev *dev) ...@@ -2113,6 +2121,8 @@ int saa7134_video_init1(struct saa7134_dev *dev)
q->type = V4L2_BUF_TYPE_VBI_CAPTURE; q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
/* Don't add VB2_USERPTR, see comment above */ /* Don't add VB2_USERPTR, see comment above */
q->io_modes = VB2_MMAP | VB2_READ; q->io_modes = VB2_MMAP | VB2_READ;
if (saa7134_userptr)
q->io_modes |= VB2_USERPTR;
q->drv_priv = &dev->vbi_q; q->drv_priv = &dev->vbi_q;
q->ops = &saa7134_vbi_qops; q->ops = &saa7134_vbi_qops;
q->gfp_flags = GFP_DMA32; q->gfp_flags = GFP_DMA32;
......
...@@ -714,6 +714,7 @@ static inline bool is_empress(struct file *file) ...@@ -714,6 +714,7 @@ static inline bool is_empress(struct file *file)
extern struct list_head saa7134_devlist; extern struct list_head saa7134_devlist;
extern struct mutex saa7134_devlist_lock; extern struct mutex saa7134_devlist_lock;
extern int saa7134_no_overlay; extern int saa7134_no_overlay;
extern bool saa7134_userptr;
void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);
void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment