aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2013-03-10 11:06:30 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-21 06:49:17 -0400
commitf5de95e2467b7b6b968e6c67489425265dd2a1c2 (patch)
tree60d7c3ba80e1751b50fff8407ca2ae142d0eb1d5
parenta9b9fbdf0a6a65359cd97254a282526822de5257 (diff)
[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: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/common/siano/smsdvb-main.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
index 4242005082ed..90f6e894e593 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -155,11 +155,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe)
155 n_layers = 1; 155 n_layers = 1;
156 } 156 }
157 157
158 /* Fill the length of each status counter */ 158 /* Global stats */
159
160 /* Only global stats */
161 c->strength.len = 1; 159 c->strength.len = 1;
162 c->cnr.len = 1; 160 c->cnr.len = 1;
161 c->strength.stat[0].scale = FE_SCALE_DECIBEL;
162 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
163 163
164 /* Per-layer stats */ 164 /* Per-layer stats */
165 c->post_bit_error.len = n_layers; 165 c->post_bit_error.len = n_layers;
@@ -167,13 +167,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe)
167 c->block_error.len = n_layers; 167 c->block_error.len = n_layers;
168 c->block_count.len = n_layers; 168 c->block_count.len = n_layers;
169 169
170 /* Signal is always available */ 170 /*
171 c->strength.stat[0].scale = FE_SCALE_RELATIVE; 171 * Put all of them at FE_SCALE_NOT_AVAILABLE. They're dynamically
172 c->strength.stat[0].uvalue = 0; 172 * changed when the stats become available.
173 173 */
174 /* Put all of them at FE_SCALE_NOT_AVAILABLE */
175 for (i = 0; i < n_layers; i++) { 174 for (i = 0; i < n_layers; i++) {
176 c->cnr.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
177 c->post_bit_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE; 175 c->post_bit_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
178 c->post_bit_count.stat[i].scale = FE_SCALE_NOT_AVAILABLE; 176 c->post_bit_count.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
179 c->block_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE; 177 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 client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked); 259 client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
262 c->modulation = sms_to_modulation(p->constellation); 260 c->modulation = sms_to_modulation(p->constellation);
263 261
262 /* Signal Strength, in DBm */
263 c->strength.stat[0].uvalue = p->inBandPower * 1000;
264
265 /* Carrier to Noise ratio, in DB */
266 c->cnr.stat[0].svalue = p->snr * 1000;
267
268 /* PER/BER requires demod lock */
269 if (!p->IsDemodLocked)
270 return;
271
264 /* TS PER */ 272 /* TS PER */
265 client->last_per = c->block_error.stat[0].uvalue; 273 client->last_per = c->block_error.stat[0].uvalue;
266 c->block_error.stat[0].scale = FE_SCALE_COUNTER; 274 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 /* Legacy PER/BER */ 285 /* Legacy PER/BER */
278 client->legacy_per = (p->etsPackets * 65535) / 286 client->legacy_per = (p->etsPackets * 65535) /
279 (p->tsPackets + p->etsPackets); 287 (p->tsPackets + p->etsPackets);
280
281 /* Signal Strength, in DBm */
282 c->strength.stat[0].uvalue = p->RSSI * 1000;
283
284 /* Carrier to Noise ratio, in DB */
285 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
286 c->cnr.stat[0].svalue = p->snr * 1000;
287} 288}
288 289
289static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client, 290static 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 c->lna = p->IsExternalLNAOn ? 1 : 0; 313 c->lna = p->IsExternalLNAOn ? 1 : 0;
313 314
314 /* Carrier to Noise ratio, in DB */ 315 /* Carrier to Noise ratio, in DB */
315 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
316 c->cnr.stat[0].svalue = p->SNR * 1000; 316 c->cnr.stat[0].svalue = p->SNR * 1000;
317 317
318 /* Signal Strength, in DBm */ 318 /* Signal Strength, in DBm */
319 c->strength.stat[0].uvalue = p->RSSI * 1000; 319 c->strength.stat[0].uvalue = p->InBandPwr * 1000;
320
321 /* PER/BER requires demod lock */
322 if (!p->IsDemodLocked)
323 return;
320 324
321 /* TS PER */ 325 /* TS PER */
322 client->last_per = c->block_error.stat[0].uvalue; 326 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 c->lna = p->IsExternalLNAOn ? 1 : 0; 368 c->lna = p->IsExternalLNAOn ? 1 : 0;
365 369
366 /* Carrier to Noise ratio, in DB */ 370 /* Carrier to Noise ratio, in DB */
367 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
368 c->cnr.stat[0].svalue = p->SNR * 1000; 371 c->cnr.stat[0].svalue = p->SNR * 1000;
369 372
370 /* Signal Strength, in DBm */ 373 /* Signal Strength, in DBm */
371 c->strength.stat[0].uvalue = p->RSSI * 1000; 374 c->strength.stat[0].uvalue = p->InBandPwr * 1000;
375
376 /* PER/BER and per-layer stats require demod lock */
377 if (!p->IsDemodLocked)
378 return;
372 379
373 client->last_per = c->block_error.stat[0].uvalue; 380 client->last_per = c->block_error.stat[0].uvalue;
374 381
@@ -441,11 +448,14 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
441 c->lna = p->IsExternalLNAOn ? 1 : 0; 448 c->lna = p->IsExternalLNAOn ? 1 : 0;
442 449
443 /* Carrier to Noise ratio, in DB */ 450 /* Carrier to Noise ratio, in DB */
444 c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
445 c->cnr.stat[0].svalue = p->SNR * 1000; 451 c->cnr.stat[0].svalue = p->SNR * 1000;
446 452
447 /* Signal Strength, in DBm */ 453 /* Signal Strength, in DBm */
448 c->strength.stat[0].uvalue = p->RSSI * 1000; 454 c->strength.stat[0].uvalue = p->InBandPwr * 1000;
455
456 /* PER/BER and per-layer stats require demod lock */
457 if (!p->IsDemodLocked)
458 return;
449 459
450 client->last_per = c->block_error.stat[0].uvalue; 460 client->last_per = c->block_error.stat[0].uvalue;
451 461
@@ -943,11 +953,14 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
943 953
944static int smsdvb_set_frontend(struct dvb_frontend *fe) 954static int smsdvb_set_frontend(struct dvb_frontend *fe)
945{ 955{
956 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
946 struct smsdvb_client_t *client = 957 struct smsdvb_client_t *client =
947 container_of(fe, struct smsdvb_client_t, frontend); 958 container_of(fe, struct smsdvb_client_t, frontend);
948 struct smscore_device_t *coredev = client->coredev; 959 struct smscore_device_t *coredev = client->coredev;
949 960
950 smsdvb_stats_not_ready(fe); 961 smsdvb_stats_not_ready(fe);
962 c->strength.stat[0].uvalue = 0;
963 c->cnr.stat[0].uvalue = 0;
951 964
952 switch (smscore_get_device_mode(coredev)) { 965 switch (smscore_get_device_mode(coredev)) {
953 case DEVICE_MODE_DVBT: 966 case DEVICE_MODE_DVBT: