public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean-Francois Moine <moinejf@free.fr>
To: Antonio Ospite <ospite@studenti.unina.it>
Cc: video4linux-list@redhat.com
Subject: Re: [PATCH] gspca_ov534: Print only frame_rate actually used.
Date: Wed, 03 Dec 2008 20:17:20 +0100	[thread overview]
Message-ID: <1228331840.1705.15.camel@localhost> (raw)
In-Reply-To: <20081203194426.f0bbdc6b.ospite@studenti.unina.it>

[-- Attachment #1: Type: text/plain, Size: 2536 bytes --]

On Wed, 2008-12-03 at 19:44 +0100, Antonio Ospite wrote:
> Yes, the code takes this path in gspca.c, gspca_frame_add(), line 277:
> 
> 	if (packet_type == FIRST_PACKET) {
> 		if ((frame->v4l2_buf.flags & BUF_ALL_FLAGS)
> 						!= V4L2_BUF_FLAG_QUEUED) {
> 			gspca_dev->last_packet_type = DISCARD_PACKET;
> 			return frame;
> 		}
> 
> and then it keeps on adding only INTER_PACKETs because of the current
> end of frame check. It is a timing issue, it happens only with high
> frame_rates, maybe there is some code in gspca that needs to be
> protected by locking?
> Or would it be normal to loose some frames at high frame rates using
> smaller bulk_size?
> 
> > > As a side note, if I use this check to detect the end of the frame:
> > > 
> > > 	if (len < gspca_dev->cam.bulk_size) {
> > > 		...
> > > 	} else ...
> > > 
> > > I can recover from the previous error even if I get some frame
> > > discarded from time to time. Is this check acceptable to you If I take
> > > care that framesize is not a multiple of bulk_size?
> > 
> > Hold off a bit on this work.
> > 
> > There's a problem with breaking up the transfers, because we're not
> > currently getting any header data from the bridge chip that lets us
> > know when we really hit the end of a frame, and it's easy to get out
> > of sync.  Using (len < bulk_size) is a good trick if they're not a
> > multiple, as you say, since the last payload will be shorter, but I
> > have a better solution -- I found how to get the camera to add a
> > UVC-format header on each payload.  I'm finishing up the patch and
> > will post it a bit later today once I iron out a few bugs.
> > 
> > -jim

Hi Antonio,

The problem comes from the availability of the application buffer. In
the bulk_irq, there is:

	frame = gspca_get_i_frame(gspca_dev);
	if (!frame) {
		gspca_dev->last_packet_type = DISCARD_PACKET;
	} else {
		.. pkt_scan(..);
	}

Then, you are not called and you cannot know how many bytes have been
really received.

As the buffer check exists in frame_add, I may call you each time with a
valid frame pointer (see patch). In this case, you cannot count the
image bytes with the data_end. You should have a counter in the sd
structure.

An other solution is to start and stop the transfer for each image as it
was in the original driver, but it asks for a kernel thread.

Anyway, if Jim may add a mark between the images, if will be the best...

Cheers.

-- 
Ken ar c'hentañ |             ** Breizh ha Linux atav! **
Jef             |               http://moinejf.free.fr/


[-- Attachment #2: gspca.patch --]
[-- Type: text/x-patch, Size: 1061 bytes --]

diff -r d23374509b5b linux/drivers/media/video/gspca/gspca.c
--- a/linux/drivers/media/video/gspca/gspca.c	Wed Dec 03 18:10:01 2008 +0100
+++ b/linux/drivers/media/video/gspca/gspca.c	Wed Dec 03 20:11:23 2008 +0100
@@ -211,6 +211,7 @@
 {
 	struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;
 	struct gspca_frame *frame;
+	int i;
 	int st;
 
 	PDEBUG(D_PACK, "bulk irq");
@@ -231,16 +232,14 @@
 	}
 
 	/* check the availability of the frame buffer */
-	frame = gspca_get_i_frame(gspca_dev);
-	if (!frame) {
-		gspca_dev->last_packet_type = DISCARD_PACKET;
-	} else {
-		PDEBUG(D_PACK, "packet l:%d", urb->actual_length);
-		gspca_dev->sd_desc->pkt_scan(gspca_dev,
-					frame,
-					urb->transfer_buffer,
-					urb->actual_length);
-	}
+	i = gspca_dev->fr_i;
+	i = gspca_dev->fr_queue[i];
+	frame = &gspca_dev->frame[i];
+	PDEBUG(D_PACK, "packet l:%d", urb->actual_length);
+	gspca_dev->sd_desc->pkt_scan(gspca_dev,
+				frame,
+				urb->transfer_buffer,
+				urb->actual_length);
 
 	/* resubmit the URB */
 	if (gspca_dev->cam.bulk_nurbs != 0) {

[-- Attachment #3: Type: text/plain, Size: 164 bytes --]

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

  reply	other threads:[~2008-12-04  2:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-25 22:52 [PATCH] gspca_ov534: Print only frame_rate actually used Antonio Ospite
2008-11-27  9:23 ` Jean-Francois Moine
2008-11-27 11:05   ` Antonio Ospite
2008-11-27 12:22     ` Jean-Francois Moine
2008-11-27 13:52       ` Antonio Ospite
2008-12-03 16:45         ` Antonio Ospite
2008-12-03 18:01           ` Jim Paris
2008-12-03 18:44             ` Antonio Ospite
2008-12-03 19:17               ` Jean-Francois Moine [this message]
2008-12-04 11:55                 ` Antonio Ospite

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=1228331840.1705.15.camel@localhost \
    --to=moinejf@free.fr \
    --cc=ospite@studenti.unina.it \
    --cc=video4linux-list@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox