public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
       [not found]         ` <472A0CC2.8040509@free.fr>
@ 2008-04-23 19:39           ` Thierry Merle
       [not found]             ` <16781.192.100.124.220.1209712634.squirrel@ncircle.nullnet.fi>
  0 siblings, 1 reply; 21+ messages in thread
From: Thierry Merle @ 2008-04-23 19:39 UTC (permalink / raw)
  To: Tomi Orava; +Cc: linux-dvb

Thierry Merle a écrit :
> Tested the attached patch on my NSLU2 (266MHz ARM architecture, 32Mb
> RAM), with a debian-arm 2.6.22 (sid) installed.
> The dvb stream is OK and the driver looks simpler (less code and
> modularized).
> 2 minor notes:
> - you should not put ² for cinergyT2 but '2' in the file headers. It
> looks like that on my system: "Cinergy T�" (UTF8 or something like that).
> - your patch is missing a newline at the end. This causes an error when
> applied:
> "patch unexpectedly ends in middle of line
> patch: **** malformed patch at line 1017:  "
> 
> Thanks for this enhancement.
> Cheers,
> Thierry

Hi Tomi,
what is the status of this driver enhancement?
Is there a blocking issue to integrate it in the v4l-dvb tree?
If I can help you to solve any issue, please tell me.
Thanks
Thierry

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
       [not found]             ` <16781.192.100.124.220.1209712634.squirrel@ncircle.nullnet.fi>
@ 2008-05-02 17:08               ` Thierry Merle
       [not found]                 ` <30354.192.100.124.220.1209969477.squirrel@ncircle.nullnet.fi>
  0 siblings, 1 reply; 21+ messages in thread
From: Thierry Merle @ 2008-05-02 17:08 UTC (permalink / raw)
  To: Tomi Orava; +Cc: linux-dvb

Tomi Orava a écrit :
> Hi Thierry,
>
>   
>> what is the status of this driver enhancement?
>> Is there a blocking issue to integrate it in the v4l-dvb tree?
>> If I can help you to solve any issue, please tell me.
>>     
>
> I don't think there should be any blocking issues with this driver.
> The remote controller functionality could be improved to work better
> with LIRC's irrecord utility, but that's about all for now.
>
> Currently it's more or less a question of what I have to do in order to
> get the driver included into the official tree ?
>   
Well, I see some issues after taking a closer look at your driver:
1- checkpatch.pl raises errors: 90 errors, 53 warnings, 995 lines checked
2- there is a compilation error (I applied the patch on the latest
v4l-dvb tree):
cinergyT2-core.c: In function 'cinergyt2_usb_probe':
cinergyT2-core.c:138: error: too few arguments to function
'dvb_usb_device_init'
3- you should replace the existing driver, not proposing a different
driver. I mean, patch directly
linux/drivers/media/dvb/cinergyT2/cinergyT2.c.

Furthermore, I have some questions:
- is there a way to use the dvb-usb-remote module? This in order to get
rid of cinergyT2-remote.c
- so, renaming cinergyT2-core.c to cinergyT2.c would be correct?
- stream buffer count was set to 32 in the old driver and you set it to
5, why this change? It works perfectly with 5 and consumes less memory
so if this is the reason I fully agree!

I think the best way is to rework your patch and fix these issues; I can
help you if you want.
Then I will commit that in a particular tree and ask for pushing it to
the official tree.

> Regards,
> Tomi Orava
>   
Cheers,
Thierry

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
       [not found]                 ` <30354.192.100.124.220.1209969477.squirrel@ncircle.nullnet.fi>
@ 2008-05-05 19:57                   ` Thierry Merle
  2008-05-07 18:49                     ` Tomi Orava
  2008-05-08 20:47                     ` Ingo Peukes
  0 siblings, 2 replies; 21+ messages in thread
From: Thierry Merle @ 2008-05-05 19:57 UTC (permalink / raw)
  To: Tomi Orava; +Cc: linux-dvb

Tomi Orava a écrit :
> Hi,
> 
>> Well, I see some issues after taking a closer look at your driver:
>> 1- checkpatch.pl raises errors: 90 errors, 53 warnings, 995 lines checked
>> 2- there is a compilation error (I applied the patch on the latest
>> v4l-dvb tree):
>> cinergyT2-core.c: In function 'cinergyt2_usb_probe':
>> cinergyT2-core.c:138: error: too few arguments to function
>> 'dvb_usb_device_init'
>> 3- you should replace the existing driver, not proposing a different
>> driver. I mean, patch directly
>> linux/drivers/media/dvb/cinergyT2/cinergyT2.c.
> 
> Ok, these are easy to fix.
> 
>> Furthermore, I have some questions:
>> - is there a way to use the dvb-usb-remote module? This in order to get
>> rid of cinergyT2-remote.c
> 
> No, due to the fact that the dvb-usb.h defines a struct which is too
> limited for the Cinergy T2 remote controller handling. If you compare
> the original struct dvb_usb_rc_key to the modified one:
> 
> Original:
> 
> struct dvb_usb_rc_key {
>         u8 custom,data; <--------------------
>         u32 event;
> };
> 
> Cinergy T2 send U32 remote controller:
> 
> struct cinergyt2_rc_key {
> 	u32 custom; <--------------
> 	u32 data;   <--------------
> 	u32 event;
> };
> 
> Obviously I could get rid of the whole cinergyT2-remote.c file
> if the dvb-usb defined struct could be widened.
> 
Indeed, but in the current structure I am not sure that all the bits of the u32 data is useful.
For example:
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfe01eb04,	KEY_POWER },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfd02eb04,	KEY_1 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfc03eb04,	KEY_2 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfb04eb04,	KEY_3 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfa05eb04,	KEY_4 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf906eb04,	KEY_5 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf807eb04,	KEY_6 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf708eb04,	KEY_7 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf609eb04,	KEY_8 },
	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf50aeb04,	KEY_9 },
I see for example that in the u32 0xfe01eb04, first and second bytes are linked (0xfe + 0x01 = 0xff)
It works with all others: 0xfd02eb04 -> 0xfd + 0x02 = 0xff, ...
Furthermore the last 2 bytes are constant (0xeb04).
So the sole significant byte is the second: 0x01, 0x02, ...
I will try to do something around that.

>> - so, renaming cinergyT2-core.c to cinergyT2.c would be correct?
> 
> Hmm, if I remember correctly there was some sort of clash with the filenames
> and the actual compiled driver.
In fact if you remove the old driver (by resolving the issue #3), I suggested to name the cinergyT2-core.c cinergyT2.c but there is no obligation. 
> 
>> - stream buffer count was set to 32 in the old driver and you set it to
>> 5, why this change? It works perfectly with 5 and consumes less memory
>> so if this is the reason I fully agree!
> 
> As the old existing driver is handling the communication differently
> also the buffer count values are different. When I began writing the
> new version of the CinergyT2 driver I did some trials and based on the
> helpful comments & test results the value of 5 has been there.
> 
OK
>> I think the best way is to rework your patch and fix these issues; I can
>> help you if you want.
>> Then I will commit that in a particular tree and ask for pushing it to
>> the official tree.
> 
> Sure, I'll fix the reported errors and get back to you.
> 
Thanks
> Regards,
> Tomi Orava
> 
Cheers,
Thierry

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-05 19:57                   ` Thierry Merle
@ 2008-05-07 18:49                     ` Tomi Orava
  2008-05-07 22:21                       ` Antti Palosaari
  2008-05-08 21:18                       ` Thierry Merle
  2008-05-08 20:47                     ` Ingo Peukes
  1 sibling, 2 replies; 21+ messages in thread
From: Tomi Orava @ 2008-05-07 18:49 UTC (permalink / raw)
  To: Thierry Merle; +Cc: linux-dvb

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]


Hi,

>>> Well, I see some issues after taking a closer look at your driver:
>>> 1- checkpatch.pl raises errors: 90 errors, 53 warnings, 995 lines checked
>>> 2- there is a compilation error (I applied the patch on the latest
>>> v4l-dvb tree):
>>> cinergyT2-core.c: In function 'cinergyt2_usb_probe':
>>> cinergyT2-core.c:138: error: too few arguments to function
>>> 'dvb_usb_device_init'
>>> 3- you should replace the existing driver, not proposing a different
>>> driver. I mean, patch directly
>>> linux/drivers/media/dvb/cinergyT2/cinergyT2.c.

I did some cleanups pointed by the checkpach.pl script.
However, I did not replace the original Cinergy T2 driver
as I think that this new driver should be located in the
very same directory as the rest of the usb-dvb drivers.

The current patch is against the v4l-dvb tree.

Regards,
Tomi Orava

[-- Attachment #2: CinergyT2-V7.patch --]
[-- Type: text/x-patch, Size: 30315 bytes --]

diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/Kconfig
--- a/linux/drivers/media/dvb/dvb-usb/Kconfig	Tue May 06 11:09:01 2008 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/Kconfig	Wed May 07 22:34:53 2008 +0300
@@ -241,3 +241,11 @@ config DVB_USB_AF9005_REMOTE
 	  Say Y here to support the default remote control decoding for the
 	  Afatech AF9005 based receiver.
 
+config 	DVB_USB_CINERGY_T2
+	tristate "Alternative driver for Terratec CinergyT2/qanu USB2 DVB-T receiver"
+	depends on DVB_USB
+	help
+	  Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers
+
+	  Say Y if you own such a device and want to use it.
+
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/Makefile
--- a/linux/drivers/media/dvb/dvb-usb/Makefile	Tue May 06 11:09:01 2008 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/Makefile	Wed May 07 22:34:53 2008 +0300
@@ -61,6 +61,10 @@ dvb-usb-af9005-remote-objs = af9005-remo
 dvb-usb-af9005-remote-objs = af9005-remote.o
 obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o
 
+dvb-usb-cinergyT2-objs = cinergyT2-core.o cinergyT2-fe.o cinergyT2-remote.o
+obj-$(CONFIG_DVB_USB_CINERGY_T2) += dvb-usb-cinergyT2.o
+
+
 EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
 # due to tuner-xc3028
 EXTRA_CFLAGS += -Idrivers/media/common/tuners
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c	Wed May 07 22:34:53 2008 +0300
@@ -0,0 +1,235 @@
+/*
+ * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
+ *
+ * Based on the dvb-usb-framework code and the
+ * original Terratec Cinergy T2 driver by:
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *		    Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "cinergyT2.h"
+
+
+/* debug */
+int dvb_usb_cinergyt2_debug;
+int disable_remote;
+
+module_param_named(debug, dvb_usb_cinergyt2_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info, xfer=2, rc=4 "
+		"(or-able)).");
+
+module_param_named(disable_remote, disable_remote, int, 0644);
+MODULE_PARM_DESC(disable_remote, "Disable remote controller support (int)");
+
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+
+/* We are missing a release hook with usb_device data */
+struct dvb_usb_device *cinergyt2_usb_device;
+
+static struct dvb_usb_device_properties cinergyt2_properties;
+
+
+/* slightly modified version of dvb_usb_generic_rw -function */
+
+int cinergyt2_cmd(struct dvb_usb_device *d, char *wbuf, int wlen,
+			char *rbuf, int rlen, int delay_ms)
+{
+	int actlen, ret = -ENOMEM;
+
+	if (d->props.generic_bulk_ctrl_endpoint == 0) {
+		err("endpoint for generic control not specified.");
+		return -EINVAL;
+	}
+
+	if (wbuf == NULL || wlen == 0)
+		return -EINVAL;
+
+	ret = mutex_lock_interruptible(&d->usb_mutex);
+	if (ret)
+		return ret;
+
+	deb_xfer(">>> ");
+	debug_dump(wbuf, wlen, deb_xfer);
+
+	ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
+				d->props.generic_bulk_ctrl_endpoint),
+				wbuf, wlen, &actlen, 2000);
+
+	if (ret)
+		deb_rc("bulk message failed: %d (%d/%d)", ret, wlen, actlen);
+	else
+		ret = actlen != wlen ? -1 : 0;
+
+	/* an answer is expected, and no error before */
+	if (!ret && rbuf && rlen) {
+		if (delay_ms)
+			msleep(delay_ms);
+
+		ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev,
+					d->props.generic_bulk_ctrl_endpoint),
+					rbuf, rlen, &actlen, 2000);
+		if (ret)
+			deb_rc("recv bulk message failed: %d", ret);
+		else {
+			deb_xfer("<<< ");
+			debug_dump(rbuf, actlen, deb_xfer);
+			ret = actlen;
+		}
+	}
+	mutex_unlock(&d->usb_mutex);
+	return ret;
+}
+
+static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable)
+{
+	char buf [] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
+	char result[64];
+	return cinergyt2_cmd(adap->dev, buf, sizeof(buf), result,
+				sizeof(result), 0);
+}
+
+static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable)
+{
+	char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 };
+	char state[3];
+	return cinergyt2_cmd(d, buf, sizeof(buf), state, sizeof(state), 0);
+}
+
+static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
+{
+	char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION };
+	char state[3];
+	int ret;
+
+	adap->fe = cinergyt2_fe_attach(adap->dev);
+
+	ret = cinergyt2_cmd(adap->dev, query, sizeof(query), state,
+				sizeof(state), 0);
+	if (ret < 0) {
+		deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep "
+			"state info\n");
+	}
+
+	/* Copy this pointer as we are gonna need it in the release phase */
+	cinergyt2_usb_device = adap->dev;
+
+	ret = cinergyt2_remote_init(adap->dev);
+	if (ret)
+		err("could not initialize remote control.");
+
+	return 0;
+}
+
+static int cinergyt2_usb_probe(struct usb_interface *intf,
+				const struct usb_device_id *id)
+{
+	return dvb_usb_device_init(intf, &cinergyt2_properties,
+					THIS_MODULE, NULL, adapter_nr);
+}
+
+
+static struct usb_device_id cinergyt2_usb_table [] = {
+	{ USB_DEVICE(USB_VID_TERRATEC, 0x0038) },
+	{ 0 }
+};
+
+MODULE_DEVICE_TABLE(usb, cinergyt2_usb_table);
+
+static struct dvb_usb_device_properties cinergyt2_properties = {
+
+	.num_adapters = 1,
+	.adapter = {
+		{
+			.streaming_ctrl   = cinergyt2_streaming_ctrl,
+			.frontend_attach  = cinergyt2_frontend_attach,
+
+			/* parameter for the MPEG2-data transfer */
+			.stream = {
+				.type = USB_BULK,
+				.count = 5,
+				.endpoint = 0x02,
+				.u = {
+					.bulk = {
+						.buffersize = 512,
+					}
+				}
+			},
+		}
+	},
+
+	.power_ctrl       = cinergyt2_power_ctrl,
+
+	.rc_interval      = 50,
+	.rc_key_map       = 0,
+	.rc_key_map_size  = 0,
+	.rc_query         = 0,
+
+	.generic_bulk_ctrl_endpoint = 1,
+
+	.num_device_descs = 1,
+	.devices = {
+		{ .name = "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver",
+		  .cold_ids = {NULL},
+		  .warm_ids = { &cinergyt2_usb_table[0], NULL },
+		},
+		{ NULL },
+	}
+};
+
+
+static struct usb_driver cinergyt2_driver = {
+#if LINUX_VERSION_CODE <=  KERNEL_VERSION(2, 6, 15)
+	.owner	= THIS_MODULE,
+#endif
+	.name		= "cinergyT2",
+	.probe		= cinergyt2_usb_probe,
+	.disconnect	= dvb_usb_device_exit,
+	.id_table	= cinergyt2_usb_table
+};
+
+static int __init cinergyt2_usb_init(void)
+{
+	int err;
+
+	err = usb_register(&cinergyt2_driver);
+	if (err) {
+		err("usb_register() failed! (err %i)\n", err);
+		return err;
+	}
+	return 0;
+}
+
+static void __exit cinergyt2_usb_exit(void)
+{
+	cinergyt2_remote_exit(cinergyt2_usb_device);
+	usb_deregister(&cinergyt2_driver);
+}
+
+module_init(cinergyt2_usb_init);
+module_exit(cinergyt2_usb_exit);
+
+MODULE_DESCRIPTION("Terratec Cinergy T2 DVB-T driver");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Tomi Orava");
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-fe.c	Wed May 07 22:34:53 2008 +0300
@@ -0,0 +1,351 @@
+/*
+ * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
+ *
+ * Based on the dvb-usb-framework code and the
+ * original Terratec Cinergy T2 driver by:
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *                  Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "cinergyT2.h"
+
+
+/**
+ *  convert linux-dvb frontend parameter set into TPS.
+ *  See ETSI ETS-300744, section 4.6.2, table 9 for details.
+ *
+ *  This function is probably reusable and may better get placed in a support
+ *  library.
+ *
+ *  We replace errornous fields by default TPS fields (the ones with value 0).
+ */
+
+static uint16_t compute_tps(struct dvb_frontend_parameters *p)
+{
+	struct dvb_ofdm_parameters *op = &p->u.ofdm;
+	uint16_t tps = 0;
+
+	switch (op->code_rate_HP) {
+	case FEC_2_3:
+		tps |= (1 << 7);
+		break;
+	case FEC_3_4:
+		tps |= (2 << 7);
+		break;
+	case FEC_5_6:
+		tps |= (3 << 7);
+		break;
+	case FEC_7_8:
+		tps |= (4 << 7);
+		break;
+	case FEC_1_2:
+	case FEC_AUTO:
+	default:
+		/* tps |= (0 << 7) */;
+	}
+
+	switch (op->code_rate_LP) {
+	case FEC_2_3:
+		tps |= (1 << 4);
+		break;
+	case FEC_3_4:
+		tps |= (2 << 4);
+		break;
+	case FEC_5_6:
+		tps |= (3 << 4);
+		break;
+	case FEC_7_8:
+		tps |= (4 << 4);
+		break;
+	case FEC_1_2:
+	case FEC_AUTO:
+	default:
+		/* tps |= (0 << 4) */;
+	}
+
+	switch (op->constellation) {
+	case QAM_16:
+		tps |= (1 << 13);
+		break;
+	case QAM_64:
+		tps |= (2 << 13);
+		break;
+	case QPSK:
+	default:
+		/* tps |= (0 << 13) */;
+	}
+
+	switch (op->transmission_mode) {
+	case TRANSMISSION_MODE_8K:
+		tps |= (1 << 0);
+		break;
+	case TRANSMISSION_MODE_2K:
+	default:
+		/* tps |= (0 << 0) */;
+	}
+
+	switch (op->guard_interval) {
+	case GUARD_INTERVAL_1_16:
+		tps |= (1 << 2);
+		break;
+	case GUARD_INTERVAL_1_8:
+		tps |= (2 << 2);
+		break;
+	case GUARD_INTERVAL_1_4:
+		tps |= (3 << 2);
+		break;
+	case GUARD_INTERVAL_1_32:
+	default:
+		/* tps |= (0 << 2) */;
+	}
+
+	switch (op->hierarchy_information) {
+	case HIERARCHY_1:
+		tps |= (1 << 10);
+		break;
+	case HIERARCHY_2:
+		tps |= (2 << 10);
+		break;
+	case HIERARCHY_4:
+		tps |= (3 << 10);
+		break;
+	case HIERARCHY_NONE:
+	default:
+		/* tps |= (0 << 10) */;
+	}
+
+	return tps;
+}
+
+struct cinergyt2_fe_state {
+	struct dvb_frontend fe;
+	struct dvb_usb_device *d;
+};
+
+static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
+					fe_status_t *status)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg result;
+	u8 cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = cinergyt2_cmd(state->d, cmd, sizeof(cmd), (u8 *)&result,
+			sizeof(result), 0);
+	if (ret < 0)
+		return ret;
+
+	*status = 0;
+
+	if (0xffff - le16_to_cpu(result.gain) > 30)
+		*status |= FE_HAS_SIGNAL;
+	if (result.lock_bits & (1 << 6))
+		*status |= FE_HAS_LOCK;
+	if (result.lock_bits & (1 << 5))
+		*status |= FE_HAS_SYNC;
+	if (result.lock_bits & (1 << 4))
+		*status |= FE_HAS_CARRIER;
+	if (result.lock_bits & (1 << 1))
+		*status |= FE_HAS_VITERBI;
+
+	if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
+			(FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
+		*status &= ~FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = cinergyt2_cmd(state->d, cmd, sizeof(cmd), (char *)&status,
+				sizeof(status), 0);
+	if (ret < 0)
+		return ret;
+
+	*ber = le32_to_cpu(status.viterbi_error_rate);
+	return 0;
+}
+
+static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	u8 cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = cinergyt2_cmd(state->d, cmd, sizeof(cmd), (u8 *)&status,
+				sizeof(status), 0);
+	if (ret < 0) {
+		err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n",
+			ret);
+		return ret;
+	}
+	*unc = le32_to_cpu(status.uncorrected_block_count);
+	return 0;
+}
+
+static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe,
+						u16 *strength)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = cinergyt2_cmd(state->d, cmd, sizeof(cmd), (char *)&status,
+				sizeof(status), 0);
+	if (ret < 0) {
+		err("cinergyt2_fe_read_signal_strength() Failed!"
+			" (Error=%d)\n", ret);
+		return ret;
+	}
+	*strength = (0xffff - le16_to_cpu(status.gain));
+	return 0;
+}
+
+static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = cinergyt2_cmd(state->d, cmd, sizeof(cmd), (char *)&status,
+				sizeof(status), 0);
+	if (ret < 0) {
+		err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret);
+		return ret;
+	}
+	*snr = (status.snr << 8) | status.snr;
+	return 0;
+}
+
+static int cinergyt2_fe_init(struct dvb_frontend *fe)
+{
+	return 0;
+}
+
+static int cinergyt2_fe_sleep(struct dvb_frontend *fe)
+{
+	deb_info("cinergyt2_fe_sleep() Called\n");
+	return 0;
+}
+
+static int cinergyt2_fe_get_tune_settings(struct dvb_frontend *fe,
+				struct dvb_frontend_tune_settings *tune)
+{
+	tune->min_delay_ms = 800;
+	return 0;
+}
+
+static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe,
+				  struct dvb_frontend_parameters *fep)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_set_parameters_msg param;
+	char result[2];
+	int err;
+
+	param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
+	param.tps = cpu_to_le16(compute_tps(fep));
+	param.freq = cpu_to_le32(fep->frequency / 1000);
+	param.bandwidth = 8 - fep->u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
+
+	err = cinergyt2_cmd(state->d,
+			(char *)&param, sizeof(param),
+			result, sizeof(result), 0);
+	if (err < 0)
+		err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err);
+
+	return (err < 0) ? err : 0;
+}
+
+static int cinergyt2_fe_get_frontend(struct dvb_frontend *fe,
+				  struct dvb_frontend_parameters *fep)
+{
+	return 0;
+}
+
+static void cinergyt2_fe_release(struct dvb_frontend *fe)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	if (state != NULL)
+		kfree(state);
+}
+
+static struct dvb_frontend_ops cinergyt2_fe_ops;
+
+struct dvb_frontend *cinergyt2_fe_attach(struct dvb_usb_device *d)
+{
+	struct cinergyt2_fe_state *s = kzalloc(sizeof(
+					struct cinergyt2_fe_state), GFP_KERNEL);
+	if (s == NULL)
+		return NULL;
+
+	s->d = d;
+	memcpy(&s->fe.ops, &cinergyt2_fe_ops, sizeof(struct dvb_frontend_ops));
+	s->fe.demodulator_priv = s;
+	return &s->fe;
+}
+
+
+static struct dvb_frontend_ops cinergyt2_fe_ops = {
+	.info = {
+		.name			= DRIVER_NAME,
+		.type			= FE_OFDM,
+		.frequency_min		= 174000000,
+		.frequency_max		= 862000000,
+		.frequency_stepsize	= 166667,
+		.caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2
+			| FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4
+			| FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8
+			| FE_CAN_FEC_AUTO | FE_CAN_QPSK
+			| FE_CAN_QAM_16 | FE_CAN_QAM_64
+			| FE_CAN_QAM_AUTO
+			| FE_CAN_TRANSMISSION_MODE_AUTO
+			| FE_CAN_GUARD_INTERVAL_AUTO
+			| FE_CAN_HIERARCHY_AUTO
+			| FE_CAN_RECOVER
+			| FE_CAN_MUTE_TS
+	},
+
+	.release		= cinergyt2_fe_release,
+
+	.init			= cinergyt2_fe_init,
+	.sleep			= cinergyt2_fe_sleep,
+
+	.set_frontend		= cinergyt2_fe_set_frontend,
+	.get_frontend		= cinergyt2_fe_get_frontend,
+	.get_tune_settings	= cinergyt2_fe_get_tune_settings,
+
+	.read_status		= cinergyt2_fe_read_status,
+	.read_ber		= cinergyt2_fe_read_ber,
+	.read_signal_strength	= cinergyt2_fe_read_signal_strength,
+	.read_snr		= cinergyt2_fe_read_snr,
+	.read_ucblocks		= cinergyt2_fe_read_unc_blocks,
+};
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2-remote.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-remote.c	Wed May 07 22:34:53 2008 +0300
@@ -0,0 +1,336 @@
+/*
+ * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
+ *
+ * Based on the dvb-usb-framework code and the
+ * original Terratec Cinergy T2 driver by:
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *		    Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "cinergyT2.h"
+
+enum {
+	CINERGYT2_RC_EVENT_TYPE_NONE = 0x00,
+	CINERGYT2_RC_EVENT_TYPE_NEC  = 0x01,
+	CINERGYT2_RC_EVENT_TYPE_RC5  = 0x02
+};
+
+/**
+ * struct dvb_usb_rc_key - a remote control key and its input-event
+ * @custom: the vendor/custom part of the key
+ * @data: the actual key part
+ * @event: the input event assigned to key identified by custom and data
+ */
+struct cinergyt2_rc_key {
+	u32 custom;
+	u32 data;
+	u32 event;
+};
+
+
+struct cinergyt2_rc_event {
+	char custom;
+	uint32_t data;
+} __attribute__((packed));
+
+
+extern int disable_remote;
+
+struct cinergyt2_rc_key cinergyt2_rc_keys[] = {
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfe01eb04, 	KEY_POWER },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfd02eb04, 	KEY_1 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfc03eb04, 	KEY_2 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfb04eb04, 	KEY_3 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfa05eb04, 	KEY_4 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf906eb04, 	KEY_5 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf807eb04, 	KEY_6 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf708eb04, 	KEY_7 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf609eb04, 	KEY_8 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf50aeb04, 	KEY_9 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf30ceb04, 	KEY_0 },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf40beb04, 	KEY_VIDEO },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf20deb04, 	KEY_REFRESH },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf10eeb04, 	KEY_SELECT },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf00feb04, 	KEY_EPG },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xef10eb04, 	KEY_UP },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xeb14eb04, 	KEY_DOWN },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xee11eb04, 	KEY_LEFT },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xec13eb04, 	KEY_RIGHT },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xed12eb04, 	KEY_OK },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xea15eb04, 	KEY_TEXT },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe916eb04, 	KEY_INFO },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe817eb04, 	KEY_RED },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe718eb04, 	KEY_GREEN },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe619eb04, 	KEY_YELLOW },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe51aeb04, 	KEY_BLUE },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe31ceb04, 	KEY_VOLUMEUP },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe11eeb04, 	KEY_VOLUMEDOWN },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe21deb04, 	KEY_MUTE },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe41beb04, 	KEY_CHANNELUP },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe01feb04, 	KEY_CHANNELDOWN },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xbf40eb04, 	KEY_PAUSE },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xb34ceb04, 	KEY_PLAY },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xa758eb04, 	KEY_RECORD },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xab54eb04, 	KEY_PREVIOUS },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xb748eb04, 	KEY_STOP },
+	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xa35ceb04, 	KEY_NEXT }
+};
+
+int cinergyt2_rc_keys_size = ARRAY_SIZE(cinergyt2_rc_keys);
+
+
+static int cinergyt2_decode_rc_key(struct dvb_usb_device *dev, int type,
+					int data, u32 *event, int *state)
+{
+	int i, key, found;
+
+	*state = REMOTE_NO_KEY_PRESSED;
+	key = le32_to_cpu(data);
+
+	/* info("cinergyt2_decode_rc_key() type=%d, key=0x%x \
+	* 		(converted=0x%x)\n", type, data, key);
+	*/
+
+	switch (type) {
+	case CINERGYT2_RC_EVENT_TYPE_NEC:
+		if (key == ~0) {
+			/* Stop key repeat */
+			*state = REMOTE_NO_KEY_PRESSED;
+			break;
+		}
+		found = 0;
+
+		for (i = 0; i < cinergyt2_rc_keys_size; i++) {
+			if (cinergyt2_rc_keys[i].data == key) {
+				*event = cinergyt2_rc_keys[i].event;
+				*state = REMOTE_KEY_PRESSED;
+				found = 1;
+				/* deb_info("Remote key pressed! key = %d\n",
+				* 		i);
+				*/
+				break;
+			}
+		}
+		if (found == 0)
+			err("cinergyT2: Unknown remote control key detected!"
+				"key=0x%x (raw=0x%x)\n", key, data);
+		break;
+
+	case CINERGYT2_RC_EVENT_TYPE_RC5:
+	case CINERGYT2_RC_EVENT_TYPE_NONE:
+	default:
+		info("Unhandled remote key detected! type=0x%x\n", type);
+		break;
+	}
+	return 0;
+}
+
+static int cinergyt2_rc_process(struct dvb_usb_device *dev)
+{
+	char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS };
+	struct cinergyt2_rc_event rc_events[12];
+	int len, i, state;
+	u32 event;
+	/* struct cinergyt2_device_state *st = dev->priv; */
+
+	len = cinergyt2_cmd(dev, buf, sizeof(buf),
+				(char *)rc_events, sizeof(rc_events), 0);
+	if (len < 0) {
+		/* printk(KERN_INFO "Failed to read RC event data!\n"); */
+		return 0;
+	}
+
+	if (len == 0)
+		return 0;
+
+	state = REMOTE_NO_KEY_PRESSED;
+
+	for (i = 0; i < (len / sizeof(rc_events[0])); i++) {
+		/* deb_info("[%d/%d] rc_events[%d].data = %x (converted=%x),
+		* 		type=%x\n",
+		*		i, len / sizeof(rc_events[0]),
+		*		i, rc_events[i].data,
+		*		le32_to_cpu(rc_events[i].data),
+		*		rc_events[i].custom);
+		 */
+
+		cinergyt2_decode_rc_key(dev, rc_events[i].custom,
+					rc_events[i].data, &event, &state);
+		switch (state) {
+		case REMOTE_NO_KEY_PRESSED:
+			break;
+
+		case REMOTE_KEY_PRESSED:
+			/* deb_rc("key pressed\n"); */
+			dev->last_event = event;
+			input_event(dev->rc_input_dev, EV_KEY,
+					event, 1);
+			input_event(dev->rc_input_dev, EV_KEY,
+					dev->last_event, 0);
+			input_sync(dev->rc_input_dev);
+			break;
+
+		case REMOTE_KEY_REPEAT:
+			/* deb_rc("key repeated\n"); */
+			input_event(dev->rc_input_dev, EV_KEY,
+					event, 1);
+			input_event(dev->rc_input_dev, EV_KEY,
+					dev->last_event, 0);
+			input_sync(dev->rc_input_dev);
+			break;
+		default:
+			break;
+		}
+
+	}
+	return 0;
+}
+
+/*
+ * Code copied from dvb-usb-remote.c and modified for Cinergy T2
+ */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void cinergyt2_read_remote_control(void *data)
+#else
+static void cinergyt2_read_remote_control(struct work_struct *work)
+#endif
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+	struct dvb_usb_device *d = data;
+#else
+	struct dvb_usb_device *d =
+		container_of(work, struct dvb_usb_device,
+				rc_query_work.work);
+#endif
+
+	/* TODO: need a lock here.
+	* We can simply skip checking for the remote control
+	*  if we're busy.
+	*/
+
+	/* when the parameter has been set to 1 via sysfs while
+	* the driver was running
+	*/
+
+	if (disable_remote)
+		return;
+
+	if (cinergyt2_rc_process(d))
+		err("error while querying for an remote control event.");
+
+	schedule_delayed_work(&d->rc_query_work,
+				msecs_to_jiffies(d->props.rc_interval));
+}
+
+
+
+int cinergyt2_remote_init(struct dvb_usb_device *d)
+{
+	struct input_dev *input_dev;
+	int i;
+	int err;
+
+	if (disable_remote) {
+		err("Remote controller support disabled!\n");
+		return 0;
+	}
+
+	usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
+	strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
+
+	input_dev = input_allocate_device();
+	if (!input_dev) {
+		err("Failed to allocate new input device!\n");
+		return -ENOMEM;
+	}
+
+	input_dev->evbit[0] = BIT(EV_KEY);
+	input_dev->name = "IR-receiver inside an USB DVB receiver";
+	input_dev->phys = d->rc_phys;
+	usb_to_input_id(d->udev, &input_dev->id);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
+	input_dev->dev.parent = &d->udev->dev;
+#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
+	input_dev->cdev.dev = &d->udev->dev;
+#endif
+#endif
+
+	/* set the bits for the keys */
+	deb_rc("key map size: %d\n", cinergyt2_rc_keys_size);
+	for (i = 0; i < cinergyt2_rc_keys_size; i++) {
+		deb_rc("setting bit for event %d item %d\n",
+			cinergyt2_rc_keys[i].event, i);
+		set_bit(cinergyt2_rc_keys[i].event, input_dev->keybit);
+	}
+
+	/* Start the remote-control polling. */
+	if (d->props.rc_interval < 40)
+		d->props.rc_interval = 100; /* default */
+
+	/* setting these two values to non-zero,
+	 * we have to manage key repeats */
+
+	input_dev->rep[REP_PERIOD] = d->props.rc_interval;
+	input_dev->rep[REP_DELAY]  = d->props.rc_interval + 150;
+
+	err = input_register_device(input_dev);
+	if (err) {
+		input_free_device(input_dev);
+		err("Failed to register new input device!\n");
+		return err;
+	}
+
+	d->rc_input_dev = input_dev;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+	INIT_WORK(&d->rc_query_work, cinergyt2_read_remote_control, d);
+#else
+	INIT_DELAYED_WORK(&d->rc_query_work, cinergyt2_read_remote_control);
+#endif
+
+	info("schedule remote query interval to %d msecs.",
+		d->props.rc_interval);
+
+	schedule_delayed_work(&d->rc_query_work,
+				msecs_to_jiffies(d->props.rc_interval));
+
+	d->state |= DVB_USB_STATE_REMOTE;
+
+	return 0;
+}
+EXPORT_SYMBOL(cinergyt2_remote_init);
+
+
+int cinergyt2_remote_exit(struct dvb_usb_device *d)
+{
+	if (d->state & DVB_USB_STATE_REMOTE) {
+		cancel_rearming_delayed_work(&d->rc_query_work);
+		flush_scheduled_work();
+		input_unregister_device(d->rc_input_dev);
+	}
+	d->state &= ~DVB_USB_STATE_REMOTE;
+	return 0;
+}
+EXPORT_SYMBOL(cinergyt2_remote_exit);
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2.h	Wed May 07 22:34:53 2008 +0300
@@ -0,0 +1,101 @@
+/*
+ * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
+ *
+ * Based on the dvb-usb-framework code and the
+ * original Terratec Cinergy T2 driver by:
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *                  Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License,  or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not,  write to the Free Software
+ * Foundation,  Inc.,  675 Mass Ave,  Cambridge,  MA 02139,  USA.
+ *
+ */
+
+#ifndef _DVB_USB_CINERGYT2_H_
+#define _DVB_USB_CINERGYT2_H_
+
+#include <linux/usb/input.h>
+
+#define DVB_USB_LOG_PREFIX "cinergyT2"
+#include "dvb-usb.h"
+
+#define DRIVER_NAME "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"
+
+extern int disable_remote;
+extern int dvb_usb_cinergyt2_debug;
+
+#define deb_info(args...)  dprintk(dvb_usb_cinergyt2_debug,  0x001, args)
+#define deb_xfer(args...)  dprintk(dvb_usb_cinergyt2_debug,  0x002, args)
+#define deb_pll(args...)   dprintk(dvb_usb_cinergyt2_debug,  0x004, args)
+#define deb_ts(args...)    dprintk(dvb_usb_cinergyt2_debug,  0x008, args)
+#define deb_err(args...)   dprintk(dvb_usb_cinergyt2_debug,  0x010, args)
+#define deb_rc(args...)    dprintk(dvb_usb_cinergyt2_debug,  0x020, args)
+#define deb_fw(args...)    dprintk(dvb_usb_cinergyt2_debug,  0x040, args)
+#define deb_mem(args...)   dprintk(dvb_usb_cinergyt2_debug,  0x080, args)
+#define deb_uxfer(args...) dprintk(dvb_usb_cinergyt2_debug,  0x100, args)
+
+
+
+enum cinergyt2_ep1_cmd {
+	CINERGYT2_EP1_PID_TABLE_RESET		= 0x01,
+	CINERGYT2_EP1_PID_SETUP			= 0x02,
+	CINERGYT2_EP1_CONTROL_STREAM_TRANSFER	= 0x03,
+	CINERGYT2_EP1_SET_TUNER_PARAMETERS	= 0x04,
+	CINERGYT2_EP1_GET_TUNER_STATUS		= 0x05,
+	CINERGYT2_EP1_START_SCAN		= 0x06,
+	CINERGYT2_EP1_CONTINUE_SCAN		= 0x07,
+	CINERGYT2_EP1_GET_RC_EVENTS		= 0x08,
+	CINERGYT2_EP1_SLEEP_MODE		= 0x09,
+	CINERGYT2_EP1_GET_FIRMWARE_VERSION	= 0x0A
+};
+
+
+struct dvbt_get_status_msg {
+	uint32_t freq;
+	uint8_t bandwidth;
+	uint16_t tps;
+	uint8_t flags;
+	uint16_t gain;
+	uint8_t snr;
+	uint32_t viterbi_error_rate;
+	uint32_t rs_error_rate;
+	uint32_t uncorrected_block_count;
+	uint8_t lock_bits;
+	uint8_t prev_lock_bits;
+} __attribute__((packed));
+
+
+struct dvbt_set_parameters_msg {
+	uint8_t cmd;
+	uint32_t freq;
+	uint8_t bandwidth;
+	uint16_t tps;
+	uint8_t flags;
+} __attribute__((packed));
+
+
+extern struct dvb_frontend *cinergyt2_fe_attach(struct dvb_usb_device *d);
+extern int cinergyt2_cmd(struct dvb_usb_device *d,  char *wbuf,  int wlen,
+			char *rbuf,  int rlen,  int delay_ms);
+
+extern int cinergyt2_remote_init(struct dvb_usb_device *d);
+extern int cinergyt2_remote_exit(struct dvb_usb_device *d);
+
+#endif /* _DVB_USB_CINERGYT2_H_ */
+

[-- Attachment #3: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-07 18:49                     ` Tomi Orava
@ 2008-05-07 22:21                       ` Antti Palosaari
  2008-05-13 10:27                         ` Tomi Orava
  2008-05-08 21:18                       ` Thierry Merle
  1 sibling, 1 reply; 21+ messages in thread
From: Antti Palosaari @ 2008-05-07 22:21 UTC (permalink / raw)
  To: Tomi Orava; +Cc: linux-dvb

hello Tomi
I looked through your driver and here is some comments raised up.

- why cinergyt2_cmd, why not dvb_usb_generic_rw ?
- USB IDs are usually defined in own file dvb-usb-ids.h
- remote control code seems quite complex and long, maybe there is 
easier way?

regards
Antti
-- 
http://palosaari.fi/

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-05 19:57                   ` Thierry Merle
  2008-05-07 18:49                     ` Tomi Orava
@ 2008-05-08 20:47                     ` Ingo Peukes
  2008-05-12 18:32                       ` Tomi Orava
  1 sibling, 1 reply; 21+ messages in thread
From: Ingo Peukes @ 2008-05-08 20:47 UTC (permalink / raw)
  To: linux-dvb

Hello,

count me as a tester for the new driver cause I can't use the old one.
As I'm primary a system administrator and not a programmer I just can 
give informations from a users view.

I use the driver on my Linkstation Live which I'm going to turn into a
VDR using mythtv, and for now I can tell it compiles on this NAS with 
kernel 2.6.25.1 and the v4l-dvb sources found here:
http://ubuntuforums.org/showthread.php?t=511676&page=8

I use this cause I also have Pinnacle PCTV200e which is not supported by
the official sources. The PCTV card is also the reason why I cannot use 
the old/original driver cause somehow neither device is usable when 
both drivers are loaded. I think this comes because they both have a 
Zarlink MT352 and it seems that the modules mt352 and cinergyT2
can't work together. This problem does not exist with your driver.
So I'm happy you go for a new cinergyT2 driver :)

Well, as I said it compiles and works with the above kernel and v4l-dvb
but w_scan finds no channels with this module most of the time. In 5 
runs it found 4 channels on one multiplex.
I doubt it's the antenna although it's the stock one but if I use the
cinergyT2 on my desktop pc with the original module of kernel 2.6.25.1 
w_scan finds all available channels all the time with the same antenna 
in the same place. I will try a better antenna tomorrow to see if I can 
use it somewhat productive in mythtv...


Regards
Ingo Peukes


Thierry Merle wrote:
> Tomi Orava a écrit :
>   
>> Hi,
>>
>>     
>>> Well, I see some issues after taking a closer look at your driver:
>>> 1- checkpatch.pl raises errors: 90 errors, 53 warnings, 995 lines checked
>>> 2- there is a compilation error (I applied the patch on the latest
>>> v4l-dvb tree):
>>> cinergyT2-core.c: In function 'cinergyt2_usb_probe':
>>> cinergyT2-core.c:138: error: too few arguments to function
>>> 'dvb_usb_device_init'
>>> 3- you should replace the existing driver, not proposing a different
>>> driver. I mean, patch directly
>>> linux/drivers/media/dvb/cinergyT2/cinergyT2.c.
>>>       
>> Ok, these are easy to fix.
>>
>>     
>>> Furthermore, I have some questions:
>>> - is there a way to use the dvb-usb-remote module? This in order to get
>>> rid of cinergyT2-remote.c
>>>       
>> No, due to the fact that the dvb-usb.h defines a struct which is too
>> limited for the Cinergy T2 remote controller handling. If you compare
>> the original struct dvb_usb_rc_key to the modified one:
>>
>> Original:
>>
>> struct dvb_usb_rc_key {
>>         u8 custom,data; <--------------------
>>         u32 event;
>> };
>>
>> Cinergy T2 send U32 remote controller:
>>
>> struct cinergyt2_rc_key {
>> 	u32 custom; <--------------
>> 	u32 data;   <--------------
>> 	u32 event;
>> };
>>
>> Obviously I could get rid of the whole cinergyT2-remote.c file
>> if the dvb-usb defined struct could be widened.
>>
>>     
> Indeed, but in the current structure I am not sure that all the bits of the u32 data is useful.
> For example:
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfe01eb04,	KEY_POWER },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfd02eb04,	KEY_1 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfc03eb04,	KEY_2 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfb04eb04,	KEY_3 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xfa05eb04,	KEY_4 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf906eb04,	KEY_5 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf807eb04,	KEY_6 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf708eb04,	KEY_7 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf609eb04,	KEY_8 },
> 	{ CINERGYT2_RC_EVENT_TYPE_NEC,	0xf50aeb04,	KEY_9 },
> I see for example that in the u32 0xfe01eb04, first and second bytes are linked (0xfe + 0x01 = 0xff)
> It works with all others: 0xfd02eb04 -> 0xfd + 0x02 = 0xff, ...
> Furthermore the last 2 bytes are constant (0xeb04).
> So the sole significant byte is the second: 0x01, 0x02, ...
> I will try to do something around that.
>
>   
>>> - so, renaming cinergyT2-core.c to cinergyT2.c would be correct?
>>>       
>> Hmm, if I remember correctly there was some sort of clash with the filenames
>> and the actual compiled driver.
>>     
> In fact if you remove the old driver (by resolving the issue #3), I suggested to name the cinergyT2-core.c cinergyT2.c but there is no obligation. 
>   
>>> - stream buffer count was set to 32 in the old driver and you set it to
>>> 5, why this change? It works perfectly with 5 and consumes less memory
>>> so if this is the reason I fully agree!
>>>       
>> As the old existing driver is handling the communication differently
>> also the buffer count values are different. When I began writing the
>> new version of the CinergyT2 driver I did some trials and based on the
>> helpful comments & test results the value of 5 has been there.
>>
>>     
> OK
>   
>>> I think the best way is to rework your patch and fix these issues; I can
>>> help you if you want.
>>> Then I will commit that in a particular tree and ask for pushing it to
>>> the official tree.
>>>       
>> Sure, I'll fix the reported errors and get back to you.
>>
>>     
> Thanks
>   
>> Regards,
>> Tomi Orava
>>
>>     
> Cheers,
> Thierry
>
> _______________________________________________
> linux-dvb mailing list
> linux-dvb@linuxtv.org
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb



_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-07 18:49                     ` Tomi Orava
  2008-05-07 22:21                       ` Antti Palosaari
@ 2008-05-08 21:18                       ` Thierry Merle
  2008-05-12 18:49                         ` Tomi Orava
  1 sibling, 1 reply; 21+ messages in thread
From: Thierry Merle @ 2008-05-08 21:18 UTC (permalink / raw)
  To: Tomi Orava; +Cc: linux-dvb

[-- Attachment #1: Type: text/plain, Size: 5401 bytes --]

Tomi Orava a écrit :
> 
> Hi,
> 
>>>> Well, I see some issues after taking a closer look at your driver:
>>>> 1- checkpatch.pl raises errors: 90 errors, 53 warnings, 995 lines
>>>> checked
>>>> 2- there is a compilation error (I applied the patch on the latest
>>>> v4l-dvb tree):
>>>> cinergyT2-core.c: In function 'cinergyt2_usb_probe':
>>>> cinergyT2-core.c:138: error: too few arguments to function
>>>> 'dvb_usb_device_init'
>>>> 3- you should replace the existing driver, not proposing a different
>>>> driver. I mean, patch directly
>>>> linux/drivers/media/dvb/cinergyT2/cinergyT2.c.
> 
> I did some cleanups pointed by the checkpach.pl script.
Good! No more error.

> However, I did not replace the original Cinergy T2 driver
> as I think that this new driver should be located in the
> very same directory as the rest of the usb-dvb drivers.
> 
Agreed, but you should remove the old cinergyT2 driver.

Furthermore there is another issue: when I plug the device, the device usage count is set to 0.
When I remove the device the device usage count goes to -1 (displayed as 4294967295).
This is a misbehavior of the dvb framework but perhaps something needs to be initialized somewhere in the driver. I will look at it...dvb-usb: TerraTec/qanu USB2.0 Highspeed DVB-T Receiver successfully initialized and connected.
I noticed this error when I plug the device (I load manually the driver before, so I suspect a thing in the probe function):
sysfs: duplicate filename 'cinergyT2' can not be created
WARNING: at fs/sysfs/dir.c:424 sysfs_add_one()
Pid: 2922, comm: modprobe Not tainted 2.6.24.3 #13
 [<c017896a>] sysfs_add_one+0x54/0xb7
 [<c0178d8c>] create_dir+0x3c/0x6b
 [<c0178de8>] sysfs_create_dir+0x2d/0x40
 [<c01a8d07>] kobject_get+0xf/0x13
 [<c01a90fc>] kobject_add+0xd3/0x17a
 [<c01a91f7>] kobject_register+0x19/0x2d
 [<c02013b0>] bus_add_driver+0x50/0x197
 [<e00c7e07>] usb_register_driver+0x66/0xc8 [usbcore]
 [<c0142813>] __vunmap+0xbd/0xd1
 [<e023c018>] cinergyt2_init+0x18/0x5a [cinergyT2]
 [<c012421f>] blocking_notifier_call_chain+0x17/0x1a
 [<c012b688>] sys_init_module+0x11d4/0x12e9
 [<c0103bc2>] syscall_call+0x7/0xb
 [<c0280000>] __xfrm_lookup+0x1b/0x460
 =======================
kobject_add failed for cinergyT2 with -EEXIST, don't try to register things with the same name in the same directory.
Pid: 2922, comm: modprobe Not tainted 2.6.24.3 #13
 [<c01a9171>] kobject_add+0x148/0x17a
 [<c01a91f7>] kobject_register+0x19/0x2d
 [<c02013b0>] bus_add_driver+0x50/0x197
 [<e00c7e07>] usb_register_driver+0x66/0xc8 [usbcore]
 [<c0142813>] __vunmap+0xbd/0xd1
 [<e023c018>] cinergyt2_init+0x18/0x5a [cinergyT2]
 [<c012421f>] blocking_notifier_call_chain+0x17/0x1a
 [<c012b688>] sys_init_module+0x11d4/0x12e9
 [<c0103bc2>] syscall_call+0x7/0xb
 [<c0280000>] __xfrm_lookup+0x1b/0x460
 =======================
usbcore: error -17 registering interface 	driver cinergyT2

> The current patch is against the v4l-dvb tree.
> 
> Regards,
> Tomi Orava
> 
> diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/Kconfig
> --- a/linux/drivers/media/dvb/dvb-usb/Kconfig	Tue May 06 11:09:01 2008 -0300
> +++ b/linux/drivers/media/dvb/dvb-usb/Kconfig	Wed May 07 22:34:53 2008 +0300
> @@ -241,3 +241,11 @@ config DVB_USB_AF9005_REMOTE
>  	  Say Y here to support the default remote control decoding for the
>  	  Afatech AF9005 based receiver.
>  
> +config 	DVB_USB_CINERGY_T2
> +	tristate "Alternative driver for Terratec CinergyT2/qanu USB2 DVB-T receiver"
Just remove the "Alternative" word.
[SNIP]
> diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c	Wed May 07 22:34:53 2008 +0300
> @@ -0,0 +1,235 @@
[SNIP]
> +
> +/* slightly modified version of dvb_usb_generic_rw -function */
> +
> +int cinergyt2_cmd(struct dvb_usb_device *d, char *wbuf, int wlen,
> +			char *rbuf, int rlen, int delay_ms)
> +{
I studied the differences between this function and the original dvb_usb_generic_rw function.
The only difference is that cinergyt2_cmd returns the number of bytes that usb_bulk_msg has read (actlen).
This value is only used in cinergyT2-remote that can be removed (see further) so this function should be removed and calls replaced by the original dvb_usb_generic_rw
[SNIP}
> diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2-remote.c
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-remote.c	Wed May 07 22:34:53 2008 +0300
> @@ -0,0 +1,336 @@
[SNIP]
> +struct cinergyt2_rc_key cinergyt2_rc_keys[] = {
> +	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfe01eb04, 	KEY_POWER },
In fact, the rc keycodes are nearly standard:
first byte=RC event type (CINERGYT2_RC_EVENT_TYPE_NONE, CINERGYT2_RC_EVENT_TYPE_NEC, CINERGYT2_RC_EVENT_TYPE_RC5)
then comes a couple of bytes: the custom code=0x04 and the custom code "checksum" =0xeb
then the last couple of bytes: the key code=0x01 and the key code checksum=0xfe
This processing is done in a same way in dvd-usb-remote.
I joined to this email a patch against your patch that uses this module. Obviously you can integrate in your patch .
I will look at the module count problem and the irrecord problem, we are close to propose this beautiful patch ;)
Cheers,
Thierry


[-- Attachment #2: remove_cinergyT2_remote.patch --]
[-- Type: text/plain, Size: 14405 bytes --]

diff -r f51aa257acfa linux/drivers/media/dvb/dvb-usb/Makefile
--- a/linux/drivers/media/dvb/dvb-usb/Makefile	Thu May 08 22:53:56 2008 +0200
+++ b/linux/drivers/media/dvb/dvb-usb/Makefile	Thu May 08 23:06:34 2008 +0200
@@ -61,7 +61,7 @@
 dvb-usb-af9005-remote-objs = af9005-remote.o
 obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o
 
-dvb-usb-cinergyT2-objs = cinergyT2-core.o cinergyT2-fe.o cinergyT2-remote.o
+dvb-usb-cinergyT2-objs = cinergyT2-core.o cinergyT2-fe.o
 obj-$(CONFIG_DVB_USB_CINERGY_T2) += dvb-usb-cinergyT2.o
 
 
diff -r f51aa257acfa linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c
--- a/linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c	Thu May 08 22:53:56 2008 +0200
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c	Thu May 08 23:06:34 2008 +0200
@@ -37,10 +37,6 @@
 module_param_named(debug, dvb_usb_cinergyt2_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level (1=info, xfer=2, rc=4 "
 		"(or-able)).");
-
-module_param_named(disable_remote, disable_remote, int, 0644);
-MODULE_PARM_DESC(disable_remote, "Disable remote controller support (int)");
-
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
@@ -135,9 +131,65 @@
 	/* Copy this pointer as we are gonna need it in the release phase */
 	cinergyt2_usb_device = adap->dev;
 
-	ret = cinergyt2_remote_init(adap->dev);
-	if (ret)
-		err("could not initialize remote control.");
+	return 0;
+}
+
+static struct dvb_usb_rc_key cinergyt2_rc_keys [] = {
+	{ 0x04,	0x01,	KEY_POWER },
+	{ 0x04,	0x02,	KEY_1 },
+	{ 0x04,	0x03,	KEY_2 },
+	{ 0x04,	0x04,	KEY_3 },
+	{ 0x04,	0x05,	KEY_4 },
+	{ 0x04,	0x06,	KEY_5 },
+	{ 0x04,	0x07,	KEY_6 },
+	{ 0x04,	0x08,	KEY_7 },
+	{ 0x04,	0x09,	KEY_8 },
+	{ 0x04,	0x0a,	KEY_9 },
+	{ 0x04,	0x0c,	KEY_0 },
+	{ 0x04,	0x0b,	KEY_VIDEO },
+	{ 0x04,	0x0d,	KEY_REFRESH },
+	{ 0x04,	0x0e,	KEY_SELECT },
+	{ 0x04,	0x0f,	KEY_EPG },
+	{ 0x04,	0x10,	KEY_UP },
+	{ 0x04,	0x14,	KEY_DOWN },
+	{ 0x04,	0x11,	KEY_LEFT },
+	{ 0x04,	0x13,	KEY_RIGHT },
+	{ 0x04,	0x12,	KEY_OK },
+	{ 0x04,	0x15,	KEY_TEXT },
+	{ 0x04,	0x16,	KEY_INFO },
+	{ 0x04,	0x17,	KEY_RED },
+	{ 0x04,	0x18,	KEY_GREEN },
+	{ 0x04,	0x19,	KEY_YELLOW },
+	{ 0x04,	0x1a,	KEY_BLUE },
+	{ 0x04,	0x1c,	KEY_VOLUMEUP },
+	{ 0x04,	0x1e,	KEY_VOLUMEDOWN },
+	{ 0x04,	0x1d,	KEY_MUTE },
+	{ 0x04,	0x1b,	KEY_CHANNELUP },
+	{ 0x04,	0x1f,	KEY_CHANNELDOWN },
+	{ 0x04,	0x40,	KEY_PAUSE },
+	{ 0x04,	0x4c,	KEY_PLAY },
+	{ 0x04,	0x58,	KEY_RECORD },
+	{ 0x04,	0x54,	KEY_PREVIOUS },
+	{ 0x04,	0x48,	KEY_STOP },
+	{ 0x04,	0x5c,	KEY_NEXT }
+};
+
+static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
+{
+	u8 key[5]={0,0,0,0,0},cmd = CINERGYT2_EP1_GET_RC_EVENTS;
+	*state = REMOTE_NO_KEY_PRESSED;
+
+	cinergyt2_cmd(d,&cmd,1,key,sizeof(key),0);
+	if(key[4] == 0xff) {
+		return 0;
+	}
+
+	/* hack to pass checksum on the custom field (is set to 0xeb) */
+	key[2] = ~0x04;
+	dvb_usb_nec_rc_key_to_event(d,key,event,state);
+ 	if (key[0] != 0)
+		deb_info("key: %x %x %x %x %x\n",
+			 key[0],key[1],key[2],key[3],key[4]);
 
 	return 0;
 }
@@ -182,9 +234,9 @@
 	.power_ctrl       = cinergyt2_power_ctrl,
 
 	.rc_interval      = 50,
-	.rc_key_map       = 0,
-	.rc_key_map_size  = 0,
-	.rc_query         = 0,
+	.rc_key_map       = cinergyt2_rc_keys,
+	.rc_key_map_size  = ARRAY_SIZE(cinergyt2_rc_keys),
+	.rc_query         = cinergyt2_rc_query,
 
 	.generic_bulk_ctrl_endpoint = 1,
 
@@ -223,7 +275,6 @@
 
 static void __exit cinergyt2_usb_exit(void)
 {
-	cinergyt2_remote_exit(cinergyt2_usb_device);
 	usb_deregister(&cinergyt2_driver);
 }
 
diff -r f51aa257acfa linux/drivers/media/dvb/dvb-usb/cinergyT2-remote.c
--- a/linux/drivers/media/dvb/dvb-usb/cinergyT2-remote.c	Thu May 08 22:53:56 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,336 +0,0 @@
-/*
- * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
- *
- * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
- *
- * Based on the dvb-usb-framework code and the
- * original Terratec Cinergy T2 driver by:
- *
- * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
- *		    Holger Waechtler <holger@qanu.de>
- *
- *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include "cinergyT2.h"
-
-enum {
-	CINERGYT2_RC_EVENT_TYPE_NONE = 0x00,
-	CINERGYT2_RC_EVENT_TYPE_NEC  = 0x01,
-	CINERGYT2_RC_EVENT_TYPE_RC5  = 0x02
-};
-
-/**
- * struct dvb_usb_rc_key - a remote control key and its input-event
- * @custom: the vendor/custom part of the key
- * @data: the actual key part
- * @event: the input event assigned to key identified by custom and data
- */
-struct cinergyt2_rc_key {
-	u32 custom;
-	u32 data;
-	u32 event;
-};
-
-
-struct cinergyt2_rc_event {
-	char custom;
-	uint32_t data;
-} __attribute__((packed));
-
-
-extern int disable_remote;
-
-struct cinergyt2_rc_key cinergyt2_rc_keys[] = {
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfe01eb04, 	KEY_POWER },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfd02eb04, 	KEY_1 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfc03eb04, 	KEY_2 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfb04eb04, 	KEY_3 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xfa05eb04, 	KEY_4 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf906eb04, 	KEY_5 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf807eb04, 	KEY_6 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf708eb04, 	KEY_7 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf609eb04, 	KEY_8 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf50aeb04, 	KEY_9 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf30ceb04, 	KEY_0 },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf40beb04, 	KEY_VIDEO },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf20deb04, 	KEY_REFRESH },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf10eeb04, 	KEY_SELECT },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xf00feb04, 	KEY_EPG },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xef10eb04, 	KEY_UP },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xeb14eb04, 	KEY_DOWN },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xee11eb04, 	KEY_LEFT },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xec13eb04, 	KEY_RIGHT },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xed12eb04, 	KEY_OK },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xea15eb04, 	KEY_TEXT },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe916eb04, 	KEY_INFO },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe817eb04, 	KEY_RED },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe718eb04, 	KEY_GREEN },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe619eb04, 	KEY_YELLOW },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe51aeb04, 	KEY_BLUE },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe31ceb04, 	KEY_VOLUMEUP },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe11eeb04, 	KEY_VOLUMEDOWN },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe21deb04, 	KEY_MUTE },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe41beb04, 	KEY_CHANNELUP },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xe01feb04, 	KEY_CHANNELDOWN },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xbf40eb04, 	KEY_PAUSE },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xb34ceb04, 	KEY_PLAY },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xa758eb04, 	KEY_RECORD },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xab54eb04, 	KEY_PREVIOUS },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xb748eb04, 	KEY_STOP },
-	{ CINERGYT2_RC_EVENT_TYPE_NEC, 	0xa35ceb04, 	KEY_NEXT }
-};
-
-int cinergyt2_rc_keys_size = ARRAY_SIZE(cinergyt2_rc_keys);
-
-
-static int cinergyt2_decode_rc_key(struct dvb_usb_device *dev, int type,
-					int data, u32 *event, int *state)
-{
-	int i, key, found;
-
-	*state = REMOTE_NO_KEY_PRESSED;
-	key = le32_to_cpu(data);
-
-	/* info("cinergyt2_decode_rc_key() type=%d, key=0x%x \
-	* 		(converted=0x%x)\n", type, data, key);
-	*/
-
-	switch (type) {
-	case CINERGYT2_RC_EVENT_TYPE_NEC:
-		if (key == ~0) {
-			/* Stop key repeat */
-			*state = REMOTE_NO_KEY_PRESSED;
-			break;
-		}
-		found = 0;
-
-		for (i = 0; i < cinergyt2_rc_keys_size; i++) {
-			if (cinergyt2_rc_keys[i].data == key) {
-				*event = cinergyt2_rc_keys[i].event;
-				*state = REMOTE_KEY_PRESSED;
-				found = 1;
-				/* deb_info("Remote key pressed! key = %d\n",
-				* 		i);
-				*/
-				break;
-			}
-		}
-		if (found == 0)
-			err("cinergyT2: Unknown remote control key detected!"
-				"key=0x%x (raw=0x%x)\n", key, data);
-		break;
-
-	case CINERGYT2_RC_EVENT_TYPE_RC5:
-	case CINERGYT2_RC_EVENT_TYPE_NONE:
-	default:
-		info("Unhandled remote key detected! type=0x%x\n", type);
-		break;
-	}
-	return 0;
-}
-
-static int cinergyt2_rc_process(struct dvb_usb_device *dev)
-{
-	char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS };
-	struct cinergyt2_rc_event rc_events[12];
-	int len, i, state;
-	u32 event;
-	/* struct cinergyt2_device_state *st = dev->priv; */
-
-	len = cinergyt2_cmd(dev, buf, sizeof(buf),
-				(char *)rc_events, sizeof(rc_events), 0);
-	if (len < 0) {
-		/* printk(KERN_INFO "Failed to read RC event data!\n"); */
-		return 0;
-	}
-
-	if (len == 0)
-		return 0;
-
-	state = REMOTE_NO_KEY_PRESSED;
-
-	for (i = 0; i < (len / sizeof(rc_events[0])); i++) {
-		/* deb_info("[%d/%d] rc_events[%d].data = %x (converted=%x),
-		* 		type=%x\n",
-		*		i, len / sizeof(rc_events[0]),
-		*		i, rc_events[i].data,
-		*		le32_to_cpu(rc_events[i].data),
-		*		rc_events[i].custom);
-		 */
-
-		cinergyt2_decode_rc_key(dev, rc_events[i].custom,
-					rc_events[i].data, &event, &state);
-		switch (state) {
-		case REMOTE_NO_KEY_PRESSED:
-			break;
-
-		case REMOTE_KEY_PRESSED:
-			/* deb_rc("key pressed\n"); */
-			dev->last_event = event;
-			input_event(dev->rc_input_dev, EV_KEY,
-					event, 1);
-			input_event(dev->rc_input_dev, EV_KEY,
-					dev->last_event, 0);
-			input_sync(dev->rc_input_dev);
-			break;
-
-		case REMOTE_KEY_REPEAT:
-			/* deb_rc("key repeated\n"); */
-			input_event(dev->rc_input_dev, EV_KEY,
-					event, 1);
-			input_event(dev->rc_input_dev, EV_KEY,
-					dev->last_event, 0);
-			input_sync(dev->rc_input_dev);
-			break;
-		default:
-			break;
-		}
-
-	}
-	return 0;
-}
-
-/*
- * Code copied from dvb-usb-remote.c and modified for Cinergy T2
- */
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
-static void cinergyt2_read_remote_control(void *data)
-#else
-static void cinergyt2_read_remote_control(struct work_struct *work)
-#endif
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
-	struct dvb_usb_device *d = data;
-#else
-	struct dvb_usb_device *d =
-		container_of(work, struct dvb_usb_device,
-				rc_query_work.work);
-#endif
-
-	/* TODO: need a lock here.
-	* We can simply skip checking for the remote control
-	*  if we're busy.
-	*/
-
-	/* when the parameter has been set to 1 via sysfs while
-	* the driver was running
-	*/
-
-	if (disable_remote)
-		return;
-
-	if (cinergyt2_rc_process(d))
-		err("error while querying for an remote control event.");
-
-	schedule_delayed_work(&d->rc_query_work,
-				msecs_to_jiffies(d->props.rc_interval));
-}
-
-
-
-int cinergyt2_remote_init(struct dvb_usb_device *d)
-{
-	struct input_dev *input_dev;
-	int i;
-	int err;
-
-	if (disable_remote) {
-		err("Remote controller support disabled!\n");
-		return 0;
-	}
-
-	usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
-	strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
-
-	input_dev = input_allocate_device();
-	if (!input_dev) {
-		err("Failed to allocate new input device!\n");
-		return -ENOMEM;
-	}
-
-	input_dev->evbit[0] = BIT(EV_KEY);
-	input_dev->name = "IR-receiver inside an USB DVB receiver";
-	input_dev->phys = d->rc_phys;
-	usb_to_input_id(d->udev, &input_dev->id);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
-	input_dev->dev.parent = &d->udev->dev;
-#else
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
-	input_dev->cdev.dev = &d->udev->dev;
-#endif
-#endif
-
-	/* set the bits for the keys */
-	deb_rc("key map size: %d\n", cinergyt2_rc_keys_size);
-	for (i = 0; i < cinergyt2_rc_keys_size; i++) {
-		deb_rc("setting bit for event %d item %d\n",
-			cinergyt2_rc_keys[i].event, i);
-		set_bit(cinergyt2_rc_keys[i].event, input_dev->keybit);
-	}
-
-	/* Start the remote-control polling. */
-	if (d->props.rc_interval < 40)
-		d->props.rc_interval = 100; /* default */
-
-	/* setting these two values to non-zero,
-	 * we have to manage key repeats */
-
-	input_dev->rep[REP_PERIOD] = d->props.rc_interval;
-	input_dev->rep[REP_DELAY]  = d->props.rc_interval + 150;
-
-	err = input_register_device(input_dev);
-	if (err) {
-		input_free_device(input_dev);
-		err("Failed to register new input device!\n");
-		return err;
-	}
-
-	d->rc_input_dev = input_dev;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
-	INIT_WORK(&d->rc_query_work, cinergyt2_read_remote_control, d);
-#else
-	INIT_DELAYED_WORK(&d->rc_query_work, cinergyt2_read_remote_control);
-#endif
-
-	info("schedule remote query interval to %d msecs.",
-		d->props.rc_interval);
-
-	schedule_delayed_work(&d->rc_query_work,
-				msecs_to_jiffies(d->props.rc_interval));
-
-	d->state |= DVB_USB_STATE_REMOTE;
-
-	return 0;
-}
-EXPORT_SYMBOL(cinergyt2_remote_init);
-
-
-int cinergyt2_remote_exit(struct dvb_usb_device *d)
-{
-	if (d->state & DVB_USB_STATE_REMOTE) {
-		cancel_rearming_delayed_work(&d->rc_query_work);
-		flush_scheduled_work();
-		input_unregister_device(d->rc_input_dev);
-	}
-	d->state &= ~DVB_USB_STATE_REMOTE;
-	return 0;
-}
-EXPORT_SYMBOL(cinergyt2_remote_exit);
diff -r f51aa257acfa linux/drivers/media/dvb/dvb-usb/cinergyT2.h
--- a/linux/drivers/media/dvb/dvb-usb/cinergyT2.h	Thu May 08 22:53:56 2008 +0200
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2.h	Thu May 08 23:06:34 2008 +0200
@@ -37,7 +37,6 @@
 
 #define DRIVER_NAME "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"
 
-extern int disable_remote;
 extern int dvb_usb_cinergyt2_debug;
 
 #define deb_info(args...)  dprintk(dvb_usb_cinergyt2_debug,  0x001, args)
@@ -94,8 +93,5 @@
 extern int cinergyt2_cmd(struct dvb_usb_device *d,  char *wbuf,  int wlen,
 			char *rbuf,  int rlen,  int delay_ms);
 
-extern int cinergyt2_remote_init(struct dvb_usb_device *d);
-extern int cinergyt2_remote_exit(struct dvb_usb_device *d);
-
 #endif /* _DVB_USB_CINERGYT2_H_ */
 

[-- Attachment #3: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-08 20:47                     ` Ingo Peukes
@ 2008-05-12 18:32                       ` Tomi Orava
  2008-05-13 14:41                         ` Ingo Peukes
  0 siblings, 1 reply; 21+ messages in thread
From: Tomi Orava @ 2008-05-12 18:32 UTC (permalink / raw)
  To: Ingo Peukes; +Cc: linux-dvb


Hi,


> Well, as I said it compiles and works with the above kernel and v4l-dvb
> but w_scan finds no channels with this module most of the time. In 5
> runs it found 4 channels on one multiplex.
> I doubt it's the antenna although it's the stock one but if I use the
> cinergyT2 on my desktop pc with the original module of kernel 2.6.25.1
> w_scan finds all available channels all the time with the same antenna
> in the same place. I will try a better antenna tomorrow to see if I can
> use it somewhat productive in mythtv...

Does the "regular" scandvb work any better for you compared
to the older driver ?
BTW. Where's the source for this w_scan so that I could try it as well ?

Regards,
Tomi Orava
-- 



_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-08 21:18                       ` Thierry Merle
@ 2008-05-12 18:49                         ` Tomi Orava
  2008-05-12 19:05                           ` Patrick Boettcher
  2008-05-13 17:36                           ` Thierry Merle
  0 siblings, 2 replies; 21+ messages in thread
From: Tomi Orava @ 2008-05-12 18:49 UTC (permalink / raw)
  To: Thierry Merle; +Cc: linux-dvb

[-- Attachment #1: Type: text/plain, Size: 1737 bytes --]



Hi Thierry,

And thanks a lot for your patch. I've now updated the
Cinergy T2 driver patch with your remote control cleanup.

>> However, I did not replace the original Cinergy T2 driver
>> as I think that this new driver should be located in the
>> very same directory as the rest of the usb-dvb drivers.
>>
> Agreed, but you should remove the old cinergyT2 driver.

Ok, the attached version of the patch does remove the old driver.

> Furthermore there is another issue: when I plug the device, the device
> usage count is set to 0.
> When I remove the device the device usage count goes to -1 (displayed as
> 4294967295).
> This is a misbehavior of the dvb framework but perhaps something needs to
> be initialized somewhere in the driver. I will look at it...dvb-usb:
> TerraTec/qanu USB2.0 Highspeed DVB-T Receiver successfully initialized and
> connected.
> I noticed this error when I plug the device (I load manually the driver
> before, so I suspect a thing in the probe function):

In my understanding this is a bug in the dvb-usb-framework that cannot
be fixed in Cinergy T2 driver. I checked that if you DON'T define the
menuconfig option:

"Load and attach frontend and tuner driver modules as needed" ie.
the CONFIG_MEDIA_ATTACH

The framework will use a different version of the function called
"dvb_frontend_detach" and thefore it will not call the symbol_put_addr
on linux/drivers/media/dvb/dvb-core/dvb_frontend.c line 1220.
With this option deselected the module reference count seems to stay
in sane values.

> I will look at the module count problem and the irrecord problem, we are
> close to propose this beautiful patch ;)

Heh,heh :)

Regards,
Tomi Orava


-- 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: CinergyT2-V8.patch --]
[-- Type: text/x-patch; name="CinergyT2-V8.patch", Size: 58634 bytes --]

diff -r 41b3f12d6ce4 linux/drivers/media/dvb/Kconfig
--- a/linux/drivers/media/dvb/Kconfig	Tue May 06 11:09:01 2008 -0300
+++ b/linux/drivers/media/dvb/Kconfig	Mon May 12 21:42:16 2008 +0300
@@ -20,7 +20,6 @@ source "drivers/media/dvb/dvb-usb/Kconfi
 source "drivers/media/dvb/dvb-usb/Kconfig"
 source "drivers/media/dvb/ttusb-budget/Kconfig"
 source "drivers/media/dvb/ttusb-dec/Kconfig"
-source "drivers/media/dvb/cinergyT2/Kconfig"
 
 comment "Supported FlexCopII (B2C2) Adapters"
 	depends on DVB_CORE && (PCI || USB) && I2C
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/cinergyT2/Kconfig
--- a/linux/drivers/media/dvb/cinergyT2/Kconfig	Tue May 06 11:09:01 2008 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-config DVB_CINERGYT2
-	tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver"
-	depends on DVB_CORE && USB && INPUT
-	help
-	  Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers
-
-	  Say Y if you own such a device and want to use it.
-
-
-config DVB_CINERGYT2_TUNING
-	bool "sophisticated fine-tuning for CinergyT2 cards"
-	depends on DVB_CINERGYT2
-	help
-	  Here you can fine-tune some parameters of the CinergyT2 driver.
-
-	  Normally you don't need to touch this, but in exotic setups you
-	  may fine-tune your setup and adjust e.g. DMA buffer sizes for
-	  a particular application.
-
-
-config DVB_CINERGYT2_STREAM_URB_COUNT
-	int "Number of queued USB Request Blocks for Highspeed Stream Transfers"
-	depends on DVB_CINERGYT2_TUNING
-	default "32"
-	help
-	  USB Request Blocks for Highspeed Stream transfers are scheduled in
-	  a queue for the Host Controller.
-
-	  Usually the default value is a safe choice.
-
-	  You may increase this number if you are using this device in a
-	  Server Environment with many high-traffic USB Highspeed devices
-	  sharing the same USB bus.
-
-
-config DVB_CINERGYT2_STREAM_BUF_SIZE
-	int "Size of URB Stream Buffers for Highspeed Transfers"
-	depends on DVB_CINERGYT2_TUNING
-	default "512"
-	help
-	  Should be a multiple of native buffer size of 512 bytes.
-	  Default value is a safe choice.
-
-	  You may increase this number if you are using this device in a
-	  Server Environment with many high-traffic USB Highspeed devices
-	  sharing the same USB bus.
-
-
-config DVB_CINERGYT2_QUERY_INTERVAL
-	int "Status update interval [milliseconds]"
-	depends on DVB_CINERGYT2_TUNING
-	default "250"
-	help
-	  This is the interval for status readouts from the demodulator.
-	  You may try lower values if you need more responsive signal quality
-	  measurements.
-
-	  Please keep in mind that these updates cause traffic on the tuner
-	  control bus and thus may or may not affect reception sensitivity.
-
-	  The default value should be a safe choice for common applications.
-
-
-config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
-	bool "Register the onboard IR Remote Control Receiver as Input Device"
-	depends on DVB_CINERGYT2_TUNING
-	default y
-	help
-	  Enable this option if you want to use the onboard Infrared Remote
-	  Control Receiver as Linux-Input device.
-
-	  Right now only the keycode table for the default Remote Control
-	  delivered with the device is supported, please see the driver
-	  source code to find out how to add support for other controls.
-
-
-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 "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
-	  a safe choice.
-
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/cinergyT2/Makefile
--- a/linux/drivers/media/dvb/cinergyT2/Makefile	Tue May 06 11:09:01 2008 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-obj-$(CONFIG_DVB_CINERGYT2) += cinergyT2.o
-
-EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/cinergyT2/cinergyT2.c
--- a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c	Tue May 06 11:09:01 2008 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1178 +0,0 @@
-/*
- * TerraTec Cinergy T²/qanu USB2 DVB-T adapter.
- *
- * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
- *		    Holger Waechtler <holger@qanu.de>
- *
- *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/usb.h>
-#include <linux/input.h>
-#include <linux/dvb/frontend.h>
-#include "compat.h"
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
-#include <linux/mutex.h>
-#endif
-#include <linux/mm.h>
-#include <asm/io.h>
-
-#include "dmxdev.h"
-#include "dvb_demux.h"
-#include "dvb_net.h"
-
-#ifdef CONFIG_DVB_CINERGYT2_TUNING
-	#define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT)
-	#define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE)
-	#define QUERY_INTERVAL (CONFIG_DVB_CINERGYT2_QUERY_INTERVAL)
-	#ifdef CONFIG_DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
-		#define RC_QUERY_INTERVAL (CONFIG_DVB_CINERGYT2_RC_QUERY_INTERVAL)
-		#define ENABLE_RC (1)
-	#endif
-#else
-	#define STREAM_URB_COUNT (32)
-	#define STREAM_BUF_SIZE (512)	/* bytes */
-	#define ENABLE_RC (1)
-	#define RC_QUERY_INTERVAL (50)	/* milliseconds */
-	#define QUERY_INTERVAL (333)	/* milliseconds */
-#endif
-
-#define DRIVER_NAME "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"
-
-static int debug;
-module_param_named(debug, debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
-
-DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
-#define dprintk(level, args...)						\
-do {									\
-	if ((debug & level)) {						\
-		printk("%s: %s(): ", __stringify(KBUILD_MODNAME),	\
-		       __FUNCTION__);					\
-		printk(args); }						\
-} while (0)
-#else
-#define dprintk(level, args...)						\
-do {									\
-	if ((debug & level)) {						\
-		printk("%s: %s(): ", KBUILD_MODNAME,			\
-		       __func__);					\
-		printk(args); }						\
-} while (0)
-#endif
-
-enum cinergyt2_ep1_cmd {
-	CINERGYT2_EP1_PID_TABLE_RESET		= 0x01,
-	CINERGYT2_EP1_PID_SETUP			= 0x02,
-	CINERGYT2_EP1_CONTROL_STREAM_TRANSFER	= 0x03,
-	CINERGYT2_EP1_SET_TUNER_PARAMETERS	= 0x04,
-	CINERGYT2_EP1_GET_TUNER_STATUS		= 0x05,
-	CINERGYT2_EP1_START_SCAN		= 0x06,
-	CINERGYT2_EP1_CONTINUE_SCAN		= 0x07,
-	CINERGYT2_EP1_GET_RC_EVENTS		= 0x08,
-	CINERGYT2_EP1_SLEEP_MODE		= 0x09
-};
-
-struct dvbt_set_parameters_msg {
-	uint8_t cmd;
-	uint32_t freq;
-	uint8_t bandwidth;
-	uint16_t tps;
-	uint8_t flags;
-} __attribute__((packed));
-
-struct dvbt_get_status_msg {
-	uint32_t freq;
-	uint8_t bandwidth;
-	uint16_t tps;
-	uint8_t flags;
-	uint16_t gain;
-	uint8_t snr;
-	uint32_t viterbi_error_rate;
-	uint32_t rs_error_rate;
-	uint32_t uncorrected_block_count;
-	uint8_t lock_bits;
-	uint8_t prev_lock_bits;
-} __attribute__((packed));
-
-static struct dvb_frontend_info cinergyt2_fe_info = {
-	.name = DRIVER_NAME,
-	.type = FE_OFDM,
-	.frequency_min = 174000000,
-	.frequency_max = 862000000,
-	.frequency_stepsize = 166667,
-	.caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
-		FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
-		FE_CAN_FEC_AUTO |
-		FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
-		FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
-		FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER | FE_CAN_MUTE_TS
-};
-
-struct cinergyt2 {
-	struct dvb_demux demux;
-	struct usb_device *udev;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
-	struct mutex sem;
-	struct mutex wq_sem;
-#else
-	struct semaphore sem;
-	struct semaphore wq_sem;
-#endif
-	struct dvb_adapter adapter;
-	struct dvb_device *fedev;
-	struct dmxdev dmxdev;
-	struct dvb_net dvbnet;
-
-	int streaming;
-	int sleeping;
-
-	struct dvbt_set_parameters_msg param;
-	struct dvbt_get_status_msg status;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-	struct work_struct query_work;
-#else
-	struct delayed_work query_work;
-#endif
-
-	wait_queue_head_t poll_wq;
-	int pending_fe_events;
-	int disconnect_pending;
-	atomic_t inuse;
-
-	void *streambuf;
-	dma_addr_t streambuf_dmahandle;
-	struct urb *stream_urb [STREAM_URB_COUNT];
-
-#ifdef ENABLE_RC
-	struct input_dev *rc_input_dev;
-	char phys[64];
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-	struct work_struct rc_query_work;
-#else
-	struct delayed_work rc_query_work;
-#endif
-	int rc_input_event;
-	u32 rc_last_code;
-	unsigned long last_event_jiffies;
-#endif
-};
-
-enum {
-	CINERGYT2_RC_EVENT_TYPE_NONE = 0x00,
-	CINERGYT2_RC_EVENT_TYPE_NEC  = 0x01,
-	CINERGYT2_RC_EVENT_TYPE_RC5  = 0x02
-};
-
-struct cinergyt2_rc_event {
-	char type;
-	uint32_t value;
-} __attribute__((packed));
-
-static const uint32_t rc_keys[] = {
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xfe01eb04,	KEY_POWER,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xfd02eb04,	KEY_1,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xfc03eb04,	KEY_2,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xfb04eb04,	KEY_3,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xfa05eb04,	KEY_4,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf906eb04,	KEY_5,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf807eb04,	KEY_6,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf708eb04,	KEY_7,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf609eb04,	KEY_8,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf50aeb04,	KEY_9,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf30ceb04,	KEY_0,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf40beb04,	KEY_VIDEO,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf20deb04,	KEY_REFRESH,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf10eeb04,	KEY_SELECT,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xf00feb04,	KEY_EPG,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xef10eb04,	KEY_UP,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xeb14eb04,	KEY_DOWN,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xee11eb04,	KEY_LEFT,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xec13eb04,	KEY_RIGHT,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xed12eb04,	KEY_OK,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xea15eb04,	KEY_TEXT,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe916eb04,	KEY_INFO,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe817eb04,	KEY_RED,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe718eb04,	KEY_GREEN,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe619eb04,	KEY_YELLOW,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe51aeb04,	KEY_BLUE,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe31ceb04,	KEY_VOLUMEUP,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe11eeb04,	KEY_VOLUMEDOWN,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe21deb04,	KEY_MUTE,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe41beb04,	KEY_CHANNELUP,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xe01feb04,	KEY_CHANNELDOWN,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xbf40eb04,	KEY_PAUSE,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xb34ceb04,	KEY_PLAY,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xa758eb04,	KEY_RECORD,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xab54eb04,	KEY_PREVIOUS,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xb748eb04,	KEY_STOP,
-	CINERGYT2_RC_EVENT_TYPE_NEC,	0xa35ceb04,	KEY_NEXT
-};
-
-static int cinergyt2_command (struct cinergyt2 *cinergyt2,
-			      char *send_buf, int send_buf_len,
-			      char *recv_buf, int recv_buf_len)
-{
-	int actual_len;
-	char dummy;
-	int ret;
-
-	ret = usb_bulk_msg(cinergyt2->udev, usb_sndbulkpipe(cinergyt2->udev, 1),
-			   send_buf, send_buf_len, &actual_len, 1000);
-
-	if (ret)
-		dprintk(1, "usb_bulk_msg (send) failed, err %i\n", ret);
-
-	if (!recv_buf)
-		recv_buf = &dummy;
-
-	ret = usb_bulk_msg(cinergyt2->udev, usb_rcvbulkpipe(cinergyt2->udev, 1),
-			   recv_buf, recv_buf_len, &actual_len, 1000);
-
-	if (ret)
-		dprintk(1, "usb_bulk_msg (read) failed, err %i\n", ret);
-
-	return ret ? ret : actual_len;
-}
-
-static void cinergyt2_control_stream_transfer (struct cinergyt2 *cinergyt2, int enable)
-{
-	char buf [] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
-	cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
-}
-
-static void cinergyt2_sleep (struct cinergyt2 *cinergyt2, int sleep)
-{
-	char buf [] = { CINERGYT2_EP1_SLEEP_MODE, sleep ? 1 : 0 };
-	cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
-	cinergyt2->sleeping = sleep;
-}
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs);
-#else
-static void cinergyt2_stream_irq (struct urb *urb);
-#endif
-
-static int cinergyt2_submit_stream_urb (struct cinergyt2 *cinergyt2, struct urb *urb)
-{
-	int err;
-
-	usb_fill_bulk_urb(urb,
-			  cinergyt2->udev,
-			  usb_rcvbulkpipe(cinergyt2->udev, 0x2),
-			  urb->transfer_buffer,
-			  STREAM_BUF_SIZE,
-			  cinergyt2_stream_irq,
-			  cinergyt2);
-
-	if ((err = usb_submit_urb(urb, GFP_ATOMIC)))
-		dprintk(1, "urb submission failed (err = %i)!\n", err);
-
-	return err;
-}
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs)
-#else
-static void cinergyt2_stream_irq (struct urb *urb)
-#endif
-{
-	struct cinergyt2 *cinergyt2 = urb->context;
-
-	if (urb->actual_length > 0)
-		dvb_dmx_swfilter(&cinergyt2->demux,
-				 urb->transfer_buffer, urb->actual_length);
-
-	if (cinergyt2->streaming)
-		cinergyt2_submit_stream_urb(cinergyt2, urb);
-}
-
-static void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
-{
-	int i;
-
-	for (i=0; i<STREAM_URB_COUNT; i++)
-		usb_free_urb(cinergyt2->stream_urb[i]);
-
-	usb_buffer_free(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
-			    cinergyt2->streambuf, cinergyt2->streambuf_dmahandle);
-}
-
-static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
-{
-	int i;
-
-	cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
-					      GFP_KERNEL, &cinergyt2->streambuf_dmahandle);
-	if (!cinergyt2->streambuf) {
-		dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
-		return -ENOMEM;
-	}
-
-	memset(cinergyt2->streambuf, 0, STREAM_URB_COUNT*STREAM_BUF_SIZE);
-
-	for (i=0; i<STREAM_URB_COUNT; i++) {
-		struct urb *urb;
-
-		if (!(urb = usb_alloc_urb(0, GFP_ATOMIC))) {
-			dprintk(1, "failed to alloc consistent stream urbs, bailing out!\n");
-			cinergyt2_free_stream_urbs(cinergyt2);
-			return -ENOMEM;
-		}
-
-		urb->transfer_buffer = cinergyt2->streambuf + i * STREAM_BUF_SIZE;
-		urb->transfer_buffer_length = STREAM_BUF_SIZE;
-
-		cinergyt2->stream_urb[i] = urb;
-	}
-
-	return 0;
-}
-
-static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
-{
-	int i;
-
-	cinergyt2_control_stream_transfer(cinergyt2, 0);
-
-	for (i=0; i<STREAM_URB_COUNT; i++)
-		usb_kill_urb(cinergyt2->stream_urb[i]);
-}
-
-static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
-{
-	int i, err;
-
-	for (i=0; i<STREAM_URB_COUNT; i++) {
-		if ((err = cinergyt2_submit_stream_urb(cinergyt2, cinergyt2->stream_urb[i]))) {
-			cinergyt2_stop_stream_xfer(cinergyt2);
-			dprintk(1, "failed urb submission (%i: err = %i)!\n", i, err);
-			return err;
-		}
-	}
-
-	cinergyt2_control_stream_transfer(cinergyt2, 1);
-	return 0;
-}
-
-static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
-	struct dvb_demux *demux = dvbdmxfeed->demux;
-	struct cinergyt2 *cinergyt2 = demux->priv;
-
-	if (cinergyt2->disconnect_pending)
-		return -EAGAIN;
-	if (mutex_lock_interruptible(&cinergyt2->sem))
-		return -ERESTARTSYS;
-
-	if (cinergyt2->streaming == 0)
-		cinergyt2_start_stream_xfer(cinergyt2);
-
-	cinergyt2->streaming++;
-	mutex_unlock(&cinergyt2->sem);
-	return 0;
-}
-
-static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
-	struct dvb_demux *demux = dvbdmxfeed->demux;
-	struct cinergyt2 *cinergyt2 = demux->priv;
-
-	if (cinergyt2->disconnect_pending)
-		return -EAGAIN;
-	if (mutex_lock_interruptible(&cinergyt2->sem))
-		return -ERESTARTSYS;
-
-	if (--cinergyt2->streaming == 0)
-		cinergyt2_stop_stream_xfer(cinergyt2);
-
-	mutex_unlock(&cinergyt2->sem);
-	return 0;
-}
-
-/**
- *  convert linux-dvb frontend parameter set into TPS.
- *  See ETSI ETS-300744, section 4.6.2, table 9 for details.
- *
- *  This function is probably reusable and may better get placed in a support
- *  library.
- *
- *  We replace errornous fields by default TPS fields (the ones with value 0).
- */
-static uint16_t compute_tps (struct dvb_frontend_parameters *p)
-{
-	struct dvb_ofdm_parameters *op = &p->u.ofdm;
-	uint16_t tps = 0;
-
-	switch (op->code_rate_HP) {
-		case FEC_2_3:
-			tps |= (1 << 7);
-			break;
-		case FEC_3_4:
-			tps |= (2 << 7);
-			break;
-		case FEC_5_6:
-			tps |= (3 << 7);
-			break;
-		case FEC_7_8:
-			tps |= (4 << 7);
-			break;
-		case FEC_1_2:
-		case FEC_AUTO:
-		default:
-			/* tps |= (0 << 7) */;
-	}
-
-	switch (op->code_rate_LP) {
-		case FEC_2_3:
-			tps |= (1 << 4);
-			break;
-		case FEC_3_4:
-			tps |= (2 << 4);
-			break;
-		case FEC_5_6:
-			tps |= (3 << 4);
-			break;
-		case FEC_7_8:
-			tps |= (4 << 4);
-			break;
-		case FEC_1_2:
-		case FEC_AUTO:
-		default:
-			/* tps |= (0 << 4) */;
-	}
-
-	switch (op->constellation) {
-		case QAM_16:
-			tps |= (1 << 13);
-			break;
-		case QAM_64:
-			tps |= (2 << 13);
-			break;
-		case QPSK:
-		default:
-			/* tps |= (0 << 13) */;
-	}
-
-	switch (op->transmission_mode) {
-		case TRANSMISSION_MODE_8K:
-			tps |= (1 << 0);
-			break;
-		case TRANSMISSION_MODE_2K:
-		default:
-			/* tps |= (0 << 0) */;
-	}
-
-	switch (op->guard_interval) {
-		case GUARD_INTERVAL_1_16:
-			tps |= (1 << 2);
-			break;
-		case GUARD_INTERVAL_1_8:
-			tps |= (2 << 2);
-			break;
-		case GUARD_INTERVAL_1_4:
-			tps |= (3 << 2);
-			break;
-		case GUARD_INTERVAL_1_32:
-		default:
-			/* tps |= (0 << 2) */;
-	}
-
-	switch (op->hierarchy_information) {
-		case HIERARCHY_1:
-			tps |= (1 << 10);
-			break;
-		case HIERARCHY_2:
-			tps |= (2 << 10);
-			break;
-		case HIERARCHY_4:
-			tps |= (3 << 10);
-			break;
-		case HIERARCHY_NONE:
-		default:
-			/* tps |= (0 << 10) */;
-	}
-
-	return tps;
-}
-
-static int cinergyt2_open (struct inode *inode, struct file *file)
-{
-	struct dvb_device *dvbdev = file->private_data;
-	struct cinergyt2 *cinergyt2 = dvbdev->priv;
-	int err = -EAGAIN;
-
-	if (cinergyt2->disconnect_pending)
-		goto out;
-	err = mutex_lock_interruptible(&cinergyt2->wq_sem);
-	if (err)
-		goto out;
-
-	err = mutex_lock_interruptible(&cinergyt2->sem);
-	if (err)
-		goto out_unlock1;
-
-	if ((err = dvb_generic_open(inode, file)))
-		goto out_unlock2;
-
-	if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
-		cinergyt2_sleep(cinergyt2, 0);
-		schedule_delayed_work(&cinergyt2->query_work, HZ/2);
-	}
-
-	atomic_inc(&cinergyt2->inuse);
-
-out_unlock2:
-	mutex_unlock(&cinergyt2->sem);
-out_unlock1:
-	mutex_unlock(&cinergyt2->wq_sem);
-out:
-	return err;
-}
-
-static void cinergyt2_unregister(struct cinergyt2 *cinergyt2)
-{
-	dvb_net_release(&cinergyt2->dvbnet);
-	dvb_dmxdev_release(&cinergyt2->dmxdev);
-	dvb_dmx_release(&cinergyt2->demux);
-	dvb_unregister_device(cinergyt2->fedev);
-	dvb_unregister_adapter(&cinergyt2->adapter);
-
-	cinergyt2_free_stream_urbs(cinergyt2);
-	kfree(cinergyt2);
-}
-
-static int cinergyt2_release (struct inode *inode, struct file *file)
-{
-	struct dvb_device *dvbdev = file->private_data;
-	struct cinergyt2 *cinergyt2 = dvbdev->priv;
-
-	mutex_lock(&cinergyt2->wq_sem);
-
-	if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) {
-		cancel_rearming_delayed_work(&cinergyt2->query_work);
-
-		mutex_lock(&cinergyt2->sem);
-		cinergyt2_sleep(cinergyt2, 1);
-		mutex_unlock(&cinergyt2->sem);
-	}
-
-	mutex_unlock(&cinergyt2->wq_sem);
-
-	if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) {
-		warn("delayed unregister in release");
-		cinergyt2_unregister(cinergyt2);
-	}
-
-	return dvb_generic_release(inode, file);
-}
-
-static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct *wait)
-{
-	struct dvb_device *dvbdev = file->private_data;
-	struct cinergyt2 *cinergyt2 = dvbdev->priv;
-	unsigned int mask = 0;
-
-	if (cinergyt2->disconnect_pending)
-		return -EAGAIN;
-	if (mutex_lock_interruptible(&cinergyt2->sem))
-		return -ERESTARTSYS;
-
-	poll_wait(file, &cinergyt2->poll_wq, wait);
-
-	if (cinergyt2->pending_fe_events != 0)
-		mask |= (POLLIN | POLLRDNORM | POLLPRI);
-
-	mutex_unlock(&cinergyt2->sem);
-
-	return mask;
-}
-
-
-static int cinergyt2_ioctl (struct inode *inode, struct file *file,
-		     unsigned cmd, unsigned long arg)
-{
-	struct dvb_device *dvbdev = file->private_data;
-	struct cinergyt2 *cinergyt2 = dvbdev->priv;
-	struct dvbt_get_status_msg *stat = &cinergyt2->status;
-	fe_status_t status = 0;
-
-	switch (cmd) {
-	case FE_GET_INFO:
-		return copy_to_user((void __user*) arg, &cinergyt2_fe_info,
-				    sizeof(struct dvb_frontend_info));
-
-	case FE_READ_STATUS:
-		if (0xffff - le16_to_cpu(stat->gain) > 30)
-			status |= FE_HAS_SIGNAL;
-		if (stat->lock_bits & (1 << 6))
-			status |= FE_HAS_LOCK;
-		if (stat->lock_bits & (1 << 5))
-			status |= FE_HAS_SYNC;
-		if (stat->lock_bits & (1 << 4))
-			status |= FE_HAS_CARRIER;
-		if (stat->lock_bits & (1 << 1))
-			status |= FE_HAS_VITERBI;
-
-		return copy_to_user((void  __user*) arg, &status, sizeof(status));
-
-	case FE_READ_BER:
-		return put_user(le32_to_cpu(stat->viterbi_error_rate),
-				(__u32 __user *) arg);
-
-	case FE_READ_SIGNAL_STRENGTH:
-		return put_user(0xffff - le16_to_cpu(stat->gain),
-				(__u16 __user *) arg);
-
-	case FE_READ_SNR:
-		return put_user((stat->snr << 8) | stat->snr,
-				(__u16 __user *) arg);
-
-	case FE_READ_UNCORRECTED_BLOCKS:
-	{
-		uint32_t unc_count;
-
-		unc_count = stat->uncorrected_block_count;
-		stat->uncorrected_block_count = 0;
-
-		/* UNC are already converted to host byte order... */
-		return put_user(unc_count,(__u32 __user *) arg);
-	}
-	case FE_SET_FRONTEND:
-	{
-		struct dvbt_set_parameters_msg *param = &cinergyt2->param;
-		struct dvb_frontend_parameters p;
-		int err;
-
-		if ((file->f_flags & O_ACCMODE) == O_RDONLY)
-			return -EPERM;
-
-		if (copy_from_user(&p, (void  __user*) arg, sizeof(p)))
-			return -EFAULT;
-
-		if (cinergyt2->disconnect_pending)
-			return -EAGAIN;
-		if (mutex_lock_interruptible(&cinergyt2->sem))
-			return -ERESTARTSYS;
-
-		param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
-		param->tps = cpu_to_le16(compute_tps(&p));
-		param->freq = cpu_to_le32(p.frequency / 1000);
-		param->bandwidth = 8 - p.u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
-
-		stat->lock_bits = 0;
-		cinergyt2->pending_fe_events++;
-		wake_up_interruptible(&cinergyt2->poll_wq);
-
-		err = cinergyt2_command(cinergyt2,
-					(char *) param, sizeof(*param),
-					NULL, 0);
-
-		mutex_unlock(&cinergyt2->sem);
-
-		return (err < 0) ? err : 0;
-	}
-
-	case FE_GET_FRONTEND:
-		/**
-		 *  trivial to implement (see struct dvbt_get_status_msg).
-		 *  equivalent to FE_READ ioctls, but needs
-		 *  TPS -> linux-dvb parameter set conversion. Feel free
-		 *  to implement this and send us a patch if you need this
-		 *  functionality.
-		 */
-		break;
-
-	case FE_GET_EVENT:
-	{
-		/**
-		 *  for now we only fill the status field. the parameters
-		 *  are trivial to fill as soon FE_GET_FRONTEND is done.
-		 */
-		struct dvb_frontend_event __user *e = (void __user *) arg;
-		if (cinergyt2->pending_fe_events == 0) {
-			if (file->f_flags & O_NONBLOCK)
-				return -EWOULDBLOCK;
-			wait_event_interruptible(cinergyt2->poll_wq,
-						 cinergyt2->pending_fe_events > 0);
-		}
-		cinergyt2->pending_fe_events = 0;
-		return cinergyt2_ioctl(inode, file, FE_READ_STATUS,
-					(unsigned long) &e->status);
-	}
-
-	default:
-		;
-	}
-
-	return -EINVAL;
-}
-
-static int cinergyt2_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct dvb_device *dvbdev = file->private_data;
-	struct cinergyt2 *cinergyt2 = dvbdev->priv;
-	int ret = 0;
-
-	lock_kernel();
-
-	if (vma->vm_flags & (VM_WRITE | VM_EXEC)) {
-		ret = -EPERM;
-		goto bailout;
-	}
-
-	if (vma->vm_end > vma->vm_start + STREAM_URB_COUNT * STREAM_BUF_SIZE) {
-		ret = -EINVAL;
-		goto bailout;
-	}
-
-	vma->vm_flags |= (VM_IO | VM_DONTCOPY);
-	vma->vm_file = file;
-
-	ret = remap_pfn_range(vma, vma->vm_start,
-			      virt_to_phys(cinergyt2->streambuf) >> PAGE_SHIFT,
-			      vma->vm_end - vma->vm_start,
-			      vma->vm_page_prot) ? -EAGAIN : 0;
-bailout:
-	unlock_kernel();
-	return ret;
-}
-
-static struct file_operations cinergyt2_fops = {
-	.owner          = THIS_MODULE,
-	.ioctl		= cinergyt2_ioctl,
-	.poll           = cinergyt2_poll,
-	.open           = cinergyt2_open,
-	.release        = cinergyt2_release,
-	.mmap		= cinergyt2_mmap
-};
-
-static struct dvb_device cinergyt2_fe_template = {
-	.users = ~0,
-	.writers = 1,
-	.readers = (~0)-1,
-	.fops = &cinergyt2_fops
-};
-
-#ifdef ENABLE_RC
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void cinergyt2_query_rc (void *data)
-#else
-static void cinergyt2_query_rc (struct work_struct *work)
-#endif
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-	struct cinergyt2 *cinergyt2 = data;
-#else
-	struct cinergyt2 *cinergyt2 =
-		container_of(work, struct cinergyt2, rc_query_work.work);
-#endif
-	char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS };
-	struct cinergyt2_rc_event rc_events[12];
-	int n, len, i;
-
-	if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
-		return;
-
-	len = cinergyt2_command(cinergyt2, buf, sizeof(buf),
-				(char *) rc_events, sizeof(rc_events));
-	if (len < 0)
-		goto out;
-	if (len == 0) {
-		if (time_after(jiffies, cinergyt2->last_event_jiffies +
-			       msecs_to_jiffies(150))) {
-			/* stop key repeat */
-			if (cinergyt2->rc_input_event != KEY_MAX) {
-				dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event);
-				input_report_key(cinergyt2->rc_input_dev,
-						 cinergyt2->rc_input_event, 0);
-				input_sync(cinergyt2->rc_input_dev);
-				cinergyt2->rc_input_event = KEY_MAX;
-			}
-			cinergyt2->rc_last_code = ~0;
-		}
-		goto out;
-	}
-	cinergyt2->last_event_jiffies = jiffies;
-
-	for (n = 0; n < (len / sizeof(rc_events[0])); n++) {
-		dprintk(1, "rc_events[%d].value = %x, type=%x\n",
-			n, le32_to_cpu(rc_events[n].value), rc_events[n].type);
-
-		if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC &&
-		    rc_events[n].value == ~0) {
-			/* keyrepeat bit -> just repeat last rc_input_event */
-		} else {
-			cinergyt2->rc_input_event = KEY_MAX;
-			for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3) {
-				if (rc_keys[i + 0] == rc_events[n].type &&
-				    rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) {
-					cinergyt2->rc_input_event = rc_keys[i + 2];
-					break;
-				}
-			}
-		}
-
-		if (cinergyt2->rc_input_event != KEY_MAX) {
-			if (rc_events[n].value == cinergyt2->rc_last_code &&
-			    cinergyt2->rc_last_code != ~0) {
-				/* emit a key-up so the double event is recognized */
-				dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event);
-				input_report_key(cinergyt2->rc_input_dev,
-						 cinergyt2->rc_input_event, 0);
-			}
-			dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event);
-			input_report_key(cinergyt2->rc_input_dev,
-					 cinergyt2->rc_input_event, 1);
-			input_sync(cinergyt2->rc_input_dev);
-			cinergyt2->rc_last_code = rc_events[n].value;
-		}
-	}
-
-out:
-	schedule_delayed_work(&cinergyt2->rc_query_work,
-			      msecs_to_jiffies(RC_QUERY_INTERVAL));
-
-	mutex_unlock(&cinergyt2->sem);
-}
-
-static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
-{
-	struct input_dev *input_dev;
-	int i;
-	int err;
-
-	input_dev = input_allocate_device();
-	if (!input_dev)
-		return -ENOMEM;
-
-	usb_make_path(cinergyt2->udev, cinergyt2->phys, sizeof(cinergyt2->phys));
-	strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys));
-	cinergyt2->rc_input_event = KEY_MAX;
-	cinergyt2->rc_last_code = ~0;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-	INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2);
-#else
-	INIT_DELAYED_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc);
-#endif
-
-	input_dev->name = DRIVER_NAME " remote control";
-	input_dev->phys = cinergyt2->phys;
-	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
-	for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3)
-		set_bit(rc_keys[i + 2], input_dev->keybit);
-	input_dev->keycodesize = 0;
-	input_dev->keycodemax = 0;
-	input_dev->id.bustype = BUS_USB;
-	input_dev->id.vendor = cinergyt2->udev->descriptor.idVendor;
-	input_dev->id.product = cinergyt2->udev->descriptor.idProduct;
-	input_dev->id.version = 1;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
-	input_dev->dev.parent = &cinergyt2->udev->dev;
-#else
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
-	input_dev->cdev.dev = &cinergyt2->udev->dev;
-#else
-	input_dev->dev = &cinergyt2->udev->dev;
-#endif
-#endif
-
-	err = input_register_device(input_dev);
-	if (err) {
-		input_free_device(input_dev);
-		return err;
-	}
-
-	cinergyt2->rc_input_dev = input_dev;
-	schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
-
-	return 0;
-}
-
-static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2)
-{
-	cancel_rearming_delayed_work(&cinergyt2->rc_query_work);
-	input_unregister_device(cinergyt2->rc_input_dev);
-}
-
-static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2)
-{
-	cancel_rearming_delayed_work(&cinergyt2->rc_query_work);
-}
-
-static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2)
-{
-	schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
-}
-
-#else
-
-static inline int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) { return 0; }
-static inline void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2) { }
-static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2) { }
-static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) { }
-
-#endif /* ENABLE_RC */
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void cinergyt2_query (void *data)
-#else
-static void cinergyt2_query (struct work_struct *work)
-#endif
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-	struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data;
-#else
-	struct cinergyt2 *cinergyt2 =
-		container_of(work, struct cinergyt2, query_work.work);
-#endif
-	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
-	struct dvbt_get_status_msg *s = &cinergyt2->status;
-	uint8_t lock_bits;
-	uint32_t unc;
-
-	if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
-		return;
-
-	unc = s->uncorrected_block_count;
-	lock_bits = s->lock_bits;
-
-	cinergyt2_command(cinergyt2, cmd, sizeof(cmd), (char *) s, sizeof(*s));
-
-	unc += le32_to_cpu(s->uncorrected_block_count);
-	s->uncorrected_block_count = unc;
-
-	if (lock_bits != s->lock_bits) {
-		wake_up_interruptible(&cinergyt2->poll_wq);
-		cinergyt2->pending_fe_events++;
-	}
-
-	schedule_delayed_work(&cinergyt2->query_work,
-			      msecs_to_jiffies(QUERY_INTERVAL));
-
-	mutex_unlock(&cinergyt2->sem);
-}
-
-static int cinergyt2_probe (struct usb_interface *intf,
-		  const struct usb_device_id *id)
-{
-	struct cinergyt2 *cinergyt2;
-	int err;
-
-	if (!(cinergyt2 = kzalloc (sizeof(struct cinergyt2), GFP_KERNEL))) {
-		dprintk(1, "out of memory?!?\n");
-		return -ENOMEM;
-	}
-
-	usb_set_intfdata (intf, (void *) cinergyt2);
-
-	mutex_init(&cinergyt2->sem);
-	mutex_init(&cinergyt2->wq_sem);
-	init_waitqueue_head (&cinergyt2->poll_wq);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-	INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2);
-#else
-	INIT_DELAYED_WORK(&cinergyt2->query_work, cinergyt2_query);
-#endif
-
-	cinergyt2->udev = interface_to_usbdev(intf);
-	cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
-
-	if (cinergyt2_alloc_stream_urbs (cinergyt2) < 0) {
-		dprintk(1, "unable to allocate stream urbs\n");
-		kfree(cinergyt2);
-		return -ENOMEM;
-	}
-
-	err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME,
-				   THIS_MODULE, &cinergyt2->udev->dev,
-				   adapter_nr);
-	if (err < 0) {
-		kfree(cinergyt2);
-		return err;
-	}
-
-	cinergyt2->demux.priv = cinergyt2;
-	cinergyt2->demux.filternum = 256;
-	cinergyt2->demux.feednum = 256;
-	cinergyt2->demux.start_feed = cinergyt2_start_feed;
-	cinergyt2->demux.stop_feed = cinergyt2_stop_feed;
-	cinergyt2->demux.dmx.capabilities = DMX_TS_FILTERING |
-					    DMX_SECTION_FILTERING |
-					    DMX_MEMORY_BASED_FILTERING;
-
-	if ((err = dvb_dmx_init(&cinergyt2->demux)) < 0) {
-		dprintk(1, "dvb_dmx_init() failed (err = %d)\n", err);
-		goto bailout;
-	}
-
-	cinergyt2->dmxdev.filternum = cinergyt2->demux.filternum;
-	cinergyt2->dmxdev.demux = &cinergyt2->demux.dmx;
-	cinergyt2->dmxdev.capabilities = 0;
-
-	if ((err = dvb_dmxdev_init(&cinergyt2->dmxdev, &cinergyt2->adapter)) < 0) {
-		dprintk(1, "dvb_dmxdev_init() failed (err = %d)\n", err);
-		goto bailout;
-	}
-
-	if (dvb_net_init(&cinergyt2->adapter, &cinergyt2->dvbnet, &cinergyt2->demux.dmx))
-		dprintk(1, "dvb_net_init() failed!\n");
-
-	dvb_register_device(&cinergyt2->adapter, &cinergyt2->fedev,
-			    &cinergyt2_fe_template, cinergyt2,
-			    DVB_DEVICE_FRONTEND);
-
-	err = cinergyt2_register_rc(cinergyt2);
-	if (err)
-		goto bailout;
-
-	return 0;
-
-bailout:
-	dvb_net_release(&cinergyt2->dvbnet);
-	dvb_dmxdev_release(&cinergyt2->dmxdev);
-	dvb_dmx_release(&cinergyt2->demux);
-	dvb_unregister_adapter(&cinergyt2->adapter);
-	cinergyt2_free_stream_urbs(cinergyt2);
-	kfree(cinergyt2);
-	return -ENOMEM;
-}
-
-static void cinergyt2_disconnect (struct usb_interface *intf)
-{
-	struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
-
-	cinergyt2_unregister_rc(cinergyt2);
-	cancel_rearming_delayed_work(&cinergyt2->query_work);
-	wake_up_interruptible(&cinergyt2->poll_wq);
-
-	cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx);
-	cinergyt2->disconnect_pending = 1;
-
-	if (!atomic_read(&cinergyt2->inuse))
-		cinergyt2_unregister(cinergyt2);
-}
-
-static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
-{
-	struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
-
-	if (cinergyt2->disconnect_pending)
-		return -EAGAIN;
-	if (mutex_lock_interruptible(&cinergyt2->wq_sem))
-		return -ERESTARTSYS;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
-	if (state <= 0) {
-		mutex_unlock(&cinergyt2->wq_sem);
-		return 0;
-	}
-#endif
-	cinergyt2_suspend_rc(cinergyt2);
-	cancel_rearming_delayed_work(&cinergyt2->query_work);
-
-	mutex_lock(&cinergyt2->sem);
-	if (cinergyt2->streaming)
-		cinergyt2_stop_stream_xfer(cinergyt2);
-	cinergyt2_sleep(cinergyt2, 1);
-	mutex_unlock(&cinergyt2->sem);
-
-	mutex_unlock(&cinergyt2->wq_sem);
-
-	return 0;
-}
-
-static int cinergyt2_resume (struct usb_interface *intf)
-{
-	struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
-	struct dvbt_set_parameters_msg *param = &cinergyt2->param;
-	int err = -EAGAIN;
-
-	if (cinergyt2->disconnect_pending)
-		goto out;
-	err = mutex_lock_interruptible(&cinergyt2->wq_sem);
-	if (err)
-		goto out;
-
-	err = mutex_lock_interruptible(&cinergyt2->sem);
-	if (err)
-		goto out_unlock1;
-
-	if (!cinergyt2->sleeping) {
-		cinergyt2_sleep(cinergyt2, 0);
-		cinergyt2_command(cinergyt2, (char *) param, sizeof(*param), NULL, 0);
-		if (cinergyt2->streaming)
-			cinergyt2_start_stream_xfer(cinergyt2);
-		schedule_delayed_work(&cinergyt2->query_work, HZ/2);
-	}
-
-	cinergyt2_resume_rc(cinergyt2);
-
-	mutex_unlock(&cinergyt2->sem);
-out_unlock1:
-	mutex_unlock(&cinergyt2->wq_sem);
-out:
-	return err;
-}
-
-static const struct usb_device_id cinergyt2_table [] __devinitdata = {
-	{ USB_DEVICE(0x0ccd, 0x0038) },
-	{ 0 }
-};
-
-MODULE_DEVICE_TABLE(usb, cinergyt2_table);
-
-static struct usb_driver cinergyt2_driver = {
-#if LINUX_VERSION_CODE <=  KERNEL_VERSION(2,6,15)
-	.owner	= THIS_MODULE,
-#endif
-	.name	= "cinergyT2",
-	.probe	= cinergyt2_probe,
-	.disconnect	= cinergyt2_disconnect,
-	.suspend	= cinergyt2_suspend,
-	.resume		= cinergyt2_resume,
-	.id_table	= cinergyt2_table
-};
-
-static int __init cinergyt2_init (void)
-{
-	int err;
-
-	if ((err = usb_register(&cinergyt2_driver)) < 0)
-		dprintk(1, "usb_register() failed! (err %i)\n", err);
-
-	return err;
-}
-
-static void __exit cinergyt2_exit (void)
-{
-	usb_deregister(&cinergyt2_driver);
-}
-
-module_init (cinergyt2_init);
-module_exit (cinergyt2_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Holger Waechtler, Daniel Mack");
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/Kconfig
--- a/linux/drivers/media/dvb/dvb-usb/Kconfig	Tue May 06 11:09:01 2008 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/Kconfig	Mon May 12 21:42:16 2008 +0300
@@ -241,3 +241,11 @@ config DVB_USB_AF9005_REMOTE
 	  Say Y here to support the default remote control decoding for the
 	  Afatech AF9005 based receiver.
 
+config 	DVB_USB_CINERGY_T2
+	tristate "Terratec CinergyT2/qanu USB 2.0 DVB-T receiver"
+	depends on DVB_USB
+	help
+	  Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers
+
+	  Say Y if you own such a device and want to use it.
+
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/Makefile
--- a/linux/drivers/media/dvb/dvb-usb/Makefile	Tue May 06 11:09:01 2008 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/Makefile	Mon May 12 21:42:16 2008 +0300
@@ -61,6 +61,10 @@ dvb-usb-af9005-remote-objs = af9005-remo
 dvb-usb-af9005-remote-objs = af9005-remote.o
 obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o
 
+dvb-usb-cinergyT2-objs = cinergyT2-core.o cinergyT2-fe.o
+obj-$(CONFIG_DVB_USB_CINERGY_T2) += dvb-usb-cinergyT2.o
+
+
 EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
 # due to tuner-xc3028
 EXTRA_CFLAGS += -Idrivers/media/common/tuners
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c	Mon May 12 21:42:16 2008 +0300
@@ -0,0 +1,230 @@
+/*
+ * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
+ *
+ * Based on the dvb-usb-framework code and the
+ * original Terratec Cinergy T2 driver by:
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *		    Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "cinergyT2.h"
+
+
+/* debug */
+int dvb_usb_cinergyt2_debug;
+int disable_remote;
+
+module_param_named(debug, dvb_usb_cinergyt2_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info, xfer=2, rc=4 "
+		"(or-able)).");
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+
+/* We are missing a release hook with usb_device data */
+struct dvb_usb_device *cinergyt2_usb_device;
+
+static struct dvb_usb_device_properties cinergyt2_properties;
+
+static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable)
+{
+	char buf [] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
+	char result[64];
+	return dvb_usb_generic_rw(adap->dev, buf, sizeof(buf), result,
+				sizeof(result), 0);
+}
+
+static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable)
+{
+	char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 };
+	char state[3];
+	return dvb_usb_generic_rw(d, buf, sizeof(buf), state, sizeof(state), 0);
+}
+
+static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
+{
+	char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION };
+	char state[3];
+	int ret;
+
+	adap->fe = cinergyt2_fe_attach(adap->dev);
+
+	ret = dvb_usb_generic_rw(adap->dev, query, sizeof(query), state,
+				sizeof(state), 0);
+	if (ret < 0) {
+		deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep "
+			"state info\n");
+	}
+
+	/* Copy this pointer as we are gonna need it in the release phase */
+	cinergyt2_usb_device = adap->dev;
+
+	return 0;
+}
+
+static struct dvb_usb_rc_key cinergyt2_rc_keys [] = {
+	{ 0x04,	0x01,	KEY_POWER },
+	{ 0x04,	0x02,	KEY_1 },
+	{ 0x04,	0x03,	KEY_2 },
+	{ 0x04,	0x04,	KEY_3 },
+	{ 0x04,	0x05,	KEY_4 },
+	{ 0x04,	0x06,	KEY_5 },
+	{ 0x04,	0x07,	KEY_6 },
+	{ 0x04,	0x08,	KEY_7 },
+	{ 0x04,	0x09,	KEY_8 },
+	{ 0x04,	0x0a,	KEY_9 },
+	{ 0x04,	0x0c,	KEY_0 },
+	{ 0x04,	0x0b,	KEY_VIDEO },
+	{ 0x04,	0x0d,	KEY_REFRESH },
+	{ 0x04,	0x0e,	KEY_SELECT },
+	{ 0x04,	0x0f,	KEY_EPG },
+	{ 0x04,	0x10,	KEY_UP },
+	{ 0x04,	0x14,	KEY_DOWN },
+	{ 0x04,	0x11,	KEY_LEFT },
+	{ 0x04,	0x13,	KEY_RIGHT },
+	{ 0x04,	0x12,	KEY_OK },
+	{ 0x04,	0x15,	KEY_TEXT },
+	{ 0x04,	0x16,	KEY_INFO },
+	{ 0x04,	0x17,	KEY_RED },
+	{ 0x04,	0x18,	KEY_GREEN },
+	{ 0x04,	0x19,	KEY_YELLOW },
+	{ 0x04,	0x1a,	KEY_BLUE },
+	{ 0x04,	0x1c,	KEY_VOLUMEUP },
+	{ 0x04,	0x1e,	KEY_VOLUMEDOWN },
+	{ 0x04,	0x1d,	KEY_MUTE },
+	{ 0x04,	0x1b,	KEY_CHANNELUP },
+	{ 0x04,	0x1f,	KEY_CHANNELDOWN },
+	{ 0x04,	0x40,	KEY_PAUSE },
+	{ 0x04,	0x4c,	KEY_PLAY },
+	{ 0x04,	0x58,	KEY_RECORD },
+	{ 0x04,	0x54,	KEY_PREVIOUS },
+	{ 0x04,	0x48,	KEY_STOP },
+	{ 0x04,	0x5c,	KEY_NEXT }
+};
+
+static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
+{
+	u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS;
+	*state = REMOTE_NO_KEY_PRESSED;
+
+	dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0);
+	if (key[4] == 0xff)
+		return 0;
+
+	/* hack to pass checksum on the custom field (is set to 0xeb) */
+	key[2] = ~0x04;
+	dvb_usb_nec_rc_key_to_event(d, key, event, state);
+	if (key[0] != 0)
+		deb_info("key: %x %x %x %x %x\n",
+			 key[0], key[1], key[2], key[3], key[4]);
+
+	return 0;
+}
+
+static int cinergyt2_usb_probe(struct usb_interface *intf,
+				const struct usb_device_id *id)
+{
+	return dvb_usb_device_init(intf, &cinergyt2_properties,
+					THIS_MODULE, NULL, adapter_nr);
+}
+
+
+static struct usb_device_id cinergyt2_usb_table [] = {
+	{ USB_DEVICE(USB_VID_TERRATEC, 0x0038) },
+	{ 0 }
+};
+
+MODULE_DEVICE_TABLE(usb, cinergyt2_usb_table);
+
+static struct dvb_usb_device_properties cinergyt2_properties = {
+
+	.num_adapters = 1,
+	.adapter = {
+		{
+			.streaming_ctrl   = cinergyt2_streaming_ctrl,
+			.frontend_attach  = cinergyt2_frontend_attach,
+
+			/* parameter for the MPEG2-data transfer */
+			.stream = {
+				.type = USB_BULK,
+				.count = 5,
+				.endpoint = 0x02,
+				.u = {
+					.bulk = {
+						.buffersize = 512,
+					}
+				}
+			},
+		}
+	},
+
+	.power_ctrl       = cinergyt2_power_ctrl,
+
+	.rc_interval      = 50,
+	.rc_key_map       = cinergyt2_rc_keys,
+	.rc_key_map_size  = ARRAY_SIZE(cinergyt2_rc_keys),
+	.rc_query         = cinergyt2_rc_query,
+
+	.generic_bulk_ctrl_endpoint = 1,
+
+	.num_device_descs = 1,
+	.devices = {
+		{ .name = "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver",
+		  .cold_ids = {NULL},
+		  .warm_ids = { &cinergyt2_usb_table[0], NULL },
+		},
+		{ NULL },
+	}
+};
+
+
+static struct usb_driver cinergyt2_driver = {
+	.name		= "cinergyT2",
+	.probe		= cinergyt2_usb_probe,
+	.disconnect	= dvb_usb_device_exit,
+	.id_table	= cinergyt2_usb_table
+};
+
+static int __init cinergyt2_usb_init(void)
+{
+	int err;
+
+	err = usb_register(&cinergyt2_driver);
+	if (err) {
+		err("usb_register() failed! (err %i)\n", err);
+		return err;
+	}
+	return 0;
+}
+
+static void __exit cinergyt2_usb_exit(void)
+{
+	usb_deregister(&cinergyt2_driver);
+}
+
+module_init(cinergyt2_usb_init);
+module_exit(cinergyt2_usb_exit);
+
+MODULE_DESCRIPTION("Terratec Cinergy T2 DVB-T driver");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Tomi Orava");
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-fe.c	Mon May 12 21:42:16 2008 +0300
@@ -0,0 +1,351 @@
+/*
+ * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
+ *
+ * Based on the dvb-usb-framework code and the
+ * original Terratec Cinergy T2 driver by:
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *                  Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "cinergyT2.h"
+
+
+/**
+ *  convert linux-dvb frontend parameter set into TPS.
+ *  See ETSI ETS-300744, section 4.6.2, table 9 for details.
+ *
+ *  This function is probably reusable and may better get placed in a support
+ *  library.
+ *
+ *  We replace errornous fields by default TPS fields (the ones with value 0).
+ */
+
+static uint16_t compute_tps(struct dvb_frontend_parameters *p)
+{
+	struct dvb_ofdm_parameters *op = &p->u.ofdm;
+	uint16_t tps = 0;
+
+	switch (op->code_rate_HP) {
+	case FEC_2_3:
+		tps |= (1 << 7);
+		break;
+	case FEC_3_4:
+		tps |= (2 << 7);
+		break;
+	case FEC_5_6:
+		tps |= (3 << 7);
+		break;
+	case FEC_7_8:
+		tps |= (4 << 7);
+		break;
+	case FEC_1_2:
+	case FEC_AUTO:
+	default:
+		/* tps |= (0 << 7) */;
+	}
+
+	switch (op->code_rate_LP) {
+	case FEC_2_3:
+		tps |= (1 << 4);
+		break;
+	case FEC_3_4:
+		tps |= (2 << 4);
+		break;
+	case FEC_5_6:
+		tps |= (3 << 4);
+		break;
+	case FEC_7_8:
+		tps |= (4 << 4);
+		break;
+	case FEC_1_2:
+	case FEC_AUTO:
+	default:
+		/* tps |= (0 << 4) */;
+	}
+
+	switch (op->constellation) {
+	case QAM_16:
+		tps |= (1 << 13);
+		break;
+	case QAM_64:
+		tps |= (2 << 13);
+		break;
+	case QPSK:
+	default:
+		/* tps |= (0 << 13) */;
+	}
+
+	switch (op->transmission_mode) {
+	case TRANSMISSION_MODE_8K:
+		tps |= (1 << 0);
+		break;
+	case TRANSMISSION_MODE_2K:
+	default:
+		/* tps |= (0 << 0) */;
+	}
+
+	switch (op->guard_interval) {
+	case GUARD_INTERVAL_1_16:
+		tps |= (1 << 2);
+		break;
+	case GUARD_INTERVAL_1_8:
+		tps |= (2 << 2);
+		break;
+	case GUARD_INTERVAL_1_4:
+		tps |= (3 << 2);
+		break;
+	case GUARD_INTERVAL_1_32:
+	default:
+		/* tps |= (0 << 2) */;
+	}
+
+	switch (op->hierarchy_information) {
+	case HIERARCHY_1:
+		tps |= (1 << 10);
+		break;
+	case HIERARCHY_2:
+		tps |= (2 << 10);
+		break;
+	case HIERARCHY_4:
+		tps |= (3 << 10);
+		break;
+	case HIERARCHY_NONE:
+	default:
+		/* tps |= (0 << 10) */;
+	}
+
+	return tps;
+}
+
+struct cinergyt2_fe_state {
+	struct dvb_frontend fe;
+	struct dvb_usb_device *d;
+};
+
+static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
+					fe_status_t *status)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg result;
+	u8 cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result,
+			sizeof(result), 0);
+	if (ret < 0)
+		return ret;
+
+	*status = 0;
+
+	if (0xffff - le16_to_cpu(result.gain) > 30)
+		*status |= FE_HAS_SIGNAL;
+	if (result.lock_bits & (1 << 6))
+		*status |= FE_HAS_LOCK;
+	if (result.lock_bits & (1 << 5))
+		*status |= FE_HAS_SYNC;
+	if (result.lock_bits & (1 << 4))
+		*status |= FE_HAS_CARRIER;
+	if (result.lock_bits & (1 << 1))
+		*status |= FE_HAS_VITERBI;
+
+	if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
+			(FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
+		*status &= ~FE_HAS_LOCK;
+
+	return 0;
+}
+
+static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
+				sizeof(status), 0);
+	if (ret < 0)
+		return ret;
+
+	*ber = le32_to_cpu(status.viterbi_error_rate);
+	return 0;
+}
+
+static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	u8 cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status,
+				sizeof(status), 0);
+	if (ret < 0) {
+		err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n",
+			ret);
+		return ret;
+	}
+	*unc = le32_to_cpu(status.uncorrected_block_count);
+	return 0;
+}
+
+static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe,
+						u16 *strength)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
+				sizeof(status), 0);
+	if (ret < 0) {
+		err("cinergyt2_fe_read_signal_strength() Failed!"
+			" (Error=%d)\n", ret);
+		return ret;
+	}
+	*strength = (0xffff - le16_to_cpu(status.gain));
+	return 0;
+}
+
+static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_get_status_msg status;
+	char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
+	int ret;
+
+	ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
+				sizeof(status), 0);
+	if (ret < 0) {
+		err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret);
+		return ret;
+	}
+	*snr = (status.snr << 8) | status.snr;
+	return 0;
+}
+
+static int cinergyt2_fe_init(struct dvb_frontend *fe)
+{
+	return 0;
+}
+
+static int cinergyt2_fe_sleep(struct dvb_frontend *fe)
+{
+	deb_info("cinergyt2_fe_sleep() Called\n");
+	return 0;
+}
+
+static int cinergyt2_fe_get_tune_settings(struct dvb_frontend *fe,
+				struct dvb_frontend_tune_settings *tune)
+{
+	tune->min_delay_ms = 800;
+	return 0;
+}
+
+static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe,
+				  struct dvb_frontend_parameters *fep)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	struct dvbt_set_parameters_msg param;
+	char result[2];
+	int err;
+
+	param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
+	param.tps = cpu_to_le16(compute_tps(fep));
+	param.freq = cpu_to_le32(fep->frequency / 1000);
+	param.bandwidth = 8 - fep->u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
+
+	err = dvb_usb_generic_rw(state->d,
+			(char *)&param, sizeof(param),
+			result, sizeof(result), 0);
+	if (err < 0)
+		err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err);
+
+	return (err < 0) ? err : 0;
+}
+
+static int cinergyt2_fe_get_frontend(struct dvb_frontend *fe,
+				  struct dvb_frontend_parameters *fep)
+{
+	return 0;
+}
+
+static void cinergyt2_fe_release(struct dvb_frontend *fe)
+{
+	struct cinergyt2_fe_state *state = fe->demodulator_priv;
+	if (state != NULL)
+		kfree(state);
+}
+
+static struct dvb_frontend_ops cinergyt2_fe_ops;
+
+struct dvb_frontend *cinergyt2_fe_attach(struct dvb_usb_device *d)
+{
+	struct cinergyt2_fe_state *s = kzalloc(sizeof(
+					struct cinergyt2_fe_state), GFP_KERNEL);
+	if (s == NULL)
+		return NULL;
+
+	s->d = d;
+	memcpy(&s->fe.ops, &cinergyt2_fe_ops, sizeof(struct dvb_frontend_ops));
+	s->fe.demodulator_priv = s;
+	return &s->fe;
+}
+
+
+static struct dvb_frontend_ops cinergyt2_fe_ops = {
+	.info = {
+		.name			= DRIVER_NAME,
+		.type			= FE_OFDM,
+		.frequency_min		= 174000000,
+		.frequency_max		= 862000000,
+		.frequency_stepsize	= 166667,
+		.caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2
+			| FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4
+			| FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8
+			| FE_CAN_FEC_AUTO | FE_CAN_QPSK
+			| FE_CAN_QAM_16 | FE_CAN_QAM_64
+			| FE_CAN_QAM_AUTO
+			| FE_CAN_TRANSMISSION_MODE_AUTO
+			| FE_CAN_GUARD_INTERVAL_AUTO
+			| FE_CAN_HIERARCHY_AUTO
+			| FE_CAN_RECOVER
+			| FE_CAN_MUTE_TS
+	},
+
+	.release		= cinergyt2_fe_release,
+
+	.init			= cinergyt2_fe_init,
+	.sleep			= cinergyt2_fe_sleep,
+
+	.set_frontend		= cinergyt2_fe_set_frontend,
+	.get_frontend		= cinergyt2_fe_get_frontend,
+	.get_tune_settings	= cinergyt2_fe_get_tune_settings,
+
+	.read_status		= cinergyt2_fe_read_status,
+	.read_ber		= cinergyt2_fe_read_ber,
+	.read_signal_strength	= cinergyt2_fe_read_signal_strength,
+	.read_snr		= cinergyt2_fe_read_snr,
+	.read_ucblocks		= cinergyt2_fe_read_unc_blocks,
+};
diff -r 41b3f12d6ce4 linux/drivers/media/dvb/dvb-usb/cinergyT2.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2.h	Mon May 12 21:42:16 2008 +0300
@@ -0,0 +1,95 @@
+/*
+ * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
+ *
+ * Copyright (C) 2007 Tomi Orava (tomimo@ncircle.nullnet.fi)
+ *
+ * Based on the dvb-usb-framework code and the
+ * original Terratec Cinergy T2 driver by:
+ *
+ * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
+ *                  Holger Waechtler <holger@qanu.de>
+ *
+ *  Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License,  or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not,  write to the Free Software
+ * Foundation,  Inc.,  675 Mass Ave,  Cambridge,  MA 02139,  USA.
+ *
+ */
+
+#ifndef _DVB_USB_CINERGYT2_H_
+#define _DVB_USB_CINERGYT2_H_
+
+#include <linux/usb/input.h>
+
+#define DVB_USB_LOG_PREFIX "cinergyT2"
+#include "dvb-usb.h"
+
+#define DRIVER_NAME "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"
+
+extern int dvb_usb_cinergyt2_debug;
+
+#define deb_info(args...)  dprintk(dvb_usb_cinergyt2_debug,  0x001, args)
+#define deb_xfer(args...)  dprintk(dvb_usb_cinergyt2_debug,  0x002, args)
+#define deb_pll(args...)   dprintk(dvb_usb_cinergyt2_debug,  0x004, args)
+#define deb_ts(args...)    dprintk(dvb_usb_cinergyt2_debug,  0x008, args)
+#define deb_err(args...)   dprintk(dvb_usb_cinergyt2_debug,  0x010, args)
+#define deb_rc(args...)    dprintk(dvb_usb_cinergyt2_debug,  0x020, args)
+#define deb_fw(args...)    dprintk(dvb_usb_cinergyt2_debug,  0x040, args)
+#define deb_mem(args...)   dprintk(dvb_usb_cinergyt2_debug,  0x080, args)
+#define deb_uxfer(args...) dprintk(dvb_usb_cinergyt2_debug,  0x100, args)
+
+
+
+enum cinergyt2_ep1_cmd {
+	CINERGYT2_EP1_PID_TABLE_RESET		= 0x01,
+	CINERGYT2_EP1_PID_SETUP			= 0x02,
+	CINERGYT2_EP1_CONTROL_STREAM_TRANSFER	= 0x03,
+	CINERGYT2_EP1_SET_TUNER_PARAMETERS	= 0x04,
+	CINERGYT2_EP1_GET_TUNER_STATUS		= 0x05,
+	CINERGYT2_EP1_START_SCAN		= 0x06,
+	CINERGYT2_EP1_CONTINUE_SCAN		= 0x07,
+	CINERGYT2_EP1_GET_RC_EVENTS		= 0x08,
+	CINERGYT2_EP1_SLEEP_MODE		= 0x09,
+	CINERGYT2_EP1_GET_FIRMWARE_VERSION	= 0x0A
+};
+
+
+struct dvbt_get_status_msg {
+	uint32_t freq;
+	uint8_t bandwidth;
+	uint16_t tps;
+	uint8_t flags;
+	uint16_t gain;
+	uint8_t snr;
+	uint32_t viterbi_error_rate;
+	uint32_t rs_error_rate;
+	uint32_t uncorrected_block_count;
+	uint8_t lock_bits;
+	uint8_t prev_lock_bits;
+} __attribute__((packed));
+
+
+struct dvbt_set_parameters_msg {
+	uint8_t cmd;
+	uint32_t freq;
+	uint8_t bandwidth;
+	uint16_t tps;
+	uint8_t flags;
+} __attribute__((packed));
+
+
+extern struct dvb_frontend *cinergyt2_fe_attach(struct dvb_usb_device *d);
+
+#endif /* _DVB_USB_CINERGYT2_H_ */
+

