Commit d8bad1e2 authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Mauro Carvalho Chehab

[media] lmedm04: create frontend callbacks for signal/snr/ber/ucblocks

Create call backs dm04_read_signal_strength, dm04_read_snr and
move dm04_read_ber and dm04_read_ucblocks for all frontends

Removing the I2C filtering from lme2510_msg and the old rs2000 callbacks.
Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 15e1ce33
...@@ -515,21 +515,6 @@ static int lme2510_msg(struct dvb_usb_device *d, ...@@ -515,21 +515,6 @@ static int lme2510_msg(struct dvb_usb_device *d,
rbuf[0] = 0x55; rbuf[0] = 0x55;
rbuf[1] = st->signal_lock; rbuf[1] = st->signal_lock;
break; break;
case 0x43:
rbuf[0] = 0x55;
rbuf[1] = st->signal_level;
break;
case 0x1c:
rbuf[0] = 0x55;
rbuf[1] = st->signal_sn;
break;
case 0x15:
case 0x16:
case 0x17:
case 0x18:
rbuf[0] = 0x55;
rbuf[1] = 0x00;
break;
default: default:
lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen); lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
st->i2c_talk_onoff = 1; st->i2c_talk_onoff = 1;
...@@ -538,25 +523,10 @@ static int lme2510_msg(struct dvb_usb_device *d, ...@@ -538,25 +523,10 @@ static int lme2510_msg(struct dvb_usb_device *d,
break; break;
case TUNER_S7395: case TUNER_S7395:
switch (wbuf[3]) { switch (wbuf[3]) {
case 0x10:
rbuf[0] = 0x55;
rbuf[1] = (st->signal_level & 0x80)
? 0 : (st->signal_level * 2);
break;
case 0x2d:
rbuf[0] = 0x55;
rbuf[1] = st->signal_sn;
break;
case 0x24: case 0x24:
rbuf[0] = 0x55; rbuf[0] = 0x55;
rbuf[1] = st->signal_lock; rbuf[1] = st->signal_lock;
break; break;
case 0x2e:
case 0x26:
case 0x27:
rbuf[0] = 0x55;
rbuf[1] = 0x00;
break;
default: default:
lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen); lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
st->i2c_talk_onoff = 1; st->i2c_talk_onoff = 1;
...@@ -565,26 +535,10 @@ static int lme2510_msg(struct dvb_usb_device *d, ...@@ -565,26 +535,10 @@ static int lme2510_msg(struct dvb_usb_device *d,
break; break;
case TUNER_S0194: case TUNER_S0194:
switch (wbuf[3]) { switch (wbuf[3]) {
case 0x18:
rbuf[0] = 0x55;
rbuf[1] = (st->signal_level & 0x80)
? 0 : (st->signal_level * 2);
break;
case 0x24:
rbuf[0] = 0x55;
rbuf[1] = st->signal_sn;
break;
case 0x1b: case 0x1b:
rbuf[0] = 0x55; rbuf[0] = 0x55;
rbuf[1] = st->signal_lock; rbuf[1] = st->signal_lock;
break; break;
case 0x19:
case 0x25:
case 0x1e:
case 0x1d:
rbuf[0] = 0x55;
rbuf[1] = 0x00;
break;
default: default:
lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen); lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
st->i2c_talk_onoff = 1; st->i2c_talk_onoff = 1;
...@@ -1006,21 +960,44 @@ static int dm04_lme2510_set_voltage(struct dvb_frontend *fe, ...@@ -1006,21 +960,44 @@ static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
return (ret < 0) ? -ENODEV : 0; return (ret < 0) ? -ENODEV : 0;
} }
static int dm04_rs2000_read_signal_strength(struct dvb_frontend *fe, static int dm04_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
u16 *strength)
{ {
struct lme2510_state *st = fe_to_priv(fe); struct lme2510_state *st = fe_to_priv(fe);
*strength = (u16)((u32)st->signal_level * 0xffff / 0xff); switch (st->tuner_config) {
case TUNER_LG:
*strength = 0xff - st->signal_level;
*strength |= *strength << 8;
break;
/* fall through */
case TUNER_S7395:
case TUNER_S0194:
*strength = 0xffff - (((st->signal_level * 2) << 8) * 5 / 4);
break;
case TUNER_RS2000:
*strength = (u16)((u32)st->signal_level * 0xffff / 0xff);
}
return 0; return 0;
} }
static int dm04_rs2000_read_snr(struct dvb_frontend *fe, u16 *snr) static int dm04_read_snr(struct dvb_frontend *fe, u16 *snr)
{ {
struct lme2510_state *st = fe_to_priv(fe); struct lme2510_state *st = fe_to_priv(fe);
*snr = (u16)((u32)st->signal_sn * 0xffff / 0x7f); switch (st->tuner_config) {
case TUNER_LG:
*snr = 0xff - st->signal_sn;
*snr |= *snr << 8;
break;
/* fall through */
case TUNER_S7395:
case TUNER_S0194:
*snr = (u16)((0xff - st->signal_sn - 0xa1) * 3) << 8;
break;
case TUNER_RS2000:
*snr = (u16)((u32)st->signal_sn * 0xffff / 0x7f);
}
return 0; return 0;
} }
...@@ -1127,15 +1104,6 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) ...@@ -1127,15 +1104,6 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
st->tuner_config = TUNER_RS2000; st->tuner_config = TUNER_RS2000;
st->fe_set_voltage = st->fe_set_voltage =
adap->fe[0]->ops.set_voltage; adap->fe[0]->ops.set_voltage;
adap->fe[0]->ops.read_signal_strength =
dm04_rs2000_read_signal_strength;
adap->fe[0]->ops.read_snr =
dm04_rs2000_read_snr;
adap->fe[0]->ops.read_ber =
dm04_read_ber;
adap->fe[0]->ops.read_ucblocks =
dm04_read_ucblocks;
} }
break; break;
} }
...@@ -1154,7 +1122,12 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) ...@@ -1154,7 +1122,12 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
return -ENODEV; return -ENODEV;
} }
adap->fe[0]->ops.read_signal_strength = dm04_read_signal_strength;
adap->fe[0]->ops.read_snr = dm04_read_snr;
adap->fe[0]->ops.read_ber = dm04_read_ber;
adap->fe[0]->ops.read_ucblocks = dm04_read_ucblocks;
adap->fe[0]->ops.set_voltage = dm04_lme2510_set_voltage; adap->fe[0]->ops.set_voltage = dm04_lme2510_set_voltage;
ret = lme_name(adap); ret = lme_name(adap);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment