Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Feb 2002 16:59:24 -0800
From:      Charles Henrich <henrich@sigbus.com>
To:        freebsd-multimedia@freebsd.org
Subject:   bktr patches
Message-ID:  <20020218165923.B60190@sigbus.com>

next in thread | raw e-mail | index | archive | help

--r5Pyd7+fXNt84Ff3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Please let me know if your existing bktr apps still work properly!

-Crh

       Charles Henrich         Eon Entertainment         henrich@msu.edu

                       http://www.sigbus.com:81/~henrich

--r5Pyd7+fXNt84Ff3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bktr.patch"

diff -u -r bktr.orig/CHANGELOG.TXT bktr/CHANGELOG.TXT
--- bktr.orig/CHANGELOG.TXT	Wed Nov  1 20:36:14 2000
+++ bktr/CHANGELOG.TXT	Tue Feb 19 11:37:38 2002
@@ -518,4 +518,9 @@
                   support for audio on Hauppauge cards without the audio mux.
                   The MSP is used for audio selection. (the 44xxx models)
 
-
+2.19  19 Feb 2002 Charles Henrich (henrich@sigbus.com)
+                  Modified frame synchronization code to allow arbitrary
+                  field pattern matchin (i.e. 2 even, 1 odd makes one clean
+                  frame).  This is probably bogus, but necessary for YUV format
+                  capture and frame signaling.  (its also cleaner code in my
+                  book :)
diff -u -r bktr.orig/bktr_core.c bktr/bktr_core.c
--- bktr.orig/bktr_core.c	Wed Nov  1 20:36:14 2000
+++ bktr/bktr_core.c	Tue Feb 19 11:43:40 2002
@@ -730,21 +730,6 @@
 		OUTB(bktr, BKTR_TDEC, 0);
 		OUTB(bktr, BKTR_TDEC, tdec_save);
 		
-		/*  Reset to no-fields captured state  */
-		if (bktr->flags & (METEOR_CONTIN | METEOR_SYNCAP)) {
-			switch(bktr->flags & METEOR_ONLY_FIELDS_MASK) {
-			case METEOR_ONLY_ODD_FIELDS:
-				bktr->flags |= METEOR_WANT_ODD;
-				break;
-			case METEOR_ONLY_EVEN_FIELDS:
-				bktr->flags |= METEOR_WANT_EVEN;
-				break;
-			default:
-				bktr->flags |= METEOR_WANT_MASK;
-				break;
-			}
-		}
-
 		OUTL(bktr, BKTR_RISC_STRT_ADD, vtophys(bktr->dma_prog));
 		OUTW(bktr, BKTR_GPIO_DMA_CTL, FIFO_ENABLED);
 		OUTW(bktr, BKTR_GPIO_DMA_CTL, bktr->capcontrol);
@@ -780,6 +765,8 @@
 	/* Determine which field generated this interrupt */
 	field = ( bktr_status & BT848_INT_FIELD ) ? EVEN_F : ODD_F;
 
+	if(field == ODD_F) bktr->sync_fields++;
+	else			   bktr->sync_fields+=0x10;
 
 	/*
 	 * Process the VBI data if it is being captured. We do this once
@@ -803,61 +790,20 @@
 			selwakeup(&bktr->vbi_select);
 		}
 
-
-	}
-
-
-	/*
-	 *  Register the completed field
-	 *    (For dual-field mode, require fields from the same frame)
-	 */
-	switch ( bktr->flags & METEOR_WANT_MASK ) {
-		case METEOR_WANT_ODD  : w_field = ODD_F         ;  break;
-		case METEOR_WANT_EVEN : w_field = EVEN_F        ;  break;
-		default               : w_field = (ODD_F|EVEN_F);  break;
-	}
-	switch ( bktr->flags & METEOR_ONLY_FIELDS_MASK ) {
-		case METEOR_ONLY_ODD_FIELDS  : req_field = ODD_F  ;  break;
-		case METEOR_ONLY_EVEN_FIELDS : req_field = EVEN_F ;  break;
-		default                      : req_field = (ODD_F|EVEN_F);  
-			                       break;
 	}
 
