aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMalcolm Priestley <tvboxspy@gmail.com>2011-07-25 14:35:03 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-08-27 09:35:21 -0400
commitf6d8735493eb02248bc7d7b05d5967f9a68b5c44 (patch)
tree732a0d6a0107a072fc107f023c9d7f1f7420d88e /drivers
parent52cb3e2757baefddaa159c3d3157a2c4a9e5f694 (diff)
[media] it913x: Driver for Kworld UB499-2T (id 1b80:e409) v1.05
Driver for Kworld UB499-2T (id 1b80:e409) The device driver has been named it913x, so that support for other family members can be added later. TODOs Firmware support for other it913x devices. Remote control support, there are two known types. Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com> [mchehab@redhat.com: Fix a merge conflict] Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig7
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h1
-rw-r--r--drivers/media/dvb/dvb-usb/it913x.c613
4 files changed, 624 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 5d73dec8ac07..6e97bb35ba67 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -374,3 +374,10 @@ config DVB_USB_TECHNISAT_USB2
374 select DVB_STV6110x if !DVB_FE_CUSTOMISE 374 select DVB_STV6110x if !DVB_FE_CUSTOMISE
375 help 375 help
376 Say Y here to support the Technisat USB2 DVB-S/S2 device 376 Say Y here to support the Technisat USB2 DVB-S/S2 device
377
378config DVB_USB_IT913X
379 tristate "it913x driver"
380 depends on DVB_USB
381 select DVB_IT913X_FE
382 help
383 Say Y here to support the it913x device
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 4bac13da0c39..3494d410383d 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -94,6 +94,9 @@ obj-$(CONFIG_DVB_USB_LME2510) += dvb-usb-lmedm04.o
94dvb-usb-technisat-usb2-objs = technisat-usb2.o 94dvb-usb-technisat-usb2-objs = technisat-usb2.o
95obj-$(CONFIG_DVB_USB_TECHNISAT_USB2) += dvb-usb-technisat-usb2.o 95obj-$(CONFIG_DVB_USB_TECHNISAT_USB2) += dvb-usb-technisat-usb2.o
96 96
97dvb-usb-it913x-objs := it913x.o
98obj-$(CONFIG_DVB_USB_IT913X) += dvb-usb-it913x.o
99
97EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 100EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
98# due to tuner-xc3028 101# due to tuner-xc3028
99EXTRA_CFLAGS += -Idrivers/media/common/tuners 102EXTRA_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 2a79b8fb3e8d..7433261b229d 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -136,6 +136,7 @@
136#define USB_PID_KWORLD_PC160_2T 0xc160 136#define USB_PID_KWORLD_PC160_2T 0xc160
137#define USB_PID_KWORLD_PC160_T 0xc161 137#define USB_PID_KWORLD_PC160_T 0xc161
138#define USB_PID_KWORLD_UB383_T 0xe383 138#define USB_PID_KWORLD_UB383_T 0xe383
139#define USB_PID_KWORLD_UB499_2T_T09 0xe409
139#define USB_PID_KWORLD_VSTREAM_COLD 0x17de 140#define USB_PID_KWORLD_VSTREAM_COLD 0x17de
140#define USB_PID_KWORLD_VSTREAM_WARM 0x17df 141#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
141#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055 142#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055
diff --git a/drivers/media/dvb/dvb-usb/it913x.c b/drivers/media/dvb/dvb-usb/it913x.c
new file mode 100644
index 000000000000..3900068a2928
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/it913x.c
@@ -0,0 +1,613 @@
1/* DVB USB compliant linux driver for IT9137
2 *
3 * Copyright (C) 2011 Malcolm Priestley (tvboxspy@gmail.com)
4 * IT9137 (C) ITE Tech Inc.
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 Version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 *
20 * see Documentation/dvb/README.dvb-usb for more information
21 * see Documentation/dvb/it9137.txt for firmware information
22 *
23 */
24#define DVB_USB_LOG_PREFIX "it913x"
25
26#include <linux/usb.h>
27#include <linux/usb/input.h>
28#include <media/rc-core.h>
29
30#include "dvb-usb.h"
31#include "it913x-fe.h"
32
33/* debug */
34static int dvb_usb_it913x_debug;
35#define l_dprintk(var, level, args...) do { \
36 if ((var >= level)) \
37 printk(KERN_DEBUG DVB_USB_LOG_PREFIX ": " args); \
38} while (0)
39
40#define deb_info(level, args...) l_dprintk(dvb_usb_it913x_debug, level, args)
41#define debug_data_snipet(level, name, p) \
42 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
43 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
44 *(p+5), *(p+6), *(p+7));
45
46
47module_param_named(debug, dvb_usb_it913x_debug, int, 0644);
48MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))."
49 DVB_USB_DEBUG_STATUS);
50
51static int pid_filter;
52module_param_named(pid, pid_filter, int, 0644);
53MODULE_PARM_DESC(pid, "set default 0=on 1=off");
54
55int cmd_counter;
56
57DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
58
59struct it913x_state {
60 u8 id;
61};
62
63static int it913x_bulk_write(struct usb_device *dev,
64 u8 *snd, int len, u8 pipe)
65{
66 int ret, actual_l;
67
68 ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
69 snd, len , &actual_l, 100);
70 return ret;
71}
72
73static int it913x_bulk_read(struct usb_device *dev,
74 u8 *rev, int len, u8 pipe)
75{
76 int ret, actual_l;
77
78 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
79 rev, len , &actual_l, 200);
80 return ret;
81}
82
83static u16 check_sum(u8 *p, u8 len)
84{
85 u16 sum = 0;
86 u8 i = 1;
87 while (i < len)
88 sum += (i++ & 1) ? (*p++) << 8 : *p++;
89 return ~sum;
90}
91
92static int it913x_io(struct usb_device *udev, u8 mode, u8 pro,
93 u8 cmd, u32 reg, u8 addr, u8 *data, u8 len)
94{
95 int ret = 0, i, buf_size = 1;
96 u8 *buff;
97 u8 rlen;
98 u16 chk_sum;
99
100 buff = kzalloc(256, GFP_KERNEL);
101 if (!buff) {
102 info("USB Buffer Failed");
103 return -ENOMEM;
104 }
105
106 buff[buf_size++] = pro;
107 buff[buf_size++] = cmd;
108 buff[buf_size++] = cmd_counter;
109
110 switch (mode) {
111 case READ_LONG:
112 case WRITE_LONG:
113 buff[buf_size++] = len;
114 buff[buf_size++] = 2;
115 buff[buf_size++] = (reg >> 24);
116 buff[buf_size++] = (reg >> 16) & 0xff;
117 buff[buf_size++] = (reg >> 8) & 0xff;
118 buff[buf_size++] = reg & 0xff;
119 break;
120 case READ_SHORT:
121 buff[buf_size++] = addr;
122 break;
123 case WRITE_SHORT:
124 buff[buf_size++] = len;
125 buff[buf_size++] = addr;
126 buff[buf_size++] = (reg >> 8) & 0xff;
127 buff[buf_size++] = reg & 0xff;
128 break;
129 case READ_DATA:
130 case WRITE_DATA:
131 break;
132 case WRITE_CMD:
133 mode = 7;
134 break;
135 default:
136 kfree(buff);
137 return -EINVAL;
138 }
139
140 if (mode & 1) {
141 for (i = 0; i < len ; i++)
142 buff[buf_size++] = data[i];
143 }
144 chk_sum = check_sum(&buff[1], buf_size);
145
146 buff[buf_size++] = chk_sum >> 8;
147 buff[0] = buf_size;
148 buff[buf_size++] = (chk_sum & 0xff);
149
150 ret = it913x_bulk_write(udev, buff, buf_size , 0x02);
151
152 ret |= it913x_bulk_read(udev, buff, (mode & 1) ?
153 5 : len + 5 , 0x01);
154
155 rlen = (mode & 0x1) ? 0x1 : len;
156
157 if (mode & 1)
158 ret |= buff[2];
159 else
160 memcpy(data, &buff[3], rlen);
161
162 cmd_counter++;
163
164 kfree(buff);
165
166 return (ret < 0) ? -ENODEV : 0;
167}
168
169static int it913x_wr_reg(struct usb_device *udev, u8 pro, u32 reg , u8 data)
170{
171 int ret;
172 u8 b[1];
173 b[0] = data;
174 ret = it913x_io(udev, WRITE_LONG, pro,
175 CMD_DEMOD_WRITE, reg, 0, b, sizeof(b));
176
177 return ret;
178}
179
180static int it913x_read_reg(struct usb_device *udev, u32 reg)
181{
182 int ret;
183 u8 data[1];
184
185 ret = it913x_io(udev, READ_LONG, DEV_0,
186 CMD_DEMOD_READ, reg, 0, &data[0], 1);
187
188 return (ret < 0) ? ret : data[0];
189}
190
191static u32 it913x_query(struct usb_device *udev, u8 pro)
192{
193 int ret;
194 u32 res = 0;
195 u8 data[4];
196 ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ,
197 0x1222, 0, &data[0], 1);
198 if (data[0] == 0x1) {
199 ret = it913x_io(udev, READ_SHORT, pro,
200 CMD_QUERYINFO, 0, 0x1, &data[0], 4);
201 res = (data[0] << 24) + (data[1] << 16) +
202 (data[2] << 8) + data[3];
203 }
204
205 return (ret < 0) ? 0 : res;
206}
207
208static int it913x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
209{
210 int ret = 0;
211 u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
212
213 if (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0)
214 return -EAGAIN;
215 deb_info(1, "PID_C (%02x)", onoff);
216
217 if (!onoff)
218 ret = it913x_wr_reg(adap->dev->udev, pro, PID_RST, 0x1);
219
220 mutex_unlock(&adap->dev->i2c_mutex);
221 return ret;
222}
223
224static int it913x_pid_filter(struct dvb_usb_adapter *adap,
225 int index, u16 pid, int onoff)
226{
227 struct usb_device *udev = adap->dev->udev;
228 int ret = 0;
229 u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
230
231 if (pid_filter > 0)
232 return 0;
233
234 if (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0)
235 return -EAGAIN;
236 deb_info(1, "PID_F (%02x)", onoff);
237 if (onoff) {
238 ret = it913x_wr_reg(udev, pro, PID_EN, 0x1);
239
240 ret |= it913x_wr_reg(udev, pro, PID_LSB, (u8)(pid & 0xff));
241
242 ret |= it913x_wr_reg(udev, pro, PID_MSB, (u8)(pid >> 8));
243
244 ret |= it913x_wr_reg(udev, pro, PID_INX_EN, (u8)onoff);
245
246 ret |= it913x_wr_reg(udev, pro, PID_INX, (u8)(index & 0x1f));
247
248 }
249
250 mutex_unlock(&adap->dev->i2c_mutex);
251 return 0;
252}
253
254
255static int it913x_return_status(struct usb_device *udev)
256{
257 u32 firm = 0;
258
259 firm = it913x_query(udev, DEV_0);
260 if (firm > 0)
261 info("Firmware Version %d", firm);
262
263 return (firm > 0) ? firm : 0;
264}
265
266static int it913x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
267 int num)
268{
269 struct dvb_usb_device *d = i2c_get_adapdata(adap);
270 static u8 data[256];
271 int ret;
272 u32 reg;
273 u8 pro;
274 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
275 return -EAGAIN;
276
277 debug_data_snipet(1, "Message out", msg[0].buf);
278 deb_info(2, "num of messages %d address %02x", num, msg[0].addr);
279
280 pro = (msg[0].addr & 0x2) ? DEV_0_DMOD : 0x0;
281 pro |= (msg[0].addr & 0x20) ? DEV_1 : DEV_0;
282 memcpy(data, msg[0].buf, msg[0].len);
283 reg = (data[0] << 24) + (data[1] << 16) +
284 (data[2] << 8) + data[3];
285 if (num == 2) {
286 ret = it913x_io(d->udev, READ_LONG, pro,
287 CMD_DEMOD_READ, reg, 0, data, msg[1].len);
288 memcpy(msg[1].buf, data, msg[1].len);
289 } else
290 ret = it913x_io(d->udev, WRITE_LONG, pro, CMD_DEMOD_WRITE,
291 reg, 0, &data[4], msg[0].len - 4);
292
293 mutex_unlock(&d->i2c_mutex);
294
295 return ret;
296}
297
298static u32 it913x_i2c_func(struct i2c_adapter *adapter)
299{
300 return I2C_FUNC_I2C;
301}
302
303static struct i2c_algorithm it913x_i2c_algo = {
304 .master_xfer = it913x_i2c_xfer,
305 .functionality = it913x_i2c_func,
306};
307
308/* Callbacks for DVB USB */
309static int it913x_identify_state(struct usb_device *udev,
310 struct dvb_usb_device_properties *props,
311 struct dvb_usb_device_description **desc,
312 int *cold)
313{
314 int ret = 0, firm_no;
315 u8 reg, adap, ep, tun0, tun1;
316
317 firm_no = it913x_return_status(udev);
318
319 ep = it913x_read_reg(udev, 0x49ac);
320 adap = it913x_read_reg(udev, 0x49c5);
321 tun0 = it913x_read_reg(udev, 0x49d0);
322 info("No. Adapters=%x Endpoints=%x Tuner Type=%x", adap, ep, tun0);
323
324 if (firm_no > 0) {
325 *cold = 0;
326 return 0;
327 }
328
329 if (adap > 2) {
330 tun1 = it913x_read_reg(udev, 0x49e0);
331 ret = it913x_wr_reg(udev, DEV_0, GPIOH1_EN, 0x1);
332 ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_ON, 0x1);
333 ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_O, 0x1);
334 msleep(50); /* Delay noticed reset cycle ? */
335 ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_O, 0x0);
336 msleep(50);
337 reg = it913x_read_reg(udev, GPIOH1_O);
338 if (reg == 0) {
339 ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_O, 0x1);
340 ret |= it913x_return_status(udev);
341 if (ret != 0)
342 ret = it913x_wr_reg(udev, DEV_0,
343 GPIOH1_O, 0x0);
344 }
345 } else
346 props->num_adapters = 1;
347
348 reg = it913x_read_reg(udev, IO_MUX_POWER_CLK);
349
350 ret |= it913x_wr_reg(udev, DEV_0, 0x4bfb, CHIP2_I2C_ADDR);
351
352 ret |= it913x_wr_reg(udev, DEV_0, CLK_O_EN, 0x1);
353
354 *cold = 1;
355
356 return (ret < 0) ? -ENODEV : 0;
357}
358
359static int it913x_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
360{
361 int ret = 0;
362 u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
363
364 if (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0)
365 return -EAGAIN;
366 deb_info(1, "STM (%02x)", onoff);
367
368 if (!onoff)
369 ret = it913x_wr_reg(adap->dev->udev, pro, PID_RST, 0x1);
370
371
372 mutex_unlock(&adap->dev->i2c_mutex);
373
374 return ret;
375}
376
377
378static int it913x_download_firmware(struct usb_device *udev,
379 const struct firmware *fw)
380{
381 int ret = 0, i;
382 u8 packet_size, dlen, tun1;
383 u8 *fw_data;
384
385 packet_size = 0x29;
386
387 tun1 = it913x_read_reg(udev, 0x49e0);
388
389 ret = it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_100);
390
391 info("FRM Starting Firmware Download");
392 /* This uses scatter write firmware headers follow */
393 /* 03 XX 00 XX = chip number? */
394
395 for (i = 0; i < fw->size; i += packet_size) {
396 if (i > 0)
397 packet_size = 0x39;
398 fw_data = (u8 *)(fw->data + i);
399 dlen = ((i + packet_size) > fw->size)
400 ? (fw->size - i) : packet_size;
401 ret |= it913x_io(udev, WRITE_DATA, DEV_0,
402 CMD_SCATTER_WRITE, 0, 0, fw_data, dlen);
403 udelay(1000);
404 }
405
406 ret |= it913x_io(udev, WRITE_CMD, DEV_0,
407 CMD_BOOT, 0, 0, NULL, 0);
408
409 msleep(100);
410
411 if (ret < 0)
412 info("FRM Firmware Download Failed (%04x)" , ret);
413 else
414 info("FRM Firmware Download Completed - Resetting Device");
415
416 ret |= it913x_return_status(udev);
417
418 msleep(30);
419
420 ret |= it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400);
421
422 /* Tuner function */
423 ret |= it913x_wr_reg(udev, DEV_0_DMOD , 0xec4c, 0xa0);
424
425 ret |= it913x_wr_reg(udev, DEV_0, PADODPU, 0x0);
426 ret |= it913x_wr_reg(udev, DEV_0, AGC_O_D, 0x0);
427 if (tun1 > 0) {
428 ret |= it913x_wr_reg(udev, DEV_1, PADODPU, 0x0);
429 ret |= it913x_wr_reg(udev, DEV_1, AGC_O_D, 0x0);
430 }
431
432 return (ret < 0) ? -ENODEV : 0;
433}
434
435static int it913x_name(struct dvb_usb_adapter *adap)
436{
437 const char *desc = adap->dev->desc->name;
438 char *fe_name[] = {"_1", "_2", "_3", "_4"};
439 char *name = adap->fe[0]->ops.info.name;
440
441 strlcpy(name, desc, 128);
442 strlcat(name, fe_name[adap->id], 128);
443
444 return 0;
445}
446
447static int it913x_frontend_attach(struct dvb_usb_adapter *adap)
448{
449 struct usb_device *udev = adap->dev->udev;
450 int ret = 0;
451 u8 adf = it913x_read_reg(udev, IO_MUX_POWER_CLK);
452 u8 adap_addr = I2C_BASE_ADDR + (adap->id << 5);
453 u16 ep_size = adap->props.stream.u.bulk.buffersize;
454
455 adap->fe[0] = dvb_attach(it913x_fe_attach,
456 &adap->dev->i2c_adap, adap_addr, adf, IT9137);
457
458 if (adap->id == 0 && adap->fe[0]) {
459 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2_SW_RST, 0x1);
460 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_SW_RST, 0x1);
461 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_EN, 0x0f);
462 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_NAK, 0x1b);
463 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_EN, 0x2f);
464 ret = it913x_wr_reg(udev, DEV_0, EP4_TX_LEN_LSB,
465 ep_size & 0xff);
466 ret = it913x_wr_reg(udev, DEV_0, EP4_TX_LEN_MSB, ep_size >> 8);
467 ret = it913x_wr_reg(udev, DEV_0, EP4_MAX_PKT, 0x80);
468 } else if (adap->id == 1 && adap->fe[0]) {
469 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_EN, 0x6f);
470 ret = it913x_wr_reg(udev, DEV_0, EP5_TX_LEN_LSB,
471 ep_size & 0xff);
472 ret = it913x_wr_reg(udev, DEV_0, EP5_TX_LEN_MSB, ep_size >> 8);
473 ret = it913x_wr_reg(udev, DEV_0, EP5_MAX_PKT, 0x80);
474 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_EN, 0x1);
475 ret = it913x_wr_reg(udev, DEV_1_DMOD, MP2IF_SERIAL, 0x1);
476 ret = it913x_wr_reg(udev, DEV_1, TOP_HOSTB_SER_MODE, 0x1);
477 ret = it913x_wr_reg(udev, DEV_0_DMOD, TSIS_ENABLE, 0x1);
478 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2_SW_RST, 0x0);
479 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_SW_RST, 0x0);
480 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_HALF_PSB, 0x0);
481 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF_STOP_EN, 0x1);
482 ret = it913x_wr_reg(udev, DEV_1_DMOD, MPEG_FULL_SPEED, 0x0);
483 ret = it913x_wr_reg(udev, DEV_1_DMOD, MP2IF_STOP_EN, 0x0);
484 } else
485 return -ENODEV;
486
487 ret = it913x_name(adap);
488
489 return ret;
490}
491
492/* DVB USB Driver */
493static struct dvb_usb_device_properties it913x_properties;
494
495static int it913x_probe(struct usb_interface *intf,
496 const struct usb_device_id *id)
497{
498 cmd_counter = 0;
499 if (0 == dvb_usb_device_init(intf, &it913x_properties,
500 THIS_MODULE, NULL, adapter_nr)) {
501 info("DEV registering device driver");
502 return 0;
503 }
504
505 info("DEV it913x Error");
506 return -ENODEV;
507
508}
509
510static struct usb_device_id it913x_table[] = {
511 { USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09) },
512 {} /* Terminating entry */
513};
514
515MODULE_DEVICE_TABLE(usb, it913x_table);
516
517static struct dvb_usb_device_properties it913x_properties = {
518 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
519 .usb_ctrl = DEVICE_SPECIFIC,
520 .download_firmware = it913x_download_firmware,
521 .firmware = "dvb-usb-it9137-01.fw",
522 .no_reconnect = 1,
523 .size_of_priv = sizeof(struct it913x_state),
524 .num_adapters = 2,
525 .adapter = {
526 {
527 .caps = DVB_USB_ADAP_HAS_PID_FILTER|
528 DVB_USB_ADAP_NEED_PID_FILTERING|
529 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
530 .streaming_ctrl = it913x_streaming_ctrl,
531 .pid_filter_count = 31,
532 .pid_filter = it913x_pid_filter,
533 .pid_filter_ctrl = it913x_pid_filter_ctrl,
534 .frontend_attach = it913x_frontend_attach,
535 /* parameter for the MPEG2-data transfer */
536 .stream = {
537 .type = USB_BULK,
538 .count = 10,
539 .endpoint = 0x04,
540 .u = {/* Keep Low if PID filter on */
541 .bulk = {
542 .buffersize = 3584,
543
544 }
545 }
546 }
547 },
548 {
549 .caps = DVB_USB_ADAP_HAS_PID_FILTER|
550 DVB_USB_ADAP_NEED_PID_FILTERING|
551 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
552 .streaming_ctrl = it913x_streaming_ctrl,
553 .pid_filter_count = 31,
554 .pid_filter = it913x_pid_filter,
555 .pid_filter_ctrl = it913x_pid_filter_ctrl,
556 .frontend_attach = it913x_frontend_attach,
557 /* parameter for the MPEG2-data transfer */
558 .stream = {
559 .type = USB_BULK,
560 .count = 5,
561 .endpoint = 0x05,
562 .u = {
563 .bulk = {
564 .buffersize = 3584,
565
566 }
567 }
568 }
569 }
570 },
571 .identify_state = it913x_identify_state,
572 .i2c_algo = &it913x_i2c_algo,
573 .num_device_descs = 1,
574 .devices = {
575 { "Kworld UB499-2T T09(IT9137)",
576 { &it913x_table[0], NULL },
577 },
578
579 }
580};
581
582static struct usb_driver it913x_driver = {
583 .name = "it913x",
584 .probe = it913x_probe,
585 .disconnect = dvb_usb_device_exit,
586 .id_table = it913x_table,
587};
588
589/* module stuff */
590static int __init it913x_module_init(void)
591{
592 int result = usb_register(&it913x_driver);
593 if (result) {
594 err("usb_register failed. Error number %d", result);
595 return result;
596 }
597
598 return 0;
599}
600
601static void __exit it913x_module_exit(void)
602{
603 /* deregister this driver from the USB subsystem */
604 usb_deregister(&it913x_driver);
605}
606
607module_init(it913x_module_init);
608module_exit(it913x_module_exit);
609
610MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
611MODULE_DESCRIPTION("it913x USB 2 Driver");
612MODULE_VERSION("1.05");
613MODULE_LICENSE("GPL");