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

bktr(4) patches: new device, consistency



The following patch

  adds configuration for ATI TV Wonder Value Edition.  it's the only
  new bktr(4) card I could find in Eugene, OR.

  consistently uppercases acronyms in comments. PCI, DMA, RISC, RGB,
  YUV, etc.

  consistently types dma_prog and target_buffer.

  makes yuvpack_prog use the same types as the other capture routines.

  fixes various spelling errors and typos.

I've been running these patches for a couple weeks, I haven't noticed
any difference in functionality (except of course, for the card specific
configuration information).

-- 
<jakemsr@jakemsr.com>


Index: bktr_card.c
===================================================================
RCS file: /home/cvs/OpenBSD/src/sys/dev/pci/bktr/bktr_card.c,v
retrieving revision 1.8
diff -u -r1.8 bktr_card.c
--- bktr_card.c	24 May 2004 21:59:28 -0000	1.8
+++ bktr_card.c	28 Jun 2004 04:53:28 -0000
@@ -343,6 +343,18 @@
            { 0x20000, 0x00000, 0x30000, 0x40000, 1 }, /* audio MUX values*/
            0x70000 },                           /* GPIO mask */
 
+	{  CARD_TVWONDER,			/* the card id */
+	   "ATI TV-Wonder/VE",			/* the 'name' */
+	   NULL,				/* the tuner */
+	   0,
+	   0,
+	   0,
+	   0,
+	   0,					/* EEProm type */
+	   0,					/* EEProm size */
+	   { 0x1002, 0x1002, 0x3003, 0x3003, 0x3003 },	/* audio MUX values*/
+	   0x300f },					/* GPIO mask */
+
 };
 
 struct bt848_card_sig bt848_card_signature[1]= {
@@ -498,7 +510,7 @@
  *
  * However some makes of card (eg Hauppauge) come with a configuration eeprom
  * which tells us the make of the card. Most eeproms also tell us the
- * tuner type and other features of the the cards.
+ * tuner type and other features of the cards.
  *
  * The current probe code works as follows
  * A) If the card uses a Bt878/879:
@@ -680,6 +692,13 @@
                     goto checkTuner;
                 }
 
+		if (subsystem_vendor_id == PCI_VENDOR_ATI) {
+                    bktr->card = cards[ (card = CARD_TVWONDER) ];
+		    bktr->card.eepromAddr = eeprom_i2c_address;
+		    bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
+                    goto checkTuner;
+                }
+
                 /* Vendor is unknown. We will use the standard probe code */
 		/* which may not give best results */
                 printf("%s: Warning "
@@ -1087,6 +1106,11 @@
 #else
 	    select_tuner( bktr, PHILIPS_FR1236_NTSC );
 #endif
+            goto checkDBX;
+	    break;
+
+	case CARD_TVWONDER:
+	    select_tuner( bktr, PHILIPS_NTSC );
             goto checkDBX;
 	    break;
 
Index: bktr_card.h
===================================================================
RCS file: /home/cvs/OpenBSD/src/sys/dev/pci/bktr/bktr_card.h,v
retrieving revision 1.3
diff -u -r1.3 bktr_card.h
--- bktr_card.h	25 Feb 2004 08:42:38 -0000	1.3
+++ bktr_card.h	28 Jun 2004 04:53:28 -0000
@@ -77,7 +77,8 @@
 #define CARD_ASKEY_DYNALINK_MAGIC_TVIEW	14
 #define CARD_LEADTEK		15
 #define CARD_TERRATVPLUS	16
-#define Bt848_MAX_CARD		17
+#define CARD_TVWONDER		17
+#define Bt848_MAX_CARD		18
 
 
 int	signCard( bktr_ptr_t bktr, int offset, int count, u_char *sig );
Index: bktr_core.c
===================================================================
RCS file: /home/cvs/OpenBSD/src/sys/dev/pci/bktr/bktr_core.c,v
retrieving revision 1.12
diff -u -r1.12 bktr_core.c
--- bktr_core.c	24 May 2004 21:59:28 -0000	1.12
+++ bktr_core.c	28 Jun 2004 04:53:28 -0000
@@ -239,9 +239,9 @@
  */
 #define DMA_PROG_ALLOC		(8 * PAGE_SIZE)
 
-/* When to split a dma transfer , the bt848 has timing as well as
-   dma transfer size limitations so that we have to split dma
-   transfers into two dma requests
+/* When to split a DMA transfer , the bt848 has timing as well as
+   DMA transfer size limitations so that we have to split DMA
+   transfers into two DMA requests
    */
 #define DMA_BT848_SPLIT 319*2
 
@@ -478,7 +478,7 @@
 /* *** OS Specific memory routines *** */
 /***************************************/
 #if defined(__NetBSD__) || defined(__OpenBSD__)
-        /* allocate space for dma program */
+        /* allocate space for DMA program */
         bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, DMA_PROG_ALLOC);
         bktr->odd_dma_prog = get_bktr_mem(bktr, &bktr->dm_oprog,
 	    DMA_PROG_ALLOC);
@@ -512,7 +512,7 @@
 #endif
 
 	if (need_to_allocate_memory == 1) {
-		/* allocate space for dma program */
+		/* allocate space for DMA program */
 		bktr->dma_prog     = get_bktr_mem(unit, DMA_PROG_ALLOC);
 		bktr->odd_dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC);
 
@@ -557,7 +557,7 @@
 		bktr->alloc_pages = 0;
 	}
 
-	bktr->flags = METEOR_INITALIZED | METEOR_AUTOMODE |
+	bktr->flags = METEOR_INITIALIZED | METEOR_AUTOMODE |
 		      METEOR_DEV0 | METEOR_RGB16;
 	bktr->dma_prog_loaded = FALSE;
 	bktr->cols = 640;
@@ -572,7 +572,7 @@
 	bktr->vbisize = 0;
 	bktr->vbiflags = 0;
 
-	/* using the pci device id and revision id */
+	/* using the PCI device id and revision id */
 	/* and determine the card type            */
 	if (PCI_VENDOR(pci_id) == PCI_VENDOR_BROOKTREE) {
 		switch (PCI_PRODUCT(pci_id)) {
@@ -597,7 +597,7 @@
 	bktr->clr_on_start = FALSE;
 
 	/* defaults for the tuner section of the card */
-	bktr->tflags = TUNER_INITALIZED;
+	bktr->tflags = TUNER_INITIALIZED;
 	bktr->tuner.frequency = 0;
 	bktr->tuner.channel = 0;
 	bktr->tuner.chnlset = DEFAULT_CHNLSET;
@@ -710,7 +710,7 @@
 	*/
 
 
-	/* if risc was disabled re-start process again */
+	/* if RISC was disabled re-start process again */
 	/* if there was one of the following errors re-start again */
 	if ( !(bktr_status & BT848_INT_RISC_EN) ||
 	     ((bktr_status &(/* BT848_INT_FBUS   | */
@@ -894,10 +894,10 @@
 		 */
 		if (bktr->flags & METEOR_SINGLE) {
 
-			/* stop dma */
+			/* stop DMA */
 			OUTL(bktr, BKTR_INT_MASK, ALL_INTS_DISABLED);
 
-			/* disable risc, leave fifo running */
+			/* disable RISC, leave FIFO running */
 			OUTW(bktr, BKTR_GPIO_DMA_CTL, FIFO_ENABLED);
 			wakeup(BKTR_SLEEP);
 		}
@@ -1080,7 +1080,7 @@
 int
 tuner_open( bktr_ptr_t bktr )
 {
-	if ( !(bktr->tflags & TUNER_INITALIZED) )	/* device not found */
+	if ( !(bktr->tflags & TUNER_INITIALIZED) )	/* device not found */
 		return( ENXIO );
 
 	if ( bktr->tflags & TUNER_OPEN )		/* already open */
@@ -1604,10 +1604,10 @@
 					INL(bktr, BKTR_RISC_COUNT));
 #endif
 
-				/* stop dma */
+				/* stop DMA */
 				OUTL(bktr, BKTR_INT_MASK, ALL_INTS_DISABLED);
 
-				/* disable risc, leave fifo running */
+				/* disable RISC, leave FIFO running */
 				OUTW(bktr, BKTR_GPIO_DMA_CTL, FIFO_ENABLED);
 			}
 
@@ -2758,7 +2758,7 @@
 	/* Construct Write */
 
 	if (bktr->video.addr) {
-		target_buffer = bktr->video.addr;
+		target_buffer = (u_int)bktr->video.addr;
 		pitch = bktr->video.width;
 	}
 	else {
@@ -2933,7 +2933,7 @@
 	/* Construct Write */
 
 	if (bktr->video.addr) {
-		target_buffer = (u_long) bktr->video.addr;
+		target_buffer = (u_int) bktr->video.addr;
 		pitch = bktr->video.width;
 	}
 	else {
@@ -3067,11 +3067,11 @@
 yuvpack_prog( bktr_ptr_t bktr, char i_flag,
 	      int cols, int rows, int interlace )
 {
-	int			i;
-	volatile unsigned int	inst;
-	volatile unsigned int	inst3;
-	volatile u_long		target_buffer, buffer;
-	volatile  u_long	*dma_prog;
+	int		i;
+	u_int		inst;
+	u_int		inst3;
+	u_int		target_buffer, buffer;
+	u_int		*dma_prog;
         const struct meteor_pixfmt_internal *pf_int = &pixfmt_table[ bktr->pixfmt ];
 	int			b;
 
@@ -3086,7 +3086,7 @@
 	bktr->capcontrol =   1 << 6 | 1 << 4 | 1 << 2 | 3;
 	bktr->capcontrol = 3 << 2 |  3;
 
-	dma_prog = (u_long *) bktr->dma_prog;
+	dma_prog = (u_int *) bktr->dma_prog;
 
 	/* Construct Write */
 
@@ -3096,7 +3096,7 @@
 	inst3 = OP_WRITE | OP_EOL | (cols);
 
 	if (bktr->video.addr)
-		target_buffer = (u_long) bktr->video.addr;
+		target_buffer = (u_int) bktr->video.addr;
 	else
 #ifdef __FreeBSD__
 		target_buffer = (u_long) vtophys(bktr->bigbuf);
@@ -3106,7 +3106,7 @@
 
 	buffer = target_buffer;
 
-	/* contruct sync : for video packet format */
+	/* construct sync : for video packet format */
 	/* sync, mode indicator packed data */
 	*dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC | BKTR_FM1);
 	*dma_prog++ = htole32(0);  /* NULL WORD */
@@ -3162,9 +3162,9 @@
 
 	if (interlace == 2) {
 
-		target_buffer =	 (u_long) buffer + cols*2;
+		target_buffer =	 (u_int) buffer + cols*2;
 
-		dma_prog = (u_long * ) bktr->odd_dma_prog;
+		dma_prog = (u_int *) bktr->odd_dma_prog;
 
 		/* sync vre */
 		*dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC | BKTR_FM1);
@@ -3249,7 +3249,7 @@
 
 	t1 = buffer;
 
-	/* contruct sync : for video packet format */
+	/* construct sync : for video packet format */
 	/*     sync, mode indicator packed data*/
 	*dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC | BKTR_FM3);
 	*dma_prog++ = htole32(0);  /* NULL WORD */
@@ -3362,7 +3362,7 @@
 	inst  = OP_WRITE123  | OP_SOL | OP_EOL |  (cols);
 	inst1  = OP_WRITES123  | OP_SOL | OP_EOL |  (cols);
 	if (bktr->video.addr)
-		target_buffer = (u_long) bktr->video.addr;
+		target_buffer = (u_int) bktr->video.addr;
 	else
 #ifdef __FreeBSD__
 		target_buffer = (u_long) vtophys(bktr->bigbuf);
@@ -3373,6 +3373,7 @@
 	buffer = target_buffer;
 	t1 = buffer;
 
+	/* construct sync : for video packet format */
 	/* sync, mode indicator packed data*/
 	*dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC | BKTR_FM3);
 	*dma_prog++ = htole32(0);  /* NULL WORD */
@@ -3433,7 +3434,7 @@
 
 		dma_prog = (u_int *)bktr->odd_dma_prog;
 
-		target_buffer  = (u_long) buffer + cols;
+		target_buffer  = (u_int) buffer + cols;
 		t1 = buffer + cols/2;
 		*dma_prog++ = htole32(OP_SYNC | BKTR_RESYNC | BKTR_FM3);
 		*dma_prog++ = htole32(0);  /* NULL WORD */
@@ -3632,8 +3633,8 @@
 	bktr->vbiflags &= ~VBI_CAPTURE;	/* default - no vbi capture */
 
 	/* RGB Grabs. If /dev/vbi is already open, or we are a PAL/SECAM */
-	/* user, then use the rgb_vbi RISC program. */
-	/* Otherwise, use the normal rgb RISC program */
+	/* user, then use the rgb_vbi_prog() RISC program. */
+	/* Otherwise, use the normal rgb_prog() RISC program */
 	if (pf_int->public.type == METEOR_PIXTYPE_RGB) {
 		if ( (bktr->vbiflags & VBI_OPEN)
 		   ||(bktr->format_params == BT848_IFORM_F_PALBDGHI)
Index: bktr_os.c
===================================================================
RCS file: /home/cvs/OpenBSD/src/sys/dev/pci/bktr/bktr_os.c,v
retrieving revision 1.18
diff -u -r1.18 bktr_os.c
--- bktr_os.c	24 May 2004 21:56:41 -0000	1.18
+++ bktr_os.c	28 Jun 2004 04:53:28 -0000
@@ -422,7 +422,7 @@
 		printf(" %d.\n", (int) latency);
 	}
 
-	/* read the pci device id and revision id */
+	/* read the PCI device id and revision id */
 	fun = pci_get_devid(dev);
         rev = pci_get_revid(dev);
 
@@ -572,7 +572,7 @@
 		return (ENXIO);
 	}
 
-	if (!(bktr->flags & METEOR_INITALIZED)) /* device not found */
+	if (!(bktr->flags & METEOR_INITIALIZED)) /* device not found */
 		return( ENXIO );	
 
 	/* Record that the device is now busy */
@@ -1011,7 +1011,7 @@
 	}
 
 
-	/* read the pci id and determine the card type */
+	/* read the PCI id and determine the card type */
 	fun = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ID_REG);
         rev = PCI_REVISION(pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG));
 
@@ -1061,7 +1061,7 @@
                 return 0;
         }
         /*
-         * Create and locd the DMA map for the DMA area
+         * Create and load the DMA map for the DMA area
          */
         if (bus_dmamap_create(dmat, size, 1, size, 0, BUS_DMA_NOWAIT, dmapp)) {
                 printf("%s: Unable to dmamap_create of %d bytes\n",
@@ -1127,7 +1127,7 @@
 
 	bktr = bktr_cd.cd_devs[unit];
 
-	if (!(bktr->flags & METEOR_INITALIZED)) /* device not found */
+	if (!(bktr->flags & METEOR_INITIALIZED)) /* device not found */
 		return(ENXIO);	
 
 	switch (FUNCTION(dev)) {
Index: bktr_reg.h
===================================================================
RCS file: /home/cvs/OpenBSD/src/sys/dev/pci/bktr/bktr_reg.h,v
retrieving revision 1.6
diff -u -r1.6 bktr_reg.h
--- bktr_reg.h	5 Jan 2003 01:24:53 -0000	1.6
+++ bktr_reg.h	28 Jun 2004 04:53:28 -0000
@@ -91,11 +91,11 @@
 
 
 #ifndef PCI_LATENCY_TIMER
-#define	PCI_LATENCY_TIMER		0x0c	/* pci timer register */
+#define	PCI_LATENCY_TIMER		0x0c	/* PCI timer register */
 #endif
 
 /*
- * Definitions for the Brooktree 848/878 video capture to pci interface.
+ * Definitions for the Brooktree 848/878 video capture to PCI interface.
  */
 #ifndef __NetBSD__
 #ifdef __OpenBSD__
@@ -455,7 +455,7 @@
   int htotal, hdelay, hactive;
   /* Scaled horizontal image pixels, Total Scaled horizontal pixels */
   int  scaled_hactive, scaled_htotal;
-  /* frame rate . for ntsc is 30 frames per second */
+  /* frame rate . for NTSC is 30 frames per second */
   int frame_rate;
   /* A-delay and B-delay */
   u_char adelay, bdelay;
@@ -476,7 +476,7 @@
 /* Bt848/878 register access
  * The registers can either be access via a memory mapped structure
  * or accessed via bus_space.
- * bus_0pace access allows cross platform support, where as the
+ * bus_space access allows cross platform support, where as the
  * memory mapped structure method only works on 32 bit processors
  * with the right type of endianness.
  */
@@ -630,10 +630,10 @@
     char	capture_area_enabled;  /* When TRUE use user's capture area. */
     int		pixfmt;         /* active pixel format (idx into fmt tbl) */
     int		pixfmt_compat;  /* Y/N - in meteor pix fmt compat mode */
-    u_long	format;		/* frame format rgb, yuv, etc.. */
+    u_long	format;		/* frame format. RGB, YUV, etc.. */
     short	frames;		/* number of frames allocated */
     int		frame_size;	/* number of bytes in a frame */
-    u_long	fifo_errors;	/* number of fifo capture errors since open */
+    u_long	fifo_errors;	/* number of FIFO capture errors since open */
     u_long	dma_errors;	/* number of DMA capture errors since open */
     u_long	frames_captured;/* number of frames captured since open */
     u_long	even_fields_captured; /* number of even fields captured */
@@ -642,7 +642,7 @@
     u_short     capcontrol;     /* reg 0xdc capture control */
     u_short     bktr_cap_ctl;
     volatile u_int	flags;
-#define	METEOR_INITALIZED	0x00000001
+#define	METEOR_INITIALIZED	0x00000001
 #define	METEOR_OPEN		0x00000002 
 #define	METEOR_MMAP		0x00000004
 #define	METEOR_INTR		0x00000008
@@ -679,13 +679,13 @@
 #define METEOR_YUV_422		0x04000000
 #define	METEOR_OUTPUT_FMT_MASK	0x040f0000
 #define	METEOR_WANT_TS		0x08000000	/* time-stamp a frame */
-#define METEOR_RGB		0x20000000	/* meteor rgb unit */
+#define METEOR_RGB		0x20000000	/* meteor RGB unit */
 #define METEOR_FIELD_MODE	0x80000000
     u_char	tflags;				/* Tuner flags (/dev/tuner) */
-#define	TUNER_INITALIZED	0x00000001
+#define	TUNER_INITIALIZED	0x00000001
 #define	TUNER_OPEN		0x00000002 
     u_char      vbiflags;			/* VBI flags (/dev/vbi) */
-#define VBI_INITALIZED          0x00000001
+#define VBI_INITIALIZED         0x00000001
 #define VBI_OPEN                0x00000002
 #define VBI_CAPTURE             0x00000004
     u_short	fps;		/* frames per second */