-	if (( field == EVEN_F ) && ( w_field == EVEN_F ))
-		bktr->flags &= ~METEOR_WANT_EVEN;
-	else if (( field == ODD_F ) && ( req_field == ODD_F ) &&
-		 ( w_field == ODD_F ))
-		bktr->flags &= ~METEOR_WANT_ODD;
-	else if (( field == ODD_F ) && ( req_field == (ODD_F|EVEN_F) ) &&
-		 ( w_field == (ODD_F|EVEN_F) ))
-		bktr->flags &= ~METEOR_WANT_ODD;
-	else if (( field == ODD_F ) && ( req_field == (ODD_F|EVEN_F) ) &&
-		 ( w_field == ODD_F )) {
-		bktr->flags &= ~METEOR_WANT_ODD;
-		bktr->flags |=  METEOR_WANT_EVEN;
-	}
-	else {
-		/*  We're out of sync.  Start over.  */
-		if (bktr->flags & (METEOR_CONTIN | METEOR_SYNCAP)) {
-			switch(bktr->flags & METEOR_ONLY_FIELDS_MASK) {
-			case METEOR_ONLY_ODD_FIELDS:
-				bktr->flags |= METEOR_WANT_ODD;
-				break;
-			case METEOR_ONLY_EVEN_FIELDS:
-				bktr->flags |= METEOR_WANT_EVEN;
-				break;
-			default:
-				bktr->flags |= METEOR_WANT_MASK;
-				break;
-			}
-		}
+	if(bktr->sync_fields > bktr->sync_match) {
+	/* printf("Out of sync, starting over %x > %x\n", bktr->sync_fields, bktr->sync_match); */
+		bktr->sync_fields = 0;
 		return 1;
 	}
 
 	/*
 	 * If we have a complete frame.
 	 */
-	if (!(bktr->flags & METEOR_WANT_MASK)) {
+	if ((bktr->sync_fields & bktr->sync_match) == bktr->sync_match) {
+
+		bktr->sync_fields = 0;
 		bktr->frames_captured++;
 		/*
 		 * post the completion time. 
@@ -913,19 +859,6 @@
 * As a consequence, this fourth mode is currently unsupported.
 */
 
-		if (bktr->flags & (METEOR_CONTIN | METEOR_SYNCAP)) {
-			switch(bktr->flags & METEOR_ONLY_FIELDS_MASK) {
-			case METEOR_ONLY_ODD_FIELDS:
-				bktr->flags |= METEOR_WANT_ODD;
-				break;
-			case METEOR_ONLY_EVEN_FIELDS:
-				bktr->flags |= METEOR_WANT_EVEN;
-				break;
-			default:
-				bktr->flags |= METEOR_WANT_MASK;
-				break;
-			}
-		}
 	}
 
 	return 1;
@@ -1023,6 +956,8 @@
 	bktr->frames_captured = 0;
 	bktr->even_fields_captured = 0;
 	bktr->odd_fields_captured = 0;
+    bktr->sync_fields = 0;
+    bktr->sync_match = SYNC_RGB;
 	bktr->proc = (struct proc *)0;
 	set_fps(bktr, frame_rate);
 	bktr->video.addr = 0;
@@ -1770,17 +1705,21 @@
 			case 0:			/* default */
 			case METEOR_GEO_RGB16:
 				    bktr->format = METEOR_GEO_RGB16;
+					bktr->sync_match = SYNC_RGB;
 				    break;
 			case METEOR_GEO_RGB24:
 				    bktr->format = METEOR_GEO_RGB24;
+					bktr->sync_match = SYNC_RGB;
 				    break;
 			case METEOR_GEO_YUV_422:
 				    bktr->format = METEOR_GEO_YUV_422;
                                     if (geo->oformat & METEOR_GEO_YUV_12) 
 					bktr->format = METEOR_GEO_YUV_12;
+					bktr->sync_match = SYNC_YUV;
 				    break;
 			case METEOR_GEO_YUV_PACKED:
 				    bktr->format = METEOR_GEO_YUV_PACKED;
+					bktr->sync_match = SYNC_YUV;
 				    break;
 			}
 			bktr->pixfmt = oformat_meteor_to_bt( bktr->format );
@@ -1810,6 +1749,10 @@
 						    BT848_INT_FMTCHG);
 			}
 		}
+
+		if (geo->oformat & METEOR_GEO_ODD_ONLY) bktr->sync_match &= SYNC_ODD;
+		if (geo->oformat & METEOR_GEO_EVEN_ONLY) bktr->sync_match &= SYNC_EVEN;
+
 		break;
 	/* end of METEORSETGEO */
 
diff -u -r bktr.orig/bktr_reg.h bktr/bktr_reg.h
--- bktr.orig/bktr_reg.h	Wed Nov  1 20:36:14 2000
+++ bktr/bktr_reg.h	Tue Feb 19 11:44:32 2002
@@ -613,6 +613,12 @@
     int		frame_size;	/* number of bytes in a frame */
     u_long	fifo_errors;	/* number of fifo capture errors since open */
     u_long	dma_errors;	/* number of DMA capture errors since open */
+#define SYNC_YUV  0x00000012
+#define SYNC_RGB  0x00000011
+#define SYNC_ODD  0x0000000F
+#define SYNC_EVEN 0x000000F0
+    u_int   sync_match;
+    u_int   sync_fields;
     u_long	frames_captured;/* number of frames captured since open */
     u_long	even_fields_captured; /* number of even fields captured */
     u_long	odd_fields_captured; /* number of odd fields captured */

--r5Pyd7+fXNt84Ff3--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020218165923.B60190>