Merge tag 'v3.3-rc1' into staging/for_v3.3
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 22 Jan 2012 01:23:15 +0000 (23:23 -0200)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 22 Jan 2012 01:23:15 +0000 (23:23 -0200)
* tag 'v3.3-rc1': (8187 commits)
  Linux 3.3-rc1
  x86, syscall: Need __ARCH_WANT_SYS_IPC for 32 bits
  qnx4: don't leak ->BitMap on late failure exits
  qnx4: reduce the insane nesting in qnx4_checkroot()
  qnx4: di_fname is an array, for crying out loud...
  KEYS: Permit key_serial() to be called with a const key pointer
  keys: fix user_defined key sparse messages
  ima: fix cred sparse warning
  uml: fix compile for x86-64
  MPILIB: Add a missing ENOMEM check
  tpm: fix (ACPI S3) suspend regression
  nvme: fix merge error due to change of 'make_request_fn' fn type
  xen: using EXPORT_SYMBOL requires including export.h
  gpio: tps65910: Use correct offset for gpio initialization
  acpi/apei/einj: Add extensions to EINJ from rev 5.0 of acpi spec
  intel_idle: Split up and provide per CPU initialization func
  ACPI processor: Remove unneeded variable passed by acpi_processor_hotadd_init V2
  tg3: Fix single-vector MSI-X code
  openvswitch: Fix multipart datapath dumps.
  ipv6: fix per device IP snmp counters
  ...

drivers/media/common/tuners/mt2063.c
drivers/media/dvb/ddbridge/ddbridge-core.c
drivers/media/dvb/dvb-usb/Kconfig
drivers/media/dvb/dvb-usb/Makefile
drivers/media/dvb/dvb-usb/az6007.c [new file with mode: 0644]
drivers/media/dvb/dvb-usb/dvb-usb-ids.h
drivers/media/dvb/frontends/drxk.h
drivers/media/dvb/frontends/drxk_hard.c
drivers/media/dvb/frontends/drxk_hard.h
drivers/media/dvb/ngene/ngene-cards.c
drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c

index c89af3c..7bbf25d 100644 (file)
@@ -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;
 }
index ce4f858..d88c4aa 100644 (file)
@@ -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);
index 9f203c6..e894bad 100644 (file)
@@ -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
index 26c8b9e..d9549cb 100644 (file)
@@ -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
 
diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c
new file mode 100644 (file)
index 0000000..02efd94
--- /dev/null
@@ -0,0 +1,581 @@
+/*
+ * 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()
+ *
+ * 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
+ * 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"
+#include "mt2063.h"
+#include "dvb_ca_en50221.h"
+
+#define DVB_USB_LOG_PREFIX "az6007"
+#include "dvb-usb.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);
+
+#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);
+
+/* 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         0xb4
+
+struct az6007_device_state {
+       struct mutex            mutex;
+       struct dvb_ca_en50221   ca;
+       unsigned                warm:1;
+       int                     (*gate_ctrl) (struct dvb_frontend *, int);
+       unsigned char           data[4096];
+};
+
+static struct drxk_config terratec_h7_drxk = {
+       .adr = 0x29,
+       .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,
+       .microcode_name = "dvb-usb-terratec-h7-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;
+       int status = 0;
+
+       deb_info("%s: %s\n", __func__, enable ? "enable" : "disable");
+
+       if (!adap)
+               return -EINVAL;
+
+       st = adap->dev->priv;
+
+       if (!st)
+               return -EINVAL;
+
+       if (enable)
+               status = st->gate_ctrl(fe, 1);
+       else
+               status = st->gate_ctrl(fe, 0);
+
+       return status;
+}
+
+static struct mt2063_config az6007_mt2063_config = {
+       .tuner_address = 0x60,
+       .refclock = 36125000,
+};
+
+static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
+                           u16 index, u8 *b, int blen)
+{
+       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 read 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);
+
+       return ret;
+}
+
+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;
+
+       deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ", req, value,
+                index);
+       debug_dump(b, blen, deb_xfer);
+
+       if (blen > 64) {
+               err("az6007: tried to write %d bytes, but I2C max size is 64 bytes\n",
+                   blen);
+               return -EOPNOTSUPP;
+       }
+
+       ret = usb_control_msg(udev,
+                             usb_sndctrlpipe(udev, 0),
+                             req,
+                             USB_TYPE_VENDOR | USB_DIR_OUT,
+                             value, index, b, blen, 5000);
+       if (ret != blen) {
+               err("usb write operation failed. (%d)", ret);
+               return -EIO;
+       }
+
+       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(d, 0xbc, onoff, 0, NULL, 0);
+}
+
+/* remote control stuff (does not work with my box) */
+static int az6007_rc_query(struct dvb_usb_device *d)
+{
+       struct az6007_device_state *st = d->priv;
+       unsigned code = 0;
+
+       az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
+
+       if (st->data[1] == 0x44)
+               return 0;
+
+       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];
+
+       rc_keydown(d->rc_dev, code, st->data[5]);
+
+       return 0;
+}
+
+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, st->data, 6);
+       memcpy(mac, st->data, sizeof(mac));
+
+       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_attach(struct dvb_usb_adapter *adap)
+{
+       struct az6007_device_state *st = adap->dev->priv;
+
+       deb_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)
+               return -EINVAL;
+
+       adap->fe_adap[0].fe->sec_priv = adap;
+       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;
+}
+
+static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
+{
+       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,
+                       &az6007_mt2063_config,
+                       &adap->dev->i2c_adap))
+               return -EINVAL;
+
+       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;
+}
+
+int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
+{
+       struct az6007_device_state *st = d->priv;
+       int ret;
+
+       deb_info("%s()\n", __func__);
+
+       if (!st->warm) {
+               mutex_init(&st->mutex);
+
+               ret = az6007_write(d, AZ6007_POWER, 0, 2, NULL, 0);
+               if (ret < 0)
+                       return ret;
+               msleep(60);
+               ret = az6007_write(d, AZ6007_POWER, 1, 4, NULL, 0);
+               if (ret < 0)
+                       return ret;
+               msleep(100);
+               ret = az6007_write(d, AZ6007_POWER, 1, 3, NULL, 0);
+               if (ret < 0)
+                       return ret;
+               msleep(20);
+               ret = az6007_write(d, AZ6007_POWER, 1, 4, NULL, 0);
+               if (ret < 0)
+                       return ret;
+
+               msleep(400);
+               ret = az6007_write(d, FX2_SCON1, 0, 3, NULL, 0);
+               if (ret < 0)
+                       return ret;
+               msleep(150);
+               ret = az6007_write(d, FX2_SCON1, 1, 3, NULL, 0);
+               if (ret < 0)
+                       return ret;
+               msleep(430);
+               ret = az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
+               if (ret < 0)
+                       return ret;
+
+               st->warm = true;
+
+               return 0;
+       }
+
+       if (!onoff)
+               return 0;
+
+       az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
+       az6007_write(d, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
+
+       return 0;
+}
+
+/* I2C */
+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;
+
+       if (mutex_lock_interruptible(&st->mutex) < 0)
+               return -EAGAIN;
+
+       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
+                        */
+                       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 = AZ6007_I2C_RD;
+                       index = msgs[i].buf[0];
+                       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);
+                       if (ret >= len) {
+                               for (j = 0; j < len; j++) {
+                                       msgs[i + 1].buf[j] = st->data[j + 5];
+                                       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 */
+                       if (dvb_usb_az6007_debug & 2)
+                               printk(KERN_DEBUG
+                                      "az6007 I2C xfer write addr=0x%x len=%d: ",
+                                      addr, msgs[i].len);
+                       req = AZ6007_I2C_WR;
+                       index = msgs[i].buf[0];
+                       value = addr | (1 << 8);
+                       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++) {
+                               st->data[j] = msgs[i].buf[j + 1];
+                               if (dvb_usb_az6007_debug & 2)
+                                       printk(KERN_CONT "0x%02x ",
+                                              st->data[j]);
+                       }
+                       ret =  __az6007_write(d->udev, req, value, index,
+                                             st->data, length);
+               } else {
+                       /* read bytes */
+                       if (dvb_usb_az6007_debug & 2)
+                               printk(KERN_DEBUG
+                                      "az6007 I2C xfer read addr=0x%x len=%d: ",
+                                      addr, msgs[i].len);
+                       req = AZ6007_I2C_RD;
+                       index = msgs[i].buf[0];
+                       value = addr;
+                       length = msgs[i].len + 6;
+                       len = msgs[i].len;
+                       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)
+                                       printk(KERN_CONT
+                                              "0x%02x ", st->data[j + 5]);
+                       }
+               }
+               if (dvb_usb_az6007_debug & 2)
+                       printk(KERN_CONT "\n");
+               if (ret < 0)
+                       goto err;
+       }
+err:
+       mutex_unlock(&st->mutex);
+
+       if (ret < 0) {
+               info("%s ERROR: %i", __func__, ret);
+               return ret;
+       }
+       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,
+       .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 ret;
+       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);
+       if (ret == 6)
+               *cold = 0;
+       else
+               *cold = 1;
+
+       kfree(mac);
+
+       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;
+}
+
+static struct dvb_usb_device_properties az6007_properties;
+
+static int az6007_usb_probe(struct usb_interface *intf,
+                           const struct usb_device_id *id)
+{
+       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,
+       .firmware            = "dvb-usb-terratec-h7-az6007.fw",
+       .no_reconnect        = 1,
+       .size_of_priv        = sizeof(struct az6007_device_state),
+       .identify_state      = az6007_identify_state,
+       .num_adapters = 1,
+       .adapter = {
+               {
+               .num_frontends = 1,
+               .fe = {{
+                       .streaming_ctrl   = az6007_streaming_ctrl,
+                       .tuner_attach     = az6007_tuner_attach,
+                       .frontend_attach  = az6007_frontend_attach,
+
+                       /* parameter for the MPEG2-data transfer */
+                       .stream = {
+                               .type = USB_BULK,
+                               .count = 10,
+                               .endpoint = 0x02,
+                               .u = {
+                                       .bulk = {
+                                               .buffersize = 4096,
+                                       }
+                               }
+                       },
+               } }
+       } },
+       .power_ctrl       = az6007_power_ctrl,
+       .read_mac_address = az6007_read_mac_addr,
+
+       .rc.core = {
+               .rc_interval      = 400,
+               .rc_codes         = RC_MAP_NEC_TERRATEC_CINERGY_XS,
+               .module_name      = "az6007",
+               .rc_query         = az6007_rc_query,
+               .allowed_protos   = RC_TYPE_NEC,
+       },
+       .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,
+       .id_table       = az6007_usb_table,
+};
+
+/* module stuff */
+static int __init az6007_usb_module_init(void)
+{
+       int result;
+       deb_info("az6007 usb module init\n");
+
+       result = usb_register(&az6007_usb_driver);
+       if (result) {
+               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 */
+       deb_info("az6007 usb module exit\n");
+       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_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");
index d390dda..b3e7be4 100644 (file)
@@ -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
 #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
index 0209818..9d64e4f 100644 (file)
@@ -7,15 +7,19 @@
 /**
  * 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.
+ * @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
+ * @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
+ * @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
  * UIO-3.
@@ -25,11 +29,14 @@ struct drxk_config {
        bool    single_master;
        bool    no_i2c_bridge;
        bool    parallel_ts;
+       bool    dynamic_clk;
+       bool    enable_merr_cfg;
 
        bool    antenna_dvbt;
        u16     antenna_gpio;
 
-       int    chunk_size;
+       u8      mpeg_out_clk_strength;
+       int     chunk_size;
 
        const char *microcode_name;
 };
index 6980ed7..5fa1927 100644 (file)
@@ -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
 
@@ -650,9 +646,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;
 
@@ -662,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;
 
@@ -815,8 +807,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 */
 
@@ -824,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;
@@ -1189,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",
@@ -1254,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);
@@ -6070,9 +6066,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 */
@@ -6391,6 +6385,21 @@ 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;
+               state->m_DVBCStaticCLK = 0;
+       } else {
+               state->m_DVBTStaticCLK = 1;
+               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;
index 3a58b73..4bbf841 100644 (file)
@@ -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;
index 8418c02..7539a5d 100644 (file)
@@ -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);
index f3b86c8..8d4dae2 100644 (file)
@@ -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 = {