diff mbox

[27/26] v4l: vb2: Set data_offset to 0 for single-plane buffers

Message ID 1352376336-5404-1-git-send-email-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Pinchart Nov. 8, 2012, 12:05 p.m. UTC
Single-planar V4L2 buffers are converted to multi-planar vb2 buffers
with a single plane when queued. The plane data_offset field is not
available in the single-planar API and must be set to 0 for dmabuf
buffers and all output buffers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/v4l2-core/videobuf2-core.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Marek Szyprowski Nov. 8, 2012, 12:13 p.m. UTC | #1
Hello,

On 11/8/2012 1:05 PM, Laurent Pinchart wrote:
> Single-planar V4L2 buffers are converted to multi-planar vb2 buffers
> with a single plane when queued. The plane data_offset field is not
> available in the single-planar API and must be set to 0 for dmabuf
> buffers and all output buffers.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   drivers/media/v4l2-core/videobuf2-core.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index b0402f2..3eae3d8 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -931,6 +931,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b,
>   		 */
>   		if (V4L2_TYPE_IS_OUTPUT(b->type))
>   			v4l2_planes[0].bytesused = b->bytesused;
> +			v4l2_planes[0].data_offset = 0;
>   
>   		if (b->memory == V4L2_MEMORY_USERPTR) {
>   			v4l2_planes[0].m.userptr = b->m.userptr;
> @@ -940,6 +941,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b,
>   		if (b->memory == V4L2_MEMORY_DMABUF) {
>   			v4l2_planes[0].m.fd = b->m.fd;
>   			v4l2_planes[0].length = b->length;
> +			v4l2_planes[0].data_offset = 0;
>   		}
>   
>   	}

Best regards
Laurent Pinchart Nov. 8, 2012, 12:19 p.m. UTC | #2
Hello,

On Thursday 08 November 2012 13:13:50 Marek Szyprowski wrote:
> On 11/8/2012 1:05 PM, Laurent Pinchart wrote:
> > Single-planar V4L2 buffers are converted to multi-planar vb2 buffers
> > with a single plane when queued. The plane data_offset field is not
> > available in the single-planar API and must be set to 0 for dmabuf
> > buffers and all output buffers.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

Thank you.

Tomasz, could you please take this in your dma-buf branch ? Sorry for 
forgetting to CC you on the patch.

> > ---
> > 
> >   drivers/media/v4l2-core/videobuf2-core.c |    2 ++
> >   1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/videobuf2-core.c
> > b/drivers/media/v4l2-core/videobuf2-core.c index b0402f2..3eae3d8 100644
> > --- a/drivers/media/v4l2-core/videobuf2-core.c
> > +++ b/drivers/media/v4l2-core/videobuf2-core.c
> > @@ -931,6 +931,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
> > const struct v4l2_buffer *b,> 
> >   		 */
> >   		
> >   		if (V4L2_TYPE_IS_OUTPUT(b->type))
> >   		
> >   			v4l2_planes[0].bytesused = b->bytesused;
> > 
> > +			v4l2_planes[0].data_offset = 0;
> > 
> >   		if (b->memory == V4L2_MEMORY_USERPTR) {
> >   		
> >   			v4l2_planes[0].m.userptr = b->m.userptr;
> > 
> > @@ -940,6 +941,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
> > const struct v4l2_buffer *b,> 
> >   		if (b->memory == V4L2_MEMORY_DMABUF) {
> >   		
> >   			v4l2_planes[0].m.fd = b->m.fd;
> >   			v4l2_planes[0].length = b->length;
> > 
> > +			v4l2_planes[0].data_offset = 0;
> > 
> >   		}
> >   	
> >   	}
Tomasz Stanislawski Nov. 8, 2012, 3:28 p.m. UTC | #3
Hi Laurent,
The fix was partially applied in "[PATCHv10 03/26] v4l: vb2: add support for shared buffer (dma_buf)".
The data_offset is set to 0 for DMABUF capture/output for single-planar API.

We should define the meaning of data_offset in case of USERPTR and MMAP buffers.
For output device it is pretty intuitive.

For DMABUF capture devices data_offset maybe used to inform a driver to
capture the image at some offset inside the DMABUF buffer.

BTW. Should {} be added after "if (V4L2_TYPE_IS_OUTPUT(b->type))"
to avoid 'interesting' behavior? :)

Regards,
Tomasz Stanislawski


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart Nov. 8, 2012, 4:36 p.m. UTC | #4
Hi Tomasz,

On Thursday 08 November 2012 16:28:12 Tomasz Stanislawski wrote:
> Hi Laurent,
> The fix was partially applied in "[PATCHv10 03/26] v4l: vb2: add support for
> shared buffer (dma_buf)". The data_offset is set to 0 for DMABUF
> capture/output for single-planar API.

My bad, I had an old version of your patch set in my git tree. The other half 
of the patch should still be applied, but it can go through Mauro's tree 
without going through yours.

> We should define the meaning of data_offset in case of USERPTR and MMAP
> buffers. For output device it is pretty intuitive.
> 
> For DMABUF capture devices data_offset maybe used to inform a driver to
> capture the image at some offset inside the DMABUF buffer.

That's indeed missing from the documentation.

> BTW. Should {} be added after "if (V4L2_TYPE_IS_OUTPUT(b->type))"
> to avoid 'interesting' behavior? :)

Oops :-) I'll fix that.
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index b0402f2..3eae3d8 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -931,6 +931,7 @@  static int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b,
 		 */
 		if (V4L2_TYPE_IS_OUTPUT(b->type))
 			v4l2_planes[0].bytesused = b->bytesused;
+			v4l2_planes[0].data_offset = 0;
 
 		if (b->memory == V4L2_MEMORY_USERPTR) {
 			v4l2_planes[0].m.userptr = b->m.userptr;
@@ -940,6 +941,7 @@  static int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b,
 		if (b->memory == V4L2_MEMORY_DMABUF) {
 			v4l2_planes[0].m.fd = b->m.fd;
 			v4l2_planes[0].length = b->length;
+			v4l2_planes[0].data_offset = 0;
 		}
 
 	}