Hi,

On Friday 25 September 2009 03:49:53 Bo Liu wrote:
>  <[email protected]>
> Content-Type: text/plain; charset="gb2312"
> Content-Transfer-Encoding: 8bit
> MIME-Version: 1.0

Please try to fix your mail client. This is really annoying.
 
> > On Thursday 24 September 2009 11:14:35 Bo Liu wrote:
> > > Hi, All
> > >
> > > I have a question about VIDIOC_S_FMT?
> > >
> > > Gstreamer will ioctl(VIDIOC_STREAMINGOFF) then ioctl(VIDIOC_S_FMT),
> > > then ioctl(VIDIOC_STREAMINGON)
> > >
> > > The newest's code have these patch:
> > >
> > > diff --git a/drivers/media/video/uvc/uvc_v4l2.c 
> > > b/drivers/media/video/uvc/uvc_v4l2.c index 507542d..f8b94d6 100644
> > > (file)
> > > --- a/drivers/media/video/uvc/uvc_v4l2.c
> > > +++ b/drivers/media/video/uvc/uvc_v4l2.c
> > > @@ -251,7 +251,7 @@ static int uvc_v4l2_set_format(struct
> > > uvc_video_device *video, if (fmt->type != video->streaming->type)
> > > return -EINVAL;
> > >
> > > - if (uvc_queue_streaming(&video->queue))
> > > + if (uvc_queue_allocated(&video->queue))
> > > return -EBUSY;
> > >
> > > ret = uvc_v4l2_try_format(video, fmt, &probe, &format, &frame);
> > >
> > >
> > > And, I found after this patch ioctl(VIDIOC_S_FMT) will failed at
> > > uvc_queue_allocated(it won't failed at uvc_queue_streaming).
> > >
> > > So, Now Can Gstreamer set the format(use ioctl(VIDIOC_STREAMINGOFF£©£¬
> > > then ioctl(VIDIOC_S_FMT), then ioctl(VIDIOC_STREAMINGON)) after open the
> > > device(doesn't close) ? If not, How to implement this?
> >
> > You can't change the format while buffers are allocated. You need to free
> > the buffers before, using VIDIOC_REQBUFS with a buffer count of 0.
> 
> Thanks for your reply, uvc_v4l2_try_format() success now.

I suppose you mean uvc_v4l2_set_format().

> But gstreamer still failed while dequeue buffer, I think maybe it doesn't
> realloc buffer and add to queue. Then, How and where to realloc the buffer
> after change the format? I try to use VIDIOC_REQBUFS with a buffer count.
> But it seems no useage.

That's the right way to do it, and it should work.

ioctl(VIDIOC_S_FMT)
ioctl(VIDIOC_REQBUFS - n buffers)
mmap()
ioctl(VIDIOC_QBUF)
ioctl(VIDIOC_STREAMON)
ioctl(VIDIOC_DQBUF)
ioctl(VIDIOC_QBUF)
...
ioctl(VIDIOC_STREAMOFF)
munmap()
ioctl(VIDIOC_REQBUFS - 0 buffers)

At this point the buffers are free and you should be able to start over, 
setting a new format, requesting the buffers, mapping them, ...

If you get an error from the driver please report it.

-- 
Regards,

Laurent Pinchart
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to