All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/35] Add a driver for Terratec H7
@ 2012-01-21 16:04 Mauro Carvalho Chehab
  2012-01-21 16:04 ` [PATCH 01/35] [media] dvb: Add a new driver for az6007 Mauro Carvalho Chehab
                   ` (3 more replies)
  0 siblings, 4 replies; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Terratec H7 is a Cypress FX2 device with a mt2063 tuner and a drx-k
demod. This series add support for it. It started with a public
tree found at:
	 http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz

The driver were almost completely re-written, and it is now working,
at least with DVB-C. I don't have a DVB-T signal here for testing,
but I suspect it should also work fine.

The FX2 firmware has a NEC IR decoder. The driver has support for
it. The default keytable has support for the black Terratec IR
and for the grey IR with orange keys.

The CI support inside the driver is similar to the one found at the
az6027 driver. I don't have a CI module here, so it is not tested.

Tests and feedback are welcome.

Mauro Carvalho Chehab (35):
  [media] dvb: Add a new driver for az6007
  [media] az6007: Fix compilation troubles at az6007
  [media] az6007: Fix it to allow loading it without crash
  [media] az6007: Fix the I2C code in order to handle mt2063
  [media] az6007: Comment the gate_ctl mutex
  [media] az6007: Remove some dead code that doesn't seem to be needed
  [media] az6007: CodingStyle cleanup
  [media] az6007: Get rid of az6007.h
  [media] az6007: Replace the comments at the beginning of the driver
  [media] az6007: move device PID's to the proper place
  [media] az6007: make driver less verbose
  [media] drxk: Don't assume a default firmware name
  [media] az6007: need to define drivers name before including dvb-usb.h
  [media] az6007: Fix some init sequences and use the right firmwares
  [media] az6007: Change the az6007 read/write routine parameter
  [media] az6007: Simplify the read/write logic
  [media] az6007: Simplify the code by removing an uneeded function
  [media] az6007: Fix IR receive code
  [media] az6007: improve the error messages for az6007 read/write calls
  [media] az6007: Use the new MFE support at dvb-usb
  [media] az6007: Change it to use the MFE solution adopted at dvb-usb
  [media] az6007: Use a per device private struct
  [media] drxk: Allow setting it on dynamic_clock mode
  [media] az6007: Use DRX-K dynamic clock mode
  [media] drxk: add support for Mpeg output clock drive strength config
  [media] drxk: Allow enabling MERR/MVAL cfg
  [media] az6007: code cleanups and fixes
  [media] az6007: Driver cleanup
  [media] az6007: Protect read/write calls with a mutex
  [media] az6007: Be sure to use kmalloc'ed buffer for transfers
  [media] az6007: Fix IR handling
  [media] az6007: Convert IR to use the rc_core logic
  [media] az6007: Use the right keycode for Terratec H7
  [media] az6007: Enable the driver at the building system
  [media] az6007: CodingStyle fixes

 drivers/media/common/tuners/mt2063.c               |    2 +-
 drivers/media/dvb/ddbridge/ddbridge-core.c         |    1 +
 drivers/media/dvb/dvb-usb/Kconfig                  |    8 +
 drivers/media/dvb/dvb-usb/Makefile                 |    4 +-
 drivers/media/dvb/dvb-usb/az6007.c                 |  581 ++++++++++++++++++++
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h            |    2 +
 drivers/media/dvb/frontends/drxk.h                 |   23 +-
 drivers/media/dvb/frontends/drxk_hard.c            |   41 +-
 drivers/media/dvb/frontends/drxk_hard.h            |    1 +
 drivers/media/dvb/ngene/ngene-cards.c              |    1 +
 .../media/rc/keymaps/rc-nec-terratec-cinergy-xs.c  |   52 ++
 11 files changed, 690 insertions(+), 26 deletions(-)
 create mode 100644 drivers/media/dvb/dvb-usb/az6007.c

-- 
1.7.8


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

* [PATCH 01/35] [media] dvb: Add a new driver for az6007
  2012-01-21 16:04 [PATCH 00/35] Add a driver for Terratec H7 Mauro Carvalho Chehab
@ 2012-01-21 16:04 ` Mauro Carvalho Chehab
  2012-01-21 16:04   ` [PATCH 02/35] [media] az6007: Fix compilation troubles at az6007 Mauro Carvalho Chehab
  2012-01-29 21:18 ` [PATCH 00/35] Add a driver for Terratec H7 Roger Mårtensson
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Import the az6007 driver from Terratec H7 source, as-is.

It won't compile or run, so latter patches are needed in order
to fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |  627 ++++++++++++++++++++++++++++++++++++
 drivers/media/dvb/dvb-usb/az6007.h |   18 +
 2 files changed, 645 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/dvb/dvb-usb/az6007.c
 create mode 100644 drivers/media/dvb/dvb-usb/az6007.h

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
new file mode 100644
index 0000000..cd5dd4c
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -0,0 +1,627 @@
+/* DVB USB compliant Linux driver for the AzureWave 6017 USB2.0 DVB-S
+ * receiver.
+ * see Documentation/dvb/README.dvb-usb for more information
+ */
+
+#include "az6007.h"
+#include "drxk.h"
+#include "mt2063.h"
+#include "dvb_ca_en50221.h"
+
+/* debug */
+int dvb_usb_az6007_debug;
+module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
+
+
+static int az6007_type =0;
+module_param(az6007_type, int, 0644);
+MODULE_PARM_DESC(az6007_type, "select delivery mode (0=DVB-T, 1=DVB-T");
+
+//module_param_named(type, 6007_type, int, 0644);
+//MODULE_PARM_DESC(type, "select delivery mode (0=DVB-T, 1=DVB-C)");
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+
+struct az6007_device_state {
+	struct dvb_ca_en50221 ca;
+	struct mutex ca_mutex;
+	u8 power_state;
+};
+
+struct drxk3913_config az6007_drxk3913_config_DVBT = {	
+	.demod_address = 0x52,
+	.min_delay_ms = 100,
+	.standard	= MTTUNEA_DVBT,
+	.set_tuner = mt2063_setTune,
+	.tuner_getlocked = mt2063_lockStatus,
+	.tuner_MT2063_Open = tuner_MT2063_Open,
+	.tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
+	.tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+};
+
+struct drxk3913_config az6007_drxk3913_config_DVBC = {	
+	.demod_address = 0x52,
+	.min_delay_ms = 100,
+	.standard	= MTTUNEA_DVBC,
+	.set_tuner = mt2063_setTune,
+	.tuner_getlocked = mt2063_lockStatus,
+	.tuner_MT2063_Open = tuner_MT2063_Open,
+	.tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
+	.tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+};
+
+struct mt2063_config az6007_mt2063_config = {
+	.tuner_address = 0xc0,
+	.refclock = 36125000,
+};
+
+/* check for mutex FIXME */
+int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen)
+{
+	int ret = -1;
+
+		ret = usb_control_msg(d->udev,
+			usb_rcvctrlpipe(d->udev,0),
+			req,
+			USB_TYPE_VENDOR | USB_DIR_IN,
+			value,index,b,blen,
+			5000);
+
+	if (ret < 0) {
+		warn("usb in operation failed. (%d)", ret);
+		ret = -EIO;
+	} else
+		ret = 0;
+
+
+	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
+	debug_dump(b,blen,deb_xfer);
+
+	return ret;
+}
+
+static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
+			     u16 index, u8 *b, int blen)
+{
+	int ret;
+
+#if 0	
+	int i=0, cyc=0, rem=0;
+	cyc = blen/64;
+	rem = blen%64;
+#endif
+
+	deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
+	debug_dump(b,blen,deb_xfer);
+
+	
+#if 0
+	if (blen>64)
+	{
+		for (i=0; i<cyc; i++)
+		{
+			if ((ret = usb_control_msg(d->udev,
+				usb_sndctrlpipe(d->udev,0),
+				req,
+				USB_TYPE_VENDOR | USB_DIR_OUT,
+				value,index+i*64,b+i*64,64,
+				5000)) != 64) {
+				warn("usb out operation failed. (%d)",ret);
+				return -EIO;
+			}	
+		}
+
+		if (rem>0)
+		{
+			if ((ret = usb_control_msg(d->udev,
+				usb_sndctrlpipe(d->udev,0),
+				req,
+				USB_TYPE_VENDOR | USB_DIR_OUT,
+				value,index+cyc*64,b+cyc*64,rem,
+				5000)) != rem) {
+				warn("usb out operation failed. (%d)",ret);
+				return -EIO;
+			}
+		}
+	}
+	else
+#endif		
+	{
+		if ((ret = usb_control_msg(d->udev,
+				usb_sndctrlpipe(d->udev,0),
+				req,
+				USB_TYPE_VENDOR | USB_DIR_OUT,
+				value,index,b,blen,
+				5000)) != blen) {
+			warn("usb out operation failed. (%d)",ret);
+			return -EIO;
+		}
+	}
+	
+	return 0;
+}
+
+static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
+{
+	return 0;
+}
+
+/* keys for the enclosed remote control */
+static struct dvb_usb_rc_key az6007_rc_keys[] = {
+	{ 0x00, 0x01, KEY_1 },
+	{ 0x00, 0x02, KEY_2 },
+};
+
+/* remote control stuff (does not work with my box) */
+static int az6007_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
+{
+	return 0;
+#if 0
+	u8 key[10];
+	int i;
+
+/* remove the following return to enabled remote querying */
+	
+
+	az6007_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10);
+
+	deb_rc("remote query key: %x %d\n",key[1],key[1]);
+
+	if (key[1] == 0x44) {
+		*state = REMOTE_NO_KEY_PRESSED;
+		return 0;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(az6007_rc_keys); i++)
+		if (az6007_rc_keys[i].custom == key[1]) {
+			*state = REMOTE_KEY_PRESSED;
+			*event = az6007_rc_keys[i].event;
+			break;
+		}
+	return 0;
+#endif
+}
+
+/*
+int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
+{
+	u8 v = onoff;
+	return az6007_usb_out_op(d,0xBC,v,3,NULL,1);
+}
+*/
+
+static int az6007_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
+{
+	az6007_usb_in_op(d, 0xb7, 6, 0, &mac[0], 6);
+	return 0;
+}
+
+static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
+{
+	int ret;
+	u8 req;
+	u16 value;
+	u16 index;
+	int blen;
+
+	info("az6007_frontend_poweron adap=%p adap->dev=%p\n", adap, adap->dev);
+
+	req = 0xBC;
+	value = 1;//power on
+	index = 3;
+	blen =0;
+
+	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
+	{
+		err("az6007_frontend_poweron failed!!!");
+		 return -EIO;
+	}
+
+	msleep_interruptible(200);
+
+	req = 0xBC;
+	value = 0;//power on
+	index = 3;
+	blen =0;
+
+	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
+	{
+		err("az6007_frontend_poweron failed!!!");
+		 return -EIO;
+	}
+
+	msleep_interruptible(200);
+
+	req = 0xBC;
+	value = 1;//power on
+	index = 3;
+	blen =0;
+
+	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
+	{
+		err("az6007_frontend_poweron failed!!!");
+		 return -EIO;
+	}
+	info("az6007_frontend_poweron\n");
+	return 0;
+}
+
+static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
+{
+	int ret;
+	u8 req;
+	u16 value;
+	u16 index;
+	int blen;
+
+	info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
+	
+	//reset demodulator
+	req = 0xC0;
+	value = 1;//high
+	index = 3;
+	blen =0;
+	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
+	{
+		err("az6007_frontend_reset failed 1 !!!");
+		   return -EIO;
+	}
+	
+	req = 0xC0;
+	value = 0;//low
+	index = 3;
+	blen =0;
+	msleep_interruptible(200);
+	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
+	{
+		err("az6007_frontend_reset failed 2 !!!");
+		   return -EIO;
+	}
+	msleep_interruptible(200);
+	req = 0xC0;
+	value = 1;//high
+	index = 3;
+	blen =0;
+
+	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
+	{
+		err("az6007_frontend_reset failed 3 !!!");
+		   return -EIO;
+	}
+	
+	msleep_interruptible(200);
+	
+	info("reset az6007 frontend\n");
+	
+	return 0;
+}
+
+static int az6007_led_on_off(struct usb_interface *intf, int onoff)
+{
+	int ret = -1;
+	u8 req;
+	u16 value;
+	u16 index;
+	int blen;
+	//TS through
+	req = 0xBC;
+	value = onoff;
+	index = 0;
+	blen =0;
+
+	ret = usb_control_msg(interface_to_usbdev(intf),
+		usb_rcvctrlpipe(interface_to_usbdev(intf),0),
+		req,
+		USB_TYPE_VENDOR | USB_DIR_OUT,
+		value,index,NULL,blen,
+		2000);
+
+	if (ret < 0) {
+		warn("usb in operation failed. (%d)", ret);
+		ret = -EIO;
+	} else
+		ret = 0;
+
+
+	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
+
+	return ret;
+}
+
+static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap,int onoff)
+{
+	int ret;
+	u8 req;
+	u16 value;
+	u16 index;
+	int blen;
+	//TS through
+	req = 0xC7;
+	value = onoff;
+	index = 0;
+	blen =0;
+
+	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
+		   return -EIO;
+	return 0;
+}
+
+static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
+{
+	az6007_frontend_poweron(adap);
+	az6007_frontend_reset(adap);
+
+	info("az6007_frontend_attach\n");
+
+	if (az6007_type == 0)
+	{
+		info("az6007_drxk3913_config_DVBT\n");
+		adap->fe = drxk3913_attach(&az6007_drxk3913_config_DVBT, &adap->dev->i2c_adap);
+	}
+	else
+	{
+		info("az6007_drxk3913_config_DVBC\n");
+		adap->fe = drxk3913_attach(&az6007_drxk3913_config_DVBC, &adap->dev->i2c_adap);
+	}
+	if (adap->fe) {		
+		if (mt2063_attach(adap->fe, &az6007_mt2063_config, &adap->dev->i2c_adap)) {
+			info("found STB6100 DVB-C/DVB-T frontend @0x%02x\n",az6007_mt2063_config.tuner_address);
+			
+			//vp6027_ci_init(adap);
+		} else {
+			adap->fe = NULL;
+		}
+	}
+	else
+	{
+		adap->fe = NULL;	
+		err("no front-end attached\n");
+	}
+	//az6007_frontend_tsbypass(adap,0);
+	
+	return 0;
+}
+
+static struct dvb_usb_device_properties az6007_properties;
+
+static void
+az6007_usb_disconnect(struct usb_interface *intf)
+{
+	dvb_usb_device_exit (intf);
+}
+
+/* I2C */
+static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
+{
+	struct dvb_usb_device *d = i2c_get_adapdata(adap);
+	int j=0,len=0;
+	int ret=0;
+	u16 index;
+	u16 value;
+	int length;
+	u8 req;
+	u8 data[512];
+	
+	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+		return -EAGAIN;
+	if (num > 2)
+		warn("more than 2 i2c messages at a time is not handled yet. TODO.");
+
+
+	if (msg[0].addr == 0xc0) //MT2063
+	{
+		if (msg[0].flags != I2C_M_RD) //write
+		{
+			//printk("Tuner Tuner Write DevAddr=%02x  RegAddr=%d\n", msg[0].addr, msg[0].buf[0]);
+			req = 0xBD;
+			index = msg[0].buf[0];
+			value = msg[0].addr | (1<<8);
+			length = msg[0].len - 1;
+			len = msg[0].len - 1;
+			//printk("Tuner Tuner WriteDATA len=%d ", len);
+			for(j=0;j<len;j++)
+			{
+				data[j] = msg[0].buf[j+1];
+				//printk("data[%d]=%02x ", j, data[j]);
+			}
+			//printk("\n");
+			ret = az6007_usb_out_op(d,req,value,index,data,length);
+			//ret = az6007_usb_out_op(d,req,value,index,&(msg[0].buf[1]),length);
+		}
+		else //read
+		{
+			//printk("Tuner Tuner Read DevAddr=%02x RegAddr=%02x\n", msg[0].addr, msg[0].buf[0]);
+			req = 0xB9;
+			index = msg[0].buf[0];
+			value = msg[0].addr + (1 << 8);
+			length = msg[1].len + 6;
+			ret = az6007_usb_in_op(d,req,value,index,data,length);
+			len = msg[1].len;
+			//printk("Tuner Tuner ReadDATA len=%d ", len);
+			for (j=0; j<len; j++)
+			{
+				msg[1].buf[j] = data[j+5];	
+				//printk("data[%d]=%02x ", j, data[j+5]);
+			}
+			//printk("\n");
+		}
+	}
+	else
+	{	//Demodulator
+		if (msg[0].flags != I2C_M_RD) //write
+		{
+			//printk("Demodulator Write DevAddr=%02x  RegAddr=%d\n", msg[0].addr, msg[0].buf[0]);
+			req = 0xBD;
+			index = msg[0].buf[0];
+			value = msg[0].addr | (1<<8);
+			length = msg[0].len - 1;
+			len = msg[0].len - 1;
+			//printk("Demodulator WriteDATA len=%d ", len);			
+			for(j=0;j<len;j++)
+			{
+				data[j] = msg[0].buf[j+1];
+				//printk("data[%d]=%02x ", j, data[j]);
+			}
+			//printk("\n");			
+			ret = az6007_usb_out_op(d,req,value,index,data,length);
+		}
+		else //read
+		{
+			//printk("Demodulator Read DevAddr=%02x RegAddr=%02x\n", msg[0].addr, msg[0].buf[0]);
+			req = 0xB9;
+			index = 0;
+			value = msg[0].addr + (0 << 8);
+			length = msg[0].len + 6;
+			ret = az6007_usb_in_op(d,req,value,index,data,length);
+			len = msg[0].len;
+			//printk("Demodulator ReadDATA len=%d ", len);
+			for (j=0; j<len; j++)
+			{
+				msg[0].buf[j] = data[j+5];	
+				//printk("data[%d]=%02x ", j, data[j+5]);
+			}
+			//printk("\n");
+		}
+	}
+	mutex_unlock(&d->i2c_mutex);
+	return ret;
+}
+
+
+static u32 az6007_i2c_func(struct i2c_adapter *adapter)
+{
+	return I2C_FUNC_I2C;
+}
+
+static struct i2c_algorithm az6007_i2c_algo = {
+	.master_xfer   = az6007_i2c_xfer,
+	.functionality = az6007_i2c_func,
+#ifdef NEED_ALGO_CONTROL
+	.algo_control = dummy_algo_control,
+#endif
+};
+
+int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
+			struct dvb_usb_device_description **desc, int *cold)
+{
+	u8 b[16];
+	s16 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev,0),
+		0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b, 6, USB_CTRL_GET_TIMEOUT);
+
+	info("FW GET_VERSION length: %d\n",ret);
+
+	*cold = ret <= 0;
+
+	info("cold: %d\n", *cold);
+	return 0;
+}
+
+static int az6007_usb_probe(struct usb_interface *intf,
+		const struct usb_device_id *id)
+{
+	az6007_led_on_off(intf, 0);	
+		
+	return dvb_usb_device_init(intf, &az6007_properties,
+				   THIS_MODULE, NULL, adapter_nr);	
+}
+
+static struct usb_device_id az6007_usb_table [] = {
+	    { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_6007) },
+	    { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7) },
+	    { 0 },
+};
+
+MODULE_DEVICE_TABLE(usb, az6007_usb_table);
+
+static struct dvb_usb_device_properties az6007_properties = {
+	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
+	.usb_ctrl = CYPRESS_FX2,
+	//.download_firmware = az6007_download_firmware,
+	.firmware            = "dvb-usb-az6007-03.fw",
+	.no_reconnect        = 1,
+
+	.size_of_priv     = sizeof(struct az6007_device_state),
+	.identify_state		= az6007_identify_state,
+	.num_adapters = 1,
+	.adapter = {
+		{
+			//.caps             = DVB_USB_ADAP_RECEIVES_204_BYTE_TS,
+
+			.streaming_ctrl   = az6007_streaming_ctrl,
+			.frontend_attach  = az6007_frontend_attach,
+
+			/* parameter for the MPEG2-data transfer */
+			.stream = {
+				.type = USB_BULK,
+				.count = 10,
+				.endpoint = 0x02,
+				.u = {
+					.bulk = {
+						.buffersize = 4096,
+					}
+				}
+			},
+			.size_of_priv     = 0,//sizeof(struct az6007_state),
+		}
+	},
+	//.power_ctrl       = az6007_power_ctrl,
+	.read_mac_address = az6007_read_mac_addr,
+
+	.rc_key_map       = az6007_rc_keys,
+	.rc_key_map_size  = ARRAY_SIZE(az6007_rc_keys),
+	.rc_interval      = 400,
+	.rc_query         = az6007_rc_query,
+	.i2c_algo         = &az6007_i2c_algo,
+
+	.num_device_descs = 2,
+	.devices = {
+		{ .name = "AzureWave DTV StarBox DVB-T/C USB2.0 (az6007)",
+		  .cold_ids = { &az6007_usb_table[0], NULL },
+		  .warm_ids = { NULL },
+		},
+		{ .name = "TerraTec DTV StarBox DVB-T/C USB2.0 (az6007)",
+		  .cold_ids = { &az6007_usb_table[1], NULL },
+		  .warm_ids = { NULL },
+		},
+ 		{ NULL },
+	}
+};
+  
+/* usb specific object needed to register this driver with the usb subsystem */
+static struct usb_driver az6007_usb_driver = {
+	.name		= "dvb_usb_az6007",
+	.probe 		= az6007_usb_probe,
+	.disconnect = dvb_usb_device_exit,
+	//.disconnect 	= az6007_usb_disconnect,
+	.id_table 	= az6007_usb_table,
+};
+
+/* module stuff */
+static int __init az6007_usb_module_init(void)
+{
+	int result;
+	info("henry :: az6007 usb module init");
+	if ((result = usb_register(&az6007_usb_driver))) {
+		err("usb_register failed. (%d)",result);
+		return result;
+	}
+
+	return 0;
+}
+
+static void __exit az6007_usb_module_exit(void)
+{
+	/* deregister this driver from the USB subsystem */
+	info("henry :: az6007 usb module exit");
+	usb_deregister(&az6007_usb_driver);
+}
+
+module_init(az6007_usb_module_init);
+module_exit(az6007_usb_module_exit);
+
+MODULE_AUTHOR("Henry Wang <Henry.wang@AzureWave.com>");
+MODULE_DESCRIPTION("Driver for AzureWave 6007 DVB-C/T USB2.0 and clones");
+MODULE_VERSION("1.0");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/az6007.h b/drivers/media/dvb/dvb-usb/az6007.h
new file mode 100644
index 0000000..aefa5b5
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/az6007.h
@@ -0,0 +1,18 @@
+#ifndef _DVB_USB_AZ6007_H_
+#define _DVB_USB_AZ6007_H_
+
+#define DVB_USB_LOG_PREFIX "az6007"
+#include "dvb-usb.h"
+
+
+extern int dvb_usb_az6007_debug;
+#define deb_info(args...) dprintk(dvb_usb_az6007_debug,0x01,args)
+#define deb_xfer(args...) dprintk(dvb_usb_az6007_debug,0x02,args)
+#define deb_rc(args...)   dprintk(dvb_usb_az6007_debug,0x04,args)
+#define deb_fe(args...)   dprintk(dvb_usb_az6007_debug,0x08,args)
+
+
+extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec);
+extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
+
+#endif
-- 
1.7.8


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

* [PATCH 02/35] [media] az6007: Fix compilation troubles at az6007
  2012-01-21 16:04 ` [PATCH 01/35] [media] dvb: Add a new driver for az6007 Mauro Carvalho Chehab
@ 2012-01-21 16:04   ` Mauro Carvalho Chehab
  2012-01-21 16:04     ` [PATCH 03/35] [media] az6007: Fix it to allow loading it without crash Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Some changes are needed, in order to make az6007 compile with the
upstream tree. Most of the changes are due to the upstream drxk
module.

Even allowing its compilation, the driver is not working yet.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/common/tuners/mt2063.c |    2 +-
 drivers/media/dvb/dvb-usb/az6007.c   |  174 ++++++++++++++++++++--------------
 2 files changed, 104 insertions(+), 72 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c b/drivers/media/common/tuners/mt2063.c
index c89af3c..7bbf25d 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -350,7 +350,7 @@ static int MT2063_Sleep(struct dvb_frontend *fe)
 	/*
 	 *  ToDo:  Add code here to implement a OS blocking
 	 */
-	msleep(10);
+	msleep(100);
 
 	return 0;
 }
diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index cd5dd4c..5873759 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -8,6 +8,10 @@
 #include "mt2063.h"
 #include "dvb_ca_en50221.h"
 
+/* HACK: Should be moved to the right place */
+#define USB_PID_AZUREWAVE_6007		0xccd
+#define USB_PID_TERRATEC_H7		0x10b4
+
 /* debug */
 int dvb_usb_az6007_debug;
 module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
@@ -28,30 +32,39 @@ struct az6007_device_state {
 	struct dvb_ca_en50221 ca;
 	struct mutex ca_mutex;
 	u8 power_state;
-};
 
-struct drxk3913_config az6007_drxk3913_config_DVBT = {	
-	.demod_address = 0x52,
-	.min_delay_ms = 100,
-	.standard	= MTTUNEA_DVBT,
-	.set_tuner = mt2063_setTune,
-	.tuner_getlocked = mt2063_lockStatus,
-	.tuner_MT2063_Open = tuner_MT2063_Open,
-	.tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
-	.tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+	/* Due to DRX-K - probably need changes */
+	int (*gate_ctrl)(struct dvb_frontend *, int);
+	struct semaphore      pll_mutex;
+	bool			dont_attach_fe1;
 };
 
-struct drxk3913_config az6007_drxk3913_config_DVBC = {	
-	.demod_address = 0x52,
-	.min_delay_ms = 100,
-	.standard	= MTTUNEA_DVBC,
-	.set_tuner = mt2063_setTune,
-	.tuner_getlocked = mt2063_lockStatus,
-	.tuner_MT2063_Open = tuner_MT2063_Open,
-	.tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
-	.tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+struct drxk_config terratec_h7_drxk = {
+	.adr = 0x29,
+	.single_master = 1,
+	.no_i2c_bridge = 1,
+	.microcode_name = "dvb-usb-terratec-h5-drxk.fw",
 };
 
+static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
+{
+	struct dvb_usb_adapter *adap = fe->sec_priv;
+	struct az6007_device_state *st = adap->priv;
+	int status;
+
+	if (!adap || !st)
+		return -EINVAL;
+
+	if (enable) {
+		down(&st->pll_mutex);
+		status = st->gate_ctrl(fe, 1);
+	} else {
+		status = st->gate_ctrl(fe, 0);
+		up(&st->pll_mutex);
+	}
+	return status;
+}
+
 struct mt2063_config az6007_mt2063_config = {
 	.tuner_address = 0xc0,
 	.refclock = 36125000,
@@ -87,7 +100,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 {
 	int ret;
 
-#if 0	
+#if 0
 	int i=0, cyc=0, rem=0;
 	cyc = blen/64;
 	rem = blen%64;
@@ -96,7 +109,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 	deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
 	debug_dump(b,blen,deb_xfer);
 
-	
+
 #if 0
 	if (blen>64)
 	{
@@ -110,7 +123,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 				5000)) != 64) {
 				warn("usb out operation failed. (%d)",ret);
 				return -EIO;
-			}	
+			}
 		}
 
 		if (rem>0)
@@ -127,7 +140,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 		}
 	}
 	else
-#endif		
+#endif
 	{
 		if ((ret = usb_control_msg(d->udev,
 				usb_sndctrlpipe(d->udev,0),
@@ -139,7 +152,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 			return -EIO;
 		}
 	}
-	
+
 	return 0;
 }
 
@@ -149,9 +162,9 @@ static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 }
 
 /* keys for the enclosed remote control */
-static struct dvb_usb_rc_key az6007_rc_keys[] = {
-	{ 0x00, 0x01, KEY_1 },
-	{ 0x00, 0x02, KEY_2 },
+struct rc_map_table rc_map_az6007_table[] = {
+	{ 0x0001, KEY_1 },
+	{ 0x0002, KEY_2 },
 };
 
 /* remote control stuff (does not work with my box) */
@@ -163,7 +176,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
 	int i;
 
 /* remove the following return to enabled remote querying */
-	
+
 
 	az6007_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10);
 
@@ -257,7 +270,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 	int blen;
 
 	info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
-	
+
 	//reset demodulator
 	req = 0xC0;
 	value = 1;//high
@@ -268,7 +281,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 		err("az6007_frontend_reset failed 1 !!!");
 		   return -EIO;
 	}
-	
+
 	req = 0xC0;
 	value = 0;//low
 	index = 3;
@@ -290,11 +303,11 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 		err("az6007_frontend_reset failed 3 !!!");
 		   return -EIO;
 	}
-	
+
 	msleep_interruptible(200);
-	
+
 	info("reset az6007 frontend\n");
-	
+
 	return 0;
 }
 
@@ -350,38 +363,55 @@ static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap,int onoff)
 
 static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
+	struct az6007_device_state *st = adap->priv;
+
+	int result;
+
 	az6007_frontend_poweron(adap);
 	az6007_frontend_reset(adap);
 
 	info("az6007_frontend_attach\n");
 
-	if (az6007_type == 0)
-	{
-		info("az6007_drxk3913_config_DVBT\n");
-		adap->fe = drxk3913_attach(&az6007_drxk3913_config_DVBT, &adap->dev->i2c_adap);
+	adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
+			      &adap->dev->i2c_adap, &adap->fe2);
+	if (!adap->fe) {
+		result = -EINVAL;
+		goto out_free;
 	}
-	else
-	{
-		info("az6007_drxk3913_config_DVBC\n");
-		adap->fe = drxk3913_attach(&az6007_drxk3913_config_DVBC, &adap->dev->i2c_adap);
-	}
-	if (adap->fe) {		
-		if (mt2063_attach(adap->fe, &az6007_mt2063_config, &adap->dev->i2c_adap)) {
-			info("found STB6100 DVB-C/DVB-T frontend @0x%02x\n",az6007_mt2063_config.tuner_address);
-			
-			//vp6027_ci_init(adap);
-		} else {
-			adap->fe = NULL;
-		}
-	}
-	else
-	{
-		adap->fe = NULL;	
-		err("no front-end attached\n");
+
+	/* FIXME: do we need a pll semaphore? */
+	adap->fe->sec_priv = adap;
+	sema_init(&st->pll_mutex, 1);
+	st->gate_ctrl = adap->fe->ops.i2c_gate_ctrl;
+	adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
+	adap->fe2->id = 1;
+
+	/* Attach mt2063 to DVB-C frontend */
+	if (adap->fe->ops.i2c_gate_ctrl)
+		adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
+	if (!dvb_attach(mt2063_attach, adap->fe, &az6007_mt2063_config,
+			&adap->dev->i2c_adap)) {
+		result = -EINVAL;
+
+		goto out_free;
 	}
-	//az6007_frontend_tsbypass(adap,0);
-	
+	if (adap->fe->ops.i2c_gate_ctrl)
+		adap->fe->ops.i2c_gate_ctrl(adap->fe, 0);
+
+	/* Hack - needed due to drxk */
+	adap->fe2->tuner_priv = adap->fe->tuner_priv;
+	memcpy(&adap->fe2->ops.tuner_ops,
+	       &adap->fe->ops.tuner_ops,
+	       sizeof(adap->fe->ops.tuner_ops));
 	return 0;
+
+out_free:
+	if (adap->fe)
+		dvb_frontend_detach(adap->fe);
+	adap->fe = NULL;
+	adap->fe2 = NULL;
+
+	return result;
 }
 
 static struct dvb_usb_device_properties az6007_properties;
@@ -403,7 +433,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
 	int length;
 	u8 req;
 	u8 data[512];
-	
+
 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
 		return -EAGAIN;
 	if (num > 2)
@@ -442,7 +472,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
 			//printk("Tuner Tuner ReadDATA len=%d ", len);
 			for (j=0; j<len; j++)
 			{
-				msg[1].buf[j] = data[j+5];	
+				msg[1].buf[j] = data[j+5];
 				//printk("data[%d]=%02x ", j, data[j+5]);
 			}
 			//printk("\n");
@@ -458,13 +488,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
 			value = msg[0].addr | (1<<8);
 			length = msg[0].len - 1;
 			len = msg[0].len - 1;
-			//printk("Demodulator WriteDATA len=%d ", len);			
+			//printk("Demodulator WriteDATA len=%d ", len);
 			for(j=0;j<len;j++)
 			{
 				data[j] = msg[0].buf[j+1];
 				//printk("data[%d]=%02x ", j, data[j]);
 			}
-			//printk("\n");			
+			//printk("\n");
 			ret = az6007_usb_out_op(d,req,value,index,data,length);
 		}
 		else //read
@@ -479,7 +509,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
 			//printk("Demodulator ReadDATA len=%d ", len);
 			for (j=0; j<len; j++)
 			{
-				msg[0].buf[j] = data[j+5];	
+				msg[0].buf[j] = data[j+5];
 				//printk("data[%d]=%02x ", j, data[j+5]);
 			}
 			//printk("\n");
@@ -521,10 +551,10 @@ int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_propert
 static int az6007_usb_probe(struct usb_interface *intf,
 		const struct usb_device_id *id)
 {
-	az6007_led_on_off(intf, 0);	
-		
+	az6007_led_on_off(intf, 0);
+
 	return dvb_usb_device_init(intf, &az6007_properties,
-				   THIS_MODULE, NULL, adapter_nr);	
+				   THIS_MODULE, NULL, adapter_nr);
 }
 
 static struct usb_device_id az6007_usb_table [] = {
@@ -569,10 +599,12 @@ static struct dvb_usb_device_properties az6007_properties = {
 	//.power_ctrl       = az6007_power_ctrl,
 	.read_mac_address = az6007_read_mac_addr,
 
-	.rc_key_map       = az6007_rc_keys,
-	.rc_key_map_size  = ARRAY_SIZE(az6007_rc_keys),
-	.rc_interval      = 400,
-	.rc_query         = az6007_rc_query,
+	.rc.legacy = {
+		.rc_map_table  = rc_map_az6007_table,
+		.rc_map_size  = ARRAY_SIZE(rc_map_az6007_table),
+		.rc_interval      = 400,
+		.rc_query         = az6007_rc_query,
+	},
 	.i2c_algo         = &az6007_i2c_algo,
 
 	.num_device_descs = 2,
@@ -585,10 +617,10 @@ static struct dvb_usb_device_properties az6007_properties = {
 		  .cold_ids = { &az6007_usb_table[1], NULL },
 		  .warm_ids = { NULL },
 		},
- 		{ NULL },
+		{ NULL },
 	}
 };
-  
+
 /* usb specific object needed to register this driver with the usb subsystem */
 static struct usb_driver az6007_usb_driver = {
 	.name		= "dvb_usb_az6007",
-- 
1.7.8


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

* [PATCH 03/35] [media] az6007: Fix it to allow loading it without crash
  2012-01-21 16:04   ` [PATCH 02/35] [media] az6007: Fix compilation troubles at az6007 Mauro Carvalho Chehab
@ 2012-01-21 16:04     ` Mauro Carvalho Chehab
  2012-01-21 16:04       ` [PATCH 04/35] [media] az6007: Fix the I2C code in order to handle mt2063 Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Add some fixes to allow frontend attachment. The patch is not
complete yet, as just the frontend 0 is initialized. So, more
changes will be needed, including some changes at dvb-usb core.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |  190 ++++++++++++++++++-----------------
 1 files changed, 98 insertions(+), 92 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 5873759..6a21f92 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -49,12 +49,20 @@ struct drxk_config terratec_h7_drxk = {
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 {
 	struct dvb_usb_adapter *adap = fe->sec_priv;
-	struct az6007_device_state *st = adap->priv;
+	struct az6007_device_state *st;
 	int status;
 
-	if (!adap || !st)
+	info("%s", __func__);
+
+	if (!adap)
+		return -EINVAL;
+
+	st = adap->priv;
+
+	if (!st)
 		return -EINVAL;
 
+
 	if (enable) {
 		down(&st->pll_mutex);
 		status = st->gate_ctrl(fe, 1);
@@ -66,7 +74,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 }
 
 struct mt2063_config az6007_mt2063_config = {
-	.tuner_address = 0xc0,
+	.tuner_address = 0x60,
 	.refclock = 36125000,
 };
 
@@ -84,10 +92,8 @@ int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8
 
 	if (ret < 0) {
 		warn("usb in operation failed. (%d)", ret);
-		ret = -EIO;
-	} else
-		ret = 0;
-
+		return -EIO;
+	}
 
 	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
 	debug_dump(b,blen,deb_xfer);
@@ -219,7 +225,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	u16 index;
 	int blen;
 
-	info("az6007_frontend_poweron adap=%p adap->dev=%p\n", adap, adap->dev);
+	info("az6007_frontend_poweron adap=%p adap->dev=%p", adap, adap->dev);
 
 	req = 0xBC;
 	value = 1;//power on
@@ -257,7 +263,8 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 		err("az6007_frontend_poweron failed!!!");
 		 return -EIO;
 	}
-	info("az6007_frontend_poweron\n");
+	info("az6007_frontend_poweron: OK");
+
 	return 0;
 }
 
@@ -269,7 +276,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 	u16 index;
 	int blen;
 
-	info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
+	info("az6007_frontend_reset adap=%p adap->dev=%p", adap, adap->dev);
 
 	//reset demodulator
 	req = 0xC0;
@@ -306,7 +313,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 
 	msleep_interruptible(200);
 
-	info("reset az6007 frontend\n");
+	info("reset az6007 frontend");
 
 	return 0;
 }
@@ -367,10 +374,12 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 
 	int result;
 
+	BUG_ON(!st);
+
 	az6007_frontend_poweron(adap);
 	az6007_frontend_reset(adap);
 
-	info("az6007_frontend_attach\n");
+	info("az6007_frontend_attach: drxk");
 
 	adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
 			      &adap->dev->i2c_adap, &adap->fe2);
@@ -379,6 +388,8 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 		goto out_free;
 	}
 
+	info("Setting hacks");
+
 	/* FIXME: do we need a pll semaphore? */
 	adap->fe->sec_priv = adap;
 	sema_init(&st->pll_mutex, 1);
@@ -386,6 +397,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 	adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
 	adap->fe2->id = 1;
 
+	info("az6007_frontend_attach: mt2063");
 	/* Attach mt2063 to DVB-C frontend */
 	if (adap->fe->ops.i2c_gate_ctrl)
 		adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
@@ -423,100 +435,95 @@ az6007_usb_disconnect(struct usb_interface *intf)
 }
 
 /* I2C */
-static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
+static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int num)
 {
 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
-	int j=0,len=0;
-	int ret=0;
+	int i, j, len;
+	int ret = 0;
 	u16 index;
 	u16 value;
 	int length;
-	u8 req;
+	u8 req, addr;
 	u8 data[512];
 
 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
 		return -EAGAIN;
-	if (num > 2)
-		warn("more than 2 i2c messages at a time is not handled yet. TODO.");
 
-
-	if (msg[0].addr == 0xc0) //MT2063
-	{
-		if (msg[0].flags != I2C_M_RD) //write
-		{
-			//printk("Tuner Tuner Write DevAddr=%02x  RegAddr=%d\n", msg[0].addr, msg[0].buf[0]);
-			req = 0xBD;
-			index = msg[0].buf[0];
-			value = msg[0].addr | (1<<8);
-			length = msg[0].len - 1;
-			len = msg[0].len - 1;
-			//printk("Tuner Tuner WriteDATA len=%d ", len);
-			for(j=0;j<len;j++)
-			{
-				data[j] = msg[0].buf[j+1];
-				//printk("data[%d]=%02x ", j, data[j]);
-			}
-			//printk("\n");
-			ret = az6007_usb_out_op(d,req,value,index,data,length);
-			//ret = az6007_usb_out_op(d,req,value,index,&(msg[0].buf[1]),length);
-		}
-		else //read
-		{
-			//printk("Tuner Tuner Read DevAddr=%02x RegAddr=%02x\n", msg[0].addr, msg[0].buf[0]);
-			req = 0xB9;
-			index = msg[0].buf[0];
-			value = msg[0].addr + (1 << 8);
-			length = msg[1].len + 6;
+	for (i = 0; i < num; i++) {
+		addr = msgs[i].addr << 1;
+
+		if (((i + 1) < num)
+		    && (msgs[i].len == 1)
+		    && (!msgs[i].flags & I2C_M_RD)
+		    && (msgs[i + 1].flags & I2C_M_RD)
+		    && (msgs[i].addr == msgs[i + 1].addr)) {
+			/*
+			 * A write + read xfer for the same address, where
+			 * the first xfer has just 1 byte length.
+			 * Need to join both into one operation
+			 */
+			printk("az6007 I2C xfer write+read addr=0x%x len=%d/%d: ",
+				addr, msgs[i].len, msgs[i + 1].len);
+			req = 0xb9;
+			index = 0;
+			value = addr;
+			for (j = 0; j < msgs[i].len; j++)
+				data[j] = msgs[i].buf[j];
+			length = 6 + msgs[i + 1].len;
+			len = msgs[i + 1].len;
 			ret = az6007_usb_in_op(d,req,value,index,data,length);
-			len = msg[1].len;
-			//printk("Tuner Tuner ReadDATA len=%d ", len);
-			for (j=0; j<len; j++)
-			{
-				msg[1].buf[j] = data[j+5];
-				//printk("data[%d]=%02x ", j, data[j+5]);
-			}
-			//printk("\n");
-		}
-	}
-	else
-	{	//Demodulator
-		if (msg[0].flags != I2C_M_RD) //write
-		{
-			//printk("Demodulator Write DevAddr=%02x  RegAddr=%d\n", msg[0].addr, msg[0].buf[0]);
-			req = 0xBD;
-			index = msg[0].buf[0];
-			value = msg[0].addr | (1<<8);
-			length = msg[0].len - 1;
-			len = msg[0].len - 1;
-			//printk("Demodulator WriteDATA len=%d ", len);
-			for(j=0;j<len;j++)
+			if (ret >= len) {
+				for (j = 0; j < len; j++) {
+					msgs[i + 1].buf[j] = data[j + 5];
+					printk("0x%02x ", msgs[i + 1].buf[j]);
+				}
+			} else
+				ret = -EIO;
+			i++;
+		} else if (!(msgs[i].flags & I2C_M_RD)) {
+			/* write bytes */
+//			printk("az6007 I2C xfer write addr=0x%x len=%d: ",
+//				 addr, msgs[i].len);
+			req = 0xbd;
+			index = msgs[i].buf[0];
+			value = addr | (1 << 8);
+			length = msgs[i].len - 1;
+			len = msgs[i].len - 1;
+//			printk("(0x%02x) ", msgs[i].buf[0]);
+			for (j = 0; j < len; j++)
 			{
-				data[j] = msg[0].buf[j+1];
-				//printk("data[%d]=%02x ", j, data[j]);
+				data[j] = msgs[i].buf[j + 1];
+//				printk("0x%02x ", data[j]);
 			}
-			//printk("\n");
 			ret = az6007_usb_out_op(d,req,value,index,data,length);
-		}
-		else //read
-		{
-			//printk("Demodulator Read DevAddr=%02x RegAddr=%02x\n", msg[0].addr, msg[0].buf[0]);
-			req = 0xB9;
-			index = 0;
-			value = msg[0].addr + (0 << 8);
-			length = msg[0].len + 6;
+		} else {
+			/* read bytes */
+//			printk("az6007 I2C xfer read addr=0x%x len=%d: ",
+//				 addr, msgs[i].len);
+			req = 0xb9;
+			index = msgs[i].buf[0];
+			value = addr;
+			length = msgs[i].len + 6;
+			len = msgs[i].len;
 			ret = az6007_usb_in_op(d,req,value,index,data,length);
-			len = msg[0].len;
-			//printk("Demodulator ReadDATA len=%d ", len);
-			for (j=0; j<len; j++)
+			for (j = 0; j < len; j++)
 			{
-				msg[0].buf[j] = data[j+5];
-				//printk("data[%d]=%02x ", j, data[j+5]);
+				msgs[i].buf[j] = data[j + 5];
+//				printk("0x%02x ", data[j + 5]);
 			}
-			//printk("\n");
 		}
+//		printk("\n");
+		if (ret < 0)
+			goto err;
 	}
+err:
 	mutex_unlock(&d->i2c_mutex);
-	return ret;
+
+	if (ret < 0) {
+		info("%s ERROR: %i\n", __func__, ret);
+		return ret;
+	}
+	return num;
 }
 
 
@@ -540,11 +547,11 @@ int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_propert
 	s16 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev,0),
 		0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b, 6, USB_CTRL_GET_TIMEOUT);
 
-	info("FW GET_VERSION length: %d\n",ret);
+	info("FW GET_VERSION length: %d",ret);
 
 	*cold = ret <= 0;
 
-	info("cold: %d\n", *cold);
+	info("cold: %d", *cold);
 	return 0;
 }
 
@@ -572,7 +579,6 @@ static struct dvb_usb_device_properties az6007_properties = {
 	.firmware            = "dvb-usb-az6007-03.fw",
 	.no_reconnect        = 1,
 
-	.size_of_priv     = sizeof(struct az6007_device_state),
 	.identify_state		= az6007_identify_state,
 	.num_adapters = 1,
 	.adapter = {
@@ -593,7 +599,7 @@ static struct dvb_usb_device_properties az6007_properties = {
 					}
 				}
 			},
-			.size_of_priv     = 0,//sizeof(struct az6007_state),
+			.size_of_priv     = sizeof(struct az6007_device_state),
 		}
 	},
 	//.power_ctrl       = az6007_power_ctrl,
@@ -634,7 +640,7 @@ static struct usb_driver az6007_usb_driver = {
 static int __init az6007_usb_module_init(void)
 {
 	int result;
-	info("henry :: az6007 usb module init");
+	info("az6007 usb module init");
 	if ((result = usb_register(&az6007_usb_driver))) {
 		err("usb_register failed. (%d)",result);
 		return result;
@@ -646,7 +652,7 @@ static int __init az6007_usb_module_init(void)
 static void __exit az6007_usb_module_exit(void)
 {
 	/* deregister this driver from the USB subsystem */
-	info("henry :: az6007 usb module exit");
+	info("az6007 usb module exit");
 	usb_deregister(&az6007_usb_driver);
 }
 
-- 
1.7.8


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

* [PATCH 04/35] [media] az6007: Fix the I2C code in order to handle mt2063
  2012-01-21 16:04     ` [PATCH 03/35] [media] az6007: Fix it to allow loading it without crash Mauro Carvalho Chehab
@ 2012-01-21 16:04       ` Mauro Carvalho Chehab
  2012-01-21 16:04         ` [PATCH 05/35] [media] az6007: Comment the gate_ctl mutex Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

mt2063 uses a one-byte transfer. This requires a special handling
inside the i2c code. Fix it to properly accept i2c reads. This
is needed to make the mt2063 to be detected.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   47 +++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 6a21f92..56126d4 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -42,7 +42,7 @@ struct az6007_device_state {
 struct drxk_config terratec_h7_drxk = {
 	.adr = 0x29,
 	.single_master = 1,
-	.no_i2c_bridge = 1,
+	.no_i2c_bridge = 0,
 	.microcode_name = "dvb-usb-terratec-h5-drxk.fw",
 };
 
@@ -451,7 +451,6 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu
 
 	for (i = 0; i < num; i++) {
 		addr = msgs[i].addr << 1;
-
 		if (((i + 1) < num)
 		    && (msgs[i].len == 1)
 		    && (!msgs[i].flags & I2C_M_RD)
@@ -462,44 +461,55 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu
 			 * the first xfer has just 1 byte length.
 			 * Need to join both into one operation
 			 */
-			printk("az6007 I2C xfer write+read addr=0x%x len=%d/%d: ",
-				addr, msgs[i].len, msgs[i + 1].len);
+			if (dvb_usb_az6007_debug & 2)
+				printk(KERN_DEBUG
+				       "az6007 I2C xfer write+read addr=0x%x len=%d/%d: ",
+				       addr, msgs[i].len, msgs[i + 1].len);
 			req = 0xb9;
-			index = 0;
-			value = addr;
-			for (j = 0; j < msgs[i].len; j++)
-				data[j] = msgs[i].buf[j];
+			index = msgs[i].buf[0];
+			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
 			ret = az6007_usb_in_op(d,req,value,index,data,length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
 					msgs[i + 1].buf[j] = data[j + 5];
-					printk("0x%02x ", msgs[i + 1].buf[j]);
+					if (dvb_usb_az6007_debug & 2)
+						printk(KERN_CONT
+						       "0x%02x ",
+						       msgs[i + 1].buf[j]);
 				}
 			} else
 				ret = -EIO;
 			i++;
 		} else if (!(msgs[i].flags & I2C_M_RD)) {
 			/* write bytes */
-//			printk("az6007 I2C xfer write addr=0x%x len=%d: ",
-//				 addr, msgs[i].len);
+			if (dvb_usb_az6007_debug & 2)
+				printk(KERN_DEBUG
+				       "az6007 I2C xfer write addr=0x%x len=%d: ",
+				       addr, msgs[i].len);
 			req = 0xbd;
 			index = msgs[i].buf[0];
 			value = addr | (1 << 8);
 			length = msgs[i].len - 1;
 			len = msgs[i].len - 1;
-//			printk("(0x%02x) ", msgs[i].buf[0]);
+			if (dvb_usb_az6007_debug & 2)
+				printk(KERN_CONT
+				       "(0x%02x) ", msgs[i].buf[0]);
 			for (j = 0; j < len; j++)
 			{
 				data[j] = msgs[i].buf[j + 1];
-//				printk("0x%02x ", data[j]);
+				if (dvb_usb_az6007_debug & 2)
+					printk(KERN_CONT
+					       "0x%02x ", data[j]);
 			}
 			ret = az6007_usb_out_op(d,req,value,index,data,length);
 		} else {
 			/* read bytes */
-//			printk("az6007 I2C xfer read addr=0x%x len=%d: ",
-//				 addr, msgs[i].len);
+			if (dvb_usb_az6007_debug & 2)
+				printk(KERN_DEBUG
+				       "az6007 I2C xfer read addr=0x%x len=%d: ",
+				       addr, msgs[i].len);
 			req = 0xb9;
 			index = msgs[i].buf[0];
 			value = addr;
@@ -509,10 +519,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu
 			for (j = 0; j < len; j++)
 			{
 				msgs[i].buf[j] = data[j + 5];
-//				printk("0x%02x ", data[j + 5]);
+				if (dvb_usb_az6007_debug & 2)
+					printk(KERN_CONT
+					       "0x%02x ", data[j + 5]);
 			}
 		}
-//		printk("\n");
+		if (dvb_usb_az6007_debug & 2)
+			printk(KERN_CONT "\n");
 		if (ret < 0)
 			goto err;
 	}
-- 
1.7.8


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

* [PATCH 05/35] [media] az6007: Comment the gate_ctl mutex
  2012-01-21 16:04       ` [PATCH 04/35] [media] az6007: Fix the I2C code in order to handle mt2063 Mauro Carvalho Chehab
@ 2012-01-21 16:04         ` Mauro Carvalho Chehab
  2012-01-21 16:04           ` [PATCH 06/35] [media] az6007: Remove some dead code that doesn't seem to be needed Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

The mutex is there to protect the I2C gate. However, for some reason,
it is being called twice:

[ 2103.542796] usbcore: registered new interface driver dvb_usb_az6007
[ 2103.772392] az6007: drxk_gate_ctrl: enable
[ 2103.793900] az6007: drxk_gate_ctrl: enable

For now, let's just comment, to allow the driver to run.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 56126d4..ed376b8 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -52,7 +52,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 	struct az6007_device_state *st;
 	int status;
 
-	info("%s", __func__);
+	info("%s: %s", __func__, enable? "enable" : "disable" );
 
 	if (!adap)
 		return -EINVAL;
@@ -64,10 +64,14 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 
 
 	if (enable) {
+#if 0
 		down(&st->pll_mutex);
+#endif
 		status = st->gate_ctrl(fe, 1);
 	} else {
+#if 0
 		status = st->gate_ctrl(fe, 0);
+#endif
 		up(&st->pll_mutex);
 	}
 	return status;
-- 
1.7.8


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

* [PATCH 06/35] [media] az6007: Remove some dead code that doesn't seem to be needed
  2012-01-21 16:04         ` [PATCH 05/35] [media] az6007: Comment the gate_ctl mutex Mauro Carvalho Chehab
@ 2012-01-21 16:04           ` Mauro Carvalho Chehab
  2012-01-21 16:04             ` [PATCH 07/35] [media] az6007: CodingStyle cleanup Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   79 +++++++----------------------------
 1 files changed, 16 insertions(+), 63 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index ed376b8..1fc174b 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -17,17 +17,8 @@ int dvb_usb_az6007_debug;
 module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
 
-
-static int az6007_type =0;
-module_param(az6007_type, int, 0644);
-MODULE_PARM_DESC(az6007_type, "select delivery mode (0=DVB-T, 1=DVB-T");
-
-//module_param_named(type, 6007_type, int, 0644);
-//MODULE_PARM_DESC(type, "select delivery mode (0=DVB-T, 1=DVB-C)");
-
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
-
 struct az6007_device_state {
 	struct dvb_ca_en50221 ca;
 	struct mutex ca_mutex;
@@ -110,57 +101,22 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 {
 	int ret;
 
-#if 0
-	int i=0, cyc=0, rem=0;
-	cyc = blen/64;
-	rem = blen%64;
-#endif
-
 	deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
 	debug_dump(b,blen,deb_xfer);
 
-
-#if 0
-	if (blen>64)
-	{
-		for (i=0; i<cyc; i++)
-		{
-			if ((ret = usb_control_msg(d->udev,
-				usb_sndctrlpipe(d->udev,0),
-				req,
-				USB_TYPE_VENDOR | USB_DIR_OUT,
-				value,index+i*64,b+i*64,64,
-				5000)) != 64) {
-				warn("usb out operation failed. (%d)",ret);
-				return -EIO;
-			}
-		}
-
-		if (rem>0)
-		{
-			if ((ret = usb_control_msg(d->udev,
-				usb_sndctrlpipe(d->udev,0),
-				req,
-				USB_TYPE_VENDOR | USB_DIR_OUT,
-				value,index+cyc*64,b+cyc*64,rem,
-				5000)) != rem) {
-				warn("usb out operation failed. (%d)",ret);
-				return -EIO;
-			}
-		}
+	if (blen > 64) {
+		printk(KERN_ERR "az6007: doesn't suport I2C transactions longer than 64 bytes\n");
+		return -EOPNOTSUPP;
 	}
-	else
-#endif
-	{
-		if ((ret = usb_control_msg(d->udev,
-				usb_sndctrlpipe(d->udev,0),
-				req,
-				USB_TYPE_VENDOR | USB_DIR_OUT,
-				value,index,b,blen,
-				5000)) != blen) {
-			warn("usb out operation failed. (%d)",ret);
-			return -EIO;
-		}
+
+	if ((ret = usb_control_msg(d->udev,
+			usb_sndctrlpipe(d->udev,0),
+			req,
+			USB_TYPE_VENDOR | USB_DIR_OUT,
+			value,index,b,blen,
+			5000)) != blen) {
+		warn("usb out operation failed. (%d)",ret);
+		return -EIO;
 	}
 
 	return 0;
@@ -232,7 +188,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	info("az6007_frontend_poweron adap=%p adap->dev=%p", adap, adap->dev);
 
 	req = 0xBC;
-	value = 1;//power on
+	value = 1;		/* power on */
 	index = 3;
 	blen =0;
 
@@ -245,7 +201,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	msleep_interruptible(200);
 
 	req = 0xBC;
-	value = 0;//power on
+	value = 0;		/* power off */
 	index = 3;
 	blen =0;
 
@@ -258,7 +214,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	msleep_interruptible(200);
 
 	req = 0xBC;
-	value = 1;//power on
+	value = 1;		/* power on */
 	index = 3;
 	blen =0;
 
@@ -552,9 +508,6 @@ static u32 az6007_i2c_func(struct i2c_adapter *adapter)
 static struct i2c_algorithm az6007_i2c_algo = {
 	.master_xfer   = az6007_i2c_xfer,
 	.functionality = az6007_i2c_func,
-#ifdef NEED_ALGO_CONTROL
-	.algo_control = dummy_algo_control,
-#endif
 };
 
 int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
@@ -678,5 +631,5 @@ module_exit(az6007_usb_module_exit);
 
 MODULE_AUTHOR("Henry Wang <Henry.wang@AzureWave.com>");
 MODULE_DESCRIPTION("Driver for AzureWave 6007 DVB-C/T USB2.0 and clones");
-MODULE_VERSION("1.0");
+MODULE_VERSION("1.1");
 MODULE_LICENSE("GPL");
-- 
1.7.8


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

* [PATCH 07/35] [media] az6007: CodingStyle cleanup
  2012-01-21 16:04           ` [PATCH 06/35] [media] az6007: Remove some dead code that doesn't seem to be needed Mauro Carvalho Chehab
@ 2012-01-21 16:04             ` Mauro Carvalho Chehab
  2012-01-21 16:04               ` [PATCH 08/35] [media] az6007: Get rid of az6007.h Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

make checkpatch.pl happy

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |  239 ++++++++++++++++++------------------
 1 files changed, 120 insertions(+), 119 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 1fc174b..a709cec 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -14,23 +14,24 @@
 
 /* debug */
 int dvb_usb_az6007_debug;
-module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
+module_param_named(debug, dvb_usb_az6007_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))."
+		 DVB_USB_DEBUG_STATUS);
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct az6007_device_state {
-	struct dvb_ca_en50221 ca;
-	struct mutex ca_mutex;
-	u8 power_state;
+	struct			dvb_ca_en50221 ca;
+	struct			mutex ca_mutex;
+	u8			power_state;
 
 	/* Due to DRX-K - probably need changes */
-	int (*gate_ctrl)(struct dvb_frontend *, int);
-	struct semaphore      pll_mutex;
+	int			(*gate_ctrl) (struct dvb_frontend *, int);
+	struct			semaphore pll_mutex;
 	bool			dont_attach_fe1;
 };
 
-struct drxk_config terratec_h7_drxk = {
+static struct drxk_config terratec_h7_drxk = {
 	.adr = 0x29,
 	.single_master = 1,
 	.no_i2c_bridge = 0,
@@ -43,7 +44,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 	struct az6007_device_state *st;
 	int status;
 
-	info("%s: %s", __func__, enable? "enable" : "disable" );
+	info("%s: %s", __func__, enable ? "enable" : "disable");
 
 	if (!adap)
 		return -EINVAL;
@@ -53,7 +54,6 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 	if (!st)
 		return -EINVAL;
 
-
 	if (enable) {
 #if 0
 		down(&st->pll_mutex);
@@ -68,30 +68,31 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 	return status;
 }
 
-struct mt2063_config az6007_mt2063_config = {
+static struct mt2063_config az6007_mt2063_config = {
 	.tuner_address = 0x60,
 	.refclock = 36125000,
 };
 
 /* check for mutex FIXME */
-int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen)
+static int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
+			    u16 index, u8 *b, int blen)
 {
 	int ret = -1;
 
-		ret = usb_control_msg(d->udev,
-			usb_rcvctrlpipe(d->udev,0),
-			req,
-			USB_TYPE_VENDOR | USB_DIR_IN,
-			value,index,b,blen,
-			5000);
+	ret = usb_control_msg(d->udev,
+			      usb_rcvctrlpipe(d->udev, 0),
+			      req,
+			      USB_TYPE_VENDOR | USB_DIR_IN,
+			      value, index, b, blen, 5000);
 
 	if (ret < 0) {
 		warn("usb in operation failed. (%d)", ret);
 		return -EIO;
 	}
 
-	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
-	debug_dump(b,blen,deb_xfer);
+	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ", req, value,
+		 index);
+	debug_dump(b, blen, deb_xfer);
 
 	return ret;
 }
@@ -101,21 +102,23 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 {
 	int ret;
 
-	deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
-	debug_dump(b,blen,deb_xfer);
+	deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ", req, value,
+		 index);
+	debug_dump(b, blen, deb_xfer);
 
 	if (blen > 64) {
-		printk(KERN_ERR "az6007: doesn't suport I2C transactions longer than 64 bytes\n");
+		printk(KERN_ERR
+		       "az6007: doesn't suport I2C transactions longer than 64 bytes\n");
 		return -EOPNOTSUPP;
 	}
 
-	if ((ret = usb_control_msg(d->udev,
-			usb_sndctrlpipe(d->udev,0),
-			req,
-			USB_TYPE_VENDOR | USB_DIR_OUT,
-			value,index,b,blen,
-			5000)) != blen) {
-		warn("usb out operation failed. (%d)",ret);
+	ret = usb_control_msg(d->udev,
+			      usb_sndctrlpipe(d->udev, 0),
+			      req,
+			      USB_TYPE_VENDOR | USB_DIR_OUT,
+			      value, index, b, blen, 5000);
+	if (ret != blen) {
+		warn("usb out operation failed. (%d)", ret);
 		return -EIO;
 	}
 
@@ -128,25 +131,24 @@ static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 }
 
 /* keys for the enclosed remote control */
-struct rc_map_table rc_map_az6007_table[] = {
-	{ 0x0001, KEY_1 },
-	{ 0x0002, KEY_2 },
+static struct rc_map_table rc_map_az6007_table[] = {
+	{0x0001, KEY_1},
+	{0x0002, KEY_2},
 };
 
 /* remote control stuff (does not work with my box) */
-static int az6007_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
+static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 {
 	return 0;
 #if 0
 	u8 key[10];
 	int i;
 
-/* remove the following return to enabled remote querying */
-
+	/* remove the following return to enabled remote querying */
 
-	az6007_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10);
+	az6007_usb_in_op(d, READ_REMOTE_REQ, 0, 0, key, 10);
 
-	deb_rc("remote query key: %x %d\n",key[1],key[1]);
+	deb_rc("remote query key: %x %d\n", key[1], key[1]);
 
 	if (key[1] == 0x44) {
 		*state = REMOTE_NO_KEY_PRESSED;
@@ -171,7 +173,7 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 }
 */
 
-static int az6007_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
+static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
 	az6007_usb_in_op(d, 0xb7, 6, 0, &mac[0], 6);
 	return 0;
@@ -190,12 +192,12 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	req = 0xBC;
 	value = 1;		/* power on */
 	index = 3;
-	blen =0;
+	blen = 0;
 
-	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
-	{
+	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	if (ret != 0) {
 		err("az6007_frontend_poweron failed!!!");
-		 return -EIO;
+		return -EIO;
 	}
 
 	msleep_interruptible(200);
@@ -203,12 +205,12 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	req = 0xBC;
 	value = 0;		/* power off */
 	index = 3;
-	blen =0;
+	blen = 0;
 
-	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
-	{
+	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	if (ret != 0) {
 		err("az6007_frontend_poweron failed!!!");
-		 return -EIO;
+		return -EIO;
 	}
 
 	msleep_interruptible(200);
@@ -216,12 +218,12 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	req = 0xBC;
 	value = 1;		/* power on */
 	index = 3;
-	blen =0;
+	blen = 0;
 
-	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
-	{
+	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	if (ret != 0) {
 		err("az6007_frontend_poweron failed!!!");
-		 return -EIO;
+		return -EIO;
 	}
 	info("az6007_frontend_poweron: OK");
 
@@ -238,37 +240,37 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 
 	info("az6007_frontend_reset adap=%p adap->dev=%p", adap, adap->dev);
 
-	//reset demodulator
+	/* reset demodulator */
 	req = 0xC0;
-	value = 1;//high
+	value = 1;		/* high */
 	index = 3;
-	blen =0;
-	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
-	{
+	blen = 0;
+	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	if (ret != 0) {
 		err("az6007_frontend_reset failed 1 !!!");
-		   return -EIO;
+		return -EIO;
 	}
 
 	req = 0xC0;
-	value = 0;//low
+	value = 0;		/* low */
 	index = 3;
-	blen =0;
+	blen = 0;
 	msleep_interruptible(200);
-	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
-	{
+	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	if (ret != 0) {
 		err("az6007_frontend_reset failed 2 !!!");
-		   return -EIO;
+		return -EIO;
 	}
 	msleep_interruptible(200);
 	req = 0xC0;
-	value = 1;//high
+	value = 1;		/* high */
 	index = 3;
-	blen =0;
+	blen = 0;
 
-	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
-	{
+	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	if (ret != 0) {
 		err("az6007_frontend_reset failed 3 !!!");
-		   return -EIO;
+		return -EIO;
 	}
 
 	msleep_interruptible(200);
@@ -285,18 +287,17 @@ static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 	u16 value;
 	u16 index;
 	int blen;
-	//TS through
+	/* TS through */
 	req = 0xBC;
 	value = onoff;
 	index = 0;
-	blen =0;
+	blen = 0;
 
 	ret = usb_control_msg(interface_to_usbdev(intf),
-		usb_rcvctrlpipe(interface_to_usbdev(intf),0),
-		req,
-		USB_TYPE_VENDOR | USB_DIR_OUT,
-		value,index,NULL,blen,
-		2000);
+			      usb_rcvctrlpipe(interface_to_usbdev(intf), 0),
+			      req,
+			      USB_TYPE_VENDOR | USB_DIR_OUT,
+			      value, index, NULL, blen, 2000);
 
 	if (ret < 0) {
 		warn("usb in operation failed. (%d)", ret);
@@ -304,27 +305,28 @@ static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 	} else
 		ret = 0;
 
-
-	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
+	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ", req, value,
+		 index);
 
 	return ret;
 }
 
-static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap,int onoff)
+static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap, int onoff)
 {
 	int ret;
 	u8 req;
 	u16 value;
 	u16 index;
 	int blen;
-	//TS through
+	/* TS through */
 	req = 0xC7;
 	value = onoff;
 	index = 0;
-	blen =0;
+	blen = 0;
 
-	if((ret = az6007_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0)
-		   return -EIO;
+	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	if (ret != 0)
+		return -EIO;
 	return 0;
 }
 
@@ -373,8 +375,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 	/* Hack - needed due to drxk */
 	adap->fe2->tuner_priv = adap->fe->tuner_priv;
 	memcpy(&adap->fe2->ops.tuner_ops,
-	       &adap->fe->ops.tuner_ops,
-	       sizeof(adap->fe->ops.tuner_ops));
+	       &adap->fe->ops.tuner_ops, sizeof(adap->fe->ops.tuner_ops));
 	return 0;
 
 out_free:
@@ -388,14 +389,14 @@ out_free:
 
 static struct dvb_usb_device_properties az6007_properties;
 
-static void
-az6007_usb_disconnect(struct usb_interface *intf)
+static void az6007_usb_disconnect(struct usb_interface *intf)
 {
-	dvb_usb_device_exit (intf);
+	dvb_usb_device_exit(intf);
 }
 
 /* I2C */
-static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int num)
+static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
+			   int num)
 {
 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
 	int i, j, len;
@@ -430,7 +431,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
-			ret = az6007_usb_in_op(d,req,value,index,data,length);
+			ret = az6007_usb_in_op(d, req, value, index, data,
+					       length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
 					msgs[i + 1].buf[j] = data[j + 5];
@@ -454,16 +456,14 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu
 			length = msgs[i].len - 1;
 			len = msgs[i].len - 1;
 			if (dvb_usb_az6007_debug & 2)
-				printk(KERN_CONT
-				       "(0x%02x) ", msgs[i].buf[0]);
-			for (j = 0; j < len; j++)
-			{
+				printk(KERN_CONT "(0x%02x) ", msgs[i].buf[0]);
+			for (j = 0; j < len; j++) {
 				data[j] = msgs[i].buf[j + 1];
 				if (dvb_usb_az6007_debug & 2)
-					printk(KERN_CONT
-					       "0x%02x ", data[j]);
+					printk(KERN_CONT "0x%02x ", data[j]);
 			}
-			ret = az6007_usb_out_op(d,req,value,index,data,length);
+			ret =  az6007_usb_out_op(d, req, value, index, data,
+						 length);
 		} else {
 			/* read bytes */
 			if (dvb_usb_az6007_debug & 2)
@@ -475,9 +475,9 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int nu
 			value = addr;
 			length = msgs[i].len + 6;
 			len = msgs[i].len;
-			ret = az6007_usb_in_op(d,req,value,index,data,length);
-			for (j = 0; j < len; j++)
-			{
+			ret = az6007_usb_in_op(d, req, value, index, data,
+					       length);
+			for (j = 0; j < len; j++) {
 				msgs[i].buf[j] = data[j + 5];
 				if (dvb_usb_az6007_debug & 2)
 					printk(KERN_CONT
@@ -499,25 +499,26 @@ err:
 	return num;
 }
 
-
 static u32 az6007_i2c_func(struct i2c_adapter *adapter)
 {
 	return I2C_FUNC_I2C;
 }
 
 static struct i2c_algorithm az6007_i2c_algo = {
-	.master_xfer   = az6007_i2c_xfer,
+	.master_xfer = az6007_i2c_xfer,
 	.functionality = az6007_i2c_func,
 };
 
-int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
-			struct dvb_usb_device_description **desc, int *cold)
+int az6007_identify_state(struct usb_device *udev,
+			  struct dvb_usb_device_properties *props,
+			  struct dvb_usb_device_description **desc, int *cold)
 {
 	u8 b[16];
-	s16 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev,0),
-		0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b, 6, USB_CTRL_GET_TIMEOUT);
+	s16 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+				  0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b,
+				  6, USB_CTRL_GET_TIMEOUT);
 
-	info("FW GET_VERSION length: %d",ret);
+	info("FW GET_VERSION length: %d", ret);
 
 	*cold = ret <= 0;
 
@@ -526,7 +527,7 @@ int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_propert
 }
 
 static int az6007_usb_probe(struct usb_interface *intf,
-		const struct usb_device_id *id)
+			    const struct usb_device_id *id)
 {
 	az6007_led_on_off(intf, 0);
 
@@ -534,10 +535,10 @@ static int az6007_usb_probe(struct usb_interface *intf,
 				   THIS_MODULE, NULL, adapter_nr);
 }
 
-static struct usb_device_id az6007_usb_table [] = {
-	    { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_6007) },
-	    { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7) },
-	    { 0 },
+static struct usb_device_id az6007_usb_table[] = {
+	{USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_6007)},
+	{USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7)},
+	{0},
 };
 
 MODULE_DEVICE_TABLE(usb, az6007_usb_table);
@@ -545,7 +546,6 @@ MODULE_DEVICE_TABLE(usb, az6007_usb_table);
 static struct dvb_usb_device_properties az6007_properties = {
 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
 	.usb_ctrl = CYPRESS_FX2,
-	//.download_firmware = az6007_download_firmware,
 	.firmware            = "dvb-usb-az6007-03.fw",
 	.no_reconnect        = 1,
 
@@ -553,8 +553,7 @@ static struct dvb_usb_device_properties az6007_properties = {
 	.num_adapters = 1,
 	.adapter = {
 		{
-			//.caps             = DVB_USB_ADAP_RECEIVES_204_BYTE_TS,
-
+			/* .caps             = DVB_USB_ADAP_RECEIVES_204_BYTE_TS, */
 			.streaming_ctrl   = az6007_streaming_ctrl,
 			.frontend_attach  = az6007_frontend_attach,
 
@@ -572,7 +571,7 @@ static struct dvb_usb_device_properties az6007_properties = {
 			.size_of_priv     = sizeof(struct az6007_device_state),
 		}
 	},
-	//.power_ctrl       = az6007_power_ctrl,
+	/* .power_ctrl       = az6007_power_ctrl, */
 	.read_mac_address = az6007_read_mac_addr,
 
 	.rc.legacy = {
@@ -600,10 +599,10 @@ static struct dvb_usb_device_properties az6007_properties = {
 /* usb specific object needed to register this driver with the usb subsystem */
 static struct usb_driver az6007_usb_driver = {
 	.name		= "dvb_usb_az6007",
-	.probe 		= az6007_usb_probe,
+	.probe		= az6007_usb_probe,
 	.disconnect = dvb_usb_device_exit,
-	//.disconnect 	= az6007_usb_disconnect,
-	.id_table 	= az6007_usb_table,
+	/* .disconnect	= az6007_usb_disconnect, */
+	.id_table	= az6007_usb_table,
 };
 
 /* module stuff */
@@ -611,8 +610,10 @@ static int __init az6007_usb_module_init(void)
 {
 	int result;
 	info("az6007 usb module init");
-	if ((result = usb_register(&az6007_usb_driver))) {
-		err("usb_register failed. (%d)",result);
+
+	result = usb_register(&az6007_usb_driver);
+	if (result) {
+		err("usb_register failed. (%d)", result);
 		return result;
 	}
 
-- 
1.7.8


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

* [PATCH 08/35] [media] az6007: Get rid of az6007.h
  2012-01-21 16:04             ` [PATCH 07/35] [media] az6007: CodingStyle cleanup Mauro Carvalho Chehab
@ 2012-01-21 16:04               ` Mauro Carvalho Chehab
  2012-01-21 16:04                 ` [PATCH 09/35] [media] az6007: Replace the comments at the beginning of the driver Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

The header file serves for no purpose and exports some things
that should be static.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   11 +++++++++--
 drivers/media/dvb/dvb-usb/az6007.h |   18 ------------------
 2 files changed, 9 insertions(+), 20 deletions(-)
 delete mode 100644 drivers/media/dvb/dvb-usb/az6007.h

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index a709cec..1791cb0 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -3,13 +3,15 @@
  * see Documentation/dvb/README.dvb-usb for more information
  */
 
-#include "az6007.h"
 #include "drxk.h"
 #include "mt2063.h"
 #include "dvb_ca_en50221.h"
+#include "dvb-usb.h"
+
+#define DVB_USB_LOG_PREFIX "az6007"
 
 /* HACK: Should be moved to the right place */
-#define USB_PID_AZUREWAVE_6007		0xccd
+#define USB_PID_AZUREWAVE_6007		0x0ccd
 #define USB_PID_TERRATEC_H7		0x10b4
 
 /* debug */
@@ -18,6 +20,11 @@ module_param_named(debug, dvb_usb_az6007_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))."
 		 DVB_USB_DEBUG_STATUS);
 
+#define deb_info(args...) dprintk(dvb_usb_az6007_debug, 0x01, args)
+#define deb_xfer(args...) dprintk(dvb_usb_az6007_debug, 0x02, args)
+#define deb_rc(args...)   dprintk(dvb_usb_az6007_debug, 0x04, args)
+#define deb_fe(args...)   dprintk(dvb_usb_az6007_debug, 0x08, args)
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct az6007_device_state {
diff --git a/drivers/media/dvb/dvb-usb/az6007.h b/drivers/media/dvb/dvb-usb/az6007.h
deleted file mode 100644
index aefa5b5..0000000
--- a/drivers/media/dvb/dvb-usb/az6007.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _DVB_USB_AZ6007_H_
-#define _DVB_USB_AZ6007_H_
-
-#define DVB_USB_LOG_PREFIX "az6007"
-#include "dvb-usb.h"
-
-
-extern int dvb_usb_az6007_debug;
-#define deb_info(args...) dprintk(dvb_usb_az6007_debug,0x01,args)
-#define deb_xfer(args...) dprintk(dvb_usb_az6007_debug,0x02,args)
-#define deb_rc(args...)   dprintk(dvb_usb_az6007_debug,0x04,args)
-#define deb_fe(args...)   dprintk(dvb_usb_az6007_debug,0x08,args)
-
-
-extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec);
-extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
-
-#endif
-- 
1.7.8


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

* [PATCH 09/35] [media] az6007: Replace the comments at the beginning of the driver
  2012-01-21 16:04               ` [PATCH 08/35] [media] az6007: Get rid of az6007.h Mauro Carvalho Chehab
@ 2012-01-21 16:04                 ` Mauro Carvalho Chehab
  2012-01-21 16:04                   ` [PATCH 10/35] [media] az6007: move device PID's to the proper place Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

The comments there is wrong.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 1791cb0..f946b1b 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -1,6 +1,23 @@
-/* DVB USB compliant Linux driver for the AzureWave 6017 USB2.0 DVB-S
- * receiver.
- * see Documentation/dvb/README.dvb-usb for more information
+/*
+ * Driver for AzureWave 6007 DVB-C/T USB2.0 and clones
+ *
+ * Copyright (c) Henry Wang <Henry.wang@AzureWave.com>
+ *
+ * This driver was made publicly available by Terratec, at:
+ *	http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
+ * The original driver's license is GPL, as declared with MODULE_LICENSE()
+ *
+ *  Driver modifiyed by Mauro Carvalho Chehab <mchehab@redhat.com> in order
+ * 	to work with upstream drxk driver, and to fix some bugs.
+ *
+ * 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 under version 2 of the License.
+ *
+ * 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.
  */
 
 #include "drxk.h"
-- 
1.7.8


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

* [PATCH 10/35] [media] az6007: move device PID's to the proper place
  2012-01-21 16:04                 ` [PATCH 09/35] [media] az6007: Replace the comments at the beginning of the driver Mauro Carvalho Chehab
@ 2012-01-21 16:04                   ` Mauro Carvalho Chehab
  2012-01-21 16:04                     ` [PATCH 11/35] [media] az6007: make driver less verbose Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c      |    4 ----
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h |    2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index f946b1b..780a480 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -27,10 +27,6 @@
 
 #define DVB_USB_LOG_PREFIX "az6007"
 
-/* HACK: Should be moved to the right place */
-#define USB_PID_AZUREWAVE_6007		0x0ccd
-#define USB_PID_TERRATEC_H7		0x10b4
-
 /* debug */
 int dvb_usb_az6007_debug;
 module_param_named(debug, dvb_usb_az6007_debug, int, 0644);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index d390dda..b3e7be4 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -80,6 +80,7 @@
 #define USB_PID_ANSONIC_DVBT_USB			0x6000
 #define USB_PID_ANYSEE					0x861f
 #define USB_PID_AZUREWAVE_AD_TU700			0x3237
+#define USB_PID_AZUREWAVE_6007				0x0ccd
 #define USB_PID_AVERMEDIA_DVBT_USB_COLD			0x0001
 #define USB_PID_AVERMEDIA_DVBT_USB_WARM			0x0002
 #define USB_PID_AVERMEDIA_DVBT_USB2_COLD		0xa800
@@ -226,6 +227,7 @@
 #define USB_PID_TERRATEC_CINERGY_T_EXPRESS		0x0062
 #define USB_PID_TERRATEC_CINERGY_T_XXS			0x0078
 #define USB_PID_TERRATEC_CINERGY_T_XXS_2		0x00ab
+#define USB_PID_TERRATEC_H7				0x10b4
 #define USB_PID_TERRATEC_T3				0x10a0
 #define USB_PID_TERRATEC_T5				0x10a1
 #define USB_PID_PINNACLE_EXPRESSCARD_320CX		0x022e
-- 
1.7.8


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

* [PATCH 11/35] [media] az6007: make driver less verbose
  2012-01-21 16:04                   ` [PATCH 10/35] [media] az6007: move device PID's to the proper place Mauro Carvalho Chehab
@ 2012-01-21 16:04                     ` Mauro Carvalho Chehab
  2012-01-21 16:04                       ` [PATCH 12/35] [media] drxk: Don't assume a default firmware name Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   35 +++++++++++++++++------------------
 1 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 780a480..bb597c6 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -62,9 +62,9 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 {
 	struct dvb_usb_adapter *adap = fe->sec_priv;
 	struct az6007_device_state *st;
-	int status;
+	int status = 0;
 
-	info("%s: %s", __func__, enable ? "enable" : "disable");
+	deb_info("%s: %s\n", __func__, enable ? "enable" : "disable");
 
 	if (!adap)
 		return -EINVAL;
@@ -127,8 +127,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 	debug_dump(b, blen, deb_xfer);
 
 	if (blen > 64) {
-		printk(KERN_ERR
-		       "az6007: doesn't suport I2C transactions longer than 64 bytes\n");
+		err("az6007: doesn't suport I2C transactions longer than 64 bytes\n");
 		return -EOPNOTSUPP;
 	}
 
@@ -138,7 +137,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 			      USB_TYPE_VENDOR | USB_DIR_OUT,
 			      value, index, b, blen, 5000);
 	if (ret != blen) {
-		warn("usb out operation failed. (%d)", ret);
+		err("usb out operation failed. (%d)", ret);
 		return -EIO;
 	}
 
@@ -207,7 +206,8 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	u16 index;
 	int blen;
 
-	info("az6007_frontend_poweron adap=%p adap->dev=%p", adap, adap->dev);
+	deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
+		 adap, adap->dev);
 
 	req = 0xBC;
 	value = 1;		/* power on */
@@ -245,7 +245,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 		err("az6007_frontend_poweron failed!!!");
 		return -EIO;
 	}
-	info("az6007_frontend_poweron: OK");
+	deb_info("az6007_frontend_poweron: OK\n");
 
 	return 0;
 }
@@ -258,7 +258,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 	u16 index;
 	int blen;
 
-	info("az6007_frontend_reset adap=%p adap->dev=%p", adap, adap->dev);
+	deb_info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
 
 	/* reset demodulator */
 	req = 0xC0;
@@ -295,7 +295,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 
 	msleep_interruptible(200);
 
-	info("reset az6007 frontend");
+	deb_info("reset az6007 frontend\n");
 
 	return 0;
 }
@@ -361,8 +361,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 	az6007_frontend_poweron(adap);
 	az6007_frontend_reset(adap);
 
-	info("az6007_frontend_attach: drxk");
-
+	info("az6007: attaching demod drxk");
 	adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
 			      &adap->dev->i2c_adap, &adap->fe2);
 	if (!adap->fe) {
@@ -370,7 +369,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 		goto out_free;
 	}
 
-	info("Setting hacks");
+	deb_info("Setting hacks\n");
 
 	/* FIXME: do we need a pll semaphore? */
 	adap->fe->sec_priv = adap;
@@ -379,7 +378,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 	adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
 	adap->fe2->id = 1;
 
-	info("az6007_frontend_attach: mt2063");
+	info("az6007: attaching tuner mt2063");
 	/* Attach mt2063 to DVB-C frontend */
 	if (adap->fe->ops.i2c_gate_ctrl)
 		adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
@@ -513,7 +512,7 @@ err:
 	mutex_unlock(&d->i2c_mutex);
 
 	if (ret < 0) {
-		info("%s ERROR: %i\n", __func__, ret);
+		info("%s ERROR: %i", __func__, ret);
 		return ret;
 	}
 	return num;
@@ -538,11 +537,11 @@ int az6007_identify_state(struct usb_device *udev,
 				  0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b,
 				  6, USB_CTRL_GET_TIMEOUT);
 
-	info("FW GET_VERSION length: %d", ret);
+	deb_info("FW GET_VERSION length: %d\n", ret);
 
 	*cold = ret <= 0;
 
-	info("cold: %d", *cold);
+	deb_info("cold: %d\n", *cold);
 	return 0;
 }
 
@@ -629,7 +628,7 @@ static struct usb_driver az6007_usb_driver = {
 static int __init az6007_usb_module_init(void)
 {
 	int result;
-	info("az6007 usb module init");
+	deb_info("az6007 usb module init\n");
 
 	result = usb_register(&az6007_usb_driver);
 	if (result) {
@@ -643,7 +642,7 @@ static int __init az6007_usb_module_init(void)
 static void __exit az6007_usb_module_exit(void)
 {
 	/* deregister this driver from the USB subsystem */
-	info("az6007 usb module exit");
+	deb_info("az6007 usb module exit\n");
 	usb_deregister(&az6007_usb_driver);
 }
 
-- 
1.7.8


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

* [PATCH 12/35] [media] drxk: Don't assume a default firmware name
  2012-01-21 16:04                     ` [PATCH 11/35] [media] az6007: make driver less verbose Mauro Carvalho Chehab
@ 2012-01-21 16:04                       ` Mauro Carvalho Chehab
  2012-01-21 16:04                         ` [PATCH 13/35] [media] az6007: need to define drivers name before including dvb-usb.h Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Move the ngene/ddbridge firmware into their drivers.

There are two reasons for that:
	1) The firmware used there didn't work for a few devices
I tested here (Terratec H5, H6 and H7);
	2) At least Terratec H7 doesn't seem to require a firmware
for it to work.

After this change, if firmware is not specified, the driver will
use a rom-based firmware (this seems to be the case for Terratec
H7, although I need to better check the USB dumps to be sure about
that).

In any case, the firmware seems to be optional, as the DRX-K driver
don't return the firmware load error.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/ddbridge/ddbridge-core.c |    1 +
 drivers/media/dvb/dvb-usb/az6007.c         |    8 +++++---
 drivers/media/dvb/frontends/drxk_hard.c    |    4 +---
 drivers/media/dvb/ngene/ngene-cards.c      |    1 +
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
index 2f31648..243dbb3 100644
--- a/drivers/media/dvb/ddbridge/ddbridge-core.c
+++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
@@ -578,6 +578,7 @@ static int demod_attach_drxk(struct ddb_input *input)
 	struct drxk_config config;
 
 	memset(&config, 0, sizeof(config));
+	config.microcode_name = "drxk_a3.mc";
 	config.adr = 0x29 + (input->nr & 1);
 
 	fe = input->fe = dvb_attach(drxk_attach, &config, i2c);
diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index bb597c6..523972f 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -55,7 +55,8 @@ static struct drxk_config terratec_h7_drxk = {
 	.adr = 0x29,
 	.single_master = 1,
 	.no_i2c_bridge = 0,
-	.microcode_name = "dvb-usb-terratec-h5-drxk.fw",
+	.max_size = 64,
+//	.microcode_name = "dvb-usb-terratec-h5-drxk.fw",
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
@@ -127,7 +128,8 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 	debug_dump(b, blen, deb_xfer);
 
 	if (blen > 64) {
-		err("az6007: doesn't suport I2C transactions longer than 64 bytes\n");
+		err("az6007: tried to write %d bytes, but I2C max size is 64 bytes\n",
+		    blen);
 		return -EOPNOTSUPP;
 	}
 
@@ -395,6 +397,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 	adap->fe2->tuner_priv = adap->fe->tuner_priv;
 	memcpy(&adap->fe2->ops.tuner_ops,
 	       &adap->fe->ops.tuner_ops, sizeof(adap->fe->ops.tuner_ops));
+
 	return 0;
 
 out_free:
@@ -572,7 +575,6 @@ static struct dvb_usb_device_properties az6007_properties = {
 	.num_adapters = 1,
 	.adapter = {
 		{
-			/* .caps             = DVB_USB_ADAP_RECEIVES_204_BYTE_TS, */
 			.streaming_ctrl   = az6007_streaming_ctrl,
 			.frontend_attach  = az6007_frontend_attach,
 
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index 6980ed7..4b99255 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -6070,9 +6070,7 @@ static int init_drxk(struct drxk_state *state)
 		if (status < 0)
 			goto error;
 
-		if (!state->microcode_name)
-			load_microcode(state, "drxk_a3.mc");
-		else
+		if (state->microcode_name)
 			load_microcode(state, state->microcode_name);
 
 		/* disable token-ring bus through OFDM block for possible ucode upload */
diff --git a/drivers/media/dvb/ngene/ngene-cards.c b/drivers/media/dvb/ngene/ngene-cards.c
index 8418c02..7539a5d 100644
--- a/drivers/media/dvb/ngene/ngene-cards.c
+++ b/drivers/media/dvb/ngene/ngene-cards.c
@@ -216,6 +216,7 @@ static int demod_attach_drxk(struct ngene_channel *chan,
 	struct drxk_config config;
 
 	memset(&config, 0, sizeof(config));
+	config.microcode_name = "drxk_a3.mc";
 	config.adr = 0x29 + (chan->number ^ 2);
 
 	chan->fe = dvb_attach(drxk_attach, &config, i2c);
-- 
1.7.8


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

* [PATCH 13/35] [media] az6007: need to define drivers name before including dvb-usb.h
  2012-01-21 16:04                       ` [PATCH 12/35] [media] drxk: Don't assume a default firmware name Mauro Carvalho Chehab
@ 2012-01-21 16:04                         ` Mauro Carvalho Chehab
  2012-01-21 16:04                           ` [PATCH 14/35] [media] az6007: Fix some init sequences and use the right firmwares Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 523972f..87dff93 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -23,9 +23,9 @@
 #include "drxk.h"
 #include "mt2063.h"
 #include "dvb_ca_en50221.h"
-#include "dvb-usb.h"
 
 #define DVB_USB_LOG_PREFIX "az6007"
+#include "dvb-usb.h"
 
 /* debug */
 int dvb_usb_az6007_debug;
-- 
1.7.8


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

* [PATCH 14/35] [media] az6007: Fix some init sequences and use the right firmwares
  2012-01-21 16:04                         ` [PATCH 13/35] [media] az6007: need to define drivers name before including dvb-usb.h Mauro Carvalho Chehab
@ 2012-01-21 16:04                           ` Mauro Carvalho Chehab
  2012-01-21 16:04                             ` [PATCH 15/35] [media] az6007: Change the az6007 read/write routine parameter Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |  105 +++++++++++++++---------------------
 1 files changed, 43 insertions(+), 62 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 87dff93..03e318d 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -56,7 +56,8 @@ static struct drxk_config terratec_h7_drxk = {
 	.single_master = 1,
 	.no_i2c_bridge = 0,
 	.max_size = 64,
-//	.microcode_name = "dvb-usb-terratec-h5-drxk.fw",
+	.microcode_name = "dvb-usb-terratec-h7-drxk.fw",
+	.parallel_ts = 1,
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
@@ -200,53 +201,31 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 	return 0;
 }
 
+#define AZ6007_POWER	0xbc
+#define FX2_SCON1		0xc0
+#define AZ6007_TS_THROUGH	0xc7
+
 static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 {
-	int ret;
-	u8 req;
-	u16 value;
-	u16 index;
-	int blen;
+	struct dvb_usb_device *d = adap->dev;
 
 	deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
 		 adap, adap->dev);
 
-	req = 0xBC;
-	value = 1;		/* power on */
-	index = 3;
-	blen = 0;
-
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-	if (ret != 0) {
-		err("az6007_frontend_poweron failed!!!");
-		return -EIO;
-	}
-
-	msleep_interruptible(200);
-
-	req = 0xBC;
-	value = 0;		/* power off */
-	index = 3;
-	blen = 0;
-
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-	if (ret != 0) {
-		err("az6007_frontend_poweron failed!!!");
-		return -EIO;
-	}
-
-	msleep_interruptible(200);
-
-	req = 0xBC;
-	value = 1;		/* power on */
-	index = 3;
-	blen = 0;
+	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
+	msleep(150);
+	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	msleep(100);
+	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
+	msleep(100);
+	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	msleep(100);
+	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
+	msleep (10);
+	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
+	msleep (10);
+	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
 
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-	if (ret != 0) {
-		err("az6007_frontend_poweron failed!!!");
-		return -EIO;
-	}
 	deb_info("az6007_frontend_poweron: OK\n");
 
 	return 0;
@@ -333,25 +312,6 @@ static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 	return ret;
 }
 
-static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap, int onoff)
-{
-	int ret;
-	u8 req;
-	u16 value;
-	u16 index;
-	int blen;
-	/* TS through */
-	req = 0xC7;
-	value = onoff;
-	index = 0;
-	blen = 0;
-
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-	if (ret != 0)
-		return -EIO;
-	return 0;
-}
-
 static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	struct az6007_device_state *st = adap->priv;
@@ -409,6 +369,27 @@ out_free:
 	return result;
 }
 
+int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
+{
+	if (!onoff)
+		return 0;
+
+
+	info("Sending poweron sequence");
+
+	az6007_usb_out_op(d, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);
+
+#if 0
+	// Seems to be a poweroff sequence
+	az6007_usb_out_op(d, 0xbc, 1, 3, NULL, 0);
+	az6007_usb_out_op(d, 0xbc, 1, 4, NULL, 0);
+	az6007_usb_out_op(d, 0xc0, 0, 3, NULL, 0);
+	az6007_usb_out_op(d, 0xc0, 1, 3, NULL, 0);
+	az6007_usb_out_op(d, 0xbc, 0, 1, NULL, 0);
+#endif
+	return 0;
+}
+
 static struct dvb_usb_device_properties az6007_properties;
 
 static void az6007_usb_disconnect(struct usb_interface *intf)
@@ -568,7 +549,7 @@ MODULE_DEVICE_TABLE(usb, az6007_usb_table);
 static struct dvb_usb_device_properties az6007_properties = {
 	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
 	.usb_ctrl = CYPRESS_FX2,
-	.firmware            = "dvb-usb-az6007-03.fw",
+	.firmware            = "dvb-usb-terratec-h7-az6007.fw",
 	.no_reconnect        = 1,
 
 	.identify_state		= az6007_identify_state,
@@ -592,7 +573,7 @@ static struct dvb_usb_device_properties az6007_properties = {
 			.size_of_priv     = sizeof(struct az6007_device_state),
 		}
 	},
-	/* .power_ctrl       = az6007_power_ctrl, */
+	.power_ctrl       = az6007_power_ctrl,
 	.read_mac_address = az6007_read_mac_addr,
 
 	.rc.legacy = {
-- 
1.7.8


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

* [PATCH 15/35] [media] az6007: Change the az6007 read/write routine parameter
  2012-01-21 16:04                           ` [PATCH 14/35] [media] az6007: Fix some init sequences and use the right firmwares Mauro Carvalho Chehab
@ 2012-01-21 16:04                             ` Mauro Carvalho Chehab
  2012-01-21 16:04                               ` [PATCH 16/35] [media] az6007: Simplify the read/write logic Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Use usb_device for those routines, as it allows using them on
all places. While there, rename to better express the meaning.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   56 ++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 03e318d..f098e47 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -96,13 +96,13 @@ static struct mt2063_config az6007_mt2063_config = {
 };
 
 /* check for mutex FIXME */
-static int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
+static int az6007_read(struct usb_device *udev, u8 req, u16 value,
 			    u16 index, u8 *b, int blen)
 {
 	int ret = -1;
 
-	ret = usb_control_msg(d->udev,
-			      usb_rcvctrlpipe(d->udev, 0),
+	ret = usb_control_msg(udev,
+			      usb_rcvctrlpipe(udev, 0),
 			      req,
 			      USB_TYPE_VENDOR | USB_DIR_IN,
 			      value, index, b, blen, 5000);
@@ -119,7 +119,7 @@ static int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
 	return ret;
 }
 
-static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
+static int az6007_write(struct usb_device *udev, u8 req, u16 value,
 			     u16 index, u8 *b, int blen)
 {
 	int ret;
@@ -134,8 +134,8 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
 		return -EOPNOTSUPP;
 	}
 
-	ret = usb_control_msg(d->udev,
-			      usb_sndctrlpipe(d->udev, 0),
+	ret = usb_control_msg(udev,
+			      usb_sndctrlpipe(udev, 0),
 			      req,
 			      USB_TYPE_VENDOR | USB_DIR_OUT,
 			      value, index, b, blen, 5000);
@@ -168,7 +168,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 
 	/* remove the following return to enabled remote querying */
 
-	az6007_usb_in_op(d, READ_REMOTE_REQ, 0, 0, key, 10);
+	az6007_read(d->udev, READ_REMOTE_REQ, 0, 0, key, 10);
 
 	deb_rc("remote query key: %x %d\n", key[1], key[1]);
 
@@ -191,13 +191,13 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
 	u8 v = onoff;
-	return az6007_usb_out_op(d,0xBC,v,3,NULL,1);
+	return az6007_write(d->udev,0xBC,v,3,NULL,1);
 }
 */
 
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
-	az6007_usb_in_op(d, 0xb7, 6, 0, &mac[0], 6);
+	az6007_read(d->udev, 0xb7, 6, 0, &mac[0], 6);
 	return 0;
 }
 
@@ -212,19 +212,19 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 	deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
 		 adap, adap->dev);
 
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
 	msleep(150);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
 	msleep(100);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
 	msleep(100);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
 	msleep(100);
-	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
+	az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
 	msleep (10);
-	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
+	az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
 	msleep (10);
-	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
+	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
 
 	deb_info("az6007_frontend_poweron: OK\n");
 
@@ -246,7 +246,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 	value = 1;		/* high */
 	index = 3;
 	blen = 0;
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
 	if (ret != 0) {
 		err("az6007_frontend_reset failed 1 !!!");
 		return -EIO;
@@ -257,7 +257,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 	index = 3;
 	blen = 0;
 	msleep_interruptible(200);
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
 	if (ret != 0) {
 		err("az6007_frontend_reset failed 2 !!!");
 		return -EIO;
@@ -268,7 +268,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 	index = 3;
 	blen = 0;
 
-	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
 	if (ret != 0) {
 		err("az6007_frontend_reset failed 3 !!!");
 		return -EIO;
@@ -377,15 +377,15 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 
 	info("Sending poweron sequence");
 
-	az6007_usb_out_op(d, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);
+	az6007_write(d->udev, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);
 
 #if 0
 	// Seems to be a poweroff sequence
-	az6007_usb_out_op(d, 0xbc, 1, 3, NULL, 0);
-	az6007_usb_out_op(d, 0xbc, 1, 4, NULL, 0);
-	az6007_usb_out_op(d, 0xc0, 0, 3, NULL, 0);
-	az6007_usb_out_op(d, 0xc0, 1, 3, NULL, 0);
-	az6007_usb_out_op(d, 0xbc, 0, 1, NULL, 0);
+	az6007_write(d->udev, 0xbc, 1, 3, NULL, 0);
+	az6007_write(d->udev, 0xbc, 1, 4, NULL, 0);
+	az6007_write(d->udev, 0xc0, 0, 3, NULL, 0);
+	az6007_write(d->udev, 0xc0, 1, 3, NULL, 0);
+	az6007_write(d->udev, 0xbc, 0, 1, NULL, 0);
 #endif
 	return 0;
 }
@@ -434,7 +434,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
-			ret = az6007_usb_in_op(d, req, value, index, data,
+			ret = az6007_read(d->udev, req, value, index, data,
 					       length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
@@ -465,7 +465,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 				if (dvb_usb_az6007_debug & 2)
 					printk(KERN_CONT "0x%02x ", data[j]);
 			}
-			ret =  az6007_usb_out_op(d, req, value, index, data,
+			ret =  az6007_write(d->udev, req, value, index, data,
 						 length);
 		} else {
 			/* read bytes */
@@ -478,7 +478,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr;
 			length = msgs[i].len + 6;
 			len = msgs[i].len;
-			ret = az6007_usb_in_op(d, req, value, index, data,
+			ret = az6007_read(d->udev, req, value, index, data,
 					       length);
 			for (j = 0; j < len; j++) {
 				msgs[i].buf[j] = data[j + 5];
-- 
1.7.8


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

* [PATCH 16/35] [media] az6007: Simplify the read/write logic
  2012-01-21 16:04                             ` [PATCH 15/35] [media] az6007: Change the az6007 read/write routine parameter Mauro Carvalho Chehab
@ 2012-01-21 16:04                               ` Mauro Carvalho Chehab
  2012-01-21 16:04                                 ` [PATCH 17/35] [media] az6007: Simplify the code by removing an uneeded function Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

This patch introduces no functional changes. It basically defines
a macro for each different req found at the driver, and cleans the
code to use them, making easier to understand the code.

With regards to the IR handling code, although the original code
doesn't define what's the request, it is clear, from the USB logs,
that 0xc5 is for IR polling.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |  185 +++++++++++++++++-------------------
 1 files changed, 87 insertions(+), 98 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index f098e47..8add81a 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -40,6 +40,17 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))."
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
+/* Known requests (Cypress FX2 firmware + az6007 "private" ones*/
+
+#define FX2_OED			0xb5
+#define AZ6007_READ_DATA	0xb7
+#define AZ6007_I2C_RD		0xb9
+#define AZ6007_POWER		0xbc
+#define AZ6007_I2C_WR		0xbd
+#define FX2_SCON1		0xc0
+#define AZ6007_TS_THROUGH	0xc7
+#define AZ6007_READ_IR		0xc5
+
 struct az6007_device_state {
 	struct			dvb_ca_en50221 ca;
 	struct			mutex ca_mutex;
@@ -168,7 +179,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 
 	/* remove the following return to enabled remote querying */
 
-	az6007_read(d->udev, READ_REMOTE_REQ, 0, 0, key, 10);
+	az6007_read(d->udev, AZ6007_READ_IR, 0, 0, key, 10);
 
 	deb_rc("remote query key: %x %d\n", key[1], key[1]);
 
@@ -187,127 +198,104 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 #endif
 }
 
-/*
+#if 0
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
 	u8 v = onoff;
-	return az6007_write(d->udev,0xBC,v,3,NULL,1);
+	return az6007_write(d->udev, AZ6007_POWER, v , 3, NULL, 1);
 }
-*/
+#endif
 
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
-	az6007_read(d->udev, 0xb7, 6, 0, &mac[0], 6);
-	return 0;
-}
+	int ret;
+	ret = az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
 
-#define AZ6007_POWER	0xbc
-#define FX2_SCON1		0xc0
-#define AZ6007_TS_THROUGH	0xc7
+	if (ret > 0)
+		deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n",
+			 __func__, mac[0], mac[1], mac[2],
+			 mac[3], mac[4], mac[5]);
+
+	return ret;
+}
 
 static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 {
-	struct dvb_usb_device *d = adap->dev;
+	int ret;
+	struct usb_device *udev = adap->dev->udev;
 
-	deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
-		 adap, adap->dev);
+	deb_info("%s: adap=%p adap->dev=%p\n", __func__, adap, adap->dev);
 
