Re: [PATCH] m920x for LifeView TV Walker Twin

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

 



On Tue, 20 Mar 2007 17:03:58 +0200
Aapo Tahkola <aet@xxxxxxxxxxxxxx> wrote:

> On Wed, 21 Mar 2007 00:33:46 +1100
> Nick Andrew <nick-linuxtv@xxxxxxxxxxxxxxx> wrote:
> 
> > Here's my patch so far.
> > 
> > Two remaining problems:
> > 
> > 
> > 1 - device is probed twice and I end up with 4 /dev/dvb adapters
> > rather than two. The reason is that the USB configuration defines
> > two interfaces, so the probe function is called once for each
> > interface.
> > 
> > I don't yet know what to do about this. Presumably the right
> > solution is to configure tuner/demod 0 on the first call to
> > m920x_probe(), and tuner/demod 1 on the second call. But I don't
> > know how to achieve this because all the configuring happens inside
> > dvb_usb_device_init() and it's mostly hardcoded inside the @adapter
> > array in dvb_usb_device_properties.
> > 
> > I wrote a quick workaround (which _isn't_ in this patch) which
> > detects if it is probing bInterface == 1, and if so then returns
> > without probing, and that proves my analysis (only 2 adapters
> > are created under /dev/dvb).
> > 
> > 
> > 2 - I haven't been able to stream anything with 'dvbstream',
> > although kaffeine works fine. I expect this is not going to
> > prevent acceptance of my patch.
> > 
> > 
> > description:
> > m920x: add support for LifeView TV Walker Twin
> > 
> > From: Nick Andrew <nick@xxxxxxxxxxxxxxx>
> > 
> > Add support for "LifeView TV Walker Twin" (USB IDs 10fd:0514,
> > 10fd:0513)
> > 
> > Signed-off-by: Nick Andrew <nick@xxxxxxxxxxxxxxx>
> > 
> > Nick.
> 
> Nice job!
> 
> Signed-off-by: Aapo Tahkola <aet@xxxxxxxxxxxxxx>
> 
> Add comments to describe different sticks rc return values.
> These might conflict with future hardware.
> 
> Signed-off-by: Aapo Tahkola <aet@xxxxxxxxxxxxxx>
> 

This patch *might* make pid filtering work on your second adapter.

Can you test it?
You should be able to enable pid filters by rmmoding ehci_hdc(usb 2.0
driver). That should force your device into usb 1.0 mode and thus
enable hardware pid filters.

-- 
Aapo Tahkola
diff -r e37cde12c5d6 linux/drivers/media/dvb/dvb-usb/m920x.c
--- a/linux/drivers/media/dvb/dvb-usb/m920x.c	Tue Mar 20 17:04:33 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-usb/m920x.c	Tue Mar 20 17:43:35 2007 +0200
@@ -63,6 +63,9 @@ static struct dvb_usb_rc_key tvwalkertwi
 	{ 0x0, 0x1e, KEY_VOLUMEUP },
 };
 
