Linux Media Controller development
 help / color / mirror / Atom feed
* How to store the latest image without modifying videobuf-core.c
@ 2009-10-12  7:33 Mattias Persson
  2009-10-12 12:33 ` David Ellingsworth
  0 siblings, 1 reply; 2+ messages in thread
From: Mattias Persson @ 2009-10-12  7:33 UTC (permalink / raw)
  To: video4linux-list

Hi, 

I am developing a driver for a camera. As an example I am using the vivi driver (2.6.28) and the first major difference between my ISR and thread_tick() is that my driver will always attempt to store the latest image, even if nobody is waiting for a new image. 

In my driver, when all queued buffers are used any new images will be stored in the oldest frame which has already been captured (state == VIDEOBUF_DONE) and here is where my problems start. (If this is wrong, what shall I do to always keep the latest captured image?)

In the function videobuf_dqbuf in videobuf-core.c, if a new image is returned by stream_next_buffer and the ISR kicks in before videobuf_dqbuf can set buf->state to VIDEOBUF_IDLE, my driver will modify the image presented to userspace and that is not acceptable. 

The only solution I can find is to use the spinlock in videobuf_queue when the userspace application is requesting a new image (DQBUF/poll) to check for a new image and set some flag indicating that the buffer can't be overwritten by the ISR. However, this approach would require changes to videobuf-core.c and that doesn't seem right. Can someone please give me some guidance on this? 

Regards, 
Mattias



      __________________________________________________________
Ta semester! - sök efter resor hos Kelkoo.
Jämför pris på flygbiljetter och hotellrum här:
http://www.kelkoo.se/c-169901-resor-biljetter.html?partnerId=96914052

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

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

* Re: How to store the latest image without modifying videobuf-core.c
  2009-10-12  7:33 How to store the latest image without modifying videobuf-core.c Mattias Persson
@ 2009-10-12 12:33 ` David Ellingsworth
  0 siblings, 0 replies; 2+ messages in thread
From: David Ellingsworth @ 2009-10-12 12:33 UTC (permalink / raw)
  To: Mattias Persson; +Cc: video4linux-list, Linux Media Mailing List

On Mon, Oct 12, 2009 at 3:33 AM, Mattias Persson <d98mp@yahoo.se> wrote:
> Hi,
>

Please send messages to the new mailing list:
linux-media@vger.kernel.org from now on.

> I am developing a driver for a camera. As an example I am using the vivi driver (2.6.28) and the first major difference between my ISR and thread_tick() is that my driver will always attempt to store the latest image, even if nobody is waiting for a new image.

I believe the standard here is that your driver should simply drop the
frame if no one is waiting for it.
>
> In my driver, when all queued buffers are used any new images will be stored in the oldest frame which has already been captured (state == VIDEOBUF_DONE) and here is where my problems start. (If this is wrong, what shall I do to always keep the latest captured image?)
>

If no one wants the image you should just drop it but note that it
existed. I believe the v4l2 api has frame counters so that the
application knows that it missed some.

> In the function videobuf_dqbuf in videobuf-core.c, if a new image is returned by stream_next_buffer and the ISR kicks in before videobuf_dqbuf can set buf->state to VIDEOBUF_IDLE, my driver will modify the image presented to userspace and that is not acceptable.

Correct, it's not acceptable to modify userspace memory when not asked to do so.

>
> The only solution I can find is to use the spinlock in videobuf_queue when the userspace application is requesting a new image (DQBUF/poll) to check for a new image and set some flag indicating that the buffer can't be overwritten by the ISR. However, this approach would require changes to videobuf-core.c and that doesn't seem right. Can someone please give me some guidance on this?
>
> Regards,
> Mattias

You might want to take a look at possibly using gspca as a base for
your driver. It currently supports hundreds of cameras and there are
quite a few drivers that you can use as a reference. gspca doesn't use
videobuf.. but should make it less painful to write a driver.

Regards,

David Ellingsworth

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

end of thread, other threads:[~2009-10-12 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-12  7:33 How to store the latest image without modifying videobuf-core.c Mattias Persson
2009-10-12 12:33 ` David Ellingsworth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox