aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2009-03-25 15:59:45 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:40 -0400
commiteebb876b0b8f7ee5e6c01a85433a754c9be88369 (patch)
tree5b16d997054b31c8b32cc4e8add7ff05db1bc62e /drivers/media/dvb
parent378a2793eb5e1e6bcd44f85d368ad6962c8ce1ee (diff)
V4L/DVB (11216): Add driver for Intel CE6230 DVB-T USB2.0
Add driver for Intel CE6230 DVB-T USB 2.0 COFDM demodulator Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig8
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile2
-rw-r--r--drivers/media/dvb/dvb-usb/ce6230.c328
-rw-r--r--drivers/media/dvb/dvb-usb/ce6230.h69
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h2
5 files changed, 409 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 5b0c8cc25fdf..6103caad1644 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -304,3 +304,11 @@ config DVB_USB_AF9015
304 select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE 304 select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE
305 help 305 help
306 Say Y here to support the Afatech AF9015 based DVB-T USB2.0 receiver 306 Say Y here to support the Afatech AF9015 based DVB-T USB2.0 receiver
307
308config DVB_USB_CE6230
309 tristate "Intel CE6230 DVB-T USB2.0 support"
310 depends on DVB_USB && EXPERIMENTAL
311 select DVB_ZL10353
312 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMIZE
313 help
314 Say Y here to support the Intel CE6230 DVB-T USB2.0 receiver
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 3122b7cc2c23..f92734ed777a 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -76,6 +76,8 @@ obj-$(CONFIG_DVB_USB_AF9015) += dvb-usb-af9015.o
76dvb-usb-cinergyT2-objs = cinergyT2-core.o cinergyT2-fe.o 76dvb-usb-cinergyT2-objs = cinergyT2-core.o cinergyT2-fe.o
77obj-$(CONFIG_DVB_USB_CINERGY_T2) += dvb-usb-cinergyT2.o 77obj-$(CONFIG_DVB_USB_CINERGY_T2) += dvb-usb-cinergyT2.o
78 78
79dvb-usb-ce6230-objs = ce6230.o
80obj-$(CONFIG_DVB_USB_CE6230) += dvb-usb-ce6230.o
79 81
80EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 82EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
81# due to tuner-xc3028 83# due to tuner-xc3028
diff --git a/drivers/media/dvb/dvb-usb/ce6230.c b/drivers/media/dvb/dvb-usb/ce6230.c
new file mode 100644
index 000000000000..8a3059040352
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/ce6230.c
@@ -0,0 +1,328 @@
1/*
2 * DVB USB Linux driver for Intel CE6230 DVB-T USB2.0 receiver
3 *
4 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21
22#include "ce6230.h"
23#include "zl10353.h"
24#include "mxl5005s.h"
25
26/* debug */
27static int dvb_usb_ce6230_debug;
28module_param_named(debug, dvb_usb_ce6230_debug, int, 0644);
29MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
30DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
31
32static struct zl10353_config ce6230_zl10353_config;
33
34static int ce6230_rw_udev(struct usb_device *udev, struct req_t *req)
35{
36 int ret;
37 unsigned int pipe;
38 u8 request;
39 u8 requesttype;
40 u16 value;
41 u16 index;
42 u8 buf[req->data_len];
43
44 request = req->cmd;
45 value = req->value;
46 index = req->index;
47
48 switch (req->cmd) {
49 case I2C_READ:
50 case DEMOD_READ:
51 case REG_READ:
52 requesttype = (USB_TYPE_VENDOR | USB_DIR_IN);
53 break;
54 case I2C_WRITE:
55 case DEMOD_WRITE:
56 case REG_WRITE:
57 requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT);
58 break;
59 default:
60 err("unknown command:%02x", req->cmd);
61 ret = -EPERM;
62 goto error;
63 }
64
65 if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) {
66 /* write */
67 memcpy(buf, req->data, req->data_len);
68 pipe = usb_sndctrlpipe(udev, 0);
69 } else {
70 /* read */
71 pipe = usb_rcvctrlpipe(udev, 0);
72 }
73
74 msleep(1); /* avoid I2C errors */
75
76 ret = usb_control_msg(udev, pipe, request, requesttype, value, index,
77 buf, sizeof(buf), CE6230_USB_TIMEOUT);
78
79 ce6230_debug_dump(request, requesttype, value, index, buf,
80 req->data_len, deb_xfer);
81
82 if (ret < 0)
83 deb_info("%s: usb_control_msg failed:%d\n", __func__, ret);
84 else
85 ret = 0;
86
87 /* read request, copy returned data to return buf */
88 if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN))
89 memcpy(req->data, buf, req->data_len);
90
91error:
92 return ret;
93}
94
95static int ce6230_ctrl_msg(struct dvb_usb_device *d, struct req_t *req)
96{
97 return ce6230_rw_udev(d->udev, req);
98}
99
100/* I2C */
101static int ce6230_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
102 int num)
103{
104 struct dvb_usb_device *d = i2c_get_adapdata(adap);
105 int i = 0;
106 struct req_t req;
107 int ret;
108 memset(&req, 0, sizeof(&req));
109
110 if (num > 2)
111 return -EINVAL;
112
113 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
114 return -EAGAIN;
115
116 while (i < num) {
117 if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
118 if (msg[i].addr ==
119 ce6230_zl10353_config.demod_address) {
120 req.cmd = DEMOD_READ;
121 req.value = msg[i].addr >> 1;
122 req.index = msg[i].buf[0];
123 req.data_len = msg[i+1].len;
124 req.data = &msg[i+1].buf[0];
125 ret = ce6230_ctrl_msg(d, &req);
126 } else {
127 err("i2c read not implemented");
128 ret = -EPERM;
129 }
130 i += 2;
131 } else {
132 if (msg[i].addr ==
133 ce6230_zl10353_config.demod_address) {
134 req.cmd = DEMOD_WRITE;
135 req.value = msg[i].addr >> 1;
136 req.index = msg[i].buf[0];
137 req.data_len = msg[i].len-1;
138 req.data = &msg[i].buf[1];
139 ret = ce6230_ctrl_msg(d, &req);
140 } else {
141 req.cmd = I2C_WRITE;
142 req.value = 0x2000 + (msg[i].addr >> 1);
143 req.index = 0x0000;
144 req.data_len = msg[i].len;
145 req.data = &msg[i].buf[0];
146 ret = ce6230_ctrl_msg(d, &req);
147 }
148 i += 1;
149 }
150 if (ret)
151 break;
152 }
153
154 mutex_unlock(&d->i2c_mutex);
155 return ret ? ret : i;
156}
157
158static u32 ce6230_i2c_func(struct i2c_adapter *adapter)
159{
160 return I2C_FUNC_I2C;
161}
162
163static struct i2c_algorithm ce6230_i2c_algo = {
164 .master_xfer = ce6230_i2c_xfer,
165 .functionality = ce6230_i2c_func,
166};
167
168/* Callbacks for DVB USB */
169static struct zl10353_config ce6230_zl10353_config = {
170 .demod_address = 0x1e,
171 .adc_clock = 450000,
172 .if2 = 45700,
173 .no_tuner = 1,
174 .parallel_ts = 1,
175 .clock_ctl_1 = 0x34,
176 .pll_0 = 0x0e,
177};
178
179static int ce6230_zl10353_frontend_attach(struct dvb_usb_adapter *adap)
180{
181 deb_info("%s:\n", __func__);
182 adap->fe = dvb_attach(zl10353_attach, &ce6230_zl10353_config,
183 &adap->dev->i2c_adap);
184 if (adap->fe == NULL)
185 return -ENODEV;
186 return 0;
187}
188
189static struct mxl5005s_config ce6230_mxl5003s_config = {
190 .i2c_address = 0xc6,
191 .if_freq = IF_FREQ_4570000HZ,
192 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
193 .agc_mode = MXL_SINGLE_AGC,
194 .tracking_filter = MXL_TF_DEFAULT,
195 .rssi_enable = MXL_RSSI_ENABLE,
196 .cap_select = MXL_CAP_SEL_ENABLE,
197 .div_out = MXL_DIV_OUT_4,
198 .clock_out = MXL_CLOCK_OUT_DISABLE,
199 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
200 .top = MXL5005S_TOP_25P2,
201 .mod_mode = MXL_DIGITAL_MODE,
202 .if_mode = MXL_ZERO_IF,
203 .AgcMasterByte = 0x00,
204};
205
206static int ce6230_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
207{
208 int ret;
209 deb_info("%s:\n", __func__);
210 ret = dvb_attach(mxl5005s_attach, adap->fe, &adap->dev->i2c_adap,
211 &ce6230_mxl5003s_config) == NULL ? -ENODEV : 0;
212 return ret;
213}
214
215static int ce6230_power_ctrl(struct dvb_usb_device *d, int onoff)
216{
217 int ret;
218 deb_info("%s: onoff:%d\n", __func__, onoff);
219
220 /* InterfaceNumber 1 / AlternateSetting 0 idle
221 InterfaceNumber 1 / AlternateSetting 1 streaming */
222 ret = usb_set_interface(d->udev, 1, onoff);
223 if (ret)
224 err("usb_set_interface failed with error:%d", ret);
225
226 return ret;
227}
228
229/* DVB USB Driver stuff */
230static struct dvb_usb_device_properties ce6230_properties;
231
232static int ce6230_probe(struct usb_interface *intf,
233 const struct usb_device_id *id)
234{
235 int ret = 0;
236 struct dvb_usb_device *d = NULL;
237
238 deb_info("%s: interface:%d\n", __func__,
239 intf->cur_altsetting->desc.bInterfaceNumber);
240
241 if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
242 ret = dvb_usb_device_init(intf, &ce6230_properties, THIS_MODULE,
243 &d, adapter_nr);
244 if (ret)
245 err("init failed with error:%d\n", ret);
246 }
247
248 return ret;
249}
250
251static struct usb_device_id ce6230_table[] = {
252 { USB_DEVICE(USB_VID_INTEL, USB_PID_INTEL_CE9500) },
253 { } /* Terminating entry */
254};
255MODULE_DEVICE_TABLE(usb, ce6230_table);
256
257static struct dvb_usb_device_properties ce6230_properties = {
258 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
259
260 .usb_ctrl = DEVICE_SPECIFIC,
261 .no_reconnect = 1,
262
263 .size_of_priv = 0,
264
265 .num_adapters = 1,
266 .adapter = {
267 {
268 .frontend_attach = ce6230_zl10353_frontend_attach,
269 .tuner_attach = ce6230_mxl5003s_tuner_attach,
270 .stream = {
271 .type = USB_BULK,
272 .count = 6,
273 .endpoint = 0x82,
274 .u = {
275 .bulk = {
276 .buffersize = 512,
277 }
278 }
279 },
280 }
281 },
282
283 .power_ctrl = ce6230_power_ctrl,
284
285 .i2c_algo = &ce6230_i2c_algo,
286
287 .num_device_descs = 1,
288 .devices = {
289 {
290 .name = "Intel CE9500 reference design",
291 .cold_ids = {NULL},
292 .warm_ids = {&ce6230_table[0], NULL},
293 },
294 }
295};
296
297static struct usb_driver ce6230_driver = {
298 .name = "dvb_usb_ce6230",
299 .probe = ce6230_probe,
300 .disconnect = dvb_usb_device_exit,
301 .id_table = ce6230_table,
302};
303
304/* module stuff */
305static int __init ce6230_module_init(void)
306{
307 int ret;
308 deb_info("%s:\n", __func__);
309 ret = usb_register(&ce6230_driver);
310 if (ret)
311 err("usb_register failed with error:%d", ret);
312
313 return ret;
314}
315
316static void __exit ce6230_module_exit(void)
317{
318 deb_info("%s:\n", __func__);
319 /* deregister this driver from the USB subsystem */
320 usb_deregister(&ce6230_driver);
321}
322
323module_init(ce6230_module_init);
324module_exit(ce6230_module_exit);
325
326MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
327MODULE_DESCRIPTION("Driver for Intel CE6230 DVB-T USB2.0");
328MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/ce6230.h b/drivers/media/dvb/dvb-usb/ce6230.h
new file mode 100644
index 000000000000..97c42482ccb3
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/ce6230.h
@@ -0,0 +1,69 @@
1/*
2 * DVB USB Linux driver for Intel CE6230 DVB-T USB2.0 receiver
3 *
4 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21
22#ifndef _DVB_USB_CE6230_H_
23#define _DVB_USB_CE6230_H_
24
25#define DVB_USB_LOG_PREFIX "ce6230"
26#include "dvb-usb.h"
27
28#define deb_info(args...) dprintk(dvb_usb_ce6230_debug, 0x01, args)
29#define deb_rc(args...) dprintk(dvb_usb_ce6230_debug, 0x02, args)
30#define deb_xfer(args...) dprintk(dvb_usb_ce6230_debug, 0x04, args)
31#define deb_reg(args...) dprintk(dvb_usb_ce6230_debug, 0x08, args)
32#define deb_i2c(args...) dprintk(dvb_usb_ce6230_debug, 0x10, args)
33#define deb_fw(args...) dprintk(dvb_usb_ce6230_debug, 0x20, args)
34
35#define ce6230_debug_dump(r, t, v, i, b, l, func) { \
36 int loop_; \
37 func("%02x %02x %02x %02x %02x %02x %02x %02x", \
38 t, r, v & 0xff, v >> 8, i & 0xff, i >> 8, l & 0xff, l >> 8); \
39 if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \
40 func(" >>> "); \
41 else \
42 func(" <<< "); \
43 for (loop_ = 0; loop_ < l; loop_++) \
44 func("%02x ", b[loop_]); \
45 func("\n");\
46}
47
48#define CE6230_USB_TIMEOUT 1000
49
50struct req_t {
51 u8 cmd; /* [1] */
52 u16 value; /* [2|3] */
53 u16 index; /* [4|5] */
54 u16 data_len; /* [6|7] */
55 u8 *data;
56};
57
58enum ce6230_cmd {
59 CONFIG_READ = 0xd0, /* rd 0 (unclear) */
60 UNKNOWN_WRITE = 0xc7, /* wr 7 (unclear) */
61 I2C_READ = 0xd9, /* rd 9 (unclear) */
62 I2C_WRITE = 0xca, /* wr a */
63 DEMOD_READ = 0xdb, /* rd b */
64 DEMOD_WRITE = 0xcc, /* wr c */
65 REG_READ = 0xde, /* rd e */
66 REG_WRITE = 0xcf, /* wr f */
67};
68
69#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 3dfb271741f6..0f239c668c51 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -33,6 +33,7 @@
33#define USB_VID_HANFTEK 0x15f4 33#define USB_VID_HANFTEK 0x15f4
34#define USB_VID_HAUPPAUGE 0x2040 34#define USB_VID_HAUPPAUGE 0x2040
35#define USB_VID_HYPER_PALTEK 0x1025 35#define USB_VID_HYPER_PALTEK 0x1025
36#define USB_VID_INTEL 0x8086
36#define USB_VID_KWORLD 0xeb2a 37#define USB_VID_KWORLD 0xeb2a
37#define USB_VID_KWORLD_2 0x1b80 38#define USB_VID_KWORLD_2 0x1b80
38#define USB_VID_KYE 0x0458 39#define USB_VID_KYE 0x0458
@@ -96,6 +97,7 @@
96#define USB_PID_UNIWILL_STK7700P 0x6003 97#define USB_PID_UNIWILL_STK7700P 0x6003
97#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 98#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
98#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 99#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
100#define USB_PID_INTEL_CE9500 0x9500
99#define USB_PID_KWORLD_399U 0xe399 101#define USB_PID_KWORLD_399U 0xe399
100#define USB_PID_KWORLD_395U 0xe396 102#define USB_PID_KWORLD_395U 0xe396
101#define USB_PID_KWORLD_395U_2 0xe39b 103#define USB_PID_KWORLD_395U_2 0xe39b