Skip to contentSkip to conversation

dvb: add nxt200x frontend module

PATCH In review Michael Krufky 3 participants 4 messages Nov 1, 2005 – Nov 4, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 30/37 dvb: add nxt200x frontend module

From: Kirk Lapray <[email protected]>

* nxt200x.c, nxt200x.h
- New frontend module that supports both NXT2002 and NXT2004. So far, only tested on NXT2004. After testing on NXT2002, we should deprecate the nxt2002 module, and implement this one instead on the applicable cards.

* get_dvb_firmware:
- Added support for the NXT2004 firmware. This firmware works with both the ATI HDTV Wonder and the AVerTVHD MCE a180.
This was originally written by Jean-Francois Thibert

* dvb-pll.c
- Fixed minimum frequency for tuv1236d. It seems that the data sheets are wrong.

 Documentation/dvb/get_dvb_firmware    |   19 
 drivers/media/dvb/frontends/Kconfig   |    8 
 drivers/media/dvb/frontends/Makefile  |    1 
 drivers/media/dvb/frontends/dvb-pll.c |    2 
 drivers/media/dvb/frontends/nxt200x.c | 1203 ++++++++++++++++++++++++++++++++++
 drivers/media/dvb/frontends/nxt200x.h |   58 +
 6 files changed, 1289 insertions(+), 2 deletions(-)
Documentation/dvb/get_dvb_firmware +18 -1
@@ -22,7 +22,7 @@
 use IO::Handle;
 
 @components = ( "sp8870", "sp887x", "tda10045", "tda10046", "av7110", "dec2000t",
-		"dec2540t", "dec3000s", "vp7041", "dibusb", "nxt2002",
+		"dec2540t", "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
 		"or51211", "or51132_qam", "or51132_vsb");
 
 # Check args
@@ -252,6 +252,23 @@
     $outfile;
 }
 
