Skip to contentSkip to conversation

DVB update

PATCH In review Johannes Stezenbach 3 participants 67 messages Sep 4, 2005 – Sep 5, 2005

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

PATCH 3/54 avoid building empty built-in.o

In reply to Johannes Stezenbach

Don't build empty built-in.o when DVB/V4L is not configured. Thanks to Sam Ravnborg and Keith Owens.

 drivers/media/Makefile |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/Makefile +4 -1
@@ -2,4 +2,7 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
-obj-y        := video/ radio/ dvb/ common/
+obj-y := common/
+obj-$(CONFIG_VIDEO_DEV) += video/
+obj-$(CONFIG_VIDEO_DEV) += radio/
+obj-$(CONFIG_DVB)       += dvb/

--

#1 lore raw

PATCH 1/54 email address update

In reply to Johannes Stezenbach

Update email address of Peter Hettkamp.

 drivers/media/dvb/bt8xx/bt878.c       |    2 +-
 drivers/media/dvb/bt8xx/bt878.h       |    2 +-
 drivers/media/dvb/bt8xx/dvb-bt8xx.h   |    2 +-
 drivers/media/dvb/frontends/cx24110.c |    2 +-
 drivers/media/dvb/frontends/cx24110.h |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/media/dvb/bt8xx/bt878.c +1 -1
@@ -1,7 +1,7 @@
 /*
  * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card
  *
- * Copyright (C) 2002 Peter Hettkamp <[email protected]>
+ * Copyright (C) 2002 Peter Hettkamp <[email protected]>
  *
  * large parts based on the bttv driver
  * Copyright (C) 1996,97,98 Ralph  Metzler ([email protected])
drivers/media/dvb/bt8xx/dvb-bt8xx.h +1 -1
@@ -2,7 +2,7 @@
  * Bt8xx based DVB adapter driver
  *
  * Copyright (C) 2002,2003 Florian Schirmer <[email protected]>
- * Copyright (C) 2002 Peter Hettkamp <[email protected]>
+ * Copyright (C) 2002 Peter Hettkamp <[email protected]>
  * Copyright (C) 1999-2001 Ralph  Metzler & Marcus Metzler for convergence integrated media GmbH
  * Copyright (C) 1998,1999 Christian Theiss <[email protected]>
  *
drivers/media/dvb/frontends/cx24110.c +1 -1
@@ -1,7 +1,7 @@
 /*
     cx24110 - Single Chip Satellite Channel Receiver driver module
 
-    Copyright (C) 2002 Peter Hettkamp <[email protected]> based on
+    Copyright (C) 2002 Peter Hettkamp <[email protected]> based on
     work
     Copyright (C) 1999 Convergence Integrated Media GmbH <[email protected]>
 
drivers/media/dvb/frontends/cx24110.h +1 -1
@@ -1,7 +1,7 @@
 /*
     cx24110 - Single Chip Satellite Channel Receiver driver module
 
-    Copyright (C) 2002 Peter Hettkamp <[email protected]> based on
+    Copyright (C) 2002 Peter Hettkamp <[email protected]> based on
     work
     Copyright (C) 1999 Convergence Integrated Media GmbH <[email protected]>
 
drivers/media/dvb/bt8xx/bt878.h +1 -1
@@ -1,7 +1,7 @@
 /*
     bt878.h - Bt878 audio module (register offsets)
 
-    Copyright (C) 2002 Peter Hettkamp <[email protected]>
+    Copyright (C) 2002 Peter Hettkamp <[email protected]>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by

--

#2 lore raw

PATCH 2/54 remove version.h dependencies

In reply to Johannes Stezenbach

From: Olaf Hering <[email protected]>

Remove all #include <linux/version.h> and all references to LINUX_VERSION_CODE and KERNEL_VERSION. Based on patch by Olaf Hering.

 drivers/media/common/saa7146_fops.c     |    1 -
 drivers/media/common/saa7146_i2c.c      |    5 -----
 drivers/media/dvb/cinergyT2/cinergyT2.c |    1 -
 drivers/media/dvb/dvb-core/dvb_net.c    |    5 -----
 drivers/media/dvb/frontends/dib3000mb.c |    1 -
 drivers/media/dvb/frontends/dib3000mc.c |    1 -
 drivers/media/dvb/ttusb-dec/ttusb_dec.c |    1 -
 include/media/saa7146.h                 |   13 +------------
 8 files changed, 1 insertion(+), 27 deletions(-)
drivers/media/common/saa7146_fops.c +0 -1
@@ -1,5 +1,4 @@
 #include <media/saa7146_vv.h>
-#include <linux/version.h>
 
 #define BOARD_CAN_DO_VBI(dev)   (dev->revision != 0 && dev->vv_data->vbi_minor != -1) 
 
drivers/media/common/saa7146_i2c.c +0 -5
@@ -1,4 +1,3 @@
-#include <linux/version.h>
 #include <media/saa7146_vv.h>
 
 static u32 saa7146_i2c_func(struct i2c_adapter *adapter)
@@ -404,12 +403,8 @@ int saa7146_i2c_adapter_prepare(struct s
 	saa7146_i2c_reset(dev);
 
 	if( NULL != i2c_adapter ) {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-		i2c_adapter->data = dev;
-#else
 		BUG_ON(!i2c_adapter->class);
 		i2c_set_adapdata(i2c_adapter,dev);
-#endif
 		i2c_adapter->algo	   = &saa7146_algo;
 		i2c_adapter->algo_data     = NULL;
 		i2c_adapter->id		   = I2C_ALGO_SAA7146;
drivers/media/dvb/cinergyT2/cinergyT2.c +0 -1
@@ -25,7 +25,6 @@
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/pci.h>
drivers/media/dvb/dvb-core/dvb_net.c +0 -5
@@ -62,7 +62,6 @@
 #include <linux/uio.h>
 #include <asm/uaccess.h>
 #include <linux/crc32.h>
-#include <linux/version.h>
 
 #include "dvb_demux.h"
 #include "dvb_net.h"
@@ -171,11 +170,7 @@ static unsigned short dvb_net_eth_type_t
 
 	skb->mac.raw=skb->data;
 	skb_pull(skb,dev->hard_header_len);
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,8)
-	eth = skb->mac.ethernet;
-#else
 	eth = eth_hdr(skb);
-#endif
 
 	if (*eth->h_dest & 1) {
 		if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
drivers/media/dvb/frontends/dib3000mb.c +0 -1
@@ -23,7 +23,6 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
drivers/media/dvb/frontends/dib3000mc.c +0 -1
@@ -22,7 +22,6 @@
  */
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
drivers/media/dvb/ttusb-dec/ttusb_dec.c +0 -1
@@ -28,7 +28,6 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/usb.h>
-#include <linux/version.h>
 #include <linux/interrupt.h>
 #include <linux/firmware.h>
 #include <linux/crc32.h>
include/media/saa7146.h +1 -12
@@ -1,7 +1,6 @@
 #ifndef __SAA7146__
 #define __SAA7146__
 
-#include <linux/version.h>	/* for version macros */
 #include <linux/module.h>	/* for module-version */
 #include <linux/delay.h>	/* for delay-stuff */
 #include <linux/slab.h>		/* for kmalloc/kfree */
@@ -15,12 +14,7 @@
 #include <linux/vmalloc.h>	/* for vmalloc() */
 #include <linux/mm.h>		/* for vmalloc_to_page() */
 
-/* ugly, but necessary to build the dvb stuff under 2.4. */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
-	#include "dvb_functions.h"
-#endif
-
-#define SAA7146_VERSION_CODE KERNEL_VERSION(0,5,0)
+#define SAA7146_VERSION_CODE 0x000500   /* 0.5.0 */
 
 #define saa7146_write(sxy,adr,dat)    writel((dat),(sxy->mem+(adr)))
 #define saa7146_read(sxy,adr)         readl(sxy->mem+(adr))
@@ -33,13 +27,8 @@ extern unsigned int saa7146_debug;
 	#define DEBUG_VARIABLE saa7146_debug
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
-#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_BASENAME),__FUNCTION__)
-#define INFO(x) { printk("%s: ",__stringify(KBUILD_BASENAME)); printk x; }
-#else
 #define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__)
 #define INFO(x) { printk("%s: ",__stringify(KBUILD_MODNAME)); printk x; }
-#endif
 
 #define ERR(x) { DEBUG_PROLOG; printk x; }
 

--

#10 lore raw

PATCH 10/54 core: dvb_demux formatting fixes

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Formatting fixes (Lindent + some handwork).

 drivers/media/dvb/dvb-core/dvb_demux.c |  469 ++++++++++++++++-----------------
 drivers/media/dvb/dvb-core/dvb_demux.h |  109 +++----
 2 files changed, 284 insertions(+), 294 deletions(-)
drivers/media/dvb/dvb-core/dvb_demux.c +230 -239
@@ -38,55 +38,52 @@
 */
 // #define DVB_DEMUX_SECTION_LOSS_LOG
 
-
 /******************************************************************************
  * static inlined helper functions
  ******************************************************************************/
 
-
 static inline u16 section_length(const u8 *buf)
 {
-	return 3+((buf[1]&0x0f)<<8)+buf[2];
+	return 3 + ((buf[1] & 0x0f) << 8) + buf[2];
 }
 
-
 static inline u16 ts_pid(const u8 *buf)
 {
-	return ((buf[1]&0x1f)<<8)+buf[2];
+	return ((buf[1] & 0x1f) << 8) + buf[2];
 }
 
-
 static inline u8 payload(const u8 *tsp)
 {
-	if (!(tsp[3] & 0x10)) // no payload?
+	if (!(tsp[3] & 0x10))	// no payload?
 		return 0;
-	if (tsp[3] & 0x20) {  // adaptation field?
-		if (tsp[4] > 183)    // corrupted data?
+
+	if (tsp[3] & 0x20) {	// adaptation field?
+		if (tsp[4] > 183)	// corrupted data?
 			return 0;
 		else
-			return 184-1-tsp[4];
+			return 184 - 1 - tsp[4];
 	}
+
 	return 184;
 }
 
-
-static u32 dvb_dmx_crc32 (struct dvb_demux_feed *f, const u8 *src, size_t len)
+static u32 dvb_dmx_crc32(struct dvb_demux_feed *f, const u8 *src, size_t len)
 {
-	return (f->feed.sec.crc_val = crc32_be (f->feed.sec.crc_val, src, len));
+	return (f->feed.sec.crc_val = crc32_be(f->feed.sec.crc_val, src, len));
 }
 
-
-static void dvb_dmx_memcopy (struct dvb_demux_feed *f, u8 *d, const u8 *s, size_t len)
+static void dvb_dmx_memcopy(struct dvb_demux_feed *f, u8 *d, const u8 *s,
+			    size_t len)
 {
-	memcpy (d, s, len);
+	memcpy(d, s, len);
 }
 
-
 /******************************************************************************
  * Software filter functions
  ******************************************************************************/
 
-static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u8 *buf)
+static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed,
+					   const u8 *buf)
 {
 	int count = payload(buf);
 	int p;
@@ -96,32 +93,31 @@ static inline int dvb_dmx_swfilter_paylo
 	if (count == 0)
 		return -1;
 
-	p = 188-count;
+	p = 188 - count;
 
 	/*
-	cc=buf[3]&0x0f;
-	ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0;
-	dvbdmxfeed->cc=cc;
+	cc = buf[3] & 0x0f;
+	ccok = ((feed->cc + 1) & 0x0f) == cc;
+	feed->cc = cc;
 	if (!ccok)
 		printk("missed packet!\n");
 	*/
 
-	if (buf[1] & 0x40)  // PUSI ?
+	if (buf[1] & 0x40)	// PUSI ?
 		feed->peslen = 0xfffa;
 
 	feed->peslen += count;
 
-	return feed->cb.ts (&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK);
+	return feed->cb.ts(&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK);
 }
 
-
-static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed,
-				    struct dvb_demux_filter *f)
+static int dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *feed,
+					  struct dvb_demux_filter *f)
 {
 	u8 neq = 0;
 	int i;
 
-	for (i=0; i<DVB_DEMUX_MASK_MAX; i++) {
+	for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
 		u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i];
 
 		if (f->maskandmode[i] & xor)
@@ -133,12 +129,11 @@ static int dvb_dmx_swfilter_sectionfilte
 	if (f->doneq && !neq)
 		return 0;
 
-	return feed->cb.sec (feed->feed.sec.secbuf, feed->feed.sec.seclen,
-			     NULL, 0, &f->filter, DMX_OK);
+	return feed->cb.sec(feed->feed.sec.secbuf, feed->feed.sec.seclen,
+			    NULL, 0, &f->filter, DMX_OK);
 }
 
-
-static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed)
+static inline int dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *feed)
 {
 	struct dvb_demux *demux = feed->demux;
 	struct dvb_demux_filter *f = feed->filter;
@@ -168,26 +163,24 @@ static inline int dvb_dmx_swfilter_secti
 	return 0;
 }
 
-
 static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
 {
 	struct dmx_section_feed *sec = &feed->feed.sec;
 
 #ifdef DVB_DEMUX_SECTION_LOSS_LOG
-	if(sec->secbufp < sec->tsfeedp)
-	{
+	if (sec->secbufp < sec->tsfeedp) {
 		int i, n = sec->tsfeedp - sec->secbufp;
 
-		/* section padding is done with 0xff bytes entirely.
-		** due to speed reasons, we won't check all of them
-		** but just first and last
-		*/
-		if(sec->secbuf[0] != 0xff || sec->secbuf[n-1] != 0xff)
-		{
+		/*
+		 * Section padding is done with 0xff bytes entirely.
+		 * Due to speed reasons, we won't check all of them
+		 * but just first and last.
+		 */
+		if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) {
 			printk("dvb_demux.c section ts padding loss: %d/%d\n",
 			       n, sec->tsfeedp);
 			printk("dvb_demux.c pad data:");
-			for(i = 0; i < n; i++)
+			for (i = 0; i < n; i++)
 				printk(" %02x", sec->secbuf[i]);
 			printk("\n");
 		}
@@ -199,82 +192,81 @@ static void dvb_dmx_swfilter_section_new
 }
 
 /*
-** Losless Section Demux 1.4.1 by Emard
-** Valsecchi Patrick:
-**  - middle of section A  (no PUSI)
-**  - end of section A and start of section B
-**    (with PUSI pointing to the start of the second section)
-**
-**  In this case, without feed->pusi_seen you'll receive a garbage section
-**  consisting of the end of section A. Basically because tsfeedp
-**  is incemented and the use=0 condition is not raised
-**  when the second packet arrives.
-**
-** Fix:
-** when demux is started, let feed->pusi_seen = 0 to
-** prevent initial feeding of garbage from the end of
-** previous section. When you for the first time see PUSI=1
-** then set feed->pusi_seen = 1
-*/
-static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len)
+ * Losless Section Demux 1.4.1 by Emard
+ * Valsecchi Patrick:
+ *  - middle of section A  (no PUSI)
+ *  - end of section A and start of section B
+ *    (with PUSI pointing to the start of the second section)
+ *
+ *  In this case, without feed->pusi_seen you'll receive a garbage section
+ *  consisting of the end of section A. Basically because tsfeedp
+ *  is incemented and the use=0 condition is not raised
+ *  when the second packet arrives.
+ *
+ * Fix:
+ * when demux is started, let feed->pusi_seen = 0 to
+ * prevent initial feeding of garbage from the end of
+ * previous section. When you for the first time see PUSI=1
+ * then set feed->pusi_seen = 1
+ */
+static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
+					      const u8 *buf, u8 len)
 {
 	struct dvb_demux *demux = feed->demux;
 	struct dmx_section_feed *sec = &feed->feed.sec;
 	u16 limit, seclen, n;
 
-	if(sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
+	if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
 		return 0;
 
-	if(sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE)
-	{
+	if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
 #ifdef DVB_DEMUX_SECTION_LOSS_LOG
 		printk("dvb_demux.c section buffer full loss: %d/%d\n",
-		       sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, DMX_MAX_SECFEED_SIZE);
+		       sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE,
+		       DMX_MAX_SECFEED_SIZE);
 #endif
 		len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp;
 	}
 
-	if(len <= 0)
+	if (len <= 0)
 		return 0;
 
 	demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len);
 	sec->tsfeedp += len;
 
-	/* -----------------------------------------------------
-	** Dump all the sections we can find in the data (Emard)
-	*/
-
+	/*
+	 * Dump all the sections we can find in the data (Emard)
+	 */
 	limit = sec->tsfeedp;
-	if(limit > DMX_MAX_SECFEED_SIZE)
-		return -1; /* internal error should never happen */
+	if (limit > DMX_MAX_SECFEED_SIZE)
+		return -1;	/* internal error should never happen */
 
 	/* to be sure always set secbuf */
 	sec->secbuf = sec->secbuf_base + sec->secbufp;
 
-	for(n = 0; sec->secbufp + 2 < limit; n++)
-	{
+	for (n = 0; sec->secbufp + 2 < limit; n++) {
 		seclen = section_length(sec->secbuf);
-		if(seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE
-		   || seclen + sec->secbufp > limit)
+		if (seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE
+		    || seclen + sec->secbufp > limit)
 			return 0;
 		sec->seclen = seclen;
 		sec->crc_val = ~0;
 		/* dump [secbuf .. secbuf+seclen) */
-		if(feed->pusi_seen)
+		if (feed->pusi_seen)
 			dvb_dmx_swfilter_section_feed(feed);
 #ifdef DVB_DEMUX_SECTION_LOSS_LOG
 		else
 			printk("dvb_demux.c pusi not seen, discarding section data\n");
 #endif
-		sec->secbufp += seclen; /* secbufp and secbuf moving together is */
-		sec->secbuf += seclen; /* redundand but saves pointer arithmetic */
+		sec->secbufp += seclen;	/* secbufp and secbuf moving together is */
+		sec->secbuf += seclen;	/* redundant but saves pointer arithmetic */
 	}
 
 	return 0;
 }
 
-
-static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
+static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
+					   const u8 *buf)
 {
 	u8 p, count;
 	int ccok, dc_i = 0;
@@ -282,10 +274,10 @@ static int dvb_dmx_swfilter_section_pack
 
 	count = payload(buf);
 
-	if (count == 0)  /* count == 0 if no payload or out of range */
+	if (count == 0)		/* count == 0 if no payload or out of range */
 		return -1;
 
-	p = 188 - count; /* payload start */
+	p = 188 - count;	/* payload start */
 
 	cc = buf[3] & 0x0f;
 	ccok = ((feed->cc + 1) & 0x0f) == cc;
@@ -299,51 +291,53 @@ static int dvb_dmx_swfilter_section_pack
 
 	if (!ccok || dc_i) {
 #ifdef DVB_DEMUX_SECTION_LOSS_LOG
-		printk("dvb_demux.c discontinuity detected %d bytes lost\n", count);
-		/* those bytes under sume circumstances will again be reported
-		** in the following dvb_dmx_swfilter_section_new
-		*/
+		printk("dvb_demux.c discontinuity detected %d bytes lost\n",
+		       count);
+		/*
+		 * those bytes under sume circumstances will again be reported
+		 * in the following dvb_dmx_swfilter_section_new
+		 */
 #endif
-		/* Discontinuity detected. Reset pusi_seen = 0 to
-		** stop feeding of suspicious data until next PUSI=1 arrives
-		*/
+		/*
+		 * Discontinuity detected. Reset pusi_seen = 0 to
+		 * stop feeding of suspicious data until next PUSI=1 arrives
+		 */
 		feed->pusi_seen = 0;
 		dvb_dmx_swfilter_section_new(feed);
 	}
 
 	if (buf[1] & 0x40) {
-		// PUSI=1 (is set), section boundary is here
+		/* PUSI=1 (is set), section boundary is here */
 		if (count > 1 && buf[p] < count) {
-			const u8 *before = buf+p+1;
+			const u8 *before = &buf[p + 1];
 			u8 before_len = buf[p];
-			const u8 *after = before+before_len;
-			u8 after_len = count-1-before_len;
+			const u8 *after = &before[before_len];
+			u8 after_len = count - 1 - before_len;
 
-			dvb_dmx_swfilter_section_copy_dump(feed, before, before_len);
+			dvb_dmx_swfilter_section_copy_dump(feed, before,
+							   before_len);
 			/* before start of new section, set pusi_seen = 1 */
 			feed->pusi_seen = 1;
 			dvb_dmx_swfilter_section_new(feed);
-			dvb_dmx_swfilter_section_copy_dump(feed, after, after_len);
+			dvb_dmx_swfilter_section_copy_dump(feed, after,
+							   after_len);
 		}
 #ifdef DVB_DEMUX_SECTION_LOSS_LOG
-		else
-			if (count > 0)
-				printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count);
+		else if (count > 0)
+			printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count);
 #endif
 	} else {
-		// PUSI=0 (is not set), no section boundary
-		const u8 *entire = buf+p;
-		u8 entire_len = count;
-
-		dvb_dmx_swfilter_section_copy_dump(feed, entire, entire_len);
+		/* PUSI=0 (is not set), no section boundary */
+		dvb_dmx_swfilter_section_copy_dump(feed, &buf[p], count);
 	}
+
 	return 0;
 }
 
-
-static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf)
+static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed,
+						const u8 *buf)
 {
-	switch(feed->type) {
+	switch (feed->type) {
 	case DMX_TYPE_TS:
 		if (!feed->feed.ts.is_filtering)
 			break;
@@ -351,7 +345,8 @@ static inline void dvb_dmx_swfilter_pack
 			if (feed->ts_type & TS_PAYLOAD_ONLY)
 				dvb_dmx_swfilter_payload(feed, buf);
 			else
-				feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK);
+				feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts,
+					    DMX_OK);
 		}
 		if (feed->ts_type & TS_DECODER)
 			if (feed->demux->write_to_decoder)
@@ -362,7 +357,7 @@ static inline void dvb_dmx_swfilter_pack
 		if (!feed->feed.sec.is_filtering)
 			break;
 		if (dvb_dmx_swfilter_section_packet(feed, buf) < 0)
-			feed->feed.sec.seclen = feed->feed.sec.secbufp=0;
+			feed->feed.sec.seclen = feed->feed.sec.secbufp = 0;
 		break;
 
 	default:
@@ -378,7 +373,7 @@ static inline void dvb_dmx_swfilter_pack
 static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
 {
 	struct dvb_demux_feed *feed;
-	struct list_head *pos, *head=&demux->feed_list;
+	struct list_head *pos, *head = &demux->feed_list;
 	u16 pid = ts_pid(buf);
 	int dvr_done = 0;
 
@@ -404,21 +399,21 @@ static void dvb_dmx_swfilter_packet(stru
 	}
 }
 
-void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count)
+void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
+			      size_t count)
 {
 	spin_lock(&demux->lock);
 
 	while (count--) {
-		if(buf[0] == 0x47) {
-		        dvb_dmx_swfilter_packet(demux, buf);
-		}
+		if (buf[0] == 0x47)
+			dvb_dmx_swfilter_packet(demux, buf);
 		buf += 188;
 	}
 
 	spin_unlock(&demux->lock);
 }
-EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
 
+EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
 
 void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
 {
@@ -426,8 +421,10 @@ void dvb_dmx_swfilter(struct dvb_demux *
 
 	spin_lock(&demux->lock);
 
-	if ((i = demux->tsbufp)) {
-		if (count < (j=188-i)) {
+	if (demux->tsbufp) {
+		i = demux->tsbufp;
+		j = 188 - i;
+		if (count < j) {
 			memcpy(&demux->tsbuf[i], buf, count);
 			demux->tsbufp += count;
 			goto bailout;
@@ -441,13 +438,13 @@ void dvb_dmx_swfilter(struct dvb_demux *
 
 	while (p < count) {
 		if (buf[p] == 0x47) {
-			if (count-p >= 188) {
-				dvb_dmx_swfilter_packet(demux, buf+p);
+			if (count - p >= 188) {
+				dvb_dmx_swfilter_packet(demux, &buf[p]);
 				p += 188;
 			} else {
-				i = count-p;
-				memcpy(demux->tsbuf, buf+p, i);
-				demux->tsbufp=i;
+				i = count - p;
+				memcpy(demux->tsbuf, &buf[p], i);
+				demux->tsbufp = i;
 				goto bailout;
 			}
 		} else
@@ -457,24 +454,29 @@ void dvb_dmx_swfilter(struct dvb_demux *
 bailout:
 	spin_unlock(&demux->lock);
 }
+
 EXPORT_SYMBOL(dvb_dmx_swfilter);
 
 void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
 {
-	int p = 0,i, j;
+	int p = 0, i, j;
 	u8 tmppack[188];
+
 	spin_lock(&demux->lock);
 
-	if ((i = demux->tsbufp)) {
-		if (count < (j=204-i)) {
+	if (demux->tsbufp) {
+		i = demux->tsbufp;
+		j = 204 - i;
+		if (count < j) {
 			memcpy(&demux->tsbuf[i], buf, count);
 			demux->tsbufp += count;
 			goto bailout;
 		}
 		memcpy(&demux->tsbuf[i], buf, j);
-		if ((demux->tsbuf[0] == 0x47)|(demux->tsbuf[0]==0xB8))  {
+		if ((demux->tsbuf[0] == 0x47) | (demux->tsbuf[0] == 0xB8)) {
 			memcpy(tmppack, demux->tsbuf, 188);
-			if (tmppack[0] == 0xB8) tmppack[0] = 0x47;
+			if (tmppack[0] == 0xB8)
+				tmppack[0] = 0x47;
 			dvb_dmx_swfilter_packet(demux, tmppack);
 		}
 		demux->tsbufp = 0;
@@ -482,16 +484,17 @@ void dvb_dmx_swfilter_204(struct dvb_dem
 	}
 
 	while (p < count) {
-		if ((buf[p] == 0x47)|(buf[p] == 0xB8)) {
-			if (count-p >= 204) {
-				memcpy(tmppack, buf+p, 188);
-				if (tmppack[0] == 0xB8) tmppack[0] = 0x47;
+		if ((buf[p] == 0x47) | (buf[p] == 0xB8)) {
+			if (count - p >= 204) {
+				memcpy(tmppack, &buf[p], 188);
+				if (tmppack[0] == 0xB8)
+					tmppack[0] = 0x47;
 				dvb_dmx_swfilter_packet(demux, tmppack);
 				p += 204;
 			} else {
-				i = count-p;
-				memcpy(demux->tsbuf, buf+p, i);
-				demux->tsbufp=i;
+				i = count - p;
+				memcpy(demux->tsbuf, &buf[p], i);
+				demux->tsbufp = i;
 				goto bailout;
 			}
 		} else {
@@ -502,14 +505,14 @@ void dvb_dmx_swfilter_204(struct dvb_dem
 bailout:
 	spin_unlock(&demux->lock);
 }
-EXPORT_SYMBOL(dvb_dmx_swfilter_204);
 
+EXPORT_SYMBOL(dvb_dmx_swfilter_204);
 
-static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux)
+static struct dvb_demux_filter *dvb_dmx_filter_alloc(struct dvb_demux *demux)
 {
 	int i;
 
-	for (i=0; i<demux->filternum; i++)
+	for (i = 0; i < demux->filternum; i++)
 		if (demux->filter[i].state == DMX_STATE_FREE)
 			break;
 
@@ -521,11 +524,11 @@ static struct dvb_demux_filter * dvb_dmx
 	return &demux->filter[i];
 }
 
-static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux)
+static struct dvb_demux_feed *dvb_dmx_feed_alloc(struct dvb_demux *demux)
 {
 	int i;
 
-	for (i=0; i<demux->feednum; i++)
+	for (i = 0; i < demux->feednum; i++)
 		if (demux->feed[i].state == DMX_STATE_FREE)
 			break;
 
@@ -553,7 +556,7 @@ static void dvb_demux_feed_add(struct dv
 	spin_lock_irq(&feed->demux->lock);
 	if (dvb_demux_feed_find(feed)) {
 		printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n",
-				__FUNCTION__, feed->type, feed->state, feed->pid);
+		       __FUNCTION__, feed->type, feed->state, feed->pid);
 		goto out;
 	}
 
@@ -567,7 +570,7 @@ static void dvb_demux_feed_del(struct dv
 	spin_lock_irq(&feed->demux->lock);
 	if (!(dvb_demux_feed_find(feed))) {
 		printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n",
-				__FUNCTION__, feed->type, feed->state, feed->pid);
+		       __FUNCTION__, feed->type, feed->state, feed->pid);
 		goto out;
 	}
 
@@ -576,17 +579,17 @@ out:
 	spin_unlock_irq(&feed->demux->lock);
 }
 
-static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
-		     enum dmx_ts_pes pes_type, size_t circular_buffer_size,
-		     struct timespec timeout)
+static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
+			   enum dmx_ts_pes pes_type,
+			   size_t circular_buffer_size, struct timespec timeout)
 {
-	struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
+	struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
 	struct dvb_demux *demux = feed->demux;
 
 	if (pid > DMX_MAX_PID)
 		return -EINVAL;
 
-	if (down_interruptible (&demux->mutex))
+	if (down_interruptible(&demux->mutex))
 		return -ERESTARTSYS;
 
 	if (ts_type & TS_DECODER) {
@@ -615,7 +618,7 @@ static int dmx_ts_feed_set (struct dmx_t
 
 	if (feed->buffer_size) {
 #ifdef NOBUFS
-		feed->buffer=NULL;
+		feed->buffer = NULL;
 #else
 		feed->buffer = vmalloc(feed->buffer_size);
 		if (!feed->buffer) {
@@ -631,14 +634,13 @@ static int dmx_ts_feed_set (struct dmx_t
 	return 0;
 }
 
-
-static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed)
+static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed)
 {
-	struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
+	struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
 	struct dvb_demux *demux = feed->demux;
 	int ret;
 
-	if (down_interruptible (&demux->mutex))
+	if (down_interruptible(&demux->mutex))
 		return -ERESTARTSYS;
 
 	if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) {
@@ -665,13 +667,13 @@ static int dmx_ts_feed_start_filtering(s
 	return 0;
 }
 
-static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed)
+static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
 {
-	struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
+	struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
 	struct dvb_demux *demux = feed->demux;
 	int ret;
 
-	if (down_interruptible (&demux->mutex))
+	if (down_interruptible(&demux->mutex))
 		return -ERESTARTSYS;
 
 	if (feed->state < DMX_STATE_GO) {
@@ -695,13 +697,14 @@ static int dmx_ts_feed_stop_filtering(st
 	return ret;
 }
 
-static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **ts_feed,
-			     dmx_ts_cb callback)
+static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
+				   struct dmx_ts_feed **ts_feed,
+				   dmx_ts_cb callback)
 {
-	struct dvb_demux *demux = (struct dvb_demux *) dmx;
+	struct dvb_demux *demux = (struct dvb_demux *)dmx;
 	struct dvb_demux_feed *feed;
 
-	if (down_interruptible (&demux->mutex))
+	if (down_interruptible(&demux->mutex))
 		return -ERESTARTSYS;
 
 	if (!(feed = dvb_dmx_feed_alloc(demux))) {
@@ -724,7 +727,6 @@ static int dvbdmx_allocate_ts_feed (stru
 	(*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering;
 	(*ts_feed)->set = dmx_ts_feed_set;
 
-
 	if (!(feed->filter = dvb_dmx_filter_alloc(demux))) {
 		feed->state = DMX_STATE_FREE;
 		up(&demux->mutex);
@@ -740,22 +742,22 @@ static int dvbdmx_allocate_ts_feed (stru
 	return 0;
 }
 
-static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_feed)
+static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
+				  struct dmx_ts_feed *ts_feed)
 {
-	struct dvb_demux *demux = (struct dvb_demux *) dmx;
-	struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
+	struct dvb_demux *demux = (struct dvb_demux *)dmx;
+	struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
 
-	if (down_interruptible (&demux->mutex))
+	if (down_interruptible(&demux->mutex))
 		return -ERESTARTSYS;
 
 	if (feed->state == DMX_STATE_FREE) {
 		up(&demux->mutex);
 		return -EINVAL;
 	}
-
 #ifndef NOBUFS
 	vfree(feed->buffer);
-	feed->buffer=0;
+	feed->buffer = NULL;
 #endif
 
 	feed->state = DMX_STATE_FREE;
@@ -772,19 +774,18 @@ static int dvbdmx_release_ts_feed(struct
 	return 0;
 }
 
-
 /******************************************************************************
  * dmx_section_feed API calls
  ******************************************************************************/
 
-static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed,
-				     struct dmx_section_filter** filter)
+static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
+					    struct dmx_section_filter **filter)
 {
-	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed;
+	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
 	struct dvb_demux *dvbdemux = dvbdmxfeed->demux;
 	struct dvb_demux_filter *dvbdmxfilter;
 
-	if (down_interruptible (&dvbdemux->mutex))
+	if (down_interruptible(&dvbdemux->mutex))
 		return -ERESTARTSYS;
 
 	dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux);
@@ -808,18 +809,17 @@ static int dmx_section_feed_allocate_fil
 	return 0;
 }
 
-
-static int dmx_section_feed_set(struct dmx_section_feed* feed,
-			 u16 pid, size_t circular_buffer_size,
-			 int check_crc)
+static int dmx_section_feed_set(struct dmx_section_feed *feed,
+				u16 pid, size_t circular_buffer_size,
+				int check_crc)
 {
-	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed;
+	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
 	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
 
 	if (pid > 0x1fff)
 		return -EINVAL;
 
-	if (down_interruptible (&dvbdmx->mutex))
+	if (down_interruptible(&dvbdmx->mutex))
 		return -ERESTARTSYS;
 
 	dvb_demux_feed_add(dvbdmxfeed);
@@ -831,7 +831,7 @@ static int dmx_section_feed_set(struct d
 #ifdef NOBUFS
 	dvbdmxfeed->buffer = NULL;
 #else
-	dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size);
+	dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size);
 	if (!dvbdmxfeed->buffer) {
 		up(&dvbdmx->mutex);
 		return -ENOMEM;
@@ -843,7 +843,6 @@ static int dmx_section_feed_set(struct d
 	return 0;
 }
 
-
 static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
 {
 	int i;
@@ -851,12 +850,12 @@ static void prepare_secfilters(struct dv
 	struct dmx_section_filter *sf;
 	u8 mask, mode, doneq;
 
-	if (!(f=dvbdmxfeed->filter))
+	if (!(f = dvbdmxfeed->filter))
 		return;
 	do {
 		sf = &f->filter;
 		doneq = 0;
-		for (i=0; i<DVB_DEMUX_MASK_MAX; i++) {
+		for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
 			mode = sf->filter_mode[i];
 			mask = sf->filter_mask[i];
 			f->maskandmode[i] = mask & mode;
@@ -866,14 +865,13 @@ static void prepare_secfilters(struct dv
 	} while ((f = f->next));
 }
 
-
 static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
 {
-	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed;
+	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
 	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
 	int ret;
 
-	if (down_interruptible (&dvbdmx->mutex))
+	if (down_interruptible(&dvbdmx->mutex))
 		return -ERESTARTSYS;
 
 	if (feed->is_filtering) {
@@ -912,14 +910,13 @@ static int dmx_section_feed_start_filter
 	return 0;
 }
 
-
-static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed)
+static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
 {
-	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed;
+	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
 	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
 	int ret;
 
-	if (down_interruptible (&dvbdmx->mutex))
+	if (down_interruptible(&dvbdmx->mutex))
 		return -ERESTARTSYS;
 
 	if (!dvbdmx->stop_feed) {
@@ -938,15 +935,14 @@ static int dmx_section_feed_stop_filteri
 	return ret;
 }
 
-
 static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
-				struct dmx_section_filter* filter)
+					   struct dmx_section_filter *filter)
 {
-	struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *) filter, *f;
-	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed;
+	struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *)filter, *f;
+	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
 	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
 
-	if (down_interruptible (&dvbdmx->mutex))
+	if (down_interruptible(&dvbdmx->mutex))
 		return -ERESTARTSYS;
 
 	if (dvbdmxfilter->feed != dvbdmxfeed) {
@@ -963,7 +959,7 @@ static int dmx_section_feed_release_filt
 	if (f == dvbdmxfilter) {
 		dvbdmxfeed->filter = dvbdmxfilter->next;
 	} else {
-		while(f->next != dvbdmxfilter)
+		while (f->next != dvbdmxfilter)
 			f = f->next;
 		f->next = f->next->next;
 	}
@@ -978,10 +974,10 @@ static int dvbdmx_allocate_section_feed(
 					struct dmx_section_feed **feed,
 					dmx_section_cb callback)
 {
-	struct dvb_demux *dvbdmx = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
 	struct dvb_demux_feed *dvbdmxfeed;
 
-	if (down_interruptible (&dvbdmx->mutex))
+	if (down_interruptible(&dvbdmx->mutex))
 		return -ERESTARTSYS;
 
 	if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) {
@@ -999,7 +995,7 @@ static int dvbdmx_allocate_section_feed(
 	dvbdmxfeed->filter = NULL;
 	dvbdmxfeed->buffer = NULL;
 
-	(*feed)=&dvbdmxfeed->feed.sec;
+	(*feed) = &dvbdmxfeed->feed.sec;
 	(*feed)->is_filtering = 0;
 	(*feed)->parent = demux;
 	(*feed)->priv = NULL;
@@ -1017,21 +1013,21 @@ static int dvbdmx_allocate_section_feed(
 static int dvbdmx_release_section_feed(struct dmx_demux *demux,
 				       struct dmx_section_feed *feed)
 {
-	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed;
-	struct dvb_demux *dvbdmx = (struct dvb_demux *) demux;
+	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
+	struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
 
-	if (down_interruptible (&dvbdmx->mutex))
+	if (down_interruptible(&dvbdmx->mutex))
 		return -ERESTARTSYS;
 
-	if (dvbdmxfeed->state==DMX_STATE_FREE) {
+	if (dvbdmxfeed->state == DMX_STATE_FREE) {
 		up(&dvbdmx->mutex);
 		return -EINVAL;
 	}
 #ifndef NOBUFS
 	vfree(dvbdmxfeed->buffer);
-	dvbdmxfeed->buffer=0;
+	dvbdmxfeed->buffer = NULL;
 #endif
-	dvbdmxfeed->state=DMX_STATE_FREE;
+	dvbdmxfeed->state = DMX_STATE_FREE;
 
 	dvb_demux_feed_del(dvbdmxfeed);
 
@@ -1041,14 +1037,13 @@ static int dvbdmx_release_section_feed(s
 	return 0;
 }
 
-
 /******************************************************************************
  * dvb_demux kernel data API calls
  ******************************************************************************/
 
 static int dvbdmx_open(struct dmx_demux *demux)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
 	if (dvbdemux->users >= MAX_DVB_DEMUX_USERS)
 		return -EUSERS;
@@ -1057,10 +1052,9 @@ static int dvbdmx_open(struct dmx_demux 
 	return 0;
 }
 
-
 static int dvbdmx_close(struct dmx_demux *demux)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
 	if (dvbdemux->users == 0)
 		return -ENODEV;
@@ -1070,15 +1064,14 @@ static int dvbdmx_close(struct dmx_demux
 	return 0;
 }
 
-
 static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count)
 {
-	struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
 	if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE))
 		return -EINVAL;
 
-	if (down_interruptible (&dvbdemux->mutex))
+	if (down_interruptible(&dvbdemux->mutex))
 		return -ERESTARTSYS;
 	dvb_dmx_swfilter(dvbdemux, buf, count);
 	up(&dvbdemux->mutex);
@@ -1088,10 +1081,10 @@ static int dvbdmx_write(struct dmx_demux
 	return count;
 }
 
-
-static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend)
+static int dvbdmx_add_frontend(struct dmx_demux *demux,
+			       struct dmx_frontend *frontend)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 	struct list_head *head = &dvbdemux->frontend_list;
 
 	list_add(&(frontend->connectivity_list), head);
@@ -1099,13 +1092,13 @@ static int dvbdmx_add_frontend(struct dm
 	return 0;
 }
 
-
-static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend)
+static int dvbdmx_remove_frontend(struct dmx_demux *demux,
+				  struct dmx_frontend *frontend)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 	struct list_head *pos, *n, *head = &dvbdemux->frontend_list;
 
-	list_for_each_safe (pos, n, head) {
+	list_for_each_safe(pos, n, head) {
 		if (DMX_FE_ENTRY(pos) == frontend) {
 			list_del(pos);
 			return 0;
@@ -1115,25 +1108,25 @@ static int dvbdmx_remove_frontend(struct
 	return -ENODEV;
 }
 
-
-static struct list_head * dvbdmx_get_frontends(struct dmx_demux *demux)
+static struct list_head *dvbdmx_get_frontends(struct dmx_demux *demux)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
 	if (list_empty(&dvbdemux->frontend_list))
 		return NULL;
+
 	return &dvbdemux->frontend_list;
 }
 
-
-static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend)
+static int dvbdmx_connect_frontend(struct dmx_demux *demux,
+				   struct dmx_frontend *frontend)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
 	if (demux->frontend)
 		return -EINVAL;
 
-	if (down_interruptible (&dvbdemux->mutex))
+	if (down_interruptible(&dvbdemux->mutex))
 		return -ERESTARTSYS;
 
 	demux->frontend = frontend;
@@ -1141,12 +1134,11 @@ static int dvbdmx_connect_frontend(struc
 	return 0;
 }
 
-
 static int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
-	if (down_interruptible (&dvbdemux->mutex))
+	if (down_interruptible(&dvbdemux->mutex))
 		return -ERESTARTSYS;
 
 	demux->frontend = NULL;
@@ -1154,44 +1146,42 @@ static int dvbdmx_disconnect_frontend(st
 	return 0;
 }
 
-
-static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids)
+static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 * pids)
 {
-	struct dvb_demux *dvbdemux = (struct dvb_demux *) demux;
+	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
-	memcpy(pids, dvbdemux->pids, 5*sizeof(u16));
+	memcpy(pids, dvbdemux->pids, 5 * sizeof(u16));
 	return 0;
 }
 
-
 int dvb_dmx_init(struct dvb_demux *dvbdemux)
 {
 	int i;
 	struct dmx_demux *dmx = &dvbdemux->dmx;
 
 	dvbdemux->users = 0;
-	dvbdemux->filter = vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter));
+	dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter));
 
 	if (!dvbdemux->filter)
 		return -ENOMEM;
 
-	dvbdemux->feed = vmalloc(dvbdemux->feednum*sizeof(struct dvb_demux_feed));
+	dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed));
 	if (!dvbdemux->feed) {
 		vfree(dvbdemux->filter);
 		return -ENOMEM;
 	}
-	for (i=0; i<dvbdemux->filternum; i++) {
+	for (i = 0; i < dvbdemux->filternum; i++) {
 		dvbdemux->filter[i].state = DMX_STATE_FREE;
 		dvbdemux->filter[i].index = i;
 	}
-	for (i=0; i<dvbdemux->feednum; i++) {
+	for (i = 0; i < dvbdemux->feednum; i++) {
 		dvbdemux->feed[i].state = DMX_STATE_FREE;
 		dvbdemux->feed[i].index = i;
 	}
 
 	INIT_LIST_HEAD(&dvbdemux->frontend_list);
 
-	for (i=0; i<DMX_TS_PES_OTHER; i++) {
+	for (i = 0; i < DMX_TS_PES_OTHER; i++) {
 		dvbdemux->pesfilter[i] = NULL;
 		dvbdemux->pids[i] = 0xffff;
 	}
@@ -1205,11 +1195,11 @@ int dvb_dmx_init(struct dvb_demux *dvbde
 	if (!dvbdemux->check_crc32)
 		dvbdemux->check_crc32 = dvb_dmx_crc32;
 
-	 if (!dvbdemux->memcopy)
-		 dvbdemux->memcopy = dvb_dmx_memcopy;
+	if (!dvbdemux->memcopy)
+		dvbdemux->memcopy = dvb_dmx_memcopy;
 
 	dmx->frontend = NULL;
-	dmx->priv = (void *) dvbdemux;
+	dmx->priv = dvbdemux;
 	dmx->open = dvbdmx_open;
 	dmx->close = dvbdmx_close;
 	dmx->write = dvbdmx_write;
@@ -1230,12 +1220,13 @@ int dvb_dmx_init(struct dvb_demux *dvbde
 
 	return 0;
 }
-EXPORT_SYMBOL(dvb_dmx_init);
 
+EXPORT_SYMBOL(dvb_dmx_init);
 
 void dvb_dmx_release(struct dvb_demux *dvbdemux)
 {
 	vfree(dvbdemux->filter);
 	vfree(dvbdemux->feed);
 }
+
 EXPORT_SYMBOL(dvb_dmx_release);
drivers/media/dvb/dvb-core/dvb_demux.h +54 -55

159 lines not on this page · raw message

--

#27 lore raw

PATCH 24/54 usb: dibusb: Kworld Xpert DVB-T USB2.0 support

In reply to Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

Add USB IDs of the Kworld Xpert DVB-T USB2.0 (clone of the ADStech box). Thanks to Marcus Hagn for testing.

 drivers/media/dvb/dvb-usb/dibusb-mb.c   |   14 ++++++++++----
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h |    1 +
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/media/dvb/dvb-usb/dibusb-mb.c +10 -4
@@ -126,10 +126,12 @@ static struct usb_device_id dibusb_dib30
 /* 25 */	{ USB_DEVICE(USB_VID_KYE,			USB_PID_KYE_DVB_T_COLD) },
 /* 26 */	{ USB_DEVICE(USB_VID_KYE,			USB_PID_KYE_DVB_T_WARM) },
 
+/* 27 */	{ USB_DEVICE(USB_VID_KWORLD,		USB_PID_KWORLD_VSTREAM_COLD) },
+
 // #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs
 
 #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs
-/* 27 */	{ USB_DEVICE(USB_VID_ANCHOR,		USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },
+/* 28 */	{ USB_DEVICE(USB_VID_ANCHOR,		USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },
 #endif
 			{ }		/* Terminating entry */
 };
@@ -262,7 +264,7 @@ static struct dvb_usb_properties dibusb1
 		},
 #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs
 		{	"Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)",
-			{ &dibusb_dib3000mb_table[27], NULL },
+			{ &dibusb_dib3000mb_table[28], NULL },
 			{ NULL },
 		},
 #endif
@@ -306,12 +308,16 @@ static struct dvb_usb_properties dibusb2
 		}
 	},
 
-	.num_device_descs = 1,
+	.num_device_descs = 2,
 	.devices = {
-		{	"KWorld/ADSTech Instant DVB-T USB 2.0",
+		{	"KWorld/ADSTech Instant DVB-T USB2.0",
 			{ &dibusb_dib3000mb_table[23], NULL },
 			{ &dibusb_dib3000mb_table[24], NULL },
 		},
+		{	"KWorld Xpert DVB-T USB2.0",
+			{ &dibusb_dib3000mb_table[27], NULL },
+			{ NULL }
+		},
 	}
 };
 
drivers/media/dvb/dvb-usb/dvb-usb-ids.h +1 -0
@@ -24,6 +24,7 @@
 #define USB_VID_HANFTEK						0x15f4
 #define USB_VID_HAUPPAUGE					0x2040
 #define USB_VID_HYPER_PALTEK				0x1025
+#define USB_VID_KWORLD						0xeb2a
 #define USB_VID_KYE							0x0458
 #define USB_VID_MEDION						0x1660
 #define USB_VID_VISIONPLUS					0x13d3

--

#0 lore raw

cover DVB update

Hi Andrew,

here's another DVB update, mostly small fixes and improvements. Patches have been prepared against 2.6.13-git4 and IMHO could go straight into Linus' tree, but have been tested to apply cleanly against 2.6.13-mm1.

The dvb-bt8xx-dst-doc-update.patch depends on dvb-clarify-description-text-for-dvb-bt8xx-in-kconfig-fix.patch which is currently in -mm1.

Please apply.

Thanks,
Johannes

#48 lore raw

PATCH 45/54 av7110: Siemens DVB-C analog video input support

From: thomas schorpp <[email protected]>

Add support for analog video inputs (CVBS and Y/C) of the analog module for the Siemens DVB-C card.

 drivers/media/dvb/ttpci/av7110_v4l.c |   74 +++++++++++++++++++++++++----------
 1 file changed, 54 insertions(+), 20 deletions(-)
drivers/media/dvb/ttpci/av7110_v4l.c +54 -20
@@ -70,7 +70,7 @@ static int msp_readreg(struct av7110 *av
 	return 0;
 }
 
-static struct v4l2_input inputs[2] = {
+static struct v4l2_input inputs[4] = {
 	{
 		.index		= 0,
 		.name		= "DVB",
@@ -87,6 +87,22 @@ static struct v4l2_input inputs[2] = {
 		.tuner		= 0,
 		.std		= V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
 		.status		= 0,
+	}, {
+		.index		= 2,
+		.name		= "Video",
+		.type		= V4L2_INPUT_TYPE_CAMERA,
+		.audioset	= 0,
+		.tuner		= 0,
+		.std		= V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
+		.status		= 0,
+	}, {
+		.index		= 3,
+		.name		= "Y/C",
+		.type		= V4L2_INPUT_TYPE_CAMERA,
+		.audioset	= 0,
+		.tuner		= 0,
+		.std		= V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
+		.status		= 0,
 	}
 };
 
@@ -212,24 +228,44 @@ static int av7110_dvb_c_switch(struct sa
 	}
 
 	if (0 != av7110->current_input) {
+		dprintk(1, "switching to analog TV:\n");
 		adswitch = 1;
 		source = SAA7146_HPS_SOURCE_PORT_B;
 		sync = SAA7146_HPS_SYNC_PORT_B;
 		memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2);
-		dprintk(1, "switching to analog TV\n");
-		msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
-		msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
-		msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
-		msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
-		msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
-		msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
 
-		if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
-			if (ves1820_writereg(dev, 0x09, 0x0f, 0x60))
-				dprintk(1, "setting band in demodulator failed.\n");
-		} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
-			saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD)
-			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF)
+		switch (av7110->current_input) {
+		case 1:
+			dprintk(1, "switching SAA7113 to Analog Tuner Input.\n");
+			msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
+			msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
+			msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
+			msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
+			msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
+			msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
+
+			if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
+				if (ves1820_writereg(dev, 0x09, 0x0f, 0x60))
+					dprintk(1, "setting band in demodulator failed.\n");
+			} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
+				saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD)
+				saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF)
+			}
+			if (i2c_writereg(av7110, 0x48, 0x02, 0xd0) != 1)
+				dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
+			break;
+		case 2:
+			dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n");
+			if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1)
+				dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
+			break;
+		case 3:
+			dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n");
+			if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1)
+				dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
+			break;
+		default:
+			dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n");
 		}
 	} else {
 		adswitch = 0;
@@ -300,7 +336,6 @@ static int av7110_ioctl(struct saa7146_f
 		// FIXME: standard / stereo detection is still broken
 		msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det);
 		dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det);
-
 		msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det);
 		dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det);
 		stereo = (s8)(stereo_det >> 8);
@@ -310,7 +345,7 @@ static int av7110_ioctl(struct saa7146_f
 			t->audmode = V4L2_TUNER_MODE_STEREO;
 		}
 		else if (stereo < -0x10) {
-			/* bilingual*/
+			/* bilingual */
 			t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
 			t->audmode = V4L2_TUNER_MODE_LANG1;
 		}
@@ -344,7 +379,7 @@ static int av7110_ioctl(struct saa7146_f
 			fm_matrix = 0x3000; // mono
 			src = 0x0010;
 			break;
-		default: /* case V4L2_TUNER_MODE_MONO: {*/
+		default: /* case V4L2_TUNER_MODE_MONO: */
 			dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n");
 			fm_matrix = 0x3000; // mono
 			src = 0x0030;
@@ -406,7 +441,7 @@ static int av7110_ioctl(struct saa7146_f
 		dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index);
 
 		if (av7110->analog_tuner_flags) {
-			if (i->index < 0 || i->index >= 2)
+			if (i->index < 0 || i->index >= 4)
 				return -EINVAL;
 		} else {
 			if (i->index != 0)
@@ -433,10 +468,9 @@ static int av7110_ioctl(struct saa7146_f
 		if (!av7110->analog_tuner_flags)
 			return 0;
 
-		if (input < 0 || input >= 2)
+		if (input < 0 || input >= 4)
 			return -EINVAL;
 
-		/* FIXME: switch inputs here */
 		av7110->current_input = input;
 		return av7110_dvb_c_switch(fh);
 	}

--

#54 lore raw

PATCH 51/54 ttpci: av7110: RC5+ remote control support

In reply to Johannes Stezenbach

From: Oliver Endriss <[email protected]>

Improved remote control support for av7110-based cards:
o extended rc5 protocol, firmware >= 0x2620 required
o key-up timer slightly adjusted
o completely moved remote control code to av7110_ir.c
o support for multiple ir receivers
o for now, all av7110 cards share the same ir configuration and event device

 drivers/media/dvb/ttpci/av7110.c    |   70 +-----------------
 drivers/media/dvb/ttpci/av7110.h    |   11 +-
 drivers/media/dvb/ttpci/av7110_ir.c |  140 ++++++++++++++++++++++++------------
 3 files changed, 110 insertions(+), 111 deletions(-)
drivers/media/dvb/ttpci/av7110.c +7 -63
@@ -177,9 +177,6 @@ static void init_av7110_av(struct av7110
 	ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
 	if (ret < 0)
 		printk("dvb-ttpci:cannot set volume :%d\n",ret);
-	ret = av7110_setup_irc_config(av7110, 0);
-	if (ret < 0)
-		printk("dvb-ttpci:cannot setup irc config :%d\n",ret);
 }
 
 static void recover_arm(struct av7110 *av7110)
@@ -265,60 +262,6 @@ static int arm_thread(void *data)
 }
 
 
-/**
- *  Hack! we save the last av7110 ptr. This should be ok, since
- *  you rarely will use more then one IR control.
- *
- *  If we want to support multiple controls we would have to do much more...
- */
-int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
-{
-	int ret = 0;
-	static struct av7110 *last;
-
-	dprintk(4, "%p\n", av7110);
-
-	if (!av7110)
-		av7110 = last;
-	else
-		last = av7110;
-
-	if (av7110) {
-		ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
-		av7110->ir_config = ir_config;
-	}
-	return ret;
-}
-
-static void (*irc_handler)(u32);
-
-void av7110_register_irc_handler(void (*func)(u32))
-{
-	dprintk(4, "registering %p\n", func);
-	irc_handler = func;
-}
-
-void av7110_unregister_irc_handler(void (*func)(u32))
-{
-	dprintk(4, "unregistering %p\n", func);
-	irc_handler = NULL;
-}
-
-static void run_handlers(unsigned long ircom)
-{
-	if (irc_handler != NULL)
-		(*irc_handler)((u32) ircom);
-}
-
-static DECLARE_TASKLET(irtask, run_handlers, 0);
-
-static void IR_handle(struct av7110 *av7110, u32 ircom)
-{
-	dprintk(4, "ircommand = %08x\n", ircom);
-	irtask.data = (unsigned long) ircom;
-	tasklet_schedule(&irtask);
-}
-
 /****************************************************************************
  * IRQ handling
  ****************************************************************************/
@@ -711,8 +654,9 @@ static void gpioirq(unsigned long data)
 		return;
 
 	case DATA_IRCOMMAND:
-		IR_handle(av7110,
-			  swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));
+		if (av7110->ir_handler)
+			av7110->ir_handler(av7110,
+				swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));
 		iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
 		break;
 
@@ -2783,7 +2727,7 @@ static int av7110_attach(struct saa7146_
 		goto err_av7110_exit_v4l_12;
 
 #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
-	av7110_ir_init();
+	av7110_ir_init(av7110);
 #endif
 	printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num);
 	av7110_num++;
@@ -2825,6 +2769,9 @@ static int av7110_detach(struct saa7146_
 	struct av7110 *av7110 = saa->ext_priv;
 	dprintk(4, "%p\n", av7110);
 
+#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
+	av7110_ir_exit(av7110);
+#endif
 	if (budgetpatch) {
 		/* Disable RPS1 */
 		saa7146_write(saa, MC1, MASK_29);
@@ -2980,9 +2927,6 @@ static int __init av7110_init(void)
 
 static void __exit av7110_exit(void)
 {
-#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
-	av7110_ir_exit();
-#endif
 	saa7146_unregister_extension(&av7110_extension);
 }
 
drivers/media/dvb/ttpci/av7110.h +6 -5
@@ -228,7 +228,10 @@ struct av7110 {
 	struct dvb_video_events  video_events;
 	video_size_t		 video_size;
 
-	u32		    ir_config;
+	u32			ir_config;
+	u32			ir_command;
+	void			(*ir_handler)(struct av7110 *av7110, u32 ircom); 
+	struct tasklet_struct	ir_tasklet;
 
 	/* firmware stuff */
 	unsigned char *bin_fw;
@@ -257,12 +260,10 @@ struct av7110 {
 extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
 		       u16 subpid, u16 pcrpid);
 
-extern void av7110_register_irc_handler(void (*func)(u32));
-extern void av7110_unregister_irc_handler(void (*func)(u32));
 extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config);
 
-extern int av7110_ir_init (void);
-extern void av7110_ir_exit (void);
+extern int av7110_ir_init(struct av7110 *av7110);
+extern void av7110_ir_exit(struct av7110 *av7110);
 
 /* msp3400 i2c subaddresses */
 #define MSP_WR_DEM 0x10
drivers/media/dvb/ttpci/av7110_ir.c +97 -43

216 lines not on this page · raw message

--

#36 lore raw

PATCH 33/54 bt8xx: endianness fix

In reply to Johannes Stezenbach

Endianness fix for risc DMA start address setting. (reported by Stefan Haubenthal/Peter Hettkamp)

 drivers/media/dvb/bt8xx/bt878.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb/bt8xx/bt878.c +1 -1
@@ -219,7 +219,7 @@ void bt878_start(struct bt878 *bt, u32 c
 	controlreg &= ~0x1f;
 	controlreg |= 0x1b;
 
-	btwrite(cpu_to_le32(bt->risc_dma), BT878_ARISC_START);
+	btwrite(bt->risc_dma, BT878_ARISC_START);
 
 	/* original int mask had :
 	 *    6    2    8    4    0

--

#42 lore raw

PATCH 39/54 dst: dprrintk cleanup

In reply to Johannes Stezenbach

From: Manu Abraham <[email protected]>

Code Cleanup:
o Remove debug noise
o Remove debug module parameter
debug level is achieved using the verbosity level
o Updated to kernel coding style
(case labels should not be indented)

 drivers/media/dvb/bt8xx/dst.c        |  645 ++++++++++++++---------------------
 drivers/media/dvb/bt8xx/dst_ca.c     |  441 +++++++++--------------
 drivers/media/dvb/bt8xx/dst_common.h |    4 
 3 files changed, 458 insertions(+), 632 deletions(-)
drivers/media/dvb/bt8xx/dst.c +276 -369
@@ -1,5 +1,4 @@
 /*
-
 	Frontend/Card driver for TwinHan DST Frontend
 	Copyright (C) 2003 Jamie Honan
 	Copyright (C) 2004, 2005 Manu Abraham ([email protected])
@@ -19,7 +18,6 @@
 	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -28,31 +26,45 @@
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <asm/div64.h>
-
 #include "dvb_frontend.h"
 #include "dst_priv.h"
 #include "dst_common.h"
 
-
 static unsigned int verbose = 1;
 module_param(verbose, int, 0644);
 MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
 
-static unsigned int debug = 1;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)");
-
 static unsigned int dst_addons;
 module_param(dst_addons, int, 0644);
 MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)");
 
-#define dprintk	if (debug) printk
+#define HAS_LOCK		1
+#define ATTEMPT_TUNE		2
+#define HAS_POWER		4
+
+#define DST_ERROR		0
+#define DST_NOTICE		1
+#define DST_INFO		2
+#define DST_DEBUG		3
+
+#define dprintk(x, y, z, format, arg...) do {						\
+	if (z) {									\
+		if	((x > DST_ERROR) && (x > y))					\
+			printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg);	\
+		else if	((x > DST_NOTICE) && (x > y))					\
+			printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__, ##arg);	\
+		else if ((x > DST_INFO) && (x > y))					\
+			printk(KERN_INFO "%s: " format "\n", __FUNCTION__, ##arg);	\
+		else if ((x > DST_DEBUG) && (x > y))					\
+			printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__, ##arg);	\
+	} else {									\
+		if (x > y)								\
+			printk(format, ##arg);						\
+	}										\
+} while(0)
 
-#define HAS_LOCK	1
-#define ATTEMPT_TUNE	2
-#define HAS_POWER	4
 
-static void dst_packsize(struct dst_state* state, int psize)
+static void dst_packsize(struct dst_state *state, int psize)
 {
 	union dst_gpio_packet bits;
 
@@ -60,7 +72,7 @@ static void dst_packsize(struct dst_stat
 	bt878_device_control(state->bt, DST_IG_TS, &bits);
 }
 
-int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay)
+int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, u32 outhigh, int delay)
 {
 	union dst_gpio_packet enb;
 	union dst_gpio_packet bits;
@@ -68,63 +80,55 @@ int dst_gpio_outb(struct dst_state* stat
 
 	enb.enb.mask = mask;
 	enb.enb.enable = enbb;
-	if (verbose > 4)
-		dprintk("%s: mask=[%04x], enbb=[%04x], outhigh=[%04x]\n", __FUNCTION__, mask, enbb, outhigh);
 
+	dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh);
 	if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) {
-		dprintk("%s: dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n", __FUNCTION__, err, mask, enbb);
+		dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb);
 		return -EREMOTEIO;
 	}
 	udelay(1000);
 	/* because complete disabling means no output, no need to do output packet */
 	if (enbb == 0)
 		return 0;
-
 	if (delay)
 		msleep(10);
-
 	bits.outp.mask = enbb;
 	bits.outp.highvals = outhigh;
-
 	if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) {
-		dprintk("%s: dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n", __FUNCTION__, err, enbb, outhigh);
+		dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh);
 		return -EREMOTEIO;
 	}
+
 	return 0;
 }
 EXPORT_SYMBOL(dst_gpio_outb);
 
-int dst_gpio_inb(struct dst_state *state, u8 * result)
+int dst_gpio_inb(struct dst_state *state, u8 *result)
 {
 	union dst_gpio_packet rd_packet;
 	int err;
 
 	*result = 0;
-
 	if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) {
-		dprintk("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err);
+		dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)\n", err);
 		return -EREMOTEIO;
 	}
-
 	*result = (u8) rd_packet.rd.value;
+
 	return 0;
 }
 EXPORT_SYMBOL(dst_gpio_inb);
 
 int rdc_reset_state(struct dst_state *state)
 {
-	if (verbose > 1)
-		dprintk("%s: Resetting state machine\n", __FUNCTION__);
-
+	dprintk(verbose, DST_INFO, 1, "Resetting state machine");
 	if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) {
-		dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
 		return -1;
 	}
-
 	msleep(10);
-
 	if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) {
-		dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
 		msleep(10);
 		return -1;
 	}
@@ -135,16 +139,14 @@ EXPORT_SYMBOL(rdc_reset_state);
 
 int rdc_8820_reset(struct dst_state *state)
 {
-	if (verbose > 1)
-		dprintk("%s: Resetting DST\n", __FUNCTION__);
-
+	dprintk(verbose, DST_DEBUG, 1, "Resetting DST");
 	if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) {
-		dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
 		return -1;
 	}
 	udelay(1000);
 	if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) {
-		dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
 		return -1;
 	}
 
@@ -155,10 +157,11 @@ EXPORT_SYMBOL(rdc_8820_reset);
 int dst_pio_enable(struct dst_state *state)
 {
 	if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) {
-		dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
 		return -1;
 	}
 	udelay(1000);
+
 	return 0;
 }
 EXPORT_SYMBOL(dst_pio_enable);
@@ -166,7 +169,7 @@ EXPORT_SYMBOL(dst_pio_enable);
 int dst_pio_disable(struct dst_state *state)
 {
 	if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) {
-		dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
 		return -1;
 	}
 	if (state->type_flags & DST_TYPE_HAS_FW_1)
@@ -183,19 +186,16 @@ int dst_wait_dst_ready(struct dst_state 
 
 	for (i = 0; i < 200; i++) {
 		if (dst_gpio_inb(state, &reply) < 0) {
-			dprintk("%s: dst_gpio_inb ERROR !\n", __FUNCTION__);
+			dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !");
 			return -1;
 		}
-
 		if ((reply & RDC_8820_PIO_0_ENABLE) == 0) {
-			if (verbose > 4)
-				dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i);
+			dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i);
 			return 1;
 		}
 		msleep(10);
 	}
-	if (verbose > 1)
-		dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i);
+	dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i);
 
 	return 0;
 }
@@ -203,7 +203,7 @@ EXPORT_SYMBOL(dst_wait_dst_ready);
 
 int dst_error_recovery(struct dst_state *state)
 {
-	dprintk("%s: Trying to return from previous errors...\n", __FUNCTION__);
+	dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors.");
 	dst_pio_disable(state);
 	msleep(10);
 	dst_pio_enable(state);
@@ -215,7 +215,7 @@ EXPORT_SYMBOL(dst_error_recovery);
 
 int dst_error_bailout(struct dst_state *state)
 {
-	dprintk("%s: Trying to bailout from previous error...\n", __FUNCTION__);
+	dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error.");
 	rdc_8820_reset(state);
 	dst_pio_disable(state);
 	msleep(10);
@@ -224,17 +224,15 @@ int dst_error_bailout(struct dst_state *
 }
 EXPORT_SYMBOL(dst_error_bailout);
 
-
-int dst_comm_init(struct dst_state* state)
+int dst_comm_init(struct dst_state *state)
 {
-	if (verbose > 1)
-		dprintk ("%s: Initializing DST..\n", __FUNCTION__);
+	dprintk(verbose, DST_INFO, 1, "Initializing DST.");
 	if ((dst_pio_enable(state)) < 0) {
-		dprintk("%s: PIO Enable Failed.\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed");
 		return -1;
 	}
 	if ((rdc_reset_state(state)) < 0) {
-		dprintk("%s: RDC 8820 State RESET Failed.\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed.");
 		return -1;
 	}
 	if (state->type_flags & DST_TYPE_HAS_FW_1)
@@ -246,36 +244,33 @@ int dst_comm_init(struct dst_state* stat
 }
 EXPORT_SYMBOL(dst_comm_init);
 
-
 int write_dst(struct dst_state *state, u8 *data, u8 len)
 {
 	struct i2c_msg msg = {
-		.addr = state->config->demod_address,.flags = 0,.buf = data,.len = len
+		.addr = state->config->demod_address,
+		.flags = 0,
+		.buf = data,
+		.len = len
 	};
 
 	int err;
-	int cnt;
-	if (debug && (verbose > 4)) {
-		u8 i;
-		if (verbose > 4) {
-			dprintk("%s writing [ ", __FUNCTION__);
-			for (i = 0; i < len; i++)
-				dprintk("%02x ", data[i]);
-			dprintk("]\n");
-		}
-	}
+	u8 cnt, i;
+
+	dprintk(verbose, DST_NOTICE, 0, "writing [ ");
+	for (i = 0; i < len; i++)
+		dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]);
+	dprintk(verbose, DST_NOTICE, 0, "]\n");
+
 	for (cnt = 0; cnt < 2; cnt++) {
 		if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
-			dprintk("%s: _write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]);
+			dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]);
 			dst_error_recovery(state);
 			continue;
 		} else
 			break;
 	}
-
 	if (cnt >= 2) {
-		if (verbose > 1)
-			printk("%s: RDC 8820 RESET...\n", __FUNCTION__);
+		dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET");
 		dst_error_bailout(state);
 
 		return -1;
@@ -285,36 +280,37 @@ int write_dst(struct dst_state *state, u
 }
 EXPORT_SYMBOL(write_dst);
 
-int read_dst(struct dst_state *state, u8 * ret, u8 len)
+int read_dst(struct dst_state *state, u8 *ret, u8 len)
 {
-	struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len };
+	struct i2c_msg msg = {
+		.addr = state->config->demod_address,
+		.flags = I2C_M_RD,
+		.buf = ret,
+		.len = len
+	};
+
 	int err;
 	int cnt;
 
 	for (cnt = 0; cnt < 2; cnt++) {
 		if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
-
-			dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]);
+			dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]);
 			dst_error_recovery(state);
-
 			continue;
 		} else
 			break;
 	}
 	if (cnt >= 2) {
-		if (verbose > 1)
-			printk("%s: RDC 8820 RESET...\n", __FUNCTION__);
+		dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET");
 		dst_error_bailout(state);
 
 		return -1;
 	}
-	if (debug && (verbose > 4)) {
-		dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]);
-		for (err = 1; err < len; err++)
-			dprintk(" 0x%x", ret[err]);
-		if (err > 1)
-			dprintk("\n");
-	}
+	dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]);
+	for (err = 1; err < len; err++)
+		dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]);
+	if (err > 1)
+		dprintk(verbose, DST_DEBUG, 0, "\n");
 
 	return 0;
 }
@@ -323,19 +319,16 @@ EXPORT_SYMBOL(read_dst);
 static int dst_set_polarization(struct dst_state *state)
 {
 	switch (state->voltage) {
-		case SEC_VOLTAGE_13:	// vertical
-			dprintk("%s: Polarization=[Vertical]\n", __FUNCTION__);
-			state->tx_tuna[8] &= ~0x40;  //1
-			break;
-
-		case SEC_VOLTAGE_18:	// horizontal
-			dprintk("%s: Polarization=[Horizontal]\n", __FUNCTION__);
-			state->tx_tuna[8] |= 0x40;  // 0
-			break;
-
-		case SEC_VOLTAGE_OFF:
-
-			break;
+	case SEC_VOLTAGE_13:	/*	Vertical	*/
+		dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]");
+		state->tx_tuna[8] &= ~0x40;
+		break;
+	case SEC_VOLTAGE_18:	/*	Horizontal	*/
+		dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]");
+		state->tx_tuna[8] |= 0x40;
+		break;
+	case SEC_VOLTAGE_OFF:
+		break;
 	}
 
 	return 0;
@@ -344,14 +337,12 @@ static int dst_set_polarization(struct d
 static int dst_set_freq(struct dst_state *state, u32 freq)
 {
 	state->frequency = freq;
-	if (verbose > 4)
-		dprintk("%s: set Frequency %u\n", __FUNCTION__, freq);
+	dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq);
 
 	if (state->dst_type == DST_TYPE_IS_SAT) {
 		freq = freq / 1000;
 		if (freq < 950 || freq > 2150)
 			return -EINVAL;
-
 		state->tx_tuna[2] = (freq >> 8);
 		state->tx_tuna[3] = (u8) freq;
 		state->tx_tuna[4] = 0x01;
@@ -360,27 +351,24 @@ static int dst_set_freq(struct dst_state
 			if (freq < 1531)
 				state->tx_tuna[8] |= 0x04;
 		}
-
 	} else if (state->dst_type == DST_TYPE_IS_TERR) {
 		freq = freq / 1000;
 		if (freq < 137000 || freq > 858000)
 			return -EINVAL;
-
 		state->tx_tuna[2] = (freq >> 16) & 0xff;
 		state->tx_tuna[3] = (freq >> 8) & 0xff;
 		state->tx_tuna[4] = (u8) freq;
-
 	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
 		state->tx_tuna[2] = (freq >> 16) & 0xff;
 		state->tx_tuna[3] = (freq >> 8) & 0xff;
 		state->tx_tuna[4] = (u8) freq;
-
 	} else
 		return -EINVAL;
+
 	return 0;
 }
 
-static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth)
+static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth)
 {
 	state->bandwidth = bandwidth;
 
@@ -388,90 +376,82 @@ static int dst_set_bandwidth(struct dst_
 		return 0;
 
 	switch (bandwidth) {
-		case BANDWIDTH_6_MHZ:
-			if (state->dst_hw_cap & DST_TYPE_HAS_CA)
-				state->tx_tuna[7] = 0x06;
-			else {
-				state->tx_tuna[6] = 0x06;
-				state->tx_tuna[7] = 0x00;
-			}
-			break;
-
-		case BANDWIDTH_7_MHZ:
-			if (state->dst_hw_cap & DST_TYPE_HAS_CA)
-				state->tx_tuna[7] = 0x07;
-			else {
-				state->tx_tuna[6] = 0x07;
-				state->tx_tuna[7] = 0x00;
-			}
-			break;
-
-		case BANDWIDTH_8_MHZ:
-			if (state->dst_hw_cap & DST_TYPE_HAS_CA)
-				state->tx_tuna[7] = 0x08;
-			else {
-				state->tx_tuna[6] = 0x08;
-				state->tx_tuna[7] = 0x00;
-			}
-			break;
-
-		default:
-			return -EINVAL;
+	case BANDWIDTH_6_MHZ:
+		if (state->dst_hw_cap & DST_TYPE_HAS_CA)
+			state->tx_tuna[7] = 0x06;
+		else {
+			state->tx_tuna[6] = 0x06;
+			state->tx_tuna[7] = 0x00;
+		}
+		break;
+	case BANDWIDTH_7_MHZ:
+		if (state->dst_hw_cap & DST_TYPE_HAS_CA)
+			state->tx_tuna[7] = 0x07;
+		else {
+			state->tx_tuna[6] = 0x07;
+			state->tx_tuna[7] = 0x00;
+		}
+		break;
+	case BANDWIDTH_8_MHZ:
+		if (state->dst_hw_cap & DST_TYPE_HAS_CA)
+			state->tx_tuna[7] = 0x08;
+		else {
+			state->tx_tuna[6] = 0x08;
+			state->tx_tuna[7] = 0x00;
+		}
+		break;
+	default:
+		return -EINVAL;
 	}
+
 	return 0;
 }
 
-static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion)
+static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion)
 {
 	state->inversion = inversion;
 	switch (inversion) {
-		case INVERSION_OFF:	// Inversion = Normal
-			state->tx_tuna[8] &= ~0x80;
-			break;
-
-		case INVERSION_ON:
-			state->tx_tuna[8] |= 0x80;
-			break;
-		default:
-			return -EINVAL;
+	case INVERSION_OFF:	/*	Inversion = Normal	*/
+		state->tx_tuna[8] &= ~0x80;
+		break;
+	case INVERSION_ON:
+		state->tx_tuna[8] |= 0x80;
+		break;
+	default:
+		return -EINVAL;
 	}
+
 	return 0;
 }
 
-static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec)
+static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec)
 {
 	state->fec = fec;
 	return 0;
 }
 
-static fe_code_rate_t dst_get_fec(struct dst_state* state)
+static fe_code_rate_t dst_get_fec(struct dst_state *state)
 {
 	return state->fec;
 }
 
-static int dst_set_symbolrate(struct dst_state* state, u32 srate)
+static int dst_set_symbolrate(struct dst_state *state, u32 srate)
 {
 	u32 symcalc;
 	u64 sval;
 
 	state->symbol_rate = srate;
-
 	if (state->dst_type == DST_TYPE_IS_TERR) {
 		return 0;
 	}
-	if (debug > 4)
-		dprintk("%s: set symrate %u\n", __FUNCTION__, srate);
+	dprintk(verbose, DST_INFO, 1, "set symrate %u", srate);
 	srate /= 1000;
-
 	if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
 		sval = srate;
 		sval <<= 20;
 		do_div(sval, 88000);
 		symcalc = (u32) sval;
-
-		if (debug > 4)
-			dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc);
-
+		dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc);
 		state->tx_tuna[5] = (u8) (symcalc >> 12);
 		state->tx_tuna[6] = (u8) (symcalc >> 4);
 		state->tx_tuna[7] = (u8) (symcalc << 4);
@@ -496,32 +476,27 @@ static int dst_set_modulation(struct dst
 
 	state->modulation = modulation;
 	switch (modulation) {
-		case QAM_16:
-			state->tx_tuna[8] = 0x10;
-			break;
-
-		case QAM_32:
-			state->tx_tuna[8] = 0x20;
-			break;
-
-		case QAM_64:
-			state->tx_tuna[8] = 0x40;
-			break;
-
-		case QAM_128:
-			state->tx_tuna[8] = 0x80;
-			break;
-
-		case QAM_256:
-			state->tx_tuna[8] = 0x00;
-			break;
-
-		case QPSK:
-		case QAM_AUTO:
-		case VSB_8:
-		case VSB_16:
-		default:
-			return -EINVAL;
+	case QAM_16:
+		state->tx_tuna[8] = 0x10;
+		break;
+	case QAM_32:
+		state->tx_tuna[8] = 0x20;
+		break;
+	case QAM_64:
+		state->tx_tuna[8] = 0x40;
+		break;
+	case QAM_128:
+		state->tx_tuna[8] = 0x80;
+		break;
+	case QAM_256:
+		state->tx_tuna[8] = 0x00;
+		break;
+	case QPSK:
+	case QAM_AUTO:
+	case VSB_8:
+	case VSB_16:
+	default:
+		return -EINVAL;
 
 	}
 
@@ -534,7 +509,7 @@ static fe_modulation_t dst_get_modulatio
 }
 
 
-u8 dst_check_sum(u8 * buf, u32 len)
+u8 dst_check_sum(u8 *buf, u32 len)
 {
 	u32 i;
 	u8 val = 0;
@@ -549,26 +524,24 @@ EXPORT_SYMBOL(dst_check_sum);
 
 static void dst_type_flags_print(u32 type_flags)
 {
-	printk("DST type flags :");
+	dprintk(verbose, DST_ERROR, 0, "DST type flags :");
 	if (type_flags & DST_TYPE_HAS_NEWTUNE)
-		printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE);
+		dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE);
 	if (type_flags & DST_TYPE_HAS_TS204)
-		printk(" 0x%x ts204", DST_TYPE_HAS_TS204);
+		dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204);
 	if (type_flags & DST_TYPE_HAS_SYMDIV)
-		printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
+		dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
 	if (type_flags & DST_TYPE_HAS_FW_1)
-		printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1);
+		dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1);
 	if (type_flags & DST_TYPE_HAS_FW_2)
-		printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2);
+		dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2);
 	if (type_flags & DST_TYPE_HAS_FW_3)
-		printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3);
-//	if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw)
-
-	printk("\n");
+		dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3);
+	dprintk(verbose, DST_ERROR, 0, "\n");
 }
 
 
-static int dst_type_print (u8 type)
+static int dst_type_print(u8 type)
 {
 	char *otype;
 	switch (type) {
@@ -585,10 +558,10 @@ static int dst_type_print (u8 type)
 		break;
 
 	default:
-		printk("%s: invalid dst type %d\n", __FUNCTION__, type);
+		dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type);
 		return -EINVAL;
 	}
-	printk("DST type : %s\n", otype);
+	dprintk(verbose, DST_INFO, 1, "DST type: %s", otype);
 
 	return 0;
 }
@@ -772,53 +745,45 @@ static int dst_get_device_id(struct dst_
 
 	if (write_dst(state, device_type, FIXED_COMM))
 		return -1;		/*	Write failed		*/
-
 	if ((dst_pio_disable(state)) < 0)
 		return -1;
-
 	if (read_dst(state, &reply, GET_ACK))
 		return -1;		/*	Read failure		*/
-
 	if (reply != ACK) {
-		dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply);
+		dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply);
 		return -1;		/*	Unack'd write		*/
 	}
-
 	if (!dst_wait_dst_ready(state, DEVICE_INIT))
 		return -1;		/*	DST not ready yet	*/
-
 	if (read_dst(state, state->rxbuffer, FIXED_COMM))
 		return -1;
 
 	dst_pio_disable(state);
-
 	if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
-		dprintk("%s: Checksum failure! \n", __FUNCTION__);
+		dprintk(verbose, DST_INFO, 1, "Checksum failure!");
 		return -1;		/*	Checksum failure	*/
 	}
-
 	state->rxbuffer[7] = '\0';
 
-	for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) {
+	for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) {
 		if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) {
 			use_type_flags = p_dst_type->type_flags;
 			use_dst_type = p_dst_type->dst_type;
 
 			/*	Card capabilities	*/
 			state->dst_hw_cap = p_dst_type->dst_feature;
-			printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id);
+			dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id);
 
 			break;
 		}
 	}
 
 	if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) {
-		printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]);
-		printk("%s: please email [email protected] with this type in\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]);
+		dprintk(verbose, DST_ERROR, 1, "please email [email protected] with this type in");
 		use_dst_type = DST_TYPE_IS_SAT;
 		use_type_flags = DST_TYPE_HAS_SYMDIV;
 	}
-
 	dst_type_print(use_dst_type);
 	state->type_flags = use_type_flags;
 	state->dst_type = use_dst_type;
@@ -834,7 +799,7 @@ static int dst_get_device_id(struct dst_
 static int dst_probe(struct dst_state *state)
 {
 	if ((rdc_8820_reset(state)) < 0) {
-		dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
 		return -1;
 	}
 	if (dst_addons & DST_TYPE_HAS_CA)
@@ -843,80 +808,69 @@ static int dst_probe(struct dst_state *s
 		msleep(100);
 
 	if ((dst_comm_init(state)) < 0) {
-		dprintk("%s: DST Initialization Failed.\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed.");
 		return -1;
 	}
 	msleep(100);
 	if (dst_get_device_id(state) < 0) {
-		dprintk("%s: unknown device.\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "unknown device.");
 		return -1;
 	}
 
 	return 0;
 }
 
-int dst_command(struct dst_state* state, u8 * data, u8 len)
+int dst_command(struct dst_state *state, u8 *data, u8 len)
 {
 	u8 reply;
 	if ((dst_comm_init(state)) < 0) {
-		dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__);
+		dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
 		return -1;
 	}
-
 	if (write_dst(state, data, len)) {
-		if (verbose > 1)
-			dprintk("%s: Tring to recover.. \n", __FUNCTION__);
+		dprintk(verbose, DST_INFO, 1, "Tring to recover.. ");
 		if ((dst_error_recovery(state)) < 0) {
-			dprintk("%s: Recovery Failed.\n", __FUNCTION__);
+			dprintk(verbose, DST_ERROR, 1, "Recovery Failed.");
 			return -1;
 		}
 		return -1;
 	}
 	if ((dst_pio_disable(state)) < 0) {
-		dprintk("%s: PIO Disable Failed.\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed.");
 		return -1;
 	}
 	if (state->type_flags & DST_TYPE_HAS_FW_1)
 		udelay(3000);
-
 	if (read_dst(state, &reply, GET_ACK)) {
-		if (verbose > 1)
-			dprintk("%s: Trying to recover.. \n", __FUNCTION__);
+		dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
 		if ((dst_error_recovery(state)) < 0) {
-			dprintk("%s: Recovery Failed.\n", __FUNCTION__);
+			dprintk(verbose, DST_INFO, 1, "Recovery Failed.");
 			return -1;
 		}
 		return -1;
 	}
-
 	if (reply != ACK) {
-		dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply);
+		dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply);
 		return -1;
 	}
 	if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
 		return 0;
-
-//	udelay(3000);
 	if (state->type_flags & DST_TYPE_HAS_FW_1)
 		udelay(3000);
 	else
 		udelay(2000);
-
 	if (!dst_wait_dst_ready(state, NO_DELAY))
 		return -1;
-
 	if (read_dst(state, state->rxbuffer, FIXED_COMM)) {
-		if (verbose > 1)
-			dprintk("%s: Trying to recover.. \n", __FUNCTION__);
+		dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
 		if ((dst_error_recovery(state)) < 0) {
-			dprintk("%s: Recovery failed.\n", __FUNCTION__);
+			dprintk(verbose, DST_INFO, 1, "Recovery failed.");
 			return -1;
 		}
 		return -1;
 	}
-
 	if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
-		dprintk("%s: checksum failure\n", __FUNCTION__);
+		dprintk(verbose, DST_INFO, 1, "checksum failure");
 		return -1;
 	}
 
@@ -924,7 +878,7 @@ int dst_command(struct dst_state* state,
 }
 EXPORT_SYMBOL(dst_command);
 
-static int dst_get_signal(struct dst_state* state)
+static int dst_get_signal(struct dst_state *state)
 {
 	int retval;
 	u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
@@ -955,13 +909,12 @@ static int dst_get_signal(struct dst_sta
 	return 0;
 }
 
-static int dst_tone_power_cmd(struct dst_state* state)
+static int dst_tone_power_cmd(struct dst_state *state)
 {
 	u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 };
 
 	if (state->dst_type == DST_TYPE_IS_TERR)
 		return 0;
-
 	paket[4] = state->tx_tuna[4];
 	paket[2] = state->tx_tuna[2];
 	paket[3] = state->tx_tuna[3];
@@ -971,61 +924,53 @@ static int dst_tone_power_cmd(struct dst
 	return 0;
 }
 
-static int dst_get_tuna(struct dst_state* state)
+static int dst_get_tuna(struct dst_state *state)
 {
 	int retval;
 
 	if ((state->diseq_flags & ATTEMPT_TUNE) == 0)
 		return 0;
-
 	state->diseq_flags &= ~(HAS_LOCK);
 	if (!dst_wait_dst_ready(state, NO_DELAY))
 		return 0;
-
-	if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
+	if (state->type_flags & DST_TYPE_HAS_NEWTUNE)
 		/* how to get variable length reply ???? */
 		retval = read_dst(state, state->rx_tuna, 10);
-	} else {
+	else
 		retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
-	}
-
 	if (retval < 0) {
-		dprintk("%s: read not successful\n", __FUNCTION__);
+		dprintk(verbose, DST_DEBUG, 1, "read not successful");
 		return 0;
 	}
-
 	if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
 		if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
-			dprintk("%s: checksum failure?\n", __FUNCTION__);
+			dprintk(verbose, DST_INFO, 1, "checksum failure ? ");
 			return 0;
 		}
 	} else {
 		if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) {
-			dprintk("%s: checksum failure?\n", __FUNCTION__);
+			dprintk(verbose, DST_INFO, 1, "checksum failure? ");
 			return 0;
 		}
 	}
 	if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0)
 		return 0;
 	state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3];
-
 	state->decode_lock = 1;
 	state->diseq_flags |= HAS_LOCK;
 
 	return 1;
 }
 
-static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
+static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
 
-static int dst_write_tuna(struct dvb_frontend* fe)
+static int dst_write_tuna(struct dvb_frontend *fe)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 	int retval;
 	u8 reply;
 
-	if (debug > 4)
-		dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags);
-
+	dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags);
 	state->decode_freq = 0;
 	state->decode_lock = state->decode_strength = state->decode_snr = 0;
 	if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -1035,35 +980,31 @@ static int dst_write_tuna(struct dvb_fro
 	state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
 
 	if ((dst_comm_init(state)) < 0) {
-		dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__);
+		dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
 		return -1;
 	}
-
 	if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
 		state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
 		retval = write_dst(state, &state->tx_tuna[0], 10);
-
 	} else {
 		state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7);
 		retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM);
 	}
 	if (retval < 0) {
 		dst_pio_disable(state);
-		dprintk("%s: write not successful\n", __FUNCTION__);
+		dprintk(verbose, DST_DEBUG, 1, "write not successful");
 		return retval;
 	}
-
 	if ((dst_pio_disable(state)) < 0) {
-		dprintk("%s: DST PIO disable failed !\n", __FUNCTION__);
+		dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !");
 		return -1;
 	}
-
 	if ((read_dst(state, &reply, GET_ACK) < 0)) {
-		dprintk("%s: read verify not successful.\n", __FUNCTION__);
+		dprintk(verbose, DST_DEBUG, 1, "read verify not successful.");
 		return -1;
 	}
 	if (reply != ACK) {
-		dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply);
+		dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply);
 		return 0;
 	}
 	state->diseq_flags |= ATTEMPT_TUNE;
@@ -1085,14 +1026,13 @@ static int dst_write_tuna(struct dvb_fro
  * Diseqc 4    0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0
  */
 
-static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
+static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 	u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
 
 	if (state->dst_type != DST_TYPE_IS_SAT)
 		return 0;
-
 	if (cmd->msg_len == 0 || cmd->msg_len > 4)
 		return -EINVAL;
 	memcpy(&paket[3], cmd->msg, cmd->msg_len);
@@ -1101,65 +1041,61 @@ static int dst_set_diseqc(struct dvb_fro
 	return 0;
 }
 
-static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
+static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
 {
 	int need_cmd;
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 
 	state->voltage = voltage;
-
 	if (state->dst_type != DST_TYPE_IS_SAT)
 		return 0;
 
 	need_cmd = 0;
-	switch (voltage) {
-		case SEC_VOLTAGE_13:
-		case SEC_VOLTAGE_18:
-			if ((state->diseq_flags & HAS_POWER) == 0)
-				need_cmd = 1;
-			state->diseq_flags |= HAS_POWER;
-			state->tx_tuna[4] = 0x01;
-			break;
 
-		case SEC_VOLTAGE_OFF:
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+	case SEC_VOLTAGE_18:
+		if ((state->diseq_flags & HAS_POWER) == 0)
 			need_cmd = 1;
-			state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE);
-			state->tx_tuna[4] = 0x00;
-			break;
-
-		default:
-			return -EINVAL;
+		state->diseq_flags |= HAS_POWER;
+		state->tx_tuna[4] = 0x01;
+		break;
+	case SEC_VOLTAGE_OFF:
+		need_cmd = 1;
+		state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE);
+		state->tx_tuna[4] = 0x00;
+		break;
+	default:
+		return -EINVAL;
 	}
+
 	if (need_cmd)
 		dst_tone_power_cmd(state);
 
 	return 0;
 }
 
-static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
+static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 
 	state->tone = tone;
-
 	if (state->dst_type != DST_TYPE_IS_SAT)
 		return 0;
 
 	switch (tone) {
-		case SEC_TONE_OFF:
-			if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
-			    state->tx_tuna[2] = 0x00;
-			else
-			    state->tx_tuna[2] = 0xff;
-
-			break;
-
-		case SEC_TONE_ON:
-			state->tx_tuna[2] = 0x02;
-			break;
+	case SEC_TONE_OFF:
+		if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
+		    state->tx_tuna[2] = 0x00;
+		else
+		    state->tx_tuna[2] = 0xff;
+		break;
 
-		default:
-			return -EINVAL;
+	case SEC_TONE_ON:
+		state->tx_tuna[2] = 0x02;
+		break;
+	default:
+		return -EINVAL;
 	}
 	dst_tone_power_cmd(state);
 
@@ -1172,16 +1108,14 @@ static int dst_send_burst(struct dvb_fro
 
 	if (state->dst_type != DST_TYPE_IS_SAT)
 		return 0;
-
 	state->minicmd = minicmd;
-
 	switch (minicmd) {
-		case SEC_MINI_A:
-			state->tx_tuna[3] = 0x02;
-			break;
-		case SEC_MINI_B:
-			state->tx_tuna[3] = 0xff;
-			break;
+	case SEC_MINI_A:
+		state->tx_tuna[3] = 0x02;
+		break;
+	case SEC_MINI_B:
+		state->tx_tuna[3] = 0xff;
+		break;
 	}
 	dst_tone_power_cmd(state);
 
@@ -1189,42 +1123,37 @@ static int dst_send_burst(struct dvb_fro
 }
 
 
-static int dst_init(struct dvb_frontend* fe)
+static int dst_init(struct dvb_frontend *fe)
 {
-	struct dst_state* state = fe->demodulator_priv;
-	static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 };
-	static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 };
-	static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
-	static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
-	static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
-	static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 };
-//	state->inversion = INVERSION_ON;
+	struct dst_state *state = fe->demodulator_priv;
+
+	static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 };
+	static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 };
+	static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
+	static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
+	static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
+	static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
+
 	state->inversion = INVERSION_OFF;
 	state->voltage = SEC_VOLTAGE_13;
 	state->tone = SEC_TONE_OFF;
-	state->symbol_rate = 29473000;
-	state->fec = FEC_AUTO;
 	state->diseq_flags = 0;
 	state->k22 = 0x02;
 	state->bandwidth = BANDWIDTH_7_MHZ;
 	state->cur_jiff = jiffies;
-	if (state->dst_type == DST_TYPE_IS_SAT) {
-		state->frequency = 950000;
-		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna));
-	} else if (state->dst_type == DST_TYPE_IS_TERR) {
-		state->frequency = 137000000;
-		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna));
-	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
-		state->frequency = 51000000;
-		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna));
-	}
+	if (state->dst_type == DST_TYPE_IS_SAT)
+		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204));
+	else if (state->dst_type == DST_TYPE_IS_TERR)
+		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204));
+	else if (state->dst_type == DST_TYPE_IS_CABLE)
+		memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204));
 
 	return 0;
 }
 
-static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status)
+static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 
 	*status = 0;
 	if (state->diseq_flags & HAS_LOCK) {
@@ -1236,9 +1165,9 @@ static int dst_read_status(struct dvb_fr
 	return 0;
 }
 
-static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength)
+static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 
 	dst_get_signal(state);
 	*strength = state->decode_strength;
@@ -1246,9 +1175,9 @@ static int dst_read_signal_strength(stru
 	return 0;
 }
 
-static int dst_read_snr(struct dvb_frontend* fe, u16* snr)
+static int dst_read_snr(struct dvb_frontend *fe, u16 *snr)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 
 	dst_get_signal(state);
 	*snr = state->decode_snr;
@@ -1256,28 +1185,24 @@ static int dst_read_snr(struct dvb_front
 	return 0;
 }
 
-static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 
 	dst_set_freq(state, p->frequency);
-	if (verbose > 4)
-		dprintk("Set Frequency=[%d]\n", p->frequency);
+	dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
 
-//	dst_set_inversion(state, p->inversion);
 	if (state->dst_type == DST_TYPE_IS_SAT) {
 		if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
 			dst_set_inversion(state, p->inversion);
-
 		dst_set_fec(state, p->u.qpsk.fec_inner);
 		dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
 		dst_set_polarization(state);
-		if (verbose > 4)
-			dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate);
+		dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate);
 
-	} else if (state->dst_type == DST_TYPE_IS_TERR) {
+	} else if (state->dst_type == DST_TYPE_IS_TERR)
 		dst_set_bandwidth(state, p->u.ofdm.bandwidth);
-	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
+	else if (state->dst_type == DST_TYPE_IS_CABLE) {
 		dst_set_fec(state, p->u.qam.fec_inner);
 		dst_set_symbolrate(state, p->u.qam.symbol_rate);
 		dst_set_modulation(state, p->u.qam.modulation);
@@ -1287,16 +1212,14 @@ static int dst_set_frontend(struct dvb_f
 	return 0;
 }
 
-static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 
 	p->frequency = state->decode_freq;
-//	p->inversion = state->inversion;
 	if (state->dst_type == DST_TYPE_IS_SAT) {
 		if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
 			p->inversion = state->inversion;
-
 		p->u.qpsk.symbol_rate = state->symbol_rate;
 		p->u.qpsk.fec_inner = dst_get_fec(state);
 	} else if (state->dst_type == DST_TYPE_IS_TERR) {
@@ -1304,16 +1227,15 @@ static int dst_get_frontend(struct dvb_f
 	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
 		p->u.qam.symbol_rate = state->symbol_rate;
 		p->u.qam.fec_inner = dst_get_fec(state);
-//		p->u.qam.modulation = QAM_AUTO;
 		p->u.qam.modulation = dst_get_modulation(state);
 	}
 
 	return 0;
 }
 
-static void dst_release(struct dvb_frontend* fe)
+static void dst_release(struct dvb_frontend *fe)
 {
-	struct dst_state* state = fe->demodulator_priv;
+	struct dst_state *state = fe->demodulator_priv;
 	kfree(state);
 }
 
@@ -1321,9 +1243,8 @@ static struct dvb_frontend_ops dst_dvbt_
 static struct dvb_frontend_ops dst_dvbs_ops;
 static struct dvb_frontend_ops dst_dvbc_ops;
 
-struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
+struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
 {
-
 	/* check if the ASIC is there */
 	if (dst_probe(state) < 0) {
 		if (state)
@@ -1336,17 +1257,14 @@ struct dst_state* dst_attach(struct dst_
 	case DST_TYPE_IS_TERR:
 		memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
 		break;
-
 	case DST_TYPE_IS_CABLE:
 		memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
 		break;
-
 	case DST_TYPE_IS_SAT:
 		memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
 		break;
-
 	default:
-		printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__);
+		dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist.");
 		if (state)
 			kfree(state);
 
@@ -1374,12 +1292,9 @@ static struct dvb_frontend_ops dst_dvbt_
 	},
 
 	.release = dst_release,
-
 	.init = dst_init,
-
 	.set_frontend = dst_set_frontend,
 	.get_frontend = dst_get_frontend,
-
 	.read_status = dst_read_status,
 	.read_signal_strength = dst_read_signal_strength,
 	.read_snr = dst_read_snr,
@@ -1401,16 +1316,12 @@ static struct dvb_frontend_ops dst_dvbs_
 	},
 
 	.release = dst_release,
-
 	.init = dst_init,
-
 	.set_frontend = dst_set_frontend,
 	.get_frontend = dst_get_frontend,
-
 	.read_status = dst_read_status,
 	.read_signal_strength = dst_read_signal_strength,
 	.read_snr = dst_read_snr,
-
 	.diseqc_send_burst = dst_send_burst,
 	.diseqc_send_master_cmd = dst_set_diseqc,
 	.set_voltage = dst_set_voltage,
@@ -1432,18 +1343,14 @@ static struct dvb_frontend_ops dst_dvbc_
 	},
 
 	.release = dst_release,
