Commit 426508e6 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] rtl2832: move stats polling to read status

Do statistics polling on read status in order to avoid
unnecessary delayed work.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent d884acad
...@@ -408,8 +408,6 @@ static int rtl2832_init(struct dvb_frontend *fe) ...@@ -408,8 +408,6 @@ static int rtl2832_init(struct dvb_frontend *fe)
c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
c->post_bit_count.len = 1; c->post_bit_count.len = 1;
c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
/* start statistics polling */
schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
dev->sleeping = false; dev->sleeping = false;
return 0; return 0;
...@@ -427,8 +425,6 @@ static int rtl2832_sleep(struct dvb_frontend *fe) ...@@ -427,8 +425,6 @@ static int rtl2832_sleep(struct dvb_frontend *fe)
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
dev->sleeping = true; dev->sleeping = true;
/* stop statistics polling */
cancel_delayed_work_sync(&dev->stat_work);
dev->fe_status = 0; dev->fe_status = 0;
ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1); ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1);
...@@ -691,8 +687,11 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status) ...@@ -691,8 +687,11 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status)
{ {
struct rtl2832_dev *dev = fe->demodulator_priv; struct rtl2832_dev *dev = fe->demodulator_priv;
struct i2c_client *client = dev->client; struct i2c_client *client = dev->client;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret; int ret;
u32 uninitialized_var(tmp); u32 uninitialized_var(tmp);
u8 u8tmp, buf[2];
u16 u16tmp;
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
...@@ -713,45 +712,6 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status) ...@@ -713,45 +712,6 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status)
} }
dev->fe_status = *status; dev->fe_status = *status;
return 0;
err:
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
/* report SNR in resolution of 0.1 dB */
if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
*snr = div_s64(c->cnr.stat[0].svalue, 100);
else
*snr = 0;
return 0;
}
static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
*ber = (dev->post_bit_error - dev->post_bit_error_prev);
dev->post_bit_error_prev = dev->post_bit_error;
return 0;
}
static void rtl2832_stat_work(struct work_struct *work)
{
struct rtl2832_dev *dev = container_of(work, struct rtl2832_dev, stat_work.work);
struct i2c_client *client = dev->client;
struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
int ret, tmp;
u8 u8tmp, buf[2];
u16 u16tmp;
dev_dbg(&client->dev, "\n");
/* signal strength */ /* signal strength */
if (dev->fe_status & FE_HAS_SIGNAL) { if (dev->fe_status & FE_HAS_SIGNAL) {
...@@ -788,11 +748,11 @@ static void rtl2832_stat_work(struct work_struct *work) ...@@ -788,11 +748,11 @@ static void rtl2832_stat_work(struct work_struct *work)
constellation = (u8tmp >> 2) & 0x03; /* [3:2] */ constellation = (u8tmp >> 2) & 0x03; /* [3:2] */
if (constellation > CONSTELLATION_NUM - 1) if (constellation > CONSTELLATION_NUM - 1)
goto err_schedule_delayed_work; goto err;
hierarchy = (u8tmp >> 4) & 0x07; /* [6:4] */ hierarchy = (u8tmp >> 4) & 0x07; /* [6:4] */
if (hierarchy > HIERARCHY_NUM - 1) if (hierarchy > HIERARCHY_NUM - 1)
goto err_schedule_delayed_work; goto err;
ret = rtl2832_bulk_read(client, 0x40c, buf, 2); ret = rtl2832_bulk_read(client, 0x40c, buf, 2);
if (ret) if (ret)
...@@ -834,11 +794,33 @@ static void rtl2832_stat_work(struct work_struct *work) ...@@ -834,11 +794,33 @@ static void rtl2832_stat_work(struct work_struct *work)
c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
} }
err_schedule_delayed_work: return 0;
schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
return;
err: err:
dev_dbg(&client->dev, "failed=%d\n", ret); dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
/* report SNR in resolution of 0.1 dB */
if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
*snr = div_s64(c->cnr.stat[0].svalue, 100);
else
*snr = 0;
return 0;
}
static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
*ber = (dev->post_bit_error - dev->post_bit_error_prev);
dev->post_bit_error_prev = dev->post_bit_error;
return 0;
} }
/* /*
...@@ -1235,7 +1217,6 @@ static int rtl2832_probe(struct i2c_client *client, ...@@ -1235,7 +1217,6 @@ static int rtl2832_probe(struct i2c_client *client,
dev->pdata = client->dev.platform_data; dev->pdata = client->dev.platform_data;
dev->sleeping = true; dev->sleeping = true;
INIT_DELAYED_WORK(&dev->i2c_gate_work, rtl2832_i2c_gate_work); INIT_DELAYED_WORK(&dev->i2c_gate_work, rtl2832_i2c_gate_work);
INIT_DELAYED_WORK(&dev->stat_work, rtl2832_stat_work);
/* create regmap */ /* create regmap */
mutex_init(&dev->regmap_mutex); mutex_init(&dev->regmap_mutex);
dev->regmap_config.reg_bits = 8, dev->regmap_config.reg_bits = 8,
......
...@@ -38,7 +38,6 @@ struct rtl2832_dev { ...@@ -38,7 +38,6 @@ struct rtl2832_dev {
struct regmap *regmap; struct regmap *regmap;
struct i2c_adapter *i2c_adapter_tuner; struct i2c_adapter *i2c_adapter_tuner;
struct dvb_frontend fe; struct dvb_frontend fe;
struct delayed_work stat_work;
enum fe_status fe_status; enum fe_status fe_status;
u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */ u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */
u64 post_bit_error; u64 post_bit_error;
......
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