[-- Attachment #3: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-12 18:49                         ` Tomi Orava
@ 2008-05-12 19:05                           ` Patrick Boettcher
  2008-06-16 15:24                             ` Tino Keitel
  2008-05-13 17:36                           ` Thierry Merle
  1 sibling, 1 reply; 21+ messages in thread
From: Patrick Boettcher @ 2008-05-12 19:05 UTC (permalink / raw)
  To: Tomi Orava; +Cc: linux-dvb

Hi all,

On Mon, 12 May 2008, Tomi Orava wrote:
> In my understanding this is a bug in the dvb-usb-framework that cannot
> be fixed in Cinergy T2 driver. I checked that if you DON'T define the
> menuconfig option:
>
> "Load and attach frontend and tuner driver modules as needed" ie.
> the CONFIG_MEDIA_ATTACH
>
> The framework will use a different version of the function called
> "dvb_frontend_detach" and thefore it will not call the symbol_put_addr
> on linux/drivers/media/dvb/dvb-core/dvb_frontend.c line 1220.
> With this option deselected the module reference count seems to stay
> in sane values.

In fact any dvb-driver driver has this problem when it is not using a 
separate frontend-module, but using the module from "inside". (vp702x, 
gp8psk, vp7045, dtt200u)

dvb_frontend is decrementing the use_count when releasing the driver. 
dvb_attach is incrementing it, but you can only use dvb_attach on 
EXPORT_SYMBOL-functions.

Trent Piepo was suggesting a solution, but no one ever had time to solve 
this problem. In fast this is only a propblem for developers, not so much 
for the average users as he is not unloading the module usually.

thanks for your great work,
Patrick.

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-07 22:21                       ` Antti Palosaari
@ 2008-05-13 10:27                         ` Tomi Orava
  0 siblings, 0 replies; 21+ messages in thread
From: Tomi Orava @ 2008-05-13 10:27 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-dvb


Hi,

> I looked through your driver and here is some comments raised up.
>
> - why cinergyt2_cmd, why not dvb_usb_generic_rw ?
> - USB IDs are usually defined in own file dvb-usb-ids.h
> - remote control code seems quite complex and long, maybe there is
> easier way?

Ok, as you may have noticed, the latest version of the patch
has been cleaned so that it now uses the dvb_usb_generic_rw instead
of its own version and Thierry Merle sent a patch that removed the
private version of remote control code and converted Cinergy T2
driver to use the generic one. I'll still need to remember to insert
the USB ID of the card into the dvb-usb-ids.h instead as requested.

Now what is needed is some good testing to make sure that the
driver still works properly, especially if no structural changes
are required.

The current patch has been posted to the mailing list on monday 12.05.08
under the subject: "Re: [linux-dvb] Testers wanted for alternative version
of Terratec Cinergy T2 driver"

Regards,
Tomi Orava

-- 



_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-12 18:32                       ` Tomi Orava
@ 2008-05-13 14:41                         ` Ingo Peukes
  0 siblings, 0 replies; 21+ messages in thread
From: Ingo Peukes @ 2008-05-13 14:41 UTC (permalink / raw)
  To: linux-dvb

Tomi Orava wrote:
> Hi,
> 
> 
>> Well, as I said it compiles and works with the above kernel and v4l-dvb
>> but w_scan finds no channels with this module most of the time. In 5
>> runs it found 4 channels on one multiplex.
>> I doubt it's the antenna although it's the stock one but if I use the
>> cinergyT2 on my desktop pc with the original module of kernel 2.6.25.1
>> w_scan finds all available channels all the time with the same antenna
>> in the same place. I will try a better antenna tomorrow to see if I can
>> use it somewhat productive in mythtv...
> 
> Does the "regular" scandvb work any better for you compared
> to the older driver ?
No, not realy. It find's and tunes only half of the channels available at my location.

> BTW. Where's the source for this w_scan so that I could try it as well ?
You find it here, at the bottom of the page: http://wirbel.htpc-forum.de/w_scan/index2.html
If I supply the parameter -t 3 to w_scan scan which sets the tuning timeout to 'slow' the card
finds almost all channels all the time...

> 
> Regards,
> Tomi Orava
Got a better Antenna today, will try it later.

Greetings,
Ingo Peukes

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-12 18:49                         ` Tomi Orava
  2008-05-12 19:05                           ` Patrick Boettcher
@ 2008-05-13 17:36                           ` Thierry Merle
  1 sibling, 0 replies; 21+ messages in thread
From: Thierry Merle @ 2008-05-13 17:36 UTC (permalink / raw)
  To: Tomi Orava; +Cc: linux-dvb

Tomi Orava a écrit :
> 
> Hi Thierry,
> 
> And thanks a lot for your patch. I've now updated the
> Cinergy T2 driver patch with your remote control cleanup.
> 
>>> However, I did not replace the original Cinergy T2 driver
>>> as I think that this new driver should be located in the
>>> very same directory as the rest of the usb-dvb drivers.
>>>
>> Agreed, but you should remove the old cinergyT2 driver.
> 
> Ok, the attached version of the patch does remove the old driver.
> 
>> Furthermore there is another issue: when I plug the device, the device
>> usage count is set to 0.
>> When I remove the device the device usage count goes to -1 (displayed as
>> 4294967295).
>> This is a misbehavior of the dvb framework but perhaps something needs to
>> be initialized somewhere in the driver. I will look at it...dvb-usb:
>> TerraTec/qanu USB2.0 Highspeed DVB-T Receiver successfully initialized and
>> connected.
>> I noticed this error when I plug the device (I load manually the driver
>> before, so I suspect a thing in the probe function):
> 
> In my understanding this is a bug in the dvb-usb-framework that cannot
> be fixed in Cinergy T2 driver. I checked that if you DON'T define the
> menuconfig option:
> 
> "Load and attach frontend and tuner driver modules as needed" ie.
> the CONFIG_MEDIA_ATTACH
> 
> The framework will use a different version of the function called
> "dvb_frontend_detach" and thefore it will not call the symbol_put_addr
> on linux/drivers/media/dvb/dvb-core/dvb_frontend.c line 1220.
> With this option deselected the module reference count seems to stay
> in sane values.
> 
>> I will look at the module count problem and the irrecord problem, we are
>> close to propose this beautiful patch ;)
> 
> Heh,heh :)
> 
> Regards,
> Tomi Orava
> 
> 
> 
Just one thing missing, sorry: the SOB line!
Please see http://www.linuxtv.org/v4lwiki/index.php/How_to_submit_patches
A bit procedural, but these rules are applied for every patch over the linux kernel and makes easier the maintainer's life.
Thanks
Thierry


_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-05-12 19:05                           ` Patrick Boettcher
@ 2008-06-16 15:24                             ` Tino Keitel
  2008-06-20 19:44                               ` Thierry Merle
  2008-06-22 17:17                               ` Tino Keitel
  0 siblings, 2 replies; 21+ messages in thread
From: Tino Keitel @ 2008-06-16 15:24 UTC (permalink / raw)
  To: Patrick Boettcher; +Cc: linux-dvb

On Mon, May 12, 2008 at 21:05:40 +0200, Patrick Boettcher wrote:

[...]

> Trent Piepo was suggesting a solution, but no one ever had time to solve 
> this problem. In fast this is only a propblem for developers, not so much 
> for the average users as he is not unloading the module usually.

I unload the module at each suspend and reload it at resume. I did this
with the old driver, because it was not suspend-proof, and I think I
continued to do so because I had suspend/resume problems with the new
driver.

I'll re-check if the current driver still causes problems with suspend.

Regards,
Tino

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-06-16 15:24                             ` Tino Keitel
@ 2008-06-20 19:44                               ` Thierry Merle
  2008-06-20 21:17                                 ` Tomi Orava
  2008-06-22 17:17                               ` Tino Keitel
  1 sibling, 1 reply; 21+ messages in thread
From: Thierry Merle @ 2008-06-20 19:44 UTC (permalink / raw)
  To: Patrick Boettcher, Tomi Orava, linux-dvb, Tino Keitel,
	Ingo Peukes

