diff options
author | Antti Palosaari <crope@iki.fi> | 2009-11-13 20:38:55 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:41:33 -0500 |
commit | 2bf290be4f3ef11889026d750244cc3bd1164974 (patch) | |
tree | 4ea4ed24cd302299dd86f29ed92c567e145cbe64 | |
parent | a15c7b42b2b8eda719920e93b81be031f2e0b01b (diff) |
V4L/DVB (13364): ec168: add new driver for E3C EC168 DVB USB
E3C EC168 DVB USB driver
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/dvb-usb/Kconfig | 8 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/Makefile | 3 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 6 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/ec168.c | 440 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/ec168.h | 73 |
5 files changed, 530 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 0e4b97fba384..2dee1bf73577 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -322,3 +322,11 @@ config DVB_USB_FRIIO | |||
322 | depends on DVB_USB | 322 | depends on DVB_USB |
323 | help | 323 | help |
324 | Say Y here to support the Japanese DTV receiver Friio. | 324 | Say Y here to support the Japanese DTV receiver Friio. |
325 | |||
326 | config DVB_USB_EC168 | ||
327 | tristate "E3C EC168 DVB-T USB2.0 support" | ||
328 | depends on DVB_USB && EXPERIMENTAL | ||
329 | select DVB_EC100 | ||
330 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE | ||
331 | help | ||
332 | Say Y here to support the E3C EC168 DVB-T USB2.0 receiver. | ||
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 85b83a43d55d..72c92cb69a22 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile | |||
@@ -82,6 +82,9 @@ obj-$(CONFIG_DVB_USB_CE6230) += dvb-usb-ce6230.o | |||
82 | dvb-usb-friio-objs = friio.o friio-fe.o | 82 | dvb-usb-friio-objs = friio.o friio-fe.o |
83 | obj-$(CONFIG_DVB_USB_FRIIO) += dvb-usb-friio.o | 83 | obj-$(CONFIG_DVB_USB_FRIIO) += dvb-usb-friio.o |
84 | 84 | ||
85 | dvb-usb-ec168-objs = ec168.o | ||
86 | obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o | ||
87 | |||
85 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | 88 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ |
86 | # due to tuner-xc3028 | 89 | # due to tuner-xc3028 |
87 | EXTRA_CFLAGS += -Idrivers/media/common/tuners | 90 | EXTRA_CFLAGS += -Idrivers/media/common/tuners |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 128fca63df95..491440d6e652 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define USB_VID_DIBCOM 0x10b8 | 27 | #define USB_VID_DIBCOM 0x10b8 |
28 | #define USB_VID_DPOSH 0x1498 | 28 | #define USB_VID_DPOSH 0x1498 |
29 | #define USB_VID_DVICO 0x0fe9 | 29 | #define USB_VID_DVICO 0x0fe9 |
30 | #define USB_VID_E3C 0x18b4 | ||
30 | #define USB_VID_ELGATO 0x0fd9 | 31 | #define USB_VID_ELGATO 0x0fd9 |
31 | #define USB_VID_EMPIA 0xeb1a | 32 | #define USB_VID_EMPIA 0xeb1a |
32 | #define USB_VID_GENPIX 0x09c0 | 33 | #define USB_VID_GENPIX 0x09c0 |
@@ -104,6 +105,11 @@ | |||
104 | #define USB_PID_DIBCOM_STK7770P 0x1e80 | 105 | #define USB_PID_DIBCOM_STK7770P 0x1e80 |
105 | #define USB_PID_DPOSH_M9206_COLD 0x9206 | 106 | #define USB_PID_DPOSH_M9206_COLD 0x9206 |
106 | #define USB_PID_DPOSH_M9206_WARM 0xa090 | 107 | #define USB_PID_DPOSH_M9206_WARM 0xa090 |
108 | #define USB_PID_E3C_EC168 0x1689 | ||
109 | #define USB_PID_E3C_EC168_2 0xfffa | ||
110 | #define USB_PID_E3C_EC168_3 0xfffb | ||
111 | #define USB_PID_E3C_EC168_4 0x1001 | ||
112 | #define USB_PID_E3C_EC168_5 0x1002 | ||
107 | #define USB_PID_UNIWILL_STK7700P 0x6003 | 113 | #define USB_PID_UNIWILL_STK7700P 0x6003 |
108 | #define USB_PID_GENIUS_TVGO_DVB_T03 0x4012 | 114 | #define USB_PID_GENIUS_TVGO_DVB_T03 0x4012 |
109 | #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 | 115 | #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 |
diff --git a/drivers/media/dvb/dvb-usb/ec168.c b/drivers/media/dvb/dvb-usb/ec168.c new file mode 100644 index 000000000000..52f5d4f0f230 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/ec168.c | |||
@@ -0,0 +1,440 @@ | |||
1 | /* | ||
2 | * E3C EC168 DVB USB driver | ||
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 "ec168.h" | ||
23 | #include "ec100.h" | ||
24 | #include "mxl5005s.h" | ||
25 | |||
26 | /* debug */ | ||
27 | static int dvb_usb_ec168_debug; | ||
28 | module_param_named(debug, dvb_usb_ec168_debug, int, 0644); | ||
29 | MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); | ||
30 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
31 | |||
32 | static struct ec100_config ec168_ec100_config; | ||
33 | |||
34 | static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req) | ||
35 | { | ||
36 | int ret; | ||
37 | unsigned int pipe; | ||
38 | u8 request, requesttype; | ||
39 | u8 buf[req->size]; | ||
40 | |||
41 | switch (req->cmd) { | ||
42 | case DOWNLOAD_FIRMWARE: | ||
43 | case GPIO: | ||
44 | case WRITE_I2C: | ||
45 | case STREAMING_CTRL: | ||
46 | requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT); | ||
47 | request = req->cmd; | ||
48 | break; | ||
49 | case READ_I2C: | ||
50 | requesttype = (USB_TYPE_VENDOR | USB_DIR_IN); | ||
51 | request = req->cmd; | ||
52 | break; | ||
53 | case GET_CONFIG: | ||
54 | requesttype = (USB_TYPE_VENDOR | USB_DIR_IN); | ||
55 | request = CONFIG; | ||
56 | break; | ||
57 | case SET_CONFIG: | ||
58 | requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT); | ||
59 | request = CONFIG; | ||
60 | break; | ||
61 | case WRITE_DEMOD: | ||
62 | requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT); | ||
63 | request = DEMOD_RW; | ||
64 | break; | ||
65 | case READ_DEMOD: | ||
66 | requesttype = (USB_TYPE_VENDOR | USB_DIR_IN); | ||
67 | request = DEMOD_RW; | ||
68 | break; | ||
69 | default: | ||
70 | err("unknown command:%02x", req->cmd); | ||
71 | ret = -EPERM; | ||
72 | goto error; | ||
73 | } | ||
74 | |||
75 | if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) { | ||
76 | /* write */ | ||
77 | memcpy(buf, req->data, req->size); | ||
78 | pipe = usb_sndctrlpipe(udev, 0); | ||
79 | } else { | ||
80 | /* read */ | ||
81 | pipe = usb_rcvctrlpipe(udev, 0); | ||
82 | } | ||
83 | |||
84 | msleep(1); /* avoid I2C errors */ | ||
85 | |||
86 | ret = usb_control_msg(udev, pipe, request, requesttype, req->value, | ||
87 | req->index, buf, sizeof(buf), EC168_USB_TIMEOUT); | ||
88 | |||
89 | ec168_debug_dump(request, requesttype, req->value, req->index, buf, | ||
90 | req->size, deb_xfer); | ||
91 | |||
92 | if (ret < 0) | ||
93 | goto error; | ||
94 | else | ||
95 | ret = 0; | ||
96 | |||
97 | /* read request, copy returned data to return buf */ | ||
98 | if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) | ||
99 | memcpy(req->data, buf, req->size); | ||
100 | |||
101 | return ret; | ||
102 | error: | ||
103 | deb_info("%s: failed:%d\n", __func__, ret); | ||
104 | return ret; | ||
105 | } | ||
106 | |||
107 | static int ec168_ctrl_msg(struct dvb_usb_device *d, struct ec168_req *req) | ||
108 | { | ||
109 | return ec168_rw_udev(d->udev, req); | ||
110 | } | ||
111 | |||
112 | /* I2C */ | ||
113 | static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | ||
114 | int num) | ||
115 | { | ||
116 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | ||
117 | struct ec168_req req; | ||
118 | int i = 0; | ||
119 | int ret; | ||
120 | |||
121 | if (num > 2) | ||
122 | return -EINVAL; | ||
123 | |||
124 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | ||
125 | return -EAGAIN; | ||
126 | |||
127 | while (i < num) { | ||
128 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { | ||
129 | if (msg[i].addr == ec168_ec100_config.demod_address) { | ||
130 | req.cmd = READ_DEMOD; | ||
131 | req.value = 0; | ||
132 | req.index = 0xff00 + msg[i].buf[0]; /* reg */ | ||
133 | req.size = msg[i+1].len; /* bytes to read */ | ||
134 | req.data = &msg[i+1].buf[0]; | ||
135 | ret = ec168_ctrl_msg(d, &req); | ||
136 | i += 2; | ||
137 | } else { | ||
138 | err("I2C read not implemented"); | ||
139 | ret = -ENOSYS; | ||
140 | i += 2; | ||
141 | } | ||
142 | } else { | ||
143 | if (msg[i].addr == ec168_ec100_config.demod_address) { | ||
144 | req.cmd = WRITE_DEMOD; | ||
145 | req.value = msg[i].buf[1]; /* val */ | ||
146 | req.index = 0xff00 + msg[i].buf[0]; /* reg */ | ||
147 | req.size = 0; | ||
148 | req.data = NULL; | ||
149 | ret = ec168_ctrl_msg(d, &req); | ||
150 | i += 1; | ||
151 | } else { | ||
152 | req.cmd = WRITE_I2C; | ||
153 | req.value = msg[i].buf[0]; /* val */ | ||
154 | req.index = 0x0100 + msg[i].addr; /* I2C addr */ | ||
155 | req.size = msg[i].len-1; | ||
156 | req.data = &msg[i].buf[1]; | ||
157 | ret = ec168_ctrl_msg(d, &req); | ||
158 | i += 1; | ||
159 | } | ||
160 | } | ||
161 | if (ret) | ||
162 | goto error; | ||
163 | |||
164 | } | ||
165 | ret = i; | ||
166 | |||
167 | error: | ||
168 | mutex_unlock(&d->i2c_mutex); | ||
169 | return i; | ||
170 | } | ||
171 | |||
172 | |||
173 | static u32 ec168_i2c_func(struct i2c_adapter *adapter) | ||
174 | { | ||
175 | return I2C_FUNC_I2C; | ||
176 | } | ||
177 | |||
178 | static struct i2c_algorithm ec168_i2c_algo = { | ||
179 | .master_xfer = ec168_i2c_xfer, | ||
180 | .functionality = ec168_i2c_func, | ||
181 | }; | ||
182 | |||
183 | /* Callbacks for DVB USB */ | ||
184 | static struct ec100_config ec168_ec100_config = { | ||
185 | .demod_address = 0xff, /* not real address, demod is integrated */ | ||
186 | }; | ||
187 | |||
188 | static int ec168_ec100_frontend_attach(struct dvb_usb_adapter *adap) | ||
189 | { | ||
190 | deb_info("%s:\n", __func__); | ||
191 | adap->fe = dvb_attach(ec100_attach, &ec168_ec100_config, | ||
192 | &adap->dev->i2c_adap); | ||
193 | if (adap->fe == NULL) | ||
194 | return -ENODEV; | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static struct mxl5005s_config ec168_mxl5003s_config = { | ||
200 | .i2c_address = 0xc6, | ||
201 | .if_freq = IF_FREQ_4570000HZ, | ||
202 | .xtal_freq = CRYSTAL_FREQ_16000000HZ, | ||
203 | .agc_mode = MXL_SINGLE_AGC, | ||
204 | .tracking_filter = MXL_TF_OFF, | ||
205 | .rssi_enable = MXL_RSSI_ENABLE, | ||
206 | .cap_select = MXL_CAP_SEL_ENABLE, | ||
207 | .div_out = MXL_DIV_OUT_4, | ||
208 | .clock_out = MXL_CLOCK_OUT_DISABLE, | ||
209 | .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, | ||
210 | .top = MXL5005S_TOP_25P2, | ||
211 | .mod_mode = MXL_DIGITAL_MODE, | ||
212 | .if_mode = MXL_ZERO_IF, | ||
213 | .AgcMasterByte = 0x00, | ||
214 | }; | ||
215 | |||
216 | static int ec168_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap) | ||
217 | { | ||
218 | deb_info("%s:\n", __func__); | ||
219 | return dvb_attach(mxl5005s_attach, adap->fe, &adap->dev->i2c_adap, | ||
220 | &ec168_mxl5003s_config) == NULL ? -ENODEV : 0; | ||
221 | } | ||
222 | |||
223 | static int ec168_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | ||
224 | { | ||
225 | struct ec168_req req = {STREAMING_CTRL, 0x7f01, 0x0202, 0, NULL}; | ||
226 | deb_info("%s: onoff:%d\n", __func__, onoff); | ||
227 | if (onoff) | ||
228 | req.index = 0x0102; | ||
229 | return ec168_ctrl_msg(adap->dev, &req); | ||
230 | } | ||
231 | |||
232 | static int ec168_download_firmware(struct usb_device *udev, | ||
233 | const struct firmware *fw) | ||
234 | { | ||
235 | int i, len, packets, remainder, ret; | ||
236 | u16 addr = 0x0000; /* firmware start address */ | ||
237 | struct ec168_req req = {DOWNLOAD_FIRMWARE, 0, 0, 0, NULL}; | ||
238 | deb_info("%s:\n", __func__); | ||
239 | |||
240 | #define FW_PACKET_MAX_DATA 2048 | ||
241 | packets = fw->size / FW_PACKET_MAX_DATA; | ||
242 | remainder = fw->size % FW_PACKET_MAX_DATA; | ||
243 | len = FW_PACKET_MAX_DATA; | ||
244 | for (i = 0; i <= packets; i++) { | ||
245 | if (i == packets) /* set size of the last packet */ | ||
246 | len = remainder; | ||
247 | |||
248 | req.size = len; | ||
249 | req.data = (u8 *)(fw->data + i * FW_PACKET_MAX_DATA); | ||
250 | req.index = addr; | ||
251 | addr += FW_PACKET_MAX_DATA; | ||
252 | |||
253 | ret = ec168_rw_udev(udev, &req); | ||
254 | if (ret) { | ||
255 | err("firmware download failed:%d packet:%d", ret, i); | ||
256 | goto error; | ||
257 | } | ||
258 | } | ||
259 | req.size = 0; | ||
260 | |||
261 | /* set "warm"? */ | ||
262 | req.cmd = SET_CONFIG; | ||
263 | req.value = 0; | ||
264 | req.index = 0x0001; | ||
265 | ret = ec168_rw_udev(udev, &req); | ||
266 | if (ret) | ||
267 | goto error; | ||
268 | |||
269 | /* really needed - no idea what does */ | ||
270 | req.cmd = GPIO; | ||
271 | req.value = 0; | ||
272 | req.index = 0x0206; | ||
273 | ret = ec168_rw_udev(udev, &req); | ||
274 | if (ret) | ||
275 | goto error; | ||
276 | |||
277 | /* activate tuner I2C? */ | ||
278 | req.cmd = WRITE_I2C; | ||
279 | req.value = 0; | ||
280 | req.index = 0x00c6; | ||
281 | ret = ec168_rw_udev(udev, &req); | ||
282 | if (ret) | ||
283 | goto error; | ||
284 | |||
285 | return ret; | ||
286 | error: | ||
287 | deb_info("%s: failed:%d\n", __func__, ret); | ||
288 | return ret; | ||
289 | } | ||
290 | |||
291 | static int ec168_identify_state(struct usb_device *udev, | ||
292 | struct dvb_usb_device_properties *props, | ||
293 | struct dvb_usb_device_description **desc, int *cold) | ||
294 | { | ||
295 | int ret; | ||
296 | u8 reply; | ||
297 | struct ec168_req req = {GET_CONFIG, 0, 1, sizeof(reply), &reply}; | ||
298 | deb_info("%s:\n", __func__); | ||
299 | |||
300 | ret = ec168_rw_udev(udev, &req); | ||
301 | if (ret) | ||
302 | goto error; | ||
303 | |||
304 | deb_info("%s: reply:%02x\n", __func__, reply); | ||
305 | |||
306 | if (reply == 0x01) | ||
307 | *cold = 0; | ||
308 | else | ||
309 | *cold = 1; | ||
310 | |||
311 | return ret; | ||
312 | error: | ||
313 | deb_info("%s: failed:%d\n", __func__, ret); | ||
314 | return ret; | ||
315 | } | ||
316 | |||
317 | /* DVB USB Driver stuff */ | ||
318 | static struct dvb_usb_device_properties ec168_properties; | ||
319 | |||
320 | static int ec168_probe(struct usb_interface *intf, | ||
321 | const struct usb_device_id *id) | ||
322 | { | ||
323 | int ret; | ||
324 | deb_info("%s: interface:%d\n", __func__, | ||
325 | intf->cur_altsetting->desc.bInterfaceNumber); | ||
326 | |||
327 | ret = dvb_usb_device_init(intf, &ec168_properties, THIS_MODULE, NULL, | ||
328 | adapter_nr); | ||
329 | if (ret) | ||
330 | goto error; | ||
331 | |||
332 | return ret; | ||
333 | error: | ||
334 | deb_info("%s: failed:%d\n", __func__, ret); | ||
335 | return ret; | ||
336 | } | ||
337 | |||
338 | #define E3C_EC168_1689 0 | ||
339 | #define E3C_EC168_FFFA 1 | ||
340 | #define E3C_EC168_FFFB 2 | ||
341 | #define E3C_EC168_1001 3 | ||
342 | #define E3C_EC168_1002 4 | ||
343 | |||
344 | static struct usb_device_id ec168_id[] = { | ||
345 | [E3C_EC168_1689] = | ||
346 | {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168)}, | ||
347 | [E3C_EC168_FFFA] = | ||
348 | {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_2)}, | ||
349 | [E3C_EC168_FFFB] = | ||
350 | {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_3)}, | ||
351 | [E3C_EC168_1001] = | ||
352 | {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_4)}, | ||
353 | [E3C_EC168_1002] = | ||
354 | {USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_5)}, | ||
355 | {} /* terminating entry */ | ||
356 | }; | ||
357 | |||
358 | MODULE_DEVICE_TABLE(usb, ec168_id); | ||
359 | |||
360 | static struct dvb_usb_device_properties ec168_properties = { | ||
361 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
362 | |||
363 | .usb_ctrl = DEVICE_SPECIFIC, | ||
364 | .download_firmware = ec168_download_firmware, | ||
365 | .firmware = "dvb-usb-ec168.fw", | ||
366 | .no_reconnect = 1, | ||
367 | |||
368 | .size_of_priv = 0, | ||
369 | |||
370 | .num_adapters = 1, | ||
371 | .adapter = { | ||
372 | { | ||
373 | .streaming_ctrl = ec168_streaming_ctrl, | ||
374 | .frontend_attach = ec168_ec100_frontend_attach, | ||
375 | .tuner_attach = ec168_mxl5003s_tuner_attach, | ||
376 | .stream = { | ||
377 | .type = USB_BULK, | ||
378 | .count = 6, | ||
379 | .endpoint = 0x82, | ||
380 | .u = { | ||
381 | .bulk = { | ||
382 | .buffersize = (32*512), | ||
383 | } | ||
384 | } | ||
385 | }, | ||
386 | } | ||
387 | }, | ||
388 | |||
389 | .identify_state = ec168_identify_state, | ||
390 | |||
391 | .i2c_algo = &ec168_i2c_algo, | ||
392 | |||
393 | .num_device_descs = 1, | ||
394 | .devices = { | ||
395 | { | ||
396 | .name = "E3C EC168 DVB-T USB2.0 reference design", | ||
397 | .cold_ids = { | ||
398 | &ec168_id[E3C_EC168_1689], | ||
399 | &ec168_id[E3C_EC168_FFFA], | ||
400 | &ec168_id[E3C_EC168_FFFB], | ||
401 | &ec168_id[E3C_EC168_1001], | ||
402 | &ec168_id[E3C_EC168_1002], | ||
403 | NULL}, | ||
404 | .warm_ids = {NULL}, | ||
405 | }, | ||
406 | } | ||
407 | }; | ||
408 | |||
409 | static struct usb_driver ec168_driver = { | ||
410 | .name = "dvb_usb_ec168", | ||
411 | .probe = ec168_probe, | ||
412 | .disconnect = dvb_usb_device_exit, | ||
413 | .id_table = ec168_id, | ||
414 | }; | ||
415 | |||
416 | /* module stuff */ | ||
417 | static int __init ec168_module_init(void) | ||
418 | { | ||
419 | int ret; | ||
420 | deb_info("%s:\n", __func__); | ||
421 | ret = usb_register(&ec168_driver); | ||
422 | if (ret) | ||
423 | err("module init failed:%d", ret); | ||
424 | |||
425 | return ret; | ||
426 | } | ||
427 | |||
428 | static void __exit ec168_module_exit(void) | ||
429 | { | ||
430 | deb_info("%s:\n", __func__); | ||
431 | /* deregister this driver from the USB subsystem */ | ||
432 | usb_deregister(&ec168_driver); | ||
433 | } | ||
434 | |||
435 | module_init(ec168_module_init); | ||
436 | module_exit(ec168_module_exit); | ||
437 | |||
438 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | ||
439 | MODULE_DESCRIPTION("E3C EC168 DVB-T USB2.0 driver"); | ||
440 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/dvb-usb/ec168.h b/drivers/media/dvb/dvb-usb/ec168.h new file mode 100644 index 000000000000..e7e0b831314e --- /dev/null +++ b/drivers/media/dvb/dvb-usb/ec168.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * E3C EC168 DVB USB driver | ||
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 EC168_H | ||
23 | #define EC168_H | ||
24 | |||
25 | #define DVB_USB_LOG_PREFIX "ec168" | ||
26 | #include "dvb-usb.h" | ||
27 | |||
28 | #define deb_info(args...) dprintk(dvb_usb_ec168_debug, 0x01, args) | ||
29 | #define deb_rc(args...) dprintk(dvb_usb_ec168_debug, 0x02, args) | ||
30 | #define deb_xfer(args...) dprintk(dvb_usb_ec168_debug, 0x04, args) | ||
31 | #define deb_reg(args...) dprintk(dvb_usb_ec168_debug, 0x08, args) | ||
32 | #define deb_i2c(args...) dprintk(dvb_usb_ec168_debug, 0x10, args) | ||
33 | #define deb_fw(args...) dprintk(dvb_usb_ec168_debug, 0x20, args) | ||
34 | |||
35 | #define ec168_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 EC168_USB_TIMEOUT 1000 | ||
49 | |||
50 | struct ec168_req { | ||
51 | u8 cmd; /* [1] */ | ||
52 | u16 value; /* [2|3] */ | ||
53 | u16 index; /* [4|5] */ | ||
54 | u16 size; /* [6|7] */ | ||
55 | u8 *data; | ||
56 | }; | ||
57 | |||
58 | enum ec168_cmd { | ||
59 | DOWNLOAD_FIRMWARE = 0x00, | ||
60 | CONFIG = 0x01, | ||
61 | DEMOD_RW = 0x03, | ||
62 | GPIO = 0x04, | ||
63 | STREAMING_CTRL = 0x10, | ||
64 | READ_I2C = 0x20, | ||
65 | WRITE_I2C = 0x21, | ||
66 | HID_DOWNLOAD = 0x30, | ||
67 | GET_CONFIG, | ||
68 | SET_CONFIG, | ||
69 | READ_DEMOD, | ||
70 | WRITE_DEMOD, | ||
71 | }; | ||
72 | |||
73 | #endif | ||