NetBSD Problem Report #26751

Received: (qmail 2649 invoked by uid 605); 24 Aug 2004 12:22:21 -0000
Message-Id: <200408241153.i7OBrqHc001760@localhost.>
Date: Tue, 24 Aug 2004 13:53:52 +0200 (SAST)
From: yha@na.rau.ac.za
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: yha@na.rau.ac.za
To: gnats-bugs@gnats.NetBSD.org
Subject: add support for tea5757 to bktr(4)
X-Send-Pr-Version: 3.95

>Number:         26751
>Category:       kern
>Synopsis:       add support for tea5757 to bktr(4)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 24 12:23:00 +0000 2004
>Closed-Date:    
>Last-Modified:  
>Originator:     Yorick hardy
>Release:        NetBSD 2.0_BETA
>Organization:
>Environment:
System: NetBSD yha 2.0_BETA NetBSD 2.0_BETA (YHA) #4: Tue Aug 10 11:15:54 SAST 2004 yorick@yha:/usr/obj/sys/arch/i386/compile/YHA i386
Architecture: i386
Machine: i386
>Description:
Add support for the TEA5757 radio chip used by some bktr(4) compatible cards.
>How-To-Repeat:
>Fix:
--- sys/dev/pci/bktr/bktr_card.c.orig	2003-10-30 03:58:17.000000000 +0200
+++ sys/dev/pci/bktr/bktr_card.c	2004-08-07 18:40:35.000000000 +0200
@@ -132,6 +132,9 @@
 #define DEFAULT_TUNER   PHILIPS_NTSC
 #endif

+/* Use an instance specific to the card, not the radio chip
+   since different cards may use different gpio pins for control */
+static const struct RADIO vhx_radio = { RADIO_TYPE_TEA5757, { 3, 4, 5 } };



@@ -153,7 +156,8 @@
 	   0,					/* EEProm unknown */
 	   0,					/* EEProm unknown */
 	   { 0, 0, 0, 0, 0 },
-	   0 },					/* GPIO mask */
+	   0,					/* GPIO mask */
+	   NULL },

 	{  CARD_MIRO,				/* the card id */
 	  "Pinnacle/Miro TV",			/* the 'name' */
@@ -165,7 +169,8 @@
 	   0,					/* EEProm unknown */
 	   0,					/* size unknown */
 	   { 0x02, 0x01, 0x00, 0x0a, 1 },	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

 	{  CARD_HAUPPAUGE,			/* the card id */
 	  "Hauppauge WinCast/TV",		/* the 'name' */
@@ -177,7 +182,8 @@
 	   PFC8582_WADDR,			/* EEProm type */
 	   (u_char)(256 / EEPROMBLOCKSIZE),	/* 256 bytes */
 	   { 0x00, 0x02, 0x01, 0x04, 1 },	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

 	{  CARD_STB,				/* the card id */
 	  "STB TV/PCI",				/* the 'name' */
@@ -189,7 +195,8 @@
 	   X24C01_WADDR,			/* EEProm type */
 	   (u_char)(128 / EEPROMBLOCKSIZE),	/* 128 bytes */
 	   { 0x00, 0x01, 0x02, 0x02, 1 }, 	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

 	{  CARD_INTEL,				/* the card id */
 	  "Intel Smart Video III/VideoLogic Captivator PCI", /* the 'name' */
@@ -201,7 +208,8 @@
 	   0,
 	   0,
 	   { 0, 0, 0, 0, 0 }, 			/* audio MUX values */
-	   0x00 },				/* GPIO mask */
+	   0x00,				/* GPIO mask */
+	   NULL },

 	{  CARD_IMS_TURBO,			/* the card id */
 	  "IMS TV Turbo",			/* the 'name' */
@@ -213,7 +221,8 @@
 	   PFC8582_WADDR,			/* EEProm type */
 	   (u_char)(256 / EEPROMBLOCKSIZE),	/* 256 bytes */
 	   { 0x01, 0x02, 0x01, 0x00, 1 },	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

         {  CARD_AVER_MEDIA,			/* the card id */
           "AVer Media TV/FM",                   /* the 'name' */
@@ -225,7 +234,8 @@
            0,                                   /* EEProm type */
            0,                                   /* EEProm size */
            { 0x0c, 0x08, 0x04, 0x00, 1 },	/* audio MUX values */
-	   0x1f },				/* GPIO mask */
+	   0x1f,				/* GPIO mask */
+	   NULL },

         {  CARD_OSPREY,				/* the card id */
           "MMAC Osprey",                   	/* the 'name' */
@@ -237,7 +247,8 @@
 	   PFC8582_WADDR,			/* EEProm type */
 	   (u_char)(256 / EEPROMBLOCKSIZE),	/* 256 bytes */
            { 0x00, 0x00, 0x00, 0x00, 0 },	/* audio MUX values */
-	   0 },					/* GPIO mask */
+	   0,					/* GPIO mask */
+	   NULL },

         {  CARD_NEC_PK,                         /* the card id */
           "NEC PK-UG-X017",                     /* the 'name' */
@@ -249,7 +260,8 @@
            0,                                   /* EEProm type */
            0,                                   /* EEProm size */
            { 0x01, 0x02, 0x01, 0x00, 1 },	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

         {  CARD_IO_GV,                          /* the card id */
           "I/O DATA GV-BCTV2/PCI",              /* the 'name' */
@@ -261,7 +273,8 @@
            0,                                   /* EEProm type */
            0,                                   /* EEProm size */
            { 0x00, 0x00, 0x00, 0x00, 1 },	/* Has special MUX handler */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

         {  CARD_FLYVIDEO,			/* the card id */
           "FlyVideo",				/* the 'name' */
@@ -273,7 +286,8 @@
 	   0xac,				/* EEProm type */
 	   (u_char)(256 / EEPROMBLOCKSIZE),	/* 256 bytes */
            { 0x000, 0x800, 0x400, 0x8dff00, 1 },/* audio MUX values */
-	   0x8dff00 },				/* GPIO mask */
+	   0x8dff00,				/* GPIO mask */
+	   NULL },

 	{  CARD_ZOLTRIX,			/* the card id */
 	  "Zoltrix",				/* the 'name' */
@@ -285,7 +299,8 @@
 	   0,					/* EEProm type */
 	   0,					/* EEProm size */
 	   { 0x04, 0x01, 0x00, 0x0a, 1 },	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

 	{  CARD_KISS,				/* the card id */
 	  "KISS TV/FM PCI",			/* the 'name' */
@@ -297,7 +312,8 @@
 	   0,					/* EEProm type */
 	   0,					/* EEProm size */
 	   { 0x0c, 0x00, 0x0b, 0x0b, 1 },	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

 	{  CARD_VIDEO_HIGHWAY_XTREME,		/* the card id */
 	  "Video Highway Xtreme",		/* the 'name' */
@@ -309,7 +325,8 @@
 	   0,					/* EEProm type */
 	   0,					/* EEProm size */
 	   { 0x00, 0x02, 0x01, 0x04, 1 },	/* audio MUX values */
-	   0x0f },				/* GPIO mask */
+	   0x0f,				/* GPIO mask */
+	   NULL },

 	{  CARD_ASKEY_DYNALINK_MAGIC_TVIEW,	/* the card id */
 	  "Askey/Dynalink Magic TView",		/* the 'name' */
@@ -321,7 +338,8 @@
 	   0,					/* EEProm type */
 	   0,					/* EEProm size */
 	   { 0x400, 0xE00, 0x400, 0xC00, 1 },	/* audio MUX values */
-	   0xE00 },				/* GPIO mask */
+	   0xE00,				/* GPIO mask */
+	   NULL },

 	{  CARD_LEADTEK,			/* the card id */
 	  "Leadtek WinFast TV2000/VC100",	/* the 'name' */
@@ -334,7 +352,8 @@
 	   0,					/* EEProm size */
 	   /* Tuner, Extern, Intern, Mute, Enabled */
 	   { 0x621000, 0x621000, 0x621000, 0xE21000, 1 }, /* audio MUX values */
-	   0xfff000 },				/* GPIO mask */
+	   0xfff000,				/* GPIO mask */
+	   NULL },

         {  CARD_TERRATVPLUS,                    /* the card id */
           "TerraTVplus",                        /* the 'name' */
@@ -346,8 +365,21 @@
 	   0,					/* EEProm type */
 	   0,					/* EEProm size */
            { 0x20000, 0x00000, 0x30000, 0x40000, 1 }, /* audio MUX values*/
-           0x70000 },                           /* GPIO mask */
+           0x70000,                             /* GPIO mask */
+	   NULL },

