----------------------- cut here ----------------------------
diff -ur /home/kraxel/2/src/bttv-0.5.8/driver/bttv.c driver/bttv.c
--- /home/kraxel/2/src/bttv-0.5.8/driver/bttv.c	Tue May 12 17:42:53 1998
+++ driver/bttv.c	Mon Jun  1 22:46:48 1998
@@ -825,6 +825,7 @@
                 *((*rp)++)=line_adr+*x*bpp;
 	*x+=dx;
 }
+
 static void make_clip_tab(struct bttv *btv, struct cliprec *cr, int count)
 {
         int i,ncr;
@@ -1206,7 +1207,7 @@
 		if(fbuffer_alloc(btv))
 			return -ENOBUFS;
 	}
-        if (btv->grabbing > 1)
+        if (btv->grabbing >= MAX_GBUFFERS)
                 return -ENOBUFS;
 	
 	/*
@@ -1244,12 +1245,15 @@
 	/* bt848_set_risc_jmps(btv); */
 	btor(3, BT848_CAP_CTL);
 	btor(3, BT848_GPIO_DMA_CTL);
+        btv->frame_stat[mp->frame] = GBUFFER_GRABBING;
         if (btv->grabbing) {
 		btv->gro_next=virt_to_bus(ro);
 		btv->gre_next=virt_to_bus(re);
+                btv->grf_next=mp->frame;
         } else {
 		btv->gro=virt_to_bus(ro);
 		btv->gre=virt_to_bus(re);
+                btv->grf=mp->frame;
         }
 	if (!(btv->grabbing++)) 
 		btv->risc_jmp[12]=BT848_RISC_JUMP|(0x8<<16)|BT848_RISC_IRQ;
@@ -1672,7 +1676,7 @@
 {
 	unsigned char eedata[256];
 	struct bttv *btv=(struct bttv *)dev;
-  	static int lastchan=0;
+  	static int lastchan=0,i;
   	
 	switch (cmd)
 	{	
@@ -1705,6 +1709,7 @@
 			v.flags=VIDEO_VC_AUDIO;
 			v.tuners=0;
 			v.type=VIDEO_TYPE_CAMERA;
+			v.mode = btv->win.norm;
 			switch(v.channel)
 			{
 				case 0:
@@ -1734,11 +1739,15 @@
 		 */
 		case VIDIOCSCHAN:
 		{
-			int v;
+			struct video_channel v;
 			if(copy_from_user(&v, arg, sizeof(v)))
 				return -EFAULT;
-			bt848_muxsel(btv, v);
-			lastchan=v;
+			bt848_muxsel(btv, v.channel);
+			lastchan=v.channel;
+#if 0
+			btv->win.norm = v.mode;
+			bt848_set_winsize(btv);
+#endif
 			return 0;
 		}
 		case VIDIOCGTUNER:
@@ -1751,7 +1760,8 @@
 			strcpy(v.name, "Television");
 			v.rangelow=0;
 			v.rangehigh=0xFFFFFFFF;
-			v.flags=VIDEO_TUNER_PAL|VIDEO_TUNER_NTSC;
+			v.flags=VIDEO_TUNER_PAL|VIDEO_TUNER_NTSC|
+				VIDEO_SECAM_SECAM;
 			v.mode = btv->win.norm;
 			if(copy_to_user(arg,&v,sizeof(v)))
 				return -EFAULT;
@@ -2038,7 +2048,7 @@
 			btv->audio_dev=v;
 			return 0;
 		}
-	        case VIDIOCSYNC:
+	        case VIDIOCSYNC_OLD:
 #if 0
                         if (!btv->grabbing)
                                 return -EAGAIN;
@@ -2047,6 +2057,20 @@
 			        interruptible_sleep_on(&btv->capq);
 		        btv->lastgrab++;
 		        return 0;
+	        case VIDIOCSYNC:
+			if(copy_from_user((void *)&i,arg,sizeof(int)))
+				return -EFAULT;
+                        switch (btv->frame_stat[i]) {
+                        case GBUFFER_UNUSED:
+                                return -EINVAL;
+                        case GBUFFER_GRABBING:
+			        interruptible_sleep_on(&btv->capq);
+                                /* fall */
+                        case GBUFFER_DONE:
+                                btv->frame_stat[i] = GBUFFER_UNUSED;
+                                break;
+                        }
+                        return 0;
 
 		case BTTV_WRITEE:
 			if(!suser())
@@ -2069,6 +2093,8 @@
                         struct video_mmap vm;
 			if(copy_from_user((void *) &vm, (void *) arg, sizeof(vm)))
 				return -EFAULT;
+                        if (btv->frame_stat[i] == GBUFFER_GRABBING)
+                                return -EBUSY;
 		        return vgrab(btv, &vm);
 		}
 		default:
@@ -2920,10 +2946,12 @@
 			if (stat&(2<<28)) 
 			{
 			        btv->grab++;
+                                btv->frame_stat[btv->grf] = GBUFFER_DONE;
 			        if ((--btv->grabbing))
 				{
 					btv->gro = btv->gro_next;
 					btv->gre = btv->gre_next;
+					btv->grf = btv->grf_next;
                                         btv->risc_jmp[5]=btv->gro;
 					btv->risc_jmp[11]=btv->gre;
 					bt848_set_geo(btv, btv->gwidth,
diff -ur /home/kraxel/2/src/bttv-0.5.8/driver/bttv.h driver/bttv.h
--- /home/kraxel/2/src/bttv-0.5.8/driver/bttv.h	Fri May  8 00:08:45 1998
+++ driver/bttv.h	Mon Jun  1 20:16:54 1998
@@ -32,6 +32,7 @@
 #include "videodev.h"
 
 #define MAX_CLIPRECS	100
+#define MAX_GBUFFERS	2
 #define RISCMEM_LEN	(32744*2)
 
 /* maximum needed buffer size for extended VBI frame mode capturing */
@@ -115,11 +116,19 @@
 	struct gbuffer *egbuffers;
 	u16 gwidth, gheight, gfmt;
 	u32 *grisc;
+
 	unsigned long gro;
 	unsigned long gre;
 	unsigned long gro_next;
 	unsigned long gre_next;
-	char *fbuffer;
+
+        int grf,grf_next;  /* frame numbers in grab queue */
+        int frame_stat[MAX_GBUFFERS];
+#define GBUFFER_UNUSED       0
+#define GBUFFER_GRABBING     1
+#define GBUFFER_DONE         2
+
+        char *fbuffer;
 	int gmode;
 	int grabbing;
 	int lastgrab;
diff -ur /home/kraxel/2/src/bttv-0.5.8/driver/videodev.h driver/videodev.h
--- /home/kraxel/2/src/bttv-0.5.8/driver/videodev.h	Fri May  1 17:51:57 1998
+++ driver/videodev.h	Mon Jun  1 20:27:31 1998
@@ -180,7 +180,8 @@
 #define VIDIOCSFREQ		_IOW('v',15, unsigned long)		/* Set tuner */
 #define VIDIOCGAUDIO		_IOR('v',16, struct video_audio)	/* Get audio info */
 #define VIDIOCSAUDIO		_IOW('v',17, struct video_audio)	/* Audio source, mute etc */
-#define VIDIOCSYNC		_IO('v',18)				/* Sync with mmap grabbing */
+#define VIDIOCSYNC_OLD		_IO('v',18)				/* Sync with mmap grabbing */
+#define VIDIOCSYNC		_IOW('v',18, int)      			/* Sync with mmap grabbing */
 #define VIDIOCMCAPTURE		_IOW('v',19, struct video_mmap)		/* Grab frames */