Commit 0febf923 authored by Stanimir Varbanov's avatar Stanimir Varbanov Committed by Mauro Carvalho Chehab

media: venus: helpers: Done buffers per queue type

Currently calling venus_helper_buffers_done() will return buffers to
user for both capture and output queues in the same call. This is
wrong because both queues are really separate and calling
stop_streaming on one queue shouldn't return buffers for the other.
Solve this by add a new queue type argument and fix the clients of
the helper function.
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 18cf8ba1
...@@ -1129,15 +1129,18 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) ...@@ -1129,15 +1129,18 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb)
} }
EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue); EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue);
void venus_helper_buffers_done(struct venus_inst *inst, void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type,
enum vb2_buffer_state state) enum vb2_buffer_state state)
{ {
struct vb2_v4l2_buffer *buf; struct vb2_v4l2_buffer *buf;
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
while ((buf = v4l2_m2m_src_buf_remove(inst->m2m_ctx))) while ((buf = v4l2_m2m_src_buf_remove(inst->m2m_ctx)))
v4l2_m2m_buf_done(buf, state); v4l2_m2m_buf_done(buf, state);
} else if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
while ((buf = v4l2_m2m_dst_buf_remove(inst->m2m_ctx))) while ((buf = v4l2_m2m_dst_buf_remove(inst->m2m_ctx)))
v4l2_m2m_buf_done(buf, state); v4l2_m2m_buf_done(buf, state);
}
} }
EXPORT_SYMBOL_GPL(venus_helper_buffers_done); EXPORT_SYMBOL_GPL(venus_helper_buffers_done);
...@@ -1168,7 +1171,10 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) ...@@ -1168,7 +1171,10 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q)
INIT_LIST_HEAD(&inst->registeredbufs); INIT_LIST_HEAD(&inst->registeredbufs);
} }
venus_helper_buffers_done(inst, VB2_BUF_STATE_ERROR); venus_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
VB2_BUF_STATE_ERROR);
venus_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
VB2_BUF_STATE_ERROR);
if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
inst->streamon_out = 0; inst->streamon_out = 0;
......
...@@ -14,7 +14,7 @@ struct venus_core; ...@@ -14,7 +14,7 @@ struct venus_core;
bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt); bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt);
struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst,
unsigned int type, u32 idx); unsigned int type, u32 idx);
void venus_helper_buffers_done(struct venus_inst *inst, void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type,
enum vb2_buffer_state state); enum vb2_buffer_state state);
int venus_helper_vb2_buf_init(struct vb2_buffer *vb); int venus_helper_vb2_buf_init(struct vb2_buffer *vb);
int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb); int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb);
......
...@@ -1044,7 +1044,7 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count) ...@@ -1044,7 +1044,7 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count)
put_power: put_power:
vdec_pm_put(inst, false); vdec_pm_put(inst, false);
error: error:
venus_helper_buffers_done(inst, VB2_BUF_STATE_QUEUED); venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED);
mutex_unlock(&inst->lock); mutex_unlock(&inst->lock);
return ret; return ret;
} }
...@@ -1071,7 +1071,6 @@ static int vdec_stop_capture(struct venus_inst *inst) ...@@ -1071,7 +1071,6 @@ static int vdec_stop_capture(struct venus_inst *inst)
break; break;
case VENUS_DEC_STATE_DRC: case VENUS_DEC_STATE_DRC:
ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT); ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT);
vdec_cancel_dst_buffers(inst);
inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
INIT_LIST_HEAD(&inst->registeredbufs); INIT_LIST_HEAD(&inst->registeredbufs);
venus_helper_free_dpb_bufs(inst); venus_helper_free_dpb_bufs(inst);
...@@ -1117,7 +1116,7 @@ static void vdec_stop_streaming(struct vb2_queue *q) ...@@ -1117,7 +1116,7 @@ static void vdec_stop_streaming(struct vb2_queue *q)
else else
ret = vdec_stop_output(inst); ret = vdec_stop_output(inst);
venus_helper_buffers_done(inst, VB2_BUF_STATE_ERROR); venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR);
if (ret) if (ret)
goto unlock; goto unlock;
......
...@@ -1018,7 +1018,7 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) ...@@ -1018,7 +1018,7 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count)
deinit_sess: deinit_sess:
hfi_session_deinit(inst); hfi_session_deinit(inst);
bufs_done: bufs_done:
venus_helper_buffers_done(inst, VB2_BUF_STATE_QUEUED); venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED);
if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
inst->streamon_out = 0; inst->streamon_out = 0;
else else
......
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