Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jun 1997 22:38:53 -0400
From:      Randall Hopper <rhh@ct.picker.com>
To:        Amancio Hasty <hasty@rah.star-gate.com>, Steve Passe <smp@csn.net>
Cc:        multimedia@freebsd.org
Subject:   bktr FPS/Temporal Decimation problems
Message-ID:  <19970603223853.09824@ct.picker.com>

next in thread | raw e-mail | index | archive | help
     Well, after picking at the FPS problems for a few evenings, I need to
ask for some help.  I got it partially working (works fine in single
field--though I'm sure the method probably isn't right), but in interlaced
mode the engine seems to be dropping fields instead of frames, giving a
cool (but wrong) ghosting effect.

     Attached is my patch to this point.  It will apply to the 970424
driver posted on the home page.  The original TDEC computation wasn't
correct.  Additionally, I've made the FPS code more PAL-friendly,
obsoleting a PAL FPS hack that was in there.  It also turns temporal
decimation off for CAP_SINGLEs so you always get a frame in this capture
mode.

     The problem: despite the databook's description of how temporal
decimation on frames is supposed to work (whole frames are masked as a unit
for purposes of synchronization), it appears that the engine is masking out
fields, or rotating the enablement of the fields based on the requested
number of dropped frames.  Anyway, I must be missing something.  Could sure
use a set of eyes with more bt experience.

     BTW, in the patch, the correct TDEC computation:

/*#define FPS_TO_TDEC(bktr,fps) (((FPS_MAX(bktr) - (fps))*2) & 0x3f)*/

is commented out in favor of a tweaked version I was having better luck
with.

Thanks,

Randall


--- brooktree848.c-970424	Sun Jun  1 20:35:25 1997
+++ brooktree848.c	Tue Jun  3 22:21:19 1997
@@ -176,6 +176,10 @@
                            interrupt isn't delivered, and fixed fixing 
 			   CAP_SINGLEs that for ODD_ONLY fields.
 
+1.19            6/02/97    Randall Hopper <rhh@ct.picker.com>
+                           Fix temporal decimation, & disable it when doing
+			   CAP_SINGLEs.
+
 */
 
 #include "bktr.h"
@@ -255,6 +259,14 @@
 
 #define BKTRPRI (PZERO+8)|PCATCH
 
+#define NTSC_ACTIVE(bktr)     (bktr->format_params == FORMAT_PARAMS_NTSC525)
+#define FPS_MAX(bktr)         (NTSC_ACTIVE(bktr) ? 30 : 25)
+
+/*  Though the docs say # of frames or fields to drop out of a total of   */
+/*    60, for single-field captures, we get better results using 30.      */
+/*#define FPS_TO_TDEC(bktr,fps) (((FPS_MAX(bktr) - (fps))*2) & 0x3f)*/
+#define FPS_TO_TDEC(bktr,fps) ((FPS_MAX(bktr) - (fps)) & 0x3f)
+
 static char*	bktr_probe( pcici_t tag, pcidi_t type );
 static void	bktr_attach( pcici_t tag, int unit );
 
@@ -764,16 +776,24 @@
 	printf( " STATUS %x %x %x \n",
 		dstatus, bktr_status, bt848->risc_count );
 	*/
+
+#define RESTART_ERRORS  (BT848_INT_FBUS   | BT848_INT_FTRGT  | \
+			 BT848_INT_FDSR   | BT848_INT_PPERR  | \
+			 BT848_INT_RIPERR | BT848_INT_PABORT | \
+			 BT848_INT_OCERR  | BT848_INT_SCERR)
+
+	/* if temp decimation is on, frames will be skipped; ignore dropped */
+	/*   data and overrun errors logged w/ the frame after the skip(s)  */
+	if ( (bt848->tdec != 0) && (bktr_status & BT848_INT_RISC_EN) &&
+	     (bktr_status & BT848_INT_RISCI) &&
+	     (bktr_status & (BT848_INT_FDSR | BT848_INT_FBUS)) &&
+	     !(bktr_status & 
+	       (RESTART_ERRORS & ~(BT848_INT_FDSR | BT848_INT_FBUS))) )
+		bktr_status &= ~(BT848_INT_FDSR | BT848_INT_FBUS);
+
 	/* if risc was disabled re-start process again */
-	if ( !(bktr_status & BT848_INT_RISC_EN) ||
-	     ((bktr_status & (BT848_INT_FBUS   |
-			      BT848_INT_FTRGT  |
-			      BT848_INT_FDSR   |
-			      BT848_INT_PPERR  |
-			      BT848_INT_RIPERR |
-			      BT848_INT_PABORT |
-			      BT848_INT_OCERR  |
-			      BT848_INT_SCERR)) != 0) ) {
+	else if ( !(bktr_status & BT848_INT_RISC_EN) ||
+	     ((bktr_status & RESTART_ERRORS) != 0) ) {
 
 		bt848->gpio_dma_ctl = FIFO_RISC_DISABLED;
 
@@ -981,7 +1001,7 @@
 	bktr->even_fields_captured = 0;
 	bktr->odd_fields_captured = 0;
 	bktr->proc = (struct proc *)0;
-	set_fps(bktr, 30);
+	set_fps(bktr, FPS_MAX(bktr));
 	bktr->video.addr = 0;
 	bktr->video.width = 0;
 	bktr->video.banksize = 0;
@@ -2350,9 +2370,9 @@
 
 	/* contruct sync : for video packet format */
 	*dma_prog++ = OP_SYNC  | 1 << 15 | BKTR_FM1;
+	*dma_prog++ = 0;  /* NULL WORD */
 
 	/* sync, mode indicator packed data */
-	*dma_prog++ = 0;  /* NULL WORD */
 	width = cols;
 	for (i = 0; i < (rows/interlace); i++) {
 	    target = target_buffer;
@@ -2793,6 +2813,12 @@
 	bt848->dstatus = 0;
 	bt848->int_stat = bt848->int_stat;
 
+	/*  For capcontin, set FPS (disable for capsingle)          */
+	/*    (Always init to 0 first to reset decimation counter)  */
+	bt848->tdec = 0;
+	if ( type != METEOR_SINGLE )
+		bt848->tdec = FPS_TO_TDEC( bktr, bktr->fps );
+
 	bktr->flags |= type;
 	switch(bktr->flags & METEOR_ONLY_FIELDS_MASK) {
 	case METEOR_ONLY_EVEN_FIELDS:
@@ -2844,13 +2870,8 @@
 
 	bktr->fps = fps;
 
-	if ( fps == 30 ) {
-		bt848->tdec = 0;
-		return;
-	} else {
-		bt848->tdec = (int) (((float) fps / 30.0) * 60.0) & 0x3f;
-		bt848->tdec |= 0x80;
-	}
+	bt848->tdec = 0;	/*  Always init to 0 1st to reset decim ctr */
+	bt848->tdec = FPS_TO_TDEC( bktr, bktr->fps );
 
 	if ( bktr->flags & METEOR_CAP_MASK ) {
 



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