diff options
author | Lad, Prabhakar <prabhakar.csengg@gmail.com> | 2014-05-16 10:33:11 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-05-23 19:02:33 -0300 |
commit | 27cdf9ba1f7dd12709a1fbdbab65a807a5f76657 (patch) | |
tree | dfd3b7ecd38a97b18781d8e5c91c7d89780c3255 /drivers/media/platform/davinci/vpif_display.c | |
parent | cde27a338a3d25015100bd6d94589b1fb7545250 (diff) | |
download | linux-stable-27cdf9ba1f7dd12709a1fbdbab65a807a5f76657.tar.gz linux-stable-27cdf9ba1f7dd12709a1fbdbab65a807a5f76657.tar.bz2 linux-stable-27cdf9ba1f7dd12709a1fbdbab65a807a5f76657.zip |
[media] media: davinci: vpif_display: improve vpif_buffer_prepare() callback
this patch improve vpif_buffer_prepare() callback, as buf_prepare()
callback is never called with invalid state and check for
vb2_plane_vaddr(vb, 0) is dropped as payload check should
be done unconditionally.
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/platform/davinci/vpif_display.c')
-rw-r--r-- | drivers/media/platform/davinci/vpif_display.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 9999b9c9cec0..1c518de9571d 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -67,41 +67,40 @@ static struct device *vpif_dev; static void vpif_calculate_offsets(struct channel_obj *ch); static void vpif_config_addr(struct channel_obj *ch, int muxmode); -/* - * buffer_prepare: This is the callback function called from vb2_qbuf() - * function the buffer is prepared and user space virtual address is converted - * into physical address +/** + * vpif_buffer_prepare : callback function for buffer prepare + * @vb: ptr to vb2_buffer + * + * This is the callback function for buffer prepare when vb2_qbuf() + * function is called. The buffer is prepared and user space virtual address + * or user address is converted into physical address */ static int vpif_buffer_prepare(struct vb2_buffer *vb) { - struct vb2_queue *q = vb->vb2_queue; - struct channel_obj *ch = vb2_get_drv_priv(q); + struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue); struct common_obj *common; - unsigned long addr; common = &ch->common[VPIF_VIDEO_INDEX]; - if (vb->state != VB2_BUF_STATE_ACTIVE && - vb->state != VB2_BUF_STATE_PREPARED) { - vb2_set_plane_payload(vb, 0, common->fmt.fmt.pix.sizeimage); - if (vb2_plane_vaddr(vb, 0) && - vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) - goto buf_align_exit; - - addr = vb2_dma_contig_plane_dma_addr(vb, 0); - if (q->streaming && - (V4L2_BUF_TYPE_SLICED_VBI_OUTPUT != q->type)) { - if (!ISALIGNED(addr + common->ytop_off) || + + vb2_set_plane_payload(vb, 0, common->fmt.fmt.pix.sizeimage); + if (vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) + return -EINVAL; + + vb->v4l2_buf.field = common->fmt.fmt.pix.field; + + if (vb->vb2_queue->type != V4L2_BUF_TYPE_SLICED_VBI_OUTPUT) { + unsigned long addr = vb2_dma_contig_plane_dma_addr(vb, 0); + + if (!ISALIGNED(addr + common->ytop_off) || !ISALIGNED(addr + common->ybtm_off) || !ISALIGNED(addr + common->ctop_off) || - !ISALIGNED(addr + common->cbtm_off)) - goto buf_align_exit; + !ISALIGNED(addr + common->cbtm_off)) { + vpif_err("buffer offset not aligned to 8 bytes\n"); + return -EINVAL; } } - return 0; -buf_align_exit: - vpif_err("buffer offset not aligned to 8 bytes\n"); - return -EINVAL; + return 0; } /* |