|
48 | 48 | before we are allowed to start it running. */ |
49 | 49 | #define TIME_MSEC_DECODER_WAIT 50 |
50 | 50 |
|
| 51 | +/* This defines a minimum interval that the decoder must be allowed to run |
| 52 | + before we can safely begin using its streaming output. */ |
| 53 | +#define TIME_MSEC_DECODER_STABILIZATION_WAIT 300 |
| 54 | + |
51 | 55 | /* This defines a minimum interval that the encoder must remain quiet |
52 | 56 | before we are allowed to configure it. I had this originally set to |
53 | 57 | 50msec, but Martin Dauskardt <martin.dauskardt@gmx.de> reports that |
@@ -334,6 +338,7 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw); |
334 | 338 | static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw); |
335 | 339 | static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw); |
336 | 340 | static void pvr2_hdw_quiescent_timeout(unsigned long); |
| 341 | +static void pvr2_hdw_decoder_stabilization_timeout(unsigned long); |
337 | 342 | static void pvr2_hdw_encoder_wait_timeout(unsigned long); |
338 | 343 | static void pvr2_hdw_encoder_run_timeout(unsigned long); |
339 | 344 | static int pvr2_issue_simple_cmd(struct pvr2_hdw *,u32); |
@@ -2462,6 +2467,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, |
2462 | 2467 | hdw->quiescent_timer.data = (unsigned long)hdw; |
2463 | 2468 | hdw->quiescent_timer.function = pvr2_hdw_quiescent_timeout; |
2464 | 2469 |
|
| 2470 | + init_timer(&hdw->decoder_stabilization_timer); |
| 2471 | + hdw->decoder_stabilization_timer.data = (unsigned long)hdw; |
| 2472 | + hdw->decoder_stabilization_timer.function = |
| 2473 | + pvr2_hdw_decoder_stabilization_timeout; |
| 2474 | + |
2465 | 2475 | init_timer(&hdw->encoder_wait_timer); |
2466 | 2476 | hdw->encoder_wait_timer.data = (unsigned long)hdw; |
2467 | 2477 | hdw->encoder_wait_timer.function = pvr2_hdw_encoder_wait_timeout; |
@@ -2675,6 +2685,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, |
2675 | 2685 | fail: |
2676 | 2686 | if (hdw) { |
2677 | 2687 | del_timer_sync(&hdw->quiescent_timer); |
| 2688 | + del_timer_sync(&hdw->decoder_stabilization_timer); |
2678 | 2689 | del_timer_sync(&hdw->encoder_run_timer); |
2679 | 2690 | del_timer_sync(&hdw->encoder_wait_timer); |
2680 | 2691 | if (hdw->workqueue) { |
@@ -2742,6 +2753,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) |
2742 | 2753 | hdw->workqueue = NULL; |
2743 | 2754 | } |
2744 | 2755 | del_timer_sync(&hdw->quiescent_timer); |
| 2756 | + del_timer_sync(&hdw->decoder_stabilization_timer); |
2745 | 2757 | del_timer_sync(&hdw->encoder_run_timer); |
2746 | 2758 | del_timer_sync(&hdw->encoder_wait_timer); |
2747 | 2759 | if (hdw->fw_buffer) { |
@@ -4453,7 +4465,7 @@ static int state_check_enable_encoder_run(struct pvr2_hdw *hdw) |
4453 | 4465 |
|
4454 | 4466 | switch (hdw->pathway_state) { |
4455 | 4467 | case PVR2_PATHWAY_ANALOG: |
4456 | | - if (hdw->state_decoder_run) { |
| 4468 | + if (hdw->state_decoder_run && hdw->state_decoder_ready) { |
4457 | 4469 | /* In analog mode, if the decoder is running, then |
4458 | 4470 | run the encoder. */ |
4459 | 4471 | return !0; |
@@ -4520,6 +4532,17 @@ static void pvr2_hdw_quiescent_timeout(unsigned long data) |
4520 | 4532 | } |
4521 | 4533 |
|
4522 | 4534 |
|
| 4535 | +/* Timeout function for decoder stabilization timer. */ |
| 4536 | +static void pvr2_hdw_decoder_stabilization_timeout(unsigned long data) |
| 4537 | +{ |
| 4538 | + struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; |
| 4539 | + hdw->state_decoder_ready = !0; |
| 4540 | + trace_stbit("state_decoder_ready", hdw->state_decoder_ready); |
| 4541 | + hdw->state_stale = !0; |
| 4542 | + queue_work(hdw->workqueue, &hdw->workpoll); |
| 4543 | +} |
| 4544 | + |
| 4545 | + |
4523 | 4546 | /* Timeout function for encoder wait timer. */ |
4524 | 4547 | static void pvr2_hdw_encoder_wait_timeout(unsigned long data) |
4525 | 4548 | { |
@@ -4558,8 +4581,13 @@ static int state_eval_decoder_run(struct pvr2_hdw *hdw) |
4558 | 4581 | } |
4559 | 4582 | hdw->state_decoder_quiescent = 0; |
4560 | 4583 | hdw->state_decoder_run = 0; |
4561 | | - /* paranoia - solve race if timer just completed */ |
| 4584 | + /* paranoia - solve race if timer(s) just completed */ |
4562 | 4585 | del_timer_sync(&hdw->quiescent_timer); |
| 4586 | + /* Kill the stabilization timer, in case we're killing the |
| 4587 | + encoder before the previous stabilization interval has |
| 4588 | + been properly timed. */ |
| 4589 | + del_timer_sync(&hdw->decoder_stabilization_timer); |
| 4590 | + hdw->state_decoder_ready = 0; |
4563 | 4591 | } else { |
4564 | 4592 | if (!hdw->state_decoder_quiescent) { |
4565 | 4593 | if (!timer_pending(&hdw->quiescent_timer)) { |
@@ -4597,10 +4625,16 @@ static int state_eval_decoder_run(struct pvr2_hdw *hdw) |
4597 | 4625 | if (hdw->flag_decoder_missed) return 0; |
4598 | 4626 | if (pvr2_decoder_enable(hdw,!0) < 0) return 0; |
4599 | 4627 | hdw->state_decoder_quiescent = 0; |
| 4628 | + hdw->state_decoder_ready = 0; |
4600 | 4629 | hdw->state_decoder_run = !0; |
| 4630 | + hdw->decoder_stabilization_timer.expires = |
| 4631 | + jiffies + |
| 4632 | + (HZ * TIME_MSEC_DECODER_STABILIZATION_WAIT / 1000); |
| 4633 | + add_timer(&hdw->decoder_stabilization_timer); |
4601 | 4634 | } |
4602 | 4635 | trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); |
4603 | 4636 | trace_stbit("state_decoder_run",hdw->state_decoder_run); |
| 4637 | + trace_stbit("state_decoder_ready", hdw->state_decoder_ready); |
4604 | 4638 | return !0; |
4605 | 4639 | } |
4606 | 4640 |
|
@@ -4798,7 +4832,8 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, |
4798 | 4832 | buf,acnt, |
4799 | 4833 | "worker:%s%s%s%s%s%s%s", |
4800 | 4834 | (hdw->state_decoder_run ? |
4801 | | - " <decode:run>" : |
| 4835 | + (hdw->state_decoder_ready ? |
| 4836 | + "<decode:run>" : " <decode:start>") : |
4802 | 4837 | (hdw->state_decoder_quiescent ? |
4803 | 4838 | "" : " <decode:stop>")), |
4804 | 4839 | (hdw->state_decoder_quiescent ? |
|
0 commit comments