Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285486
b: refs/heads/master
c: 9481f40
h: refs/heads/master
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Dec 31, 2011
1 parent cf24724 commit 3dedfb6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 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: 57605c9680bf2c57cb2ff3ad737fefd9c82bc012
refs/heads/master: 9481f4009c7bc95a03b5553e9174cfd2a0248d57
63 changes: 46 additions & 17 deletions trunk/drivers/media/common/tuners/tuner-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,24 +791,26 @@ static int simple_set_params(struct dvb_frontend *fe,
}

static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf,
const struct dvb_frontend_parameters *params)
const u32 delsys,
const u32 frequency,
const u32 bandwidth)
{
struct tuner_simple_priv *priv = fe->tuner_priv;

switch (priv->type) {
case TUNER_PHILIPS_FMD1216ME_MK3:
case TUNER_PHILIPS_FMD1216MEX_MK3:
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ &&
params->frequency >= 158870000)
if (bandwidth == 8000000 &&
frequency >= 158870000)
buf[3] |= 0x08;
break;
case TUNER_PHILIPS_TD1316:
/* determine band */
buf[3] |= (params->frequency < 161000000) ? 1 :
(params->frequency < 444000000) ? 2 : 4;
buf[3] |= (frequency < 161000000) ? 1 :
(frequency < 444000000) ? 2 : 4;

/* setup PLL filter */
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
if (bandwidth == 8000000)
buf[3] |= 1 << 3;
break;
case TUNER_PHILIPS_TUV1236D:
Expand All @@ -819,12 +821,11 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf,
if (dtv_input[priv->nr])
new_rf = dtv_input[priv->nr];
else
switch (params->u.vsb.modulation) {
case QAM_64:
case QAM_256:
switch (delsys) {
case SYS_DVBC_ANNEX_B:
new_rf = 1;
break;
case VSB_8:
case SYS_ATSC:
default:
new_rf = 0;
break;
Expand All @@ -838,7 +839,9 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf,
}

static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
const struct dvb_frontend_parameters *params)
const u32 delsys,
const u32 freq,
const u32 bw)
{
/* This function returns the tuned frequency on success, 0 on error */
struct tuner_simple_priv *priv = fe->tuner_priv;
Expand All @@ -847,7 +850,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
u8 config, cb;
u32 div;
int ret;
unsigned frequency = params->frequency / 62500;
u32 frequency = freq / 62500;

if (!tun->stepsize) {
/* tuner-core was loaded before the digital tuner was
Expand All @@ -871,7 +874,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
buf[2] = config;
buf[3] = cb;

simple_set_dvb(fe, buf, params);
simple_set_dvb(fe, buf, delsys, freq, bw);

tuner_dbg("%s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
tun->name, div, buf[0], buf[1], buf[2], buf[3]);
Expand All @@ -884,13 +887,29 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params,
u8 *buf, int buf_len)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u32 delsys = c->delivery_system;
u32 bw = c->bandwidth_hz;
struct tuner_simple_priv *priv = fe->tuner_priv;
u32 frequency;

if (buf_len < 5)
return -EINVAL;

frequency = simple_dvb_configure(fe, buf+1, params);
switch (delsys) {
case SYS_DVBT:
case SYS_DVBT2:
if (params->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
bw = 6000000;
if (params->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
bw = 7000000;
if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
bw = 8000000;
break;
default:
break;
}
frequency = simple_dvb_configure(fe, buf+1, delsys, params->frequency, bw);
if (frequency == 0)
return -EINVAL;

Expand All @@ -906,7 +925,12 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe,
static int simple_dvb_set_params(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u32 delsys = c->delivery_system;
u32 bw = c->bandwidth_hz;
u32 freq = c->frequency;
struct tuner_simple_priv *priv = fe->tuner_priv;
u32 frequency;
u32 prev_freq, prev_bw;
int ret;
u8 buf[5];
Expand All @@ -917,9 +941,14 @@ static int simple_dvb_set_params(struct dvb_frontend *fe,
prev_freq = priv->frequency;
prev_bw = priv->bandwidth;

ret = simple_dvb_calc_regs(fe, params, buf, 5);
if (ret != 5)
goto fail;
frequency = simple_dvb_configure(fe, buf+1, delsys, freq, bw);
if (frequency == 0)
return -EINVAL;

buf[0] = priv->i2c_props.addr;

priv->frequency = frequency;
priv->bandwidth = bw;

/* put analog demod in standby when tuning digital */
if (fe->ops.analog_ops.standby)
Expand Down

0 comments on commit 3dedfb6

Please sign in to comment.