Commit 35d1a7bb authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab

media: staging: rkisp1: validate links before powering and streaming

In function rkisp1_vb2_start_streaming, the call to
media_pipeline_start should be the first thing in order
to validate the links and prevents their state from being modified
before power up and streaming.

Adjust stop streaming to the same logic, call media_pipeline_stop
after we disable streaming on the entities in the topology.
Signed-off-by: default avatarHelen Koike <helen.koike@collabora.com>
Signed-off-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: default avatarTomasz Figa <tfiga@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 6e8c09bb
...@@ -921,7 +921,6 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue) ...@@ -921,7 +921,6 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
mutex_lock(&cap->rkisp1->stream_lock); mutex_lock(&cap->rkisp1->stream_lock);
rkisp1_stream_stop(cap); rkisp1_stream_stop(cap);
media_pipeline_stop(&node->vdev.entity);
ret = rkisp1_pipeline_sink_walk(&node->vdev.entity, NULL, ret = rkisp1_pipeline_sink_walk(&node->vdev.entity, NULL,
rkisp1_pipeline_disable_cb); rkisp1_pipeline_disable_cb);
if (ret) if (ret)
...@@ -937,6 +936,8 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue) ...@@ -937,6 +936,8 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
rkisp1_dummy_buf_destroy(cap); rkisp1_dummy_buf_destroy(cap);
media_pipeline_stop(&node->vdev.entity);
mutex_unlock(&cap->rkisp1->stream_lock); mutex_unlock(&cap->rkisp1->stream_lock);
} }
...@@ -986,9 +987,15 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) ...@@ -986,9 +987,15 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
mutex_lock(&cap->rkisp1->stream_lock); mutex_lock(&cap->rkisp1->stream_lock);
ret = media_pipeline_start(entity, &cap->rkisp1->pipe);
if (ret) {
dev_err(cap->rkisp1->dev, "start pipeline failed %d\n", ret);
goto err_ret_buffers;
}
ret = rkisp1_dummy_buf_create(cap); ret = rkisp1_dummy_buf_create(cap);
if (ret) if (ret)
goto err_ret_buffers; goto err_pipeline_stop;
ret = pm_runtime_get_sync(cap->rkisp1->dev); ret = pm_runtime_get_sync(cap->rkisp1->dev);
if (ret < 0) { if (ret < 0) {
...@@ -1009,18 +1016,10 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) ...@@ -1009,18 +1016,10 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
if (ret) if (ret)
goto err_stop_stream; goto err_stop_stream;
ret = media_pipeline_start(entity, &cap->rkisp1->pipe);
if (ret) {
dev_err(cap->rkisp1->dev, "start pipeline failed %d\n", ret);
goto err_pipe_disable;
}
mutex_unlock(&cap->rkisp1->stream_lock); mutex_unlock(&cap->rkisp1->stream_lock);
return 0; return 0;
err_pipe_disable:
rkisp1_pipeline_sink_walk(entity, NULL, rkisp1_pipeline_disable_cb);
err_stop_stream: err_stop_stream:
rkisp1_stream_stop(cap); rkisp1_stream_stop(cap);
v4l2_pipeline_pm_put(entity); v4l2_pipeline_pm_put(entity);
...@@ -1028,6 +1027,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) ...@@ -1028,6 +1027,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
pm_runtime_put(cap->rkisp1->dev); pm_runtime_put(cap->rkisp1->dev);
err_destroy_dummy: err_destroy_dummy:
rkisp1_dummy_buf_destroy(cap); rkisp1_dummy_buf_destroy(cap);
err_pipeline_stop:
media_pipeline_stop(entity);
err_ret_buffers: err_ret_buffers:
rkisp1_return_all_buffers(cap, VB2_BUF_STATE_QUEUED); rkisp1_return_all_buffers(cap, VB2_BUF_STATE_QUEUED);
mutex_unlock(&cap->rkisp1->stream_lock); mutex_unlock(&cap->rkisp1->stream_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment