summaryrefslogtreecommitdiff
path: root/wiki/2016-10-miniperi/vsp2_running_count.patch
blob: f6b00033daa62897d26c8446ea70324c9792eb9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff --git a/drv/vsp2_video.c b/drv/vsp2_video.c
index 2946088..eacbb83 100755
--- a/drv/vsp2_video.c
+++ b/drv/vsp2_video.c
@@ -442,6 +442,7 @@ static void __vsp2_pipeline_cleanup(struct vsp2_pipeline *pipe)
 
 	INIT_LIST_HEAD(&pipe->entities);
 	pipe->state = VSP2_PIPELINE_STOPPED;
+	pipe->running_count = 0;
 	pipe->buffers_ready = 0;
 	pipe->num_video = 0;
 	pipe->num_inputs = 0;
@@ -556,6 +557,7 @@ static void vsp2_pipeline_run(struct vsp2_pipeline *pipe)
 	vsp2_vspm_drv_entry(vsp2);
 
 	pipe->state = VSP2_PIPELINE_RUNNING;
+	pipe->running_count++;
 	pipe->buffers_ready = 0;
 }
 
@@ -675,7 +677,9 @@ void vsp2_pipeline_frame_end(struct vsp2_pipeline *pipe)
 	spin_lock_irqsave(&pipe->irqlock, flags);
 
 	state = pipe->state;
-	pipe->state = VSP2_PIPELINE_STOPPED;
+
+	if (--pipe->running_count == 0)
+		pipe->state = VSP2_PIPELINE_STOPPED;
 
 	/* If a stop has been requested, mark the pipeline as stopped and
 	 * return.
@@ -981,7 +985,7 @@ static int vsp2_video_stop_streaming(struct vb2_queue *vq)
 	int ret;
 
 	mutex_lock(&pipe->lock);
-	if (--pipe->stream_count == 0) {
+	if (--pipe->stream_count == pipe->num_inputs) {
 		/* Stop the pipeline. */
 		ret = vsp2_pipeline_stop(pipe);
 		if (ret == -ETIMEDOUT)
diff --git a/drv/vsp2_video.h b/drv/vsp2_video.h
index 90c3478..db67e66 100755
--- a/drv/vsp2_video.h
+++ b/drv/vsp2_video.h
@@ -120,6 +120,7 @@ struct vsp2_pipeline {
 	struct mutex lock;
 	unsigned int use_count;
 	unsigned int stream_count;
+	unsigned int running_count;
 	unsigned int buffers_ready;
 
 	unsigned int num_video;