aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common/siano
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2013-03-09 20:33:06 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-21 06:47:49 -0400
commit3f6b87cff66bb8507aefd62559c516dd7c8f822a (patch)
tree648010919c825c32148e74dadfa34a50812685ef /drivers/media/common/siano
parentc02272f9b9c71c5fe6c0cb3874ec153ff2e842ef (diff)
[media] siano: allow showing the complete statistics via debugfs
Outputs the result of the statistics responses via debugfs. That can help to track bugs at the stats filling. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common/siano')
-rw-r--r--drivers/media/common/siano/smsdvb.c464
1 files changed, 355 insertions, 109 deletions
diff --git a/drivers/media/common/siano/smsdvb.c b/drivers/media/common/siano/smsdvb.c
index 70ea3e9b4ac6..aeadd8a42775 100644
--- a/drivers/media/common/siano/smsdvb.c
+++ b/drivers/media/common/siano/smsdvb.c
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/debugfs.h>
25 26
26#include "dmxdev.h" 27#include "dmxdev.h"
27#include "dvbdev.h" 28#include "dvbdev.h"
@@ -55,6 +56,13 @@ struct smsdvb_client_t {
55 56
56 int event_fe_state; 57 int event_fe_state;
57 int event_unc_state; 58 int event_unc_state;
59
60 /* Stats debugfs data */
61 struct dentry *debugfs;
62 char *stats_data;
63 atomic_t stats_count;
64 bool stats_was_read;
65 wait_queue_head_t stats_queue;
58}; 66};
59 67
60static struct list_head g_smsdvb_clients; 68static struct list_head g_smsdvb_clients;
@@ -140,134 +148,358 @@ u32 sms_to_modulation_table[] = {
140 [3] = DQPSK, 148 [3] = DQPSK,
141}; 149};
142 150
143static void smsdvb_print_dvb_stats(struct SMSHOSTLIB_STATISTICS_ST *p) 151static struct dentry *smsdvb_debugfs;
152
153static void smsdvb_print_dvb_stats(struct smsdvb_client_t *client,
154 struct SMSHOSTLIB_STATISTICS_ST *p)
144{ 155{
145 if (!(sms_dbg & 2)) 156 int n = 0;
157 char *buf;
158
159 if (!client->stats_data || atomic_read(&client->stats_count))
146 return; 160 return;
147 161
148 printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked); 162 buf = client->stats_data;
149 printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked); 163
150 printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn); 164 n += snprintf(&buf[n], PAGE_SIZE - n,
151 printk(KERN_DEBUG "SNR = %d", p->SNR); 165 "IsRfLocked = %d\n", p->IsRfLocked);
152 printk(KERN_DEBUG "BER = %d", p->BER); 166 n += snprintf(&buf[n], PAGE_SIZE - n,
153 printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC); 167 "IsDemodLocked = %d\n", p->IsDemodLocked);
154 printk(KERN_DEBUG "TS_PER = %d", p->TS_PER); 168 n += snprintf(&buf[n], PAGE_SIZE - n,
155 printk(KERN_DEBUG "MFER = %d", p->MFER); 169 "IsExternalLNAOn = %d\n", p->IsExternalLNAOn);
156 printk(KERN_DEBUG "RSSI = %d", p->RSSI); 170 n += snprintf(&buf[n], PAGE_SIZE - n,
157 printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr); 171 "SNR = %d\n", p->SNR);
158 printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset); 172 n += snprintf(&buf[n], PAGE_SIZE - n,
159 printk(KERN_DEBUG "ModemState = %d", p->ModemState); 173 "BER = %d\n", p->BER);
160 printk(KERN_DEBUG "Frequency = %d", p->Frequency); 174 n += snprintf(&buf[n], PAGE_SIZE - n,
161 printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth); 175 "FIB_CRC = %d\n", p->FIB_CRC);
162 printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode); 176 n += snprintf(&buf[n], PAGE_SIZE - n,
163 printk(KERN_DEBUG "ModemState = %d", p->ModemState); 177 "TS_PER = %d\n", p->TS_PER);
164 printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval); 178 n += snprintf(&buf[n], PAGE_SIZE - n,
165 printk(KERN_DEBUG "CodeRate = %d", p->CodeRate); 179 "MFER = %d\n", p->MFER);
166 printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate); 180 n += snprintf(&buf[n], PAGE_SIZE - n,
167 printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy); 181 "RSSI = %d\n", p->RSSI);
168 printk(KERN_DEBUG "Constellation = %d", p->Constellation); 182 n += snprintf(&buf[n], PAGE_SIZE - n,
169 printk(KERN_DEBUG "BurstSize = %d", p->BurstSize); 183 "InBandPwr = %d\n", p->InBandPwr);
170 printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration); 184 n += snprintf(&buf[n], PAGE_SIZE - n,
171 printk(KERN_DEBUG "BurstCycleTime = %d", p->BurstCycleTime); 185 "CarrierOffset = %d\n", p->CarrierOffset);
172 printk(KERN_DEBUG "CalculatedBurstCycleTime = %d", p->CalculatedBurstCycleTime); 186 n += snprintf(&buf[n], PAGE_SIZE - n,
173 printk(KERN_DEBUG "NumOfRows = %d", p->NumOfRows); 187 "ModemState = %d\n", p->ModemState);
174 printk(KERN_DEBUG "NumOfPaddCols = %d", p->NumOfPaddCols); 188 n += snprintf(&buf[n], PAGE_SIZE - n,
175 printk(KERN_DEBUG "NumOfPunctCols = %d", p->NumOfPunctCols); 189 "Frequency = %d\n", p->Frequency);
176 printk(KERN_DEBUG "ErrorTSPackets = %d", p->ErrorTSPackets); 190 n += snprintf(&buf[n], PAGE_SIZE - n,
177 printk(KERN_DEBUG "TotalTSPackets = %d", p->TotalTSPackets); 191 "Bandwidth = %d\n", p->Bandwidth);
178 printk(KERN_DEBUG "NumOfValidMpeTlbs = %d", p->NumOfValidMpeTlbs); 192 n += snprintf(&buf[n], PAGE_SIZE - n,
179 printk(KERN_DEBUG "NumOfInvalidMpeTlbs = %d", p->NumOfInvalidMpeTlbs); 193 "TransmissionMode = %d\n", p->TransmissionMode);
180 printk(KERN_DEBUG "NumOfCorrectedMpeTlbs = %d", p->NumOfCorrectedMpeTlbs); 194 n += snprintf(&buf[n], PAGE_SIZE - n,
181 printk(KERN_DEBUG "BERErrorCount = %d", p->BERErrorCount); 195 "ModemState = %d\n", p->ModemState);
182 printk(KERN_DEBUG "BERBitCount = %d", p->BERBitCount); 196 n += snprintf(&buf[n], PAGE_SIZE - n,
183 printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors); 197 "GuardInterval = %d\n", p->GuardInterval);
184 printk(KERN_DEBUG "PreBER = %d", p->PreBER); 198 n += snprintf(&buf[n], PAGE_SIZE - n,
185 printk(KERN_DEBUG "CellId = %d", p->CellId); 199 "CodeRate = %d\n", p->CodeRate);
186 printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP); 200 n += snprintf(&buf[n], PAGE_SIZE - n,
187 printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP); 201 "LPCodeRate = %d\n", p->LPCodeRate);
188 printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived); 202 n += snprintf(&buf[n], PAGE_SIZE - n,
203 "Hierarchy = %d\n", p->Hierarchy);
204 n += snprintf(&buf[n], PAGE_SIZE - n,
205 "Constellation = %d\n", p->Constellation);
206 n += snprintf(&buf[n], PAGE_SIZE - n,
207 "BurstSize = %d\n", p->BurstSize);
208 n += snprintf(&buf[n], PAGE_SIZE - n,
209 "BurstDuration = %d\n", p->BurstDuration);
210 n += snprintf(&buf[n], PAGE_SIZE - n,
211 "BurstCycleTime = %d\n", p->BurstCycleTime);
212 n += snprintf(&buf[n], PAGE_SIZE - n,
213 "CalculatedBurstCycleTime = %d\n",
214 p->CalculatedBurstCycleTime);
215 n += snprintf(&buf[n], PAGE_SIZE - n,
216 "NumOfRows = %d\n", p->NumOfRows);
217 n += snprintf(&buf[n], PAGE_SIZE - n,
218 "NumOfPaddCols = %d\n", p->NumOfPaddCols);
219 n += snprintf(&buf[n], PAGE_SIZE - n,
220 "NumOfPunctCols = %d\n", p->NumOfPunctCols);
221 n += snprintf(&buf[n], PAGE_SIZE - n,
222 "ErrorTSPackets = %d\n", p->ErrorTSPackets);
223 n += snprintf(&buf[n], PAGE_SIZE - n,
224 "TotalTSPackets = %d\n", p->TotalTSPackets);
225 n += snprintf(&buf[n], PAGE_SIZE - n,
226 "NumOfValidMpeTlbs = %d\n", p->NumOfValidMpeTlbs);
227 n += snprintf(&buf[n], PAGE_SIZE - n,
228 "NumOfInvalidMpeTlbs = %d\n", p->NumOfInvalidMpeTlbs);
229 n += snprintf(&buf[n], PAGE_SIZE - n,
230 "NumOfCorrectedMpeTlbs = %d\n", p->NumOfCorrectedMpeTlbs);
231 n += snprintf(&buf[n], PAGE_SIZE - n,
232 "BERErrorCount = %d\n", p->BERErrorCount);
233 n += snprintf(&buf[n], PAGE_SIZE - n,
234 "BERBitCount = %d\n", p->BERBitCount);
235 n += snprintf(&buf[n], PAGE_SIZE - n,
236 "SmsToHostTxErrors = %d\n", p->SmsToHostTxErrors);
237 n += snprintf(&buf[n], PAGE_SIZE - n,
238 "PreBER = %d\n", p->PreBER);
239 n += snprintf(&buf[n], PAGE_SIZE - n,
240 "CellId = %d\n", p->CellId);
241 n += snprintf(&buf[n], PAGE_SIZE - n,
242 "DvbhSrvIndHP = %d\n", p->DvbhSrvIndHP);
243 n += snprintf(&buf[n], PAGE_SIZE - n,
244 "DvbhSrvIndLP = %d\n", p->DvbhSrvIndLP);
245 n += snprintf(&buf[n], PAGE_SIZE - n,
246 "NumMPEReceived = %d\n", p->NumMPEReceived);
247
248 atomic_set(&client->stats_count, n);
249 wake_up(&client->stats_queue);
189} 250}
190 251
191static void smsdvb_print_isdb_stats(struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p) 252static void smsdvb_print_isdb_stats(struct smsdvb_client_t *client,
253 struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
192{ 254{
193 int i; 255 int i, n = 0;
256 char *buf;
194 257
195 if (!(sms_dbg & 2)) 258 if (!client->stats_data || atomic_read(&client->stats_count))
196 return; 259 return;
197 260
198 printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked); 261 buf = client->stats_data;
199 printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked); 262
200 printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn); 263 n += snprintf(&buf[n], PAGE_SIZE - n,
201 printk(KERN_DEBUG "SNR = %d", p->SNR); 264 "IsRfLocked = %d\t\t", p->IsRfLocked);
202 printk(KERN_DEBUG "RSSI = %d", p->RSSI); 265 n += snprintf(&buf[n], PAGE_SIZE - n,
203 printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr); 266 "IsDemodLocked = %d\t", p->IsDemodLocked);
204 printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset); 267 n += snprintf(&buf[n], PAGE_SIZE - n,
205 printk(KERN_DEBUG "Frequency = %d", p->Frequency); 268 "IsExternalLNAOn = %d\n", p->IsExternalLNAOn);
206 printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth); 269 n += snprintf(&buf[n], PAGE_SIZE - n,
207 printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode); 270 "SNR = %d dB\t\t", p->SNR);
208 printk(KERN_DEBUG "ModemState = %d", p->ModemState); 271 n += snprintf(&buf[n], PAGE_SIZE - n,
209 printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval); 272 "RSSI = %d dBm\t\t", p->RSSI);
210 printk(KERN_DEBUG "SystemType = %d", p->SystemType); 273 n += snprintf(&buf[n], PAGE_SIZE - n,
211 printk(KERN_DEBUG "PartialReception = %d", p->PartialReception); 274 "InBandPwr = %d dBm\n", p->InBandPwr);
212 printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers); 275 n += snprintf(&buf[n], PAGE_SIZE - n,
213 printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors); 276 "CarrierOffset = %d\t", p->CarrierOffset);
277 n += snprintf(&buf[n], PAGE_SIZE - n,
278 "Bandwidth = %d\t\t", p->Bandwidth);
279 n += snprintf(&buf[n], PAGE_SIZE - n,
280 "Frequency = %d Hz\n", p->Frequency);
281 n += snprintf(&buf[n], PAGE_SIZE - n,
282 "TransmissionMode = %d\t", p->TransmissionMode);
283 n += snprintf(&buf[n], PAGE_SIZE - n,
284 "ModemState = %d\t\t", p->ModemState);
285 n += snprintf(&buf[n], PAGE_SIZE - n,
286 "GuardInterval = %d\n", p->GuardInterval);
287 n += snprintf(&buf[n], PAGE_SIZE - n,
288 "SystemType = %d\t\t", p->SystemType);
289 n += snprintf(&buf[n], PAGE_SIZE - n,
290 "PartialReception = %d\t", p->PartialReception);
291 n += snprintf(&buf[n], PAGE_SIZE - n,
292 "NumOfLayers = %d\n", p->NumOfLayers);
293 n += snprintf(&buf[n], PAGE_SIZE - n,
294 "SmsToHostTxErrors = %d\n", p->SmsToHostTxErrors);
214 295
215 for (i = 0; i < 3; i++) { 296 for (i = 0; i < 3; i++) {
216 printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate); 297 if (p->LayerInfo[i].NumberOfSegments < 1 ||
217 printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation); 298 p->LayerInfo[i].NumberOfSegments > 13)
218 printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER); 299 continue;
219 printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount); 300
220 printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount); 301 n += snprintf(&buf[n], PAGE_SIZE - n, "\nLayer %d\n", i);
221 printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER); 302 n += snprintf(&buf[n], PAGE_SIZE - n, "\tCodeRate = %d\t",
222 printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER); 303 p->LayerInfo[i].CodeRate);
223 printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets); 304 n += snprintf(&buf[n], PAGE_SIZE - n, "Constellation = %d\n",
224 printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets); 305 p->LayerInfo[i].Constellation);
225 printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI); 306 n += snprintf(&buf[n], PAGE_SIZE - n, "\tBER = %-5d\t",
226 printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments); 307 p->LayerInfo[i].BER);
227 printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors); 308 n += snprintf(&buf[n], PAGE_SIZE - n, "\tBERErrorCount = %-5d\t",
309 p->LayerInfo[i].BERErrorCount);
310 n += snprintf(&buf[n], PAGE_SIZE - n, "BERBitCount = %-5d\n",
311 p->LayerInfo[i].BERBitCount);
312 n += snprintf(&buf[n], PAGE_SIZE - n, "\tPreBER = %-5d\t",
313 p->LayerInfo[i].PreBER);
314 n += snprintf(&buf[n], PAGE_SIZE - n, "\tTS_PER = %-5d\n",
315 p->LayerInfo[i].TS_PER);
316 n += snprintf(&buf[n], PAGE_SIZE - n, "\tErrorTSPackets = %-5d\t",
317 p->LayerInfo[i].ErrorTSPackets);
318 n += snprintf(&buf[n], PAGE_SIZE - n, "TotalTSPackets = %-5d\t",
319 p->LayerInfo[i].TotalTSPackets);
320 n += snprintf(&buf[n], PAGE_SIZE - n, "TILdepthI = %d\n",
321 p->LayerInfo[i].TILdepthI);
322 n += snprintf(&buf[n], PAGE_SIZE - n,
323 "\tNumberOfSegments = %d\t",
324 p->LayerInfo[i].NumberOfSegments);
325 n += snprintf(&buf[n], PAGE_SIZE - n, "TMCCErrors = %d\n",
326 p->LayerInfo[i].TMCCErrors);
228 } 327 }
328
329 atomic_set(&client->stats_count, n);
330 wake_up(&client->stats_queue);
229} 331}
230 332
231static void 333static void
232smsdvb_print_isdb_stats_ex(struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p) 334smsdvb_print_isdb_stats_ex(struct smsdvb_client_t *client,
335 struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
233{ 336{
234 int i; 337 int i, n = 0;
338 char *buf;
235 339
236 if (!(sms_dbg & 2)) 340 if (!client->stats_data || atomic_read(&client->stats_count))
237 return; 341 return;
238 342
239 printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked); 343 buf = client->stats_data;
240 printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked); 344
241 printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn); 345 n += snprintf(&buf[n], PAGE_SIZE - n,
242 printk(KERN_DEBUG "SNR = %d", p->SNR); 346 "IsRfLocked = %d\t\t", p->IsRfLocked);
243 printk(KERN_DEBUG "RSSI = %d", p->RSSI); 347 n += snprintf(&buf[n], PAGE_SIZE - n,
244 printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr); 348 "IsDemodLocked = %d\t", p->IsDemodLocked);
245 printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset); 349 n += snprintf(&buf[n], PAGE_SIZE - n,
246 printk(KERN_DEBUG "Frequency = %d", p->Frequency); 350 "IsExternalLNAOn = %d\n", p->IsExternalLNAOn);
247 printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth); 351 n += snprintf(&buf[n], PAGE_SIZE - n,
248 printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode); 352 "SNR = %d dB\t\t", p->SNR);
249 printk(KERN_DEBUG "ModemState = %d", p->ModemState); 353 n += snprintf(&buf[n], PAGE_SIZE - n,
250 printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval); 354 "RSSI = %d dBm\t\t", p->RSSI);
251 printk(KERN_DEBUG "SystemType = %d", p->SystemType); 355 n += snprintf(&buf[n], PAGE_SIZE - n,
252 printk(KERN_DEBUG "PartialReception = %d", p->PartialReception); 356 "InBandPwr = %d dBm\n", p->InBandPwr);
253 printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers); 357 n += snprintf(&buf[n], PAGE_SIZE - n,
254 printk(KERN_DEBUG "SegmentNumber = %d", p->SegmentNumber); 358 "CarrierOffset = %d\t", p->CarrierOffset);
255 printk(KERN_DEBUG "TuneBW = %d", p->TuneBW); 359 n += snprintf(&buf[n], PAGE_SIZE - n,
360 "Bandwidth = %d\t\t", p->Bandwidth);
361 n += snprintf(&buf[n], PAGE_SIZE - n,
362 "Frequency = %d Hz\n", p->Frequency);
363 n += snprintf(&buf[n], PAGE_SIZE - n,
364 "TransmissionMode = %d\t", p->TransmissionMode);
365 n += snprintf(&buf[n], PAGE_SIZE - n,
366 "ModemState = %d\t\t", p->ModemState);
367 n += snprintf(&buf[n], PAGE_SIZE - n,
368 "GuardInterval = %d\n", p->GuardInterval);
369 n += snprintf(&buf[n], PAGE_SIZE - n,
370 "SystemType = %d\t\t", p->SystemType);
371 n += snprintf(&buf[n], PAGE_SIZE - n,
372 "PartialReception = %d\t", p->PartialReception);
373 n += snprintf(&buf[n], PAGE_SIZE - n,
374 "NumOfLayers = %d\n", p->NumOfLayers);
375 n += snprintf(&buf[n], PAGE_SIZE - n, "SegmentNumber = %d\t",
376 p->SegmentNumber);
377 n += snprintf(&buf[n], PAGE_SIZE - n, "TuneBW = %d\n",
378 p->TuneBW);
256 379
257 for (i = 0; i < 3; i++) { 380 for (i = 0; i < 3; i++) {
258 printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate); 381 if (p->LayerInfo[i].NumberOfSegments < 1 ||
259 printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation); 382 p->LayerInfo[i].NumberOfSegments > 13)
260 printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER); 383 continue;
261 printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount); 384
262 printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount); 385 n += snprintf(&buf[n], PAGE_SIZE - n, "\nLayer %d\n", i);
263 printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER); 386 n += snprintf(&buf[n], PAGE_SIZE - n, "\tCodeRate = %d\t",
264 printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER); 387 p->LayerInfo[i].CodeRate);
265 printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets); 388 n += snprintf(&buf[n], PAGE_SIZE - n, "Constellation = %d\n",
266 printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets); 389 p->LayerInfo[i].Constellation);
267 printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI); 390 n += snprintf(&buf[n], PAGE_SIZE - n, "\tBER = %-5d\t",
268 printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments); 391 p->LayerInfo[i].BER);
269 printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors); 392 n += snprintf(&buf[n], PAGE_SIZE - n, "\tBERErrorCount = %-5d\t",
393 p->LayerInfo[i].BERErrorCount);
394 n += snprintf(&buf[n], PAGE_SIZE - n, "BERBitCount = %-5d\n",
395 p->LayerInfo[i].BERBitCount);
396 n += snprintf(&buf[n], PAGE_SIZE - n, "\tPreBER = %-5d\t",
397 p->LayerInfo[i].PreBER);
398 n += snprintf(&buf[n], PAGE_SIZE - n, "\tTS_PER = %-5d\n",
399 p->LayerInfo[i].TS_PER);
400 n += snprintf(&buf[n], PAGE_SIZE - n, "\tErrorTSPackets = %-5d\t",
401 p->LayerInfo[i].ErrorTSPackets);
402 n += snprintf(&buf[n], PAGE_SIZE - n, "TotalTSPackets = %-5d\t",
403 p->LayerInfo[i].TotalTSPackets);
404 n += snprintf(&buf[n], PAGE_SIZE - n, "TILdepthI = %d\n",
405 p->LayerInfo[i].TILdepthI);
406 n += snprintf(&buf[n], PAGE_SIZE - n,
407 "\tNumberOfSegments = %d\t",
408 p->LayerInfo[i].NumberOfSegments);
409 n += snprintf(&buf[n], PAGE_SIZE - n, "TMCCErrors = %d\n",
410 p->LayerInfo[i].TMCCErrors);
411 }
412
413 atomic_set(&client->stats_count, n);
414 wake_up(&client->stats_queue);
415}
416
417static int smsdvb_stats_open(struct inode *inode, struct file *file)
418{
419 struct smsdvb_client_t *client = inode->i_private;
420
421 atomic_set(&client->stats_count, 0);
422 client->stats_was_read = false;
423
424 init_waitqueue_head(&client->stats_queue);
425
426 client->stats_data = kmalloc(PAGE_SIZE, GFP_KERNEL);
427 if (client->stats_data == NULL)
428 return -ENOMEM;
429
430 file->private_data = client;
431
432 return 0;
433}
434
435static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf,
436 size_t nbytes, loff_t *ppos)
437{
438 struct smsdvb_client_t *client = file->private_data;
439
440 if (!client->stats_data || client->stats_was_read)
441 return 0;
442
443 wait_event_interruptible(client->stats_queue,
444 atomic_read(&client->stats_count));
445
446 return simple_read_from_buffer(user_buf, nbytes, ppos,
447 client->stats_data,
448 atomic_read(&client->stats_count));
449
450 client->stats_was_read = true;
451}
452
453static int smsdvb_stats_release(struct inode *inode, struct file *file)
454{
455 struct smsdvb_client_t *client = file->private_data;
456
457 kfree(client->stats_data);
458 client->stats_data = NULL;
459
460 return 0;
461}
462
463static const struct file_operations debugfs_stats_ops = {
464 .open = smsdvb_stats_open,
465 .read = smsdvb_stats_read,
466 .release = smsdvb_stats_release,
467 .llseek = generic_file_llseek,
468};
469
470static int create_stats_debugfs(struct smsdvb_client_t *client)
471{
472 struct smscore_device_t *coredev = client->coredev;
473 struct dentry *d;
474
475 if (!smsdvb_debugfs)
476 return -ENODEV;
477
478 client->debugfs = debugfs_create_dir(coredev->devpath, smsdvb_debugfs);
479 if (IS_ERR_OR_NULL(client->debugfs)) {
480 sms_info("Unable to create debugfs %s directory.\n",
481 coredev->devpath);
482 return -ENODEV;
270 } 483 }
484
485 d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
486 client, &debugfs_stats_ops);
487 if (!d) {
488 debugfs_remove(client->debugfs);
489 return -ENOMEM;
490 }
491
492 return 0;
493}
494
495static void release_stats_debugfs(struct smsdvb_client_t *client)
496{
497 if (!client->debugfs)
498 return;
499
500 debugfs_remove_recursive(client->debugfs);
501
502 client->debugfs = NULL;
271} 503}
272 504
273/* Events that may come from DVB v3 adapter */ 505/* Events that may come from DVB v3 adapter */
@@ -476,7 +708,7 @@ static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client,
476 struct dvb_frontend *fe = &client->frontend; 708 struct dvb_frontend *fe = &client->frontend;
477 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 709 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
478 710
479 smsdvb_print_dvb_stats(p); 711 smsdvb_print_dvb_stats(client, p);
480 712
481 client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked); 713 client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
482 714
@@ -526,7 +758,7 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
526 struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr; 758 struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr;
527 int i, n_layers; 759 int i, n_layers;
528 760
529 smsdvb_print_isdb_stats(p); 761 smsdvb_print_isdb_stats(client, p);
530 762
531 /* Update ISDB-T transmission parameters */ 763 /* Update ISDB-T transmission parameters */
532 c->frequency = p->Frequency; 764 c->frequency = p->Frequency;
@@ -602,7 +834,7 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
602 struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr; 834 struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr;
603 int i, n_layers; 835 int i, n_layers;
604 836
605 smsdvb_print_isdb_stats_ex(p); 837 smsdvb_print_isdb_stats_ex(client, p);
606 838
607 /* Update ISDB-T transmission parameters */ 839 /* Update ISDB-T transmission parameters */
608 c->frequency = p->Frequency; 840 c->frequency = p->Frequency;
@@ -766,6 +998,7 @@ static void smsdvb_unregister_client(struct smsdvb_client_t *client)
766 998
767 list_del(&client->entry); 999 list_del(&client->entry);
768 1000
1001 release_stats_debugfs(client);
769 smscore_unregister_client(client->smsclient); 1002 smscore_unregister_client(client->smsclient);
770 dvb_unregister_frontend(&client->frontend); 1003 dvb_unregister_frontend(&client->frontend);
771 dvb_dmxdev_release(&client->dmxdev); 1004 dvb_dmxdev_release(&client->dmxdev);
@@ -1303,6 +1536,9 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
1303 sms_info("success"); 1536 sms_info("success");
1304 sms_board_setup(coredev); 1537 sms_board_setup(coredev);
1305 1538
1539 if (create_stats_debugfs(client) < 0)
1540 sms_info("failed to create debugfs node");
1541
1306 return 0; 1542 return 0;
1307 1543
1308client_error: 1544client_error:
@@ -1325,10 +1561,17 @@ adapter_error:
1325static int __init smsdvb_module_init(void) 1561static int __init smsdvb_module_init(void)
1326{ 1562{
1327 int rc; 1563 int rc;
1564 struct dentry *d;
1328 1565
1329 INIT_LIST_HEAD(&g_smsdvb_clients); 1566 INIT_LIST_HEAD(&g_smsdvb_clients);
1330 kmutex_init(&g_smsdvb_clientslock); 1567 kmutex_init(&g_smsdvb_clientslock);
1331 1568
1569 d = debugfs_create_dir("smsdvb", usb_debug_root);
1570 if (IS_ERR_OR_NULL(d))
1571 sms_err("Couldn't create sysfs node for smsdvb");
1572 else
1573 smsdvb_debugfs = d;
1574
1332 rc = smscore_register_hotplug(smsdvb_hotplug); 1575 rc = smscore_register_hotplug(smsdvb_hotplug);
1333 1576
1334 sms_debug(""); 1577 sms_debug("");
@@ -1346,6 +1589,9 @@ static void __exit smsdvb_module_exit(void)
1346 smsdvb_unregister_client( 1589 smsdvb_unregister_client(
1347 (struct smsdvb_client_t *) g_smsdvb_clients.next); 1590 (struct smsdvb_client_t *) g_smsdvb_clients.next);
1348 1591
1592 if (smsdvb_debugfs)
1593 debugfs_remove_recursive(smsdvb_debugfs);
1594
1349 kmutex_unlock(&g_smsdvb_clientslock); 1595 kmutex_unlock(&g_smsdvb_clientslock);
1350} 1596}
1351 1597