Hi all,
Tino Keitel a écrit :
> On Mon, May 12, 2008 at 21:05:40 +0200, Patrick Boettcher wrote:
>
> [...]
>
>   
>> Trent Piepo was suggesting a solution, but no one ever had time to solve 
>> this problem. In fast this is only a propblem for developers, not so much 
>> for the average users as he is not unloading the module usually.
>>     
>
> I unload the module at each suspend and reload it at resume. I did this
> with the old driver, because it was not suspend-proof, and I think I
> continued to do so because I had suspend/resume problems with the new
> driver.
>
> I'll re-check if the current driver still causes problems with suspend.
>
> Regards,
> Tino
>   
To follow easily the state of this patch and keep track on it, I put it
in a hg repo:
http://linuxtv.org/hg/~tmerle/cinergyT2
And to sum-up, 3 issues:
- possible lirc issue
    http://article.gmane.org/gmane.linux.drivers.dvb/37865
   But I am not sure this is a problem, just a lack in lirc conf.
- possible dvb-t tuning issue
    http://article.gmane.org/gmane.linux.drivers.dvb/41632
   To be confirmed
- rmmod: driver count is not well managed, dvb-usb framework issue
   This prevents the ability to remove drivers that do not support
suspend before passing in suspend mode.

Cheers,
Thierry

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-06-20 19:44                               ` Thierry Merle
@ 2008-06-20 21:17                                 ` Tomi Orava
  2008-06-20 22:16                                   ` Thierry Merle
  0 siblings, 1 reply; 21+ messages in thread
From: Tomi Orava @ 2008-06-20 21:17 UTC (permalink / raw)
  To: Thierry Merle; +Cc: Tino Keitel, linux-dvb

Hi,

> To follow easily the state of this patch and keep track on it, I put it
> in a hg repo:
> http://linuxtv.org/hg/~tmerle/cinergyT2
> And to sum-up, 3 issues:
> - possible lirc issue
>     http://article.gmane.org/gmane.linux.drivers.dvb/37865
>    But I am not sure this is a problem, just a lack in lirc conf.

Since that time the "internal" remote control code has been removed
and the driver now uses the common dvb-usb-rc code.
This should not be a problem anymore, but needs to be verified.

> - possible dvb-t tuning issue
>     http://article.gmane.org/gmane.linux.drivers.dvb/41632
>    To be confirmed

I have requested more test data from the reporter a month ago ...

> - rmmod: driver count is not well managed, dvb-usb framework issue
>    This prevents the ability to remove drivers that do not support
> suspend before passing in suspend mode.

Regards,
Tomi Orava

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-06-20 21:17                                 ` Tomi Orava
@ 2008-06-20 22:16                                   ` Thierry Merle
  2008-06-20 22:52                                     ` Tomi Orava
  0 siblings, 1 reply; 21+ messages in thread
