Skip to content

Commit bc54919

Browse files
Malcolm PriestleyMauro Carvalho Chehab
authored andcommitted
[media] it913x [VER 1.07] Support for single ITE 9135 devices
Support for single ITE 9135 device. Only single devices have been tested. Dual ITE 9135 devices should work, but have not been tested. TODOs support for ver 2 chip config for other tuner types. rework of firmware file. Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1 parent efabaaf commit bc54919

2 files changed

Lines changed: 80 additions & 27 deletions

File tree

‎drivers/media/dvb/dvb-usb/dvb-usb-ids.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define USB_VID_HAUPPAUGE 0x2040
3838
#define USB_VID_HYPER_PALTEK 0x1025
3939
#define USB_VID_INTEL 0x8086
40+
#define USB_VID_ITETECH 0x048d
4041
#define USB_VID_KWORLD 0xeb2a
4142
#define USB_VID_KWORLD_2 0x1b80
4243
#define USB_VID_KYE 0x0458
@@ -126,6 +127,7 @@
126127
#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
127128
#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
128129
#define USB_PID_INTEL_CE9500 0x9500
130+
#define USB_PID_ITETECH_IT9135 0x9135
129131
#define USB_PID_KWORLD_399U 0xe399
130132
#define USB_PID_KWORLD_399U_2 0xe400
131133
#define USB_PID_KWORLD_395U 0xe396

‎drivers/media/dvb/dvb-usb/it913x.c‎

Lines changed: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ struct it913x_state {
6060
u8 id;
6161
};
6262

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+
6374
static int it913x_bulk_write(struct usb_device *dev,
6475
u8 *snd, int len, u8 pipe)
6576
{
@@ -191,18 +202,23 @@ static int it913x_read_reg(struct usb_device *udev, u32 reg)
191202
static u32 it913x_query(struct usb_device *udev, u8 pro)
192203
{
193204
int ret;
194-
u32 res = 0;
195205
u8 data[4];
196206
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,
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,
200216
CMD_QUERYINFO, 0, 0x1, &data[0], 4);
201-
res = (data[0] << 24) + (data[1] << 16) +
217+
218+
it913x_config.firmware = (data[0] << 24) + (data[1] << 16) +
202219
(data[2] << 8) + data[3];
203-
}
204220

205-
return (ret < 0) ? 0 : res;
221+
return (ret < 0) ? 0 : it913x_config.firmware;
206222
}
207223

208224
static int it913x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
@@ -336,26 +352,35 @@ static int it913x_identify_state(struct usb_device *udev,
336352
int *cold)
337353
{
338354
int ret = 0, firm_no;
339-
u8 reg, adap, ep, tun0, tun1;
355+
u8 reg, remote;
340356

341357
firm_no = it913x_return_status(udev);
342358

343-
ep = it913x_read_reg(udev, 0x49ac);
344-
adap = it913x_read_reg(udev, 0x49c5);
345-
tun0 = it913x_read_reg(udev, 0x49d0);
346-
info("No. Adapters=%x Endpoints=%x Tuner Type=%x", adap, ep, tun0);
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);
347372

348373
if (firm_no > 0) {
349374
*cold = 0;
350375
return 0;
351376
}
352377

353-
if (adap > 2) {
354-
tun1 = it913x_read_reg(udev, 0x49e0);
378+
if (it913x_config.dual_mode) {
379+
it913x_config.tuner_id_1 = it913x_read_reg(udev, 0x49e0);
355380
ret = it913x_wr_reg(udev, DEV_0, GPIOH1_EN, 0x1);
356381
ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_ON, 0x1);
357382
ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_O, 0x1);
358-
msleep(50); /* Delay noticed reset cycle ? */
383+
msleep(50);
359384
ret |= it913x_wr_reg(udev, DEV_0, GPIOH1_O, 0x0);
360385
msleep(50);
361386
reg = it913x_read_reg(udev, GPIOH1_O);
@@ -366,14 +391,19 @@ static int it913x_identify_state(struct usb_device *udev,
366391
ret = it913x_wr_reg(udev, DEV_0,
367392
GPIOH1_O, 0x0);
368393
}
394+
props->num_adapters = 2;
369395
} else
370396
props->num_adapters = 1;
371397

372398
reg = it913x_read_reg(udev, IO_MUX_POWER_CLK);
373399

374-
ret |= it913x_wr_reg(udev, DEV_0, 0x4bfb, CHIP2_I2C_ADDR);
375-
376-
ret |= it913x_wr_reg(udev, DEV_0, CLK_O_EN, 0x1);
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+
}
377407

378408
*cold = 1;
379409

@@ -403,13 +433,11 @@ static int it913x_download_firmware(struct usb_device *udev,
403433
const struct firmware *fw)
404434
{
405435
int ret = 0, i;
406-
u8 packet_size, dlen, tun1;
436+
u8 packet_size, dlen;
407437
u8 *fw_data;
408438

409439
packet_size = 0x29;
410440

411-
tun1 = it913x_read_reg(udev, 0x49e0);
412-
413441
ret = it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_100);
414442

415443
info("FRM Starting Firmware Download");
@@ -444,11 +472,12 @@ static int it913x_download_firmware(struct usb_device *udev,
444472
ret |= it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400);
445473

446474
/* Tuner function */
447-
ret |= it913x_wr_reg(udev, DEV_0_DMOD , 0xec4c, 0xa0);
475+
if (it913x_config.dual_mode)
476+
ret |= it913x_wr_reg(udev, DEV_0_DMOD , 0xec4c, 0xa0);
448477

449478
ret |= it913x_wr_reg(udev, DEV_0, PADODPU, 0x0);
450479
ret |= it913x_wr_reg(udev, DEV_0, AGC_O_D, 0x0);
451-
if (tun1 > 0) {
480+
if (it913x_config.dual_mode) {
452481
ret |= it913x_wr_reg(udev, DEV_1, PADODPU, 0x0);
453482
ret |= it913x_wr_reg(udev, DEV_1, AGC_O_D, 0x0);
454483
}
@@ -475,9 +504,28 @@ static int it913x_frontend_attach(struct dvb_usb_adapter *adap)
475504
u8 adf = it913x_read_reg(udev, IO_MUX_POWER_CLK);
476505
u8 adap_addr = I2C_BASE_ADDR + (adap->id << 5);
477506
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+
}
478526

479527
adap->fe_adap[0].fe = dvb_attach(it913x_fe_attach,
480-
&adap->dev->i2c_adap, adap_addr, adf, IT9137);
528+
&adap->dev->i2c_adap, adap_addr, adf, tuner_type);
481529

482530
if (adap->id == 0 && adap->fe_adap[0].fe) {
483531
ret = it913x_wr_reg(udev, DEV_0_DMOD, MP2_SW_RST, 0x1);
@@ -533,6 +581,7 @@ static int it913x_probe(struct usb_interface *intf,
533581

534582
static struct usb_device_id it913x_table[] = {
535583
{ USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09) },
584+
{ USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135) },
536585
{} /* Terminating entry */
537586
};
538587

@@ -608,12 +657,14 @@ static struct dvb_usb_device_properties it913x_properties = {
608657
.rc_codes = RC_MAP_KWORLD_315U,
609658
},
610659
.i2c_algo = &it913x_i2c_algo,
611-
.num_device_descs = 1,
660+
.num_device_descs = 2,
612661
.devices = {
613662
{ "Kworld UB499-2T T09(IT9137)",
614663
{ &it913x_table[0], NULL },
615664
},
616-
665+
{ "ITE 9135 Generic",
666+
{ &it913x_table[1], NULL },
667+
},
617668
}
618669
};
619670

@@ -647,5 +698,5 @@ module_exit(it913x_module_exit);
647698

648699
MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
649700
MODULE_DESCRIPTION("it913x USB 2 Driver");
650-
MODULE_VERSION("1.06");
701+
MODULE_VERSION("1.07");
651702
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)