aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-io.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index a9889ff96ec..7aff8b72006 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -80,6 +80,10 @@ struct pvr2_stream {
80 /* Tracking state for tolerating errors */ 80 /* Tracking state for tolerating errors */
81 unsigned int fail_count; 81 unsigned int fail_count;
82 unsigned int fail_tolerance; 82 unsigned int fail_tolerance;
83
84 unsigned int buffers_processed;
85 unsigned int buffers_failed;
86 unsigned int bytes_processed;
83}; 87};
84 88
85struct pvr2_buffer { 89struct pvr2_buffer {
@@ -446,6 +450,8 @@ static void buffer_complete(struct urb *urb)
446 (urb->status == -ENOENT) || 450 (urb->status == -ENOENT) ||
447 (urb->status == -ECONNRESET) || 451 (urb->status == -ECONNRESET) ||
448 (urb->status == -ESHUTDOWN)) { 452 (urb->status == -ESHUTDOWN)) {
453 (sp->buffers_processed)++;
454 sp->bytes_processed += urb->actual_length;
449 bp->used_count = urb->actual_length; 455 bp->used_count = urb->actual_length;
450 if (sp->fail_count) { 456 if (sp->fail_count) {
451 pvr2_trace(PVR2_TRACE_TOLERANCE, 457 pvr2_trace(PVR2_TRACE_TOLERANCE,
@@ -457,11 +463,13 @@ static void buffer_complete(struct urb *urb)
457 // We can tolerate this error, because we're below the 463 // We can tolerate this error, because we're below the
458 // threshold... 464 // threshold...
459 (sp->fail_count)++; 465 (sp->fail_count)++;
466 (sp->buffers_failed)++;
460 pvr2_trace(PVR2_TRACE_TOLERANCE, 467 pvr2_trace(PVR2_TRACE_TOLERANCE,
461 "stream %p ignoring error %d" 468 "stream %p ignoring error %d"
462 " - fail count increased to %u", 469 " - fail count increased to %u",
463 sp,urb->status,sp->fail_count); 470 sp,urb->status,sp->fail_count);
464 } else { 471 } else {
472 (sp->buffers_failed)++;
465 bp->status = urb->status; 473 bp->status = urb->status;
466 } 474 }
467 spin_unlock_irqrestore(&sp->list_lock,irq_flags); 475 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
@@ -515,6 +523,28 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp,
515 } while(0); mutex_unlock(&sp->mutex); 523 } while(0); mutex_unlock(&sp->mutex);
516} 524}
517 525
526void pvr2_stream_get_stats(struct pvr2_stream *sp,
527 struct pvr2_stream_stats *stats,
528 int zero_counts)
529{
530 unsigned long irq_flags;
531 spin_lock_irqsave(&sp->list_lock,irq_flags);
532 if (stats) {
533 stats->buffers_in_queue = sp->q_count;
534 stats->buffers_in_idle = sp->i_count;
535 stats->buffers_in_ready = sp->r_count;
536 stats->buffers_processed = sp->buffers_processed;
537 stats->buffers_failed = sp->buffers_failed;
538 stats->bytes_processed = sp->bytes_processed;
539 }
540 if (zero_counts) {
541 sp->buffers_processed = 0;
542 sp->buffers_failed = 0;
543 sp->bytes_processed = 0;
544 }
545 spin_unlock_irqrestore(&sp->list_lock,irq_flags);
546}
547
518/* Query / set the nominal buffer count */ 548/* Query / set the nominal buffer count */
519int pvr2_stream_get_buffer_count(struct pvr2_stream *sp) 549int pvr2_stream_get_buffer_count(struct pvr2_stream *sp)
520{ 550{