-
 	.init = dst_init,
-
 	.set_frontend = dst_set_frontend,
 	.get_frontend = dst_get_frontend,
-
 	.read_status = dst_read_status,
 	.read_signal_strength = dst_read_signal_strength,
 	.read_snr = dst_read_snr,
 };
 
-
 MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver");
 MODULE_AUTHOR("Jamie Honan, Manu Abraham");
 MODULE_LICENSE("GPL");
drivers/media/dvb/bt8xx/dst_ca.c +182 -259

689 lines not on this page · raw message

drivers/media/dvb/bt8xx/dst_common.h +0 -4
@@ -61,7 +61,6 @@
 #define	DST_TYPE_HAS_ANALOG	64	/*	Analog inputs	*/
 #define DST_TYPE_HAS_SESSION	128
 
-
 #define RDC_8820_PIO_0_DISABLE	0
 #define RDC_8820_PIO_0_ENABLE	1
 #define RDC_8820_INT		2
@@ -124,15 +123,12 @@ struct dst_types {
 	u32 dst_feature;
 };
 
-
-
 struct dst_config
 {
 	/* the ASIC i2c address */
 	u8 demod_address;
 };
 
-
 int rdc_reset_state(struct dst_state *state);
 int rdc_8820_reset(struct dst_state *state);
 

--

#49 lore raw

PATCH 46/54 budget-ci: add support for TT DVB-C CI card

In reply to Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Add support for TT DVB-C CI card.

 drivers/media/dvb/b2c2/flexcop-fe-tuner.c |   97 +++++++++++++++
 drivers/media/dvb/frontends/stv0297.c     |  121 -------------------
 drivers/media/dvb/frontends/stv0297.h     |    8 +
 drivers/media/dvb/ttpci/av7110.c          |   95 +++++++++++++++
 drivers/media/dvb/ttpci/budget-ci.c       |  188 +++++++++++++++++++++++++++++-
 5 files changed, 387 insertions(+), 122 deletions(-)
drivers/media/dvb/ttpci/budget-ci.c +187 -1
@@ -40,6 +40,7 @@
 
 #include "dvb_ca_en50221.h"
 #include "stv0299.h"
+#include "stv0297.h"
 #include "tda1004x.h"
 
 #define DEBIADDR_IR		0x1234
@@ -847,6 +848,180 @@ static struct tda1004x_config philips_td
 	.request_firmware = philips_tdm1316l_request_firmware,
 };
 
+static int dvbc_philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
+	u8 tuner_buf[5];
+	struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,
+				    .flags = 0,
+				    .buf = tuner_buf,
+				    .len = sizeof(tuner_buf) };
+	int tuner_frequency = 0;
+	u8 band, cp, filter;
+
+	// determine charge pump
+	tuner_frequency = params->frequency + 36125000;
+	if (tuner_frequency < 87000000)
+		return -EINVAL;
+	else if (tuner_frequency < 130000000) {
+		cp = 3;
+		band = 1;
+	} else if (tuner_frequency < 160000000) {
+		cp = 5;
+		band = 1;
+	} else if (tuner_frequency < 200000000) {
+		cp = 6;
+		band = 1;
+	} else if (tuner_frequency < 290000000) {
+		cp = 3;
+		band = 2;
+	} else if (tuner_frequency < 420000000) {
+		cp = 5;
+		band = 2;
+	} else if (tuner_frequency < 480000000) {
+		cp = 6;
+		band = 2;
+	} else if (tuner_frequency < 620000000) {
+		cp = 3;
+		band = 4;
+	} else if (tuner_frequency < 830000000) {
+		cp = 5;
+		band = 4;
+	} else if (tuner_frequency < 895000000) {
+		cp = 7;
+		band = 4;
+	} else
+		return -EINVAL;
+
+	// assume PLL filter should always be 8MHz for the moment.
+	filter = 1;
+
+	// calculate divisor
+	tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500;
+
+	// setup tuner buffer
+	tuner_buf[0] = tuner_frequency >> 8;
+	tuner_buf[1] = tuner_frequency & 0xff;
+	tuner_buf[2] = 0xc8;
+	tuner_buf[3] = (cp << 5) | (filter << 3) | band;
+	tuner_buf[4] = 0x80;
+
+	stv0297_enable_plli2c(fe);
+	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
+		return -EIO;
+
+	msleep(50);
+
+	stv0297_enable_plli2c(fe);
+	if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
+		return -EIO;
+
+	msleep(1);
+
+	return 0;
+}
+
+static u8 dvbc_philips_tdm1316l_inittab[] = {
+	0x80, 0x01,
+	0x80, 0x00,
+	0x81, 0x01,
+	0x81, 0x00,
+	0x00, 0x09,
+	0x01, 0x69,
+	0x03, 0x00,
+	0x04, 0x00,
+	0x07, 0x00,
+	0x08, 0x00,
+	0x20, 0x00,
+	0x21, 0x40,
+	0x22, 0x00,
+	0x23, 0x00,
+	0x24, 0x40,
+	0x25, 0x88,
+	0x30, 0xff,
+	0x31, 0x00,
+	0x32, 0xff,
+	0x33, 0x00,
+	0x34, 0x50,
+	0x35, 0x7f,
+	0x36, 0x00,
+	0x37, 0x20,
+	0x38, 0x00,
+	0x40, 0x1c,
+	0x41, 0xff,
+	0x42, 0x29,
+	0x43, 0x20,
+	0x44, 0xff,
+	0x45, 0x00,
+	0x46, 0x00,
+	0x49, 0x04,
+	0x4a, 0x00,
+	0x4b, 0x7b,
+	0x52, 0x30,
+	0x55, 0xae,
+	0x56, 0x47,
+	0x57, 0xe1,
+	0x58, 0x3a,
+	0x5a, 0x1e,
+	0x5b, 0x34,
+	0x60, 0x00,
+	0x63, 0x00,
+	0x64, 0x00,
+	0x65, 0x00,
+	0x66, 0x00,
+	0x67, 0x00,
+	0x68, 0x00,
+	0x69, 0x00,
+	0x6a, 0x02,
+	0x6b, 0x00,
+	0x70, 0xff,
+	0x71, 0x00,
+	0x72, 0x00,
+	0x73, 0x00,
+	0x74, 0x0c,
+	0x80, 0x00,
+	0x81, 0x00,
+	0x82, 0x00,
+	0x83, 0x00,
+	0x84, 0x04,
+	0x85, 0x80,
+	0x86, 0x24,
+	0x87, 0x78,
+	0x88, 0x10,
+	0x89, 0x00,
+	0x90, 0x01,
+	0x91, 0x01,
+	0xa0, 0x04,
+	0xa1, 0x00,
+	0xa2, 0x00,
+	0xb0, 0x91,
+	0xb1, 0x0b,
+	0xc0, 0x53,
+	0xc1, 0x70,
+	0xc2, 0x12,
+	0xd0, 0x00,
+	0xd1, 0x00,
+	0xd2, 0x00,
+	0xd3, 0x00,
+	0xd4, 0x00,
+	0xd5, 0x00,
+	0xde, 0x00,
+	0xdf, 0x00,
+	0x61, 0x38,
+	0x62, 0x0a,
+	0x53, 0x13,
+	0x59, 0x08,
+	0xff, 0xff,
+};
+
+static struct stv0297_config dvbc_philips_tdm1316l_config = {
+	.demod_address = 0x1c,
+	.inittab = dvbc_philips_tdm1316l_inittab,
+	.invert = 0,
+	.pll_set = dvbc_philips_tdm1316l_pll_set,
+};
+
+
 
 
 static void frontend_init(struct budget_ci *budget_ci)
@@ -868,6 +1043,15 @@ static void frontend_init(struct budget_
 		}
 		break;
 
+	case 0x1010:		// TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt))
+		budget_ci->tuner_pll_address = 0x61;
+		budget_ci->budget.dvb_frontend =
+			stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
+		if (budget_ci->budget.dvb_frontend) {
+			break;
+		}
+		break;
+
 	case 0x1011:		// Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
 		budget_ci->tuner_pll_address = 0x63;
 		budget_ci->budget.dvb_frontend =
@@ -877,7 +1061,7 @@ static void frontend_init(struct budget_
 		}
 		break;
 
-	case 0x1012:		// Hauppauge/TT Nova-T CI budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
+	case 0x1012:		// TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
 		budget_ci->tuner_pll_address = 0x60;
 		budget_ci->budget.dvb_frontend =
 			tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
@@ -965,10 +1149,12 @@ static struct saa7146_extension budget_e
 MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC);
 MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T	 PCI", BUDGET_TT);
 MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT);
+MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT);
 
 static struct pci_device_id pci_tbl[] = {
 	MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c),
 	MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f),
+	MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010),
 	MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011),
 	MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012),
 	{
drivers/media/dvb/frontends/stv0297.c +3 -118

152 lines not on this page · raw message

drivers/media/dvb/frontends/stv0297.h +7 -1
@@ -29,6 +29,12 @@ struct stv0297_config
 	/* the demodulator's i2c address */
 	u8 demod_address;
 
+	/* inittab - array of pairs of values.
+	* First of each pair is the register, second is the value.
+	* List should be terminated with an 0xff, 0xff pair.
+	*/
+	u8* inittab;
+
 	/* does the "inversion" need inverted? */
 	u8 invert:1;
 
@@ -38,7 +44,7 @@ struct stv0297_config
 };
 
 extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
-					   struct i2c_adapter* i2c, int pwm);
+					   struct i2c_adapter* i2c);
 extern int stv0297_enable_plli2c(struct dvb_frontend* fe);
 
 #endif // STV0297_H
drivers/media/dvb/ttpci/av7110.c +94 -1

113 lines not on this page · raw message

drivers/media/dvb/b2c2/flexcop-fe-tuner.c +96 -1

111 lines not on this page · raw message

--

#24 lore raw

PATCH 22/54 frontend: or51132: remove bogus optimization attempt

In reply to Johannes Stezenbach

From: Mac Michaels <[email protected]>

This fix has also been applied to lgdt330x. There is an optimization that keeps track of the frequency tuned by the digital decoder. The digital driver does not set the frequency if it has not changed since it was tuned. The analog tuner driver knows nothing about the frequency saved by the digital driver. When the frequency is set using the video4linux code with tvtime, the hardware get changed but the digital driver's state does not get updated. Switch back to the same digital channel and the driver finds no change in frequency so the tuner is not reset to the digital frequency. The work around is to remove the check and always set the tuner to the specified frequency.

 drivers/media/dvb/frontends/or51132.c |   25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/media/dvb/frontends/or51132.c +11 -14
@@ -370,22 +370,19 @@ static int or51132_set_parameters(struct
 		or51132_setmode(fe);
 	}
 
-	/* Change only if we are actually changing the channel */
-	if (state->current_frequency != param->frequency) {
-		dvb_pll_configure(state->config->pll_desc, buf,
-				  param->frequency, 0);
-		dprintk("set_parameters tuner bytes: 0x%02x 0x%02x "
-			"0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
-		if (i2c_writebytes(state, state->config->pll_address ,buf, 4))
-			printk(KERN_WARNING "or51132: set_parameters error "
-			       "writing to tuner\n");
+	dvb_pll_configure(state->config->pll_desc, buf,
+			  param->frequency, 0);
+	dprintk("set_parameters tuner bytes: 0x%02x 0x%02x "
+		"0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
+	if (i2c_writebytes(state, state->config->pll_address ,buf, 4))
+		printk(KERN_WARNING "or51132: set_parameters error "
+		       "writing to tuner\n");
 
-		/* Set to current mode */
-		or51132_setmode(fe);
+	/* Set to current mode */
+	or51132_setmode(fe);
 
-		/* Update current frequency */
-		state->current_frequency = param->frequency;
-	}
+	/* Update current frequency */
+	state->current_frequency = param->frequency;
 	return 0;
 }
 

--

#30 lore raw

PATCH 27/54 usb: dtt200u: add proper device names

In reply to Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

Added names for clones of the DVB-T stick.
Whitespace cleanups.

 drivers/media/dvb/dvb-usb/dtt200u.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/media/dvb/dvb-usb/dtt200u.c +8 -9
@@ -106,12 +106,11 @@ static int dtt200u_usb_probe(struct usb_
 }
 
 static struct usb_device_id dtt200u_usb_table [] = {
-//		{ USB_DEVICE(0x04b4,0x8613) },
-	    { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) },
-	    { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) },
-		{ USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD)  },
-		{ USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM)  },
-	    { 0 },
+	{ USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) },
+	{ USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) },
+	{ USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD)  },
+	{ USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM)  },
+	{ 0 },
 };
 MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
 
@@ -189,7 +188,7 @@ static struct dvb_usb_properties wt220u_
 
 	.num_device_descs = 1,
 	.devices = {
-		{ .name = "WideView WT-220U PenType Receiver (and clones)",
+		{ .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
 		  .cold_ids = { &dtt200u_usb_table[2], NULL },
 		  .warm_ids = { &dtt200u_usb_table[3], NULL },
 		},
@@ -201,9 +200,9 @@ static struct dvb_usb_properties wt220u_
 static struct usb_driver dtt200u_usb_driver = {
 	.owner		= THIS_MODULE,
 	.name		= "dvb_usb_dtt200u",
-	.probe 		= dtt200u_usb_probe,
+	.probe		= dtt200u_usb_probe,
 	.disconnect = dvb_usb_device_exit,
-	.id_table 	= dtt200u_usb_table,
+	.id_table	= dtt200u_usb_table,
 };
 
 /* module stuff */

--

#62 lore raw

PATCH 54/54 ttusb-budget: use time_after_eq()

In reply to Johannes Stezenbach

From: Marcelo Feitoza Parisi <[email protected]>

Use of the time_after_eq() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read.

 drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +4 -2
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/time.h>
 #include <linux/errno.h>
+#include <linux/jiffies.h>
 #include <asm/semaphore.h>
 
 #include "dvb_frontend.h"
@@ -570,7 +571,8 @@ static void ttusb_handle_sec_data(struct
 				  const u8 * data, int len);
 #endif
 
-static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid;
+static int numpkt = 0, numts, numstuff, numsec, numinvalid;
+static unsigned long lastj;
 
 static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
 			   int len)
@@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *ur
 			u8 *data;
 			int len;
 			numpkt++;
-			if ((jiffies - lastj) >= HZ) {
+			if (time_after_eq(jiffies, lastj + HZ)) {
 #if DEBUG > 2
 				printk
 				    ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n",

--

#28 lore raw

PATCH 25/54 usb: removed empty module_init/exit calls

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Removed empty module_init/exit calls.

 drivers/media/dvb/dvb-usb/dvb-usb-init.c |   13 -------------
 1 file changed, 13 deletions(-)
drivers/media/dvb/dvb-usb/dvb-usb-init.c +0 -13
@@ -196,19 +196,6 @@ void dvb_usb_device_exit(struct usb_inte
 }
 EXPORT_SYMBOL(dvb_usb_device_exit);
 
-/* module stuff */
-static int __init dvb_usb_module_init(void)
-{
-	return 0;
-}
-
-static void __exit dvb_usb_module_exit(void)
-{
-}
-
-module_init (dvb_usb_module_init);
-module_exit (dvb_usb_module_exit);
-
 MODULE_VERSION("0.3");
 MODULE_AUTHOR("Patrick Boettcher <[email protected]>");
 MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices");

--

#35 lore raw

PATCH 32/54 remove noisy debug print

In reply to Johannes Stezenbach

comment out noisy dprintk in dst_get_signal()
(why are errors only visible with debug on?
this needs to be cleaned up so we can disable debug by default)

 drivers/media/dvb/bt8xx/dst.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb/bt8xx/dst.c +1 -1
@@ -928,7 +928,7 @@ static int dst_get_signal(struct dst_sta
 {
 	int retval;
 	u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
-	dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__);
+	//dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__);
 	if ((state->diseq_flags & ATTEMPT_TUNE) == 0) {
 		state->decode_lock = state->decode_strength = state->decode_snr = 0;
 		return 0;

--

#17 lore raw

PATCH 15/54 frontend: stv0299: support reading both BER and UCBLOCKS

In reply to Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Allow the stv0299 to read the BER and UCBLOCKS.

 drivers/media/dvb/frontends/stv0299.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/media/dvb/frontends/stv0299.c +5 -8
@@ -63,12 +63,8 @@ struct stv0299_state {
 	u32 tuner_frequency;
 	u32 symbol_rate;
 	fe_code_rate_t fec_inner;
-	int errmode;
 };
 
-#define STATUS_BER 0
-#define STATUS_UCBLOCKS 1
-
 static int debug;
 static int debug_legacy_dish_switch;
 #define dprintk(args...) \
@@ -520,7 +516,8 @@ static int stv0299_read_ber(struct dvb_f
 {
         struct stv0299_state* state = fe->demodulator_priv;
 
-	if (state->errmode != STATUS_BER) return 0;
+	stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x10);
+	msleep(100);
 	*ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
 
 	return 0;
@@ -559,8 +556,9 @@ static int stv0299_read_ucblocks(struct 
 {
         struct stv0299_state* state = fe->demodulator_priv;
 
-	if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0;
-	else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
+	stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x30);
+	msleep(100);
+	*ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
 
 	return 0;
 }
@@ -709,7 +707,6 @@ struct dvb_frontend* stv0299_attach(cons
 	state->tuner_frequency = 0;
 	state->symbol_rate = 0;
 	state->fec_inner = 0;
-	state->errmode = STATUS_BER;
 
 	/* check if the demod is there */
 	stv0299_writeregI(state, 0x02, 0x34); /* standby off */

--

#20 lore raw

PATCH 18/54 frontend: cx24110: DiSEqC fix

In reply to Johannes Stezenbach

Fix DiSEqC switching (one bug fix suggested by Peter Hettkamp, and one experimentally determined msleep(30) suggested by Adam Szalkowski).

 drivers/media/dvb/frontends/cx24110.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/dvb/frontends/cx24110.c +3 -2
@@ -398,7 +398,7 @@ static int cx24110_diseqc_send_burst(str
 		return -EINVAL;
 
 	rv = cx24110_readreg(state, 0x77);
-	cx24110_writereg(state, 0x77, rv|0x04);
+	cx24110_writereg(state, 0x77, rv | 0x04);
 
 	rv = cx24110_readreg(state, 0x76);
 	cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit));
@@ -418,7 +418,8 @@ static int cx24110_send_diseqc_msg(struc
 		cx24110_writereg(state, 0x79 + i, cmd->msg[i]);
 
 	rv = cx24110_readreg(state, 0x77);
-	cx24110_writereg(state, 0x77, rv|0x04);
+	cx24110_writereg(state, 0x77, rv & ~0x04);
+	msleep(30); /* reportedly fixes switching problems */
 
 	rv = cx24110_readreg(state, 0x76);
 

--

#60 lore raw

PATCH 52/54 ttpci: add PCI ids for old Siemens/TT DVB-C card

In reply to Johannes Stezenbach

From: Karl Herz <[email protected]>

Add PCI-ids of Siemens-DVB-C card with Technotrend manufacturer id.

 drivers/media/dvb/ttpci/av7110.c |   26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/media/dvb/ttpci/av7110.c +14 -12
@@ -168,7 +168,9 @@ static void init_av7110_av(struct av7110
 		if (ret < 0)
 			printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret);
 		if (rgb_on &&
-		    (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) {
+		    ((av7110->dev->pci->subsystem_vendor == 0x110a) || 
+		     (av7110->dev->pci->subsystem_vendor == 0x13c2)) && 
+		     (av7110->dev->pci->subsystem_device == 0x0000)) {
 			saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
 			//saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
 		}
@@ -2868,7 +2870,7 @@ static struct saa7146_pci_extension_data
 	.ext_priv = x_name, \
 	.ext = &av7110_extension }
 
-MAKE_AV7110_INFO(tts_1_X,    "Technotrend/Hauppauge WinTV DVB-S rev1.X");
+MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C");
 MAKE_AV7110_INFO(ttt_1_X,    "Technotrend/Hauppauge WinTV DVB-T rev1.X");
 MAKE_AV7110_INFO(ttc_1_X,    "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
 MAKE_AV7110_INFO(ttc_2_X,    "Technotrend/Hauppauge WinTV DVB-C rev2.X");
@@ -2880,16 +2882,16 @@ MAKE_AV7110_INFO(fsc,        "Fujitsu Si
 MAKE_AV7110_INFO(fss,        "Fujitsu Siemens DVB-S rev1.6");
 
 static struct pci_device_id pci_tbl[] = {
-	MAKE_EXTENSION_PCI(fsc,       0x110a, 0x0000),
-	MAKE_EXTENSION_PCI(tts_1_X,   0x13c2, 0x0000),
-	MAKE_EXTENSION_PCI(ttt_1_X,   0x13c2, 0x0001),
-	MAKE_EXTENSION_PCI(ttc_2_X,   0x13c2, 0x0002),
-	MAKE_EXTENSION_PCI(tts_2_X,   0x13c2, 0x0003),
-	MAKE_EXTENSION_PCI(fss,       0x13c2, 0x0006),
-	MAKE_EXTENSION_PCI(ttt,       0x13c2, 0x0008),
-	MAKE_EXTENSION_PCI(ttc_1_X,   0x13c2, 0x000a),
-	MAKE_EXTENSION_PCI(tts_2_3,   0x13c2, 0x000e),
-	MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
+	MAKE_EXTENSION_PCI(fsc,         0x110a, 0x0000),
+	MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000),
+	MAKE_EXTENSION_PCI(ttt_1_X,     0x13c2, 0x0001),
+	MAKE_EXTENSION_PCI(ttc_2_X,     0x13c2, 0x0002),
+	MAKE_EXTENSION_PCI(tts_2_X,     0x13c2, 0x0003),
+	MAKE_EXTENSION_PCI(fss,         0x13c2, 0x0006),
+	MAKE_EXTENSION_PCI(ttt,         0x13c2, 0x0008),
+	MAKE_EXTENSION_PCI(ttc_1_X,     0x13c2, 0x000a),
+	MAKE_EXTENSION_PCI(tts_2_3,     0x13c2, 0x000e),
+	MAKE_EXTENSION_PCI(tts_1_3se,   0x13c2, 0x1002),
 
 /*	MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte
 /*	MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1

--

#61 lore raw

PATCH 53/54 saa7146: i2c vs. sysfs fix

In reply to Johannes Stezenbach

From: Philipp Matthias Hahn <[email protected]>

Integrate saa7146_i2c adapter into device model:
Moves entries from /sys/device/platform to /sys/device/pci*.

 drivers/media/common/saa7146_i2c.c |    1 +
 1 file changed, 1 insertion(+)
drivers/media/common/saa7146_i2c.c +1 -0
@@ -405,6 +405,7 @@ int saa7146_i2c_adapter_prepare(struct s
 	if( NULL != i2c_adapter ) {
 		BUG_ON(!i2c_adapter->class);
 		i2c_set_adapdata(i2c_adapter,dev);
+		i2c_adapter->dev.parent    = &dev->pci->dev;
 		i2c_adapter->algo	   = &saa7146_algo;
 		i2c_adapter->algo_data     = NULL;
 		i2c_adapter->id		   = I2C_ALGO_SAA7146;

--

#11 lore raw

PATCH 11/54 core: CI timeout fix

In reply to Johannes Stezenbach

From: Dominique Dumont <[email protected]>

Patch from Dominique Dumont to get the SCM Red Viaccess CAM working with the budget-ci.

 drivers/media/dvb/dvb-core/dvb_ca_en50221.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb/dvb-core/dvb_ca_en50221.c +1 -1
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(cam_debug, "enable verb
 
 #define dprintk if (dvb_ca_en50221_debug) printk
 
-#define INIT_TIMEOUT_SECS 5
+#define INIT_TIMEOUT_SECS 10
 
 #define HOST_LINK_BUF_SIZE 0x200
 

--

#51 lore raw

PATCH 48/54 budget-av: enable frontend on KNC1 Plus cards

In reply to Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Enable frontend on KNC plus cards.

 drivers/media/dvb/ttpci/budget-av.c |    1 +
 1 file changed, 1 insertion(+)
drivers/media/dvb/ttpci/budget-av.c +1 -0
@@ -743,6 +743,7 @@ static void frontend_init(struct budget_
 		case SUBID_DVBC_KNC1_PLUS:
 		case SUBID_DVBT_KNC1_PLUS:
 			// Enable / PowerON Frontend
+			saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
 			saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
 			break;
 	}

--

#32 lore raw

PATCH 29/54 usb: digitv: support for nxt6000 demod

In reply to Johannes Stezenbach

From: Svante Olofsson <[email protected]>

Add support for the NXT6000-based digitv-box.
Add .get_tune_settings callback for the NXT6000 to have a min_tune_delay of 500ms.

 drivers/media/dvb/dvb-usb/digitv.c    |   40 ++++++++++++++++++++--------------
 drivers/media/dvb/frontends/nxt6000.c |    9 +++++++
 2 files changed, 33 insertions(+), 16 deletions(-)
drivers/media/dvb/dvb-usb/digitv.c +24 -16
@@ -113,31 +113,28 @@ static int digitv_mt352_demod_init(struc
 }
 
 static struct mt352_config digitv_mt352_config = {
-	.demod_address = 0x0, /* ignored by the digitv anyway */
 	.demod_init = digitv_mt352_demod_init,
 	.pll_set = dvb_usb_pll_set,
 };
 
-static struct nxt6000_config digitv_nxt6000_config = {
-	.demod_address = 0x0, /* ignored by the digitv anyway */
-	.clock_inversion = 0x0,
+static int digitv_nxt6000_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
+{
+	struct dvb_usb_device *d = fe->dvb->priv;
+	u8 b[5];
+	dvb_usb_pll_set(fe,fep,b);
+	return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0);
+}
 
-	.pll_init = NULL,
-	.pll_set = NULL,
+static struct nxt6000_config digitv_nxt6000_config = {
+	.clock_inversion = 1,
+	.pll_set = digitv_nxt6000_pll_set,
 };
 
 static int digitv_frontend_attach(struct dvb_usb_device *d)
 {
-	if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL)
+	if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL ||
+		(d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL)
 		return 0;
-	if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) {
-
-		warn("nxt6000 support is not done yet, in fact you are one of the first "
-				"person who wants to use this device in Linux. Please report to "
-				"[email protected]");
-
-		return 0;
-	}
 	return -EIO;
 }
 
@@ -175,7 +172,18 @@ static struct dvb_usb_properties digitv_
 static int digitv_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,NULL);
+	struct dvb_usb_device *d;
+	int ret;
+	if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) {
+		u8 b[4] = { 0 };
+
+		b[0] = 1;
+		digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0);
+
+		b[0] = 0;
+		digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0);
+	}
+	return ret;
 }
 
 static struct usb_device_id digitv_table [] = {
drivers/media/dvb/frontends/nxt6000.c +9 -0
@@ -482,6 +482,7 @@ static int nxt6000_set_frontend(struct d
 	if ((result = nxt6000_set_inversion(state, param->inversion)) < 0)
 		return result;
 
+	msleep(500);
 	return 0;
 }
 
@@ -525,6 +526,12 @@ static int nxt6000_read_signal_strength(
 	return 0;
 }
 
+static int nxt6000_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
+{
+	tune->min_delay_ms = 500;
+	return 0;
+}
+
 static struct dvb_frontend_ops nxt6000_ops;
 
 struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
@@ -577,6 +584,8 @@ static struct dvb_frontend_ops nxt6000_o
 	.release = nxt6000_release,
 
 	.init = nxt6000_init,
+	
+	.get_tune_settings = nxt6000_fe_get_tune_settings,
 
 	.set_frontend = nxt6000_set_frontend,
 

--

#53 lore raw

PATCH 50/54 av7110: conditionally disable workaround for broken firmware

In reply to Johannes Stezenbach

From: Oliver Endriss <[email protected]>

Disable COM_IF_LOCK workaround for firmware > 0x261f.

 drivers/media/dvb/ttpci/av7110_hw.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/dvb/ttpci/av7110_hw.c +4 -2
@@ -366,7 +366,8 @@ static int __av7110_send_fw_cmd(struct a
 		msleep(1);
 	}
 
-	wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);
+	if (FW_VERSION(av7110->arm_app) <= 0x261f)
+		wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);
 
 #ifndef _NOHANDSHAKE
 	start = jiffies;
@@ -439,7 +440,8 @@ static int __av7110_send_fw_cmd(struct a
 
 	wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2);
 
-	wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2);
+	if (FW_VERSION(av7110->arm_app) <= 0x261f)
+		wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2);
 
 #ifdef COM_DEBUG
 	start = jiffies;

--

#46 lore raw

PATCH 43/54 dst: Updated Documentation

In reply to Johannes Stezenbach

From: Manu Abraham <[email protected]>

Updated Documentation

 Documentation/dvb/bt8xx.txt |   95 ++++++++++++++++++++++++++------------------
 1 file changed, 57 insertions(+), 38 deletions(-)
Documentation/dvb/bt8xx.txt +57 -38
@@ -1,55 +1,74 @@
-How to get the Nebula Electronics DigiTV, Pinnacle PCTV Sat, Twinhan DST + clones working
-=========================================================================================
+How to get the Nebula, PCTV and Twinhan DST cards working
+=========================================================
 
-1) General information
-======================
+This class of cards has a bt878a as the PCI interface, and
+require the bttv driver.
 
-This class of cards has a bt878a chip as the PCI interface.
-The different card drivers require the bttv driver to provide the means
-to access the i2c bus and the gpio pins of the bt8xx chipset.
+Please pay close attention to the warning about the bttv module
+options below for the DST card.
 
-2) Compilation rules for Kernel >= 2.6.12
-=========================================
+1) General informations
+=======================
 
-Enable the following options:
+These drivers require the bttv driver to provide the means to access
+the i2c bus and the gpio pins of the bt8xx chipset.
 
+Because of this, you need to enable
 "Device drivers" => "Multimedia devices"
- => "Video For Linux" => "BT848 Video For Linux"
+  => "Video For Linux" => "BT848 Video For Linux"
+
+Furthermore you need to enable
 "Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices"
- => "DVB for Linux" "DVB Core Support" "BT8xx based PCI cards"
+  => "DVB for Linux" "DVB Core Support" "BT8xx based PCI cards"
 
-3) Loading Modules, described by two approaches
-===============================================
+2) Loading Modules
+==================
 
 In general you need to load the bttv driver, which will handle the gpio and
-i2c communication for us, plus the common dvb-bt8xx device driver,
-which is called the backend.
-The frontends for Nebula DigiTV (nxt6000), Pinnacle PCTV Sat (cx24110),
-TwinHan DST + clones (dst and dst-ca) are loaded automatically by the backend.
-For further details about TwinHan DST + clones see /Documentation/dvb/ci.txt.
-
-3a) The manual approach
------------------------
-
-Loading modules:
-modprobe bttv
-modprobe dvb-bt8xx
-
-Unloading modules:
-modprobe -r dvb-bt8xx
-modprobe -r bttv
+i2c communication for us, plus the common dvb-bt8xx device driver.
+The frontends for Nebula (nxt6000), Pinnacle PCTV (cx24110) and
+TwinHan (dst) are loaded automatically by the dvb-bt8xx device driver.
+
+3a) Nebula / Pinnacle PCTV
+--------------------------
 
-3b) The automatic approach
+   $ modprobe bttv (normally bttv is being loaded automatically by kmod)
+   $ modprobe dvb-bt8xx (or just place dvb-bt8xx in /etc/modules for automatic loading)
+
+
+3b) TwinHan and Clones
 --------------------------
 
-If not already done by installation, place a line either in
-/etc/modules.conf or in /etc/modprobe.conf containing this text:
-alias char-major-81	bttv
+   $ modprobe bttv i2c_hw=1 card=0x71
+   $ modprobe dvb-bt8xx
+   $ modprobe dst
+
+The value 0x71 will override the PCI type detection for dvb-bt8xx,
+which  is necessary for TwinHan cards.
+
+If you're having an older card (blue color circuit) and card=0x71 locks
+your machine, try using 0x68, too. If that does not work, ask on the
+mailing list.
+
+The DST module takes a couple of useful parameters.
+
+verbose takes values 0 to 4. These values control the verbosity level,
+and can be used to debug also.
+
+verbose=0 means complete disabling of messages
+	1 only error messages are displayed
+	2 notifications are also displayed
+	3 informational messages are also displayed
+	4 debug setting
+
+dst_addons takes values 0 and 0x20. A value of 0 means it is a FTA card.
+0x20 means it has a Conditional Access slot.
+
+The autodected values are determined bythe cards 'response
+string' which you can see in your logs e.g.
 
-Then place a line in /etc/modules containing this text:
-dvb-bt8xx
+dst_get_device_id: Recognise [DSTMCI]
 
-Reboot your system and have fun!
 
 --
-Authors: Richard Walker, Jamie Honan, Michael Hunold, Manu Abraham, Uwe Bugla
+Authors: Richard Walker, Jamie Honan, Michael Hunold, Manu Abraham

--

#19 lore raw

PATCH 17/54 frontend: ves1820: improve tuning

In reply to Johannes Stezenbach

Reset acgconf register after tuning to improve locking, as suggested by Marco Schluessler.
Minor cleanups in ves1820_init().

 drivers/media/dvb/frontends/ves1820.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/media/dvb/frontends/ves1820.c +7 -8
@@ -194,19 +194,18 @@ static int ves1820_init(struct dvb_front
 {
 	struct ves1820_state* state = fe->demodulator_priv;
 	int i;
-	int val;
 
 	ves1820_writereg(state, 0, 0);
 
-	for (i = 0; i < 53; i++) {
-		val = ves1820_inittab[i];
-		if ((i == 2) && (state->config->selagc)) val |= 0x08;
-		ves1820_writereg(state, i, val);
-	}
+	for (i = 0; i < sizeof(ves1820_inittab); i++)
+		ves1820_writereg(state, i, ves1820_inittab[i]);
+	if (state->config->selagc)
+		ves1820_writereg(state, 2, ves1820_inittab[2] | 0x08);
 
 	ves1820_writereg(state, 0x34, state->pwm);
 
-	if (state->config->pll_init) state->config->pll_init(fe);
+	if (state->config->pll_init)
+		state->config->pll_init(fe);
 
 	return 0;
 }
@@ -234,7 +233,7 @@ static int ves1820_set_parameters(struct
 	ves1820_writereg(state, 0x09, reg0x09[real_qam]);
 
 	ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion);
-
+	ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0));
 	return 0;
 }
 

--

#12 lore raw

PATCH 12/54 frontend: mt352: fix signal strength reading

In reply to Johannes Stezenbach

From: Barry Scott <[email protected]>

Fix two problems with the signal strength value in the mt352.c frontend:
1. the 4 most significant bits are zeroed - shift and mask wrong way round
2. need to align the 12 bits from the registers at the top of the 16 bit returned value - otherwise the range is not 0 to 0xffff its 0xf000 to 0xffff

 drivers/media/dvb/frontends/mt352.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/dvb/frontends/mt352.c +4 -2
@@ -462,9 +462,11 @@ static int mt352_read_signal_strength(st
 {
 	struct mt352_state* state = fe->demodulator_priv;
 
-	u16 signal = ((mt352_read_register(state, AGC_GAIN_1) << 8) & 0x0f) |
-		      (mt352_read_register(state, AGC_GAIN_0));
+	/* align the 12 bit AGC gain with the most significant bits */
+	u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) |
+		(mt352_read_register(state, AGC_GAIN_0) << 4);
 
+	/* inverse of gain is signal strength */
 	*strength = ~signal;
 	return 0;
 }

--

#50 lore raw

PATCH 47/54 budget-av: fixes for CI interface

In reply to Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Fixes for CI interface.

 drivers/media/dvb/ttpci/budget-av.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/dvb/ttpci/budget-av.c +1 -3
@@ -192,7 +192,7 @@ static int ciintf_slot_reset(struct dvb_
 {
 	struct budget_av *budget_av = (struct budget_av *) ca->data;
 	struct saa7146_dev *saa = budget_av->budget.dev;
-	int timeout = 50; // 5 seconds (4.4.6 Ready)
+	int timeout = 500; // 5 seconds (4.4.6 Ready)
 
 	if (slot != 0)
 		return -EINVAL;
@@ -217,7 +217,6 @@ static int ciintf_slot_reset(struct dvb_
 	{
 		printk(KERN_ERR "budget-av: cam reset failed (timeout).\n");
 		saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
-		saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
 		return -ETIMEDOUT;
 	}
 
@@ -276,7 +275,6 @@ static int ciintf_poll_slot_status(struc
 		{
 			printk(KERN_INFO "budget-av: cam ejected\n");
 			saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
-			saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
 			budget_av->slot_status = 0;
 		}
 	}

--

#6 lore raw

PATCH 6/54 core: dvb_demux: remove unused cruft

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Removed some useless functions and variables.

 drivers/media/dvb/dvb-core/demux.h     |   13 -----------
 drivers/media/dvb/dvb-core/dvb_demux.c |   39 +--------------------------------
 drivers/media/dvb/dvb-core/dvb_demux.h |    2 -
 3 files changed, 3 insertions(+), 51 deletions(-)
drivers/media/dvb/dvb-core/demux.h +0 -13
@@ -245,7 +245,6 @@ struct dmx_frontend {
 struct dmx_demux {
         u32 capabilities;            /* Bitfield of capability flags */
         struct dmx_frontend* frontend;    /* Front-end connected to the demux */
-        struct list_head reg_list;   /* List of registered demuxes */
         void* priv;                  /* Pointer to private data of the API client */
         int users;                   /* Number of users */
         int (*open) (struct dmx_demux* demux);
@@ -291,16 +290,4 @@ struct dmx_demux {
 			u64 *stc, unsigned int *base);
 };
 
-/*--------------------------------------------------------------------------*/
-/* Demux directory */
-/*--------------------------------------------------------------------------*/
-
-/*
- * DMX_DIR_ENTRY(): Casts elements in the list of registered
- * demuxes from the generic type struct list_head* to the type struct dmx_demux
- *.
- */
-
-#define DMX_DIR_ENTRY(list) list_entry(list, struct dmx_demux, reg_list)
-
 #endif /* #ifndef __DEMUX_H */
drivers/media/dvb/dvb-core/dvb_demux.c +2 -37
@@ -39,33 +39,6 @@
 // #define DVB_DEMUX_SECTION_LOSS_LOG
 
 
-static LIST_HEAD(dmx_muxs);
-
-
-static int dmx_register_demux(struct dmx_demux *demux)
-{
-	demux->users = 0;
-	list_add(&demux->reg_list, &dmx_muxs);
-	return 0;
-}
-
-static int dmx_unregister_demux(struct dmx_demux* demux)
-{
-	struct list_head *pos, *n, *head=&dmx_muxs;
-
-	list_for_each_safe (pos, n, head) {
-		if (DMX_DIR_ENTRY(pos) == demux) {
-			if (demux->users>0)
-				return -EINVAL;
-			list_del(pos);
-			return 0;
-		}
-	}
-
-	return -ENODEV;
-}
-
-
 /******************************************************************************
  * static inlined helper functions
  ******************************************************************************/
@@ -1207,7 +1180,7 @@ static int dvbdmx_get_pes_pids(struct dm
 
 int dvb_dmx_init(struct dvb_demux *dvbdemux)
 {
-	int i, err;
+	int i;
 	struct dmx_demux *dmx = &dvbdemux->dmx;
 
 	dvbdemux->users = 0;
@@ -1250,7 +1223,6 @@ int dvb_dmx_init(struct dvb_demux *dvbde
 		 dvbdemux->memcopy = dvb_dmx_memcopy;
 
 	dmx->frontend = NULL;
-	dmx->reg_list.prev = dmx->reg_list.next = &dmx->reg_list;
 	dmx->priv = (void *) dvbdemux;
 	dmx->open = dvbdmx_open;
 	dmx->close = dvbdmx_close;
@@ -1273,21 +1245,14 @@ int dvb_dmx_init(struct dvb_demux *dvbde
 	sema_init(&dvbdemux->mutex, 1);
 	spin_lock_init(&dvbdemux->lock);
 
-	if ((err = dmx_register_demux(dmx)) < 0)
-		return err;
-
 	return 0;
 }
 EXPORT_SYMBOL(dvb_dmx_init);
 
 
-int dvb_dmx_release(struct dvb_demux *dvbdemux)
+void dvb_dmx_release(struct dvb_demux *dvbdemux)
 {
-	struct dmx_demux *dmx = &dvbdemux->dmx;
-
-	dmx_unregister_demux(dmx);
 	vfree(dvbdemux->filter);
 	vfree(dvbdemux->feed);
-	return 0;
 }
 EXPORT_SYMBOL(dvb_dmx_release);
drivers/media/dvb/dvb-core/dvb_demux.h +1 -1
@@ -138,7 +138,7 @@ struct dvb_demux {
 
 
 int dvb_dmx_init(struct dvb_demux *dvbdemux);
-int dvb_dmx_release(struct dvb_demux *dvbdemux);
+void dvb_dmx_release(struct dvb_demux *dvbdemux);
 void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count);
 void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count);
 void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count);

--

#9 lore raw

PATCH 9/54 core: dvb_demux: use INIT_LIST_HEAD

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Use INIT_LIST_HEAD for frontend_list.

 drivers/media/dvb/dvb-core/dvb_demux.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/dvb/dvb-core/dvb_demux.c +3 -3
@@ -1188,9 +1188,9 @@ int dvb_dmx_init(struct dvb_demux *dvbde
 		dvbdemux->feed[i].state = DMX_STATE_FREE;
 		dvbdemux->feed[i].index = i;
 	}
-	dvbdemux->frontend_list.next=
-	  dvbdemux->frontend_list.prev=
-	    &dvbdemux->frontend_list;
+
+	INIT_LIST_HEAD(&dvbdemux->frontend_list);
+
 	for (i=0; i<DMX_TS_PES_OTHER; i++) {
 		dvbdemux->pesfilter[i] = NULL;
 		dvbdemux->pids[i] = 0xffff;

--

#37 lore raw

PATCH 34/54 bt8xx: cleanup

In reply to Johannes Stezenbach

From: David Johnson <[email protected]>

Indentation fixes and remove unnecessary braces.

 drivers/media/dvb/bt8xx/dvb-bt8xx.c |  229 ++++++++++++++++++------------------
 1 file changed, 116 insertions(+), 113 deletions(-)
drivers/media/dvb/bt8xx/dvb-bt8xx.c +116 -113
@@ -32,9 +32,7 @@
 #include "dvbdev.h"
 #include "dvb_demux.h"
 #include "dvb_frontend.h"
-
 #include "dvb-bt8xx.h"
-
 #include "bt878.h"
 
 static int debug;
@@ -43,9 +41,9 @@ module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
 
 #define dprintk( args... ) \
-	do { \
+	do \
 		if (debug) printk(KERN_DEBUG args); \
-	} while (0)
+	while (0)
 
 static void dvb_bt8xx_task(unsigned long data)
 {
@@ -119,14 +117,12 @@ static struct bt878 __init *dvb_bt8xx_87
 	unsigned int card_nr;
 
 	/* Hmm, n squared. Hope n is small */
-	for (card_nr = 0; card_nr < bt878_num; card_nr++) {
+	for (card_nr = 0; card_nr < bt878_num; card_nr++)
 		if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev))
 			return &bt878[card_nr];
-	}
 	return NULL;
 }
 
-
 static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
 {
 	static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 };
@@ -157,13 +153,19 @@ static int thomson_dtt7579_pll_set(struc
 	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
 	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
 
-	if (params->frequency < 542000000) cp = 0xb4;
-	else if (params->frequency < 771000000) cp = 0xbc;
-	else cp = 0xf4;
-
-	if (params->frequency == 0) bs = 0x03;
-	else if (params->frequency < 443250000) bs = 0x02;
-	else bs = 0x08;
+	if (params->frequency < 542000000)
+		cp = 0xb4;
+	else if (params->frequency < 771000000)
+		cp = 0xbc;
+	else
+		cp = 0xf4;
+
+	if (params->frequency == 0)
+		bs = 0x03;
+	else if (params->frequency < 443250000)
+		bs = 0x02;
+	else
+		bs = 0x08;
 
 	pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
 	pllbuf[1] = div >> 8;
@@ -175,7 +177,6 @@ static int thomson_dtt7579_pll_set(struc
 }
 
 static struct mt352_config thomson_dtt7579_config = {
-
 	.demod_address = 0x0f,
 	.demod_init = thomson_dtt7579_demod_init,
 	.pll_set = thomson_dtt7579_pll_set,
@@ -183,25 +184,26 @@ static struct mt352_config thomson_dtt75
 
 static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
-   u32 freq = params->frequency;
-
-   int i, a, n, pump;
-   u32 band, pll;
+	u32 freq = params->frequency;
 
+	int i, a, n, pump;
+	u32 band, pll;
 
-   u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
-	       1576000,1718000,1856000,2036000,2150000};
-   u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
-	       0x00102000,0x00104000,0x00108000,0x00110000,
-	       0x00120000,0x00140000};
+	u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
+		1576000,1718000,1856000,2036000,2150000};
+	u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
+		0x00102000,0x00104000,0x00108000,0x00110000,
+		0x00120000,0x00140000};
 
-#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
+	#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
 	printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq);
 
 	/* This is really the bit driving the tuner chip cx24108 */
 
-	if(freq<950000) freq=950000; /* kHz */
-	if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */
+	if (freq<950000)
+		freq = 950000; /* kHz */
+	else if (freq>2150000)
+		freq = 2150000; /* satellite IF is 950..2150MHz */
 
 	/* decide which VCO to use for the input frequency */
 	for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++);
@@ -228,25 +230,22 @@ static int cx24108_pll_set(struct dvb_fr
 	cx24110_pll_write(fe,0x500c0000);
 	cx24110_pll_write(fe,0x83f1f800);
 	cx24110_pll_write(fe,pll);
-/*        writereg(client,0x56,0x7f);*/
+	//writereg(client,0x56,0x7f);
 
 	return 0;
 }
 
 static int pinnsat_pll_init(struct dvb_frontend* fe)
 {
-   return 0;
+	return 0;
 }
 
-
 static struct cx24110_config pctvsat_config = {
-
 	.demod_address = 0x55,
 	.pll_init = pinnsat_pll_init,
 	.pll_set = cx24108_pll_set,
 };
 
-
 static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
 	struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
@@ -258,15 +257,23 @@ static int microtune_mt7202dtf_pll_set(s
 	div = (36000000 + params->frequency + 83333) / 166666;
 	cfg = 0x88;
 
-	if (params->frequency < 175000000) cpump = 2;
-	else if (params->frequency < 390000000) cpump = 1;
-	else if (params->frequency < 470000000) cpump = 2;
-	else if (params->frequency < 750000000) cpump = 2;
-	else cpump = 3;
-
-	if (params->frequency < 175000000) band_select = 0x0e;
-	else if (params->frequency < 470000000) band_select = 0x05;
-	else band_select = 0x03;
+	if (params->frequency < 175000000)
+		cpump = 2;
+	else if (params->frequency < 390000000)
+		cpump = 1;
+	else if (params->frequency < 470000000)
+		cpump = 2;
+	else if (params->frequency < 750000000)
+		cpump = 2;
+	else
+		cpump = 3;
+
+	if (params->frequency < 175000000)
+		band_select = 0x0e;
+	else if (params->frequency < 470000000)
+		band_select = 0x05;
+	else
+		band_select = 0x03;
 
 	data[0] = (div >> 8) & 0x7f;
 	data[1] = div & 0xff;
@@ -285,14 +292,11 @@ static int microtune_mt7202dtf_request_f
 }
 
 static struct sp887x_config microtune_mt7202dtf_config = {
-
 	.demod_address = 0x70,
 	.pll_set = microtune_mt7202dtf_pll_set,
 	.request_firmware = microtune_mt7202dtf_request_firmware,
 };
 
-
-
 static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
 {
 	static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
@@ -303,7 +307,6 @@ static int advbt771_samsung_tdtc9251dh0_
 	static u8 mt352_av771_extra[] = { 0xB5, 0x7A };
 	static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
 
-
 	mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
 	udelay(2000);
 	mt352_write(fe, mt352_reset, sizeof(mt352_reset));
@@ -326,25 +329,43 @@ static int advbt771_samsung_tdtc9251dh0_
 	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
 	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
 
-	if (params->frequency < 150000000) cp = 0xB4;
-	else if (params->frequency < 173000000) cp = 0xBC;
-	else if (params->frequency < 250000000) cp = 0xB4;
-	else if (params->frequency < 400000000) cp = 0xBC;
-	else if (params->frequency < 420000000) cp = 0xF4;
-	else if (params->frequency < 470000000) cp = 0xFC;
-	else if (params->frequency < 600000000) cp = 0xBC;
-	else if (params->frequency < 730000000) cp = 0xF4;
-	else cp = 0xFC;
-
-	if (params->frequency < 150000000) bs = 0x01;
-	else if (params->frequency < 173000000) bs = 0x01;
-	else if (params->frequency < 250000000) bs = 0x02;
-	else if (params->frequency < 400000000) bs = 0x02;
-	else if (params->frequency < 420000000) bs = 0x02;
-	else if (params->frequency < 470000000) bs = 0x02;
-	else if (params->frequency < 600000000) bs = 0x08;
-	else if (params->frequency < 730000000) bs = 0x08;
-	else bs = 0x08;
+	if (params->frequency < 150000000)
+		cp = 0xB4;
+	else if (params->frequency < 173000000)
+		cp = 0xBC;
+	else if (params->frequency < 250000000)
+		cp = 0xB4;
+	else if (params->frequency < 400000000)
+		cp = 0xBC;
+	else if (params->frequency < 420000000)
+		cp = 0xF4;
+	else if (params->frequency < 470000000)
+		cp = 0xFC;
+	else if (params->frequency < 600000000)
+		cp = 0xBC;
+	else if (params->frequency < 730000000)
+		cp = 0xF4;
+	else
+		cp = 0xFC;
+
+	if (params->frequency < 150000000)
+		bs = 0x01;
+	else if (params->frequency < 173000000)
+		bs = 0x01;
+	else if (params->frequency < 250000000)
+		bs = 0x02;
+	else if (params->frequency < 400000000)
+		bs = 0x02;
+	else if (params->frequency < 420000000)
+		bs = 0x02;
+	else if (params->frequency < 470000000)
+		bs = 0x02;
+	else if (params->frequency < 600000000)
+		bs = 0x08;
+	else if (params->frequency < 730000000)
+		bs = 0x08;
+	else
+		bs = 0x08;
 
 	pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
 	pllbuf[1] = div >> 8;
@@ -356,19 +377,15 @@ static int advbt771_samsung_tdtc9251dh0_
 }
 
 static struct mt352_config advbt771_samsung_tdtc9251dh0_config = {
-
 	.demod_address = 0x0f,
 	.demod_init = advbt771_samsung_tdtc9251dh0_demod_init,
 	.pll_set = advbt771_samsung_tdtc9251dh0_pll_set,
 };
 
-
 static struct dst_config dst_config = {
-
 	.demod_address = 0x55,
 };
 
-
 static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
 {
 	struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
@@ -398,10 +415,9 @@ static void or51211_reset(struct dvb_fro
 	 */
 	/* reset & PRM1,2&4 are outputs */
 	int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F);
-	if (ret != 0) {
+	if (ret != 0)
 		printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR "
 		       "(%i)\n", ret);
-	}
 	bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000);   /* Reset */
 	msleep(20);
 	/* Now set for normal operation */
@@ -417,7 +433,6 @@ static void or51211_sleep(struct dvb_fro
 }
 
 static struct or51211_config or51211_config = {
-
 	.demod_address = 0x15,
 	.request_firmware = or51211_request_firmware,
 	.setmode = or51211_setmode,
@@ -425,7 +440,6 @@ static struct or51211_config or51211_con
 	.sleep = or51211_sleep,
 };
 
-
 static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
 	struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
@@ -454,13 +468,11 @@ static int vp3021_alps_tded4_pll_set(str
 }
 
 static struct nxt6000_config vp3021_alps_tded4_config = {
-
 	.demod_address = 0x0a,
 	.clock_inversion = 1,
 	.pll_set = vp3021_alps_tded4_pll_set,
 };
 
-
 static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
 {
 	int ret;
@@ -468,7 +480,7 @@ static void frontend_init(struct dvb_bt8
 
 	switch(type) {
 #ifdef BTTV_DVICO_DVBT_LITE
-	case BTTV_DVICO_DVBT_LITE:
+		case BTTV_DVICO_DVBT_LITE:
 		card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);
 		if (card->fe != NULL) {
 			card->fe->ops->info.frequency_min = 174000000;
@@ -479,24 +491,22 @@ static void frontend_init(struct dvb_bt8
 #endif
 
 #ifdef BTTV_TWINHAN_VP3021
-	case BTTV_TWINHAN_VP3021:
+		case BTTV_TWINHAN_VP3021:
 #else
-	case BTTV_NEBULA_DIGITV:
+		case BTTV_NEBULA_DIGITV:
 #endif
 		card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
-		if (card->fe != NULL) {
+		if (card->fe != NULL)
 			break;
-		}
 		break;
 
-	case BTTV_AVDVBT_761:
+		case BTTV_AVDVBT_761:
 		card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
-		if (card->fe != NULL) {
+		if (card->fe != NULL)
 			break;
-		}
 		break;
 
-	case BTTV_AVDVBT_771:
+		case BTTV_AVDVBT_771:
 		card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
 		if (card->fe != NULL) {
 			card->fe->ops->info.frequency_min = 174000000;
@@ -505,7 +515,7 @@ static void frontend_init(struct dvb_bt8
 		}
 		break;
 
-	case BTTV_TWINHAN_DST:
+		case BTTV_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
 		/*	Setup the Card					*/
@@ -522,54 +532,48 @@ static void frontend_init(struct dvb_bt8
 
 		/*	Attach other DST peripherals if any		*/
 		/*	Conditional Access device			*/
-		if (state->dst_hw_cap & DST_TYPE_HAS_CA) {
+		if (state->dst_hw_cap & DST_TYPE_HAS_CA)
 			ret = dst_ca_attach(state, &card->dvb_adapter);
-		}
-		if (card->fe != NULL) {
+
+		if (card->fe != NULL)
 			break;
-		}
 		break;
 
-	case BTTV_PINNACLESAT:
+		case BTTV_PINNACLESAT:
 		card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
-		if (card->fe != NULL) {
+		if (card->fe != NULL)
 			break;
-		}
 		break;
 
-	case BTTV_PC_HDTV:
+		case BTTV_PC_HDTV:
 		card->fe = or51211_attach(&or51211_config, card->i2c_adapter);
-		if (card->fe != NULL) {
+		if (card->fe != NULL)
 			break;
-		}
 		break;
 	}
 
-	if (card->fe == NULL) {
+	if (card->fe == NULL)
 		printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
 		       card->bt->dev->vendor,
 		       card->bt->dev->device,
 		       card->bt->dev->subsystem_vendor,
 		       card->bt->dev->subsystem_device);
-	} else {
+	else
 		if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
 			printk("dvb-bt8xx: Frontend registration failed!\n");
 			if (card->fe->ops->release)
 				card->fe->ops->release(card->fe);
 			card->fe = NULL;
 		}
-	}
 }
 
 static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
 {
 	int result;
 
-	if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name,
-					   THIS_MODULE)) < 0) {
+	if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) {
 		printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result);
 		return result;
-
 	}
 	card->dvb_adapter.priv = card;
 
@@ -664,9 +668,8 @@ static int dvb_bt8xx_probe(struct device
 	strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
 	card->i2c_adapter = &sub->core->i2c_adap;
 
-	switch(sub->core->type)
-	{
-	case BTTV_PINNACLESAT:
+	switch(sub->core->type) {
+		case BTTV_PINNACLESAT:
 		card->gpio_mode = 0x0400c060;
 		/* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
 			      BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
@@ -675,7 +678,7 @@ static int dvb_bt8xx_probe(struct device
 		break;
 
 #ifdef BTTV_DVICO_DVBT_LITE
-	case BTTV_DVICO_DVBT_LITE:
+		case BTTV_DVICO_DVBT_LITE:
 #endif
 		card->gpio_mode = 0x0400C060;
 		card->op_sync_orin = 0;
@@ -686,25 +689,25 @@ static int dvb_bt8xx_probe(struct device
 		break;
 
 #ifdef BTTV_TWINHAN_VP3021
-	case BTTV_TWINHAN_VP3021:
+		case BTTV_TWINHAN_VP3021:
 #else
-	case BTTV_NEBULA_DIGITV:
+		case BTTV_NEBULA_DIGITV:
 #endif
-	case BTTV_AVDVBT_761:
+		case BTTV_AVDVBT_761:
 		card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
 		card->op_sync_orin = 0;
 		card->irq_err_ignore = 0;
 		/* A_PWRDN DA_SBR DA_APP (high speed serial) */
 		break;
 
-	case BTTV_AVDVBT_771: //case 0x07711461:
+		case BTTV_AVDVBT_771: //case 0x07711461:
 		card->gpio_mode = 0x0400402B;
 		card->op_sync_orin = BT878_RISC_SYNC_MASK;
 		card->irq_err_ignore = 0;
 		/* A_PWRDN DA_SBR  DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/
 		break;
 
-	case BTTV_TWINHAN_DST:
+		case BTTV_TWINHAN_DST:
 		card->gpio_mode = 0x2204f2c;
 		card->op_sync_orin = BT878_RISC_SYNC_MASK;
 		card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR |
@@ -722,13 +725,13 @@ static int dvb_bt8xx_probe(struct device
 		 * RISC+FIFO ENABLE */
 		break;
 
-	case BTTV_PC_HDTV:
+		case BTTV_PC_HDTV:
 		card->gpio_mode = 0x0100EC7B;
 		card->op_sync_orin = 0;
 		card->irq_err_ignore = 0;
 		break;
 
-	default:
+		default:
 		printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n",
 				sub->core->type);
 		kfree(card);
@@ -751,7 +754,6 @@ static int dvb_bt8xx_probe(struct device
 
 		kfree(card);
 		return -EFAULT;
-
 	}
 
 	init_MUTEX(&card->bt->gpio_lock);
@@ -779,7 +781,8 @@ static int dvb_bt8xx_remove(struct devic
 	card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
 	dvb_dmxdev_release(&card->dmxdev);
 	dvb_dmx_release(&card->demux);
-	if (card->fe) dvb_unregister_frontend(card->fe);
+	if (card->fe)
+		dvb_unregister_frontend(card->fe);
 	dvb_unregister_adapter(&card->dvb_adapter);
 
 	kfree(card);

--

#38 lore raw

PATCH 35/54 bt8xx: Nebula DigiTV mt352 support

In reply to Johannes Stezenbach

From: David Johnson <[email protected]>

Add support for Nebula DigiTV PCI cards with the MT352 frontend.

 drivers/media/dvb/bt8xx/dvb-bt8xx.c |  141 +++++++++++++++++++++++++++---------
 1 file changed, 108 insertions(+), 33 deletions(-)
drivers/media/dvb/bt8xx/dvb-bt8xx.c +108 -33
@@ -45,6 +45,8 @@ MODULE_PARM_DESC(debug, "Turn on/off deb
 		if (debug) printk(KERN_DEBUG args); \
 	while (0)
 
+#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
+
 static void dvb_bt8xx_task(unsigned long data)
 {
 	struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data;
@@ -150,7 +152,6 @@ static int thomson_dtt7579_pll_set(struc
 	unsigned char bs = 0;
 	unsigned char cp = 0;
 
-	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
 	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
 
 	if (params->frequency < 542000000)
@@ -326,7 +327,6 @@ static int advbt771_samsung_tdtc9251dh0_
 	unsigned char bs = 0;
 	unsigned char cp = 0;
 
-	#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
 	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
 
 	if (params->frequency < 150000000)
@@ -416,8 +416,7 @@ static void or51211_reset(struct dvb_fro
 	/* reset & PRM1,2&4 are outputs */
 	int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F);
 	if (ret != 0)
-		printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR "
-		       "(%i)\n", ret);
+		printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret);
 	bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000);   /* Reset */
 	msleep(20);
 	/* Now set for normal operation */
@@ -473,6 +472,80 @@ static struct nxt6000_config vp3021_alps
 	.pll_set = vp3021_alps_tded4_pll_set,
 };
 
+static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe)
+{
+	static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
+	static u8 mt352_reset [] = { 0x50, 0x80 };
+	static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+	static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 };
+	static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
+
+	mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
+	udelay(2000);
+	mt352_write(fe, mt352_reset, sizeof(mt352_reset));
+	mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
+	mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
+	mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
+
+	return 0;
+}
+
+static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
+{
+	u32 div;
+	struct dvb_ofdm_parameters *op = &params->u.ofdm;
+
+	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
+
+	pllbuf[0] = 0xc2;
+	pllbuf[1] = (div >> 8) & 0x7F;
+	pllbuf[2] = div & 0xFF;
+	pllbuf[3] = 0x85;
+
+	dprintk("frequency %u, div %u\n", params->frequency, div);
+
+	if (params->frequency < 470000000)
+		pllbuf[4] = 0x02;
+	else if (params->frequency > 823000000)
+		pllbuf[4] = 0x88;
+	else
+		pllbuf[4] = 0x08;
+
+	if (op->bandwidth == 8)
+		pllbuf[4] |= 0x04;
+
+	return 0;
+}
+
+static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt)
+{
+	/*
+	 * Reset the frontend, must be called before trying
+	 * to initialise the MT352 or mt352_attach
+	 * will fail.
+	 *
+	 * Presumably not required for the NXT6000 frontend.
+	 *
+	 */
+
+	int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08);
+	if (ret != 0)
+		printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret);
+
+	/* Pulse the reset line */
+	bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
+	bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low  */
+	msleep(100);
+
+	bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
+}
+
+static struct mt352_config digitv_alps_tded4_config = {
+	.demod_address = 0x0a,
+	.demod_init = digitv_alps_tded4_demod_init,
+	.pll_set = digitv_alps_tded4_pll_set,
+};
+
 static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
 {
 	int ret;
@@ -480,42 +553,51 @@ static void frontend_init(struct dvb_bt8
 
 	switch(type) {
 #ifdef BTTV_DVICO_DVBT_LITE
-		case BTTV_DVICO_DVBT_LITE:
+	case BTTV_DVICO_DVBT_LITE:
 		card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);
 		if (card->fe != NULL) {
 			card->fe->ops->info.frequency_min = 174000000;
 			card->fe->ops->info.frequency_max = 862000000;
-			break;
 		}
 		break;
 #endif
 
 #ifdef BTTV_TWINHAN_VP3021
-		case BTTV_TWINHAN_VP3021:
+	case BTTV_TWINHAN_VP3021:
 #else
-		case BTTV_NEBULA_DIGITV:
+	case BTTV_NEBULA_DIGITV:
 #endif
+		/*
+		 * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK);
+		 * this would be a cleaner solution than trying each frontend in turn.
+		 */
+
+		/* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
 		card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
 		if (card->fe != NULL)
-			break;
+			dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
+
+		/* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
+		digitv_alps_tded4_reset(card);
+		card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter);
+
+		if (card->fe != NULL)
+			dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n");
 		break;
 
-		case BTTV_AVDVBT_761:
+	case BTTV_AVDVBT_761:
 		card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
-		if (card->fe != NULL)
-			break;
 		break;
 
-		case BTTV_AVDVBT_771:
+	case BTTV_AVDVBT_771:
 		card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
 		if (card->fe != NULL) {
 			card->fe->ops->info.frequency_min = 174000000;
 			card->fe->ops->info.frequency_max = 862000000;
-			break;
 		}
 		break;
 
-		case BTTV_TWINHAN_DST:
+	case BTTV_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
 		/*	Setup the Card					*/
@@ -534,21 +616,14 @@ static void frontend_init(struct dvb_bt8
 		/*	Conditional Access device			*/
 		if (state->dst_hw_cap & DST_TYPE_HAS_CA)
 			ret = dst_ca_attach(state, &card->dvb_adapter);
-
-		if (card->fe != NULL)
-			break;
 		break;
 
-		case BTTV_PINNACLESAT:
+	case BTTV_PINNACLESAT:
 		card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
-		if (card->fe != NULL)
-			break;
 		break;
 
-		case BTTV_PC_HDTV:
+	case BTTV_PC_HDTV:
 		card->fe = or51211_attach(&or51211_config, card->i2c_adapter);
-		if (card->fe != NULL)
-			break;
 		break;
 	}
 
@@ -669,7 +744,7 @@ static int dvb_bt8xx_probe(struct device
 	card->i2c_adapter = &sub->core->i2c_adap;
 
 	switch(sub->core->type) {
-		case BTTV_PINNACLESAT:
+	case BTTV_PINNACLESAT:
 		card->gpio_mode = 0x0400c060;
 		/* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
 			      BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
@@ -678,7 +753,7 @@ static int dvb_bt8xx_probe(struct device
 		break;
 
 #ifdef BTTV_DVICO_DVBT_LITE
-		case BTTV_DVICO_DVBT_LITE:
+	case BTTV_DVICO_DVBT_LITE:
 #endif
 		card->gpio_mode = 0x0400C060;
 		card->op_sync_orin = 0;
@@ -689,25 +764,25 @@ static int dvb_bt8xx_probe(struct device
 		break;
 
 #ifdef BTTV_TWINHAN_VP3021
-		case BTTV_TWINHAN_VP3021:
+	case BTTV_TWINHAN_VP3021:
 #else
-		case BTTV_NEBULA_DIGITV:
+	case BTTV_NEBULA_DIGITV:
 #endif
-		case BTTV_AVDVBT_761:
+	case BTTV_AVDVBT_761:
 		card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
 		card->op_sync_orin = 0;
 		card->irq_err_ignore = 0;
 		/* A_PWRDN DA_SBR DA_APP (high speed serial) */
 		break;
 
-		case BTTV_AVDVBT_771: //case 0x07711461:
+	case BTTV_AVDVBT_771: //case 0x07711461:
 		card->gpio_mode = 0x0400402B;
 		card->op_sync_orin = BT878_RISC_SYNC_MASK;
 		card->irq_err_ignore = 0;
 		/* A_PWRDN DA_SBR  DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/
 		break;
 
-		case BTTV_TWINHAN_DST:
+	case BTTV_TWINHAN_DST:
 		card->gpio_mode = 0x2204f2c;
 		card->op_sync_orin = BT878_RISC_SYNC_MASK;
 		card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR |
@@ -725,13 +800,13 @@ static int dvb_bt8xx_probe(struct device
 		 * RISC+FIFO ENABLE */
 		break;
 
-		case BTTV_PC_HDTV:
+	case BTTV_PC_HDTV:
 		card->gpio_mode = 0x0100EC7B;
 		card->op_sync_orin = 0;
 		card->irq_err_ignore = 0;
 		break;
 
-		default:
+	default:
 		printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n",
 				sub->core->type);
 		kfree(card);

--

#43 lore raw

PATCH 40/54 dst: identify boards

In reply to Johannes Stezenbach

From: Manu Abraham <[email protected]>

Identify board properly: Add functions to retrieve MAC Address, FW details, Card type and Vendor Information.

 drivers/media/dvb/bt8xx/dst.c        |   89 +++++++++++++++++++++++++++++++++--
 drivers/media/dvb/bt8xx/dst_common.h |    4 +
 2 files changed, 90 insertions(+), 3 deletions(-)
drivers/media/dvb/bt8xx/dst.c +86 -3
@@ -673,7 +673,7 @@ struct dst_types dst_tlist[] = {
 		.offset = 1,
 		.dst_type = DST_TYPE_IS_CABLE,
 		.type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1
-							| DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD,
+							| DST_TYPE_HAS_FW_2,
 		.dst_feature = DST_TYPE_HAS_CA
 	},
 
@@ -681,7 +681,7 @@ struct dst_types dst_tlist[] = {
 		.device_id = "DCTNEW",
 		.offset = 1,
 		.dst_type = DST_TYPE_IS_CABLE,
-		.type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3,
+		.type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD,
 		.dst_feature = 0
 	},
 
@@ -689,7 +689,7 @@ struct dst_types dst_tlist[] = {
 		.device_id = "DTT-CI",
 		.offset = 1,
 		.dst_type = DST_TYPE_IS_TERR,
-		.type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD,
+		.type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2,
 		.dst_feature = 0
 	},
 
@@ -729,6 +729,71 @@ struct dst_types dst_tlist[] = {
 
 };
 
+static int dst_get_mac(struct dst_state *state)
+{
+	u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+	get_mac[7] = dst_check_sum(get_mac, 7);
+	if (dst_command(state, get_mac, 8) < 0) {
+		dprintk(verbose, DST_INFO, 1, "Unsupported Command");
+		return -1;
+	}
+	memset(&state->mac_address, '\0', 8);
+	memcpy(&state->mac_address, &state->rxbuffer, 6);
+	dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]",
+		state->mac_address[0], state->mac_address[1], state->mac_address[2],
+		state->mac_address[4], state->mac_address[5], state->mac_address[6]);
+
+	return 0;
+}
+
+static int dst_fw_ver(struct dst_state *state)
+{
+	u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+	get_ver[7] = dst_check_sum(get_ver, 7);
+	if (dst_command(state, get_ver, 8) < 0) {
+		dprintk(verbose, DST_INFO, 1, "Unsupported Command");
+		return -1;
+	}
+	memset(&state->fw_version, '\0', 8);
+	memcpy(&state->fw_version, &state->rxbuffer, 8);
+	dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x",
+		state->fw_version[0] >> 4, state->fw_version[0] & 0x0f,
+		state->fw_version[1],
+		state->fw_version[5], state->fw_version[6],
+		state->fw_version[4], state->fw_version[3], state->fw_version[2]);
+
+	return 0;
+}
+
+static int dst_card_type(struct dst_state *state)
+{
+	u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+	get_type[7] = dst_check_sum(get_type, 7);
+	if (dst_command(state, get_type, 8) < 0) {
+		dprintk(verbose, DST_INFO, 1, "Unsupported Command");
+		return -1;
+	}
+	memset(&state->card_info, '\0', 8);
+	memcpy(&state->card_info, &state->rxbuffer, 8);
+	dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]);
+
+	return 0;
+}
+
+static int dst_get_vendor(struct dst_state *state)
+{
+	u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+	get_vendor[7] = dst_check_sum(get_vendor, 7);
+	if (dst_command(state, get_vendor, 8) < 0) {
+		dprintk(verbose, DST_INFO, 1, "Unsupported Command");
+		return -1;
+	}
+	memset(&state->vendor, '\0', 8);
+	memcpy(&state->vendor, &state->rxbuffer, 8);
+	dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]);
+
+	return 0;
+}
 
 static int dst_get_device_id(struct dst_state *state)
 {
@@ -816,6 +881,24 @@ static int dst_probe(struct dst_state *s
 		dprintk(verbose, DST_ERROR, 1, "unknown device.");
 		return -1;
 	}
+	if (dst_get_mac(state) < 0) {
+		dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command");
+		return 0;
+	}
+	if (state->type_flags & DST_TYPE_HAS_FW_BUILD) {
+		if (dst_fw_ver(state) < 0) {
+			dprintk(verbose, DST_INFO, 1, "FW: Unsupported command");
+			return 0;
+		}
+		if (dst_card_type(state) < 0) {
+			dprintk(verbose, DST_INFO, 1, "Card: Unsupported command");
+			return 0;
+		}
+		if (dst_get_vendor(state) < 0) {
+			dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command");
+			return 0;
+		}
+	}
 
 	return 0;
 }
drivers/media/dvb/bt8xx/dst_common.h +4 -0
@@ -113,6 +113,10 @@ struct dst_state {
 	fe_sec_mini_cmd_t minicmd;
 	fe_modulation_t modulation;
 	u8 messages[256];
+	u8 mac_address[8];
+	u8 fw_version[8];
+	u8 card_info[8];
+	u8 vendor[8];
 };
 
 struct dst_types {

--

#8 lore raw

PATCH 8/54 core: dvb_demux: remove more unused cruft

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Removed more unused variables and constants.

 drivers/media/dvb/dvb-core/demux.h     |    7 -------
 drivers/media/dvb/dvb-core/dmxdev.c    |    4 ++--
 drivers/media/dvb/dvb-core/dvb_demux.c |   18 ++----------------
 drivers/media/dvb/dvb-core/dvb_demux.h |    7 +------
 drivers/media/dvb/dvb-core/dvb_net.c   |    4 +---
 5 files changed, 6 insertions(+), 34 deletions(-)
drivers/media/dvb/dvb-core/demux.h +0 -7
@@ -125,9 +125,7 @@ struct dmx_ts_feed {
 		    u16 pid,
 		    int type,
 		    enum dmx_ts_pes pes_type,
-		    size_t callback_length,
 		    size_t circular_buffer_size,
-		    int descramble,
 		    struct timespec timeout);
         int (*start_filtering) (struct dmx_ts_feed* feed);
         int (*stop_filtering) (struct dmx_ts_feed* feed);
@@ -160,7 +158,6 @@ struct dmx_section_feed {
         int (*set) (struct dmx_section_feed* feed,
 		    u16 pid,
 		    size_t circular_buffer_size,
-		    int descramble,
 		    int check_crc);
         int (*allocate_filter) (struct dmx_section_feed* feed,
 				struct dmx_section_filter** filter);
@@ -208,7 +205,6 @@ struct dmx_frontend {
         struct list_head connectivity_list; /* List of front-ends that can
 					       be connected to a particular
 					       demux */
-        void* priv;     /* Pointer to private data of the API client */
         enum dmx_frontend_source source;
 };
 
@@ -226,8 +222,6 @@ struct dmx_frontend {
 #define DMX_MEMORY_BASED_FILTERING              8    /* write() available */
 #define DMX_CRC_CHECKING                        16
 #define DMX_TS_DESCRAMBLING                     32
-#define DMX_SECTION_PAYLOAD_DESCRAMBLING        64
-#define DMX_MAC_ADDRESS_DESCRAMBLING            128
 
 /*
  * Demux resource type identifier.
@@ -246,7 +240,6 @@ struct dmx_demux {
         u32 capabilities;            /* Bitfield of capability flags */
         struct dmx_frontend* frontend;    /* Front-end connected to the demux */
         void* priv;                  /* Pointer to private data of the API client */
-        int users;                   /* Number of users */
         int (*open) (struct dmx_demux* demux);
         int (*close) (struct dmx_demux* demux);
         int (*write) (struct dmx_demux* demux, const char* buf, size_t count);
drivers/media/dvb/dvb-core/dmxdev.c +2 -2
@@ -571,7 +571,7 @@ static int dvb_dmxdev_filter_start(struc
 				return ret;
 			}
 
-			ret=(*secfeed)->set(*secfeed, para->pid, 32768, 0,
+			ret=(*secfeed)->set(*secfeed, para->pid, 32768,
 					    (para->flags & DMX_CHECK_CRC) ? 1 : 0);
 
 			if (ret<0) {
@@ -654,7 +654,7 @@ static int dvb_dmxdev_filter_start(struc
 		(*tsfeed)->priv = (void *) filter;
 
 		ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes,
-				     188, 32768, 0, timeout);
+				     32768, timeout);
 
 		if (ret < 0) {
 			dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed);
drivers/media/dvb/dvb-core/dvb_demux.c +2 -16
@@ -577,8 +577,7 @@ out:
 }
 
 static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
-		     enum dmx_ts_pes pes_type, size_t callback_length,
-		     size_t circular_buffer_size, int descramble,
+		     enum dmx_ts_pes pes_type, size_t circular_buffer_size,
 		     struct timespec timeout)
 {
 	struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
@@ -610,17 +609,10 @@ static int dmx_ts_feed_set (struct dmx_t
 
 	feed->pid = pid;
 	feed->buffer_size = circular_buffer_size;
-	feed->descramble = descramble;
 	feed->timeout = timeout;
-	feed->cb_length = callback_length;
 	feed->ts_type = ts_type;
 	feed->pes_type = pes_type;
 
-	if (feed->descramble) {
-		up(&demux->mutex);
-		return -ENOSYS;
-	}
-
 	if (feed->buffer_size) {
 #ifdef NOBUFS
 		feed->buffer=NULL;
@@ -819,7 +811,7 @@ static int dmx_section_feed_allocate_fil
 
 static int dmx_section_feed_set(struct dmx_section_feed* feed,
 			 u16 pid, size_t circular_buffer_size,
-			 int descramble, int check_crc)
+			 int check_crc)
 {
 	struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed;
 	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
@@ -834,12 +826,6 @@ static int dmx_section_feed_set(struct d
 
 	dvbdmxfeed->pid = pid;
 	dvbdmxfeed->buffer_size = circular_buffer_size;
-	dvbdmxfeed->descramble = descramble;
-	if (dvbdmxfeed->descramble) {
-		up(&dvbdmx->mutex);
-		return -ENOSYS;
-	}
-
 	dvbdmxfeed->feed.sec.check_crc = check_crc;
 
 #ifdef NOBUFS
drivers/media/dvb/dvb-core/dvb_demux.h +1 -6
@@ -54,12 +54,9 @@ struct dvb_demux_filter {
         int index;
         int state;
         int type;
-	int pesto;
 
-        u16 handle;
         u16 hw_handle;
         struct timer_list timer;
-	int ts_state;
 };
 
 
@@ -83,11 +80,9 @@ struct dvb_demux_feed {
         u16 pid;
         u8 *buffer;
         int buffer_size;
-        int descramble;
 
         struct timespec timeout;
         struct dvb_demux_filter *filter;
-        int cb_length;
 
         int ts_type;
         enum dmx_ts_pes pes_type;
@@ -98,7 +93,7 @@ struct dvb_demux_feed {
         u16 peslen;
 
 	struct list_head list_head;
-		int index; /* a unique index for each feed (can be used as hardware pid filter index) */
+	unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */
 };
 
 struct dvb_demux {
drivers/media/dvb/dvb-core/dvb_net.c +1 -3
@@ -903,7 +903,7 @@ static int dvb_net_feed_start(struct net
 			return ret;
 		}
 
-		ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 0, 1);
+		ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1);
 
 		if (ret<0) {
 			printk("%s: could not set section feed\n", dev->name);
@@ -955,9 +955,7 @@ static int dvb_net_feed_start(struct net
 		priv->tsfeed->priv = (void *)dev;
 		ret = priv->tsfeed->set(priv->tsfeed, priv->pid,
 					TS_PACKET, DMX_TS_PES_OTHER,
-					188 * 100, /* nr. of bytes delivered per callback */
 					32768,     /* circular buffer size */
-					0,         /* descramble */
 					timeout);
 
 		if (ret < 0) {

--

#7 lore raw

PATCH 7/54 core: dvb_demux: remove unsused descramble callbacks

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Removed unused descramble_mac_address and descramble_section_payload callbacks.

 drivers/media/dvb/dvb-core/demux.h     |   11 -----------
 drivers/media/dvb/dvb-core/dvb_demux.c |    3 ---
 2 files changed, 14 deletions(-)
drivers/media/dvb/dvb-core/demux.h +0 -11
@@ -260,17 +260,6 @@ struct dmx_demux {
 				      dmx_section_cb callback);
         int (*release_section_feed) (struct dmx_demux* demux,
 				     struct dmx_section_feed* feed);
-        int (*descramble_mac_address) (struct dmx_demux* demux,
-				       u8* buffer1,
-				       size_t buffer1_length,
-				       u8* buffer2,
-				       size_t buffer2_length,
-				       u16 pid);
-        int (*descramble_section_payload) (struct dmx_demux* demux,
-					   u8* buffer1,
-					   size_t buffer1_length,
-					   u8* buffer2, size_t buffer2_length,
-					   u16 pid);
         int (*add_frontend) (struct dmx_demux* demux,
 			     struct dmx_frontend* frontend);
         int (*remove_frontend) (struct dmx_demux* demux,
drivers/media/dvb/dvb-core/dvb_demux.c +0 -3
@@ -1232,9 +1232,6 @@ int dvb_dmx_init(struct dvb_demux *dvbde
 	dmx->allocate_section_feed = dvbdmx_allocate_section_feed;
 	dmx->release_section_feed = dvbdmx_release_section_feed;
 
-	dmx->descramble_mac_address = NULL;
-	dmx->descramble_section_payload = NULL;
-
 	dmx->add_frontend = dvbdmx_add_frontend;
 	dmx->remove_frontend = dvbdmx_remove_frontend;
 	dmx->get_frontends = dvbdmx_get_frontends;

--

#40 lore raw

PATCH 37/54 dst: fix symbol rate setting

In reply to Johannes Stezenbach

From: Manu Abraham <[email protected]>

Make the Symbolrate setting card specific.

 drivers/media/dvb/bt8xx/dst.c |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/media/dvb/bt8xx/dst.c +15 -15
@@ -324,12 +324,12 @@ static int dst_set_polarization(struct d
 {
 	switch (state->voltage) {
 		case SEC_VOLTAGE_13:	// vertical
-			printk("%s: Polarization=[Vertical]\n", __FUNCTION__);
+			dprintk("%s: Polarization=[Vertical]\n", __FUNCTION__);
 			state->tx_tuna[8] &= ~0x40;  //1
 			break;
 
 		case SEC_VOLTAGE_18:	// horizontal
-			printk("%s: Polarization=[Horizontal]\n", __FUNCTION__);
+			dprintk("%s: Polarization=[Horizontal]\n", __FUNCTION__);
 			state->tx_tuna[8] |= 0x40;  // 0
 			break;
 
@@ -344,7 +344,7 @@ static int dst_set_polarization(struct d
 static int dst_set_freq(struct dst_state *state, u32 freq)
 {
 	state->frequency = freq;
-	if (debug > 4)
+	if (verbose > 4)
 		dprintk("%s: set Frequency %u\n", __FUNCTION__, freq);
 
 	if (state->dst_type == DST_TYPE_IS_SAT) {
@@ -451,7 +451,6 @@ static fe_code_rate_t dst_get_fec(struct
 
 static int dst_set_symbolrate(struct dst_state* state, u32 srate)
 {
-	u8 *val;
 	u32 symcalc;
 	u64 sval;
 
@@ -463,7 +462,6 @@ static int dst_set_symbolrate(struct dst
 	if (debug > 4)
 		dprintk("%s: set symrate %u\n", __FUNCTION__, srate);
 	srate /= 1000;
-	val = &state->tx_tuna[0];
 
 	if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
 		sval = srate;
@@ -474,17 +472,19 @@ static int dst_set_symbolrate(struct dst
 		if (debug > 4)
 			dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc);
 
-		val[5] = (u8) (symcalc >> 12);
-		val[6] = (u8) (symcalc >> 4);
-		val[7] = (u8) (symcalc << 4);
+		state->tx_tuna[5] = (u8) (symcalc >> 12);
+		state->tx_tuna[6] = (u8) (symcalc >> 4);
+		state->tx_tuna[7] = (u8) (symcalc << 4);
 	} else {
-		val[5] = (u8) (srate >> 16) & 0x7f;
-		val[6] = (u8) (srate >> 8);
-		val[7] = (u8) srate;
-	}
-	val[8] &= ~0x20;
-	if (srate > 8000)
-		val[8] |= 0x20;
+		state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f;
+		state->tx_tuna[6] = (u8) (srate >> 8);
+		state->tx_tuna[7] = (u8) srate;
+	}
+	state->tx_tuna[8] &= ~0x20;
+	if (state->type_flags & DST_TYPE_HAS_OBS_REGS) {
+		if (srate > 8000)
+			state->tx_tuna[8] |= 0x20;
+	}
 	return 0;
 }
 

--

#55 lore raw

Re: [DVB patch 51/54] ttpci: av7110: RC5+ remote control support

In reply to Johannes Stezenbach
Quoted 8 lines · Johannes Stezenbach

From: Oliver Endriss <[email protected]>

Improved remote control support for av7110-based cards:
o extended rc5 protocol, firmware >= 0x2620 required
o key-up timer slightly adjusted
o completely moved remote control code to av7110_ir.c
o support for multiple ir receivers
o for now, all av7110 cards share the same ir configuration and event device

<snip>

drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:31:00.000000000 +0200 line 12

Quoted 10 lines
drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:31:00.000000000 +0200 renamed from drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:03:40.000000000 +0200 +2 -1
@@ -7,16 +7,16 @@
 #include <asm/bitops.h>
 
 #include "av7110.h"
+#include "av7110_hw.h"
 
-#define UP_TIMEOUT (HZ/4)
+#define UP_TIMEOUT (HZ*7/25)

<snip>

Should this be

#define UP_TIMEOUT msecs_to_jiffies(280)

or

#define UP_TIMEOUT (7*msecs_to_jiffies(40)

?

Thanks,
Nish

#45 lore raw

PATCH 42/54 dst: ci doc update

In reply to Johannes Stezenbach

From: Manu Abraham <[email protected]>

Updated documentation

 Documentation/dvb/ci.txt |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
Documentation/dvb/ci.txt +1 -8
@@ -23,7 +23,6 @@ This application requires the following 
 	  eg: $ szap -c channels.conf -r "TMC" -x
 
 	(b) a channels.conf containing a valid PMT PID
-
 	  eg: TMC:11996:h:0:27500:278:512:650:321
 
 	  here 278 is a valid PMT PID. the rest of the values are the
@@ -31,13 +30,7 @@ This application requires the following 
 
 	(c) after running a szap, you have to run ca_zap, for the
 	  descrambler to function,
-
-	  eg: $ ca_zap patched_channels.conf "TMC"
-
-	  The patched means a patch to apply to scan, such that scan can
-	  generate a channels.conf_with pmt, which has this PMT PID info
-	  (NOTE: szap cannot use this channels.conf with the PMT_PID)
-
+	  eg: $ ca_zap channels.conf "TMC"
 
 	(d) Hopeflly Enjoy your favourite subscribed channel as you do with
 	  a FTA card.

--

#31 lore raw

PATCH 28/54 usb: core: change dvb_usb_device_init() API

In reply to Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

Change the init call to optionally return the new dvb_usb_device directly.

 drivers/media/dvb/dvb-usb/a800.c         |    2 +-
 drivers/media/dvb/dvb-usb/cxusb.c        |    2 +-
 drivers/media/dvb/dvb-usb/dibusb-mb.c    |    6 +++---
 drivers/media/dvb/dvb-usb/dibusb-mc.c    |    2 +-
 drivers/media/dvb/dvb-usb/digitv.c       |    2 +-
 drivers/media/dvb/dvb-usb/dtt200u.c      |    4 ++--
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h  |    3 +++
 drivers/media/dvb/dvb-usb/dvb-usb-init.c |    7 ++++++-
 drivers/media/dvb/dvb-usb/dvb-usb.h      |    4 ++--
 drivers/media/dvb/dvb-usb/nova-t-usb2.c  |    2 +-
 drivers/media/dvb/dvb-usb/umt-010.c      |    2 +-
 drivers/media/dvb/dvb-usb/vp702x.c       |    2 +-
 drivers/media/dvb/dvb-usb/vp7045.c       |    2 +-
 13 files changed, 24 insertions(+), 16 deletions(-)
drivers/media/dvb/dvb-usb/a800.c +1 -1
@@ -90,7 +90,7 @@ static struct dvb_usb_properties a800_pr
 static int a800_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE);
+	return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE,NULL);
 }
 
 /* do not change the order of the ID table */
drivers/media/dvb/dvb-usb/dibusb-mb.c +3 -3
@@ -86,9 +86,9 @@ static struct dvb_usb_properties dibusb2
 static int dibusb_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE) == 0 ||
-		dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE) == 0 ||
-		dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE) == 0)
+	if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 ||
+		dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 ||
+		dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0)
 		return 0;
 
 	return -EINVAL;
drivers/media/dvb/dvb-usb/dibusb-mc.c +1 -1
@@ -20,7 +20,7 @@ static struct dvb_usb_properties dibusb_
 static int dibusb_mc_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE);
+	return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE,NULL);
 }
 
 /* do not change the order of the ID table */
drivers/media/dvb/dvb-usb/dtt200u.c +2 -2
@@ -98,8 +98,8 @@ static struct dvb_usb_properties wt220u_
 static int dtt200u_usb_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE) == 0 ||
-		dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE) == 0)
+	if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 ||
+		dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0)
 		return 0;
 
 	return -ENODEV;
drivers/media/dvb/dvb-usb/dvb-usb-ids.h +3 -0
@@ -27,6 +27,7 @@
 #define USB_VID_KWORLD						0xeb2a
 #define USB_VID_KYE							0x0458
 #define USB_VID_MEDION						0x1660
+#define USB_VID_PINNACLE					0x2304
 #define USB_VID_VISIONPLUS					0x13d3
 #define USB_VID_TWINHAN						0x1822
 #define USB_VID_ULTIMA_ELECTRONIC			0x05d8
@@ -88,5 +89,7 @@
 #define USB_PID_MEDION_MD95700				0x0932
 #define USB_PID_KYE_DVB_T_COLD				0x701e
 #define USB_PID_KYE_DVB_T_WARM				0x701f
+#define USB_PID_PCTV_200E					0x020e
+#define USB_PID_PCTV_400E					0x020f
 
 #endif
drivers/media/dvb/dvb-usb/dvb-usb-init.c +6 -1
@@ -128,7 +128,9 @@ static struct dvb_usb_device_description
 /*
  * USB
  */
-int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *props, struct module *owner)
+
+int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
+		*props, struct module *owner,struct dvb_usb_device **du)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct dvb_usb_device *d = NULL;
@@ -170,6 +172,9 @@ int dvb_usb_device_init(struct usb_inter
 
 		usb_set_intfdata(intf, d);
 
+		if (du != NULL)
+			*du = d;
+
 		ret = dvb_usb_init(d);
 	}
 
drivers/media/dvb/dvb-usb/dvb-usb.h +2 -2
@@ -127,7 +127,7 @@ struct dvb_usb_device;
  *  helper functions.
  *
  * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming.
- *  Currently only BULK is implemented
+ *  (BULK or ISOC)
  *
  * @num_device_descs: number of struct dvb_usb_device_description in @devices
  * @devices: array of struct dvb_usb_device_description compatibles with these
@@ -310,7 +310,7 @@ struct dvb_usb_device {
 	void *priv;
 };
 
-extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *);
+extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **);
 extern void dvb_usb_device_exit(struct usb_interface *);
 
 /* the generic read/write method for device control */
drivers/media/dvb/dvb-usb/nova-t-usb2.c +1 -1
@@ -144,7 +144,7 @@ static struct dvb_usb_properties nova_t_
 static int nova_t_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE);
+	return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE,NULL);
 }
 
 /* do not change the order of the ID table */
drivers/media/dvb/dvb-usb/umt-010.c +1 -1
@@ -77,7 +77,7 @@ static struct dvb_usb_properties umt_pro
 static int umt_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE) == 0)
+	if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0)
 		return 0;
 	return -EINVAL;
 }
drivers/media/dvb/dvb-usb/vp702x.c +1 -1
@@ -197,7 +197,7 @@ static int vp702x_usb_probe(struct usb_i
 	usb_clear_halt(udev,usb_sndctrlpipe(udev,0));
 	usb_clear_halt(udev,usb_rcvctrlpipe(udev,0));
 
-	return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE);
+	return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL);
 }
 
 static struct usb_device_id vp702x_usb_table [] = {
drivers/media/dvb/dvb-usb/vp7045.c +1 -1
@@ -199,7 +199,7 @@ static struct dvb_usb_properties vp7045_
 static int vp7045_usb_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE);
+	return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE,NULL);
 }
 
 static struct usb_device_id vp7045_usb_table [] = {
drivers/media/dvb/dvb-usb/cxusb.c +1 -1
@@ -213,7 +213,7 @@ static struct dvb_usb_properties cxusb_p
 static int cxusb_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE);
+	return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE,NULL);
 }
 
 static struct usb_device_id cxusb_table [] = {
drivers/media/dvb/dvb-usb/digitv.c +1 -1
@@ -175,7 +175,7 @@ static struct dvb_usb_properties digitv_
 static int digitv_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE);
+	return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,NULL);
 }
 
 static struct usb_device_id digitv_table [] = {

--

#5 lore raw

PATCH 5/54 core: dvb_demux: fix continuity counter error handling

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Don't return immediately from dvb_dmx_swfilter_section_packet() if CC is not ok. Otherwise a new feed drops all packets until the first packet with CC=0 arrives.

 drivers/media/dvb/dvb-core/dvb_demux.c |    1 -
 1 file changed, 1 deletion(-)
drivers/media/dvb/dvb-core/dvb_demux.c +0 -1
@@ -336,7 +336,6 @@ static int dvb_dmx_swfilter_section_pack
 		*/
 		feed->pusi_seen = 0;
 		dvb_dmx_swfilter_section_new(feed);
-		return 0;
 	}
 
 	if (buf[1] & 0x40) {

--

#4 lore raw

PATCH 4/54 core: glue code for DMX_GET_CAPS and DMX_SET_SOURCE

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Glue code for DMX_GET_CAPS and DMX_SET_SOURCE ioctls.

 drivers/media/dvb/dvb-core/demux.h  |    5 +++++
 drivers/media/dvb/dvb-core/dmxdev.c |   16 ++++++++++++++++
 2 files changed, 21 insertions(+)
drivers/media/dvb/dvb-core/demux.h +5 -0
@@ -30,6 +30,7 @@
 #include <linux/errno.h>
 #include <linux/list.h>
 #include <linux/time.h>
+#include <linux/dvb/dmx.h>
 
 /*--------------------------------------------------------------------------*/
 /* Common definitions */
@@ -282,6 +283,10 @@ struct dmx_demux {
 
         int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
 
+	int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
+
+	int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
+
         int (*get_stc) (struct dmx_demux* demux, unsigned int num,
 			u64 *stc, unsigned int *base);
 };
drivers/media/dvb/dvb-core/dmxdev.c +16 -0
@@ -929,6 +929,22 @@ static int dvb_demux_do_ioctl(struct ino
 		dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg);
 		break;
 
+	case DMX_GET_CAPS:
+		if (!dmxdev->demux->get_caps) {
+			ret = -EINVAL;
+			break;
+		}
+		ret = dmxdev->demux->get_caps(dmxdev->demux, parg);
+		break;
+
+	case DMX_SET_SOURCE:
+		if (!dmxdev->demux->set_source) {
+			ret = -EINVAL;
+			break;
+		}
+		ret = dmxdev->demux->set_source(dmxdev->demux, parg);
+		break;
+
 	case DMX_GET_STC:
 		if (!dmxdev->demux->get_stc) {
 		        ret=-EINVAL;

--

#13 lore raw

PATCH 13/54 frontend: stv0299: pass i2c bus to pll callback

In reply to Johannes Stezenbach

From: Andreas Oberritter <[email protected]>

Pass a pointer to the i2c bus to the pll callbacks (stv0299 only).

It was not possible to tell which i2c bus should be used if an adapter has multiple frontends on multiple i2c buses.

 drivers/media/dvb/b2c2/flexcop-fe-tuner.c         |    5 ++---
 drivers/media/dvb/frontends/stv0299.c             |    6 +++---
 drivers/media/dvb/frontends/stv0299.h             |    4 ++--
 drivers/media/dvb/ttpci/av7110.c                  |   10 ++++------
 drivers/media/dvb/ttpci/budget-av.c               |    4 ++--
 drivers/media/dvb/ttpci/budget-ci.c               |    9 ++++-----
 drivers/media/dvb/ttpci/budget-patch.c            |    5 ++---
 drivers/media/dvb/ttpci/budget.c                  |    5 ++---
 drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c |    4 ++--
 9 files changed, 23 insertions(+), 29 deletions(-)
drivers/media/dvb/b2c2/flexcop-fe-tuner.c +2 -3
@@ -164,12 +164,11 @@ static int samsung_tbmu24112_set_symbol_
 	return 0;
 }
 
-static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
 {
 	u8 buf[4];
 	u32 div;
 	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
-	struct flexcop_device *fc = fe->dvb->priv;
 
 	div = params->frequency / 125;
 
@@ -180,7 +179,7 @@ static int samsung_tbmu24112_pll_set(str
 
 	if (params->frequency < 1500000) buf[3] |= 0x10;
 
-	if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1)
+	if (i2c_transfer(i2c, &msg, 1) != 1)
 		return -EIO;
 	return 0;
 }
drivers/media/dvb/frontends/stv0299.c +3 -3
@@ -481,7 +481,7 @@ static int stv0299_init (struct dvb_fron
 
 	if (state->config->pll_init) {
 		stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
-		state->config->pll_init(fe);
+		state->config->pll_init(fe, state->i2c);
 		stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
 	}
 
@@ -603,7 +603,7 @@ static int stv0299_set_frontend(struct d
 		} else {
 			/* A "normal" tune is requested */
 			stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
-			state->config->pll_set(fe, p);
+			state->config->pll_set(fe, state->i2c, p);
 			stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
 
 			stv0299_writeregI(state, 0x32, 0x80);
@@ -615,7 +615,7 @@ static int stv0299_set_frontend(struct d
 		}
 	} else {
 		stv0299_writeregI(state, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
-		state->config->pll_set(fe, p);
+		state->config->pll_set(fe, state->i2c, p);
 		stv0299_writeregI(state, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
 
 		stv0299_set_FEC (state, p->u.qpsk.fec_inner);
drivers/media/dvb/frontends/stv0299.h +2 -2
@@ -92,8 +92,8 @@ struct stv0299_config
 	int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio);
 
 	/* PLL maintenance */
-	int (*pll_init)(struct dvb_frontend* fe);
-	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
+	int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c);
+	int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params);
 };
 
 extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data);
