Skip to content

Commit 9aecc03

Browse files
ezequielgarciamchehab
authored andcommitted
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: f7e7b48 ("[media] rockchip/rga: v4l2 m2m support") Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Reviewed-by: Jacob Chen <jacob-chen@iotwrt.com> [hans.verkuil@cisco.com: fix line over 80 cols warning] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent 1946117 commit 9aecc03

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

‎drivers/media/platform/rockchip/rga/rga-buf.c‎

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,43 +64,44 @@ static void rga_buf_queue(struct vb2_buffer *vb)
6464
v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
6565
}
6666

67+
static void rga_buf_return_buffers(struct vb2_queue *q,
68+
enum vb2_buffer_state state)
69+
{
70+
struct rga_ctx *ctx = vb2_get_drv_priv(q);
71+
struct vb2_v4l2_buffer *vbuf;
72+
73+
for (;;) {
74+
if (V4L2_TYPE_IS_OUTPUT(q->type))
75+
vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
76+
else
77+
vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
78+
if (!vbuf)
79+
break;
80+
v4l2_m2m_buf_done(vbuf, state);
81+
}
82+
}
83+
6784
static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count)
6885
{
6986
struct rga_ctx *ctx = vb2_get_drv_priv(q);
7087
struct rockchip_rga *rga = ctx->rga;
71-
int ret, i;
88+
int ret;
7289

7390
ret = pm_runtime_get_sync(rga->dev);
74-
75-
if (!ret)
76-
return 0;
77-
78-
for (i = 0; i < q->num_buffers; ++i) {
79-
if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE) {
80-
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(q->bufs[i]),
81-
VB2_BUF_STATE_QUEUED);
82-
}
91+
if (ret < 0) {
92+
rga_buf_return_buffers(q, VB2_BUF_STATE_QUEUED);
93+
return ret;
8394
}
8495

85-
return ret;
96+
return 0;
8697
}
8798

8899
static void rga_buf_stop_streaming(struct vb2_queue *q)
89100
{
90101
struct rga_ctx *ctx = vb2_get_drv_priv(q);
91102
struct rockchip_rga *rga = ctx->rga;
92-
struct vb2_v4l2_buffer *vbuf;
93-
94-
for (;;) {
95-
if (V4L2_TYPE_IS_OUTPUT(q->type))
96-
vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
97-
else
98-
vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
99-
if (!vbuf)
100-
break;
101-
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
102-
}
103103

104+
rga_buf_return_buffers(q, VB2_BUF_STATE_ERROR);
104105
pm_runtime_put(rga->dev);
105106
}
106107

0 commit comments

Comments
 (0)