All of lore.kernel.org
 help / color / mirror / Atom feed
* v4l2_buffer with PBO mapped memory
@ 2014-04-02 15:10 Thomas Scheuermann
  2014-04-02 19:23 ` Laurent Pinchart
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Scheuermann @ 2014-04-02 15:10 UTC (permalink / raw)
  To: linux-media

Hello,

I've written a program which shows my webcam with the v4l2 interface.
In the v4l2_buffer I use the type V4L2_BUF_TYPE_VIDEO_CAPTURE and the
memory is V4L2_MEMORY_USERPTR.
Everything works if I use malloced memory for frame buffers.
Now I want to get the frames directly in OpenGL. I've mapped a pixel
buffer object with glMapBuffer and wanted to use this as a frame buffer.
But if I use this memory, the ioctl VIDIOC_QBUF fails with 'invalid
argument'.

What can I do to use the pixel buffer object together with the v4l2
interface?
I want to use as less copy steps as possible.

Regards,

Thomas
This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: v4l2_buffer with PBO mapped memory
  2014-04-02 15:10 v4l2_buffer with PBO mapped memory Thomas Scheuermann
@ 2014-04-02 19:23 ` Laurent Pinchart
  2014-04-03 16:52   ` AW: " Scheuermann, Mail
  0 siblings, 1 reply; 9+ messages in thread
From: Laurent Pinchart @ 2014-04-02 19:23 UTC (permalink / raw)
  To: Thomas Scheuermann; +Cc: linux-media

Hi Thomas,

On Wednesday 02 April 2014 17:10:42 Thomas Scheuermann wrote:
> Hello,
> 
> I've written a program which shows my webcam with the v4l2 interface.
> In the v4l2_buffer I use the type V4L2_BUF_TYPE_VIDEO_CAPTURE and the
> memory is V4L2_MEMORY_USERPTR.
> Everything works if I use malloced memory for frame buffers.
> Now I want to get the frames directly in OpenGL. I've mapped a pixel
> buffer object with glMapBuffer and wanted to use this as a frame buffer.
> But if I use this memory, the ioctl VIDIOC_QBUF fails with 'invalid
> argument'.
> 
> What can I do to use the pixel buffer object together with the v4l2
> interface?
> I want to use as less copy steps as possible.

The use case is reasonable (although V4L2_MEMORY_DMABUF would be better, but 
we're not there yet on the OpenGL side I believe), so let's try to debug this. 
First of all, what webcam driver do you use ?

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 9+ messages in thread

* AW: v4l2_buffer with PBO mapped memory
  2014-04-02 19:23 ` Laurent Pinchart
@ 2014-04-03 16:52   ` Scheuermann, Mail
  2014-04-03 23:16     ` Laurent Pinchart
  0 siblings, 1 reply; 9+ messages in thread
From: Scheuermann, Mail @ 2014-04-03 16:52 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media

Hi Laurent,

the driver my device uses is the uvcvideo. I have the kernel 3.11.0-18 from Ubuntu 13.10 running.
It is built in in a Thinkpad X240 notebook.

Regards,

Thomas

________________________________________
Von: Laurent Pinchart [laurent.pinchart@ideasonboard.com]
Gesendet: Mittwoch, 2. April 2014 21:23
An: Scheuermann, Mail
Cc: linux-media@vger.kernel.org
Betreff: Re: v4l2_buffer with PBO mapped memory

Hi Thomas,

On Wednesday 02 April 2014 17:10:42 Thomas Scheuermann wrote:
> Hello,
>
> I've written a program which shows my webcam with the v4l2 interface.
> In the v4l2_buffer I use the type V4L2_BUF_TYPE_VIDEO_CAPTURE and the
> memory is V4L2_MEMORY_USERPTR.
> Everything works if I use malloced memory for frame buffers.
> Now I want to get the frames directly in OpenGL. I've mapped a pixel
> buffer object with glMapBuffer and wanted to use this as a frame buffer.
> But if I use this memory, the ioctl VIDIOC_QBUF fails with 'invalid
> argument'.
>
> What can I do to use the pixel buffer object together with the v4l2
> interface?
> I want to use as less copy steps as possible.

The use case is reasonable (although V4L2_MEMORY_DMABUF would be better, but
we're not there yet on the OpenGL side I believe), so let's try to debug this.
First of all, what webcam driver do you use ?

--
Regards,

Laurent Pinchart

This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: AW: v4l2_buffer with PBO mapped memory
  2014-04-03 16:52   ` AW: " Scheuermann, Mail
@ 2014-04-03 23:16     ` Laurent Pinchart
  2014-04-04 20:01       ` AW: " Scheuermann, Mail
  0 siblings, 1 reply; 9+ messages in thread
From: Laurent Pinchart @ 2014-04-03 23:16 UTC (permalink / raw)
  To: Scheuermann, Mail; +Cc: linux-media

Hi Thomas,

On Thursday 03 April 2014 16:52:19 Scheuermann, Mail wrote:
> Hi Laurent,
> 
> the driver my device uses is the uvcvideo. I have the kernel 3.11.0-18 from
> Ubuntu 13.10 running. It is built in in a Thinkpad X240 notebook.

OK. A bit of debugging will then be needed. Could you set the videobuf2-core 
debug parameter to 3, retry your test case and send us the kernel log ?

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 9+ messages in thread

* AW: AW: v4l2_buffer with PBO mapped memory
  2014-04-03 23:16     ` Laurent Pinchart
@ 2014-04-04 20:01       ` Scheuermann, Mail
  2014-04-06 23:37         ` Laurent Pinchart
  0 siblings, 1 reply; 9+ messages in thread
From: Scheuermann, Mail @ 2014-04-04 20:01 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media

Hi Laurent,

I've done the following:

echo 3 >/sys/module/videobuf2_core/parameters/debug

and found in /var/log/kern.log after starting my program:

Apr  4 21:53:48 x240 kernel: [239432.535077] vb2: Buffer 0, plane 0 offset 0x00000000
Apr  4 21:53:48 x240 kernel: [239432.535080] vb2: Buffer 1, plane 0 offset 0x001c2000
Apr  4 21:53:48 x240 kernel: [239432.535082] vb2: Buffer 2, plane 0 offset 0x00384000
Apr  4 21:53:48 x240 kernel: [239432.535083] vb2: Allocated 3 buffers, 1 plane(s) each
Apr  4 21:53:48 x240 kernel: [239432.535085] vb2: qbuf: userspace address for plane 0 changed, reacquiring memory
Apr  4 21:53:48 x240 kernel: [239432.535087] vb2: qbuf: failed acquiring userspace memory for plane 0
Apr  4 21:53:48 x240 kernel: [239432.535088] vb2: qbuf: buffer preparation failed: -22
Apr  4 21:53:48 x240 kernel: [239432.535128] vb2: streamoff: not streaming

Regards,

Thomas

________________________________________
Von: Laurent Pinchart [laurent.pinchart@ideasonboard.com]
Gesendet: Freitag, 4. April 2014 01:16
An: Scheuermann, Mail
Cc: linux-media@vger.kernel.org
Betreff: Re: AW: v4l2_buffer with PBO mapped memory

Hi Thomas,

On Thursday 03 April 2014 16:52:19 Scheuermann, Mail wrote:
> Hi Laurent,
>
> the driver my device uses is the uvcvideo. I have the kernel 3.11.0-18 from
> Ubuntu 13.10 running. It is built in in a Thinkpad X240 notebook.

OK. A bit of debugging will then be needed. Could you set the videobuf2-core
debug parameter to 3, retry your test case and send us the kernel log ?

--
Regards,

Laurent Pinchart

This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: AW: AW: v4l2_buffer with PBO mapped memory
  2014-04-04 20:01       ` AW: " Scheuermann, Mail
@ 2014-04-06 23:37         ` Laurent Pinchart
  2014-04-11  5:56           ` Thomas Scheuermann
  0 siblings, 1 reply; 9+ messages in thread
From: Laurent Pinchart @ 2014-04-06 23:37 UTC (permalink / raw)
  To: Scheuermann, Mail; +Cc: linux-media

Hi Thomas,

On Friday 04 April 2014 20:01:33 Scheuermann, Mail wrote:
> Hi Laurent,
> 
> I've done the following:
> 
> echo 3 >/sys/module/videobuf2_core/parameters/debug
> 
> and found in /var/log/kern.log after starting my program:
> 
> [239432.535077] vb2: Buffer 0, plane 0 offset 0x00000000
> [239432.535080] vb2: Buffer 1, plane 0 offset 0x001c2000
> [239432.535082] vb2: Buffer 2, plane 0 offset 0x00384000
> [239432.535083] vb2: Allocated 3 buffers, 1 plane(s) each
> [239432.535085] vb2: qbuf: userspace address for plane 0 changed,
> reacquiring memory
> [239432.535087] vb2: qbuf: failed acquiring userspace memory for plane 0

This confirms everything is working properly up to the point where videobuf2-
vmalloc fails to acquire the user pointer memory. The problem comes from 
vb2_vmalloc_get_userptr() in drivers/media/v4l2-core/videobuf2-vmalloc.c. 
Unfortunately that function lacks debugging. Are you familiar enough with 
kernel programming to add printk statements there and see where it fails ?

> [239432.535088] vb2: qbuf: buffer preparation failed: -22
> [239432.535128] vb2: streamoff: not streaming

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: AW: AW: v4l2_buffer with PBO mapped memory
  2014-04-06 23:37         ` Laurent Pinchart
@ 2014-04-11  5:56           ` Thomas Scheuermann
  2014-04-15  6:04             ` Thomas Scheuermann
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Scheuermann @ 2014-04-11  5:56 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media

Hi Laurent,

On 07.04.2014 01:37, Laurent Pinchart wrote:
> Hi Thomas,
>
> On Friday 04 April 2014 20:01:33 Scheuermann, Mail wrote:
>> Hi Laurent,
>>
>> I've done the following:
>>
>> echo 3 >/sys/module/videobuf2_core/parameters/debug
>>
>> and found in /var/log/kern.log after starting my program:
>>
>> [239432.535077] vb2: Buffer 0, plane 0 offset 0x00000000
>> [239432.535080] vb2: Buffer 1, plane 0 offset 0x001c2000
>> [239432.535082] vb2: Buffer 2, plane 0 offset 0x00384000
>> [239432.535083] vb2: Allocated 3 buffers, 1 plane(s) each
>> [239432.535085] vb2: qbuf: userspace address for plane 0 changed,
>> reacquiring memory
>> [239432.535087] vb2: qbuf: failed acquiring userspace memory for plane 0
> This confirms everything is working properly up to the point where videobuf2-
> vmalloc fails to acquire the user pointer memory. The problem comes from
> vb2_vmalloc_get_userptr() in drivers/media/v4l2-core/videobuf2-vmalloc.c.
> Unfortunately that function lacks debugging. Are you familiar enough with
> kernel programming to add printk statements there and see where it fails ?
I was able to put some debug output in vb2_vmalloc_get_userptr.
A call to 'vb2_get_contig_userptr' failed.
I will also put some debug code there to get more information.
>> [239432.535088] vb2: qbuf: buffer preparation failed: -22
>> [239432.535128] vb2: streamoff: not streaming

This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: AW: AW: v4l2_buffer with PBO mapped memory
  2014-04-11  5:56           ` Thomas Scheuermann
@ 2014-04-15  6:04             ` Thomas Scheuermann
  2014-04-15 15:02               ` Hans Verkuil
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Scheuermann @ 2014-04-15  6:04 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media

Hi Laurent,

On 11.04.2014 07:56, Thomas Scheuermann wrote:
> Hi Laurent,
>
> On 07.04.2014 01:37, Laurent Pinchart wrote:
>> Hi Thomas,
>>
>> On Friday 04 April 2014 20:01:33 Scheuermann, Mail wrote:
>>> Hi Laurent,
>>>
>>> I've done the following:
>>>
>>> echo 3 >/sys/module/videobuf2_core/parameters/debug
>>>
>>> and found in /var/log/kern.log after starting my program:
>>>
>>> [239432.535077] vb2: Buffer 0, plane 0 offset 0x00000000
>>> [239432.535080] vb2: Buffer 1, plane 0 offset 0x001c2000
>>> [239432.535082] vb2: Buffer 2, plane 0 offset 0x00384000
>>> [239432.535083] vb2: Allocated 3 buffers, 1 plane(s) each
>>> [239432.535085] vb2: qbuf: userspace address for plane 0 changed,
>>> reacquiring memory
>>> [239432.535087] vb2: qbuf: failed acquiring userspace memory for
>>> plane 0
>> This confirms everything is working properly up to the point where
>> videobuf2-
>> vmalloc fails to acquire the user pointer memory. The problem comes from
>> vb2_vmalloc_get_userptr() in
>> drivers/media/v4l2-core/videobuf2-vmalloc.c.
>> Unfortunately that function lacks debugging. Are you familiar enough
>> with
>> kernel programming to add printk statements there and see where it
>> fails ?
> I was able to put some debug output in vb2_vmalloc_get_userptr.
> A call to 'vb2_get_contig_userptr' failed.
> I will also put some debug code there to get more information.

In vb2_get_contig_userptr I saw that the call to 'follow_pfn' failed and
returned -22.
Do you know what the problem here is?
>>> [239432.535088] vb2: qbuf: buffer preparation failed: -22
>>> [239432.535128] vb2: streamoff: not streaming
>
> This message is subject to the following terms and conditions: MAIL
> DISCLAIMER<http://www.barco.com/en/maildisclaimer>
> --
> 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

This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: AW: AW: v4l2_buffer with PBO mapped memory
  2014-04-15  6:04             ` Thomas Scheuermann
@ 2014-04-15 15:02               ` Hans Verkuil
  0 siblings, 0 replies; 9+ messages in thread
From: Hans Verkuil @ 2014-04-15 15:02 UTC (permalink / raw)
  To: Thomas Scheuermann, Laurent Pinchart; +Cc: linux-media, Pawel Osciak

On 04/15/2014 08:04 AM, Thomas Scheuermann wrote:
> Hi Laurent,
> 
> On 11.04.2014 07:56, Thomas Scheuermann wrote:
>> Hi Laurent,
>>
>> On 07.04.2014 01:37, Laurent Pinchart wrote:
>>> Hi Thomas,
>>>
>>> On Friday 04 April 2014 20:01:33 Scheuermann, Mail wrote:
>>>> Hi Laurent,
>>>>
>>>> I've done the following:
>>>>
>>>> echo 3 >/sys/module/videobuf2_core/parameters/debug
>>>>
>>>> and found in /var/log/kern.log after starting my program:
>>>>
>>>> [239432.535077] vb2: Buffer 0, plane 0 offset 0x00000000
>>>> [239432.535080] vb2: Buffer 1, plane 0 offset 0x001c2000
>>>> [239432.535082] vb2: Buffer 2, plane 0 offset 0x00384000
>>>> [239432.535083] vb2: Allocated 3 buffers, 1 plane(s) each
>>>> [239432.535085] vb2: qbuf: userspace address for plane 0 changed,
>>>> reacquiring memory
>>>> [239432.535087] vb2: qbuf: failed acquiring userspace memory for
>>>> plane 0
>>> This confirms everything is working properly up to the point where
>>> videobuf2-
>>> vmalloc fails to acquire the user pointer memory. The problem comes from
>>> vb2_vmalloc_get_userptr() in
>>> drivers/media/v4l2-core/videobuf2-vmalloc.c.
>>> Unfortunately that function lacks debugging. Are you familiar enough
>>> with
>>> kernel programming to add printk statements there and see where it
>>> fails ?
>> I was able to put some debug output in vb2_vmalloc_get_userptr.
>> A call to 'vb2_get_contig_userptr' failed.

Unless I am mistaken vb2_get_contig_userptr() requires that the userptr
points to physically contiguous memory, but that should not be a
requirement for videobuf2-vmalloc.

Pawel, any idea why vb2_get_contig_userptr() is used here?

Regards,

	Hans

>> I will also put some debug code there to get more information.
> 
> In vb2_get_contig_userptr I saw that the call to 'follow_pfn' failed and
> returned -22.
> Do you know what the problem here is?
>>>> [239432.535088] vb2: qbuf: buffer preparation failed: -22
>>>> [239432.535128] vb2: streamoff: not streaming
>>
>> This message is subject to the following terms and conditions: MAIL
>> DISCLAIMER<http://www.barco.com/en/maildisclaimer>
>> --
>> 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
> 
> This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>
> --
> 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
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-04-15 15:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-02 15:10 v4l2_buffer with PBO mapped memory Thomas Scheuermann
2014-04-02 19:23 ` Laurent Pinchart
2014-04-03 16:52   ` AW: " Scheuermann, Mail
2014-04-03 23:16     ` Laurent Pinchart
2014-04-04 20:01       ` AW: " Scheuermann, Mail
2014-04-06 23:37         ` Laurent Pinchart
2014-04-11  5:56           ` Thomas Scheuermann
2014-04-15  6:04             ` Thomas Scheuermann
2014-04-15 15:02               ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.