Commit f5de95e2 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] siano: fix signal strength and CNR stats measurements

There are a number of small issues with the stats refactoring:
	- InBandPwr better represents the signal strength;
	- Don't zero signal strength /cnr if no lock;
	- Fix signal strength/cnr scale;
	- Don't need to fill PER/BER if not locked, as the
	  code will disable those stats anyway.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent a9b9fbdf
...@@ -155,11 +155,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe) ...@@ -155,11 +155,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe)
n_layers = 1; n_layers = 1;
} }
/* Fill the length of each status counter */ /* Global stats */
/* Only global stats */
c->strength.len = 1; c->strength.len = 1;
c->cnr.len = 1; c->cnr.len = 1;
c->strength.stat[0].scale = FE_SCALE_DECIBEL;
c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
/* Per-layer stats */ /* Per-layer stats */
c->post_bit_error.len = n_layers; c->post_bit_error.len = n_layers;
...@@ -167,13 +167,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe) ...@@ -167,13 +167,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe)
c->block_error.len = n_layers; c->block_error.len = n_layers;
c->block_count.len = n_layers; c->block_count.len = n_layers;
/* Signal is always available */ /*
c->strength.stat[0].scale = FE_SCALE_RELATIVE; * Put all of them at FE_SCALE_NOT_AVAILABLE. They're dynamically
c->strength.stat[0].uvalue = 0; * changed when the stats become available.
*/
/* Put all of them at FE_SCALE_NOT_AVAILABLE */
for (i = 0; i < n_layers; i++) { for (i = 0; i < n_layers; i++) {
c->cnr.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
c->post_bit_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
c->post_bit_count.stat[i].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_count.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
c->block_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE; c->block_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
...@@ -261,6 +259,16 @@ static void smsdvb_update_per_slices(struct smsdvb_client_t *client, ...@@ -261,6 +259,16 @@ static void smsdvb_update_per_slices(struct smsdvb_client_t *client,
client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked); client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
c->modulation = sms_to_modulation(p->constellation); c->modulation = sms_to_modulation(p->constellation);
/* Signal Strength, in DBm */
c->strength.stat[0].uvalue = p->inBandPower * 1000;
/* Carrier to Noise ratio, in DB */
c->cnr.stat[0].svalue = p->snr * 1000;
/* PER/BER requires demod lock */
if (!p->IsDemodLocked)
return;
/* TS PER */ /* TS PER */
client->last_per = c->block_error.stat[0].uvalue; client->last_per = c->block_error.stat[0].uvalue;
c->block_error.stat[0].scale = FE_SCALE_COUNTER; c->block_error.stat[0].scale = FE_SCALE_COUNTER;
...@@ -277,13 +285,6 @@ static void smsdvb_update_per_slices(struct smsdvb_client_t *client, ...@@ -277,13 +285,6 @@ static void smsdvb_update_per_slices(struct smsdvb_client_t *client,
/* Legacy PER/BER */ /* Legacy PER/BER */
client->legacy_per = (p->etsPackets * 65535) / client->legacy_per = (p->etsPackets * 65535) /
(p->tsPackets + p->etsPackets); (p->tsPackets + p->etsPackets);
/* Signal Strength, in DBm */
c->strength.stat[0].uvalue = p->RSSI * 1000;
/* Carrier to Noise ratio, in DB */
c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
c->cnr.stat[0].svalue = p->snr * 1000;
} }
static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client, static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client,
...@@ -312,11 +313,14 @@ static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client, ...@@ -312,11 +313,14 @@ static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client,
c->lna = p->IsExternalLNAOn ? 1 : 0; c->lna = p->IsExternalLNAOn ? 1 : 0;
/* Carrier to Noise ratio, in DB */ /* Carrier to Noise ratio, in DB */
c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
c->cnr.stat[0].svalue = p->SNR * 1000; c->cnr.stat[0].svalue = p->SNR * 1000;
/* Signal Strength, in DBm */ /* Signal Strength, in DBm */
c->strength.stat[0].uvalue = p->RSSI * 1000; c->strength.stat[0].uvalue = p->InBandPwr * 1000;
/* PER/BER requires demod lock */
if (!p->IsDemodLocked)
return;
/* TS PER */ /* TS PER */
client->last_per = c->block_error.stat[0].uvalue; client->last_per = c->block_error.stat[0].uvalue;
...@@ -364,11 +368,14 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client, ...@@ -364,11 +368,14 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
c->lna = p->IsExternalLNAOn ? 1 : 0; c->lna = p->IsExternalLNAOn ? 1 : 0;
/* Carrier to Noise ratio, in DB */ /* Carrier to Noise ratio, in DB */
c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
c->cnr.stat[0].svalue = p->SNR * 1000; c->cnr.stat[0].svalue = p->SNR * 1000;
/* Signal Strength, in DBm */ /* Signal Strength, in DBm */
c->strength.stat[0].uvalue = p->RSSI * 1000; c->strength.stat[0].uvalue = p->InBandPwr * 1000;
/* PER/BER and per-layer stats require demod lock */
if (!p->IsDemodLocked)
return;
client->last_per = c->block_error.stat[0].uvalue; client->last_per = c->block_error.stat[0].uvalue;
...@@ -441,11 +448,14 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client, ...@@ -441,11 +448,14 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
c->lna = p->IsExternalLNAOn ? 1 : 0; c->lna = p->IsExternalLNAOn ? 1 : 0;
/* Carrier to Noise ratio, in DB */ /* Carrier to Noise ratio, in DB */
c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
c->cnr.stat[0].svalue = p->SNR * 1000; c->cnr.stat[0].svalue = p->SNR * 1000;
/* Signal Strength, in DBm */ /* Signal Strength, in DBm */
c->strength.stat[0].uvalue = p->RSSI * 1000; c->strength.stat[0].uvalue = p->InBandPwr * 1000;
/* PER/BER and per-layer stats require demod lock */
if (!p->IsDemodLocked)
return;
client->last_per = c->block_error.stat[0].uvalue; client->last_per = c->block_error.stat[0].uvalue;
...@@ -943,11 +953,14 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe) ...@@ -943,11 +953,14 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
static int smsdvb_set_frontend(struct dvb_frontend *fe) static int smsdvb_set_frontend(struct dvb_frontend *fe)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct smsdvb_client_t *client = struct smsdvb_client_t *client =
container_of(fe, struct smsdvb_client_t, frontend); container_of(fe, struct smsdvb_client_t, frontend);
struct smscore_device_t *coredev = client->coredev; struct smscore_device_t *coredev = client->coredev;
smsdvb_stats_not_ready(fe); smsdvb_stats_not_ready(fe);
c->strength.stat[0].uvalue = 0;
c->cnr.stat[0].uvalue = 0;
switch (smscore_get_device_mode(coredev)) { switch (smscore_get_device_mode(coredev)) {
case DEVICE_MODE_DVBT: case DEVICE_MODE_DVBT:
......
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