+static int m9206_set_filter(struct dvb_usb_device *d, int type, int idx,
+			    int pid);
+
 static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\
 			     u16 index, void *data, int size)
 {
@@ -98,7 +101,8 @@ static inline int m9206_write(struct usb
 
 static int m9206_init(struct dvb_usb_device *d, struct m9206_inits *rc_seq)
 {
-	int ret = 0;
+	int ret = 0, i, epi;
+	int adap_enabled[M9206_MAX_ADAPTERS] = { 0 };
 
 	/* Remote controller init. */
 	if (d->props.rc_query) {
@@ -113,6 +117,26 @@ static int m9206_init(struct dvb_usb_dev
 		}
 	
 		deb_rc("Initialising remote control success\n");
+	}
+	
+	for (i = 0; i < d->props.num_adapters; i++) {
+		epi = d->adapter[i].props.stream.endpoint - 0x81;
+
+		if (epi < 0 || epi >= M9206_MAX_ADAPTERS)
+			printk(KERN_INFO "m920x: Unexpected adapter endpoint!\n");
+			
+		adap_enabled[epi] = 1;
+	}
+
+	for (i = 0; i < M9206_MAX_ADAPTERS; i++) {
+		if (adap_enabled[i])
+			continue;
+		
+		if ((ret = m9206_set_filter(d, 0x81 + i, 0, 0x0)) != 0)
+			return ret;
+
+		if ((ret = m9206_set_filter(d, 0x81 + i, 0, 0x02f5)) != 0)
+			return ret;
 	}
 
 	return ret;
@@ -244,7 +268,7 @@ static struct i2c_algorithm m9206_i2c_al
 };
 
 
-static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx,
+static int m9206_set_filter(struct dvb_usb_device *d, int type, int idx,
 			    int pid)
 {
 	int ret = 0;
@@ -254,10 +278,10 @@ static int m9206_set_filter(struct dvb_u
 
 	pid |= 0x8000;
 
-	if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
+	if ((ret = m9206_write(d->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
 		return ret;
 
-	if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
+	if ((ret = m9206_write(d->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
 		return ret;
 
 	return ret;
@@ -266,23 +290,21 @@ static int m9206_update_filters(struct d
 static int m9206_update_filters(struct dvb_usb_adapter *adap)
 {
 	struct m9206_state *m = adap->dev->priv;
-	int enabled = m->filtering_enabled;
+	int enabled = m->filtering_enabled[adap->id];
 	int i, ret = 0, filter = 0;
+	int ep = adap->props.stream.endpoint;
 
 	for (i = 0; i < M9206_MAX_FILTERS; i++)
-		if (m->filters[i] == 8192)
+		if (m->filters[adap->id][i] == 8192)
 			enabled = 0;
 
 	/* Disable all filters */
-	if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0)
+	if ((ret = m9206_set_filter(adap->dev, ep, 1, enabled)) != 0)
 		return ret;
 
 	for (i = 0; i < M9206_MAX_FILTERS; i++)
-		if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0)
+		if ((ret = m9206_set_filter(adap->dev, ep, i + 2, 0)) != 0)
 			return ret;
-
-	if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0)
-		return ret;
 
 	/* Set */
 	if (enabled) {
@@ -290,16 +312,13 @@ static int m9206_update_filters(struct d
 			if (m->filters[i] == 0)
 				continue;
 
-			if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0)
+			if ((ret = m9206_set_filter(adap->dev, ep, filter + 2, m->filters[adap->id][i])) != 0)
 				return ret;
 
 			filter++;
 		}
 	}
 
-	if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0)
-		return ret;
-
 	return ret;
 }
 
@@ -307,7 +326,7 @@ static int m9206_pid_filter_ctrl(struct 
 {
 	struct m9206_state *m = adap->dev->priv;
 
-	m->filtering_enabled = onoff ? 1 : 0;
+	m->filtering_enabled[adap->id] = onoff ? 1 : 0;
 
 	return m9206_update_filters(adap);
 }
@@ -317,7 +336,7 @@ static int m9206_pid_filter(struct dvb_u
 {
 	struct m9206_state *m = adap->dev->priv;
 
-	m->filters[index] = onoff ? pid : 0;
+	m->filters[adap->id][index] = onoff ? pid : 0;
 
 	return m9206_update_filters(adap);
 }
diff -r e37cde12c5d6 linux/drivers/media/dvb/dvb-usb/m920x.h
--- a/linux/drivers/media/dvb/dvb-usb/m920x.h	Tue Mar 20 17:04:33 2007 +0200
+++ b/linux/drivers/media/dvb/dvb-usb/m920x.h	Tue Mar 20 17:07:21 2007 +0200
@@ -18,6 +18,7 @@
 #define M9206_FW	0x30
 
 #define M9206_MAX_FILTERS 8
+#define M9206_MAX_ADAPTERS 2
 
 /*
 sequences found in logs:
@@ -60,8 +61,8 @@ response to a write, is unknown.
 */
 
 struct m9206_state {
-	u16 filters[M9206_MAX_FILTERS];
-	int filtering_enabled;
+	u16 filters[M9206_MAX_ADAPTERS][M9206_MAX_FILTERS];
+	int filtering_enabled[M9206_MAX_ADAPTERS];
 	int rep_count;
 };
 
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux