Re: Re: capturing fields to separate buffers?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Jul 08, 2002 at 05:02:41PM +0000, Gerd Knorr wrote:
> Ville Syrjälä wrote:
> >  On Mon, Jul 08, 2002 at 08:43:11AM +0000, Gerd Knorr wrote:
> > > >  And what about the overlay mode? Is there something in the API to provide
> > > >  accurate syncing (even frame based) in overlay mode?
> > > 
> > > No.
> >  
> >  I hacked the bttv driver in 2.4.19-rc1 to do field syncing and changed the
> >  BTTV_FIELDNR ioctl to return the active field.
> 
> Can I see the code for that?

Sure. I just declared a new wait queue and changed VIDIOCSYNC to use this
queue when called with the parameter '-1'. I included the whole diff
below. I haven't really done any kernel programming before so i don't know
if it's acceptable code. The global waitqueue would certainly be a problem
for multiple cards but I only have one card.

--- bttv-driver.c	Mon Jul  8 20:52:31 2002
+++ bttv-new.c	Mon Jul  8 20:53:32 2002
@@ -132,6 +132,7 @@
 #define BURSTOFFSET 76
 #define BTTV_ERRORS 5
 
+static DECLARE_WAIT_QUEUE_HEAD(vsync_wait);
 
 /*******************************/
 /* Memory management functions */
@@ -1294,6 +1295,7 @@
 	btv->needs_restart = 1;
 	spin_unlock(&btv->s_lock);
 
+        wake_up_interruptible(&vsync_wait);
 	wake_up_interruptible(&btv->vbiq);
 	wake_up_interruptible(&btv->capq);
 }
@@ -1870,6 +1872,13 @@
 
 		if(copy_from_user((void *)&i,arg,sizeof(int)))
 			return -EFAULT;
+		if (i == -1) {
+                        interruptible_sleep_on(&vsync_wait);
+                        if (signal_pending(current))
+                                return -EINTR;
+                        return 0;
+                }
+
 		if (i < 0 || i >= gbuffers)
 			return -EINVAL;
 		switch (btv->gbuf[i].stat) {
@@ -1908,11 +1917,11 @@
 	}
 
 	case BTTV_FIELDNR: 
-		if(copy_to_user((void *) arg, (void *) &btv->last_field, 
-				sizeof(btv->last_field)))
+		if(copy_to_user((void *) arg, (void *) &btv->field, 
+				sizeof(btv->field)))
 			return -EFAULT;
 		break;
-      
+
 	case BTTV_PLLSET: {
 		struct bttv_pll_info p;
 		if(!capable(CAP_SYS_ADMIN))
@@ -2599,7 +2608,7 @@
 	btwrite(btv->triton1|
                 /*BT848_INT_PABORT|BT848_INT_RIPERR|BT848_INT_PPERR|
                   BT848_INT_FDSR|BT848_INT_FTRGT|BT848_INT_FBUS|*/
-                (fieldnr ? BT848_INT_VSYNC : 0)|
+                BT848_INT_VSYNC|
 		BT848_INT_GPINT|
 		BT848_INT_SCERR|
 		BT848_INT_RISCI|BT848_INT_OCERR|BT848_INT_VPRES|
@@ -2684,8 +2693,10 @@
 		if (astat&BT848_INT_GPINT)
 			wake_up_interruptible(&btv->gpioq);
 
-		if (astat&BT848_INT_VSYNC) 
-                        btv->field++;
+		if (astat&BT848_INT_VSYNC) {
+                        btv->field = (dstat&BT848_DSTATUS_FIELD) ? 1 : 0;
+                        wake_up_interruptible(&vsync_wait);
+                }
 
 		if (astat&(BT848_INT_SCERR|BT848_INT_OCERR)) {
 			if (bttv_verbose)

-- 
Ville Syrjälä
syrjala@xxxxxx
http://www.sci.fi/~syrjala/





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux