On Thursday 02 November 2006 19:50, Duncan Webb wrote:
> Duncan Webb wrote:
> > Hans Verkuil wrote:
> >> On Tuesday 31 October 2006 07:09, Duncan Webb wrote:
> >>>>> Aha, need to use VIDIOC_STREAMOFF. I'll try this out in the
> >>>>> next few days and let you know.
> >>>>
> >>>> Thanks, this works quite nicely.
> >>>>
> >>>> There are a couple of things that I've noticed:
> >>
> >> Oops, I missed the following questions in your original email.
> >>
> >>>> 1) If the video device is read again after VIDIOC_STREAMOFF and
> >>>> reading 0 bytes, it does continue streaming. This means that
> >>>> it's not possible to use VIDIOC_STREAMOFF and VIDIOC_STREAMON to
> >>>> pause the recording. AFAICS Not a problem for what I'm doing but
> >>>> could be a problem if anybody wants to pause the video
> >>>> recording.
> >>
> >> STREAMOFF is not meant for pausing (there are ivtv ioctls for
> >> that). STREAMON is not implemented at all currently.
> >>
> >>>> 2) The end of program marker is written by VIDIOC_STREAMOFF
> >>>> instead of during the close.
> >>
> >> That's correct. You should interpret STREAMOFF as a close() that
> >> waits for the end of the GOP. You should not try to do anything
> >> after the STREAMOFF.
>
> I've done some more testing on this, attached is a tiny program to
> turn off the stream.
>
> Am I correct that to pause the stream the IVTV_IOC_PAUSE_ENCODE and
> IVTV_IOC_RESUME_ENCODE should be used?
>
> Two thing that I've noticed both cause an "Interrupted System Call"
> error.
>
> 1) If IVTV_IOC_S_GOP_END is not called
> 2) If the PAUSE and RESUME calls are made.
>
> After the interrupted system call a reboot is required, or at least
> I've not found a way to reset the driver.
>
> I'm wondering if the calls have been made incorrectly?

Hi Duncan,

You are clearly going into uncharted territories here :-)

The good news is that your code is correct, the bad news is that the 
driver code is really broken. I've attached a patch for ivtv-0.8 that 
fixes the bugs. The pause bug was really bad: pause and resume were 
swapped internally! And after stopping with END_GOP on an important 
flag wasn't cleared, so the next time the read() would stop working.

Let me know how it goes. If this is working fine for you, then I'll 
commit the changes.

Thanks,

        Hans
Index: ivtv-ioctl.c
===================================================================
--- ivtv-ioctl.c	(revision 3484)
+++ ivtv-ioctl.c	(working copy)
@@ -1395,7 +1395,7 @@
 		if (!atomic_read(&itv->capturing))
 			return 0;
 		ivtv_mute(itv);
-		ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1);
+		ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 0);
 		break;
 	}
 
@@ -1403,7 +1403,7 @@
 		IVTV_DEBUG_IOCTL("IVTV_IOC_RESUME_ENCODE\n");
 		if (!atomic_read(&itv->capturing))
 			return 0;
-		ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 0);
+		ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1);
 		ivtv_unmute(itv);
 		break;
 	}
Index: ivtv-streams.c
===================================================================
--- ivtv-streams.c	(revision 3503)
+++ ivtv-streams.c	(working copy)
@@ -904,6 +904,9 @@
 
         	/*IVTV_DEBUG_INFO("Sleeping for 100ms\n"); */
         	ivtv_sleep_timeout(HZ / 10, 0);
+
+		/* Make sure the encoder isn't paused */
+                ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1);
         }
 
 	/* begin_capture */
@@ -1255,9 +1258,8 @@
 			set_current_state(TASK_INTERRUPTIBLE);
 
 			/* wait 2s for EOS interrupt */
-			while ((!test_bit(IVTV_F_I_EOS,
-					  &itv->i_flags)) &&
-			       (jiffies < (then + (1 * HZ)))) {
+			while ((!test_bit(IVTV_F_I_EOS, &itv->i_flags)) &&
+			       (jiffies < (then + (2 * HZ)))) {
 				schedule_timeout(HZ / 100);
 			}
 
@@ -1336,8 +1338,7 @@
 	atomic_dec(&itv->capturing);
 
 	/* Clear capture and no-read bits */
-	if (!test_bit(IVTV_F_S_STREAMOFF, &st->s_flags))
-		clear_bit(IVTV_F_S_CAPTURING, &st->s_flags);
+	clear_bit(IVTV_F_S_CAPTURING, &st->s_flags);
 
 	/* Clear capture started bit */
         if (type == IVTV_ENC_STREAM_TYPE_VBI) {
Index: ivtv-fileops.c
===================================================================
--- ivtv-fileops.c	(revision 3506)
+++ ivtv-fileops.c	(working copy)
@@ -865,7 +865,8 @@
 
 	/* If capture is already in progress, then we also have to
 	   do nothing extra. */
-	if (test_and_set_bit(IVTV_F_S_CAPTURING, &stream->s_flags))
+	if (test_bit(IVTV_F_S_STREAMOFF, &stream->s_flags) ||
+	    test_and_set_bit(IVTV_F_S_CAPTURING, &stream->s_flags))
 		return ivtv_read(filp, buf, count, pos);
 
 	/* Start VBI capture if required */
@@ -1326,6 +1327,7 @@
 			ivtv_stop_capture(itv, id->type);
 		}
 	}
+	clear_bit(IVTV_F_S_STREAMOFF, &stream->s_flags);
 	if (id->type == IVTV_DEC_STREAM_TYPE_YUV  && test_bit(IVTV_F_S_DECODING_YUV, &stream->s_flags)) { /* Reset registers we have changed so mpeg playback works */
                 int h_filter, v_filter_1, v_filter_2;
 
_______________________________________________
ivtv-devel mailing list
[email protected]
http://ivtvdriver.org/mailman/listinfo/ivtv-devel

Reply via email to