Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / media / dvb / dvb-usb / it913x.c
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 */
34 static 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
47 module_param_named(debug, dvb_usb_it913x_debug, int, 0644);
48 MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))."
49                         DVB_USB_DEBUG_STATUS);
50
51 static int pid_filter;
52 module_param_named(pid, pid_filter, int, 0644);
53 MODULE_PARM_DESC(pid, "set default 0=on 1=off");
54
55 int cmd_counter;
56
57 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
58
59 struct it913x_state {
60         u8 id;
61 };
62
63 struct ite_config {
64         u8 chip_ver;
65         u16 chip_type;
66         u32 firmware;
67         u8 tuner_id_0;
68         u8 tuner_id_1;
69         u8 dual_mode;
70 };
71
72 struct ite_config it913x_config;
73
74 static int it913x_bulk_write(struct usb_device *dev,
75                                 u8 *snd, int len, u8 pipe)
76 {
77         int ret, actual_l;
78
79         ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
80                                 snd, len , &actual_l, 100);
81         return ret;
82 }
83
84 static int it913x_bulk_read(struct usb_device *dev,
85                                 u8 *rev, int len, u8 pipe)
86 {
87         int ret, actual_l;
88
89         ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
90                                  rev, len , &actual_l, 200);
91         return ret;
92 }
93
94 static u16 check_sum(u8 *p, u8 len)
95 {
96         u16 sum = 0;
97         u8 i = 1;
98         while (i < len)
99                 sum += (i++ & 1) ? (*p++) << 8 : *p++;
100         return ~sum;
101 }
102
103 static int it913x_io(struct usb_device *udev, u8 mode, u8 pro,
104                         u8 cmd, u32 reg, u8 addr, u8 *data, u8 len)
105 {
106         int ret = 0, i, buf_size = 1;
107         u8 *buff;
108         u8 rlen;
109         u16 chk_sum;
110
111         buff = kzalloc(256, GFP_KERNEL);
112         if (!buff) {
113                 info("USB Buffer Failed");
114                 return -ENOMEM;
115         }
116
117         buff[buf_size++] = pro;
118         buff[buf_size++] = cmd;
119         buff[buf_size++] = cmd_counter;
120
121         switch (mode) {
122         case READ_LONG:
123         case WRITE_LONG:
124                 buff[buf_size++] = len;
125                 buff[buf_size++] = 2;
126                 buff[buf_size++] = (reg >> 24);
127                 buff[buf_size++] = (reg >> 16) & 0xff;
128                 buff[buf_size++] = (reg >> 8) & 0xff;
129                 buff[buf_size++] = reg & 0xff;
130         break;
131         case READ_SHORT:
132                 buff[buf_size++] = addr;
133                 break;
134         case WRITE_SHORT:
135                 buff[buf_size++] = len;
136                 buff[buf_size++] = addr;
137                 buff[buf_size++] = (reg >> 8) & 0xff;
138                 buff[buf_size++] = reg & 0xff;
139         break;
140         case READ_DATA:
141         case WRITE_DATA:
142                 break;
143         case WRITE_CMD:
144                 mode = 7;
145                 break;
146         default:
147                 kfree(buff);
148                 return -EINVAL;
149         }
150
151         if (mode & 1) {
152                 for (i = 0; i < len ; i++)
153                         buff[buf_size++] = data[i];
154         }
155         chk_sum = check_sum(&buff[1], buf_size);
156
157         buff[buf_size++] = chk_sum >> 8;
158         buff[0] = buf_size;
159         buff[buf_size++] = (chk_sum & 0xff);
160
161         ret = it913x_bulk_write(udev, buff, buf_size , 0x02);
162
163         ret |= it913x_bulk_read(udev, buff, (mode & 1) ?
164                         5 : len + 5 , 0x01);
165
166         rlen = (mode & 0x1) ? 0x1 : len;
167
168         if (mode & 1)
169                 ret |= buff[2];
170         else
171                 memcpy(data, &buff[3], rlen);
172
173         cmd_counter++;
174
175         kfree(buff);
176
177         return (ret < 0) ? -ENODEV : 0;
178 }
179
180 static int it913x_wr_reg(struct usb_device *udev, u8 pro, u32 reg , u8 data)
181 {
182         int ret;
183         u8 b[1];
184         b[0] = data;
185         ret = it913x_io(udev, WRITE_LONG, pro,
186                         CMD_DEMOD_WRITE, reg, 0, b, sizeof(b));
187
188         return ret;
189 }
190
191 static int it913x_read_reg(struct usb_device *udev, u32 reg)
192 {
193         int ret;
194         u8 data[1];
195
196         ret = it913x_io(udev, READ_LONG, DEV_0,
197                         CMD_DEMOD_READ, reg, 0, &data[0], 1);
198
199         return (ret < 0) ? ret : data[0];
200 }
201
202 static u32 it913x_query(struct usb_device *udev, u8 pro)
203 {
204         int ret;
205         u8 data[4];
206         ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ,
207                 0x1222, 0, &data[0], 3);
208
209         it913x_config.chip_ver = data[0];
210         it913x_config.chip_type = (u16)(data[2] << 8) + data[1];
211
212         info("Chip Version=%02x Chip Type=%04x", it913x_config.chip_ver,
213                 it913x_config.chip_type);
214
215         ret |= it913x_io(udev, READ_SHORT, pro,
216                         CMD_QUERYINFO, 0, 0x1, &data[0], 4);
217
218         it913x_config.firmware = (data[0] << 24) + (data[1] << 16) +
219                         (data[2] << 8) + data[3];
220
221         return (ret < 0) ? 0 : it913x_config.firmware;
222 }
223
224 static int it913x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
225 {
226         int ret = 0;
227         u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
228
229         if (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0)
230                         return -EAGAIN;
231         deb_info(1, "PID_C  (%02x)", onoff);
232
233         if (!onoff)
234                 ret = it913x_wr_reg(adap->dev->udev, pro, PID_RST, 0x1);
235
236         mutex_unlock(&adap->dev->i2c_mutex);
237         return ret;
238 }
239
240 static int it913x_pid_filter(struct dvb_usb_adapter *adap,
241                 int index, u16 pid, int onoff)
242 {
243         struct usb_device *udev = adap->dev->udev;
244         int ret = 0;
245         u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
246
247         if (pid_filter > 0)
248                 return 0;
249
250         if (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0)
251                         return -EAGAIN;
252         deb_info(1, "PID_F  (%02x)", onoff);
253         if (onoff) {
254                 ret = it913x_wr_reg(udev, pro, PID_EN, 0x1);
255
256                 ret |= it913x_wr_reg(udev, pro, PID_LSB, (u8)(pid & 0xff));
257
258                 ret |= it913x_wr_reg(udev, pro, PID_MSB, (u8)(pid >> 8));
259
260                 ret |= it913x_wr_reg(udev, pro, PID_INX_EN, (u8)onoff);
261
262                 ret |= it913x_wr_reg(udev, pro, PID_INX, (u8)(index & 0x1f));
263
264         }
265
266         mutex_unlock(&adap->dev->i2c_mutex);
267         return 0;
268 }
269
270
271 static int it913x_return_status(struct usb_device *udev)
272 {
273         u32 firm = 0;
274
275         firm = it913x_query(udev, DEV_0);
276         if (firm > 0)
277                 info("Firmware Version %d", firm);
278
279         return (firm > 0) ? firm : 0;
280 }
281
282 static int it913x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
283                                  int num)
284 {
285         struct dvb_usb_device *d = i2c_get_adapdata(adap);
286         static u8 data[256];
287         int ret;
288         u32 reg;
289         u8 pro;
290         if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
291                         return -EAGAIN;
292
293         debug_data_snipet(1, "Message out", msg[0].buf);
294         deb_info(2, "num of messages %d address %02x", num, msg[0].addr);
295
296         pro = (msg[0].addr & 0x2) ?  DEV_0_DMOD : 0x0;
297         pro |= (msg[0].addr & 0x20) ? DEV_1 : DEV_0;
298         memcpy(data, msg[0].buf, msg[0].len);
299         reg = (data[0] << 24) + (data[1] << 16) +
300                         (data[2] << 8) + data[3];
301         if (num == 2) {
302                 ret = it913x_io(d->udev, READ_LONG, pro,
303                         CMD_DEMOD_READ, reg, 0, data, msg[1].len);
304                 memcpy(msg[1].buf, data, msg[1].len);
305         } else
306                 ret = it913x_io(d->udev, WRITE_LONG, pro, CMD_DEMOD_WRITE,
307                         reg, 0, &data[4], msg[0].len - 4);
308
309         mutex_unlock(&d->i2c_mutex);
310
311         return ret;
312 }
313
314 static u32 it913x_i2c_func(struct i2c_adapter *adapter)
315 {
316         return I2C_FUNC_I2C;
317 }
318
319 static struct i2c_algorithm it913x_i2c_algo = {
320         .master_xfer   = it913x_i2c_xfer,
321         .functionality = it913x_i2c_func,
322 };
323
324 /* Callbacks for DVB USB */
325 #define IT913X_POLL 250
326 static int it913x_rc_query(struct dvb_usb_device *d)
327 {
328         u8 ibuf[4];
329         int ret;
330         u32 key;
331         /* Avoid conflict with frontends*/
332         if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
333                         return -EAGAIN;
334
335         ret = it913x_io(d->udev, READ_LONG, PRO_LINK, CMD_IR_GET,
336                 0, 0, &ibuf[0], sizeof(ibuf));
337
338         if ((ibuf[2] + ibuf[3]) == 0xff) {
339                 key = ibuf[2];
340                 key += ibuf[0] << 8;
341                 deb_info(1, "INT Key =%08x", key);
342                 if (d->rc_dev != NULL)
343                         rc_keydown(d->rc_dev, key, 0);
344         }
345         mutex_unlock(&d->i2c_mutex);
346
347         return ret;
348 }
349 static int it913x_identify_state(struct usb_device *udev,
350                 struct dvb_usb_device_properties *props,
351                 struct dvb_usb_device_description **desc,
352                 int *cold)
353 {
354         int ret = 0, firm_no;
355         u8 reg, remote;
356
357         firm_no = it913x_return_status(udev);
358
359         /* checnk for dual mode */
360         it913x_config.dual_mode =  it913x_read_reg(udev, 0x49c5);
361
362         /* TODO different remotes */
363         remote = it913x_read_reg(udev, 0x49ac); /* Remote */
364         if (remote == 0)
365                 props->rc.core.rc_codes = NULL;
366
367         /* TODO at the moment tuner_id is always assigned to 0x38 */
368         it913x_config.tuner_id_0 = it913x_read_reg(udev, 0x49d0);
369
370         info("Dual mode=%x Remote=%x Tuner Type=%x", it913x_config.dual_mode
371                 , remote, it913x_config.tuner_id_0);
372
373         if (firm_no > 0) {
374                 *cold = 0;
375                 return 0;
376         }
377
378         if (it913x_config.dual_mode) {
379                 it913x_config.tuner_id_1 = it913x_read_reg(udev, 0x49e0);
380                 ret = it913x_wr_reg(udev, DEV_0, GPIOH1_EN, 0x1);
381                 ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_ON, 0x1);
382                 ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_O, 0x1);
383                 msleep(50);
384                 ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_O, 0x0);
385                 msleep(50);
386                 reg = it913x_read_reg(udev, GPIOH1_O);
387                 if (reg == 0) {
388                         ret |= it913x_wr_reg(udev, DEV_0,  GPIOH1_O, 0x1);
389                         ret |= it913x_return_status(udev);
390                         if (ret != 0)
391                                 ret = it913x_wr_reg(udev, DEV_0,
392                                         GPIOH1_O, 0x0);
393                 }
394                 props->num_adapters = 2;
395         } else
396                 props->num_adapters = 1;
397
398         reg = it913x_read_reg(udev, IO_MUX_POWER_CLK);
399
400         if (it913x_config.dual_mode) {
401                 ret |= it913x_wr_reg(udev, DEV_0, 0x4bfb, CHIP2_I2C_ADDR);
402                 ret |= it913x_wr_reg(udev, DEV_0,  CLK_O_EN, 0x1);
403         } else {
404                 ret |= it913x_wr_reg(udev, DEV_0, 0x4bfb, 0x0);
405                 ret |= it913x_wr_reg(udev, DEV_0,  CLK_O_EN, 0x0);
406         }
407
408         *cold = 1;
409
410         return (ret < 0) ? -ENODEV : 0;
411 }
412
413 static int it913x_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
414 {
415         int ret = 0;
416         u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
417
418         if (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0)
419                         return -EAGAIN;
420         deb_info(1, "STM  (%02x)", onoff);
421
422         if (!onoff)
423                 ret = it913x_wr_reg(adap->dev->udev, pro, PID_RST, 0x1);
424
425
426         mutex_unlock(&adap->dev->i2c_mutex);
427
428         return ret;
429 }
430
431
432 static int it913x_download_firmware(struct usb_device *udev,
433                                         const struct firmware *fw)
434 {
435         int ret = 0, i;
436         u8 packet_size, dlen;
437         u8 *fw_data;
438
439         packet_size = 0x29;
440
441         ret = it913x_wr_reg(udev, DEV_0,  I2C_CLK, I2C_CLK_100);
442
443         info("FRM Starting Firmware Download");
444         /* This uses scatter write firmware headers follow */
445         /* 03 XX 00     XX = chip number? */ 
446
447         for (i = 0; i < fw->size; i += packet_size) {
448                         if (i > 0)
449                                 packet_size = 0x39;
450                         fw_data = (u8 *)(fw->data + i);
451                         dlen = ((i + packet_size) > fw->size)
452                                 ? (fw->size - i) : packet_size;
453                         ret |= it913x_io(udev, WRITE_DATA, DEV_0,
454                                 CMD_SCATTER_WRITE, 0, 0, fw_data, dlen);
455                         udelay(1000);
456         }
457
458         ret |= it913x_io(udev, WRITE_CMD, DEV_0,
459                         CMD_BOOT, 0, 0, NULL, 0);
460
461         msleep(100);
462
463         if (ret < 0)
464                 info("FRM Firmware Download Failed (%04x)" , ret);
465         else
466                 info("FRM Firmware Download Completed - Resetting Device");
467
468         ret |= it913x_return_status(udev);
469
470         msleep(30);
471
472         ret |= it913x_wr_reg(udev, DEV_0,  I2C_CLK, I2C_CLK_400);
473
474         /* Tuner function */
475         if (it913x_config.dual_mode)
476                 ret |= it913x_wr_reg(udev, DEV_0_DMOD , 0xec4c, 0xa0);
477
478         ret |= it913x_wr_reg(udev, DEV_0,  PADODPU, 0x0);
479         ret |= it913x_wr_reg(udev, DEV_0,  AGC_O_D, 0x0);
480         if (it913x_config.dual_mode) {
481                 ret |= it913x_wr_reg(udev, DEV_1,  PADODPU, 0x0);
482                 ret |= it913x_wr_reg(udev, DEV_1,  AGC_O_D, 0x0);
483         }
484
485         return (ret < 0) ? -ENODEV : 0;
486 }
487
488 static int it913x_name(struct dvb_usb_adapter *adap)
489 {
490         const char *desc = adap->dev->desc->name;
491         char *fe_name[] = {"_1", "_2", "_3", "_4"};
492         char *name = adap->fe_adap[0].fe->ops.info.name;
493
494         strlcpy(name, desc, 128);
495         strlcat(name, fe_name[adap->id], 128);
496
497         return 0;
498 }
499
500 static int it913x_frontend_attach(struct dvb_usb_adapter *adap)
501 {
502         struct usb_device *udev = adap->dev->udev;
503         int ret = 0;
504         u8 adf = it913x_read_reg(udev, IO_MUX_POWER_CLK);
505         u8 adap_addr = I2C_BASE_ADDR + (adap->id << 5);
506         u16 ep_size = adap->props.fe[0].stream.u.bulk.buffersize;
507         u8 tuner_id, tuner_type;
508
509         if (adap->id == 0)
510                 tuner_id = it913x_config.tuner_id_0;
511         else
512                 tuner_id = it913x_config.tuner_id_1;
513
514         /* TODO we always use IT9137 possible references here*/
515         /* Documentation suggests don't care */
516         switch (tuner_id) {
517         case 0x51:
518         case 0x52:
519         case 0x60:
520         case 0x61:
521         case 0x62:
522         default:
523         case 0x38:
524                 tuner_type = IT9137;
525         }
526
527         adap->fe_adap[0].fe = dvb_attach(it913x_fe_attach,
528                 &adap->dev->i2c_adap, adap_addr, adf, tuner_type);
529
530         if (adap->id == 0 && adap->fe_adap[0].fe) {
531                 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2_SW_RST, 0x1);
532                 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_SW_RST, 0x1);
533                 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_EN, 0x0f);
534                 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_NAK, 0x1b);
535                 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_EN, 0x2f);
536                 ret = it913x_wr_reg(udev, DEV_0, EP4_TX_LEN_LSB,
537                                         ep_size & 0xff);
538                 ret = it913x_wr_reg(udev, DEV_0, EP4_TX_LEN_MSB, ep_size >> 8);
539                 ret = it913x_wr_reg(udev, DEV_0, EP4_MAX_PKT, 0x80);
540         } else if (adap->id == 1 && adap->fe_adap[0].fe) {
541                 ret = it913x_wr_reg(udev, DEV_0, EP0_TX_EN, 0x6f);
542                 ret = it913x_wr_reg(udev, DEV_0, EP5_TX_LEN_LSB,
543                                         ep_size & 0xff);
544                 ret = it913x_wr_reg(udev, DEV_0, EP5_TX_LEN_MSB, ep_size >> 8);
545                 ret = it913x_wr_reg(udev, DEV_0, EP5_MAX_PKT, 0x80);
546                 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_EN, 0x1);
547                 ret = it913x_wr_reg(udev, DEV_1_DMOD, MP2IF_SERIAL, 0x1);
548                 ret = it913x_wr_reg(udev, DEV_1, TOP_HOSTB_SER_MODE, 0x1);
549                 ret = it913x_wr_reg(udev, DEV_0_DMOD, TSIS_ENABLE, 0x1);
550                 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2_SW_RST, 0x0);
551                 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_SW_RST, 0x0);
552                 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF2_HALF_PSB, 0x0);
553                 ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2IF_STOP_EN, 0x1);
554                 ret = it913x_wr_reg(udev, DEV_1_DMOD, MPEG_FULL_SPEED, 0x0);
555                 ret = it913x_wr_reg(udev, DEV_1_DMOD, MP2IF_STOP_EN, 0x0);
556         } else
557                 return -ENODEV;
558
559         ret = it913x_name(adap);
560
561         return ret;
562 }
563
564 /* DVB USB Driver */
565 static struct dvb_usb_device_properties it913x_properties;
566
567 static int it913x_probe(struct usb_interface *intf,
568                 const struct usb_device_id *id)
569 {
570         cmd_counter = 0;
571         if (0 == dvb_usb_device_init(intf, &it913x_properties,
572                                      THIS_MODULE, NULL, adapter_nr)) {
573                 info("DEV registering device driver");
574                 return 0;
575         }
576
577         info("DEV it913x Error");
578         return -ENODEV;
579
580 }
581
582 static struct usb_device_id it913x_table[] = {
583         { USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09) },
584         { USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135) },
585         {}              /* Terminating entry */
586 };
587
588 MODULE_DEVICE_TABLE(usb, it913x_table);
589
590 static struct dvb_usb_device_properties it913x_properties = {
591         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
592         .usb_ctrl = DEVICE_SPECIFIC,
593         .download_firmware = it913x_download_firmware,
594         .firmware = "dvb-usb-it9137-01.fw",
595         .no_reconnect = 1,
596         .size_of_priv = sizeof(struct it913x_state),
597         .num_adapters = 2,
598         .adapter = {
599                 {
600                 .num_frontends = 1,
601                 .fe = {{
602                         .caps = DVB_USB_ADAP_HAS_PID_FILTER|
603                                 DVB_USB_ADAP_NEED_PID_FILTERING|
604                                 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
605                         .streaming_ctrl   = it913x_streaming_ctrl,
606                         .pid_filter_count = 31,
607                         .pid_filter = it913x_pid_filter,
608                         .pid_filter_ctrl  = it913x_pid_filter_ctrl,
609                         .frontend_attach  = it913x_frontend_attach,
610                         /* parameter for the MPEG2-data transfer */
611                         .stream = {
612                                 .type = USB_BULK,
613                                 .count = 10,
614                                 .endpoint = 0x04,
615                                 .u = {/* Keep Low if PID filter on */
616                                         .bulk = {
617                                                 .buffersize = 3584,
618
619                                         }
620                                 }
621                         }
622                 }},
623                 },
624                         {
625                 .num_frontends = 1,
626                 .fe = {{
627                         .caps = DVB_USB_ADAP_HAS_PID_FILTER|
628                                 DVB_USB_ADAP_NEED_PID_FILTERING|
629                                 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
630                         .streaming_ctrl   = it913x_streaming_ctrl,
631                         .pid_filter_count = 31,
632                         .pid_filter = it913x_pid_filter,
633                         .pid_filter_ctrl  = it913x_pid_filter_ctrl,
634                         .frontend_attach  = it913x_frontend_attach,
635                         /* parameter for the MPEG2-data transfer */
636                         .stream = {
637                                 .type = USB_BULK,
638                                 .count = 5,
639                                 .endpoint = 0x05,
640                                 .u = {
641                                         .bulk = {
642                                                 .buffersize = 3584,
643
644                                         }
645                                 }
646                         }
647                 }},
648                 }
649         },
650         .identify_state   = it913x_identify_state,
651         .rc.core = {
652                 .protocol       = RC_TYPE_NEC,
653                 .module_name    = "it913x",
654                 .rc_query       = it913x_rc_query,
655                 .rc_interval    = IT913X_POLL,
656                 .allowed_protos = RC_TYPE_NEC,
657                 .rc_codes       = RC_MAP_KWORLD_315U,
658         },
659         .i2c_algo         = &it913x_i2c_algo,
660         .num_device_descs = 2,
661         .devices = {
662                 {   "Kworld UB499-2T T09(IT9137)",
663                         { &it913x_table[0], NULL },
664                         },
665                 {   "ITE 9135 Generic",
666                         { &it913x_table[1], NULL },
667                         },
668         }
669 };
670
671 static struct usb_driver it913x_driver = {
672         .name           = "it913x",
673         .probe          = it913x_probe,
674         .disconnect     = dvb_usb_device_exit,
675         .id_table       = it913x_table,
676 };
677
678 module_usb_driver(it913x_driver);
679
680 MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
681 MODULE_DESCRIPTION("it913x USB 2 Driver");
682 MODULE_VERSION("1.07");
683 MODULE_LICENSE("GPL");