+	{  CARD_VIDEO_HIGHWAY_XTREME98,		/* the card id */
+	  "Video Highway Xtreme 98",		/* the 'name' */
+           NULL,				/* the tuner */
+	   0,
+	   0,
+	   0,
+	   0,
+	   0,					/* EEProm type */
+	   0,					/* EEProm size */
+	   { 0x00, 0x02, 0x01, 0x04, 1 },	/* audio MUX values */
+	   0x3f,				/* GPIO mask */
+	   &vhx_radio },
 };

 struct bt848_card_sig bt848_card_signature[1]= {
@@ -1240,7 +1272,8 @@
 		bktr->xtal_pll_mode = BT848_USE_PLL;

 	/* Enable PLL mode for Video Highway Xtreme users */
-	if (card == CARD_VIDEO_HIGHWAY_XTREME)
+	if (card == CARD_VIDEO_HIGHWAY_XTREME ||
+	    card == CARD_VIDEO_HIGHWAY_XTREME98)
 		bktr->xtal_pll_mode = BT848_USE_PLL;


--- sys/dev/pci/bktr/bktr_card.h.orig	2003-03-12 02:14:40.000000000 +0200
+++ sys/dev/pci/bktr/bktr_card.h	2004-08-07 16:08:30.000000000 +0200
@@ -79,8 +79,11 @@
 #define CARD_ASKEY_DYNALINK_MAGIC_TVIEW	14
 #define CARD_LEADTEK		15
 #define CARD_TERRATVPLUS	16
-#define Bt848_MAX_CARD		17
+#define CARD_VIDEO_HIGHWAY_XTREME98	17
+#define Bt848_MAX_CARD		18

+#define RADIO_TYPE_TEA5757 0
+#define RADIO_TYPE_TEA5759 1

 int	signCard(bktr_ptr_t bktr, int offset, int count, u_char* sig);
 void	probeCard(bktr_ptr_t bktr, int verbose, int unit);
--- sys/dev/pci/bktr/bktr_reg.h.orig	2003-03-12 02:14:41.000000000 +0200
+++ sys/dev/pci/bktr/bktr_reg.h	2004-08-07 15:57:12.000000000 +0200
@@ -419,6 +419,18 @@

 };