+sub nxt2004 {
+    my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip";
+    my $url = "http://www.aver.com/support/Drivers/$sourcefile";
+    my $hash = "111cb885b1e009188346d72acfed024c";
+    my $outfile = "dvb-fe-nxt2004.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+
+    wgetfile($sourcefile, $url);
+    unzip($sourcefile, $tmpdir);
+    verify("$tmpdir/3xHybrid.sys", $hash);
+    extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile);
+
+    $outfile;
+}
+
 sub or51211 {
     my $fwfile = "dvb-fe-or51211.fw";
     my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
drivers/media/dvb/frontends/Kconfig +8 -0
@@ -164,6 +164,14 @@
 	help
 	  An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
 
+config DVB_NXT200X
+	tristate "Nextwave NXT2002/NXT2004 based"
+	depends on DVB_CORE
+	select FW_LOADER
+	help
+	  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
+	  to support this frontend.
+
 config DVB_OR51211
 	tristate "or51211 based (pcHDTV HD2000 card)"
 	depends on DVB_CORE
drivers/media/dvb/frontends/Makefile +1 -0
@@ -26,6 +26,7 @@
 obj-$(CONFIG_DVB_TDA10021) += tda10021.o
 obj-$(CONFIG_DVB_STV0297) += stv0297.o
 obj-$(CONFIG_DVB_NXT2002) += nxt2002.o
+obj-$(CONFIG_DVB_NXT2002) += nxt200x.o
 obj-$(CONFIG_DVB_OR51211) += or51211.o
 obj-$(CONFIG_DVB_OR51132) += or51132.o
 obj-$(CONFIG_DVB_BCM3510) += bcm3510.o
drivers/media/dvb/frontends/dvb-pll.c +1 -1
@@ -314,7 +314,7 @@
  */
 struct dvb_pll_desc dvb_pll_tuv1236d = {
 	.name  = "Philips TUV1236D",
-	.min   =  57000000,
+	.min   =  54000000,
 	.max   = 864000000,
 	.count = 3,
 	.entries = {
drivers/media/dvb/frontends/nxt200x.c new file +1203 -0

1,203 lines not on this page · raw message

drivers/media/dvb/frontends/nxt200x.h new file +58 -0

58 lines not on this page · raw message

#1 lore raw
Quoted 20 lines · Michael Krufky

From: Kirk Lapray <[email protected]>

* nxt200x.c, nxt200x.h
- New frontend module that supports both NXT2002 and NXT2004. So far, only tested on NXT2004. After testing on NXT2002, we should deprecate the nxt2002 module, and implement this one instead on the applicable cards.

* get_dvb_firmware:
- Added support for the NXT2004 firmware. This firmware works with both the ATI HDTV Wonder and the AVerTVHD MCE a180.
This was originally written by Jean-Francois Thibert

* dvb-pll.c
- Fixed minimum frequency for tuv1236d. It seems that the data sheets are wrong.

...

drivers/media/dvb/frontends/nxt200x.c line 98

Quoted 3 lines
drivers/media/dvb/frontends/nxt200x.c new file +3 -0
+static int nxt200x_writebytes (struct nxt200x_state* state, u8 reg, u8 *buf, u8 len)
+{
+	u8 buf2 [len+1];

hm, a variable-sized array, with the size defined by the caller. I guess as the size is
in a u8 it's unlikely to cause too much trouble.

(Wonders what the compiler will do if len==255. 256, I think.)

Quoted 36 lines
drivers/media/dvb/frontends/nxt200x.c new file +36 -0
+static int nxt200x_readreg_multibyte (struct nxt200x_state* state, u8 reg, u8* data, u8 len)
+{
+	int i;
+	u8 buf, len2, attr;
+	dprintk("%s\n", __FUNCTION__);
+
+	/* set mutli register register */
+	nxt200x_writebytes(state, 0x35, &reg, 1);
+
+	switch (state->demod_chip) {
+		case NXT2002:
+			/* set multi register length */
+			len2 = len & 0x80;
+			nxt200x_writebytes(state, 0x34, &len2, 1);
+
+			/* read the actual data */
+			nxt200x_readbytes(state, reg, data, len);
+			return 0;
+			break;
+		case NXT2004:
+			/* probably not right, but gives correct values */
+			attr = 0x02;
+			if (reg & 0x80) {
+				attr = attr << 1;
+				if (reg & 0x04)
+					attr = attr >> 1;
+			}
+
+			/* set multi register length */
+			len2 = (attr << 4) | len;
+			nxt200x_writebytes(state, 0x34, &len2, 1);
+
+			/* toggle the multireg bit*/
+			buf = 0x80;
+			nxt200x_writebytes(state, 0x21, &buf, 1);
+

drivers/media/dvb/frontends/nxt200x.c line 251

Quoted 10 lines
drivers/media/dvb/frontends/nxt200x.c new file +10 -0
+			/* read status */
+			nxt200x_readbytes(state, 0x21, &buf, 1);
+
+			if (buf == 0)
+			{
+				/* read the actual data */
+				for(i = 0; i < len; i++) {
+                    nxt200x_readbytes(state, 0x36 + i, &data[i], 1);
+				}
+				return 0;

whitespace broke.

drivers/media/dvb/frontends/nxt200x.c line 177

Quoted 6 lines
drivers/media/dvb/frontends/nxt200x.c new file +6 -0
+			}
+			break;
+		default:
+			return -EINVAL;
+			break;
+	}

We usually indent the body of a switch statement one tab further to the left.

drivers/media/dvb/frontends/nxt200x.c line 346

Quoted 11 lines
drivers/media/dvb/frontends/nxt200x.c new file +11 -0
+
+static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
+{
+	u8 buf, count = 0;
+
+	dprintk("%s\n", __FUNCTION__);
+
+	dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
+
+	/* if pll is a Philips TUV1236D then write directly to tuner */
+	if (strcmp(state->config->pll_desc->name, "Philips TUV1236D") == 0) {

Does DVB have a better way of identifying a device type than strcmp?

#2 lore raw
Quoted 18 lines · Andrew Morton

drivers/media/dvb/frontends/nxt200x.c line 346

Quoted 13 lines · Michael Krufky
drivers/media/dvb/frontends/nxt200x.c new file +11 -0
+
+static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
+{
+	u8 buf, count = 0;
+
+	dprintk("%s\n", __FUNCTION__);
+
+	dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
+
+	/* if pll is a Philips TUV1236D then write directly to tuner */
+	if (strcmp(state->config->pll_desc->name, "Philips TUV1236D") == 0) {

Does DVB have a better way of identifying a device type than strcmp?

I said the same thing when I first saw this, but I wanted to send the patches separately, because Kirk wrote the driver, and I corrected the above issue in a separate patch:

dvb-determine-tuner-write-method-based-on-nxt-chip.patch

Feel free to fold them if you like... I was only trying to indicate separate authorship.

As for the other comments for the rest of the patch series, some of the fixes are trivial. Should I expect that you will correct these? or do you need me to send you more patches?

For now, I think the corrections should wait for Johannes' return, unless you want to take care of them. I think he comes back JUST after the end of the merge window... not quite sure.

I have 3 or 4 more patches coming.... I plan to send before the end of tonight.

Regards,

Michael Krufky

#3 lore raw
Quoted 21 lines · Mike Krufky
Quoted 18 lines · Andrew Morton

drivers/media/dvb/frontends/nxt200x.c line 346

Quoted 13 lines · Michael Krufky
drivers/media/dvb/frontends/nxt200x.c new file +11 -0
+
+static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
+{
+	u8 buf, count = 0;
+
+	dprintk("%s\n", __FUNCTION__);
+
+	dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
+
+	/* if pll is a Philips TUV1236D then write directly to tuner */
+	if (strcmp(state->config->pll_desc->name, "Philips TUV1236D") == 0) {

Does DVB have a better way of identifying a device type than strcmp?

Quoted 7 lines

I said the same thing when I first saw this, but I wanted to send the patches separately, because Kirk wrote the driver, and I corrected the above issue in a separate patch:

dvb-determine-tuner-write-method-based-on-nxt-chip.patch

Feel free to fold them if you like... I was only trying to indicate separate authorship.

OK.

Quoted 1 line

As for the other comments for the rest of the patch series, some of the fixes are trivial. Should I expect that you will correct these? or do you need me to send you more patches?

I got lazy and didn't alter the patches in any way. Mostly this was a "please do it this way in the future" exercise.

Quoted 3 lines

For now, I think the corrections should wait for Johannes' return, unless you want to take care of them. I think he comes back JUST after the end of the merge window... not quite sure.

At your convenience.

Quoted 2 lines

I have 3 or 4 more patches coming.... I plan to send before the end of tonight.

Oh good. More patches ;)