diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-25 09:29:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:26 -0500 |
commit | 5eb23975b441cb8814eab82f5768e09106d50578 (patch) | |
tree | d595ef294d234a2b51c4621033608140d459eec4 /drivers/media/dvb/siano | |
parent | 643e15a0f44156fa05d163f202a9dffb264d2078 (diff) |
V4L/DVB (13846): smsdvb: Properly implement stats for both DVB and ISDB-T
After taking a look at the driver's history and doing some tests with
DVB and ISDB-T, it was noticed that the stats were incomplete, for
ISDB-T, and weren't working for DVB.
Fixed the code and added a debug code to print the complete stats at
dmesg. This debug is useful to improve the stats of this driver.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/siano')
-rw-r--r-- | drivers/media/dvb/siano/smscoreapi.h | 77 | ||||
-rw-r--r-- | drivers/media/dvb/siano/smsdvb.c | 138 |
2 files changed, 201 insertions, 14 deletions
diff --git a/drivers/media/dvb/siano/smscoreapi.h b/drivers/media/dvb/siano/smscoreapi.h index 7393e2b5265a..8ecadecaa9d0 100644 --- a/drivers/media/dvb/siano/smscoreapi.h +++ b/drivers/media/dvb/siano/smscoreapi.h | |||
@@ -341,8 +341,8 @@ struct SmsFirmware_ST { | |||
341 | 341 | ||
342 | /* Statistics information returned as response for | 342 | /* Statistics information returned as response for |
343 | * SmsHostApiGetStatistics_Req */ | 343 | * SmsHostApiGetStatistics_Req */ |
344 | struct SMSHOSTLIB_STATISTICS_S { | 344 | struct SMSHOSTLIB_STATISTICS_ST { |
345 | u8 Reserved[5]; /* Reserved */ | 345 | u32 Reserved; /* Reserved */ |
346 | 346 | ||
347 | /* Common parameters */ | 347 | /* Common parameters */ |
348 | u32 IsRfLocked; /* 0 - not locked, 1 - locked */ | 348 | u32 IsRfLocked; /* 0 - not locked, 1 - locked */ |
@@ -426,6 +426,79 @@ struct SMSHOSTLIB_STATISTICS_S { | |||
426 | u32 ReservedFields[10]; /* Reserved */ | 426 | u32 ReservedFields[10]; /* Reserved */ |
427 | }; | 427 | }; |
428 | 428 | ||
429 | struct SmsMsgStatisticsInfo_ST { | ||
430 | u32 RequestResult; | ||
431 | |||
432 | struct SMSHOSTLIB_STATISTICS_ST Stat; | ||
433 | |||
434 | /* Split the calc of the SNR in DAB */ | ||
435 | u32 Signal; /* dB */ | ||
436 | u32 Noise; /* dB */ | ||
437 | |||
438 | }; | ||
439 | |||
440 | struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST { | ||
441 | /* Per-layer information */ | ||
442 | u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET, | ||
443 | * 255 means layer does not exist */ | ||
444 | u32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET, | ||
445 | * 255 means layer does not exist */ | ||
446 | u32 BER; /* Post Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */ | ||
447 | u32 BERErrorCount; /* Post Viterbi Error Bits Count */ | ||
448 | u32 BERBitCount; /* Post Viterbi Total Bits Count */ | ||
449 | u32 PreBER; /* Pre Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */ | ||
450 | u32 TS_PER; /* Transport stream PER [%], 0xFFFFFFFF indicate N/A */ | ||
451 | u32 ErrorTSPackets; /* Number of erroneous transport-stream packets */ | ||
452 | u32 TotalTSPackets; /* Total number of transport-stream packets */ | ||
453 | u32 TILdepthI; /* Time interleaver depth I parameter, | ||
454 | * 255 means layer does not exist */ | ||
455 | u32 NumberOfSegments; /* Number of segments in layer A, | ||
456 | * 255 means layer does not exist */ | ||
457 | u32 TMCCErrors; /* TMCC errors */ | ||
458 | }; | ||
459 | |||
460 | struct SMSHOSTLIB_STATISTICS_ISDBT_ST { | ||
461 | u32 StatisticsType; /* Enumerator identifying the type of the | ||
462 | * structure. Values are the same as | ||
463 | * SMSHOSTLIB_DEVICE_MODES_E | ||
464 | * | ||
465 | * This field MUST always be first in any | ||
466 | * statistics structure */ | ||
467 | |||
468 | u32 FullSize; /* Total size of the structure returned by the modem. | ||
469 | * If the size requested by the host is smaller than | ||
470 | * FullSize, the struct will be truncated */ | ||
471 | |||
472 | /* Common parameters */ | ||
473 | u32 IsRfLocked; /* 0 - not locked, 1 - locked */ | ||
474 | u32 IsDemodLocked; /* 0 - not locked, 1 - locked */ | ||
475 | u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */ | ||
476 | |||
477 | /* Reception quality */ | ||
478 | s32 SNR; /* dB */ | ||
479 | s32 RSSI; /* dBm */ | ||
480 | s32 InBandPwr; /* In band power in dBM */ | ||
481 | s32 CarrierOffset; /* Carrier Offset in Hz */ | ||
482 | |||
483 | /* Transmission parameters */ | ||
484 | u32 Frequency; /* Frequency in Hz */ | ||
485 | u32 Bandwidth; /* Bandwidth in MHz */ | ||
486 | u32 TransmissionMode; /* ISDB-T transmission mode */ | ||
487 | u32 ModemState; /* 0 - Acquisition, 1 - Locked */ | ||
488 | u32 GuardInterval; /* Guard Interval, 1 divided by value */ | ||
489 | u32 SystemType; /* ISDB-T system type (ISDB-T / ISDB-Tsb) */ | ||
490 | u32 PartialReception; /* TRUE - partial reception, FALSE otherwise */ | ||
491 | u32 NumOfLayers; /* Number of ISDB-T layers in the network */ | ||
492 | |||
493 | /* Per-layer information */ | ||
494 | /* Layers A, B and C */ | ||
495 | struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST LayerInfo[3]; | ||
496 | /* Per-layer statistics, see SMSHOSTLIB_ISDBT_LAYER_STAT_ST */ | ||
497 | |||
498 | /* Interface information */ | ||
499 | u32 SmsToHostTxErrors; /* Total number of transmission errors. */ | ||
500 | }; | ||
501 | |||
429 | struct PID_STATISTICS_DATA_S { | 502 | struct PID_STATISTICS_DATA_S { |
430 | struct PID_BURST_S { | 503 | struct PID_BURST_S { |
431 | u32 size; | 504 | u32 size; |
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c index 2f675cda9474..b44ba399799f 100644 --- a/drivers/media/dvb/siano/smsdvb.c +++ b/drivers/media/dvb/siano/smsdvb.c | |||
@@ -116,6 +116,119 @@ static void sms_board_dvb3_event(struct smsdvb_client_t *client, | |||
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | |||
120 | static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_S *pReceptionData, | ||
121 | struct SMSHOSTLIB_STATISTICS_ST *p) | ||
122 | { | ||
123 | if (sms_dbg & 2) { | ||
124 | printk(KERN_DEBUG "Reserved = %d", p->Reserved); | ||
125 | printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked); | ||
126 | printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked); | ||
127 | printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn); | ||
128 | printk(KERN_DEBUG "SNR = %d", p->SNR); | ||
129 | printk(KERN_DEBUG "BER = %d", p->BER); | ||
130 | printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC); | ||
131 | printk(KERN_DEBUG "TS_PER = %d", p->TS_PER); | ||
132 | printk(KERN_DEBUG "MFER = %d", p->MFER); | ||
133 | printk(KERN_DEBUG "RSSI = %d", p->RSSI); | ||
134 | printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr); | ||
135 | printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset); | ||
136 | printk(KERN_DEBUG "Frequency = %d", p->Frequency); | ||
137 | printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth); | ||
138 | printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode); | ||
139 | printk(KERN_DEBUG "ModemState = %d", p->ModemState); | ||
140 | printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval); | ||
141 | printk(KERN_DEBUG "CodeRate = %d", p->CodeRate); | ||
142 | printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate); | ||
143 | printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy); | ||
144 | printk(KERN_DEBUG "Constellation = %d", p->Constellation); | ||
145 | printk(KERN_DEBUG "BurstSize = %d", p->BurstSize); | ||
146 | printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration); | ||
147 | printk(KERN_DEBUG "BurstCycleTime = %d", p->BurstCycleTime); | ||
148 | printk(KERN_DEBUG "CalculatedBurstCycleTime = %d", p->CalculatedBurstCycleTime); | ||
149 | printk(KERN_DEBUG "NumOfRows = %d", p->NumOfRows); | ||
150 | printk(KERN_DEBUG "NumOfPaddCols = %d", p->NumOfPaddCols); | ||
151 | printk(KERN_DEBUG "NumOfPunctCols = %d", p->NumOfPunctCols); | ||
152 | printk(KERN_DEBUG "ErrorTSPackets = %d", p->ErrorTSPackets); | ||
153 | printk(KERN_DEBUG "TotalTSPackets = %d", p->TotalTSPackets); | ||
154 | printk(KERN_DEBUG "NumOfValidMpeTlbs = %d", p->NumOfValidMpeTlbs); | ||
155 | printk(KERN_DEBUG "NumOfInvalidMpeTlbs = %d", p->NumOfInvalidMpeTlbs); | ||
156 | printk(KERN_DEBUG "NumOfCorrectedMpeTlbs = %d", p->NumOfCorrectedMpeTlbs); | ||
157 | printk(KERN_DEBUG "BERErrorCount = %d", p->BERErrorCount); | ||
158 | printk(KERN_DEBUG "BERBitCount = %d", p->BERBitCount); | ||
159 | printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors); | ||
160 | printk(KERN_DEBUG "PreBER = %d", p->PreBER); | ||
161 | printk(KERN_DEBUG "CellId = %d", p->CellId); | ||
162 | printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP); | ||
163 | printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP); | ||
164 | printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived); | ||
165 | printk(KERN_DEBUG "ReservedFields[10] = %d", p->ReservedFields[10]); | ||
166 | } | ||
167 | |||
168 | pReceptionData->IsDemodLocked = p->IsDemodLocked; | ||
169 | |||
170 | pReceptionData->SNR = p->SNR; | ||
171 | pReceptionData->BER = p->BER; | ||
172 | pReceptionData->BERErrorCount = p->BERErrorCount; | ||
173 | pReceptionData->InBandPwr = p->InBandPwr; | ||
174 | pReceptionData->ErrorTSPackets = p->ErrorTSPackets; | ||
175 | }; | ||
176 | |||
177 | |||
178 | static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_S *pReceptionData, | ||
179 | struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p) | ||
180 | { | ||
181 | int i; | ||
182 | |||
183 | if (sms_dbg & 2) { | ||
184 | printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked); | ||
185 | printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked); | ||
186 | printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn); | ||
187 | printk(KERN_DEBUG "SNR = %d", p->SNR); | ||
188 | printk(KERN_DEBUG "RSSI = %d", p->RSSI); | ||
189 | printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr); | ||
190 | printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset); | ||
191 | printk(KERN_DEBUG "Frequency = %d", p->Frequency); | ||
192 | printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth); | ||
193 | printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode); | ||
194 | printk(KERN_DEBUG "ModemState = %d", p->ModemState); | ||
195 | printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval); | ||
196 | printk(KERN_DEBUG "SystemType = %d", p->SystemType); | ||
197 | printk(KERN_DEBUG "PartialReception = %d", p->PartialReception); | ||
198 | printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers); | ||
199 | printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors); | ||
200 | |||
201 | for (i = 0; i < 3; i++) { | ||
202 | printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate); | ||
203 | printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation); | ||
204 | printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER); | ||
205 | printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount); | ||
206 | printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount); | ||
207 | printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER); | ||
208 | printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER); | ||
209 | printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets); | ||
210 | printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets); | ||
211 | printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI); | ||
212 | printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments); | ||
213 | printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | pReceptionData->IsDemodLocked = p->IsDemodLocked; | ||
218 | |||
219 | pReceptionData->SNR = p->SNR; | ||
220 | pReceptionData->InBandPwr = p->InBandPwr; | ||
221 | |||
222 | pReceptionData->ErrorTSPackets = 0; | ||
223 | pReceptionData->BER = 0; | ||
224 | pReceptionData->BERErrorCount = 0; | ||
225 | for (i = 0; i < 3; i++) { | ||
226 | pReceptionData->BER += p->LayerInfo[i].BER; | ||
227 | pReceptionData->BERErrorCount += p->LayerInfo[i].BERErrorCount; | ||
228 | pReceptionData->ErrorTSPackets += p->LayerInfo[i].ErrorTSPackets; | ||
229 | } | ||
230 | } | ||
231 | |||
119 | static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | 232 | static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) |
120 | { | 233 | { |
121 | struct smsdvb_client_t *client = (struct smsdvb_client_t *) context; | 234 | struct smsdvb_client_t *client = (struct smsdvb_client_t *) context; |
@@ -219,32 +332,33 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | |||
219 | break; | 332 | break; |
220 | } | 333 | } |
221 | case MSG_SMS_GET_STATISTICS_RES: { | 334 | case MSG_SMS_GET_STATISTICS_RES: { |
222 | struct SMSHOSTLIB_STATISTICS_S *p = | 335 | union { |
223 | (struct SMSHOSTLIB_STATISTICS_S *)(phdr + 1); | 336 | struct SMSHOSTLIB_STATISTICS_ISDBT_ST isdbt; |
337 | struct SmsMsgStatisticsInfo_ST dvb; | ||
338 | } *p = (void *) (phdr + 1); | ||
224 | struct RECEPTION_STATISTICS_S *pReceptionData = | 339 | struct RECEPTION_STATISTICS_S *pReceptionData = |
225 | &client->sms_stat_dvb.ReceptionData; | 340 | &client->sms_stat_dvb.ReceptionData; |
226 | 341 | ||
227 | sms_info("MSG_SMS_GET_STATISTICS_RES"); | 342 | sms_info("MSG_SMS_GET_STATISTICS_RES"); |
228 | 343 | ||
229 | is_status_update = true; | 344 | is_status_update = true; |
230 | pReceptionData->IsDemodLocked = p->IsDemodLocked; | 345 | |
346 | switch (smscore_get_device_mode(client->coredev)) { | ||
347 | case DEVICE_MODE_ISDBT: | ||
348 | case DEVICE_MODE_ISDBT_BDA: | ||
349 | smsdvb_update_isdbt_stats(pReceptionData, &p->isdbt); | ||
350 | break; | ||
351 | default: | ||
352 | smsdvb_update_dvb_stats(pReceptionData, &p->dvb.Stat); | ||
353 | } | ||
231 | if (!pReceptionData->IsDemodLocked) { | 354 | if (!pReceptionData->IsDemodLocked) { |
232 | pReceptionData->SNR = 0; | 355 | pReceptionData->SNR = 0; |
233 | pReceptionData->BER = 0; | 356 | pReceptionData->BER = 0; |
234 | pReceptionData->BERErrorCount = 0; | 357 | pReceptionData->BERErrorCount = 0; |
235 | pReceptionData->InBandPwr = 0; | 358 | pReceptionData->InBandPwr = 0; |
236 | pReceptionData->ErrorTSPackets = 0; | 359 | pReceptionData->ErrorTSPackets = 0; |
237 | |||
238 | complete(&client->tune_done); | ||
239 | break; | ||
240 | } | 360 | } |
241 | 361 | ||
242 | pReceptionData->SNR = p->SNR; | ||
243 | pReceptionData->BER = p->BER; | ||
244 | pReceptionData->BERErrorCount = p->BERErrorCount; | ||
245 | pReceptionData->InBandPwr = p->InBandPwr; | ||
246 | pReceptionData->ErrorTSPackets = p->ErrorTSPackets; | ||
247 | |||
248 | complete(&client->tune_done); | 362 | complete(&client->tune_done); |
249 | break; | 363 | break; |
250 | } | 364 | } |