Message ID | 20220331085016.628747-1-wenst@chromium.org |
---|---|
State | New |
Headers | show |
Series | [RFT] media: vicodec: Fix encoder has stopped condition check in encoder_cmd | expand |
diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c index be43f7d32df9..898fa8e284f7 100644 --- a/drivers/media/test-drivers/vicodec/vicodec-core.c +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c @@ -1231,8 +1231,7 @@ static int vicodec_encoder_cmd(struct file *file, void *fh, v4l2_m2m_has_stopped(ctx->fh.m2m_ctx)) v4l2_event_queue_fh(&ctx->fh, &vicodec_eos_event); - if (ec->cmd == V4L2_ENC_CMD_START && - v4l2_m2m_has_stopped(ctx->fh.m2m_ctx)) + if (ec->cmd == V4L2_ENC_CMD_START) vb2_clear_last_buffer_dequeued(&ctx->fh.m2m_ctx->cap_q_ctx.q); return 0;
Before commit d4d137de5f31 ("media: vicodec: use v4l2-mem2mem draining, stopped and next-buf-is-last states handling"), the vicoded tracked the "has stopped" condition itself, and only updated it after checks and actions were done. With the move to v4l2-mem2mem helpers, the state tracking moved into the mem2mem context, and was updated by v4l2_m2m_ioctl_encoder_cmd() before checks and actions were done in vicodec. As a result, the has_stopped condition is now always false. In the original code, vb2_clear_last_buffer_dequeued() is called if the stream is successfully started. Since this is now always the case if the callback did not error out at v4l2_m2m_ioctl_encoder_cmd(), we can drop the "has stopped" condition check. This restores the original behavior. Fixes: d4d137de5f31 ("media: vicodec: use v4l2-mem2mem draining, stopped and next-buf-is-last states handling") Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> --- This arose from the review of my Hantro encoder cmd support patch [1]. I haven't used vicodec before, so this is only compile tested. Actual testing requested. [1] https://lore.kernel.org/linux-media/YjcbnmTUaWDtkIb%2F@eze-laptop/ drivers/media/test-drivers/vicodec/vicodec-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)