diff options
Diffstat (limited to 'drivers/media/video/pvrusb2')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | 12 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 53 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.h | 1 |
3 files changed, 57 insertions, 9 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h index de5485f506b1..cb4057bb07a0 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | |||
@@ -233,8 +233,9 @@ struct pvr2_hdw { | |||
233 | int state_encoder_waitok; /* Encoder pre-wait done */ | 233 | int state_encoder_waitok; /* Encoder pre-wait done */ |
234 | int state_encoder_runok; /* Encoder has run for >= .25 sec */ | 234 | int state_encoder_runok; /* Encoder has run for >= .25 sec */ |
235 | int state_decoder_run; /* Decoder is running */ | 235 | int state_decoder_run; /* Decoder is running */ |
236 | int state_decoder_ready; /* Decoder is stabilized & streamable */ | ||
236 | int state_usbstream_run; /* FX2 is streaming */ | 237 | int state_usbstream_run; /* FX2 is streaming */ |
237 | int state_decoder_quiescent; /* Decoder idle for > 50msec */ | 238 | int state_decoder_quiescent; /* Decoder idle for minimal interval */ |
238 | int state_pipeline_config; /* Pipeline is configured */ | 239 | int state_pipeline_config; /* Pipeline is configured */ |
239 | int state_pipeline_req; /* Somebody wants to stream */ | 240 | int state_pipeline_req; /* Somebody wants to stream */ |
240 | int state_pipeline_pause; /* Pipeline must be paused */ | 241 | int state_pipeline_pause; /* Pipeline must be paused */ |
@@ -255,9 +256,16 @@ struct pvr2_hdw { | |||
255 | void (*state_func)(void *); | 256 | void (*state_func)(void *); |
256 | void *state_data; | 257 | void *state_data; |
257 | 258 | ||
258 | /* Timer for measuring decoder settling time */ | 259 | /* Timer for measuring required decoder settling time before we're |
260 | allowed to fire it up again. */ | ||
259 | struct timer_list quiescent_timer; | 261 | struct timer_list quiescent_timer; |
260 | 262 | ||
263 | /* Timer for measuring decoder stabilization time, which is the | ||
264 | amount of time we need to let the decoder run before we can | ||
265 | trust its output (otherwise the encoder might see garbage and | ||
266 | then fail to start correctly). */ | ||
267 | struct timer_list decoder_stabilization_timer; | ||
268 | |||
261 | /* Timer for measuring encoder pre-wait time */ | 269 | /* Timer for measuring encoder pre-wait time */ |
262 | struct timer_list encoder_wait_timer; | 270 | struct timer_list encoder_wait_timer; |
263 | 271 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 1bbdab08fe0e..712b300f723f 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -48,11 +48,13 @@ | |||
48 | before we are allowed to start it running. */ | 48 | before we are allowed to start it running. */ |
49 | #define TIME_MSEC_DECODER_WAIT 50 | 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 | /* This defines a minimum interval that the encoder must remain quiet | 55 | /* This defines a minimum interval that the encoder must remain quiet |
52 | before we are allowed to configure it. I had this originally set to | 56 | before we are allowed to configure it. */ |
53 | 50msec, but Martin Dauskardt <martin.dauskardt@gmx.de> reports that | 57 | #define TIME_MSEC_ENCODER_WAIT 50 |
54 | things work better when it's set to 100msec. */ | ||
55 | #define TIME_MSEC_ENCODER_WAIT 100 | ||
56 | 58 | ||
57 | /* This defines the minimum interval that the encoder must successfully run | 59 | /* This defines the minimum interval that the encoder must successfully run |
58 | before we consider that the encoder has run at least once since its | 60 | before we consider that the encoder has run at least once since its |
@@ -334,6 +336,7 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw); | |||
334 | static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw); | 336 | static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw); |
335 | static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw); | 337 | static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw); |
336 | static void pvr2_hdw_quiescent_timeout(unsigned long); | 338 | static void pvr2_hdw_quiescent_timeout(unsigned long); |
339 | static void pvr2_hdw_decoder_stabilization_timeout(unsigned long); | ||
337 | static void pvr2_hdw_encoder_wait_timeout(unsigned long); | 340 | static void pvr2_hdw_encoder_wait_timeout(unsigned long); |
338 | static void pvr2_hdw_encoder_run_timeout(unsigned long); | 341 | static void pvr2_hdw_encoder_run_timeout(unsigned long); |
339 | static int pvr2_issue_simple_cmd(struct pvr2_hdw *,u32); | 342 | static int pvr2_issue_simple_cmd(struct pvr2_hdw *,u32); |
@@ -1705,6 +1708,7 @@ static int pvr2_decoder_enable(struct pvr2_hdw *hdw,int enablefl) | |||
1705 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 stream=%s", | 1708 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 stream=%s", |
1706 | (enablefl ? "on" : "off")); | 1709 | (enablefl ? "on" : "off")); |
1707 | v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_stream, enablefl); | 1710 | v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_stream, enablefl); |
1711 | v4l2_device_call_all(&hdw->v4l2_dev, 0, audio, s_stream, enablefl); | ||
1708 | if (hdw->decoder_client_id) { | 1712 | if (hdw->decoder_client_id) { |
1709 | /* We get here if the encoder has been noticed. Otherwise | 1713 | /* We get here if the encoder has been noticed. Otherwise |
1710 | we'll issue a warning to the user (which should | 1714 | we'll issue a warning to the user (which should |
@@ -2461,6 +2465,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2461 | hdw->quiescent_timer.data = (unsigned long)hdw; | 2465 | hdw->quiescent_timer.data = (unsigned long)hdw; |
2462 | hdw->quiescent_timer.function = pvr2_hdw_quiescent_timeout; | 2466 | hdw->quiescent_timer.function = pvr2_hdw_quiescent_timeout; |
2463 | 2467 | ||
2468 | init_timer(&hdw->decoder_stabilization_timer); | ||
2469 | hdw->decoder_stabilization_timer.data = (unsigned long)hdw; | ||
2470 | hdw->decoder_stabilization_timer.function = | ||
2471 | pvr2_hdw_decoder_stabilization_timeout; | ||
2472 | |||
2464 | init_timer(&hdw->encoder_wait_timer); | 2473 | init_timer(&hdw->encoder_wait_timer); |
2465 | hdw->encoder_wait_timer.data = (unsigned long)hdw; | 2474 | hdw->encoder_wait_timer.data = (unsigned long)hdw; |
2466 | hdw->encoder_wait_timer.function = pvr2_hdw_encoder_wait_timeout; | 2475 | hdw->encoder_wait_timer.function = pvr2_hdw_encoder_wait_timeout; |
@@ -2674,6 +2683,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2674 | fail: | 2683 | fail: |
2675 | if (hdw) { | 2684 | if (hdw) { |
2676 | del_timer_sync(&hdw->quiescent_timer); | 2685 | del_timer_sync(&hdw->quiescent_timer); |
2686 | del_timer_sync(&hdw->decoder_stabilization_timer); | ||
2677 | del_timer_sync(&hdw->encoder_run_timer); | 2687 | del_timer_sync(&hdw->encoder_run_timer); |
2678 | del_timer_sync(&hdw->encoder_wait_timer); | 2688 | del_timer_sync(&hdw->encoder_wait_timer); |
2679 | if (hdw->workqueue) { | 2689 | if (hdw->workqueue) { |
@@ -2741,6 +2751,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) | |||
2741 | hdw->workqueue = NULL; | 2751 | hdw->workqueue = NULL; |
2742 | } | 2752 | } |
2743 | del_timer_sync(&hdw->quiescent_timer); | 2753 | del_timer_sync(&hdw->quiescent_timer); |
2754 | del_timer_sync(&hdw->decoder_stabilization_timer); | ||
2744 | del_timer_sync(&hdw->encoder_run_timer); | 2755 | del_timer_sync(&hdw->encoder_run_timer); |
2745 | del_timer_sync(&hdw->encoder_wait_timer); | 2756 | del_timer_sync(&hdw->encoder_wait_timer); |
2746 | if (hdw->fw_buffer) { | 2757 | if (hdw->fw_buffer) { |
@@ -4452,7 +4463,7 @@ static int state_check_enable_encoder_run(struct pvr2_hdw *hdw) | |||
4452 | 4463 | ||
4453 | switch (hdw->pathway_state) { | 4464 | switch (hdw->pathway_state) { |
4454 | case PVR2_PATHWAY_ANALOG: | 4465 | case PVR2_PATHWAY_ANALOG: |
4455 | if (hdw->state_decoder_run) { | 4466 | if (hdw->state_decoder_run && hdw->state_decoder_ready) { |
4456 | /* In analog mode, if the decoder is running, then | 4467 | /* In analog mode, if the decoder is running, then |
4457 | run the encoder. */ | 4468 | run the encoder. */ |
4458 | return !0; | 4469 | return !0; |
@@ -4519,6 +4530,17 @@ static void pvr2_hdw_quiescent_timeout(unsigned long data) | |||
4519 | } | 4530 | } |
4520 | 4531 | ||
4521 | 4532 | ||
4533 | /* Timeout function for decoder stabilization timer. */ | ||
4534 | static void pvr2_hdw_decoder_stabilization_timeout(unsigned long data) | ||
4535 | { | ||
4536 | struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; | ||
4537 | hdw->state_decoder_ready = !0; | ||
4538 | trace_stbit("state_decoder_ready", hdw->state_decoder_ready); | ||
4539 | hdw->state_stale = !0; | ||
4540 | queue_work(hdw->workqueue, &hdw->workpoll); | ||
4541 | } | ||
4542 | |||
4543 | |||
4522 | /* Timeout function for encoder wait timer. */ | 4544 | /* Timeout function for encoder wait timer. */ |
4523 | static void pvr2_hdw_encoder_wait_timeout(unsigned long data) | 4545 | static void pvr2_hdw_encoder_wait_timeout(unsigned long data) |
4524 | { | 4546 | { |
@@ -4557,8 +4579,13 @@ static int state_eval_decoder_run(struct pvr2_hdw *hdw) | |||
4557 | } | 4579 | } |
4558 | hdw->state_decoder_quiescent = 0; | 4580 | hdw->state_decoder_quiescent = 0; |
4559 | hdw->state_decoder_run = 0; | 4581 | hdw->state_decoder_run = 0; |
4560 | /* paranoia - solve race if timer just completed */ | 4582 | /* paranoia - solve race if timer(s) just completed */ |
4561 | del_timer_sync(&hdw->quiescent_timer); | 4583 | del_timer_sync(&hdw->quiescent_timer); |
4584 | /* Kill the stabilization timer, in case we're killing the | ||
4585 | encoder before the previous stabilization interval has | ||
4586 | been properly timed. */ | ||
4587 | del_timer_sync(&hdw->decoder_stabilization_timer); | ||
4588 | hdw->state_decoder_ready = 0; | ||
4562 | } else { | 4589 | } else { |
4563 | if (!hdw->state_decoder_quiescent) { | 4590 | if (!hdw->state_decoder_quiescent) { |
4564 | if (!timer_pending(&hdw->quiescent_timer)) { | 4591 | if (!timer_pending(&hdw->quiescent_timer)) { |
@@ -4596,10 +4623,21 @@ static int state_eval_decoder_run(struct pvr2_hdw *hdw) | |||
4596 | if (hdw->flag_decoder_missed) return 0; | 4623 | if (hdw->flag_decoder_missed) return 0; |
4597 | if (pvr2_decoder_enable(hdw,!0) < 0) return 0; | 4624 | if (pvr2_decoder_enable(hdw,!0) < 0) return 0; |
4598 | hdw->state_decoder_quiescent = 0; | 4625 | hdw->state_decoder_quiescent = 0; |
4626 | hdw->state_decoder_ready = 0; | ||
4599 | hdw->state_decoder_run = !0; | 4627 | hdw->state_decoder_run = !0; |
4628 | if (hdw->decoder_client_id == PVR2_CLIENT_ID_SAA7115) { | ||
4629 | hdw->decoder_stabilization_timer.expires = | ||
4630 | jiffies + | ||
4631 | (HZ * TIME_MSEC_DECODER_STABILIZATION_WAIT / | ||
4632 | 1000); | ||
4633 | add_timer(&hdw->decoder_stabilization_timer); | ||
4634 | } else { | ||
4635 | hdw->state_decoder_ready = !0; | ||
4636 | } | ||
4600 | } | 4637 | } |
4601 | trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); | 4638 | trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); |
4602 | trace_stbit("state_decoder_run",hdw->state_decoder_run); | 4639 | trace_stbit("state_decoder_run",hdw->state_decoder_run); |
4640 | trace_stbit("state_decoder_ready", hdw->state_decoder_ready); | ||
4603 | return !0; | 4641 | return !0; |
4604 | } | 4642 | } |
4605 | 4643 | ||
@@ -4797,7 +4835,8 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, | |||
4797 | buf,acnt, | 4835 | buf,acnt, |
4798 | "worker:%s%s%s%s%s%s%s", | 4836 | "worker:%s%s%s%s%s%s%s", |
4799 | (hdw->state_decoder_run ? | 4837 | (hdw->state_decoder_run ? |
4800 | " <decode:run>" : | 4838 | (hdw->state_decoder_ready ? |
4839 | "<decode:run>" : " <decode:start>") : | ||
4801 | (hdw->state_decoder_quiescent ? | 4840 | (hdw->state_decoder_quiescent ? |
4802 | "" : " <decode:stop>")), | 4841 | "" : " <decode:stop>")), |
4803 | (hdw->state_decoder_quiescent ? | 4842 | (hdw->state_decoder_quiescent ? |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h index 56e70eae20c1..51d3009ab57f 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h | |||
@@ -306,6 +306,7 @@ struct pvr2_hdw_debug_info { | |||
306 | int state_encoder_ok; | 306 | int state_encoder_ok; |
307 | int state_encoder_run; | 307 | int state_encoder_run; |
308 | int state_decoder_run; | 308 | int state_decoder_run; |
309 | int state_decoder_ready; | ||
309 | int state_usbstream_run; | 310 | int state_usbstream_run; |
310 | int state_decoder_quiescent; | 311 | int state_decoder_quiescent; |
311 | int state_pipeline_config; | 312 | int state_pipeline_config; |