The patch number 11217 was added via Mauro Carvalho Chehab <[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <[email protected]>

------

From: Mauro Carvalho Chehab  <[email protected]>
merge: http://linuxtv.org/hg/~anttip/ce6230/


Signed-off-by: Mauro Carvalho Chehab <[email protected]>


---

 linux/drivers/media/dvb/dvb-usb/Kconfig          |    8 
 linux/drivers/media/dvb/dvb-usb/Makefile         |    2 
 linux/drivers/media/dvb/dvb-usb/ce6230.c         |  331 +++++++++++++++
 linux/drivers/media/dvb/dvb-usb/ce6230.h         |   69 +++
 linux/drivers/media/dvb/dvb-usb/dvb-usb-ids.h    |    2 
 linux/drivers/media/dvb/frontends/zl10353.c      |    8 
 linux/drivers/media/dvb/frontends/zl10353.h      |    4 
 linux/drivers/media/dvb/frontends/zl10353_priv.h |    8 
 8 files changed, 430 insertions(+), 2 deletions(-)

diff -r 7c3db1ea01d1 -r 8ed72ba6629f linux/drivers/media/dvb/dvb-usb/Kconfig
--- a/linux/drivers/media/dvb/dvb-usb/Kconfig   Wed Mar 25 22:40:34 2009 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/Kconfig   Wed Mar 25 23:25:35 2009 -0300
@@ -304,3 +304,11 @@ config DVB_USB_AF9015
        select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE
        help
          Say Y here to support the Afatech AF9015 based DVB-T USB2.0 receiver
+
+config DVB_USB_CE6230
+       tristate "Intel CE6230 DVB-T USB2.0 support"
+       depends on DVB_USB && EXPERIMENTAL
+       select DVB_ZL10353
+       select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMIZE
+       help
+         Say Y here to support the Intel CE6230 DVB-T USB2.0 receiver
diff -r 7c3db1ea01d1 -r 8ed72ba6629f linux/drivers/media/dvb/dvb-usb/Makefile
--- a/linux/drivers/media/dvb/dvb-usb/Makefile  Wed Mar 25 22:40:34 2009 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/Makefile  Wed Mar 25 23:25:35 2009 -0300
@@ -76,6 +76,8 @@ dvb-usb-cinergyT2-objs = cinergyT2-core.
 dvb-usb-cinergyT2-objs = cinergyT2-core.o cinergyT2-fe.o
 obj-$(CONFIG_DVB_USB_CINERGY_T2) += dvb-usb-cinergyT2.o
 
+dvb-usb-ce6230-objs = ce6230.o
+obj-$(CONFIG_DVB_USB_CE6230) += dvb-usb-ce6230.o
 
 EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
 # due to tuner-xc3028
diff -r 7c3db1ea01d1 -r 8ed72ba6629f linux/drivers/media/dvb/dvb-usb/ce6230.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/ce6230.c  Wed Mar 25 23:25:35 2009 -0300
@@ -0,0 +1,331 @@
+/*
+ * DVB USB Linux driver for Intel CE6230 DVB-T USB2.0 receiver
+ *
+ * Copyright (C) 2009 Antti Palosaari <[email protected]>
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "ce6230.h"
+#include "zl10353.h"
+#include "mxl5005s.h"
+
+/* debug */
+static int dvb_usb_ce6230_debug;
+module_param_named(debug, dvb_usb_ce6230_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+static struct zl10353_config ce6230_zl10353_config;
+
+static int ce6230_rw_udev(struct usb_device *udev, struct req_t *req)
+{
+       int ret;
+       unsigned int pipe;
+       u8 request;
+       u8 requesttype;
+       u16 value;
+       u16 index;
+       u8 buf[req->data_len];
+
+       request = req->cmd;
+       value = req->value;
+       index = req->index;
+
+       switch (req->cmd) {
+       case I2C_READ:
+       case DEMOD_READ:
+       case REG_READ:
+               requesttype = (USB_TYPE_VENDOR | USB_DIR_IN);
+               break;
+       case I2C_WRITE:
+       case DEMOD_WRITE:
+       case REG_WRITE:
+               requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT);
+               break;
+       default:
+               err("unknown command:%02x", req->cmd);
+               ret = -EPERM;
+               goto error;
+       }
+
+       if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) {
+               /* write */
+               memcpy(buf, req->data, req->data_len);
+               pipe = usb_sndctrlpipe(udev, 0);
+       } else {
+               /* read */
+               pipe = usb_rcvctrlpipe(udev, 0);
+       }
+
+       msleep(1); /* avoid I2C errors */
+
+       ret = usb_control_msg(udev, pipe, request, requesttype, value, index,
+                               buf, sizeof(buf), CE6230_USB_TIMEOUT);
+
+       ce6230_debug_dump(request, requesttype, value, index, buf,
+               req->data_len, deb_xfer);
+
+       if (ret < 0)
+               deb_info("%s: usb_control_msg failed:%d\n", __func__, ret);
+       else
+               ret = 0;
+
+       /* read request, copy returned data to return buf */
+       if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN))
+               memcpy(req->data, buf, req->data_len);
+
+error:
+       return ret;
+}
+
+static int ce6230_ctrl_msg(struct dvb_usb_device *d, struct req_t *req)
+{
+       return ce6230_rw_udev(d->udev, req);
+}
+
+/* I2C */
+static int ce6230_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                          int num)
+{
+       struct dvb_usb_device *d = i2c_get_adapdata(adap);
+       int i = 0;
+       struct req_t req;
+       int ret;
+       memset(&req, 0, sizeof(&req));
+
+       if (num > 2)
+               return -EINVAL;
+
+       if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+               return -EAGAIN;
+
+       while (i < num) {
+               if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
+                       if (msg[i].addr ==
+                               ce6230_zl10353_config.demod_address) {
+                               req.cmd = DEMOD_READ;
+                               req.value = msg[i].addr >> 1;
+                               req.index = msg[i].buf[0];
+                               req.data_len = msg[i+1].len;
+                               req.data = &msg[i+1].buf[0];
+                               ret = ce6230_ctrl_msg(d, &req);
+                       } else {
+                               err("i2c read not implemented");
+                               ret = -EPERM;
+                       }
+                       i += 2;
+               } else {
+                       if (msg[i].addr ==
+                               ce6230_zl10353_config.demod_address) {
+                               req.cmd = DEMOD_WRITE;
+                               req.value = msg[i].addr >> 1;
+                               req.index = msg[i].buf[0];
+                               req.data_len = msg[i].len-1;
+                               req.data = &msg[i].buf[1];
+                               ret = ce6230_ctrl_msg(d, &req);
+                       } else {
+                               req.cmd = I2C_WRITE;
+                               req.value = 0x2000 + (msg[i].addr >> 1);
+                               req.index = 0x0000;
+                               req.data_len = msg[i].len;
+                               req.data = &msg[i].buf[0];
+                               ret = ce6230_ctrl_msg(d, &req);
+                       }
+                       i += 1;
+               }
+               if (ret)
+                       break;
+       }
+
+       mutex_unlock(&d->i2c_mutex);
+       return ret ? ret : i;
+}
+
+static u32 ce6230_i2c_func(struct i2c_adapter *adapter)
+{
+       return I2C_FUNC_I2C;
+}
+
+static struct i2c_algorithm ce6230_i2c_algo = {
+       .master_xfer   = ce6230_i2c_xfer,
+       .functionality = ce6230_i2c_func,
+#ifdef NEED_ALGO_CONTROL
+       .algo_control = dummy_algo_control,
+#endif
+};
+
+/* Callbacks for DVB USB */
+static struct zl10353_config ce6230_zl10353_config = {
+       .demod_address = 0x1e,
+       .adc_clock = 450000,
+       .if2 = 45700,
+       .no_tuner = 1,
+       .parallel_ts = 1,
+       .clock_ctl_1 = 0x34,
+       .pll_0 = 0x0e,
+};
+
+static int ce6230_zl10353_frontend_attach(struct dvb_usb_adapter *adap)
+{
+       deb_info("%s:\n", __func__);
+       adap->fe = dvb_attach(zl10353_attach, &ce6230_zl10353_config,
+               &adap->dev->i2c_adap);
+       if (adap->fe == NULL)
+               return -ENODEV;
+       return 0;
+}
+
+static struct mxl5005s_config ce6230_mxl5003s_config = {
+       .i2c_address     = 0xc6,
+       .if_freq         = IF_FREQ_4570000HZ,
+       .xtal_freq       = CRYSTAL_FREQ_16000000HZ,
+       .agc_mode        = MXL_SINGLE_AGC,
+       .tracking_filter = MXL_TF_DEFAULT,
+       .rssi_enable     = MXL_RSSI_ENABLE,
+       .cap_select      = MXL_CAP_SEL_ENABLE,
+       .div_out         = MXL_DIV_OUT_4,
+       .clock_out       = MXL_CLOCK_OUT_DISABLE,
+       .output_load     = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
+       .top             = MXL5005S_TOP_25P2,
+       .mod_mode        = MXL_DIGITAL_MODE,
+       .if_mode         = MXL_ZERO_IF,
+       .AgcMasterByte   = 0x00,
+};
+
+static int ce6230_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
+{
+       int ret;
+       deb_info("%s:\n", __func__);
+       ret = dvb_attach(mxl5005s_attach, adap->fe, &adap->dev->i2c_adap,
+                       &ce6230_mxl5003s_config) == NULL ? -ENODEV : 0;
+       return ret;
+}
+
+static int ce6230_power_ctrl(struct dvb_usb_device *d, int onoff)
+{
+       int ret;
+       deb_info("%s: onoff:%d\n", __func__, onoff);
+
+       /* InterfaceNumber 1 / AlternateSetting 0     idle
+          InterfaceNumber 1 / AlternateSetting 1     streaming */
+       ret = usb_set_interface(d->udev, 1, onoff);
+       if (ret)
+               err("usb_set_interface failed with error:%d", ret);
+
+       return ret;
+}
+
+/* DVB USB Driver stuff */
+static struct dvb_usb_device_properties ce6230_properties;
+
+static int ce6230_probe(struct usb_interface *intf,
+                       const struct usb_device_id *id)
+{
+       int ret = 0;
+       struct dvb_usb_device *d = NULL;
+
+       deb_info("%s: interface:%d\n", __func__,
+               intf->cur_altsetting->desc.bInterfaceNumber);
+
+       if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
+               ret = dvb_usb_device_init(intf, &ce6230_properties, THIS_MODULE,
+                       &d, adapter_nr);
+               if (ret)
+                       err("init failed with error:%d\n", ret);
+       }
+
+       return ret;
+}
+
+static struct usb_device_id ce6230_table[] = {
+       { USB_DEVICE(USB_VID_INTEL, USB_PID_INTEL_CE9500) },
+       { } /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, ce6230_table);
+
+static struct dvb_usb_device_properties ce6230_properties = {
+       .caps = DVB_USB_IS_AN_I2C_ADAPTER,
+
+       .usb_ctrl = DEVICE_SPECIFIC,
+       .no_reconnect = 1,
+
+       .size_of_priv = 0,
+
+       .num_adapters = 1,
+       .adapter = {
+               {
+                       .frontend_attach  = ce6230_zl10353_frontend_attach,
+                       .tuner_attach     = ce6230_mxl5003s_tuner_attach,
+                       .stream = {
+                               .type = USB_BULK,
+                               .count = 6,
+                               .endpoint = 0x82,
+                               .u = {
+                                       .bulk = {
+                                               .buffersize = 512,
+                                       }
+                               }
+                       },
+               }
+       },
+
+       .power_ctrl = ce6230_power_ctrl,
+
+       .i2c_algo = &ce6230_i2c_algo,
+
+       .num_device_descs = 1,
+       .devices = {
+               {
+                       .name = "Intel CE9500 reference design",
+                       .cold_ids = {NULL},
+                       .warm_ids = {&ce6230_table[0], NULL},
+               },
+       }
+};
+
+static struct usb_driver ce6230_driver = {
+       .name       = "dvb_usb_ce6230",
+       .probe      = ce6230_probe,
+       .disconnect = dvb_usb_device_exit,
+       .id_table   = ce6230_table,
+};
+
+/* module stuff */
+static int __init ce6230_module_init(void)
+{
+       int ret;
+       deb_info("%s:\n", __func__);
+       ret = usb_register(&ce6230_driver);
+       if (ret)
+               err("usb_register failed with error:%d", ret);
+
+       return ret;
+}
+
+static void __exit ce6230_module_exit(void)
+{
+       deb_info("%s:\n", __func__);
+       /* deregister this driver from the USB subsystem */
+       usb_deregister(&ce6230_driver);
+}
+
+module_init(ce6230_module_init);
+module_exit(ce6230_module_exit);
+
+MODULE_AUTHOR("Antti Palosaari <[email protected]>");
+MODULE_DESCRIPTION("Driver for Intel CE6230 DVB-T USB2.0");
+MODULE_LICENSE("GPL");
diff -r 7c3db1ea01d1 -r 8ed72ba6629f linux/drivers/media/dvb/dvb-usb/ce6230.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/dvb-usb/ce6230.h  Wed Mar 25 23:25:35 2009 -0300
@@ -0,0 +1,69 @@
+/*
+ * DVB USB Linux driver for Intel CE6230 DVB-T USB2.0 receiver
+ *
+ * Copyright (C) 2009 Antti Palosaari <[email protected]>
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DVB_USB_CE6230_H_
+#define _DVB_USB_CE6230_H_
+
+#define DVB_USB_LOG_PREFIX "ce6230"
+#include "dvb-usb.h"
+
+#define deb_info(args...) dprintk(dvb_usb_ce6230_debug, 0x01, args)
+#define deb_rc(args...)   dprintk(dvb_usb_ce6230_debug, 0x02, args)
+#define deb_xfer(args...) dprintk(dvb_usb_ce6230_debug, 0x04, args)
+#define deb_reg(args...)  dprintk(dvb_usb_ce6230_debug, 0x08, args)
+#define deb_i2c(args...)  dprintk(dvb_usb_ce6230_debug, 0x10, args)
+#define deb_fw(args...)   dprintk(dvb_usb_ce6230_debug, 0x20, args)
+
+#define ce6230_debug_dump(r, t, v, i, b, l, func) { \
+       int loop_; \
+       func("%02x %02x %02x %02x %02x %02x %02x %02x", \
+               t, r, v & 0xff, v >> 8, i & 0xff, i >> 8, l & 0xff, l >> 8); \
+       if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \
+               func(" >>> "); \
+       else \
+               func(" <<< "); \
+       for (loop_ = 0; loop_ < l; loop_++) \
+               func("%02x ", b[loop_]); \
+       func("\n");\
+}
+
+#define CE6230_USB_TIMEOUT 1000
+
+struct req_t {
+       u8  cmd;       /* [1] */
+       u16 value;     /* [2|3] */
+       u16 index;     /* [4|5] */
+       u16 data_len;  /* [6|7] */
+       u8  *data;
+};
+
+enum ce6230_cmd {
+       CONFIG_READ          = 0xd0, /* rd 0 (unclear) */
+       UNKNOWN_WRITE        = 0xc7, /* wr 7 (unclear) */
+       I2C_READ             = 0xd9, /* rd 9 (unclear) */
+       I2C_WRITE            = 0xca, /* wr a */
+       DEMOD_READ           = 0xdb, /* rd b */
+       DEMOD_WRITE          = 0xcc, /* wr c */
+       REG_READ             = 0xde, /* rd e */
+       REG_WRITE            = 0xcf, /* wr f */
+};
+
+#endif
diff -r 7c3db1ea01d1 -r 8ed72ba6629f 
linux/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
--- a/linux/drivers/media/dvb/dvb-usb/dvb-usb-ids.h     Wed Mar 25 22:40:34 
2009 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/dvb-usb-ids.h     Wed Mar 25 23:25:35 
2009 -0300
@@ -33,6 +33,7 @@
 #define USB_VID_HANFTEK                                0x15f4
 #define USB_VID_HAUPPAUGE                      0x2040
 #define USB_VID_HYPER_PALTEK                   0x1025
+#define USB_VID_INTEL                          0x8086
 #define USB_VID_KWORLD                         0xeb2a
 #define USB_VID_KWORLD_2                       0x1b80
 #define USB_VID_KYE                            0x0458
@@ -96,6 +97,7 @@
 #define USB_PID_UNIWILL_STK7700P                       0x6003
 #define USB_PID_GRANDTEC_DVBT_USB_COLD                 0x0fa0
 #define USB_PID_GRANDTEC_DVBT_USB_WARM                 0x0fa1
+#define USB_PID_INTEL_CE9500                           0x9500
 #define USB_PID_KWORLD_399U                            0xe399
 #define USB_PID_KWORLD_395U                            0xe396
 #define USB_PID_KWORLD_395U_2                          0xe39b
diff -r 7c3db1ea01d1 -r 8ed72ba6629f linux/drivers/media/dvb/frontends/zl10353.c
--- a/linux/drivers/media/dvb/frontends/zl10353.c       Wed Mar 25 22:40:34 
2009 -0300
+++ b/linux/drivers/media/dvb/frontends/zl10353.c       Wed Mar 25 23:25:35 
2009 -0300
@@ -581,6 +581,10 @@ static int zl10353_init(struct dvb_front
 #endif
        if (state->config.parallel_ts)
                zl10353_reset_attach[2] &= ~0x20;
+       if (state->config.clock_ctl_1)
+               zl10353_reset_attach[3] = state->config.clock_ctl_1;
+       if (state->config.pll_0)
+               zl10353_reset_attach[4] = state->config.pll_0;
 
        /* Do a "hard" reset if not already done */
        if (zl10353_read_register(state, 0x50) != zl10353_reset_attach[1] ||
@@ -625,6 +629,7 @@ struct dvb_frontend *zl10353_attach(cons
                                    struct i2c_adapter *i2c)
 {
        struct zl10353_state *state = NULL;
+       int id;
 
        /* allocate memory for the internal state */
        state = kzalloc(sizeof(struct zl10353_state), GFP_KERNEL);
@@ -636,7 +641,8 @@ struct dvb_frontend *zl10353_attach(cons
        memcpy(&state->config, config, sizeof(struct zl10353_config));
 
        /* check if the demod is there */
-       if (zl10353_read_register(state, CHIP_ID) != ID_ZL10353)
+       id = zl10353_read_register(state, CHIP_ID);
+       if ((id != ID_ZL10353) && (id != ID_CE6230) && (id != ID_CE6231))
                goto error;
 
        /* create dvb_frontend */
diff -r 7c3db1ea01d1 -r 8ed72ba6629f linux/drivers/media/dvb/frontends/zl10353.h
--- a/linux/drivers/media/dvb/frontends/zl10353.h       Wed Mar 25 22:40:34 
2009 -0300
+++ b/linux/drivers/media/dvb/frontends/zl10353.h       Wed Mar 25 23:25:35 
2009 -0300
@@ -41,6 +41,10 @@ struct zl10353_config
 
        /* set if i2c_gate_ctrl disable is required */
        u8 disable_i2c_gate_ctrl:1;
+
+       /* clock control registers (0x51-0x54) */
+       u8 clock_ctl_1;  /* default: 0x46 */
+       u8 pll_0;        /* default: 0x15 */
 };
 
 #if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && 
defined(MODULE))
diff -r 7c3db1ea01d1 -r 8ed72ba6629f 
linux/drivers/media/dvb/frontends/zl10353_priv.h
--- a/linux/drivers/media/dvb/frontends/zl10353_priv.h  Wed Mar 25 22:40:34 
2009 -0300
+++ b/linux/drivers/media/dvb/frontends/zl10353_priv.h  Wed Mar 25 23:25:35 
2009 -0300
@@ -22,7 +22,9 @@
 #ifndef _ZL10353_PRIV_
 #define _ZL10353_PRIV_
 
-#define ID_ZL10353     0x14
+#define ID_ZL10353     0x14 /* Zarlink ZL10353 */
+#define ID_CE6230      0x18 /* Intel CE6230 */
+#define ID_CE6231      0x19 /* Intel CE6231 */
 
 #define msb(x) (((x) >> 8) & 0xff)
 #define lsb(x) ((x) & 0xff)
@@ -50,6 +52,10 @@ enum zl10353_reg_addr {
        TPS_RECEIVED_0     = 0x1E,
        TPS_CURRENT_1      = 0x1F,
        TPS_CURRENT_0      = 0x20,
+       CLOCK_CTL_0        = 0x51,
+       CLOCK_CTL_1        = 0x52,
+       PLL_0              = 0x53,
+       PLL_1              = 0x54,
        RESET              = 0x55,
        AGC_TARGET         = 0x56,
        MCLK_RATIO         = 0x5C,


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/8ed72ba6629fad2a550c3a065b9b52d39b1e33e0

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to