summaryrefslogtreecommitdiff
path: root/drivers/media/video/pvrusb2/pvrusb2-context.c
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2007-11-26 01:48:52 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 19:03:01 -0200
commit681c739944018d80dbcf7f19997eba97676c7116 (patch)
tree4c2f3ab63bfd852fba0ec87f69fe76e52fa4aa48 /drivers/media/video/pvrusb2/pvrusb2-context.c
parent493977f016f2ff52fdca38d031c7211b4da658fd (diff)
V4L/DVB (6691): pvrusb2: Rework pipeline state control
This is a new implementation for video pipeline control within the pvrusb2 driver. Actual start/stop of the pipeline is moved to the driver's kernel thread. Pipeline stages are controlled autonomously based on surrounding pipeline or application control state. Kernel thread management is also cleaned up and moved into the internal control structure of the driver, solving a set up / tear down race along the way. Better failure recovery is implemented with this new control strategy. Also with this change comes better control of the cx23416 encoder, building on additional information learned about the peculiarities of controlling this part (this information was the original trigger for this rework). With this change, overall encoder stability should be considerably improved. Yes, this is a large change for this driver, but due to the nature of the feature being worked on, the changes are fairly pervasive and would be difficult to break into smaller pieces with any semblence of step-wise stability. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-context.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c55
1 files changed, 17 insertions, 38 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index 22719ba861ac..9d94aed2e12d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -31,52 +31,32 @@
static void pvr2_context_destroy(struct pvr2_context *mp)
{
- if (mp->hdw) pvr2_hdw_destroy(mp->hdw);
pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr_main id=%p",mp);
- if (mp->workqueue) {
- flush_workqueue(mp->workqueue);
- destroy_workqueue(mp->workqueue);
- }
+ if (mp->hdw) pvr2_hdw_destroy(mp->hdw);
kfree(mp);
}
-static void pvr2_context_trigger_poll(struct pvr2_context *mp)
-{
- queue_work(mp->workqueue,&mp->workpoll);
-}
-
-
-static void pvr2_context_poll(struct work_struct *work)
-{
- struct pvr2_context *mp =
- container_of(work, struct pvr2_context, workpoll);
- pvr2_context_enter(mp); do {
- pvr2_hdw_poll(mp->hdw);
- } while (0); pvr2_context_exit(mp);
-}
-
-
-static void pvr2_context_setup(struct work_struct *work)
+static void pvr2_context_state_check(struct pvr2_context *mp)
{
- struct pvr2_context *mp =
- container_of(work, struct pvr2_context, workinit);
+ if (mp->init_flag) return;
+
+ switch (pvr2_hdw_get_state(mp->hdw)) {
+ case PVR2_STATE_WARM: break;
+ case PVR2_STATE_ERROR: break;
+ case PVR2_STATE_READY: break;
+ case PVR2_STATE_RUN: break;
+ default: return;
+ }
pvr2_context_enter(mp); do {
- if (!pvr2_hdw_dev_ok(mp->hdw)) break;
- pvr2_hdw_setup(mp->hdw);
- pvr2_hdw_setup_poll_trigger(
- mp->hdw,
- (void (*)(void *))pvr2_context_trigger_poll,
- mp);
- if (!pvr2_hdw_dev_ok(mp->hdw)) break;
- if (!pvr2_hdw_init_ok(mp->hdw)) break;
+ mp->init_flag = !0;
mp->video_stream.stream = pvr2_hdw_get_video_stream(mp->hdw);
if (mp->setup_func) {
mp->setup_func(mp);
}
} while (0); pvr2_context_exit(mp);
-}
+ }
struct pvr2_context *pvr2_context_create(
@@ -96,11 +76,10 @@ struct pvr2_context *pvr2_context_create(
mp = NULL;
goto done;
}
-
- mp->workqueue = create_singlethread_workqueue("pvrusb2");
- INIT_WORK(&mp->workinit, pvr2_context_setup);
- INIT_WORK(&mp->workpoll, pvr2_context_poll);
- queue_work(mp->workqueue,&mp->workinit);
+ pvr2_hdw_set_state_callback(mp->hdw,
+ (void (*)(void *))pvr2_context_state_check,
+ mp);
+ pvr2_context_state_check(mp);
done:
return mp;
}