drivers/media/dvb/ttpci/av7110.c +4 -6
@@ -1668,9 +1668,8 @@ static int alps_bsru6_set_symbol_rate(st
 	return 0;
 }
 
-static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
 {
-	struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
 	int ret;
 	u8 data[4];
 	u32 div;
@@ -1687,7 +1686,7 @@ static int alps_bsru6_pll_set(struct dvb
 
 	if (params->frequency > 1530000) data[3] = 0xc0;
 
-	ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
+	ret = i2c_transfer(i2c, &msg, 1);
 	if (ret != 1)
 		return -EIO;
 	return 0;
@@ -1751,9 +1750,8 @@ static u8 alps_bsbe1_inittab[] = {
 	0xff, 0xff
 };
 
-static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
 {
-	struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
 	int ret;
 	u8 data[4];
 	u32 div;
@@ -1768,7 +1766,7 @@ static int alps_bsbe1_pll_set(struct dvb
 	data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
 	data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
 
-	ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
+	ret = i2c_transfer(i2c, &msg, 1);
 	return (ret != 1) ? -EIO : 0;
 }
 
drivers/media/dvb/ttpci/budget-ci.c +4 -5
@@ -548,9 +548,8 @@ static int alps_bsru6_set_symbol_rate(st
 	return 0;
 }
 
-static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params)
 {
-	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
 	u8 buf[4];
 	u32 div;
 	struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
@@ -567,7 +566,7 @@ static int alps_bsru6_pll_set(struct dvb
 	if (params->frequency > 1530000)
 		buf[3] = 0xc0;
 
-	if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1)
+	if (i2c_transfer(i2c, &msg, 1) != 1)
 		return -EIO;
 	return 0;
 }
@@ -669,9 +668,9 @@ static int philips_su1278_tt_set_symbol_
 }
 
 static int philips_su1278_tt_pll_set(struct dvb_frontend *fe,
+				     struct i2c_adapter *i2c,
 				     struct dvb_frontend_parameters *params)
 {
-	struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
 	u32 div;
 	u8 buf[4];
 	struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
@@ -697,7 +696,7 @@ static int philips_su1278_tt_pll_set(str
 	else if (params->frequency < 2150000)
 		buf[3] |= 0xC0;
 
-	if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1)
+	if (i2c_transfer(i2c, &msg, 1) != 1)
 		return -EIO;
 	return 0;
 }
drivers/media/dvb/ttpci/budget-patch.c +2 -3
@@ -353,9 +353,8 @@ static int alps_bsru6_set_symbol_rate(st
 	return 0;
 }
 
-static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
 {
-	struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
 	u8 data[4];
 	u32 div;
 	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
@@ -370,7 +369,7 @@ static int alps_bsru6_pll_set(struct dvb
 
 	if (params->frequency > 1530000) data[3] = 0xc0;
 
-	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO;
 	return 0;
 }
 
drivers/media/dvb/ttpci/budget.c +2 -3
@@ -332,9 +332,8 @@ static int alps_bsru6_set_symbol_rate(st
 	return 0;
 }
 
-static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
 {
-	struct budget* budget = (struct budget*) fe->dvb->priv;
 	u8 data[4];
 	u32 div;
 	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
@@ -349,7 +348,7 @@ static int alps_bsru6_pll_set(struct dvb
 
 	if (params->frequency > 1530000) data[3] = 0xc0;
 
-	if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+	if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO;
 	return 0;
 }
 
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +2 -2
@@ -1299,7 +1299,7 @@ static int alps_stv0299_set_symbol_rate(
 	return 0;
 }
 
-static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params)
 {
 	struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
 	u8 buf[4];
@@ -1322,7 +1322,7 @@ static int philips_tsa5059_pll_set(struc
 	if (ttusb->revision == TTUSB_REV_2_2)
 		buf[3] |= 0x20;
 
-	if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1)
+	if (i2c_transfer(i2c, &msg, 1) != 1)
 		return -EIO;
 
 	return 0;
drivers/media/dvb/ttpci/budget-av.c +2 -2
@@ -453,9 +453,9 @@ static int philips_su1278_ty_ci_set_symb
 }
 
 static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe,
+					struct i2c_adapter *i2c,
 					struct dvb_frontend_parameters *params)
 {
-	struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv;
 	u32 div;
 	u8 buf[4];
 	struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
@@ -481,7 +481,7 @@ static int philips_su1278_ty_ci_pll_set(
 	else if (params->frequency < 2150000)
 		buf[3] |= 0xC0;
 
-	if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1)
+	if (i2c_transfer(i2c, &msg, 1) != 1)
 		return -EIO;
 	return 0;
 }

--

#63 lore raw

Re: [DVB patch 54/54] ttusb-budget: use time_after_eq()

In reply to Johannes Stezenbach
Quoted 33 lines · Johannes Stezenbach

From: Marcelo Feitoza Parisi <[email protected]>

Use of the time_after_eq() macro, defined at linux/jiffies.h, which deal with wrapping correctly and are nicer to read.

 drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 2005-09-04 22:31:06.000000000 +0200 renamed from drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 2005-09-04 22:28:03.000000000 +0200 +3 -1
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/time.h>
 #include <linux/errno.h>
+#include <linux/jiffies.h>
 #include <asm/semaphore.h>
 
 #include "dvb_frontend.h"
@@ -570,7 +571,8 @@ static void ttusb_handle_sec_data(struct
                                  const u8 * data, int len);
 #endif
 
-static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid;
+static int numpkt = 0, numts, numstuff, numsec, numinvalid;
+static unsigned long lastj;
 
 static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
                           int len)

drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 2005-09-04 22:31:06.000000000 +0200 static void ttusb_iso_irq(struct urb *ur · line 784

Quoted 5 lines
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 2005-09-04 22:31:06.000000000 +0200 renamed from drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 2005-09-04 22:28:03.000000000 +0200 +1 -1
@@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *ur
                        u8 *data;
                        int len;
                        numpkt++;
-                       if ((jiffies - lastj) >= HZ) {
+                       if (time_after_eq(jiffies, lastj + HZ)) {

I think you actually want:

static void ttusb_iso_irq(....)

{
     unsigned long lastj;

     ...

     lastj = jiffies + HZ;
     if (time_after_eq(jiffies, lastj)) {
          ...

}

The current code doesn't assign jiffies to lastj at any point that I see.

Thanks,
Nish

#25 lore raw

PATCH 23/54 usb: add TwinhanDTV StarBox support

In reply to Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

Add driver for the TwinhanDTV StarBox and clones.

Thanks to Ralph Metzler for his initial work on this box and thanks to Twinhan for their support.

 drivers/media/dvb/dvb-usb/Kconfig       |   23 +-
 drivers/media/dvb/dvb-usb/Makefile      |    3 
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h |    6 
 drivers/media/dvb/dvb-usb/vp702x-fe.c   |  339 ++++++++++++++++++++++++++++++++
 drivers/media/dvb/dvb-usb/vp702x.c      |  290 +++++++++++++++++++++++++++
 drivers/media/dvb/dvb-usb/vp702x.h      |  109 ++++++++++
 6 files changed, 765 insertions(+), 5 deletions(-)
drivers/media/dvb/dvb-usb/Kconfig +20 -3
@@ -93,13 +93,30 @@ config DVB_USB_DIGITV
 	  Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver.
 
 config DVB_USB_VP7045
-	tristate "TwinhanDTV Alpha/MagicBoxII and DNTV tinyUSB2 DVB-T USB2.0 support"
+	tristate "TwinhanDTV Alpha/MagicBoxII, DNTV tinyUSB2, Beetle USB2.0 support"
 	depends on DVB_USB
 	help
 	  Say Y here to support the
+
 	    TwinhanDTV Alpha (stick) (VP-7045),
-		TwinhanDTV MagicBox II (VP-7046) and
-		DigitalNow TinyUSB 2 DVB-t DVB-T USB2.0 receivers.
+		TwinhanDTV MagicBox II (VP-7046),
+		DigitalNow TinyUSB 2 DVB-t,
+		DigitalRise USB 2.0 Ter (Beetle) and
+		TYPHOON DVB-T USB DRIVE
+
+	  DVB-T USB2.0 receivers.
+
+config DVB_USB_VP702X
+	tristate "TwinhanDTV StarBox and clones DVB-S USB2.0 support"
+	depends on DVB_USB
+	help
+	  Say Y here to support the
+
+	    TwinhanDTV StarBox,
+		DigitalRise USB Starbox and
+		TYPHOON DVB-S USB 2.0 BOX
+
+	  DVB-S USB2.0 receivers.
 
 config DVB_USB_NOVA_T_USB2
 	tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
drivers/media/dvb/dvb-usb/Makefile +3 -0
@@ -4,6 +4,9 @@ obj-$(CONFIG_DVB_USB) += dvb-usb.o
 dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o
 obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o
 
+dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o
+obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o
+
 dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o
 obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o
 
drivers/media/dvb/dvb-usb/vp702x-fe.c new file +339 -0

339 lines not on this page · raw message

drivers/media/dvb/dvb-usb/vp702x.c new file +290 -0

290 lines not on this page · raw message

drivers/media/dvb/dvb-usb/vp702x.h new file +109 -0

109 lines not on this page · raw message

drivers/media/dvb/dvb-usb/dvb-usb-ids.h +4 -2
@@ -52,12 +52,14 @@
 #define USB_PID_KWORLD_VSTREAM_WARM			0x17df
 #define USB_PID_TWINHAN_VP7041_COLD			0x3201
 #define USB_PID_TWINHAN_VP7041_WARM			0x3202
+#define USB_PID_TWINHAN_VP7020_COLD			0x3203
+#define USB_PID_TWINHAN_VP7020_WARM			0x3204
 #define USB_PID_TWINHAN_VP7045_COLD			0x3205
 #define USB_PID_TWINHAN_VP7045_WARM			0x3206
-#define USB_PID_DNTV_TINYUSB2_COLD			0x3223
-#define USB_PID_DNTV_TINYUSB2_WARM			0x3224
 #define USB_PID_TWINHAN_VP7021_COLD			0x3207
 #define USB_PID_TWINHAN_VP7021_WARM			0x3208
+#define USB_PID_DNTV_TINYUSB2_COLD			0x3223
+#define USB_PID_DNTV_TINYUSB2_WARM			0x3224
 #define USB_PID_ULTIMA_TVBOX_COLD			0x8105
 #define USB_PID_ULTIMA_TVBOX_WARM			0x8106
 #define USB_PID_ULTIMA_TVBOX_AN2235_COLD	0x8107

--

#41 lore raw

PATCH 38/54 dst: remove unnecessary code

In reply to Johannes Stezenbach

From: Manu Abraham <[email protected]>

Code Simplification: CA PMT object is not parsed in the driver anymore.

 drivers/media/dvb/bt8xx/dst_ca.c |  115 ++++++---------------------------------
 1 file changed, 20 insertions(+), 95 deletions(-)
drivers/media/dvb/bt8xx/dst_ca.c +20 -95
@@ -260,8 +260,6 @@ static int ca_get_slot_info(struct dst_s
 }
 
 
-
-
 static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg)
 {
 	u8 i = 0;
@@ -298,10 +296,14 @@ static int ca_get_message(struct dst_sta
 static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length)
 {
 	if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) {
-		hw_buffer->msg[2] = p_ca_message->msg[1];		/*		MSB			*/
-		hw_buffer->msg[3] = p_ca_message->msg[2];		/*		LSB			*/
-	}
-	else {
+		hw_buffer->msg[2] = p_ca_message->msg[1];	/*	MSB	*/
+		hw_buffer->msg[3] = p_ca_message->msg[2];	/*	LSB	*/
+	} else {
+		if (length > 247) {
+			dprintk("%s: Message too long ! *** Bailing Out *** !\n", __FUNCTION__);
+			return -1;
+		}
+
 		hw_buffer->msg[0] = (length & 0xff) + 7;
 		hw_buffer->msg[1] = 0x40;
 		hw_buffer->msg[2] = 0x03;
@@ -309,6 +311,11 @@ static int handle_dst_tag(struct dst_sta
 		hw_buffer->msg[4] = 0x03;
 		hw_buffer->msg[5] = length & 0xff;
 		hw_buffer->msg[6] = 0x00;
+		/*
+		 *	Need to compute length for EN50221 section 8.3.2, for the time being
+		 *	assuming 8.3.2 is not applicable
+		 */
+		memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length);
 	}
 	return 0;
 }
@@ -348,15 +355,6 @@ u32 asn_1_decode(u8 *asn_1_array)
 	return length;
 }
 
-static int init_buffer(u8 *buffer, u32 length)
-{
-	u32 i;
-	for (i = 0; i < length; i++)
-		buffer[i] = 0;
-
-	return 0;
-}
-
 static int debug_string(u8 *msg, u32 length, u32 offset)
 {
 	u32 i;
@@ -369,95 +367,22 @@ static int debug_string(u8 *msg, u32 len
 	return 0;
 }
 
-static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length)
-{
-	u32 i;
-	dprintk("%s: Copying [", __FUNCTION__);
-	for (i = 0; i < length; i++) {
-		destination[i + dest_offset] = source[i + source_offset];
-		dprintk(" %02x", source[i + source_offset]);
-	}
-	dprintk("]\n");
-
-	return i;
-}
-
-static int modify_4_bits(u8 *message, u32 pos)
-{
-	message[pos] &= 0x0f;
-
-	return 0;
-}
-
-
-
 static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
 {
-	u32 length = 0, count = 0;
-	u8 asn_1_words, program_header_length;
-	u16 program_info_length = 0, es_info_length = 0;
-	u32 hw_offset = 0, buf_offset = 0, i;
-	u8 dst_tag_length;
+	u32 length = 0;
+	u8 tag_length = 8;
 
 	length = asn_1_decode(&p_ca_message->msg[3]);
 	dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length);
 	dprintk("%s: ASN.1 ", __FUNCTION__);
-	debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length
+	debug_string(&p_ca_message->msg[4], length, 0); /*	length is excluding tag & length	*/
 
-	init_buffer(hw_buffer->msg, length);
+	memset(hw_buffer->msg, '\0', length);
 	handle_dst_tag(state, p_ca_message, hw_buffer, length);
+	put_checksum(hw_buffer->msg, hw_buffer->msg[0]);
 
-	hw_offset = 7;
-	asn_1_words = 1; // just a hack to test, should compute this one
-	buf_offset = 3;
-	program_header_length = 6;
-	dst_tag_length = 7;
-
-//	debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset);
-//	dprintk("%s: Program Header(BUF)", __FUNCTION__);
-//	debug_string(&p_ca_message->msg[4], program_header_length, 0);
-//	dprintk("%s: Copying Program header\n", __FUNCTION__);
-	copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length);
-	buf_offset += program_header_length, hw_offset += program_header_length;
-	modify_4_bits(hw_buffer->msg, (hw_offset - 2));
-	if (state->type_flags & DST_TYPE_HAS_INC_COUNT) {	// workaround
-		dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__);
-		debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0);
-		hw_buffer->msg[hw_offset - 1] += 1;
-	}
-
-//	dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count);
-//	debug_string(hw_buffer->msg, hw_offset, 0);
-
-	program_info_length =  ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
-	dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length);
-	if (program_info_length) {
-		count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current
-		buf_offset += count, hw_offset += count;
-//		dprintk("%s: Program level ", __FUNCTION__);
-//		debug_string(hw_buffer->msg, hw_offset, 0);
-	}
-
-	buf_offset += 1;// hw_offset += 1;
-	for (i = buf_offset; i < length; i++) {
-//		dprintk("%s: Stream Header ", __FUNCTION__);
-		count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5);
-		modify_4_bits(hw_buffer->msg, (hw_offset + 3));
-
-		hw_offset += 5, buf_offset += 5, i += 4;
-//		debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5));
-		es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset];
-		dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length);
-		if (es_info_length) {
-			// copy descriptors @ STREAM level
-			dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__);
-		}
-
-	}
-	hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length));
-//	dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]);
-	debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0);	// dst tags also
-	write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply);	// checksum
+	debug_string(hw_buffer->msg, (length + tag_length), 0); /*	tags too	*/
+	write_to_8820(state, hw_buffer, (length + tag_length), reply);
 
 	return 0;
 }

--

#14 lore raw

PATCH 14/54 frontend: s5h1420: fixes

In reply to Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Misc. fixes.

 drivers/media/dvb/frontends/s5h1420.c |  162 +++++++++++++++++++---------------
 drivers/media/dvb/frontends/s5h1420.h |    3 
 drivers/media/dvb/ttpci/budget.c      |    1 
 3 files changed, 97 insertions(+), 69 deletions(-)
drivers/media/dvb/frontends/s5h1420.c +93 -69
@@ -48,7 +48,8 @@ struct s5h1420_state {
 };
 
 static u32 s5h1420_getsymbolrate(struct s5h1420_state* state);
-static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings);
+static int s5h1420_get_tune_settings(struct dvb_frontend* fe,
+				     struct dvb_frontend_tune_settings* fesettings);
 
 
 static int debug = 0;
@@ -91,7 +92,8 @@ static int s5h1420_set_voltage (struct d
 
 	switch(voltage) {
 	case SEC_VOLTAGE_13:
-		s5h1420_writereg(state, 0x3c, (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02);
+		s5h1420_writereg(state, 0x3c,
+				 (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02);
 		break;
 
 	case SEC_VOLTAGE_18:
@@ -112,18 +114,21 @@ static int s5h1420_set_tone (struct dvb_
 
 	switch(tone) {
 	case SEC_TONE_ON:
-		s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08);
+		s5h1420_writereg(state, 0x3b,
+				 (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08);
 		break;
 
 	case SEC_TONE_OFF:
-		s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01);
+		s5h1420_writereg(state, 0x3b,
+				 (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01);
 		break;
 	}
 
 	return 0;
 }
 
-static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
+static int s5h1420_send_master_cmd (struct dvb_frontend* fe,
+				    struct dvb_diseqc_master_cmd* cmd)
 {
 	struct s5h1420_state* state = fe->demodulator_priv;
 	u8 val;
@@ -131,6 +136,9 @@ static int s5h1420_send_master_cmd (stru
 	unsigned long timeout;
 	int result = 0;
 
+	if (cmd->msg_len > 8)
+		return -EINVAL;
+
 	/* setup for DISEQC */
 	val = s5h1420_readreg(state, 0x3b);
 	s5h1420_writereg(state, 0x3b, 0x02);
@@ -138,16 +146,17 @@ static int s5h1420_send_master_cmd (stru
 
 	/* write the DISEQC command bytes */
 	for(i=0; i< cmd->msg_len; i++) {
-		s5h1420_writereg(state, 0x3c + i, cmd->msg[i]);
+		s5h1420_writereg(state, 0x3d + i, cmd->msg[i]);
 	}
 
 	/* kick off transmission */
-	s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | ((cmd->msg_len-1) << 4) | 0x08);
+	s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) |
+				      ((cmd->msg_len-1) << 4) | 0x08);
 
 	/* wait for transmission to complete */
 	timeout = jiffies + ((100*HZ) / 1000);
 	while(time_before(jiffies, timeout)) {
-		if (s5h1420_readreg(state, 0x3b) & 0x08)
+		if (!(s5h1420_readreg(state, 0x3b) & 0x08))
 			break;
 
 		msleep(5);
@@ -161,7 +170,8 @@ static int s5h1420_send_master_cmd (stru
 	return result;
 }
 
-static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply)
+static int s5h1420_recv_slave_reply (struct dvb_frontend* fe,
+				     struct dvb_diseqc_slave_reply* reply)
 {
 	struct s5h1420_state* state = fe->demodulator_priv;
 	u8 val;
@@ -205,7 +215,7 @@ static int s5h1420_recv_slave_reply (str
 
 	/* extract data */
 	for(i=0; i< length; i++) {
-		reply->msg[i] = s5h1420_readreg(state, 0x3c + i);
+		reply->msg[i] = s5h1420_readreg(state, 0x3d + i);
 	}
 
 exit:
@@ -236,7 +246,7 @@ static int s5h1420_send_burst (struct dv
 	s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08);
 
 	/* wait for transmission to complete */
-	timeout = jiffies + ((20*HZ) / 1000);
+	timeout = jiffies + ((100*HZ) / 1000);
 	while(time_before(jiffies, timeout)) {
 		if (!(s5h1420_readreg(state, 0x3b) & 0x08))
 			break;
@@ -259,9 +269,9 @@ static fe_status_t s5h1420_get_status_bi
 
 	val = s5h1420_readreg(state, 0x14);
 	if (val & 0x02)
-		status |=  FE_HAS_SIGNAL; // FIXME: not sure if this is right
+		status |=  FE_HAS_SIGNAL;
 	if (val & 0x01)
-		status |=  FE_HAS_CARRIER; // FIXME: not sure if this is right
+		status |=  FE_HAS_CARRIER;
 	val = s5h1420_readreg(state, 0x36);
 	if (val & 0x01)
 		status |=  FE_HAS_VITERBI;
@@ -284,8 +294,8 @@ static int s5h1420_read_status(struct dv
 	/* determine lock state */
 	*status = s5h1420_get_status_bits(state);
 
-	/* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert the inversion,
-	wait a bit and check again */
+	/* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert
+	the inversion, wait a bit and check again */
 	if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) {
 		val = s5h1420_readreg(state, 0x32);
 		if ((val & 0x07) == 0x03) {
@@ -330,6 +340,10 @@ static int s5h1420_read_status(struct dv
 			tmp = (tmp * 2 * 7) / 8;
 			break;
 		}
+		if (tmp == 0) {
+			printk("s5h1420: avoided division by 0\n");
+			tmp = 1;
+		}
 		tmp = state->fclk / tmp;
 
 		/* set the MPEG_CLK_INTL for the calculated data rate */
@@ -368,16 +382,21 @@ static int s5h1420_read_ber(struct dvb_f
 
 	s5h1420_writereg(state, 0x46, 0x1d);
 	mdelay(25);
-	return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
+
+	*ber = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
+
+	return 0;
 }
 
 static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 {
 	struct s5h1420_state* state = fe->demodulator_priv;
 
-	u8 val = 0xff - s5h1420_readreg(state, 0x15);
+	u8 val = s5h1420_readreg(state, 0x15);
 
-	return (int) ((val << 8) | val);
+	*strength =  (u16) ((val << 8) | val);
+
+	return 0;
 }
 
 static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
@@ -386,7 +405,10 @@ static int s5h1420_read_ucblocks(struct 
 
 	s5h1420_writereg(state, 0x46, 0x1f);
 	mdelay(25);
-	return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
+
+	*ucblocks = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
+
+	return 0;
 }
 
 static void s5h1420_reset(struct s5h1420_state* state)
@@ -396,11 +418,12 @@ static void s5h1420_reset(struct s5h1420
 	udelay(10);
 }
 
-static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_frontend_parameters *p)
+static void s5h1420_setsymbolrate(struct s5h1420_state* state,
+				  struct dvb_frontend_parameters *p)
 {
 	u64 val;
 
-	val = (p->u.qpsk.symbol_rate / 1000) * (1<<24);
+	val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24);
 	if (p->u.qpsk.symbol_rate <= 21000000) {
 		val *= 2;
 	}
@@ -415,7 +438,7 @@ static void s5h1420_setsymbolrate(struct
 
 static u32 s5h1420_getsymbolrate(struct s5h1420_state* state)
 {
-	u64 val;
+	u64 val = 0;
 	int sampling = 2;
 
 	if (s5h1420_readreg(state, 0x05) & 0x2)
@@ -427,10 +450,10 @@ static u32 s5h1420_getsymbolrate(struct 
 	val |= s5h1420_readreg(state, 0x13);
 	s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7);
 
-	val *= (state->fclk / 1000);
+	val *= (state->fclk / 1000ULL);
 	do_div(val, ((1<<24) * sampling));
 
-	return (u32) (val * 1000);
+	return (u32) (val * 1000ULL);
 }
 
 static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset)
@@ -463,46 +486,55 @@ static int s5h1420_getfreqoffset(struct 
 
 	/* remember freqoffset is in kHz, but the chip wants the offset in Hz, so
 	 * divide fclk by 1000000 to get the correct value. */
-	val = - ((val * (state->fclk/1000000)) / (1<<24));
+	val = (((-val) * (state->fclk/1000000)) / (1<<24));
 
 	return val;
 }
 
-static void s5h1420_setfec(struct s5h1420_state* state, struct dvb_frontend_parameters *p)
+static void s5h1420_setfec_inversion(struct s5h1420_state* state,
+			   	     struct dvb_frontend_parameters *p)
 {
+	u8 inversion = 0;
+
+	if (p->inversion == INVERSION_OFF) {
+		inversion = state->config->invert ? 0x08 : 0;
+	} else if (p->inversion == INVERSION_ON) {
+		inversion = state->config->invert ? 0 : 0x08;
+	}
+
 	if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) {
-		s5h1420_writereg(state, 0x31, 0x00);
 		s5h1420_writereg(state, 0x30, 0x3f);
+		s5h1420_writereg(state, 0x31, 0x00 | inversion);
 	} else {
 		switch(p->u.qpsk.fec_inner) {
 		case FEC_1_2:
-			s5h1420_writereg(state, 0x31, 0x10);
 			s5h1420_writereg(state, 0x30, 0x01);
+			s5h1420_writereg(state, 0x31, 0x10 | inversion);
 			break;
 
 		case FEC_2_3:
-			s5h1420_writereg(state, 0x31, 0x11);
 			s5h1420_writereg(state, 0x30, 0x02);
+			s5h1420_writereg(state, 0x31, 0x11 | inversion);
 			break;
 
 		case FEC_3_4:
-			s5h1420_writereg(state, 0x31, 0x12);
 			s5h1420_writereg(state, 0x30, 0x04);
-			break;
+                        s5h1420_writereg(state, 0x31, 0x12 | inversion);
+                        break;
 
 		case FEC_5_6:
-			s5h1420_writereg(state, 0x31, 0x13);
 			s5h1420_writereg(state, 0x30, 0x08);
+			s5h1420_writereg(state, 0x31, 0x13 | inversion);
 			break;
 
 		case FEC_6_7:
-			s5h1420_writereg(state, 0x31, 0x14);
 			s5h1420_writereg(state, 0x30, 0x10);
+			s5h1420_writereg(state, 0x31, 0x14 | inversion);
 			break;
 
 		case FEC_7_8:
-			s5h1420_writereg(state, 0x31, 0x15);
 			s5h1420_writereg(state, 0x30, 0x20);
+			s5h1420_writereg(state, 0x31, 0x15 | inversion);
 			break;
 
 		default:
@@ -536,22 +568,6 @@ static fe_code_rate_t s5h1420_getfec(str
 	return FEC_NONE;
 }
 
-static void s5h1420_setinversion(struct s5h1420_state* state, struct dvb_frontend_parameters *p)
-{
-	if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) {
-		s5h1420_writereg(state, 0x31, 0x00);
-		s5h1420_writereg(state, 0x30, 0x3f);
-	} else {
-		u8 tmp = s5h1420_readreg(state, 0x31) & 0xf7;
-			tmp |= 0x10;
-
-		if (p->inversion == INVERSION_ON)
-			tmp |= 0x80;
-
-		s5h1420_writereg(state, 0x31, tmp);
-	}
-}
-
 static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state)
 {
 	if (s5h1420_readreg(state, 0x32) & 0x08)
@@ -560,35 +576,35 @@ static fe_spectral_inversion_t s5h1420_g
 	return INVERSION_OFF;
 }
 
-static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+static int s5h1420_set_frontend(struct dvb_frontend* fe,
+				struct dvb_frontend_parameters *p)
 {
 	struct s5h1420_state* state = fe->demodulator_priv;
-	u32 frequency_delta;
+	int frequency_delta;
 	struct dvb_frontend_tune_settings fesettings;
+	u32 tmp;
 
 	/* check if we should do a fast-tune */
 	memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters));
 	s5h1420_get_tune_settings(fe, &fesettings);
 	frequency_delta = p->frequency - state->tunedfreq;
-	if ((frequency_delta > -fesettings.max_drift) && (frequency_delta < fesettings.max_drift) &&
+	if ((frequency_delta > -fesettings.max_drift) &&
+	    (frequency_delta < fesettings.max_drift) &&
 	    (frequency_delta != 0) &&
 	    (state->fec_inner == p->u.qpsk.fec_inner) &&
 	    (state->symbol_rate == p->u.qpsk.symbol_rate)) {
 
-		s5h1420_setfreqoffset(state, frequency_delta);
+		if (state->config->pll_set) {
+			s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
+			state->config->pll_set(fe, p, &tmp);
+			s5h1420_setfreqoffset(state, p->frequency - tmp);
+		}
 		return 0;
 	}
 
 	/* first of all, software reset */
 	s5h1420_reset(state);
 
-	/* set tuner PLL */
-	if (state->config->pll_set) {
-		s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
-		state->config->pll_set(fe, p, &state->tunedfreq);
-		s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe);
-	}
-
 	/* set s5h1420 fclk PLL according to desired symbol rate */
 	if (p->u.qpsk.symbol_rate > 28000000) {
 		state->fclk = 88000000;
@@ -609,8 +625,9 @@ static int s5h1420_set_frontend(struct d
 
 	/* set misc registers */
 	s5h1420_writereg(state, 0x02, 0x00);
+	s5h1420_writereg(state, 0x06, 0x00);
 	s5h1420_writereg(state, 0x07, 0xb0);
-	s5h1420_writereg(state, 0x0a, 0x67);
+	s5h1420_writereg(state, 0x0a, 0xe7);
 	s5h1420_writereg(state, 0x0b, 0x78);
 	s5h1420_writereg(state, 0x0c, 0x48);
 	s5h1420_writereg(state, 0x0d, 0x6b);
@@ -626,21 +643,26 @@ static int s5h1420_set_frontend(struct d
 	/* start QPSK */
 	s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1);
 
-	/* set the frequency offset to adjust for PLL inaccuracy */
-	s5h1420_setfreqoffset(state, p->frequency - state->tunedfreq);
+	/* set tuner PLL */
+	if (state->config->pll_set) {
+		s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
+		state->config->pll_set(fe, p, &tmp);
+		s5h1420_setfreqoffset(state, 0);
+	}
 
 	/* set the reset of the parameters */
 	s5h1420_setsymbolrate(state, p);
-	s5h1420_setinversion(state, p);
-	s5h1420_setfec(state, p);
+	s5h1420_setfec_inversion(state, p);
 
 	state->fec_inner = p->u.qpsk.fec_inner;
 	state->symbol_rate = p->u.qpsk.symbol_rate;
 	state->postlocked = 0;
+	state->tunedfreq = p->frequency;
 	return 0;
 }
 
-static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
+static int s5h1420_get_frontend(struct dvb_frontend* fe,
+				struct dvb_frontend_parameters *p)
 {
 	struct s5h1420_state* state = fe->demodulator_priv;
 
@@ -652,7 +674,8 @@ static int s5h1420_get_frontend(struct d
 	return 0;
 }
 
-static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
+static int s5h1420_get_tune_settings(struct dvb_frontend* fe,
+				     struct dvb_frontend_tune_settings* fesettings)
 {
 	if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) {
 		fesettings->min_delay_ms = 50;
@@ -717,7 +740,8 @@ static void s5h1420_release(struct dvb_f
 
 static struct dvb_frontend_ops s5h1420_ops;
 
-struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, struct i2c_adapter* i2c)
+struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
+				    struct i2c_adapter* i2c)
 {
 	struct s5h1420_state* state = NULL;
 	u8 identity;
drivers/media/dvb/frontends/s5h1420.h +3 -0
@@ -30,6 +30,9 @@ struct s5h1420_config
 	/* the demodulator's i2c address */
 	u8 demod_address;
 
+	/* does the inversion require inversion? */
+	u8 invert:1;
+
 	/* PLL maintenance */
 	int (*pll_init)(struct dvb_frontend* fe);
 	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout);
drivers/media/dvb/ttpci/budget.c +1 -0
@@ -480,6 +480,7 @@ static int s5h1420_pll_set(struct dvb_fr
 
 static struct s5h1420_config s5h1420_config = {
 	.demod_address = 0x53,
+	.invert = 1,
 	.pll_set = s5h1420_pll_set,
 };
 

--

#29 lore raw

PATCH 26/54 usb: dtt200u: copy frontend_ops before modifying

In reply to Johannes Stezenbach

From: Ye Jianjun (Joey) <[email protected]>

Fix: copy frontend_ops before modifying

 drivers/media/dvb/dvb-usb/dtt200u-fe.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/dvb/dvb-usb/dtt200u-fe.c +3 -1
@@ -18,6 +18,7 @@ struct dtt200u_fe_state {
 
 	struct dvb_frontend_parameters fep;
 	struct dvb_frontend frontend;
+	struct dvb_frontend_ops ops;
 };
 
 static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat)
@@ -163,8 +164,9 @@ struct dvb_frontend* dtt200u_fe_attach(s
 	deb_info("attaching frontend dtt200u\n");
 
 	state->d = d;
+	memcpy(&state->ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops));
 
-	state->frontend.ops = &dtt200u_fe_ops;
+	state->frontend.ops = &state->ops;
 	state->frontend.demodulator_priv = state;
 
 	goto success;

--

#34 lore raw

PATCH 31/54 usb: cxusb: fixes for new firmware

In reply to Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

This patch changes two things:

1) a firmware update made by the vendor, which has to be done in Windows for now, changes the DVB-data-pipe from isochronous to bulk: it fixes the data distortions (and thus the video-distortions) in DVB-T mode; there is no backwards compatibility with the old firmware as it didn't work anyway

2) with the help of Steve Toth some reverse-engineered functionality is now named correctly, thank you

 drivers/media/dvb/dvb-usb/cxusb.c |   64 +++++++++++++-------------------------
 drivers/media/dvb/dvb-usb/cxusb.h |   27 ++++++++--------
 2 files changed, 37 insertions(+), 54 deletions(-)
drivers/media/dvb/dvb-usb/cxusb.c +23 -41
@@ -48,35 +48,26 @@ static int cxusb_ctrl_msg(struct dvb_usb
 	return 0;
 }
 
-/* I2C */
-static void cxusb_set_i2c_path(struct dvb_usb_device *d, enum cxusb_i2c_pathes path)
+/* GPIO */
+static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
 {
 	struct cxusb_state *st = d->priv;
 	u8 o[2],i;
 
-	if (path == st->cur_i2c_path)
+	if (st->gpio_write_state[GPIO_TUNER] == onoff)
 		return;
 
-	o[0] = IOCTL_SET_I2C_PATH;
-	switch (path) {
-		case PATH_CX22702:
-			o[1] = 0;
-			break;
-		case PATH_TUNER_OTHER:
-			o[1] = 1;
-			break;
-		default:
-			err("unkown i2c path");
-			return;
-	}
-	cxusb_ctrl_msg(d,CMD_IOCTL,o,2,&i,1);
+	o[0] = GPIO_TUNER;
+	o[1] = onoff;
+	cxusb_ctrl_msg(d,CMD_GPIO_WRITE,o,2,&i,1);
 
 	if (i != 0x01)
-		deb_info("i2c_path setting failed.\n");
+		deb_info("gpio_write failed.\n");
 
-	st->cur_i2c_path = path;
+	st->gpio_write_state[GPIO_TUNER] = onoff;
 }
 
+/* I2C */
 static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
 {
 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
@@ -92,10 +83,10 @@ static int cxusb_i2c_xfer(struct i2c_ada
 
 		switch (msg[i].addr) {
 			case 0x63:
-				cxusb_set_i2c_path(d,PATH_CX22702);
+				cxusb_gpio_tuner(d,0);
 				break;
 			default:
-				cxusb_set_i2c_path(d,PATH_TUNER_OTHER);
+				cxusb_gpio_tuner(d,1);
 				break;
 		}
 
@@ -149,16 +140,20 @@ static struct i2c_algorithm cxusb_i2c_al
 
 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
-	return 0;
+	u8 b = 0;
+	if (onoff)
+		return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
+	else
+		return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
 }
 
 static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
 {
 	u8 buf[2] = { 0x03, 0x00 };
 	if (onoff)
-		cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0);
+		cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0);
 	else
-		cxusb_ctrl_msg(d,0x37, NULL, 0, NULL, 0);
+		cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0);
 
 	return 0;
 }
@@ -184,22 +179,11 @@ static int cxusb_tuner_attach(struct dvb
 
 static int cxusb_frontend_attach(struct dvb_usb_device *d)
 {
-	u8 buf[2] = { 0x03, 0x00 };
-	u8 b = 0;
-
-	if (usb_set_interface(d->udev,0,0) < 0)
-		err("set interface to alts=0 failed");
-
-	cxusb_ctrl_msg(d,0xde,&b,0,NULL,0);
-	cxusb_set_i2c_path(d,PATH_TUNER_OTHER);
-	cxusb_ctrl_msg(d,CMD_POWER_OFF, NULL, 0, &b, 1);
-
+	u8 b;
 	if (usb_set_interface(d->udev,0,6) < 0)
 		err("set interface failed");
 
-	cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0);
-	cxusb_set_i2c_path(d,PATH_CX22702);
-	cxusb_ctrl_msg(d,CMD_POWER_ON, NULL, 0, &b, 1);
+	cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1);
 
 	if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL)
 		return 0;
@@ -239,14 +223,12 @@ static struct dvb_usb_properties cxusb_p
 	.generic_bulk_ctrl_endpoint = 0x01,
 	/* parameter for the MPEG2-data transfer */
 	.urb = {
-		.type = DVB_USB_ISOC,
+		.type = DVB_USB_BULK,
 		.count = 5,
 		.endpoint = 0x02,
 		.u = {
-			.isoc = {
-				.framesperurb = 32,
-				.framesize = 940,
-				.interval = 5,
+			.bulk = {
+				.buffersize = 8192,
 			}
 		}
 	},
drivers/media/dvb/dvb-usb/cxusb.h +14 -13
@@ -1,30 +1,31 @@
 #ifndef _DVB_USB_CXUSB_H_
 #define _DVB_USB_CXUSB_H_
 
-#define DVB_USB_LOG_PREFIX "digitv"
+#define DVB_USB_LOG_PREFIX "cxusb"
 #include "dvb-usb.h"
 
 extern int dvb_usb_cxusb_debug;
 #define deb_info(args...)   dprintk(dvb_usb_cxusb_debug,0x01,args)
 
 /* usb commands - some of it are guesses, don't have a reference yet */
-#define CMD_I2C_WRITE    0x08
-#define CMD_I2C_READ     0x09
+#define CMD_I2C_WRITE     0x08
+#define CMD_I2C_READ      0x09
 
-#define CMD_IOCTL        0x0e
-#define    IOCTL_SET_I2C_PATH 0x02
+#define CMD_GPIO_READ     0x0d
+#define CMD_GPIO_WRITE    0x0e
+#define     GPIO_TUNER         0x02
 
-#define CMD_POWER_OFF    0x50
-#define CMD_POWER_ON     0x51
+#define CMD_POWER_OFF     0xdc
+#define CMD_POWER_ON      0xde
 
-enum cxusb_i2c_pathes {
-	PATH_UNDEF       = 0x00,
-	PATH_CX22702     = 0x01,
-	PATH_TUNER_OTHER = 0x02,
-};
+#define CMD_STREAMING_ON  0x36
+#define CMD_STREAMING_OFF 0x37
+
+#define CMD_ANALOG        0x50
+#define CMD_DIGITAL       0x51
 
 struct cxusb_state {
-	enum cxusb_i2c_pathes cur_i2c_path;
+	u8 gpio_write_state[3];
 };
 
 #endif

--

#21 lore raw

PATCH 19/54 frontend: cx24110: another DiSEqC fix

In reply to Johannes Stezenbach

From: Adam Szalkowski <[email protected]>

Fix DiSEqC problems.

 drivers/media/dvb/frontends/cx24110.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/media/dvb/frontends/cx24110.c +8 -5
@@ -398,7 +398,8 @@ static int cx24110_diseqc_send_burst(str
 		return -EINVAL;
 
 	rv = cx24110_readreg(state, 0x77);
-	cx24110_writereg(state, 0x77, rv | 0x04);
+	if (!(rv & 0x04))
+		cx24110_writereg(state, 0x77, rv | 0x04);
 
 	rv = cx24110_readreg(state, 0x76);
 	cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit));
@@ -418,14 +419,16 @@ static int cx24110_send_diseqc_msg(struc
 		cx24110_writereg(state, 0x79 + i, cmd->msg[i]);
 
 	rv = cx24110_readreg(state, 0x77);
-	cx24110_writereg(state, 0x77, rv & ~0x04);
-	msleep(30); /* reportedly fixes switching problems */
+	if (rv & 0x04) {
+		cx24110_writereg(state, 0x77, rv & ~0x04);
+		msleep(30); /* reportedly fixes switching problems */
+	}
 
 	rv = cx24110_readreg(state, 0x76);
 
 	cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3));
-	for (i=500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);)
-		; /* wait for LNB ready */
+	for (i=100; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);)
+		msleep(1); /* wait for LNB ready */
 
 	return 0;
 }

--

#44 lore raw

PATCH 41/54 dst: fix DVB-C tuning

In reply to Johannes Stezenbach

From: Manu Abraham <[email protected]>

Fix BUG in DVB-C frequency setting.
Thanks to Peng Cao <[email protected]>

 drivers/media/dvb/bt8xx/dst.c |    1 +
 1 file changed, 1 insertion(+)
drivers/media/dvb/bt8xx/dst.c +1 -0
@@ -359,6 +359,7 @@ static int dst_set_freq(struct dst_state
 		state->tx_tuna[3] = (freq >> 8) & 0xff;
 		state->tx_tuna[4] = (u8) freq;
 	} else if (state->dst_type == DST_TYPE_IS_CABLE) {
+		freq = freq / 1000;
 		state->tx_tuna[2] = (freq >> 16) & 0xff;
 		state->tx_tuna[3] = (freq >> 8) & 0xff;
 		state->tx_tuna[4] = (u8) freq;

--

#47 lore raw

PATCH 44/54 cinergyT2: remote control fixes

In reply to Johannes Stezenbach

IR RC fixes:
- EVIOCSKEYCODE is not supported by this driver, fix potential crash when it is used by not setting rc_input_dev->keycodesize
- fix key repeat handling (hopefully)
- reduce default poll internal to 50msec (necessary for key repeat handling)

 drivers/media/dvb/cinergyT2/Kconfig     |    2 
 drivers/media/dvb/cinergyT2/cinergyT2.c |   93 +++++++++++++++++++-------------
 2 files changed, 57 insertions(+), 38 deletions(-)
drivers/media/dvb/cinergyT2/Kconfig +1 -1
@@ -77,7 +77,7 @@ config DVB_CINERGYT2_ENABLE_RC_INPUT_DEV
 config DVB_CINERGYT2_RC_QUERY_INTERVAL
 	int "Infrared Remote Controller update interval [milliseconds]"
 	depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
-        default "100"
+        default "50"
 	help
 	  If you have a very fast-repeating remote control you can try lower
 	  values, for normal consumer receivers the default value should be
drivers/media/dvb/cinergyT2/cinergyT2.c +56 -37

161 lines not on this page · raw message

--

#22 lore raw

PATCH 20/54 frontend: cx24110: clean up timeout handling.

In reply to Johannes Stezenbach

Clean up timeout handling.

 drivers/media/dvb/frontends/cx24110.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/media/dvb/frontends/cx24110.c +9 -5
@@ -387,8 +387,9 @@ static int cx24110_set_voltage (struct d
 
 static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
 {
-	int rv, bit, i;
+	int rv, bit;
 	struct cx24110_state *state = fe->demodulator_priv;
+	unsigned long timeout;
 
 	if (burst == SEC_MINI_A)
 		bit = 0x00;
@@ -403,8 +404,9 @@ static int cx24110_diseqc_send_burst(str
 
 	rv = cx24110_readreg(state, 0x76);
 	cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit));
-	for (i = 500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40) ; )
-              ; /* wait for LNB ready */
+	timeout = jiffies + msecs_to_jiffies(100);
+	while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40))
+		; /* wait for LNB ready */
 
 	return 0;
 }
@@ -414,6 +416,7 @@ static int cx24110_send_diseqc_msg(struc
 {
 	int i, rv;
 	struct cx24110_state *state = fe->demodulator_priv;
+	unsigned long timeout;
 
 	for (i = 0; i < cmd->msg_len; i++)
 		cx24110_writereg(state, 0x79 + i, cmd->msg[i]);
@@ -427,8 +430,9 @@ static int cx24110_send_diseqc_msg(struc
 	rv = cx24110_readreg(state, 0x76);
 
 	cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3));
-	for (i=100; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);)
-		msleep(1); /* wait for LNB ready */
+	timeout = jiffies + msecs_to_jiffies(100);
+	while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40))
+		; /* wait for LNB ready */
 
 	return 0;
 }

--

#52 lore raw

PATCH 49/54 av7110: disable superflous firmware handshake

In reply to Johannes Stezenbach

Disable superflous firmware handshake.

 drivers/media/dvb/ttpci/av7110_hw.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/media/dvb/ttpci/av7110_hw.c +2 -0
@@ -41,6 +41,8 @@
 #include "av7110.h"
 #include "av7110_hw.h"
 
+#define _NOHANDSHAKE
+
 /****************************************************************************
  * DEBI functions
  ****************************************************************************/

--

#18 lore raw

PATCH 16/54 frontend: tda1004x: fix SNR reading

In reply to Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Fix SNR reading

 drivers/media/dvb/frontends/tda1004x.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/dvb/frontends/tda1004x.c +1 -2
@@ -1046,8 +1046,7 @@ static int tda1004x_read_snr(struct dvb_
 	tmp = tda1004x_read_byte(state, TDA1004X_SNR);
 	if (tmp < 0)
 		return -EIO;
-	if (tmp)
-		tmp = 255 - tmp;
+	tmp = 255 - tmp;
 
 	*snr = ((tmp << 8) | tmp);
 	dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr);

--

#23 lore raw

PATCH 21/54 frontend: stv0297: QAM128 tuning improvement

In reply to Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

while investigating the QAM_128-issue with the stv0297-driver for the Cablestar (which is not the same as the one in dvb-kernel CVS, yet), I fixed it, not by increasing the timeout, but by disabling the corner-detection for QAM_128 and higher.

This patch has been tested on dvb-kernel cvs, and has been reported to work by multiple users. Some cards still need timeout increase on top of this patch. This will be addressed later.

 drivers/media/dvb/frontends/stv0297.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/dvb/frontends/stv0297.c +7 -1
@@ -606,7 +606,13 @@ static int stv0297_set_frontend(struct d
 	stv0297_set_inversion(state, inversion);
 
 	/* kick off lock */
-	stv0297_writereg_mask(state, 0x88, 0x08, 0x08);
+	/* Disable corner detection for higher QAMs */
+	if (p->u.qam.modulation == QAM_128 ||
+		p->u.qam.modulation == QAM_256)
+		stv0297_writereg_mask(state, 0x88, 0x08, 0x00);
+	else
+		stv0297_writereg_mask(state, 0x88, 0x08, 0x08);
+
 	stv0297_writereg_mask(state, 0x5a, 0x20, 0x00);
 	stv0297_writereg_mask(state, 0x6a, 0x01, 0x01);
 	stv0297_writereg_mask(state, 0x43, 0x40, 0x40);

--

#33 lore raw

PATCH 30/54 usb: white space cleanup

In reply to Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

white space cleanup

 drivers/media/dvb/dvb-usb/vp7045.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/dvb/dvb-usb/vp7045.c +2 -3
@@ -164,7 +164,6 @@ static int vp7045_read_eeprom(struct dvb
 	return 0;
 }
 
-
 static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
 {
 	return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR);
@@ -256,9 +255,9 @@ static struct dvb_usb_properties vp7045_
 static struct usb_driver vp7045_usb_driver = {
 	.owner		= THIS_MODULE,
 	.name		= "dvb_usb_vp7045",
-	.probe 		= vp7045_usb_probe,
+	.probe		= vp7045_usb_probe,
 	.disconnect = dvb_usb_device_exit,
-	.id_table 	= vp7045_usb_table,
+	.id_table	= vp7045_usb_table,
 };
 
 /* module stuff */

--

#39 lore raw

PATCH 36/54 Nebula DigiTV nxt6000 fix

In reply to Johannes Stezenbach

From: Stuart Auchterlonie <[email protected]>

Fix bug in Nebula DigiTV frontend detection for nxt6000.

 drivers/media/dvb/bt8xx/dvb-bt8xx.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/dvb/bt8xx/dvb-bt8xx.c +3 -1
@@ -574,8 +574,10 @@ static void frontend_init(struct dvb_bt8
 
 		/* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
 		card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
-		if (card->fe != NULL)
+		if (card->fe != NULL) {
 			dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
+			break;
+		}
 
 		/* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
 		digitv_alps_tded4_reset(card);

--

#26 lore raw

Re: [DVB patch 23/54] usb: add TwinhanDTV StarBox support

In reply to Johannes Stezenbach
Quoted 6 lines · Johannes Stezenbach

From: Patrick Boettcher <[email protected]>

Add driver for the TwinhanDTV StarBox and clones.

Thanks to Ralph Metzler for his initial work on this box and thanks to Twinhan for their support.

<snip>

Quoted 2 lines
drivers/media/dvb/dvb-usb/vp702x-fe.c 2005-09-04 22:28:15.000000000 +0200 renamed from dev/null 1970-01-01 00:00:00.000000000 +0000 +0 -0

<snip>

drivers/media/dvb/dvb-usb/vp702x-fe.c 2005-09-04 22:28:15.000000000 +0200

Quoted 11 lines
drivers/media/dvb/dvb-usb/vp702x-fe.c 2005-09-04 22:28:15.000000000 +0200 renamed from dev/null 1970-01-01 00:00:00.000000000 +0000 +11 -0
+static int vp702x_fe_refresh_state(struct vp702x_fe_state *st)
+{
+       u8 buf[10];
+       if (time_after(jiffies,st->next_status_check)) {
+               vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10);
+
+               st->lock = buf[4];
+               vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1);
+               vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1);
+
+               st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;

Should this be

st->next_status_check = jiffies + msecs_to_jiffies(st->status_check_interval);

?

Thanks,
Nish

#15 lore raw

Re: [DVB patch 14/54] frontend: s5h1420: fixes

In reply to Johannes Stezenbach
Quoted 3 lines · Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Misc. fixes.

<snip>

drivers/media/dvb/frontends/s5h1420.c 2005-09-04 22:28:04.000000000 +0200

Quoted 2 lines
drivers/media/dvb/frontends/s5h1420.c 2005-09-04 22:28:04.000000000 +0200 renamed from drivers/media/dvb/frontends/s5h1420.c 2005-09-04 22:24:24.000000000 +0200 +0 -0

@@ -138,16 +146,17 @@ static int s5h1420_send_master_cmd (stru

<snip>

Quoted 2 lines
        /* wait for transmission to complete */
        timeout = jiffies + ((100*HZ) / 1000);

<snip>

drivers/media/dvb/frontends/s5h1420.c 2005-09-04 22:28:04.000000000 +0200 static int s5h1420_send_burst (struct dv · line 249

Quoted 6 lines
drivers/media/dvb/frontends/s5h1420.c 2005-09-04 22:28:04.000000000 +0200 renamed from drivers/media/dvb/frontends/s5h1420.c 2005-09-04 22:24:24.000000000 +0200 +1 -1
@@ -236,7 +246,7 @@ static int s5h1420_send_burst (struct dv
        s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08);
 
        /* wait for transmission to complete */
-       timeout = jiffies + ((20*HZ) / 1000);
+       timeout = jiffies + ((100*HZ) / 1000);

Should these be

timeout = jiffies + msecs_to_jiffies(100);

?

Thanks,
Nish

#64 lore raw

Re: [DVB patch 54/54] ttusb-budget: use time_after_eq()

In reply to Nish Aravamudan
Quoted 27 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:

drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c static void ttusb_iso_irq(struct urb *ur · line 784

Quoted 13 lines · Johannes Stezenbach
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +3 -2
-static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid;
+static int numpkt = 0, numts, numstuff, numsec, numinvalid;
+static unsigned long lastj;
 
 static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
                           int len)
@@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *ur
                        u8 *data;
                        int len;
                        numpkt++;
-                       if ((jiffies - lastj) >= HZ) {
+                       if (time_after_eq(jiffies, lastj + HZ)) {

I think you actually want:

static void ttusb_iso_irq(....)

{
     unsigned long lastj;

     ...

     lastj = jiffies + HZ;
     if (time_after_eq(jiffies, lastj)) {
          ...
Quoted 3 lines

}

The current code doesn't assign jiffies to lastj at any point that I see.

The code in question is used to print a one-per-second debug output, and lastj is assigned after every print.

I agree that it's ugly, though.

Johannes

#56 lore raw

Re: [DVB patch 51/54] ttpci: av7110: RC5+ remote control support

In reply to Nish Aravamudan
Quoted 14 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:

drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:31:00.000000000 +0200 line 12

Quoted 10 lines · Johannes Stezenbach
drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:31:00.000000000 +0200 renamed from drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:03:40.000000000 +0200 +2 -1
@@ -7,16 +7,16 @@
 #include <asm/bitops.h>
 
 #include "av7110.h"
+#include "av7110_hw.h"
 
-#define UP_TIMEOUT (HZ/4)
+#define UP_TIMEOUT (HZ*7/25)

Should this be

Quoted 7 lines

#define UP_TIMEOUT msecs_to_jiffies(280)

or

#define UP_TIMEOUT (7*msecs_to_jiffies(40)

?

I agree it's nicer to read, but AFAIK not required for correctness? If so, then we'll fix those up in linuxtv.org CVS and submit cleanup patches later.

Thanks for your comments.

Johannes

#65 lore raw

Re: [DVB patch 54/54] ttusb-budget: use time_after_eq()

In reply to Johannes Stezenbach
Quoted 28 lines · Johannes Stezenbach
Quoted 27 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:

drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c static void ttusb_iso_irq(struct urb *ur · line 784

Quoted 13 lines · Johannes Stezenbach
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +3 -2
-static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid;
+static int numpkt = 0, numts, numstuff, numsec, numinvalid;
+static unsigned long lastj;
 
 static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
                           int len)
@@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *ur
                        u8 *data;
                        int len;
                        numpkt++;
-                       if ((jiffies - lastj) >= HZ) {
+                       if (time_after_eq(jiffies, lastj + HZ)) {

I think you actually want:

static void ttusb_iso_irq(....)

{
     unsigned long lastj;

     ...

     lastj = jiffies + HZ;
     if (time_after_eq(jiffies, lastj)) {
          ...
Quoted 6 lines
Quoted 3 lines

}

The current code doesn't assign jiffies to lastj at any point that I see.

The code in question is used to print a one-per-second debug output, and lastj is assigned after every print.

Ah yes, didn't see that in the current code, sorry for that noise. Still, lastj is local to ttusb_iso_irq(), right?

Quoted 1 line

I agree that it's ugly, though.

Fair enough :)

Thanks,
Nish

#57 lore raw

Re: [DVB patch 51/54] ttpci: av7110: RC5+ remote control support

In reply to Johannes Stezenbach
Quoted 19 lines · Johannes Stezenbach
Quoted 18 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:

drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:31:00.000000000 +0200 line 12

Quoted 10 lines · Johannes Stezenbach
drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:31:00.000000000 +0200 renamed from drivers/media/dvb/ttpci/av7110_ir.c 2005-09-04 22:03:40.000000000 +0200 +2 -1
@@ -7,16 +7,16 @@
 #include <asm/bitops.h>
 
 #include "av7110.h"
+#include "av7110_hw.h"
 
-#define UP_TIMEOUT (HZ/4)
+#define UP_TIMEOUT (HZ*7/25)

Should this be

#define UP_TIMEOUT msecs_to_jiffies(280)

or

Quoted 7 lines
Quoted 3 lines

#define UP_TIMEOUT (7*msecs_to_jiffies(40)

?

I agree it's nicer to read, but AFAIK not required for correctness? If so, then we'll fix those up in linuxtv.org CVS and submit cleanup patches later.

Yeah, it's correct with the three current values of HZ (100, 250 and 1000), but if you try a not-so-clean value (like Con did with 864, or something), you might run into rounding issues. msecs_to_jiffies() should take care of them (or will be a single point to do so eventually).

Thanks,
Nish

#66 lore raw

Re: [DVB patch 54/54] ttusb-budget: use time_after_eq()

In reply to Nish Aravamudan
Quoted 16 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:
Quoted 15 lines · Johannes Stezenbach
Quoted 13 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:

drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c static void ttusb_handle_sec_data(struct · line 575

Quoted 5 lines · Johannes Stezenbach
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +2 -1
-static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid;
+static int numpkt = 0, numts, numstuff, numsec, numinvalid;
+static unsigned long lastj;

I think you actually want:

static void ttusb_iso_irq(....)

{
     unsigned long lastj;
Quoted 5 lines
Quoted 2 lines

The code in question is used to print a one-per-second debug output, and lastj is assigned after every print.

Ah yes, didn't see that in the current code, sorry for that noise. Still, lastj is local to ttusb_iso_irq(), right?

Yes, but it needs to be static.

Johannes

#58 lore raw

Re: [DVB patch 51/54] ttpci: av7110: RC5+ remote control support

In reply to Nish Aravamudan
Quoted 14 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:
Quoted 9 lines · Johannes Stezenbach
Quoted 7 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:

drivers/media/dvb/ttpci/av7110_ir.c line 12

Quoted 3 lines · Johannes Stezenbach
drivers/media/dvb/ttpci/av7110_ir.c +1 -1
-#define UP_TIMEOUT (HZ/4)
+#define UP_TIMEOUT (HZ*7/25)

#define UP_TIMEOUT msecs_to_jiffies(280)
#define UP_TIMEOUT (7*msecs_to_jiffies(40)

Quoted 3 lines

I agree it's nicer to read, but AFAIK not required for correctness? If so, then we'll fix those up in linuxtv.org CVS and submit cleanup patches later.

Quoted 5 lines

Yeah, it's correct with the three current values of HZ (100, 250 and 1000), but if you try a not-so-clean value (like Con did with 864, or something), you might run into rounding issues. msecs_to_jiffies() should take care of them (or will be a single point to do so eventually).

Well, if msecs_to_jiffies() is the new way of specifying timeouts we'd have a lot more to fix up in our tree. But something like a remote control key-up timeout doesn't need much precision. Generally I see nothing wrong with HZ/4, but something like HZ*20/1000 could be problematic with small or odd HZ values.

Agreed? Or is it desired that people generally use msecs_to_jiffies()?

Johannes

#59 lore raw

Re: [DVB patch 51/54] ttpci: av7110: RC5+ remote control support

Quoted 21 lines · Johannes Stezenbach
Quoted 14 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:
Quoted 9 lines · Johannes Stezenbach
Quoted 7 lines · On Sun, Sep 04, 2005 Nish Aravamudan wrote:

drivers/media/dvb/ttpci/av7110_ir.c line 12

Quoted 3 lines · Johannes Stezenbach
drivers/media/dvb/ttpci/av7110_ir.c +1 -1
-#define UP_TIMEOUT (HZ/4)
+#define UP_TIMEOUT (HZ*7/25)

#define UP_TIMEOUT msecs_to_jiffies(280)
#define UP_TIMEOUT (7*msecs_to_jiffies(40)

Quoted 3 lines

I agree it's nicer to read, but AFAIK not required for correctness? If so, then we'll fix those up in linuxtv.org CVS and submit cleanup patches later.

Quoted 5 lines

Yeah, it's correct with the three current values of HZ (100, 250 and 1000), but if you try a not-so-clean value (like Con did with 864, or something), you might run into rounding issues. msecs_to_jiffies() should take care of them (or will be a single point to do so eventually).

Quoted 5 lines

Well, if msecs_to_jiffies() is the new way of specifying timeouts we'd have a lot more to fix up in our tree. But something like a remote control key-up timeout doesn't need much precision. Generally I see nothing wrong with HZ/4, but something like HZ*20/1000 could be problematic with small or odd HZ values.

This discussion comes up every time ;) HZ/4 rounds incorrectly (depends on your perspective, I guess) with HZ=250.

Quoted 1 line

Agreed? Or is it desired that people generally use msecs_to_jiffies()?

I agree, generally it's ok, as timeouts aren't meant to be precise. I, personally, am converting code over to msecs_to_jiffies() as I come to it, just so that the conversions are consistent (a number in the tree were not, not that yours are) and basically self-commented. And, like I mentioned, they are automatically rounded correctly with "strange" values of HZ.

The changes I mentioned in your patchset are generally not critical, but just comments and my own preferences.

Thanks,
Nish

#16 lore raw

Re: [DVB patch 14/54] frontend: s5h1420: fixes

In reply to Nish Aravamudan
Quoted 25 lines · Nish Aravamudan
Quoted 3 lines · Johannes Stezenbach

From: Andrew de Quincey <[email protected]>

Misc. fixes.

<snip>

Quoted 4 lines

--- linux-2.6.13-git4.orig/drivers/media/dvb/frontends/s5h1420.c

2005-09-04 22:24:24.000000000 +0200 +++

linux-2.6.13-git4/drivers/media/dvb/frontends/s5h1420.c 2005-09-04
22:28:04.000000000 +0200

(quoted diff) +0 -0
@@ -138,16 +146,17 @@ static int s5h1420_send_master_cmd (stru
 
<snip>
Quoted 3 lines
        /* wait for transmission to complete */
        timeout = jiffies + ((100*HZ) / 1000);

<snip>

Quoted 4 lines
(quoted diff) +0 -0
@@ -236,7 +246,7 @@ static int s5h1420_send_burst (struct dv
        s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) |
 0x08);
 
Quoted 7 lines

drivers/media/dvb/frontends/s5h1420.c static int s5h1420_send_burst (struct dv · line 249

Quoted 3 lines
drivers/media/dvb/frontends/s5h1420.c +1 -1
        /* wait for transmission to complete */
-       timeout = jiffies + ((20*HZ) / 1000);
+       timeout = jiffies + ((100*HZ) / 1000);

Should these be

timeout = jiffies + msecs_to_jiffies(100);

Yes, you're right.