+/* description of separate radio component */
+/* 
+ * gpio_pins lists the pins used, for example the first three entries for
+ * the TEA5757 will be the pins for the CLOCK, DATA and WRITE ENABLE in
+ * that order. This allows the gpio pins used for controlling the radio
+ * to be specified for each card.
+ */
+struct RADIO {
+	unsigned int		type;
+	char			gpio_pins[24];
+};
+
 /* description of the card */
 #define EEPROMBLOCKSIZE		32
 struct CARDTYPE {
@@ -435,6 +447,7 @@
 						/* int/unused (radio) */
 						/* mute, present */
 	u_int			gpio_mux_bits;	/* GPIO mask for audio mux */
+        const struct RADIO*     radio;          /* Separate radio support */
 };

 struct format_params {
--- sys/dev/pci/bktr/bktr_tuner.c.orig	2003-03-12 02:14:41.000000000 +0200
+++ sys/dev/pci/bktr/bktr_tuner.c	2004-08-07 16:04:51.000000000 +0200
@@ -140,6 +140,14 @@
 /* The control value for the ALPS TSBH1 Tuner */
 #define TSBH1_FCONTROL		0xce

+/* Constants for the TEA5757/9 */
+#define TEA5757_BAND_FM 0
+#define TEA5757_BAND_MW (1<<20) 
+#define TEA5757_BAND_LW (2<<20)
+#define TEA5757_BAND_SW (3<<20)
+#define TEA5757_MONO (1<<22)
+#define TEA5757_FMIF 1070
+#define TEA5757_AMIF 1070

 static const struct TUNER tuners[] = {
 /* XXX FIXME: fill in the band-switch crosspoints */
@@ -768,6 +776,65 @@
 #define STATUSBIT_STEREO 0x10 /* valid if FM (aka not TV) */
 #define STATUSBIT_ADC    0x07

+void
+tea5757_write( bktr_ptr_t bktr, unsigned int value )
+{
+ int mask  = INL(bktr,BKTR_GPIO_OUT_EN);
+ int temp  = INL(bktr,BKTR_GPIO_DATA);
+ int clock = (1 << ((bktr->card).radio)->gpio_pins[0]);
+ int data  = (1 << ((bktr->card).radio)->gpio_pins[1]);
+ int write = (1 << ((bktr->card).radio)->gpio_pins[2]);
+ int i,bit;
+ int clock_low=0,clock_high=clock;
+ int data_low =0,data_high =data;
+ int write_low=0,write_high=write;
+
+ temp &= ~(clock|data|write);
+ OUTL(bktr,BKTR_GPIO_OUT_EN,mask|clock|data|write);
+ for(i=24;i>=0;i--) {
+  bit = (value&(1<<i));
+  if(bit) bit = data_high; else bit = data_low;
+  OUTL(bktr,BKTR_GPIO_DATA,temp|bit|write_high|clock_low);
+  DELAY(2);
+  OUTL(bktr,BKTR_GPIO_DATA,temp|bit|write_high|clock_high);
+  DELAY(2);
+  OUTL(bktr,BKTR_GPIO_DATA,temp|bit|write_high|clock_low);
+ }
+ OUTL(bktr,BKTR_GPIO_DATA,temp|data_low|write_low|clock_low);
+ DELAY(2);
+ OUTL(bktr,BKTR_GPIO_OUT_EN,mask);
+}
+
+int
+tea5757_read( bktr_ptr_t bktr )
+{
+ int mask  = INL(bktr,BKTR_GPIO_OUT_EN);
+ int temp  = INL(bktr,BKTR_GPIO_DATA);
+ int clock = (1 << ((bktr->card).radio)->gpio_pins[0]);
+ int data  = (1 << ((bktr->card).radio)->gpio_pins[1]);
+ int write = (1 << ((bktr->card).radio)->gpio_pins[2]);
+ int i,d = 0;
+ int clock_low=0,clock_high=clock;
+ int data_low =0;
+ int write_low=0;
+
+ temp &= ~(clock|data|write);
+ OUTL(bktr,BKTR_GPIO_OUT_EN,((mask|clock|write)&~data));
+ OUTL(bktr,BKTR_GPIO_DATA,temp|clock_low|write_low);
+ for(i=23;i>=0;i--) {
+  OUTL(bktr,BKTR_GPIO_DATA,temp|write_low|clock_low);
+  if(i == 23) DELAY(15); else DELAY(2);
+  OUTL(bktr,BKTR_GPIO_DATA,temp|write_low|clock_high);
+  DELAY(2);
+  OUTL(bktr,BKTR_GPIO_DATA,temp|write_low|clock_low);
+  if(INL(bktr,BKTR_GPIO_DATA)&data) d|=(1<<i);
+ }
+ OUTL(bktr,BKTR_GPIO_DATA,temp|data_low|write_low|clock_low);
+ DELAY(2);
+ OUTL(bktr,BKTR_GPIO_OUT_EN,mask);
+ return d;
+}
+
 /*
  * set the frequency of the tuner
  * If 'type' is TV_FREQUENCY, the frequency is freq MHz*16
@@ -866,6 +933,20 @@
 	if (type == FM_RADIO_FREQUENCY) {
 		band_select = FM_RADIO_BAND;

+		/* Use the radio chip if present */
+		if ( bktr->card.radio != (struct RADIO*)NULL ) {
+			switch ( (bktr->card.radio)->type ) {
+			 case RADIO_TYPE_TEA5757:
+				 N = ((frequency + TEA5757_FMIF)*100)/125;
+				 tea5757_write(bktr,TEA5757_BAND_FM|N); break;
+			 case RADIO_TYPE_TEA5759:
+				 N = ((frequency - TEA5757_FMIF)*100)/125;
+				 tea5757_write(bktr,TEA5757_BAND_FM|N); break;
+			}
+			bktr->tuner.frequency = frequency;
+			return( 0 );
+		}
+
 		/*
 		 * N = { fRF(pc) + fIF(pc) }/step_size
                  * The step size is 50kHz for FM radio.
--- sys/dev/pci/bktr/bktr_tuner.h.orig	2003-03-12 02:14:41.000000000 +0200
+++ sys/dev/pci/bktr/bktr_tuner.h	2004-08-07 15:59:50.000000000 +0200
@@ -90,6 +90,9 @@
 int	tv_channel(bktr_ptr_t bktr, int channel);
 int	tv_freq(bktr_ptr_t bktr, int frequency, int type);
 int	get_tuner_status(bktr_ptr_t bktr);
+void	tea5757_write( bktr_ptr_t bktr, unsigned int value );
+int	tea5757_read( bktr_ptr_t bktr );
+

 #if defined(TUNER_AFC)
 int	do_afc(bktr_ptr_t bktr, int addr, int frequency);
>Release-Note:
>Audit-Trail:
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.