-	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
+	ret = az6007_write(udev, AZ6007_POWER, 0, 2, NULL, 0);
+	if (ret < 0)
+		goto error;
 	msleep(150);
-	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+	if (ret < 0)
+		goto error;
 	msleep(100);
-	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
+	ret = az6007_write(udev, AZ6007_POWER, 1, 3, NULL, 0);
+	if (ret < 0)
+		goto error;
 	msleep(100);
-	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+	ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+	if (ret < 0)
+		goto error;
 	msleep(100);
-	az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
+	ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
+	if (ret < 0)
+		goto error;
 	msleep (10);
-	az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
+	ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
+	if (ret < 0)
+		goto error;
 	msleep (10);
-	az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
+	ret = az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
 
-	deb_info("az6007_frontend_poweron: OK\n");
+error:
+	if (ret < 0)
+		err("%s failed with error %d", __func__, ret);
 
-	return 0;
+	return ret;
 }
 
 static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 {
+	struct usb_device *udev = adap->dev->udev;
 	int ret;
-	u8 req;
-	u16 value;
-	u16 index;
-	int blen;
 
 	deb_info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
 
 	/* reset demodulator */
-	req = 0xC0;
-	value = 1;		/* high */
-	index = 3;
-	blen = 0;
-	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
-	if (ret != 0) {
-		err("az6007_frontend_reset failed 1 !!!");
-		return -EIO;
-	}
+	ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
+	if (ret < 0)
+		goto error;
+	msleep(200);
+	ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
+	if (ret < 0)
+		goto error;
+	msleep(200);
+	ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
+	if (ret < 0)
+		goto error;
+	msleep(200);
+
+error:
+	if (ret < 0)
+		err("%s failed with error %d", __func__, ret);
 
-	req = 0xC0;
-	value = 0;		/* low */
-	index = 3;
-	blen = 0;
-	msleep_interruptible(200);
-	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
-	if (ret != 0) {
-		err("az6007_frontend_reset failed 2 !!!");
-		return -EIO;
-	}
-	msleep_interruptible(200);
-	req = 0xC0;
-	value = 1;		/* high */
-	index = 3;
-	blen = 0;
-
-	ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
-	if (ret != 0) {
-		err("az6007_frontend_reset failed 3 !!!");
-		return -EIO;
-	}
-
-	msleep_interruptible(200);
-
-	deb_info("reset az6007 frontend\n");
-
-	return 0;
+	return ret;
 }
 
 static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 {
-	int ret = -1;
-	u8 req;
-	u16 value;
-	u16 index;
-	int blen;
-	/* TS through */
-	req = 0xBC;
-	value = onoff;
-	index = 0;
-	blen = 0;
-
-	ret = usb_control_msg(interface_to_usbdev(intf),
-			      usb_rcvctrlpipe(interface_to_usbdev(intf), 0),
-			      req,
-			      USB_TYPE_VENDOR | USB_DIR_OUT,
-			      value, index, NULL, blen, 2000);
-
-	if (ret < 0) {
-		warn("usb in operation failed. (%d)", ret);
-		ret = -EIO;
-	} else
-		ret = 0;
+	struct usb_device *udev = interface_to_usbdev(intf);
+	int ret;
 
-	deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ", req, value,
-		 index);
+	/* TS through */
+	ret = az6007_write(udev, AZ6007_POWER, onoff, 0, NULL, 0);
+	if (ret < 0)
+		err("%s failed with error %d", __func__, ret);
 
 	return ret;
 }
@@ -377,7 +365,7 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 
 	info("Sending poweron sequence");
 
-	az6007_write(d->udev, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);
+	az6007_write(d->udev, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
 
 #if 0
 	// Seems to be a poweroff sequence
@@ -429,7 +417,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 				printk(KERN_DEBUG
 				       "az6007 I2C xfer write+read addr=0x%x len=%d/%d: ",
 				       addr, msgs[i].len, msgs[i + 1].len);
-			req = 0xb9;
+			req = AZ6007_I2C_RD;
 			index = msgs[i].buf[0];
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
@@ -453,7 +441,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 				printk(KERN_DEBUG
 				       "az6007 I2C xfer write addr=0x%x len=%d: ",
 				       addr, msgs[i].len);
-			req = 0xbd;
+			req = AZ6007_I2C_WR;
 			index = msgs[i].buf[0];
 			value = addr | (1 << 8);
 			length = msgs[i].len - 1;
@@ -473,7 +461,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 				printk(KERN_DEBUG
 				       "az6007 I2C xfer read addr=0x%x len=%d: ",
 				       addr, msgs[i].len);
-			req = 0xb9;
+			req = AZ6007_I2C_RD;
 			index = msgs[i].buf[0];
 			value = addr;
 			length = msgs[i].len + 6;
@@ -516,16 +504,17 @@ int az6007_identify_state(struct usb_device *udev,
 			  struct dvb_usb_device_properties *props,
 			  struct dvb_usb_device_description **desc, int *cold)
 {
-	u8 b[16];
-	s16 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
-				  0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b,
-				  6, USB_CTRL_GET_TIMEOUT);
-
-	deb_info("FW GET_VERSION length: %d\n", ret);
+	int ret;
+	u8 mac[6];
 
-	*cold = ret <= 0;
+	/* Try to read the mac address */
+	ret = az6007_read(udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+	if (ret == 6)
+		*cold = 0;
+	else
+		*cold = 1;
 
-	deb_info("cold: %d\n", *cold);
+	deb_info("Device is on %s state\n", *cold? "warm" : "cold");
 	return 0;
 }
 
-- 
1.7.8


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

* [PATCH 17/35] [media] az6007: Simplify the code by removing an uneeded function
  2012-01-21 16:04                               ` [PATCH 16/35] [media] az6007: Simplify the read/write logic Mauro Carvalho Chehab
@ 2012-01-21 16:04                                 ` Mauro Carvalho Chehab
  2012-01-21 16:04                                   ` [PATCH 18/35] [media] az6007: Fix IR receive code Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Everything to reset the demod is already at
az6007_frontend_poweron().

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   29 -----------------------------
 1 files changed, 0 insertions(+), 29 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 8add81a..912ba67 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -259,34 +259,6 @@ error:
 	return ret;
 }
 
-static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
-{
-	struct usb_device *udev = adap->dev->udev;
-	int ret;
-
-	deb_info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
-
-	/* reset demodulator */
-	ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep(200);
-	ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep(200);
-	ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep(200);
-
-error:
-	if (ret < 0)
-		err("%s failed with error %d", __func__, ret);
-
-	return ret;
-}
-
 static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
@@ -309,7 +281,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 	BUG_ON(!st);
 
 	az6007_frontend_poweron(adap);
-	az6007_frontend_reset(adap);
 
 	info("az6007: attaching demod drxk");
 	adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
-- 
1.7.8


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

* [PATCH 18/35] [media] az6007: Fix IR receive code
  2012-01-21 16:04                                 ` [PATCH 17/35] [media] az6007: Simplify the code by removing an uneeded function Mauro Carvalho Chehab
@ 2012-01-21 16:04                                   ` Mauro Carvalho Chehab
  2012-01-21 16:04                                     ` [PATCH 19/35] [media] az6007: improve the error messages for az6007 read/write calls Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

The code still needs to be commented, as there's a mutex
missing at the az6007_read() call. A mutex there is needed,
in order to prevent RC (or CI) calls while other operations
are in progress.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   37 +++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 912ba67..c9743ee 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -49,7 +49,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 #define AZ6007_I2C_WR		0xbd
 #define FX2_SCON1		0xc0
 #define AZ6007_TS_THROUGH	0xc7
-#define AZ6007_READ_IR		0xc5
+#define AZ6007_READ_IR		0xb4
 
 struct az6007_device_state {
 	struct			dvb_ca_en50221 ca;
@@ -172,30 +172,45 @@ static struct rc_map_table rc_map_az6007_table[] = {
 /* remote control stuff (does not work with my box) */
 static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 {
-	return 0;
-#if 0
+	struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
 	u8 key[10];
 	int i;
 
-	/* remove the following return to enabled remote querying */
+	/*
+	 * FIXME: remove the following return to enabled remote querying
+	 * The driver likely needs proper locking to avoid troubles between
+	 * this call and other concurrent calls.
+	 */
+	return 0;
 
 	az6007_read(d->udev, AZ6007_READ_IR, 0, 0, key, 10);
 
-	deb_rc("remote query key: %x %d\n", key[1], key[1]);
-
 	if (key[1] == 0x44) {
 		*state = REMOTE_NO_KEY_PRESSED;
 		return 0;
 	}
 
-	for (i = 0; i < ARRAY_SIZE(az6007_rc_keys); i++)
-		if (az6007_rc_keys[i].custom == key[1]) {
+	/*
+	 * FIXME: need to make something useful with the keycodes and to
+	 * convert it to the non-legacy mode. Yet, it is producing some
+	 * debug info already, like:
+	 * 88 04 eb 02 fd ff 00 82 63 82 (terratec IR)
+	 * 88 04 eb 03 fc 00 00 82 63 82 (terratec IR)
+	 * 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR)
+	 * I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity
+	 */
+	deb_rc("remote query key: %x %d\n", key[1], key[1]);
+	print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, key, 10);
+
+	for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
+		if (rc5_custom(&keymap[i]) == key[1]) {
+			*event = keymap[i].keycode;
 			*state = REMOTE_KEY_PRESSED;
-			*event = az6007_rc_keys[i].event;
-			break;
+
+			return 0;
 		}
+	}
 	return 0;
-#endif
 }
 
 #if 0
-- 
1.7.8


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

* [PATCH 19/35] [media] az6007: improve the error messages for az6007 read/write calls
  2012-01-21 16:04                                   ` [PATCH 18/35] [media] az6007: Fix IR receive code Mauro Carvalho Chehab
@ 2012-01-21 16:04                                     ` Mauro Carvalho Chehab
  2012-01-21 16:04                                       ` [PATCH 20/35] [media] az6007: Use the new MFE support at dvb-usb Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index c9743ee..c9b6f80 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -110,16 +110,15 @@ static struct mt2063_config az6007_mt2063_config = {
 static int az6007_read(struct usb_device *udev, u8 req, u16 value,
 			    u16 index, u8 *b, int blen)
 {
-	int ret = -1;
+	int ret;
 
 	ret = usb_control_msg(udev,
 			      usb_rcvctrlpipe(udev, 0),
 			      req,
 			      USB_TYPE_VENDOR | USB_DIR_IN,
 			      value, index, b, blen, 5000);
-
 	if (ret < 0) {
-		warn("usb in operation failed. (%d)", ret);
+		warn("usb read operation failed. (%d)", ret);
 		return -EIO;
 	}
 
@@ -151,7 +150,7 @@ static int az6007_write(struct usb_device *udev, u8 req, u16 value,
 			      USB_TYPE_VENDOR | USB_DIR_OUT,
 			      value, index, b, blen, 5000);
 	if (ret != blen) {
-		err("usb out operation failed. (%d)", ret);
+		err("usb write operation failed. (%d)", ret);
 		return -EIO;
 	}
 
-- 
1.7.8


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

* [PATCH 20/35] [media] az6007: Use the new MFE support at dvb-usb
  2012-01-21 16:04                                     ` [PATCH 19/35] [media] az6007: improve the error messages for az6007 read/write calls Mauro Carvalho Chehab
@ 2012-01-21 16:04                                       ` Mauro Carvalho Chehab
  2012-01-21 16:04                                         ` [PATCH 21/35] [media] az6007: Change it to use the MFE solution adopted " Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Use the newly dvb-usb MFE support added by
changeset 9bd9e3bd2c57530dfe3057dd0aa9bdb37824925d.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   74 ++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index c9b6f80..b667854 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -59,7 +59,7 @@ struct az6007_device_state {
 	/* Due to DRX-K - probably need changes */
 	int			(*gate_ctrl) (struct dvb_frontend *, int);
 	struct			semaphore pll_mutex;
-	bool			dont_attach_fe1;
+	bool			tuner_attached;
 };
 
 static struct drxk_config terratec_h7_drxk = {
@@ -290,56 +290,56 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	struct az6007_device_state *st = adap->priv;
 
-	int result;
+	/* FIXME: dvb-usb will call this function twice! */
+	if (adap->fe[0])
+		return 0;
 
 	BUG_ON(!st);
 
 	az6007_frontend_poweron(adap);
 
-	info("az6007: attaching demod drxk");
-	adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
-			      &adap->dev->i2c_adap, &adap->fe2);
-	if (!adap->fe) {
-		result = -EINVAL;
-		goto out_free;
-	}
-
-	deb_info("Setting hacks\n");
+	info("attaching demod drxk");
+	adap->fe[0] = dvb_attach(drxk_attach, &terratec_h7_drxk,
+			         &adap->dev->i2c_adap, &adap->fe[1]);
+	if (!adap->fe[0])
+		return -EINVAL;
 
+	adap->fe[0]->sec_priv = adap;
 	/* FIXME: do we need a pll semaphore? */
-	adap->fe->sec_priv = adap;
 	sema_init(&st->pll_mutex, 1);
-	st->gate_ctrl = adap->fe->ops.i2c_gate_ctrl;
-	adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
-	adap->fe2->id = 1;
+	st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
+	adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
+	adap->dont_attach_fe[1] = true;
+
+	return 0;
+}
+
+static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
+{
+	struct az6007_device_state *st = adap->priv;
+
+	if (st->tuner_attached)
+		return 0;
+
+	st->tuner_attached = true;
 
-	info("az6007: attaching tuner mt2063");
+	info("attaching tuner mt2063");
 	/* Attach mt2063 to DVB-C frontend */
-	if (adap->fe->ops.i2c_gate_ctrl)
-		adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
-	if (!dvb_attach(mt2063_attach, adap->fe, &az6007_mt2063_config,
-			&adap->dev->i2c_adap)) {
-		result = -EINVAL;
+	if (adap->fe[0]->ops.i2c_gate_ctrl)
+		adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 1);
+	if (!dvb_attach(mt2063_attach, adap->fe[0], &az6007_mt2063_config,
+			&adap->dev->i2c_adap))
+		return -EINVAL;
 
-		goto out_free;
-	}
-	if (adap->fe->ops.i2c_gate_ctrl)
-		adap->fe->ops.i2c_gate_ctrl(adap->fe, 0);
+	if (adap->fe[0]->ops.i2c_gate_ctrl)
+		adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 0);
 
 	/* Hack - needed due to drxk */
-	adap->fe2->tuner_priv = adap->fe->tuner_priv;
-	memcpy(&adap->fe2->ops.tuner_ops,
-	       &adap->fe->ops.tuner_ops, sizeof(adap->fe->ops.tuner_ops));
+	adap->fe[1]->tuner_priv = adap->fe[0]->tuner_priv;
+	memcpy(&adap->fe[1]->ops.tuner_ops,
+	       &adap->fe[0]->ops.tuner_ops, sizeof(adap->fe[0]->ops.tuner_ops));
 
 	return 0;
-
-out_free:
-	if (adap->fe)
-		dvb_frontend_detach(adap->fe);
-	adap->fe = NULL;
-	adap->fe2 = NULL;
-
-	return result;
 }
 
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
@@ -530,7 +530,9 @@ static struct dvb_usb_device_properties az6007_properties = {
 	.num_adapters = 1,
 	.adapter = {
 		{
+			.num_frontends    = 2,
 			.streaming_ctrl   = az6007_streaming_ctrl,
+			.tuner_attach     = az6007_tuner_attach,
 			.frontend_attach  = az6007_frontend_attach,
 
 			/* parameter for the MPEG2-data transfer */
-- 
1.7.8


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

* [PATCH 21/35] [media] az6007: Change it to use the MFE solution adopted at dvb-usb
  2012-01-21 16:04                                       ` [PATCH 20/35] [media] az6007: Use the new MFE support at dvb-usb Mauro Carvalho Chehab
@ 2012-01-21 16:04                                         ` Mauro Carvalho Chehab
  2012-01-21 16:04                                           ` [PATCH 22/35] [media] az6007: Use a per device private struct Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

This driver were written to use a previous solution for MFE at dvb-usb.
Due to the internal API changes, change the binding to work with the
new way.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   42 ++++++++++++++---------------------
 1 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index b667854..92ded30 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -66,7 +66,7 @@ static struct drxk_config terratec_h7_drxk = {
 	.adr = 0x29,
 	.single_master = 1,
 	.no_i2c_bridge = 0,
-	.max_size = 64,
+	.chunk_size = 64,
 	.microcode_name = "dvb-usb-terratec-h7-drxk.fw",
 	.parallel_ts = 1,
 };
@@ -290,26 +290,21 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	struct az6007_device_state *st = adap->priv;
 
-	/* FIXME: dvb-usb will call this function twice! */
-	if (adap->fe[0])
-		return 0;
-
 	BUG_ON(!st);
 
 	az6007_frontend_poweron(adap);
 
 	info("attaching demod drxk");
-	adap->fe[0] = dvb_attach(drxk_attach, &terratec_h7_drxk,
-			         &adap->dev->i2c_adap, &adap->fe[1]);
-	if (!adap->fe[0])
+	adap->fe_adap[0].fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
+					 &adap->dev->i2c_adap);
+	if (!adap->fe_adap[0].fe)
 		return -EINVAL;
 
-	adap->fe[0]->sec_priv = adap;
+	adap->fe_adap[0].fe->sec_priv = adap;
 	/* FIXME: do we need a pll semaphore? */
 	sema_init(&st->pll_mutex, 1);
-	st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
-	adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
-	adap->dont_attach_fe[1] = true;
+	st->gate_ctrl = adap->fe_adap[0].fe->ops.i2c_gate_ctrl;
+	adap->fe_adap[0].fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
 
 	return 0;
 }
@@ -325,19 +320,15 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 
 	info("attaching tuner mt2063");
 	/* Attach mt2063 to DVB-C frontend */
-	if (adap->fe[0]->ops.i2c_gate_ctrl)
-		adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 1);
-	if (!dvb_attach(mt2063_attach, adap->fe[0], &az6007_mt2063_config,
+	if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
+		adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 1);
+	if (!dvb_attach(mt2063_attach, adap->fe_adap[0].fe, 
+			&az6007_mt2063_config,
 			&adap->dev->i2c_adap))
 		return -EINVAL;
 
-	if (adap->fe[0]->ops.i2c_gate_ctrl)
-		adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 0);
-
-	/* Hack - needed due to drxk */
-	adap->fe[1]->tuner_priv = adap->fe[0]->tuner_priv;
-	memcpy(&adap->fe[1]->ops.tuner_ops,
-	       &adap->fe[0]->ops.tuner_ops, sizeof(adap->fe[0]->ops.tuner_ops));
+	if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
+		adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 0);
 
 	return 0;
 }
@@ -530,7 +521,8 @@ static struct dvb_usb_device_properties az6007_properties = {
 	.num_adapters = 1,
 	.adapter = {
 		{
-			.num_frontends    = 2,
+		.num_frontends = 1,
+		.fe = {{
 			.streaming_ctrl   = az6007_streaming_ctrl,
 			.tuner_attach     = az6007_tuner_attach,
 			.frontend_attach  = az6007_frontend_attach,
@@ -547,8 +539,8 @@ static struct dvb_usb_device_properties az6007_properties = {
 				}
 			},
 			.size_of_priv     = sizeof(struct az6007_device_state),
-		}
-	},
+		}}
+	} },
 	.power_ctrl       = az6007_power_ctrl,
 	.read_mac_address = az6007_read_mac_addr,
 
-- 
1.7.8


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

* [PATCH 22/35] [media] az6007: Use a per device private struct
  2012-01-21 16:04                                         ` [PATCH 21/35] [media] az6007: Change it to use the MFE solution adopted " Mauro Carvalho Chehab
@ 2012-01-21 16:04                                           ` Mauro Carvalho Chehab
  2012-01-21 16:04                                             ` [PATCH 23/35] [media] drxk: Allow setting it on dynamic_clock mode Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 92ded30..342f929 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -82,7 +82,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 	if (!adap)
 		return -EINVAL;
 
-	st = adap->priv;
+	st = adap->dev->priv;
 
 	if (!st)
 		return -EINVAL;
@@ -288,7 +288,7 @@ static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 
 static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
-	struct az6007_device_state *st = adap->priv;
+	struct az6007_device_state *st = adap->dev->priv;
 
 	BUG_ON(!st);
 
@@ -311,7 +311,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 
 static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 {
-	struct az6007_device_state *st = adap->priv;
+	struct az6007_device_state *st = adap->dev->priv;
 
 	if (st->tuner_attached)
 		return 0;
@@ -516,8 +516,8 @@ static struct dvb_usb_device_properties az6007_properties = {
 	.usb_ctrl = CYPRESS_FX2,
 	.firmware            = "dvb-usb-terratec-h7-az6007.fw",
 	.no_reconnect        = 1,
-
-	.identify_state		= az6007_identify_state,
+	.size_of_priv        = sizeof(struct az6007_device_state),
+	.identify_state	     = az6007_identify_state,
 	.num_adapters = 1,
 	.adapter = {
 		{
@@ -538,7 +538,6 @@ static struct dvb_usb_device_properties az6007_properties = {
 					}
 				}
 			},
-			.size_of_priv     = sizeof(struct az6007_device_state),
 		}}
 	} },
 	.power_ctrl       = az6007_power_ctrl,
-- 
1.7.8


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

* [PATCH 23/35] [media] drxk: Allow setting it on dynamic_clock mode
  2012-01-21 16:04                                           ` [PATCH 22/35] [media] az6007: Use a per device private struct Mauro Carvalho Chehab
@ 2012-01-21 16:04                                             ` Mauro Carvalho Chehab
  2012-01-21 16:04                                               ` [PATCH 24/35] [media] az6007: Use DRX-K dynamic clock mode Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

This is used on az6007.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/frontends/drxk.h      |   17 ++++++++++-------
 drivers/media/dvb/frontends/drxk_hard.c |   14 +++++++++-----
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/media/dvb/frontends/drxk.h b/drivers/media/dvb/frontends/drxk.h
index 0209818..6b0fd2c 100644
--- a/drivers/media/dvb/frontends/drxk.h
+++ b/drivers/media/dvb/frontends/drxk.h
@@ -7,15 +7,17 @@
 /**
  * struct drxk_config - Configure the initial parameters for DRX-K
  *
- * adr:			I2C Address of the DRX-K
- * parallel_ts:		true means that the device uses parallel TS,
+ * @adr:		I2C Address of the DRX-K
+ * @parallel_ts:	True means that the device uses parallel TS,
  * 			Serial otherwise.
- * single_master:	Device is on the single master mode
- * no_i2c_bridge:	Don't switch the I2C bridge to talk with tuner
- * antenna_gpio:	GPIO bit used to control the antenna
- * antenna_dvbt:	GPIO bit for changing antenna to DVB-C. A value of 1
+ * @dynamic_clk:	True means that the clock will be dynamically
+ *			adjusted. Static clock otherwise.
+ * @single_master:	Device is on the single master mode
+ * @no_i2c_bridge:	Don't switch the I2C bridge to talk with tuner
+ * @antenna_gpio:	GPIO bit used to control the antenna
+ * @antenna_dvbt:	GPIO bit for changing antenna to DVB-C. A value of 1
  *			means that 1=DVBC, 0 = DVBT. Zero means the opposite.
- * microcode_name:	Name of the firmware file with the microcode
+ * @microcode_name:	Name of the firmware file with the microcode
  *
  * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is
  * UIO-3.
@@ -25,6 +27,7 @@ struct drxk_config {
 	bool	single_master;
 	bool	no_i2c_bridge;
 	bool	parallel_ts;
+	bool	dynamic_clk;
 
 	bool	antenna_dvbt;
 	u16	antenna_gpio;
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index 4b99255..6570396 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -650,9 +650,6 @@ static int init_state(struct drxk_state *state)
 	u32 ulQual83 = DEFAULT_MER_83;
 	u32 ulQual93 = DEFAULT_MER_93;
 
-	u32 ulDVBTStaticTSClock = 1;
-	u32 ulDVBCStaticTSClock = 1;
-
 	u32 ulMpegLockTimeOut = DEFAULT_DRXK_MPEG_LOCK_TIMEOUT;
 	u32 ulDemodLockTimeOut = DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT;
 
@@ -815,8 +812,7 @@ static int init_state(struct drxk_state *state)
 	state->m_invertSTR = false;	/* If TRUE; invert STR signals */
 	state->m_invertVAL = false;	/* If TRUE; invert VAL signals */
 	state->m_invertCLK = (ulInvertTSClock != 0);	/* If TRUE; invert CLK signals */
-	state->m_DVBTStaticCLK = (ulDVBTStaticTSClock != 0);
-	state->m_DVBCStaticCLK = (ulDVBCStaticTSClock != 0);
+
 	/* If TRUE; static MPEG clockrate will be used;
 	   otherwise clockrate will adapt to the bitrate of the TS */
 
@@ -6390,6 +6386,14 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config,
 	state->antenna_dvbt = config->antenna_dvbt;
 	state->m_ChunkSize = config->chunk_size;
 
+	if (config->dynamic_clk) {
+		state->m_DVBTStaticCLK = 0;
+		state->m_DVBCStaticCLK = 0;
+	} else {
+		state->m_DVBTStaticCLK = 1;
+		state->m_DVBCStaticCLK = 1;
+	}
+
 	if (config->parallel_ts)
 		state->m_enableParallel = true;
 	else
-- 
1.7.8


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

* [PATCH 24/35] [media] az6007: Use DRX-K dynamic clock mode
  2012-01-21 16:04                                             ` [PATCH 23/35] [media] drxk: Allow setting it on dynamic_clock mode Mauro Carvalho Chehab
@ 2012-01-21 16:04                                               ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                 ` [PATCH 25/35] [media] drxk: add support for Mpeg output clock drive strength config Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 342f929..00a0bf1 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -64,11 +64,12 @@ struct az6007_device_state {
 
 static struct drxk_config terratec_h7_drxk = {
 	.adr = 0x29,
-	.single_master = 1,
-	.no_i2c_bridge = 0,
+	.parallel_ts = true,
+	.dynamic_clk = true,
+	.single_master = true,
+	.no_i2c_bridge = false,
 	.chunk_size = 64,
-	.microcode_name = "dvb-usb-terratec-h7-drxk.fw",
-	.parallel_ts = 1,
+	.microcode_name = "dvb-usb-terratec-h7-az6007.fw",
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
-- 
1.7.8


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

* [PATCH 25/35] [media] drxk: add support for Mpeg output clock drive strength config
  2012-01-21 16:04                                               ` [PATCH 24/35] [media] az6007: Use DRX-K dynamic clock mode Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                 ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                   ` [PATCH 26/35] [media] drxk: Allow enabling MERR/MVAL cfg Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c      |    3 +--
 drivers/media/dvb/frontends/drxk.h      |    4 +++-
 drivers/media/dvb/frontends/drxk_hard.c |   12 ++++++------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 00a0bf1..bf8d201 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -69,6 +69,7 @@ static struct drxk_config terratec_h7_drxk = {
 	.single_master = true,
 	.no_i2c_bridge = false,
 	.chunk_size = 64,
+	.mpeg_out_clk_strength = 0x02,
 	.microcode_name = "dvb-usb-terratec-h7-az6007.fw",
 };
 
@@ -278,12 +279,10 @@ static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
 	int ret;
-
 	/* TS through */
 	ret = az6007_write(udev, AZ6007_POWER, onoff, 0, NULL, 0);
 	if (ret < 0)
 		err("%s failed with error %d", __func__, ret);
-
 	return ret;
 }
 
diff --git a/drivers/media/dvb/frontends/drxk.h b/drivers/media/dvb/frontends/drxk.h
index 6b0fd2c..ca921c7 100644
--- a/drivers/media/dvb/frontends/drxk.h
+++ b/drivers/media/dvb/frontends/drxk.h
@@ -17,6 +17,7 @@
  * @antenna_gpio:	GPIO bit used to control the antenna
  * @antenna_dvbt:	GPIO bit for changing antenna to DVB-C. A value of 1
  *			means that 1=DVBC, 0 = DVBT. Zero means the opposite.
+ * @mpeg_out_clk_strength: DRXK Mpeg output clock drive strength.
  * @microcode_name:	Name of the firmware file with the microcode
  *
  * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is
@@ -32,7 +33,8 @@ struct drxk_config {
 	bool	antenna_dvbt;
 	u16	antenna_gpio;
 
-	int    chunk_size;
+	u8	mpeg_out_clk_strength;
+	int	chunk_size;
 
 	const char *microcode_name;
 };
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index 6570396..d25b0d2 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -91,10 +91,6 @@ bool IsA1WithRomCode(struct drxk_state *state)
 #define DRXK_MPEG_PARALLEL_OUTPUT_PIN_DRIVE_STRENGTH (0x03)
 #endif
 
-#ifndef DRXK_MPEG_OUTPUT_CLK_DRIVE_STRENGTH
-#define DRXK_MPEG_OUTPUT_CLK_DRIVE_STRENGTH (0x06)
-#endif
-
 #define DEFAULT_DRXK_MPEG_LOCK_TIMEOUT 700
 #define DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT 500
 
@@ -659,7 +655,6 @@ static int init_state(struct drxk_state *state)
 	u32 ulGPIOCfg = 0x0113;
 	u32 ulInvertTSClock = 0;
 	u32 ulTSDataStrength = DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH;
-	u32 ulTSClockkStrength = DRXK_MPEG_OUTPUT_CLK_DRIVE_STRENGTH;
 	u32 ulDVBTBitrate = 50000000;
 	u32 ulDVBCBitrate = DRXK_QAM_SYMBOLRATE_MAX * 8;
 
@@ -820,7 +815,6 @@ static int init_state(struct drxk_state *state)
 	state->m_DVBCBitrate = ulDVBCBitrate;
 
 	state->m_TSDataStrength = (ulTSDataStrength & 0x07);
-	state->m_TSClockkStrength = (ulTSClockkStrength & 0x07);
 
 	/* Maximum bitrate in b/s in case static clockrate is selected */
 	state->m_mpegTsStaticBitrate = 19392658;
@@ -6394,6 +6388,12 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config,
 		state->m_DVBCStaticCLK = 1;
 	}
 
+
+	if (config->mpeg_out_clk_strength)
+		state->m_TSClockkStrength = config->mpeg_out_clk_strength & 0x07;
+	else
+		state->m_TSClockkStrength = 0x06;
+
 	if (config->parallel_ts)
 		state->m_enableParallel = true;
 	else
-- 
1.7.8


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

* [PATCH 26/35] [media] drxk: Allow enabling MERR/MVAL cfg
  2012-01-21 16:04                                                 ` [PATCH 25/35] [media] drxk: add support for Mpeg output clock drive strength config Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                   ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                     ` [PATCH 27/35] [media] az6007: code cleanups and fixes Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Those two settings are different when used with az6007. Add
a config option to enable it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c      |    1 +
 drivers/media/dvb/frontends/drxk.h      |    2 ++
 drivers/media/dvb/frontends/drxk_hard.c |   11 +++++++++--
 drivers/media/dvb/frontends/drxk_hard.h |    1 +
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index bf8d201..81fdc90 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -67,6 +67,7 @@ static struct drxk_config terratec_h7_drxk = {
 	.parallel_ts = true,
 	.dynamic_clk = true,
 	.single_master = true,
+	.enable_merr_cfg = true,
 	.no_i2c_bridge = false,
 	.chunk_size = 64,
 	.mpeg_out_clk_strength = 0x02,
diff --git a/drivers/media/dvb/frontends/drxk.h b/drivers/media/dvb/frontends/drxk.h
index ca921c7..9d64e4f 100644
--- a/drivers/media/dvb/frontends/drxk.h
+++ b/drivers/media/dvb/frontends/drxk.h
@@ -12,6 +12,7 @@
  * 			Serial otherwise.
  * @dynamic_clk:	True means that the clock will be dynamically
  *			adjusted. Static clock otherwise.
+ * @enable_merr_cfg:	Enable SIO_PDR_PERR_CFG/SIO_PDR_MVAL_CFG.
  * @single_master:	Device is on the single master mode
  * @no_i2c_bridge:	Don't switch the I2C bridge to talk with tuner
  * @antenna_gpio:	GPIO bit used to control the antenna
@@ -29,6 +30,7 @@ struct drxk_config {
 	bool	no_i2c_bridge;
 	bool	parallel_ts;
 	bool	dynamic_clk;
+	bool	enable_merr_cfg;
 
 	bool	antenna_dvbt;
 	u16	antenna_gpio;
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index d25b0d2..5fa1927 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -1179,6 +1179,7 @@ static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable)
 	int status = -1;
 	u16 sioPdrMclkCfg = 0;
 	u16 sioPdrMdxCfg = 0;
+	u16 err_cfg = 0;
 
 	dprintk(1, ": mpeg %s, %s mode\n",
 		mpegEnable ? "enable" : "disable",
@@ -1244,12 +1245,17 @@ static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable)
 		status = write16(state, SIO_PDR_MSTRT_CFG__A, sioPdrMdxCfg);
 		if (status < 0)
 			goto error;
-		status = write16(state, SIO_PDR_MERR_CFG__A, 0x0000);	/* Disable */
+
+		if (state->enable_merr_cfg)
+			err_cfg = sioPdrMdxCfg;
+
+		status = write16(state, SIO_PDR_MERR_CFG__A, err_cfg);
 		if (status < 0)
 			goto error;
-		status = write16(state, SIO_PDR_MVAL_CFG__A, 0x0000);	/* Disable */
+		status = write16(state, SIO_PDR_MVAL_CFG__A, err_cfg);
 		if (status < 0)
 			goto error;
+
 		if (state->m_enableParallel == true) {
 			/* paralel -> enable MD1 to MD7 */
 			status = write16(state, SIO_PDR_MD1_CFG__A, sioPdrMdxCfg);
@@ -6379,6 +6385,7 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config,
 	state->antenna_gpio = config->antenna_gpio;
 	state->antenna_dvbt = config->antenna_dvbt;
 	state->m_ChunkSize = config->chunk_size;
+	state->enable_merr_cfg = config->enable_merr_cfg;
 
 	if (config->dynamic_clk) {
 		state->m_DVBTStaticCLK = 0;
diff --git a/drivers/media/dvb/frontends/drxk_hard.h b/drivers/media/dvb/frontends/drxk_hard.h
index 3a58b73..4bbf841 100644
--- a/drivers/media/dvb/frontends/drxk_hard.h
+++ b/drivers/media/dvb/frontends/drxk_hard.h
@@ -332,6 +332,7 @@ struct drxk_state {
 
 	u16	UIO_mask;	/* Bits used by UIO */
 
+	bool	enable_merr_cfg;
 	bool	single_master;
 	bool	no_i2c_bridge;
 	bool	antenna_dvbt;
-- 
1.7.8


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

* [PATCH 27/35] [media] az6007: code cleanups and fixes
  2012-01-21 16:04                                                   ` [PATCH 26/35] [media] drxk: Allow enabling MERR/MVAL cfg Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                     ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                       ` [PATCH 28/35] [media] az6007: Driver cleanup Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Several changes were needed to make az6007 to work, producing
the same commands as the original driver. This patch does
that.

While here, be less verbose when debug is not enabled.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |  148 ++++++++++++++++++++----------------
 1 files changed, 83 insertions(+), 65 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 81fdc90..f0e4c01 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -54,12 +54,16 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 struct az6007_device_state {
 	struct			dvb_ca_en50221 ca;
 	struct			mutex ca_mutex;
-	u8			power_state;
+	unsigned		warm : 1;
 
 	/* Due to DRX-K - probably need changes */
 	int			(*gate_ctrl) (struct dvb_frontend *, int);
 	struct			semaphore pll_mutex;
 	bool			tuner_attached;
+
+	unsigned char		data[4096];
+
+	struct usb_data_stream *stream;
 };
 
 static struct drxk_config terratec_h7_drxk = {
@@ -71,7 +75,7 @@ static struct drxk_config terratec_h7_drxk = {
 	.no_i2c_bridge = false,
 	.chunk_size = 64,
 	.mpeg_out_clk_strength = 0x02,
-	.microcode_name = "dvb-usb-terratec-h7-az6007.fw",
+	.microcode_name = "dvb-usb-terratec-h7-drxk.fw",
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
@@ -162,7 +166,9 @@ static int az6007_write(struct usb_device *udev, u8 req, u16 value,
 
 static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 {
-	return 0;
+	deb_info("%s: %s", __func__, onoff ? "enable" : "disable");
+
+	return az6007_write(adap->dev->udev, 0xbc, onoff, 0, NULL, 0);
 }
 
 /* keys for the enclosed remote control */
@@ -236,46 +242,6 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 	return ret;
 }
 
-static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
-{
-	int ret;
-	struct usb_device *udev = adap->dev->udev;
-
-	deb_info("%s: adap=%p adap->dev=%p\n", __func__, adap, adap->dev);
-
-	ret = az6007_write(udev, AZ6007_POWER, 0, 2, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep(150);
-	ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep(100);
-	ret = az6007_write(udev, AZ6007_POWER, 1, 3, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep(100);
-	ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep(100);
-	ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep (10);
-	ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
-	if (ret < 0)
-		goto error;
-	msleep (10);
-	ret = az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
-
-error:
-	if (ret < 0)
-		err("%s failed with error %d", __func__, ret);
-
-	return ret;
-}
-
 static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
@@ -293,9 +259,8 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 
 	BUG_ON(!st);
 
-	az6007_frontend_poweron(adap);
+	deb_info("attaching demod drxk");
 
-	info("attaching demod drxk");
 	adap->fe_adap[0].fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
 					 &adap->dev->i2c_adap);
 	if (!adap->fe_adap[0].fe)
@@ -319,11 +284,11 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 
 	st->tuner_attached = true;
 
-	info("attaching tuner mt2063");
+	deb_info("attaching tuner mt2063");
 	/* Attach mt2063 to DVB-C frontend */
 	if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
 		adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 1);
-	if (!dvb_attach(mt2063_attach, adap->fe_adap[0].fe, 
+	if (!dvb_attach(mt2063_attach, adap->fe_adap[0].fe,
 			&az6007_mt2063_config,
 			&adap->dev->i2c_adap))
 		return -EINVAL;
@@ -336,22 +301,69 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
-	if (!onoff)
-		return 0;
+	struct az6007_device_state *st = d->priv;
+	struct usb_device *udev = d->udev;
+	int ret;
+
+	deb_info("%s()\n", __func__);
+
+	if (!st->warm) {
+		u8 data[6];
+
+		az6007_read(udev, FX2_OED, 1, 0, data, 1); /* {0x01} */
+		az6007_read(udev, AZ6007_READ_DATA, 0, 8160, data, 1); /* {0x20} */
+		az6007_read(udev, AZ6007_READ_DATA, 0, 0, data, 5); /* {0x00, 0x00, 0x00, 0x00, 0x0a} */
+		az6007_read(udev, AZ6007_READ_DATA, 0, 4080, data, 6); /* {0x00, 0x08, 0x00, 0x0c, 0x22, 0x38} */
+
+		ret = az6007_write(udev, AZ6007_POWER, 0, 2, NULL, 0);
+		if (ret < 0)
+			return ret;
+		msleep(60);
+		ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+		if (ret < 0)
+			return ret;
+		msleep(100);
+		ret = az6007_write(udev, AZ6007_POWER, 1, 3, NULL, 0);
+		if (ret < 0)
+			return ret;
+		msleep(20);
+		ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+		if (ret < 0)
+			return ret;
+
+		msleep(400);
+		ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
+		if (ret < 0)
+			return ret;
+		msleep (150);
+		ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
+		if (ret < 0)
+			return ret;
+		msleep (430);
+		ret = az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
+		if (ret < 0)
+			return ret;
 
+		st->warm = true;
 
-	info("Sending poweron sequence");
+		return 0;
+	}
 
-	az6007_write(d->udev, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
+	if (!onoff)
+		return 0;
+
+	az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
+	az6007_write(udev, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
 
 #if 0
 	// Seems to be a poweroff sequence
-	az6007_write(d->udev, 0xbc, 1, 3, NULL, 0);
-	az6007_write(d->udev, 0xbc, 1, 4, NULL, 0);
-	az6007_write(d->udev, 0xc0, 0, 3, NULL, 0);
-	az6007_write(d->udev, 0xc0, 1, 3, NULL, 0);
-	az6007_write(d->udev, 0xbc, 0, 1, NULL, 0);
+	az6007_write(udev, 0xbc, 1, 3, NULL, 0);
+	az6007_write(udev, 0xbc, 1, 4, NULL, 0);
+	az6007_write(udev, 0xc0, 0, 3, NULL, 0);
+	az6007_write(udev, 0xc0, 1, 3, NULL, 0);
+	az6007_write(udev, 0xbc, 0, 1, NULL, 0);
 #endif
+
 	return 0;
 }
 
@@ -367,13 +379,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			   int num)
 {
 	struct dvb_usb_device *d = i2c_get_adapdata(adap);
+	struct az6007_device_state *st = d->priv;
 	int i, j, len;
 	int ret = 0;
 	u16 index;
 	u16 value;
 	int length;
 	u8 req, addr;
-	u8 data[512];
 
 	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
 		return -EAGAIN;
@@ -399,11 +411,11 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
-			ret = az6007_read(d->udev, req, value, index, data,
+			ret = az6007_read(d->udev, req, value, index, st->data,
 					       length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
-					msgs[i + 1].buf[j] = data[j + 5];
+					msgs[i + 1].buf[j] = st->data[j + 5];
 					if (dvb_usb_az6007_debug & 2)
 						printk(KERN_CONT
 						       "0x%02x ",
@@ -426,11 +438,11 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			if (dvb_usb_az6007_debug & 2)
 				printk(KERN_CONT "(0x%02x) ", msgs[i].buf[0]);
 			for (j = 0; j < len; j++) {
-				data[j] = msgs[i].buf[j + 1];
+				st->data[j] = msgs[i].buf[j + 1];
 				if (dvb_usb_az6007_debug & 2)
-					printk(KERN_CONT "0x%02x ", data[j]);
+					printk(KERN_CONT "0x%02x ", st->data[j]);
 			}
-			ret =  az6007_write(d->udev, req, value, index, data,
+			ret =  az6007_write(d->udev, req, value, index, st->data,
 						 length);
 		} else {
 			/* read bytes */
@@ -443,13 +455,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr;
 			length = msgs[i].len + 6;
 			len = msgs[i].len;
-			ret = az6007_read(d->udev, req, value, index, data,
+			ret = az6007_read(d->udev, req, value, index, st->data,
 					       length);
 			for (j = 0; j < len; j++) {
-				msgs[i].buf[j] = data[j + 5];
+				msgs[i].buf[j] = st->data[j + 5];
 				if (dvb_usb_az6007_debug & 2)
 					printk(KERN_CONT
-					       "0x%02x ", data[j + 5]);
+					       "0x%02x ", st->data[j + 5]);
 			}
 		}
 		if (dvb_usb_az6007_debug & 2)
@@ -491,6 +503,12 @@ int az6007_identify_state(struct usb_device *udev,
 	else
 		*cold = 1;
 
+	if (*cold) {
+		az6007_write(udev, 0x09, 1, 0, NULL, 0);
+		az6007_write(udev, 0x00, 0, 0, NULL, 0);
+		az6007_write(udev, 0x00, 0, 0, NULL, 0);
+	}
+
 	deb_info("Device is on %s state\n", *cold? "warm" : "cold");
 	return 0;
 }
-- 
1.7.8


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

* [PATCH 28/35] [media] az6007: Driver cleanup
  2012-01-21 16:04                                                     ` [PATCH 27/35] [media] az6007: code cleanups and fixes Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                       ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                         ` [PATCH 29/35] [media] az6007: Protect read/write calls with a mutex Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Remove commented test code, remove unused poweroff stuff, and
fix the copyright data.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   56 ++++++++---------------------------
 1 files changed, 13 insertions(+), 43 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index f0e4c01..534d326 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -7,8 +7,9 @@
  *	http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
  * The original driver's license is GPL, as declared with MODULE_LICENSE()
  *
- *  Driver modifiyed by Mauro Carvalho Chehab <mchehab@redhat.com> in order
- * 	to work with upstream drxk driver, and to fix some bugs.
+ * Copyright (c) 2010-2011 Mauro Carvalho Chehab <mchehab@redhat.com>
+ *	Driver modified by in order to work with upstream drxk driver, and
+ *	tons of bugs got fixed.
  *
  * 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
@@ -58,7 +59,6 @@ struct az6007_device_state {
 
 	/* Due to DRX-K - probably need changes */
 	int			(*gate_ctrl) (struct dvb_frontend *, int);
-	struct			semaphore pll_mutex;
 	bool			tuner_attached;
 
 	unsigned char		data[4096];
@@ -94,17 +94,11 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 	if (!st)
 		return -EINVAL;
 
-	if (enable) {
-#if 0
-		down(&st->pll_mutex);
-#endif
+	if (enable)
 		status = st->gate_ctrl(fe, 1);
-	} else {
-#if 0
+	else
 		status = st->gate_ctrl(fe, 0);
-#endif
-		up(&st->pll_mutex);
-	}
+
 	return status;
 }
 
@@ -221,14 +215,6 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 	return 0;
 }
 
-#if 0
-int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
-	u8 v = onoff;
-	return az6007_write(d->udev, AZ6007_POWER, v , 3, NULL, 1);
-}
-#endif
-
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
 	int ret;
@@ -246,6 +232,7 @@ static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
 	int ret;
+
 	/* TS through */
 	ret = az6007_write(udev, AZ6007_POWER, onoff, 0, NULL, 0);
 	if (ret < 0)
@@ -257,8 +244,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	struct az6007_device_state *st = adap->dev->priv;
 
-	BUG_ON(!st);
-
 	deb_info("attaching demod drxk");
 
 	adap->fe_adap[0].fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
@@ -267,8 +252,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 		return -EINVAL;
 
 	adap->fe_adap[0].fe->sec_priv = adap;
-	/* FIXME: do we need a pll semaphore? */
-	sema_init(&st->pll_mutex, 1);
 	st->gate_ctrl = adap->fe_adap[0].fe->ops.i2c_gate_ctrl;
 	adap->fe_adap[0].fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
 
@@ -282,9 +265,8 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 	if (st->tuner_attached)
 		return 0;
 
-	st->tuner_attached = true;
-
 	deb_info("attaching tuner mt2063");
+
 	/* Attach mt2063 to DVB-C frontend */
 	if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
 		adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 1);
@@ -296,6 +278,8 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 	if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
 		adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 0);
 
+	st->tuner_attached = true;
+
 	return 0;
 }
 
@@ -355,25 +339,9 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 	az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
 	az6007_write(udev, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
 
-#if 0
-	// Seems to be a poweroff sequence
-	az6007_write(udev, 0xbc, 1, 3, NULL, 0);
-	az6007_write(udev, 0xbc, 1, 4, NULL, 0);
-	az6007_write(udev, 0xc0, 0, 3, NULL, 0);
-	az6007_write(udev, 0xc0, 1, 3, NULL, 0);
-	az6007_write(udev, 0xbc, 0, 1, NULL, 0);
-#endif
-
 	return 0;
 }
 
-static struct dvb_usb_device_properties az6007_properties;
-
-static void az6007_usb_disconnect(struct usb_interface *intf)
-{
-	dvb_usb_device_exit(intf);
-}
-
 /* I2C */
 static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			   int num)
@@ -513,6 +481,8 @@ int az6007_identify_state(struct usb_device *udev,
 	return 0;
 }
 
+static struct dvb_usb_device_properties az6007_properties;
+
 static int az6007_usb_probe(struct usb_interface *intf,
 			    const struct usb_device_id *id)
 {
@@ -589,7 +559,6 @@ static struct usb_driver az6007_usb_driver = {
 	.name		= "dvb_usb_az6007",
 	.probe		= az6007_usb_probe,
 	.disconnect = dvb_usb_device_exit,
-	/* .disconnect	= az6007_usb_disconnect, */
 	.id_table	= az6007_usb_table,
 };
 
@@ -619,6 +588,7 @@ module_init(az6007_usb_module_init);
 module_exit(az6007_usb_module_exit);
 
 MODULE_AUTHOR("Henry Wang <Henry.wang@AzureWave.com>");
+MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
 MODULE_DESCRIPTION("Driver for AzureWave 6007 DVB-C/T USB2.0 and clones");
 MODULE_VERSION("1.1");
 MODULE_LICENSE("GPL");
-- 
1.7.8


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

* [PATCH 29/35] [media] az6007: Protect read/write calls with a mutex
  2012-01-21 16:04                                                       ` [PATCH 28/35] [media] az6007: Driver cleanup Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                         ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                           ` [PATCH 30/35] [media] az6007: Be sure to use kmalloc'ed buffer for transfers Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

This will avoid interference with CI and IR I/O operations.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |  122 ++++++++++++++++++------------------
 1 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 534d326..6177332 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -53,17 +53,11 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 #define AZ6007_READ_IR		0xb4
 
 struct az6007_device_state {
-	struct			dvb_ca_en50221 ca;
-	struct			mutex ca_mutex;
-	unsigned		warm : 1;
-
-	/* Due to DRX-K - probably need changes */
+	struct mutex		mutex;
+	struct dvb_ca_en50221	ca;
+	unsigned		warm:1;
 	int			(*gate_ctrl) (struct dvb_frontend *, int);
-	bool			tuner_attached;
-
 	unsigned char		data[4096];
-
-	struct usb_data_stream *stream;
 };
 
 static struct drxk_config terratec_h7_drxk = {
@@ -107,8 +101,7 @@ static struct mt2063_config az6007_mt2063_config = {
 	.refclock = 36125000,
 };
 
-/* check for mutex FIXME */
-static int az6007_read(struct usb_device *udev, u8 req, u16 value,
+static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
 			    u16 index, u8 *b, int blen)
 {
 	int ret;
@@ -130,7 +123,23 @@ static int az6007_read(struct usb_device *udev, u8 req, u16 value,
 	return ret;
 }
 
-static int az6007_write(struct usb_device *udev, u8 req, u16 value,
+static int az6007_read(struct dvb_usb_device *d, u8 req, u16 value,
+			    u16 index, u8 *b, int blen)
+{
+	struct az6007_device_state *st = d->priv;
+	int ret;
+
+	if (mutex_lock_interruptible(&st->mutex) < 0)
+		return -EAGAIN;
+
+	ret = __az6007_read(d->udev, req, value, index, b, blen);
+
+	mutex_unlock(&st->mutex);
+
+	return ret;
+}
+
+static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
 			     u16 index, u8 *b, int blen)
 {
 	int ret;
@@ -158,11 +167,29 @@ static int az6007_write(struct usb_device *udev, u8 req, u16 value,
 	return 0;
 }
 
+static int az6007_write(struct dvb_usb_device *d, u8 req, u16 value,
+			    u16 index, u8 *b, int blen)
+{
+	struct az6007_device_state *st = d->priv;
+	int ret;
+
+	if (mutex_lock_interruptible(&st->mutex) < 0)
+		return -EAGAIN;
+
+	ret = __az6007_write(d->udev, req, value, index, b, blen);
+
+	mutex_unlock(&st->mutex);
+
+	return ret;
+}
+
 static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 {
+	struct dvb_usb_device *d = adap->dev;
+
 	deb_info("%s: %s", __func__, onoff ? "enable" : "disable");
 
-	return az6007_write(adap->dev->udev, 0xbc, onoff, 0, NULL, 0);
+	return az6007_write(d, 0xbc, onoff, 0, NULL, 0);
 }
 
 /* keys for the enclosed remote control */
@@ -185,7 +212,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 	 */
 	return 0;
 
-	az6007_read(d->udev, AZ6007_READ_IR, 0, 0, key, 10);
+	az6007_read(d, AZ6007_READ_IR, 0, 0, key, 10);
 
 	if (key[1] == 0x44) {
 		*state = REMOTE_NO_KEY_PRESSED;
@@ -218,7 +245,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
 	int ret;
-	ret = az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+	ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, mac, 6);
 
 	if (ret > 0)
 		deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -228,18 +255,6 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 	return ret;
 }
 
-static int az6007_led_on_off(struct usb_interface *intf, int onoff)
-{
-	struct usb_device *udev = interface_to_usbdev(intf);
-	int ret;
-
-	/* TS through */
-	ret = az6007_write(udev, AZ6007_POWER, onoff, 0, NULL, 0);
-	if (ret < 0)
-		err("%s failed with error %d", __func__, ret);
-	return ret;
-}
-
 static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	struct az6007_device_state *st = adap->dev->priv;
@@ -260,11 +275,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 
 static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 {
-	struct az6007_device_state *st = adap->dev->priv;
-
-	if (st->tuner_attached)
-		return 0;
-
 	deb_info("attaching tuner mt2063");
 
 	/* Attach mt2063 to DVB-C frontend */
@@ -278,53 +288,45 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 	if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
 		adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 0);
 
-	st->tuner_attached = true;
-
 	return 0;
 }
 
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
 	struct az6007_device_state *st = d->priv;
-	struct usb_device *udev = d->udev;
 	int ret;
 
 	deb_info("%s()\n", __func__);
 
 	if (!st->warm) {
-		u8 data[6];
+		mutex_init(&st->mutex);
 
-		az6007_read(udev, FX2_OED, 1, 0, data, 1); /* {0x01} */
-		az6007_read(udev, AZ6007_READ_DATA, 0, 8160, data, 1); /* {0x20} */
-		az6007_read(udev, AZ6007_READ_DATA, 0, 0, data, 5); /* {0x00, 0x00, 0x00, 0x00, 0x0a} */
-		az6007_read(udev, AZ6007_READ_DATA, 0, 4080, data, 6); /* {0x00, 0x08, 0x00, 0x0c, 0x22, 0x38} */
-
-		ret = az6007_write(udev, AZ6007_POWER, 0, 2, NULL, 0);
+		ret = az6007_write(d, AZ6007_POWER, 0, 2, NULL, 0);
 		if (ret < 0)
 			return ret;
 		msleep(60);
-		ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+		ret = az6007_write(d, AZ6007_POWER, 1, 4, NULL, 0);
 		if (ret < 0)
 			return ret;
 		msleep(100);
-		ret = az6007_write(udev, AZ6007_POWER, 1, 3, NULL, 0);
+		ret = az6007_write(d, AZ6007_POWER, 1, 3, NULL, 0);
 		if (ret < 0)
 			return ret;
 		msleep(20);
-		ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+		ret = az6007_write(d, AZ6007_POWER, 1, 4, NULL, 0);
 		if (ret < 0)
 			return ret;
 
 		msleep(400);
-		ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
+		ret = az6007_write(d, FX2_SCON1, 0, 3, NULL, 0);
 		if (ret < 0)
 			return ret;
 		msleep (150);
-		ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
+		ret = az6007_write(d, FX2_SCON1, 1, 3, NULL, 0);
 		if (ret < 0)
 			return ret;
 		msleep (430);
-		ret = az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
+		ret = az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
 		if (ret < 0)
 			return ret;
 
@@ -336,8 +338,8 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 	if (!onoff)
 		return 0;
 
-	az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
-	az6007_write(udev, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
+	az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
+	az6007_write(d, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
 
 	return 0;
 }
@@ -355,7 +357,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 	int length;
 	u8 req, addr;
 
-	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+	if (mutex_lock_interruptible(&st->mutex) < 0)
 		return -EAGAIN;
 
 	for (i = 0; i < num; i++) {
@@ -379,7 +381,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
-			ret = az6007_read(d->udev, req, value, index, st->data,
+			ret = __az6007_read(d->udev, req, value, index, st->data,
 					       length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
@@ -410,7 +412,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 				if (dvb_usb_az6007_debug & 2)
 					printk(KERN_CONT "0x%02x ", st->data[j]);
 			}
-			ret =  az6007_write(d->udev, req, value, index, st->data,
+			ret =  __az6007_write(d->udev, req, value, index, st->data,
 						 length);
 		} else {
 			/* read bytes */
@@ -423,7 +425,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr;
 			length = msgs[i].len + 6;
 			len = msgs[i].len;
-			ret = az6007_read(d->udev, req, value, index, st->data,
+			ret = __az6007_read(d->udev, req, value, index, st->data,
 					       length);
 			for (j = 0; j < len; j++) {
 				msgs[i].buf[j] = st->data[j + 5];
@@ -438,7 +440,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			goto err;
 	}
 err:
-	mutex_unlock(&d->i2c_mutex);
+	mutex_unlock(&st->mutex);
 
 	if (ret < 0) {
 		info("%s ERROR: %i", __func__, ret);
@@ -465,16 +467,16 @@ int az6007_identify_state(struct usb_device *udev,
 	u8 mac[6];
 
 	/* Try to read the mac address */
-	ret = az6007_read(udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+	ret = __az6007_read(udev, AZ6007_READ_DATA, 6, 0, mac, 6);
 	if (ret == 6)
 		*cold = 0;
 	else
 		*cold = 1;
 
 	if (*cold) {
-		az6007_write(udev, 0x09, 1, 0, NULL, 0);
-		az6007_write(udev, 0x00, 0, 0, NULL, 0);
-		az6007_write(udev, 0x00, 0, 0, NULL, 0);
+		__az6007_write(udev, 0x09, 1, 0, NULL, 0);
+		__az6007_write(udev, 0x00, 0, 0, NULL, 0);
+		__az6007_write(udev, 0x00, 0, 0, NULL, 0);
 	}
 
 	deb_info("Device is on %s state\n", *cold? "warm" : "cold");
@@ -486,7 +488,7 @@ static struct dvb_usb_device_properties az6007_properties;
 static int az6007_usb_probe(struct usb_interface *intf,
 			    const struct usb_device_id *id)
 {
-	az6007_led_on_off(intf, 0);
+	struct usb_device *udev = interface_to_usbdev(intf);
 
 	return dvb_usb_device_init(intf, &az6007_properties,
 				   THIS_MODULE, NULL, adapter_nr);
-- 
1.7.8


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

* [PATCH 30/35] [media] az6007: Be sure to use kmalloc'ed buffer for transfers
  2012-01-21 16:04                                                         ` [PATCH 29/35] [media] az6007: Protect read/write calls with a mutex Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                           ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                             ` [PATCH 31/35] [media] az6007: Fix IR handling Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

USB data transfers may not work if the buffer is allocated at
the stack. Be sure to use kmalloc on all places where a buffer
is needed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 6177332..142ef7b 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -201,8 +201,8 @@ static struct rc_map_table rc_map_az6007_table[] = {
 /* remote control stuff (does not work with my box) */
 static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 {
+	struct az6007_device_state *st = d->priv;
 	struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
-	u8 key[10];
 	int i;
 
 	/*
@@ -212,9 +212,9 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 	 */
 	return 0;
 
-	az6007_read(d, AZ6007_READ_IR, 0, 0, key, 10);
+	az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
 
-	if (key[1] == 0x44) {
+	if (st->data[1] == 0x44) {
 		*state = REMOTE_NO_KEY_PRESSED;
 		return 0;
 	}
@@ -228,11 +228,11 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 	 * 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR)
 	 * I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity
 	 */
-	deb_rc("remote query key: %x %d\n", key[1], key[1]);
-	print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, key, 10);
+	deb_rc("remote query key: %x %d\n", st->data[1], st->data[1]);
+	print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, st->data, 10);
 
 	for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
-		if (rc5_custom(&keymap[i]) == key[1]) {
+		if (rc5_custom(&keymap[i]) == st->data[1]) {
 			*event = keymap[i].keycode;
 			*state = REMOTE_KEY_PRESSED;
 
@@ -244,8 +244,11 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
+	struct az6007_device_state *st = d->priv;
 	int ret;
-	ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, mac, 6);
+
+	ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, st->data, 6);
+	memcpy(mac, st->data, sizeof(mac));
 
 	if (ret > 0)
 		deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -464,7 +467,11 @@ int az6007_identify_state(struct usb_device *udev,
 			  struct dvb_usb_device_description **desc, int *cold)
 {
 	int ret;
-	u8 mac[6];
+	u8 *mac;
+
+	mac = kmalloc(6, GFP_ATOMIC);
+	if (!mac)
+		return -ENOMEM;
 
 	/* Try to read the mac address */
 	ret = __az6007_read(udev, AZ6007_READ_DATA, 6, 0, mac, 6);
@@ -473,6 +480,8 @@ int az6007_identify_state(struct usb_device *udev,
 	else
 		*cold = 1;
 
+	kfree(mac);
+
 	if (*cold) {
 		__az6007_write(udev, 0x09, 1, 0, NULL, 0);
 		__az6007_write(udev, 0x00, 0, 0, NULL, 0);
@@ -488,8 +497,6 @@ static struct dvb_usb_device_properties az6007_properties;
 static int az6007_usb_probe(struct usb_interface *intf,
 			    const struct usb_device_id *id)
 {
-	struct usb_device *udev = interface_to_usbdev(intf);
-
 	return dvb_usb_device_init(intf, &az6007_properties,
 				   THIS_MODULE, NULL, adapter_nr);
 }
-- 
1.7.8


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

* [PATCH 31/35] [media] az6007: Fix IR handling
  2012-01-21 16:04                                                           ` [PATCH 30/35] [media] az6007: Be sure to use kmalloc'ed buffer for transfers Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                             ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                               ` [PATCH 32/35] [media] az6007: Convert IR to use the rc_core logic Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 142ef7b..a8aedb8 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -204,13 +204,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 	struct az6007_device_state *st = d->priv;
 	struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
 	int i;
-
-	/*
-	 * FIXME: remove the following return to enabled remote querying
-	 * The driver likely needs proper locking to avoid troubles between
-	 * this call and other concurrent calls.
-	 */
-	return 0;
+	unsigned code = 0;
 
 	az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
 
@@ -219,20 +213,21 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 		return 0;
 	}
 
-	/*
-	 * FIXME: need to make something useful with the keycodes and to
-	 * convert it to the non-legacy mode. Yet, it is producing some
-	 * debug info already, like:
-	 * 88 04 eb 02 fd ff 00 82 63 82 (terratec IR)
-	 * 88 04 eb 03 fc 00 00 82 63 82 (terratec IR)
-	 * 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR)
-	 * I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity
-	 */
-	deb_rc("remote query key: %x %d\n", st->data[1], st->data[1]);
+	if ((st->data[1] ^ st->data[2]) == 0xff)
+		code = st->data[1];
+	else
+		code = st->data[1] << 8 | st->data[2];
+
+	if ((st->data[3] ^ st->data[4]) == 0xff)
+		code = code << 8 | st->data[3];
+	else
+		code = code << 16 | st->data[3] << 8| st->data[4];
+
+	printk("remote query key: %04x\n", code);
 	print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, st->data, 10);
 
 	for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
-		if (rc5_custom(&keymap[i]) == st->data[1]) {
+		if (rc5_custom(&keymap[i]) == code) {
 			*event = keymap[i].keycode;
 			*state = REMOTE_KEY_PRESSED;
 
-- 
1.7.8


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

* [PATCH 32/35] [media] az6007: Convert IR to use the rc_core logic
  2012-01-21 16:04                                                             ` [PATCH 31/35] [media] az6007: Fix IR handling Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                               ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                                 ` [PATCH 33/35] [media] az6007: Use the right keycode for Terratec H7 Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   30 +++++++-----------------------
 1 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index a8aedb8..2288916 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -192,26 +192,16 @@ static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 	return az6007_write(d, 0xbc, onoff, 0, NULL, 0);
 }
 
-/* keys for the enclosed remote control */
-static struct rc_map_table rc_map_az6007_table[] = {
-	{0x0001, KEY_1},
-	{0x0002, KEY_2},
-};
-
 /* remote control stuff (does not work with my box) */
-static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
+static int az6007_rc_query(struct dvb_usb_device *d)
 {
 	struct az6007_device_state *st = d->priv;
-	struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
-	int i;
 	unsigned code = 0;
 
 	az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
 
-	if (st->data[1] == 0x44) {
-		*state = REMOTE_NO_KEY_PRESSED;
+	if (st->data[1] == 0x44)
 		return 0;
-	}
 
 	if ((st->data[1] ^ st->data[2]) == 0xff)
 		code = st->data[1];
@@ -224,16 +214,9 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 		code = code << 16 | st->data[3] << 8| st->data[4];
 
 	printk("remote query key: %04x\n", code);
-	print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, st->data, 10);
 
-	for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
-		if (rc5_custom(&keymap[i]) == code) {
-			*event = keymap[i].keycode;
-			*state = REMOTE_KEY_PRESSED;
+	rc_keydown(d->rc_dev, code, st->data[5]);
 
-			return 0;
-		}
-	}
 	return 0;
 }
 
@@ -536,11 +519,12 @@ static struct dvb_usb_device_properties az6007_properties = {
 	.power_ctrl       = az6007_power_ctrl,
 	.read_mac_address = az6007_read_mac_addr,
 
-	.rc.legacy = {
-		.rc_map_table  = rc_map_az6007_table,
-		.rc_map_size  = ARRAY_SIZE(rc_map_az6007_table),
+	.rc.core = {
 		.rc_interval      = 400,
+		.rc_codes         = RC_MAP_DIB0700_NEC_TABLE,
+		.module_name	  = "az6007",
 		.rc_query         = az6007_rc_query,
+		.allowed_protos   = RC_TYPE_NEC,
 	},
 	.i2c_algo         = &az6007_i2c_algo,
 
-- 
1.7.8


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

* [PATCH 33/35] [media] az6007: Use the right keycode for Terratec H7
  2012-01-21 16:04                                                               ` [PATCH 32/35] [media] az6007: Convert IR to use the rc_core logic Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                                 ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                                   ` [PATCH 34/35] [media] az6007: Enable the driver at the building system Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Instead of using a fake keycode, just for testing, use the
right one, for Terratec H7.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c                 |    2 +-
 .../media/rc/keymaps/rc-nec-terratec-cinergy-xs.c  |   52 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 2288916..14733b8 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -521,7 +521,7 @@ static struct dvb_usb_device_properties az6007_properties = {
 
 	.rc.core = {
 		.rc_interval      = 400,
-		.rc_codes         = RC_MAP_DIB0700_NEC_TABLE,
+		.rc_codes         = RC_MAP_NEC_TERRATEC_CINERGY_XS,
 		.module_name	  = "az6007",
 		.rc_query         = az6007_rc_query,
 		.allowed_protos   = RC_TYPE_NEC,
diff --git a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
index f3b86c8..8d4dae2 100644
--- a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
+++ b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
@@ -18,6 +18,8 @@
  */
 
 static struct rc_map_table nec_terratec_cinergy_xs[] = {
+
+	/* Terratec Grey IR, with most keys in orange */
 	{ 0x1441, KEY_HOME},
 	{ 0x1401, KEY_POWER2},
 
@@ -78,6 +80,56 @@ static struct rc_map_table nec_terratec_cinergy_xs[] = {
 	{ 0x144e, KEY_REWIND},
 	{ 0x144f, KEY_FASTFORWARD},
 	{ 0x145c, KEY_NEXT},
+
+	/* Terratec Black IR, with most keys in black */
+	{ 0x04eb01, KEY_POWER2},
+
+	{ 0x04eb02, KEY_1},
+	{ 0x04eb03, KEY_2},
+	{ 0x04eb04, KEY_3},
+	{ 0x04eb05, KEY_4},
+	{ 0x04eb06, KEY_5},
+	{ 0x04eb07, KEY_6},
+	{ 0x04eb08, KEY_7},
+	{ 0x04eb09, KEY_8},
+	{ 0x04eb0a, KEY_9},
+	{ 0x04eb0c, KEY_0},
+
+	{ 0x04eb0b, KEY_TEXT},		/* TXT */
+	{ 0x04eb0d, KEY_REFRESH},	/* Refresh */
+
+	{ 0x04eb0e, KEY_HOME},
+	{ 0x04eb0f, KEY_EPG},
+
+	{ 0x04eb10, KEY_UP},
+	{ 0x04eb11, KEY_LEFT},
+	{ 0x04eb12, KEY_OK},
+	{ 0x04eb13, KEY_RIGHT},
+	{ 0x04eb14, KEY_DOWN},
+
+	{ 0x04eb15, KEY_BACKSPACE},
+	{ 0x04eb16, KEY_INFO},
+
+	{ 0x04eb17, KEY_RED},
+	{ 0x04eb18, KEY_GREEN},
+	{ 0x04eb19, KEY_YELLOW},
+	{ 0x04eb1a, KEY_BLUE},
+
+	{ 0x04eb1c, KEY_VOLUMEUP},
+	{ 0x04eb1e, KEY_VOLUMEDOWN},
+
+	{ 0x04eb1d, KEY_MUTE},
+
+	{ 0x04eb1b, KEY_CHANNELUP},
+	{ 0x04eb1f, KEY_CHANNELDOWN},
+
+	{ 0x04eb40, KEY_RECORD},
+	{ 0x04eb4c, KEY_PLAY},
+	{ 0x04eb58, KEY_PAUSE},
+
+	{ 0x04eb54, KEY_REWIND},
+	{ 0x04eb48, KEY_STOP},
+	{ 0x04eb5c, KEY_NEXT},
 };
 
 static struct rc_map_list nec_terratec_cinergy_xs_map = {
-- 
1.7.8


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

* [PATCH 34/35] [media] az6007: Enable the driver at the building system
  2012-01-21 16:04                                                                 ` [PATCH 33/35] [media] az6007: Use the right keycode for Terratec H7 Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                                   ` Mauro Carvalho Chehab
  2012-01-21 16:04                                                                     ` [PATCH 35/35] [media] az6007: CodingStyle fixes Mauro Carvalho Chehab
  0 siblings, 1 reply; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Add the corresponding entries to allow building this driver.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/Kconfig  |    8 ++++++++
 drivers/media/dvb/dvb-usb/Makefile |    4 +++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 9f203c6..e894bad 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -361,6 +361,14 @@ config DVB_USB_EC168
 	help
 	  Say Y here to support the E3C EC168 DVB-T USB2.0 receiver.
 
+config DVB_USB_AZ6007
+	tristate "AzureWave 6007 and clones DVB-T/C USB2.0 support"
+	depends on DVB_USB
+	select DVB_DRXK if !DVB_FE_CUSTOMISE
+	select MEDIA_TUNER_MT2063 if !DVB_FE_CUSTOMISE
+	help
+	  Say Y here to support theAfatech AF9005 based DVB-T/DVB-C receivers.
+
 config DVB_USB_AZ6027
 	tristate "Azurewave DVB-S/S2 USB2.0 AZ6027 support"
 	depends on DVB_USB
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 26c8b9e..d9549cb 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -54,7 +54,6 @@ obj-$(CONFIG_DVB_USB_DIB0700) += dvb-usb-dib0700.o
 dvb-usb-opera-objs = opera1.o
 obj-$(CONFIG_DVB_USB_OPERA1) += dvb-usb-opera.o
 
-
 dvb-usb-af9005-objs = af9005.o af9005-fe.o
 obj-$(CONFIG_DVB_USB_AF9005) += dvb-usb-af9005.o
 
@@ -88,6 +87,9 @@ obj-$(CONFIG_DVB_USB_FRIIO) += dvb-usb-friio.o
 dvb-usb-ec168-objs = ec168.o
 obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o
 
+dvb-usb-az6007-objs = az6007.o
+obj-$(CONFIG_DVB_USB_AZ6007) += dvb-usb-az6007.o
+
 dvb-usb-az6027-objs = az6027.o
 obj-$(CONFIG_DVB_USB_AZ6027) += dvb-usb-az6027.o
 
-- 
1.7.8


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

* [PATCH 35/35] [media] az6007: CodingStyle fixes
  2012-01-21 16:04                                                                   ` [PATCH 34/35] [media] az6007: Enable the driver at the building system Mauro Carvalho Chehab
@ 2012-01-21 16:04                                                                     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 44+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-21 16:04 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-usb/az6007.c |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
index 14733b8..02efd94 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -211,9 +211,7 @@ static int az6007_rc_query(struct dvb_usb_device *d)
 	if ((st->data[3] ^ st->data[4]) == 0xff)
 		code = code << 8 | st->data[3];
 	else
-		code = code << 16 | st->data[3] << 8| st->data[4];
-
-	printk("remote query key: %04x\n", code);
+		code = code << 16 | st->data[3] << 8 | st->data[4];
 
 	rc_keydown(d->rc_dev, code, st->data[5]);
 
@@ -302,11 +300,11 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 		ret = az6007_write(d, FX2_SCON1, 0, 3, NULL, 0);
 		if (ret < 0)
 			return ret;
-		msleep (150);
+		msleep(150);
 		ret = az6007_write(d, FX2_SCON1, 1, 3, NULL, 0);
 		if (ret < 0)
 			return ret;
-		msleep (430);
+		msleep(430);
 		ret = az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
 		if (ret < 0)
 			return ret;
@@ -362,8 +360,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr | (1 << 8);
 			length = 6 + msgs[i + 1].len;
 			len = msgs[i + 1].len;
-			ret = __az6007_read(d->udev, req, value, index, st->data,
-					       length);
+			ret = __az6007_read(d->udev, req, value, index,
+					    st->data, length);
 			if (ret >= len) {
 				for (j = 0; j < len; j++) {
 					msgs[i + 1].buf[j] = st->data[j + 5];
@@ -391,10 +389,11 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			for (j = 0; j < len; j++) {
 				st->data[j] = msgs[i].buf[j + 1];
 				if (dvb_usb_az6007_debug & 2)
-					printk(KERN_CONT "0x%02x ", st->data[j]);
+					printk(KERN_CONT "0x%02x ",
+					       st->data[j]);
 			}
-			ret =  __az6007_write(d->udev, req, value, index, st->data,
-						 length);
+			ret =  __az6007_write(d->udev, req, value, index,
+					      st->data, length);
 		} else {
 			/* read bytes */
 			if (dvb_usb_az6007_debug & 2)
@@ -406,8 +405,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 			value = addr;
 			length = msgs[i].len + 6;
 			len = msgs[i].len;
-			ret = __az6007_read(d->udev, req, value, index, st->data,
-					       length);
+			ret = __az6007_read(d->udev, req, value, index,
+					    st->data, length);
 			for (j = 0; j < len; j++) {
 				msgs[i].buf[j] = st->data[j + 5];
 				if (dvb_usb_az6007_debug & 2)
@@ -466,7 +465,7 @@ int az6007_identify_state(struct usb_device *udev,
 		__az6007_write(udev, 0x00, 0, 0, NULL, 0);
 	}
 
-	deb_info("Device is on %s state\n", *cold? "warm" : "cold");
+	deb_info("Device is on %s state\n", *cold ? "warm" : "cold");
 	return 0;
 }
 
@@ -514,7 +513,7 @@ static struct dvb_usb_device_properties az6007_properties = {
 					}
 				}
 			},
-		}}
+		} }
 	} },
 	.power_ctrl       = az6007_power_ctrl,
 	.read_mac_address = az6007_read_mac_addr,
-- 
1.7.8


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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-01-21 16:04 [PATCH 00/35] Add a driver for Terratec H7 Mauro Carvalho Chehab
  2012-01-21 16:04 ` [PATCH 01/35] [media] dvb: Add a new driver for az6007 Mauro Carvalho Chehab
@ 2012-01-29 21:18 ` Roger Mårtensson
  2012-02-08 21:32 ` Torfinn Ingolfsen
  2012-02-16 18:43 ` Roger Mårtensson
  3 siblings, 0 replies; 44+ messages in thread
From: Roger Mårtensson @ 2012-01-29 21:18 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

Mauro Carvalho Chehab skrev 2012-01-21 17:04:
> Terratec H7 is a Cypress FX2 device with a mt2063 tuner and a drx-k
> demod. This series add support for it. It started with a public
> tree found at:
> 	 http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz

I hope this driver is for the device found here: 
http://www.terratec.net/en/products/TERRATEC_H7_91101.html?premium=1
I'm in need of a CI-capable device that I can use in my DVB-C network 
since my current device seems to have serious problems with the CAM-card 
installed.

Do you have access to a DVB-C with encrypted channels or do you know if 
someone is testing this driver in such environment?
Otherwise I'm thinking of buying this device. Is the driver available in 
the media_build bundle?

I can probably test DVB-T with encrypted channels too if needed but it's 
nothing I have at the moment but can possible invest in.

PS.
The device I have problems with is named like this with lspci. The 
problems starts when I insert the CAM-card. dmesg says it's inserted but 
the stream sometimes starts out ok but within a minute I see artifacts 
and it becomes worse after that. Without card inserted the free channels 
works like a charm.  That's why I'm interested to switch to this device.
08:01.0 Multimedia controller: Philips Semiconductors SAA7146 (rev 01)
         Subsystem: KNC One Device 0028

/Yours,
Roger.M

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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-01-21 16:04 [PATCH 00/35] Add a driver for Terratec H7 Mauro Carvalho Chehab
  2012-01-21 16:04 ` [PATCH 01/35] [media] dvb: Add a new driver for az6007 Mauro Carvalho Chehab
  2012-01-29 21:18 ` [PATCH 00/35] Add a driver for Terratec H7 Roger Mårtensson
@ 2012-02-08 21:32 ` Torfinn Ingolfsen
  2012-02-08 23:04   ` Torfinn Ingolfsen
  2012-02-16 18:43 ` Roger Mårtensson
  3 siblings, 1 reply; 44+ messages in thread
From: Torfinn Ingolfsen @ 2012-02-08 21:32 UTC (permalink / raw)
  To: linux-media

Hello,

On Sat, Jan 21, 2012 at 5:04 PM, Mauro Carvalho Chehab
<mchehab@redhat.com> wrote:
>
> Terratec H7 is a Cypress FX2 device with a mt2063 tuner and a drx-k
> demod. This series add support for it. It started with a public
> tree found at:
>         http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
>
> The driver were almost completely re-written, and it is now working,
> at least with DVB-C. I don't have a DVB-T signal here for testing,
> but I suspect it should also work fine.
>
> The FX2 firmware has a NEC IR decoder. The driver has support for
> it. The default keytable has support for the black Terratec IR
> and for the grey IR with orange keys.
>

Do I need to do anything special to make this driver work?
I just installed the newest media drivers (by following instructions at
http://git.linuxtv.org/media_build.git) on a maxhine running Xubuntu 11.10:
tingo@kg-f4:~/work/media_
build$ uname -a
Linux kg-f4 3.0.0-15-generic #26-Ubuntu SMP Fri Jan 20 17:23:00 UTC
2012 x86_64 x86_64 x86_64 GNU/Linux

This machine has a TerraTec H7 connected, lsusb shows:
tingo@kg-f4:~/work/media_build$ sudo lsusb  -s 1:6
Bus 001 Device 006: ID 0ccd:10a3 TerraTec Electronic GmbH

But after installing the drivers, and after a reboot of the machine,
the dvb-usb-az6007 driver doesn't load.
If I manually do 'sudo modprobe dvb-usb-az6007', the driver loads, but
all I get in dmesg is this:
[ 1049.838911] WARNING: You are using an experimental version of the
media stack.
[ 1049.838917]  As the driver is backported to an older kernel, it doesn't offer
[ 1049.838922]  enough quality for its usage in production.
[ 1049.838925]  Use it with care.
[ 1049.838928] Latest git patches (needed if you report a bug to
linux-media@vger.kernel.org):
[ 1049.838932]  59b30294e14fa6a370fdd2bc2921cca1f977ef16 Merge branch
'v4l_for_linus' into staging/for_v3.4
[ 1049.838936]  72565224609a23a60d10fcdf42f87a2fa8f7b16d [media]
cxd2820r: sleep on DVB-T/T2 delivery system switch
[ 1049.838941]  46de20a78ae4b122b79fc02633e9a6c3d539ecad [media]
anysee: fix CI init
[ 1049.857524] IR NEC protocol handler initialized
[ 1049.892787] usbcore: registered new interface driver dvb_usb_az6007
[ 1049.905264] IR RC5(x) protocol handler initialized
[ 1049.919476] IR RC6 protocol handler initialized
[ 1049.929152] IR JVC protocol handler initialized
[ 1049.943103] IR Sony protocol handler initialized
[ 1049.956308] IR SANYO protocol handler initialized
[ 1049.966667] IR MCE Keyboard/mouse protocol handler initialized
[ 1049.989256] lirc_dev: IR Remote Control driver registered, major 250
[ 1050.003618] IR LIRC bridge handler initialized
[ 1445.609008] usb 1-2: USB disconnect, device number 5
[ 1449.944046] usb 1-2: new high speed USB device number 6 using ehci_hcd

and there aren't anything created in /dev/dvb.

What am I doing wrong?
--
Regards,
Torfinn Ingolfsen

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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-02-08 21:32 ` Torfinn Ingolfsen
@ 2012-02-08 23:04   ` Torfinn Ingolfsen
  2012-02-09 21:12     ` Torfinn Ingolfsen
  0 siblings, 1 reply; 44+ messages in thread
From: Torfinn Ingolfsen @ 2012-02-08 23:04 UTC (permalink / raw)
  To: linux-media

On Wed, Feb 8, 2012 at 10:32 PM, Torfinn Ingolfsen <tingox@gmail.com> wrote:
> Do I need to do anything special to make this driver work?
> I just installed the newest media drivers (by following instructions at
> http://git.linuxtv.org/media_build.git) on a maxhine running Xubuntu 11.10:
> tingo@kg-f4:~/work/media_
> build$ uname -a
> Linux kg-f4 3.0.0-15-generic #26-Ubuntu SMP Fri Jan 20 17:23:00 UTC
> 2012 x86_64 x86_64 x86_64 GNU/Linux
>
> This machine has a TerraTec H7 connected, lsusb shows:
> tingo@kg-f4:~/work/media_build$ sudo lsusb  -s 1:6
> Bus 001 Device 006: ID 0ccd:10a3 TerraTec Electronic GmbH
>
> But after installing the drivers, and after a reboot of the machine,
> the dvb-usb-az6007 driver doesn't load.
> If I manually do 'sudo modprobe dvb-usb-az6007', the driver loads, but
> all I get in dmesg is this:
> [ 1049.838911] WARNING: You are using an experimental version of the
> media stack.
> [ 1049.838917]  As the driver is backported to an older kernel, it doesn't offer
> [ 1049.838922]  enough quality for its usage in production.
> [ 1049.838925]  Use it with care.
> [ 1049.838928] Latest git patches (needed if you report a bug to
> linux-media@vger.kernel.org):
> [ 1049.838932]  59b30294e14fa6a370fdd2bc2921cca1f977ef16 Merge branch
> 'v4l_for_linus' into staging/for_v3.4
> [ 1049.838936]  72565224609a23a60d10fcdf42f87a2fa8f7b16d [media]
> cxd2820r: sleep on DVB-T/T2 delivery system switch
> [ 1049.838941]  46de20a78ae4b122b79fc02633e9a6c3d539ecad [media]
> anysee: fix CI init
> [ 1049.857524] IR NEC protocol handler initialized
> [ 1049.892787] usbcore: registered new interface driver dvb_usb_az6007
> [ 1049.905264] IR RC5(x) protocol handler initialized
> [ 1049.919476] IR RC6 protocol handler initialized
> [ 1049.929152] IR JVC protocol handler initialized
> [ 1049.943103] IR Sony protocol handler initialized
> [ 1049.956308] IR SANYO protocol handler initialized
> [ 1049.966667] IR MCE Keyboard/mouse protocol handler initialized
> [ 1049.989256] lirc_dev: IR Remote Control driver registered, major 250
> [ 1050.003618] IR LIRC bridge handler initialized
> [ 1445.609008] usb 1-2: USB disconnect, device number 5
> [ 1449.944046] usb 1-2: new high speed USB device number 6 using ehci_hcd
>
> and there aren't anything created in /dev/dvb.
>
> What am I doing wrong?

Never mind. after adding this patch:
http://patchwork.linuxtv.org/patch/9691/

and rebuilding the media drivers, the device is now detected:
tingo@kg-f4:~$ dmesg | grep -i terratec
[   19.755806] dvb-usb: found a 'TerraTec DTV StarBox DVB-T/C USB2.0
(az6007)' in warm state.
[   20.949045] DVB: registering new adapter (TerraTec DTV StarBox
DVB-T/C USB2.0 (az6007))
[   23.732039] Registered IR keymap rc-nec-terratec-cinergy-xs
[   23.732442] dvb-usb: TerraTec DTV StarBox DVB-T/C USB2.0 (az6007)
successfully initialized and connected.


-- 
Regards,
Torfinn Ingolfsen

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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-02-08 23:04   ` Torfinn Ingolfsen
@ 2012-02-09 21:12     ` Torfinn Ingolfsen
  2012-02-10 15:57       ` Jason Krolo
  2012-02-14 19:38       ` Torfinn Ingolfsen
  0 siblings, 2 replies; 44+ messages in thread
From: Torfinn Ingolfsen @ 2012-02-09 21:12 UTC (permalink / raw)
  To: linux-media

Update:

On Thu, Feb 9, 2012 at 12:04 AM, Torfinn Ingolfsen <tingox@gmail.com> wrote:
> Never mind. after adding this patch:
> http://patchwork.linuxtv.org/patch/9691/
>
> and rebuilding the media drivers, the device is now detected:
> tingo@kg-f4:~$ dmesg | grep -i terratec
> [   19.755806] dvb-usb: found a 'TerraTec DTV StarBox DVB-T/C USB2.0
> (az6007)' in warm state.
> [   20.949045] DVB: registering new adapter (TerraTec DTV StarBox
> DVB-T/C USB2.0 (az6007))
> [   23.732039] Registered IR keymap rc-nec-terratec-cinergy-xs
> [   23.732442] dvb-usb: TerraTec DTV StarBox DVB-T/C USB2.0 (az6007)
> successfully initialized and connected.

I have now tested the TerraTec H7, both with w_scan and with Kaffeine.
Neither of then is able to find any channels from the H7. (The device
is connected to an external power supply). However, if I connect
another device (a PCTV nanoStick T2 290e) to the same cable, both
w_scan and Kaffeine find all the channels for my provider, and I can
watch the clear (unencrypted) ones in Kaffeine.

How can I debug the H7 further?
-- 
Regards,
Torfinn Ingolfsen

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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-02-09 21:12     ` Torfinn Ingolfsen
@ 2012-02-10 15:57       ` Jason Krolo
  2012-02-13 16:11         ` Eddi De Pieri
  2012-02-14 19:38       ` Torfinn Ingolfsen
  1 sibling, 1 reply; 44+ messages in thread
From: Jason Krolo @ 2012-02-10 15:57 UTC (permalink / raw)
  To: linux-media

Am 09.02.2012 22:12, schrieb Torfinn Ingolfsen:
> Update:
>
> On Thu, Feb 9, 2012 at 12:04 AM, Torfinn Ingolfsen<tingox@gmail.com>  wrote:
>> Never mind. after adding this patch:
>> http://patchwork.linuxtv.org/patch/9691/
>>
>> and rebuilding the media drivers, the device is now detected:
>> tingo@kg-f4:~$ dmesg | grep -i terratec
>> [   19.755806] dvb-usb: found a 'TerraTec DTV StarBox DVB-T/C USB2.0
>> (az6007)' in warm state.
>> [   20.949045] DVB: registering new adapter (TerraTec DTV StarBox
>> DVB-T/C USB2.0 (az6007))
>> [   23.732039] Registered IR keymap rc-nec-terratec-cinergy-xs
>> [   23.732442] dvb-usb: TerraTec DTV StarBox DVB-T/C USB2.0 (az6007)
>> successfully initialized and connected.
>
> I have now tested the TerraTec H7, both with w_scan and with Kaffeine.
> Neither of then is able to find any channels from the H7. (The device
> is connected to an external power supply). However, if I connect
> another device (a PCTV nanoStick T2 290e) to the same cable, both
> w_scan and Kaffeine find all the channels for my provider, and I can
> watch the clear (unencrypted) ones in Kaffeine.
>
> How can I debug the H7 further?




Thank you for the hint to the usb-pid patch. That brought my h7 the 
first dvb pictures with linux.

We both seem to have the second revision device. My has the 0ccd:10a3 
usb-id.
w_scan and dvbscan find channels. With czap i have a signal 
(FE_HAS_LOCK) but no transport traffic. With mencoder i'm able to get an 
mpeg, which is corrupt, but there are pictures and sporadically sound, 
the device receives the dvb-c stream.
Typical mencoder statement is: skipping/duplicate frame.

I didn't test dvb-t terrestrial, but under /dev/dvb i have only one 
adapter. Is there no need for two, one for cable, another for terrestrial?


ps:
Sorry I never used a newsgroup about nttp, with this post i try to get 
access. I write from moz-thunderbird and don't know if this message will 
come through. Thanks. ;)


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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-02-10 15:57       ` Jason Krolo
@ 2012-02-13 16:11         ` Eddi De Pieri
  0 siblings, 0 replies; 44+ messages in thread
From: Eddi De Pieri @ 2012-02-13 16:11 UTC (permalink / raw)
  To: Jason Krolo; +Cc: linux-media

Hi Jason,

> I didn't test dvb-t terrestrial, but under /dev/dvb i have only one adapter.
> Is there no need for two, one for cable, another for terrestrial?

Try using dvb-fe-tool from following git:

"http://git.linuxtv.org/mchehab/experimental-v4l-utils.git/shortlog/refs/heads/dvbv5-0.0.1"

This tool allow switching the delivery system from DVB-C to DVB-T (and
other if supported)

Eddi

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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-02-09 21:12     ` Torfinn Ingolfsen
  2012-02-10 15:57       ` Jason Krolo
@ 2012-02-14 19:38       ` Torfinn Ingolfsen
  1 sibling, 0 replies; 44+ messages in thread
From: Torfinn Ingolfsen @ 2012-02-14 19:38 UTC (permalink / raw)
  To: linux-media

On Thu, Feb 9, 2012 at 10:12 PM, Torfinn Ingolfsen <tingox@gmail.com> wrote:
> Update:
>
> On Thu, Feb 9, 2012 at 12:04 AM, Torfinn Ingolfsen <tingox@gmail.com> wrote:
>> Never mind. after adding this patch:
>> http://patchwork.linuxtv.org/patch/9691/
>>
>> and rebuilding the media drivers, the device is now detected:
>> tingo@kg-f4:~$ dmesg | grep -i terratec
>> [   19.755806] dvb-usb: found a 'TerraTec DTV StarBox DVB-T/C USB2.0
>> (az6007)' in warm state.
>> [   20.949045] DVB: registering new adapter (TerraTec DTV StarBox
>> DVB-T/C USB2.0 (az6007))
>> [   23.732039] Registered IR keymap rc-nec-terratec-cinergy-xs
>> [   23.732442] dvb-usb: TerraTec DTV StarBox DVB-T/C USB2.0 (az6007)
>> successfully initialized and connected.
>
> I have now tested the TerraTec H7, both with w_scan and with Kaffeine.
> Neither of then is able to find any channels from the H7. (The device
> is connected to an external power supply). However, if I connect
> another device (a PCTV nanoStick T2 290e) to the same cable, both
> w_scan and Kaffeine find all the channels for my provider, and I can
> watch the clear (unencrypted) ones in Kaffeine.
>
> How can I debug the H7 further?

For anyone using the H7 on DVB-C with success; which firmware are you
using? The one included with the experimental "media build" drivers,
or ?
And what is the device id of your H7?
(from lsusb)
mine is:
tingo@kg-f4:~$ lsusb -s 1:3
Bus 001 Device 003: ID 0ccd:10a3 TerraTec Electronic GmbH
-- 
Regards,
Torfinn Ingolfsen

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

* Re: [PATCH 00/35] Add a driver for Terratec H7
  2012-01-21 16:04 [PATCH 00/35] Add a driver for Terratec H7 Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2012-02-08 21:32 ` Torfinn Ingolfsen
@ 2012-02-16 18:43 ` Roger Mårtensson
  3 siblings, 0 replies; 44+ messages in thread
From: Roger Mårtensson @ 2012-02-16 18:43 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

Mauro Carvalho Chehab skrev 2012-01-21 17:04:
> Terratec H7 is a Cypress FX2 device with a mt2063 tuner and a drx-k
> demod. This series add support for it. It started with a public
> tree found at:
> 	 http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
>
> The driver were almost completely re-written, and it is now working,
> at least with DVB-C. I don't have a DVB-T signal here for testing,
> but I suspect it should also work fine.
>
> The FX2 firmware has a NEC IR decoder. The driver has support for
> it. The default keytable has support for the black Terratec IR
> and for the grey IR with orange keys.
>
> The CI support inside the driver is similar to the one found at the
> az6027 driver. I don't have a CI module here, so it is not tested.
>
> Tests and feedback are welcome.

A small feedback report.

I've tested with the latest media_build and can watch unencrypted 
channels on the DVB-C network I'm connected to.

It seems that the CI-module doesn't work. Nothing happens when I insert 
a CAM-module with our without a programme card.
I haven't tried to use the IR yet.

  * Okänt - identifierat
  * Engelska
  * Svenska
  * Franska
  * Tyska

  * Engelska
  * Svenska
  * Franska
  * Tyska

<javascript:void(0);>

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

end of thread, other threads:[~2012-02-16 18:43 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-21 16:04 [PATCH 00/35] Add a driver for Terratec H7 Mauro Carvalho Chehab
2012-01-21 16:04 ` [PATCH 01/35] [media] dvb: Add a new driver for az6007 Mauro Carvalho Chehab
2012-01-21 16:04   ` [PATCH 02/35] [media] az6007: Fix compilation troubles at az6007 Mauro Carvalho Chehab
2012-01-21 16:04     ` [PATCH 03/35] [media] az6007: Fix it to allow loading it without crash Mauro Carvalho Chehab
2012-01-21 16:04       ` [PATCH 04/35] [media] az6007: Fix the I2C code in order to handle mt2063 Mauro Carvalho Chehab
2012-01-21 16:04         ` [PATCH 05/35] [media] az6007: Comment the gate_ctl mutex Mauro Carvalho Chehab
2012-01-21 16:04           ` [PATCH 06/35] [media] az6007: Remove some dead code that doesn't seem to be needed Mauro Carvalho Chehab
2012-01-21 16:04             ` [PATCH 07/35] [media] az6007: CodingStyle cleanup Mauro Carvalho Chehab
2012-01-21 16:04               ` [PATCH 08/35] [media] az6007: Get rid of az6007.h Mauro Carvalho Chehab
2012-01-21 16:04                 ` [PATCH 09/35] [media] az6007: Replace the comments at the beginning of the driver Mauro Carvalho Chehab
2012-01-21 16:04                   ` [PATCH 10/35] [media] az6007: move device PID's to the proper place Mauro Carvalho Chehab
2012-01-21 16:04                     ` [PATCH 11/35] [media] az6007: make driver less verbose Mauro Carvalho Chehab
2012-01-21 16:04                       ` [PATCH 12/35] [media] drxk: Don't assume a default firmware name Mauro Carvalho Chehab
2012-01-21 16:04                         ` [PATCH 13/35] [media] az6007: need to define drivers name before including dvb-usb.h Mauro Carvalho Chehab
2012-01-21 16:04                           ` [PATCH 14/35] [media] az6007: Fix some init sequences and use the right firmwares Mauro Carvalho Chehab
2012-01-21 16:04                             ` [PATCH 15/35] [media] az6007: Change the az6007 read/write routine parameter Mauro Carvalho Chehab
2012-01-21 16:04                               ` [PATCH 16/35] [media] az6007: Simplify the read/write logic Mauro Carvalho Chehab
2012-01-21 16:04                                 ` [PATCH 17/35] [media] az6007: Simplify the code by removing an uneeded function Mauro Carvalho Chehab
2012-01-21 16:04                                   ` [PATCH 18/35] [media] az6007: Fix IR receive code Mauro Carvalho Chehab
2012-01-21 16:04                                     ` [PATCH 19/35] [media] az6007: improve the error messages for az6007 read/write calls Mauro Carvalho Chehab
2012-01-21 16:04                                       ` [PATCH 20/35] [media] az6007: Use the new MFE support at dvb-usb Mauro Carvalho Chehab
2012-01-21 16:04                                         ` [PATCH 21/35] [media] az6007: Change it to use the MFE solution adopted " Mauro Carvalho Chehab
2012-01-21 16:04                                           ` [PATCH 22/35] [media] az6007: Use a per device private struct Mauro Carvalho Chehab
2012-01-21 16:04                                             ` [PATCH 23/35] [media] drxk: Allow setting it on dynamic_clock mode Mauro Carvalho Chehab
2012-01-21 16:04                                               ` [PATCH 24/35] [media] az6007: Use DRX-K dynamic clock mode Mauro Carvalho Chehab
2012-01-21 16:04                                                 ` [PATCH 25/35] [media] drxk: add support for Mpeg output clock drive strength config Mauro Carvalho Chehab
2012-01-21 16:04                                                   ` [PATCH 26/35] [media] drxk: Allow enabling MERR/MVAL cfg Mauro Carvalho Chehab
2012-01-21 16:04                                                     ` [PATCH 27/35] [media] az6007: code cleanups and fixes Mauro Carvalho Chehab
2012-01-21 16:04                                                       ` [PATCH 28/35] [media] az6007: Driver cleanup Mauro Carvalho Chehab
2012-01-21 16:04                                                         ` [PATCH 29/35] [media] az6007: Protect read/write calls with a mutex Mauro Carvalho Chehab
2012-01-21 16:04                                                           ` [PATCH 30/35] [media] az6007: Be sure to use kmalloc'ed buffer for transfers Mauro Carvalho Chehab
2012-01-21 16:04                                                             ` [PATCH 31/35] [media] az6007: Fix IR handling Mauro Carvalho Chehab
2012-01-21 16:04                                                               ` [PATCH 32/35] [media] az6007: Convert IR to use the rc_core logic Mauro Carvalho Chehab
2012-01-21 16:04                                                                 ` [PATCH 33/35] [media] az6007: Use the right keycode for Terratec H7 Mauro Carvalho Chehab
2012-01-21 16:04                                                                   ` [PATCH 34/35] [media] az6007: Enable the driver at the building system Mauro Carvalho Chehab
2012-01-21 16:04                                                                     ` [PATCH 35/35] [media] az6007: CodingStyle fixes Mauro Carvalho Chehab
2012-01-29 21:18 ` [PATCH 00/35] Add a driver for Terratec H7 Roger Mårtensson
2012-02-08 21:32 ` Torfinn Ingolfsen
2012-02-08 23:04   ` Torfinn Ingolfsen
2012-02-09 21:12     ` Torfinn Ingolfsen
2012-02-10 15:57       ` Jason Krolo
2012-02-13 16:11         ` Eddi De Pieri
2012-02-14 19:38       ` Torfinn Ingolfsen
2012-02-16 18:43 ` Roger Mårtensson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.