[PATCH] mantis: Azurewave AD-CP300 on 2.6.18

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

 




Hi all!

After much frustration I managed to get my Azurewave AD-CP300 (aka Twinhan VP-2033) DVB-C card working using the mantis driver from http://www.jusst.de/hg/mantis/ on the Debian Etch 2.6.18 kernel. I only use it for Free-To-Air channels (no CA/CI/whatchamacallit).

To spare others some frustration I send the result of my hacking, this patch fixes:

- Compilation errors on 2.6.18 kernels (INIT_WORK takes different
  number of arguments, fix version for .release change in
  video_class).

- Prohibit TDA10021 claiming TDA10023 devices, since this makes
  tuning fail with no hint on what's wrong whatsoever. Fixes init to
  first try TDA10021 and then try TDA10023. This should work better
  than making assumptions based on the mantis subsystem ID.

- Make TDA10023 init print id in the same manner as TDA10021 init.

The TDA10023 detection on tda10021.c might need some polishing, I simply hard coded 0x7d as the id but someone with a relevant data sheet could improve it with some nice explanatory defines making tda10021.c claim devices it explicitly supports instead of just blacklisting new devices.

As said, it seems to work for me (dmesg):
found a VP-2033 PCI DVB-C device on (02:09.0),
    Mantis Rev 1 [1822:0008], irq: 169, latency: 64
    memory: 0xf6fff000, mmio: 0xe0a36000
    MAC Address=[00:08:ca:XX:YY:ZZ]
mantis_alloc_buffers (0): DMA=0x162c0000 cpu=0xd62c0000 size=65536
mantis_alloc_buffers (0): RISC=0x1514e000 cpu=0xd514e000 size=1000
DVB: registering new adapter (Mantis dvb adapter)
mantis_frontend_init (0): Probing for CU1216 (DVB-C)
TDA10023: i2c-addr = 0x0c, id = 0x7d
mantis_frontend_init (0): found Philips CU1216 DVB-C frontend (TDA10023) @ 0x0c
mantis_frontend_init (0): Mantis DVB-C Philips CU1216 frontend attach success
DVB: registering frontend 0 (Philips TDA10023 DVB-C)...
mantis_ca_init (0): Registering EN50221 device
mantis_ca_init (0): Registered EN50221 device
mantis_hif_init (0): Adapter(0) Initializing Mantis Host Interface

And tuning works:
% czap -n 6
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
  6 SVT1:410000000:INVERSION_AUTO:6875000:FEC_2_3:QAM_64:1001:1002:1010
  6 SVT1: f 410000000, s 6875000, i 2, fec 2, qam 3, v 0x3e9, a 0x3ea
status 00 | signal cccc | snr 0000 | ber 000fffff | unc 000000cf |
status 1f | signal cfcf | snr efef | ber 00000001 | unc 00000000 | FE_HAS_LOCK

So, I'm happy. Now I just hope that some derivative of this work finds it back into the relevant repositories. And to be honest, I hope that the mantis driver gets merged into the main v4l tree Really Soon Now.


/Nikke
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se      |     nikke@xxxxxxxxxx
---------------------------------------------------------------------------
 You will never be younger then you are today..
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
diff -r 0b04be0c088a linux/drivers/media/dvb/frontends/tda10021.c
--- a/linux/drivers/media/dvb/frontends/tda10021.c	Wed May 28 13:25:23 2008 +0400
+++ b/linux/drivers/media/dvb/frontends/tda10021.c	Sun Jun 22 13:57:18 2008 +0200
@@ -425,6 +425,11 @@ struct dvb_frontend* tda10021_attach(str
 	/* check if the demod is there */
 	id = tda10021_readreg(state, 0x1a);
 	if ((id & 0xf0) != 0x70) goto error;
+
+	/* Don't claim TDA10023 */
+	if(id == 0x7d) {
+		goto error;
+	}
 
 	printk("TDA10021: i2c-addr = 0x%02x, id = 0x%02x\n",
 	       state->config->demod_address, id);
diff -r 0b04be0c088a linux/drivers/media/dvb/frontends/tda10023.c
--- a/linux/drivers/media/dvb/frontends/tda10023.c	Wed May 28 13:25:23 2008 +0400
+++ b/linux/drivers/media/dvb/frontends/tda10023.c	Sun Jun 22 14:22:12 2008 +0200
@@ -466,6 +466,7 @@ struct dvb_frontend* tda10023_attach(con
 {
 	struct tda10023_state* state = NULL;
 	int i;
+	u8 id;
 
 	/* allocate memory for the internal state */
 	state = kmalloc(sizeof(struct tda10023_state), GFP_KERNEL);
@@ -485,8 +486,13 @@ struct dvb_frontend* tda10023_attach(con
 
 	// Wakeup if in standby
 	tda10023_writereg (state, 0x00, 0x33);
+
 	/* check if the demod is there */
-	if ((tda10023_readreg(state, 0x1a) & 0xf0) != 0x70) goto error;
+	id = tda10023_readreg(state, 0x1a);
+	if ((id & 0xf0) != 0x70) goto error;
+
+	printk("TDA10023: i2c-addr = 0x%02x, id = 0x%02x\n",
+		state->config->demod_address, id);
 
 	/* create dvb_frontend */
 	memcpy(&state->frontend.ops, &tda10023_ops, sizeof(struct dvb_frontend_ops));
diff -r 0b04be0c088a linux/drivers/media/dvb/mantis/mantis_dvb.c
--- a/linux/drivers/media/dvb/mantis/mantis_dvb.c	Wed May 28 13:25:23 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_dvb.c	Sun Jun 22 14:11:56 2008 +0200
@@ -260,29 +260,26 @@ int __devinit mantis_frontend_init(struc
 		}
 		break;
 	case MANTIS_VP_2033_DVB_C:	// VP-2033
-		dprintk(verbose, MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)");
-		mantis->fe = tda10021_attach(&philips_cu1216_config, &mantis->adapter, read_pwm(mantis));
-		if (mantis->fe) {
-			mantis->fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set;
-			dprintk(verbose, MANTIS_ERROR, 1,
-				"found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x",
-				philips_cu1216_config.demod_address);
-
-			dprintk(verbose, MANTIS_ERROR, 1,
-				"Mantis DVB-C Philips CU1216 frontend attach success");
-
-		}
-		break;
 	case MANTIS_VP_2040_DVB_C:	// VP-2040
 	case TERRATEC_CINERGY_C_PCI:
 	case TECHNISAT_CABLESTAR_HD2:
 		dprintk(verbose, MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)");
-		mantis->fe = tda10023_attach(&tda10023_cu1216_config, &mantis->adapter, read_pwm(mantis));
+		mantis->fe = tda10021_attach(&philips_cu1216_config, &mantis->adapter, read_pwm(mantis));
+		if(mantis->fe) {
+			dprintk(verbose, MANTIS_ERROR, 1,
+				"found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x",
+				philips_cu1216_config.demod_address);
+		}
+		else {
+			mantis->fe = tda10023_attach(&tda10023_cu1216_config, &mantis->adapter, read_pwm(mantis));
+			if(mantis->fe) {
+				dprintk(verbose, MANTIS_ERROR, 1,
+					"found Philips CU1216 DVB-C frontend (TDA10023) @ 0x%02x",
+					philips_cu1216_config.demod_address);
+			}
+		}
 		if (mantis->fe) {
 			mantis->fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set;
-			dprintk(verbose, MANTIS_ERROR, 1,
-				"found Philips CU1216 DVB-C frontend (TDA10023) @ 0x%02x",
-				philips_cu1216_config.demod_address);
 
 			dprintk(verbose, MANTIS_ERROR, 1,
 				"Mantis DVB-C Philips CU1216 frontend attach success");
diff -r 0b04be0c088a linux/drivers/media/dvb/mantis/mantis_evm.c
--- a/linux/drivers/media/dvb/mantis/mantis_evm.c	Wed May 28 13:25:23 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_evm.c	Sun Jun 22 11:53:47 2008 +0200
@@ -86,7 +86,11 @@ int mantis_evmgr_init(struct mantis_ca *
 	struct mantis_pci *mantis = ca->ca_priv;
 
 	dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
 	INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
+#else
+	INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work, ca);
+#endif
 	mantis_pcmcia_init(ca);	
 	schedule_work(&ca->hif_evm_work);
 	mantis_hif_init(ca);
diff -r 0b04be0c088a linux/drivers/media/video/videodev.c
--- a/linux/drivers/media/video/videodev.c	Wed May 28 13:25:23 2008 +0400
+++ b/linux/drivers/media/video/videodev.c	Sat Apr 05 15:49:05 2008 +0200
@@ -485,7 +485,7 @@ static struct device_attribute video_dev
 
 static struct class video_class = {
 	.name    = VIDEO_NAME,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
 	.release = video_release,
 #else
 	.dev_attrs = video_device_attrs,
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

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

  Powered by Linux