Commit 9aecc035 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab

media: rockchip/rga: Fix broken .start_streaming

Currently, rga_buf_start_streaming() is expecting
pm_runtime_get_sync to return zero on success, which
is wrong.

As per the documentation, pm_runtime_get_sync increments
the device's usage counter and return its result.
This means it will typically return a positive integer
on success and a negative error code.

Therefore, rockchip-rga driver is currently unusable
failing to start_streaming in most cases. Fix it and
while here, cleanup the buffer return-to-core logic.

Fixes: f7e7b48e ("[media] rockchip/rga: v4l2 m2m support")
Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Reviewed-by: default avatarJacob Chen <jacob-chen@iotwrt.com>
[hans.verkuil@cisco.com: fix line over 80 cols warning]
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 1946117b
...@@ -64,43 +64,44 @@ static void rga_buf_queue(struct vb2_buffer *vb) ...@@ -64,43 +64,44 @@ static void rga_buf_queue(struct vb2_buffer *vb)
v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
} }
static void rga_buf_return_buffers(struct vb2_queue *q,
enum vb2_buffer_state state)
{
struct rga_ctx *ctx = vb2_get_drv_priv(q);
struct vb2_v4l2_buffer *vbuf;
for (;;) {
if (V4L2_TYPE_IS_OUTPUT(q->type))
vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
else
vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
if (!vbuf)
break;
v4l2_m2m_buf_done(vbuf, state);
}
}
static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count) static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count)
{ {
struct rga_ctx *ctx = vb2_get_drv_priv(q); struct rga_ctx *ctx = vb2_get_drv_priv(q);
struct rockchip_rga *rga = ctx->rga; struct rockchip_rga *rga = ctx->rga;
int ret, i; int ret;
ret = pm_runtime_get_sync(rga->dev); ret = pm_runtime_get_sync(rga->dev);
if (ret < 0) {
if (!ret) rga_buf_return_buffers(q, VB2_BUF_STATE_QUEUED);
return 0; return ret;
for (i = 0; i < q->num_buffers; ++i) {
if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE) {
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(q->bufs[i]),
VB2_BUF_STATE_QUEUED);
}
} }
return ret; return 0;
} }
static void rga_buf_stop_streaming(struct vb2_queue *q) static void rga_buf_stop_streaming(struct vb2_queue *q)
{ {
struct rga_ctx *ctx = vb2_get_drv_priv(q); struct rga_ctx *ctx = vb2_get_drv_priv(q);
struct rockchip_rga *rga = ctx->rga; struct rockchip_rga *rga = ctx->rga;
struct vb2_v4l2_buffer *vbuf;
for (;;) {
if (V4L2_TYPE_IS_OUTPUT(q->type))
vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
else
vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
if (!vbuf)
break;
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
}
rga_buf_return_buffers(q, VB2_BUF_STATE_ERROR);
pm_runtime_put(rga->dev); pm_runtime_put(rga->dev);
} }
......
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