Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285346
b: refs/heads/master
c: 990f49a
h: refs/heads/master
v: v3
  • Loading branch information
Malcolm Priestley authored and Mauro Carvalho Chehab committed Dec 11, 2011
1 parent 219afd5 commit d530f50
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 773ddbd228dc16a4829836e1dc16383e44c8575e
refs/heads/master: 990f49af3f564b9a0f572e06f22e2ae34c79c37d
37 changes: 35 additions & 2 deletions trunk/drivers/media/dvb/dvb-usb/it913x.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,31 @@ static int it913x_rc_query(struct dvb_usb_device *d)
return ret;
}

static int ite_firmware_select(struct usb_device *udev,
struct dvb_usb_device_properties *props)
{
int sw;
/* auto switch */
if (le16_to_cpu(udev->descriptor.idProduct) ==
USB_PID_ITETECH_IT9135)
sw = IT9135_V1_FW;
else
sw = IT9137_FW;

switch (sw) {
case IT9135_V1_FW:
it913x_config.firmware_ver = 0;
it913x_config.adc_x2 = 1;
break;
case IT9137_FW:
default:
it913x_config.firmware_ver = 0;
it913x_config.adc_x2 = 0;
}

return 0;
}

#define TS_MPEG_PKT_SIZE 188
#define EP_LOW 21
#define TS_BUFFER_SIZE_PID (EP_LOW*TS_MPEG_PKT_SIZE)
Expand Down Expand Up @@ -392,6 +417,8 @@ static int it913x_identify_state(struct usb_device *udev,
props->adapter[1].fe[0].stream.u.bulk.buffersize =
props->adapter[0].fe[0].stream.u.bulk.buffersize;

ret = ite_firmware_select(udev, props);

if (firm_no > 0) {
*cold = 0;
return 0;
Expand Down Expand Up @@ -421,10 +448,16 @@ static int it913x_identify_state(struct usb_device *udev,

if (it913x_config.dual_mode) {
ret |= it913x_wr_reg(udev, DEV_0, 0x4bfb, CHIP2_I2C_ADDR);
ret |= it913x_wr_reg(udev, DEV_0, CLK_O_EN, 0x1);
if (it913x_config.firmware_ver == 1)
ret |= it913x_wr_reg(udev, DEV_0, 0xcfff, 0x1);
else
ret |= it913x_wr_reg(udev, DEV_0, CLK_O_EN, 0x1);
} else {
ret |= it913x_wr_reg(udev, DEV_0, 0x4bfb, 0x0);
ret |= it913x_wr_reg(udev, DEV_0, CLK_O_EN, 0x0);
if (it913x_config.firmware_ver == 1)
ret |= it913x_wr_reg(udev, DEV_0, 0xcfff, 0x0);
else
ret |= it913x_wr_reg(udev, DEV_0, CLK_O_EN, 0x0);
}

*cold = 1;
Expand Down
20 changes: 20 additions & 0 deletions trunk/drivers/media/dvb/frontends/it913x-fe-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ static struct it913xset init_1[] = {
{PRO_LINK, LOCK3_OUT, {0x01}, 0x01},
{PRO_LINK, PADMISCDRSR, {0x01}, 0x01},
{PRO_LINK, PADMISCDR2, {0x00}, 0x01},
{PRO_DMOD, 0xec57, {0x00, 0x00}, 0x02},
{PRO_LINK, PADMISCDR4, {0x00}, 0x01}, /* Power up */
{PRO_LINK, PADMISCDR8, {0x00}, 0x01},
{0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
Expand Down Expand Up @@ -1010,10 +1011,29 @@ static struct it913xset it9137_tuner_off[] = {
{PRO_DMOD, 0xfba8, {0x01}, 0x01}, /* Tuner Clock Off */
{PRO_DMOD, 0xec40, {0x00}, 0x01}, /* Power Down Tuner */
{PRO_DMOD, 0xec02, {0x3f, 0x1f, 0x3f, 0x3f}, 0x04},
{PRO_DMOD, 0xec06, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00}, 0x0c},
{PRO_DMOD, 0xec12, {0x00, 0x00, 0x00, 0x00}, 0x04},
{PRO_DMOD, 0xec17, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00}, 0x09},
{PRO_DMOD, 0xec22, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00}, 0x0a},
{PRO_DMOD, 0xec20, {0x00}, 0x01},
{PRO_DMOD, 0xec3f, {0x01}, 0x01},
{0xff, 0x0000, {0x00}, 0x00}, /* Terminating Entry */
};

static struct it913xset set_it9135_template[] = {
{PRO_DMOD, 0xee06, {0x00}, 0x01},
{PRO_DMOD, 0xec56, {0x00}, 0x01},
{PRO_DMOD, 0xec4c, {0x00}, 0x01},
{PRO_DMOD, 0xec4d, {0x00}, 0x01},
{PRO_DMOD, 0xec4e, {0x00}, 0x01},
{PRO_DMOD, 0x011e, {0x00}, 0x01}, /* Older Devices */
{PRO_DMOD, 0x011f, {0x00}, 0x01},
{0xff, 0x0000, {0x00}, 0x00}, /* Terminating Entry */
};

static struct it913xset set_it9137_template[] = {
{PRO_DMOD, 0xee06, {0x00}, 0x01},
{PRO_DMOD, 0xec56, {0x00}, 0x01},
Expand Down
23 changes: 18 additions & 5 deletions trunk/drivers/media/dvb/frontends/it913x-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ static int it9137_set_tuner(struct it913x_fe_state *state,
u8 lna_band;
u8 bw;

if (state->config->firmware_ver == 1)
set_tuner = set_it9135_template;
else
set_tuner = set_it9137_template;

deb_info("Tuner Frequency %d Bandwidth %d", frequency, bandwidth);

if (frequency >= 51000 && frequency <= 440000) {
Expand Down Expand Up @@ -774,8 +779,16 @@ static int it913x_fe_start(struct it913x_fe_state *state)
b[2] = (adc >> 16) & 0xff;
ret |= it913x_write(state, PRO_DMOD, ADC_FREQ, b, 3);

info("Crystal Frequency :%d Adc Frequency :%d",
state->crystalFrequency, state->adcFrequency);
if (state->config->adc_x2)
ret |= it913x_write_reg(state, PRO_DMOD, ADC_X_2, 0x01);
b[0] = 0;
b[1] = 0;
b[2] = 0;
ret |= it913x_write(state, PRO_DMOD, 0x0029, b, 3);

info("Crystal Frequency :%d Adc Frequency :%d ADC X2: %02x",
state->crystalFrequency, state->adcFrequency,
state->config->adc_x2);
deb_info("Xtal value :%04x Adc value :%04x", xtal, adc);

if (ret < 0)
Expand Down Expand Up @@ -840,10 +853,10 @@ static int it913x_fe_init(struct dvb_frontend *fe)
/* Power Up Tuner - common all versions */
ret = it913x_write_reg(state, PRO_DMOD, 0xec40, 0x1);

ret |= it913x_write_reg(state, PRO_DMOD, AFE_MEM0, 0x0);

ret |= it913x_fe_script_loader(state, init_1);

ret |= it913x_write_reg(state, PRO_DMOD, AFE_MEM0, 0x0);

ret |= it913x_write_reg(state, PRO_DMOD, 0xfba8, 0x0);

return (ret < 0) ? -ENODEV : 0;
Expand Down Expand Up @@ -938,5 +951,5 @@ static struct dvb_frontend_ops it913x_fe_ofdm_ops = {

MODULE_DESCRIPTION("it913x Frontend and it9137 tuner");
MODULE_AUTHOR("Malcolm Priestley tvboxspy@gmail.com");
MODULE_VERSION("1.10");
MODULE_VERSION("1.12");
MODULE_LICENSE("GPL");
9 changes: 9 additions & 0 deletions trunk/drivers/media/dvb/frontends/it913x-fe.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct ite_config {
u8 chip_ver;
u16 chip_type;
u32 firmware;
u8 firmware_ver;
u8 adc_x2;
u8 tuner_id_0;
u8 tuner_id_1;
u8 dual_mode;
Expand Down Expand Up @@ -211,4 +213,11 @@ enum {
WRITE_CMD,
};

enum {
IT9135_AUTO = 0,
IT9137_FW,
IT9135_V1_FW,
IT9135_V2_FW,
};

#endif /* IT913X_FE_H */

0 comments on commit d530f50

Please sign in to comment.