From: Thierry Merle @ 2008-06-20 22:16 UTC (permalink / raw)
  To: Tomi Orava; +Cc: Tino Keitel, linux-dvb

Tomi Orava a écrit :
> Hi,
>
>> To follow easily the state of this patch and keep track on it, I put it
>> in a hg repo:
>> http://linuxtv.org/hg/~tmerle/cinergyT2
>> And to sum-up, 3 issues:
>> - possible lirc issue
>>     http://article.gmane.org/gmane.linux.drivers.dvb/37865
>>    But I am not sure this is a problem, just a lack in lirc conf.
>
> Since that time the "internal" remote control code has been removed
> and the driver now uses the common dvb-usb-rc code.
> This should not be a problem anymore, but needs to be verified.
>
In fact irrecord expects key repeat functionality that is disabled in
this driver (key repeat is too rapid)
Nevertheless I succeeded in making lircd work thanks to:
http://linux.bytesex.org/v4l2/faq.html#lircd (see the last item)
This is a generic way to make dvb usb remotes work with lirc.
>> - possible dvb-t tuning issue
>>     http://article.gmane.org/gmane.linux.drivers.dvb/41632
>>    To be confirmed
>
> I have requested more test data from the reporter a month ago ...
>
I did not see a degradation, maybe the user tried a different cable...
>> - rmmod: driver count is not well managed, dvb-usb framework issue
>>    This prevents the ability to remove drivers that do not support
>> suspend before passing in suspend mode.
>
> Regards,
> Tomi Orava
>
Thierry

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-06-20 22:16                                   ` Thierry Merle
@ 2008-06-20 22:52                                     ` Tomi Orava
  2008-06-21 14:47                                       ` Thierry Merle
  0 siblings, 1 reply; 21+ messages in thread
From: Tomi Orava @ 2008-06-20 22:52 UTC (permalink / raw)
  To: Thierry Merle; +Cc: Tino Keitel, linux-dvb

Hi,

>>> - possible lirc issue
>>>     http://article.gmane.org/gmane.linux.drivers.dvb/37865
>>>    But I am not sure this is a problem, just a lack in lirc conf.
>> Since that time the "internal" remote control code has been removed
>> and the driver now uses the common dvb-usb-rc code.
>> This should not be a problem anymore, but needs to be verified.
>>
> In fact irrecord expects key repeat functionality that is disabled in
> this driver (key repeat is too rapid)
> Nevertheless I succeeded in making lircd work thanks to:
> http://linux.bytesex.org/v4l2/faq.html#lircd (see the last item)

So, does it work for you for good if you change the rc_interval from 50ms
into 150ms (ie. DEFAULT_RC_INTERVAL) on line 183 of cinergyT2-core.c ?

Regards,
Tomi Orava

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-06-20 22:52                                     ` Tomi Orava
@ 2008-06-21 14:47                                       ` Thierry Merle
  0 siblings, 0 replies; 21+ messages in thread
From: Thierry Merle @ 2008-06-21 14:47 UTC (permalink / raw)
  To: Tomi Orava; +Cc: Tino Keitel, linux-dvb

Tomi Orava a ecrit :
> Hi,
> 
>>>> - possible lirc issue
>>>>     http://article.gmane.org/gmane.linux.drivers.dvb/37865
>>>>    But I am not sure this is a problem, just a lack in lirc conf.
>>> Since that time the "internal" remote control code has been removed
>>> and the driver now uses the common dvb-usb-rc code.
>>> This should not be a problem anymore, but needs to be verified.
>>>
>> In fact irrecord expects key repeat functionality that is disabled in
>> this driver (key repeat is too rapid)
>> Nevertheless I succeeded in making lircd work thanks to:
>> http://linux.bytesex.org/v4l2/faq.html#lircd (see the last item)
> 
> So, does it work for you for good if you change the rc_interval from 50ms
> into 150ms (ie. DEFAULT_RC_INTERVAL) on line 183 of cinergyT2-core.c ?
> 
> Regards,
> Tomi Orava
> 
In fact key repeat feature needed to be implemented.
I did it with a configurable RC_REPEAT_DELAY defined as 3 queries period so 3*DEFAULT_RC_INTERVAL.
Putting DEFAULT_RC_INTERVAL to 150 causes the driver to miss some remote commands.

The patch is here: http://linuxtv.org/hg/~tmerle/cinergyT2
and inlined in this email.

Regards,
Thierry
--
cinergyT2: add remote key repeat feature

From: Thierry MERLE <thierry.merle@free.fr>

Implement key repeat feature for the cinergyT2 remote controller.

Signed-off-by: Thierry MERLE <thierry.merle@free.fr>

diff -r afe409705dd5 -r 65bedec7f7ab linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c
--- a/linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c	Fri Jun 20 21:26:40 2008 +0200
+++ b/linux/drivers/media/dvb/dvb-usb/cinergyT2-core.c	Sat Jun 21 16:38:01 2008 +0200
@@ -40,6 +40,9 @@
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
+struct cinergyt2_state {
+	u8 rc_counter;
+};
 
 /* We are missing a release hook with usb_device data */
 struct dvb_usb_device *cinergyt2_usb_device;
@@ -122,22 +125,57 @@
 	{ 0x04,	0x5c,	KEY_NEXT }
 };
 
+/* Number of keypresses to ignore before detect repeating */
+#define RC_REPEAT_DELAY 3
+
+static int repeatable_keys[] = {
+	KEY_UP,
+	KEY_DOWN,
+	KEY_LEFT,
+	KEY_RIGHT,
+	KEY_VOLUMEUP,
+	KEY_VOLUMEDOWN,
+	KEY_CHANNELUP,
+	KEY_CHANNELDOWN
+};
+
 static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
 {
+	struct cinergyt2_state *st = d->priv;
 	u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS;
+	int i;
+
 	*state = REMOTE_NO_KEY_PRESSED;
 
 	dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0);
-	if (key[4] == 0xff)
+	if (key[4] == 0xff) {
+		/* key repeat */
+		st->rc_counter++;
+		if (st->rc_counter > RC_REPEAT_DELAY) {
+			for (i = 0; i < ARRAY_SIZE(repeatable_keys); i++) {
+				if (d->last_event == repeatable_keys[i]) {
+					*state = REMOTE_KEY_REPEAT;
+					*event = d->last_event;
+					deb_rc("repeat key, event %x\n",
+						   *event);
+					return 0;
+				}
+			}
+			deb_rc("repeated key (non repeatable)\n");
+		}
 		return 0;
+	}
 
-	/* hack to pass checksum on the custom field (is set to 0xeb) */
-	key[2] = ~0x04;
+	/* hack to pass checksum on the custom field */
+	key[2] = ~key[1];
 	dvb_usb_nec_rc_key_to_event(d, key, event, state);
-	if (key[0] != 0)
-		deb_info("key: %x %x %x %x %x\n",
-			 key[0], key[1], key[2], key[3], key[4]);
+	if (key[0] != 0) {
+		if (*event != d->last_event)
+			st->rc_counter = 0;
 
+		deb_rc("key: %x %x %x %x %x\n",
+		       key[0], key[1], key[2], key[3], key[4]);
+	}
 	return 0;
 }
 
@@ -157,7 +195,7 @@
 MODULE_DEVICE_TABLE(usb, cinergyt2_usb_table);
 
 static struct dvb_usb_device_properties cinergyt2_properties = {
-
+	.size_of_priv = sizeof(struct cinergyt2_state),
 	.num_adapters = 1,
 	.adapter = {
 		{

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-06-16 15:24                             ` Tino Keitel
  2008-06-20 19:44                               ` Thierry Merle
@ 2008-06-22 17:17                               ` Tino Keitel
  2008-06-25  8:55                                 ` Tomi Orava
  1 sibling, 1 reply; 21+ messages in thread
From: Tino Keitel @ 2008-06-22 17:17 UTC (permalink / raw)
  To: linux-dvb

On Mon, Jun 16, 2008 at 17:24:30 +0200, Tino Keitel wrote:
> On Mon, May 12, 2008 at 21:05:40 +0200, Patrick Boettcher wrote:
> 
> [...]
> 
> > Trent Piepo was suggesting a solution, but no one ever had time to solve 
> > this problem. In fast this is only a propblem for developers, not so much 
> > for the average users as he is not unloading the module usually.
> 
> I unload the module at each suspend and reload it at resume. I did this
> with the old driver, because it was not suspend-proof, and I think I
> continued to do so because I had suspend/resume problems with the new
> driver.
> 
> I'll re-check if the current driver still causes problems with suspend.

Today my keyboard was broken after a resume: most key presses got
eaten. I unloaded the cinergy driver, removed the USB cable from the
CinergyT2 and re-plugged it, which restored the keyboard.

This never happened with module unload at suspend and reload at resume.

Hereis the dmesg output after resume:

dvb-usb: found a 'TerraTec/qanu USB2.0 Highspeed DVB-T Receiver' in
warm state.
dvb-usb: will pass the complete MPEG2 transport stream to the software
demuxer.
DVB: registering new adapter (TerraTec/qanu USB2.0 Highspeed DVB-T
Receiver)
DVB: registering frontend 0 (TerraTec/qanu USB2.0 Highspeed DVB-T
Receiver)...
input: IR-receiver inside an USB DVB receiver as /class/input/input21
dvb-usb: schedule remote query interval to 50 msecs.
dvb-usb: TerraTec/qanu USB2.0 Highspeed DVB-T Receiver successfully
initialized and connected.
usb 1-3: New USB device found, idVendor=0ccd, idProduct=0038
usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-3: Product: Cinergy T<B2>
usb 1-3: Manufacturer: TerraTec GmbH
usb 5-1: usbfs: USBDEVFS_CONTROL failed cmd hid2hci rqt 64 rq 0 len 0
ret -84
usb 5-1: USB disconnect, address 15
usb 5-1: new full speed USB device using uhci_hcd and address 16
dvb-usb: recv bulk message failed: -75
usb 5-1: configuration #1 chosen from 1 choice
usb 5-1: New USB device found, idVendor=05ac, idProduct=8205
usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
dvb-usb: bulk message failed: -110 (9/0)
cinergyT2: cinergyt2_fe_set_frontend() Failed! err=-110

dvb-usb: bulk message failed: -110 (1/0)
dvb-usb: bulk message failed: -110 (1/0)
dvb-usb: bulk message failed: -110 (1/0)
dvb-usb: bulk message failed: -110 (1/0)
dvb-usb: bulk message failed: -110 (9/0)

Regards,
Tino


Regards,
Tino

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver
  2008-06-22 17:17                               ` Tino Keitel
