diff options
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-io.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-io.c | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c index a984c91f571c..681f79c8064e 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-io.c +++ b/drivers/media/video/pvrusb2/pvrusb2-io.c | |||
@@ -93,7 +93,7 @@ struct pvr2_buffer { | |||
93 | struct urb *purb; | 93 | struct urb *purb; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st) | 96 | static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st) |
97 | { | 97 | { |
98 | switch (st) { | 98 | switch (st) { |
99 | case pvr2_buffer_state_none: return "none"; | 99 | case pvr2_buffer_state_none: return "none"; |
@@ -104,7 +104,8 @@ const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st) | |||
104 | return "unknown"; | 104 | return "unknown"; |
105 | } | 105 | } |
106 | 106 | ||
107 | void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg) | 107 | #ifdef SANITY_CHECK_BUFFERS |
108 | static void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg) | ||
108 | { | 109 | { |
109 | pvr2_trace(PVR2_TRACE_INFO, | 110 | pvr2_trace(PVR2_TRACE_INFO, |
110 | "buffer%s%s %p state=%s id=%d status=%d" | 111 | "buffer%s%s %p state=%s id=%d status=%d" |
@@ -115,10 +116,11 @@ void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg) | |||
115 | (bp ? pvr2_buffer_state_decode(bp->state) : "(invalid)"), | 116 | (bp ? pvr2_buffer_state_decode(bp->state) : "(invalid)"), |
116 | (bp ? bp->id : 0), | 117 | (bp ? bp->id : 0), |
117 | (bp ? bp->status : 0), | 118 | (bp ? bp->status : 0), |
118 | (bp ? bp->stream : 0), | 119 | (bp ? bp->stream : NULL), |
119 | (bp ? bp->purb : 0), | 120 | (bp ? bp->purb : NULL), |
120 | (bp ? bp->signature : 0)); | 121 | (bp ? bp->signature : 0)); |
121 | } | 122 | } |
123 | #endif /* SANITY_CHECK_BUFFERS */ | ||
122 | 124 | ||
123 | static void pvr2_buffer_remove(struct pvr2_buffer *bp) | 125 | static void pvr2_buffer_remove(struct pvr2_buffer *bp) |
124 | { | 126 | { |
@@ -284,7 +286,7 @@ static void pvr2_buffer_done(struct pvr2_buffer *bp) | |||
284 | pvr2_buffer_wipe(bp); | 286 | pvr2_buffer_wipe(bp); |
285 | pvr2_buffer_set_none(bp); | 287 | pvr2_buffer_set_none(bp); |
286 | bp->signature = 0; | 288 | bp->signature = 0; |
287 | bp->stream = 0; | 289 | bp->stream = NULL; |
288 | if (bp->purb) usb_free_urb(bp->purb); | 290 | if (bp->purb) usb_free_urb(bp->purb); |
289 | pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/" | 291 | pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/" |
290 | " bufferDone %p",bp); | 292 | " bufferDone %p",bp); |
@@ -339,13 +341,13 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt) | |||
339 | struct pvr2_buffer *bp; | 341 | struct pvr2_buffer *bp; |
340 | bp = sp->buffers[sp->buffer_total_count - 1]; | 342 | bp = sp->buffers[sp->buffer_total_count - 1]; |
341 | /* Paranoia */ | 343 | /* Paranoia */ |
342 | sp->buffers[sp->buffer_total_count - 1] = 0; | 344 | sp->buffers[sp->buffer_total_count - 1] = NULL; |
343 | (sp->buffer_total_count)--; | 345 | (sp->buffer_total_count)--; |
344 | pvr2_buffer_done(bp); | 346 | pvr2_buffer_done(bp); |
345 | kfree(bp); | 347 | kfree(bp); |
346 | } | 348 | } |
347 | if (scnt < sp->buffer_slot_count) { | 349 | if (scnt < sp->buffer_slot_count) { |
348 | struct pvr2_buffer **nb = 0; | 350 | struct pvr2_buffer **nb = NULL; |
349 | if (scnt) { | 351 | if (scnt) { |
350 | nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL); | 352 | nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL); |
351 | if (!nb) return -ENOMEM; | 353 | if (!nb) return -ENOMEM; |
@@ -513,10 +515,6 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp, | |||
513 | } | 515 | } |
514 | 516 | ||
515 | /* Query / set the nominal buffer count */ | 517 | /* Query / set the nominal buffer count */ |
516 | int pvr2_stream_get_buffer_count(struct pvr2_stream *sp) | ||
517 | { | ||
518 | return sp->buffer_target_count; | ||
519 | } | ||
520 | 518 | ||
521 | int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt) | 519 | int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt) |
522 | { | 520 | { |
@@ -532,21 +530,21 @@ int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt) | |||
532 | struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *sp) | 530 | struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *sp) |
533 | { | 531 | { |
534 | struct list_head *lp = sp->idle_list.next; | 532 | struct list_head *lp = sp->idle_list.next; |
535 | if (lp == &sp->idle_list) return 0; | 533 | if (lp == &sp->idle_list) return NULL; |
536 | return list_entry(lp,struct pvr2_buffer,list_overhead); | 534 | return list_entry(lp,struct pvr2_buffer,list_overhead); |
537 | } | 535 | } |
538 | 536 | ||
539 | struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp) | 537 | struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp) |
540 | { | 538 | { |
541 | struct list_head *lp = sp->ready_list.next; | 539 | struct list_head *lp = sp->ready_list.next; |
542 | if (lp == &sp->ready_list) return 0; | 540 | if (lp == &sp->ready_list) return NULL; |
543 | return list_entry(lp,struct pvr2_buffer,list_overhead); | 541 | return list_entry(lp,struct pvr2_buffer,list_overhead); |
544 | } | 542 | } |
545 | 543 | ||
546 | struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id) | 544 | struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id) |
547 | { | 545 | { |
548 | if (id < 0) return 0; | 546 | if (id < 0) return NULL; |
549 | if (id >= sp->buffer_total_count) return 0; | 547 | if (id >= sp->buffer_total_count) return NULL; |
550 | return sp->buffers[id]; | 548 | return sp->buffers[id]; |
551 | } | 549 | } |
552 | 550 | ||
@@ -555,17 +553,6 @@ int pvr2_stream_get_ready_count(struct pvr2_stream *sp) | |||
555 | return sp->r_count; | 553 | return sp->r_count; |
556 | } | 554 | } |
557 | 555 | ||
558 | int pvr2_stream_get_idle_count(struct pvr2_stream *sp) | ||
559 | { | ||
560 | return sp->i_count; | ||
561 | } | ||
562 | |||
563 | void pvr2_stream_flush(struct pvr2_stream *sp) | ||
564 | { | ||
565 | mutex_lock(&sp->mutex); do { | ||
566 | pvr2_stream_internal_flush(sp); | ||
567 | } while(0); mutex_unlock(&sp->mutex); | ||
568 | } | ||
569 | 556 | ||
570 | void pvr2_stream_kill(struct pvr2_stream *sp) | 557 | void pvr2_stream_kill(struct pvr2_stream *sp) |
571 | { | 558 | { |
@@ -620,20 +607,6 @@ int pvr2_buffer_queue(struct pvr2_buffer *bp) | |||
620 | return ret; | 607 | return ret; |
621 | } | 608 | } |
622 | 609 | ||
623 | int pvr2_buffer_idle(struct pvr2_buffer *bp) | ||
624 | { | ||
625 | struct pvr2_stream *sp; | ||
626 | if (!bp) return -EINVAL; | ||
627 | sp = bp->stream; | ||
628 | mutex_lock(&sp->mutex); do { | ||
629 | pvr2_buffer_wipe(bp); | ||
630 | pvr2_buffer_set_idle(bp); | ||
631 | if (sp->buffer_total_count != sp->buffer_target_count) { | ||
632 | pvr2_stream_achieve_buffer_count(sp); | ||
633 | } | ||
634 | } while(0); mutex_unlock(&sp->mutex); | ||
635 | return 0; | ||
636 | } | ||
637 | 610 | ||
638 | int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt) | 611 | int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt) |
639 | { | 612 | { |
@@ -673,10 +646,6 @@ int pvr2_buffer_get_status(struct pvr2_buffer *bp) | |||
673 | return bp->status; | 646 | return bp->status; |
674 | } | 647 | } |
675 | 648 | ||
676 | enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *bp) | ||
677 | { | ||
678 | return bp->state; | ||
679 | } | ||
680 | 649 | ||
681 | int pvr2_buffer_get_id(struct pvr2_buffer *bp) | 650 | int pvr2_buffer_get_id(struct pvr2_buffer *bp) |
682 | { | 651 | { |