All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhupesh SHARMA <bhupesh.sharma@st.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"balbi@ti.com" <balbi@ti.com>,
	"g.liakhovetski@gmx.de" <g.liakhovetski@gmx.de>
Subject: RE: Using UVC webcam gadget with a real v4l2 device
Date: Thu, 26 Apr 2012 13:23:59 +0800	[thread overview]
Message-ID: <D5ECB3C7A6F99444980976A8C6D896384FA4445DA8@EAPEX1MAIL1.st.com> (raw)
In-Reply-To: 4085740.9DbpdWgfF6@avalon

Hi Laurent,

Sorry to jump-in before your reply on my previous mail,
but as I was studying the USERPTR stuff in more detail, I have a few more
queries which I believe you can include in your reply as well..

> -----Original Message-----
> From: Bhupesh SHARMA
> Sent: Wednesday, April 25, 2012 8:37 PM
> To: 'Laurent Pinchart'
> Cc: linux-usb@vger.kernel.org; linux-media@vger.kernel.org;
> balbi@ti.com; g.liakhovetski@gmx.de
> Subject: RE: Using UVC webcam gadget with a real v4l2 device
> 
> Hi Laurent,
> 
> > -----Original Message-----
> > From: Laurent Pinchart [mailto:laurent.pinchart@ideasonboard.com]
> > Sent: Tuesday, April 24, 2012 2:26 AM
> > To: Bhupesh SHARMA
> > Cc: linux-usb@vger.kernel.org; linux-media@vger.kernel.org;
> > balbi@ti.com; g.liakhovetski@gmx.de
> > Subject: Re: Using UVC webcam gadget with a real v4l2 device
> >
> > Hi Bhupesh,
> >
> > On Tuesday 24 April 2012 02:46:22 Bhupesh SHARMA wrote:
> > > On Monday, April 23, 2012 7:47 PM Laurent Pinchart wrote:
> > > > On Monday 23 April 2012 02:24:53 Bhupesh SHARMA wrote:
> > > > > Hi Laurent,
> > > > >
> > > > > I have been doing some experimentation with the UVC webcam
> gadget
> > along
> > > > > with the UVC user-space application which you have written.
> > > > >
> > > > > The UVC webcam gadget works fine with the user space
> application
> > > > > handling the CONTROL events and providing DATA events. Now, I
> > wish to
> > > > > interface a real v4l2 device, for e.g. VIVI or more
> particularly
> > a
> > > > > soc_camera based host and subdev pair.
> > > > >
> > > > > Now, I see that I can achieve this by opening the UVC and V4L2
> > devices
> > > > > and doing MMAP -> REQBUF -> QBUF -> DQBUF calls on both the
> > devices per
> > > > > the UVC control event received. But this will involve copying
> the
> > video
> > > > > buffer in the user-space application from v4l2 (_CAPTURE) to
> uvc
> > > > > (_OUTPUT) domains, which will significantly reduce the video
> > capture
> > > > > performance.
> > > > >
> > > > > Is there a better solution to this issue? Maybe doing something
> > like a
> > > > > RNDIS gadget does with the help of u_ether.c like helper
> > routines. But
> > > > > if I remember well it also requires the BRCTL (Bridge Control
> > Utility)
> > > > > in userspace to route data arriving on usb0 to eth0 and vice-
> > versa. Not
> > > > > sure though, if it does copying of a skb buffer from ethernet
> to
> > usb
> > > > > domain and vice-versa.
> > > >
> > > > To avoid copying data between the two devices you should use
> > USERPTR
> > > > instead of MMAP on at least one of the two V4L2 devices. The UVC
> > gadget
> > > > driver doesn't support USERPTR yet though. This shouldn't be too
> > difficult
> > > > to fix, we need toreplace the custom buffers queue implementation
> > with
> > > > videobuf2, as has been done in the uvcvideo driver.
> > >
> > > I was thinking of using the USERPTR method too, but I realized that
> > > currently neither UVC webcam gadget nor soc-camera subsystem
> supports
> > this
> > > IO method. They support only MMAP IO as of now :(
> >
> > Both soc-camera and the UVC gadget driver should be ported to
> videobuf2
> > to fix
> > the problem.

I am now a bit confused on how the entire system will work now:
	- Does USERPTR method needs to be supported both in UVC gadget and soc-camera side,
	  or one can still support the MMAP method and the other can now be changed to support USERPTR method
	  and we can achieve a ZERO buffer copy operation using this method?

	- More specifically, I would like to keep the soc-camera still using MMAP (and hence still using video-buf)
	  and make changes at the UVC gadget side to support USERPTR and videobuf2. Will this work?

	- At the application side how should we design the flow in case both support USERPTR, i.e. the buffer needs
	  to be protected from simultaneous access from the UVC gadget driver and soc-camera driver (to ensure that
	  a single buffer can be shared across them). Also in case we keep soc-camera still using MMAP and UVC gadget
	  side supporting USERPTR, how can we share a common buffer across the UVC gadget and soc-camera driver.

	- In case of USERPTR method the camera capture hardware should be able to DMA the received data to the user
	  space buffers. Are there any specific requirements on the DMA capability of these use-space buffers
	  (scatter-gather or contiguous?).

Regards,
Bhupesh

> > > > I'll try to implement this. Would you then be able to test
> patches
> > ?
> > >
> > > For sure, I can test your patches on my setup.
> >
> > I had a quick look, but there's a bit more work than expected. The
> UVC
> > gadget
> > driver locking scheme needs to be revisited. I unfortunately won't
> have
> > time
> > to work on that in the next couple of weeks, and very probably not
> > before end
> > of June. Sorry.
> 
> > If you want to give it a try, I can provide you with some pointers.
> 
> It's  a pity. You are the best person to do it as you have in-depth
> know
> -how of both v4l2 and UVC webcam gadget. But I can give it a try if you
> can provide me some pointers..
> 
> 
> > > BTW, I was exploring GSTREAMER to use the data arriving from soc-
> > camera
> > > (v4l2) capture device '/dev/video1' via 'v4l2src' plugin and
> routing
> > the
> > > same to the UVC gadget '/dev/video0' via the 'v4l2sink' plugin.
> > >
> > > Don't know if this can work cleanly in my setup and whether
> GSTREAMER
> > > actually performs a buffer copy internally. But I will at-least
> give
> > it a
> > > try :)
> >
> > There will definitely be a buffer copy (and actually two copies, as
> the
> > UVC
> > gadget driver performs a second copy internally) if you don't use
> > USERPTR.
> 
> That's what I was afraid of. But can you let me know where the gadget
> driver
> performs a second copy internally, so that I can also start exploring
> the
> USERPTR method using the pointers provided by you..
> 
> Regards,
> Bhupesh

  parent reply	other threads:[~2012-04-26  5:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22 18:24 Using UVC webcam gadget with a real v4l2 device Bhupesh SHARMA
2012-04-23 14:17 ` Laurent Pinchart
2012-04-23 18:46   ` Bhupesh SHARMA
2012-04-23 20:55     ` Laurent Pinchart
2012-04-25 15:06       ` Bhupesh SHARMA
2012-04-26  5:23       ` Bhupesh SHARMA [this message]
2012-04-30 10:20         ` Laurent Pinchart
2012-04-30 10:47           ` Bhupesh SHARMA
2012-05-02 11:55             ` Laurent Pinchart
2012-04-30  3:34       ` Bhupesh SHARMA
2012-04-24  0:36 ` Peter Chen
2012-04-24  9:04   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D5ECB3C7A6F99444980976A8C6D896384FA4445DA8@EAPEX1MAIL1.st.com \
    --to=bhupesh.sharma@st.com \
    --cc=balbi@ti.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.