@ 2008-06-25  8:55                                 ` Tomi Orava
  0 siblings, 0 replies; 21+ messages in thread
From: Tomi Orava @ 2008-06-25  8:55 UTC (permalink / raw)
  To: tino.keitel; +Cc: linux-dvb


Hi Tino,

> Today my keyboard was broken after a resume: most key presses got
> eaten. I unloaded the cinergy driver, removed the USB cable from the
> CinergyT2 and re-plugged it, which restored the keyboard.
>
> This never happened with module unload at suspend and reload at resume.

I'm not entirely confident that what you saw is related to the problem
I've seen in one particular type of motherboard-type, but here it
is anyway:

http://www.mail-archive.com/linux-usb-users@lists.sourceforge.net/msg19363.html

The usb disconnection problem I've had in the past happened only with
certain type of Asus motherboard (I've got 2 machines with the same hw) and
I never got those to work properly with this Terratec tuner (it did not
matter which driver, the original or the new one I tried).
Have you by any chance modified by any means your USB-device setup ?

By co-insidence I have setup a few days ago the old problematic machine
as a test machine for the Terratec cinergyT2 tuner box and I'm quite
interested to see if the problem still persists ---> this time I've
added an externally powered USB 2.0 hub into the setup in order to
make sure that there should be enough power available for the devices.

If your problem happens again, please try to get usb debug log in order
to see more clearly what's actually happening and if your problem
is more or less related to what I've seen.

Regards,
Tomi Orava

>
> Hereis the dmesg output after resume:
>
> dvb-usb: found a 'TerraTec/qanu USB2.0 Highspeed DVB-T Receiver' in
> warm state.
> dvb-usb: will pass the complete MPEG2 transport stream to the software
> demuxer.
> DVB: registering new adapter (TerraTec/qanu USB2.0 Highspeed DVB-T
> Receiver)
> DVB: registering frontend 0 (TerraTec/qanu USB2.0 Highspeed DVB-T
> Receiver)...
> input: IR-receiver inside an USB DVB receiver as /class/input/input21
> dvb-usb: schedule remote query interval to 50 msecs.
> dvb-usb: TerraTec/qanu USB2.0 Highspeed DVB-T Receiver successfully
> initialized and connected.
> usb 1-3: New USB device found, idVendor=0ccd, idProduct=0038
> usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
> usb 1-3: Product: Cinergy T<B2>
> usb 1-3: Manufacturer: TerraTec GmbH
> usb 5-1: usbfs: USBDEVFS_CONTROL failed cmd hid2hci rqt 64 rq 0 len 0
> ret -84
> usb 5-1: USB disconnect, address 15
> usb 5-1: new full speed USB device using uhci_hcd and address 16
> dvb-usb: recv bulk message failed: -75
> usb 5-1: configuration #1 chosen from 1 choice
> usb 5-1: New USB device found, idVendor=05ac, idProduct=8205
> usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> dvb-usb: bulk message failed: -110 (9/0)
> cinergyT2: cinergyt2_fe_set_frontend() Failed! err=-110
>
> dvb-usb: bulk message failed: -110 (1/0)
> dvb-usb: bulk message failed: -110 (1/0)
> dvb-usb: bulk message failed: -110 (1/0)
> dvb-usb: bulk message failed: -110 (1/0)
> dvb-usb: bulk message failed: -110 (9/0)
>
> Regards,
> Tino
>
>
> Regards,
> Tino
>


-- 



_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2008-06-25  8:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <43276.192.168.9.10.1192357983.squirrel@ncircle.nullnet.fi>
     [not found] ` <20071018181040.GA6960@dose.home.local>
     [not found]   ` <20071018182940.GA7317@dose.home.local>
     [not found]     ` <20071018201418.GA16574@dose.home.local>
     [not found]       ` <47075.192.168.9.10.1193248379.squirrel@ncircle.nullnet.fi>
     [not found]         ` <472A0CC2.8040509@free.fr>
2008-04-23 19:39           ` [linux-dvb] Testers wanted for alternative version of Terratec Cinergy T2 driver Thierry Merle
     [not found]             ` <16781.192.100.124.220.1209712634.squirrel@ncircle.nullnet.fi>
2008-05-02 17:08               ` Thierry Merle
     [not found]                 ` <30354.192.100.124.220.1209969477.squirrel@ncircle.nullnet.fi>
2008-05-05 19:57                   ` Thierry Merle
2008-05-07 18:49                     ` Tomi Orava
2008-05-07 22:21                       ` Antti Palosaari
2008-05-13 10:27                         ` Tomi Orava
2008-05-08 21:18                       ` Thierry Merle
2008-05-12 18:49                         ` Tomi Orava
2008-05-12 19:05                           ` Patrick Boettcher
2008-06-16 15:24                             ` Tino Keitel
2008-06-20 19:44                               ` Thierry Merle
2008-06-20 21:17                                 ` Tomi Orava
2008-06-20 22:16                                   ` Thierry Merle
2008-06-20 22:52                                     ` Tomi Orava
2008-06-21 14:47                                       ` Thierry Merle
2008-06-22 17:17                               ` Tino Keitel
2008-06-25  8:55                                 ` Tomi Orava
2008-05-13 17:36                           ` Thierry Merle
2008-05-08 20:47                     ` Ingo Peukes
2008-05-12 18:32                       ` Tomi Orava
2008-05-13 14:41                         ` Ingo Peukes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox