Commit 1b275e4e authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab

media: mtk-jpeg: Correct return type for mem2mem buffer helpers

Fix the assigned type of mem2mem buffer handling API.
Namely, these functions:

 v4l2_m2m_next_buf
 v4l2_m2m_last_buf
 v4l2_m2m_buf_remove
 v4l2_m2m_next_src_buf
 v4l2_m2m_next_dst_buf
 v4l2_m2m_last_src_buf
 v4l2_m2m_last_dst_buf
 v4l2_m2m_src_buf_remove
 v4l2_m2m_dst_buf_remove

return a struct vb2_v4l2_buffer, and not a struct vb2_buffer.

Fixing this is necessary to fix the mem2mem buffer handling API,
changing the return to the correct struct vb2_v4l2_buffer instead
of a void pointer.
Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 5c88ee02
...@@ -702,7 +702,7 @@ static void mtk_jpeg_buf_queue(struct vb2_buffer *vb) ...@@ -702,7 +702,7 @@ static void mtk_jpeg_buf_queue(struct vb2_buffer *vb)
v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, to_vb2_v4l2_buffer(vb)); v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, to_vb2_v4l2_buffer(vb));
} }
static void *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx, static struct vb2_v4l2_buffer *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx,
enum v4l2_buf_type type) enum v4l2_buf_type type)
{ {
if (V4L2_TYPE_IS_OUTPUT(type)) if (V4L2_TYPE_IS_OUTPUT(type))
...@@ -714,7 +714,7 @@ static void *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx, ...@@ -714,7 +714,7 @@ static void *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx,
static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count) static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
{ {
struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q); struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q);
struct vb2_buffer *vb; struct vb2_v4l2_buffer *vb;
int ret = 0; int ret = 0;
ret = pm_runtime_get_sync(ctx->jpeg->dev); ret = pm_runtime_get_sync(ctx->jpeg->dev);
...@@ -724,14 +724,14 @@ static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count) ...@@ -724,14 +724,14 @@ static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
return 0; return 0;
err: err:
while ((vb = mtk_jpeg_buf_remove(ctx, q->type))) while ((vb = mtk_jpeg_buf_remove(ctx, q->type)))
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb), VB2_BUF_STATE_QUEUED); v4l2_m2m_buf_done(vb, VB2_BUF_STATE_QUEUED);
return ret; return ret;
} }
static void mtk_jpeg_stop_streaming(struct vb2_queue *q) static void mtk_jpeg_stop_streaming(struct vb2_queue *q)
{ {
struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q); struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q);
struct vb2_buffer *vb; struct vb2_v4l2_buffer *vb;
/* /*
* STREAMOFF is an acknowledgment for source change event. * STREAMOFF is an acknowledgment for source change event.
...@@ -743,7 +743,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q) ...@@ -743,7 +743,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q)
struct mtk_jpeg_src_buf *src_buf; struct mtk_jpeg_src_buf *src_buf;
vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
src_buf = mtk_jpeg_vb2_to_srcbuf(vb); src_buf = mtk_jpeg_vb2_to_srcbuf(&vb->vb2_buf);
mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param); mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param);
ctx->state = MTK_JPEG_RUNNING; ctx->state = MTK_JPEG_RUNNING;
} else if (V4L2_TYPE_IS_OUTPUT(q->type)) { } else if (V4L2_TYPE_IS_OUTPUT(q->type)) {
...@@ -751,7 +751,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q) ...@@ -751,7 +751,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q)
} }
while ((vb = mtk_jpeg_buf_remove(ctx, q->type))) while ((vb = mtk_jpeg_buf_remove(ctx, q->type)))
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb), VB2_BUF_STATE_ERROR); v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
pm_runtime_put_sync(ctx->jpeg->dev); pm_runtime_put_sync(ctx->jpeg->dev);
} }
...@@ -807,7 +807,7 @@ static void mtk_jpeg_device_run(void *priv) ...@@ -807,7 +807,7 @@ static void mtk_jpeg_device_run(void *priv)
{ {
struct mtk_jpeg_ctx *ctx = priv; struct mtk_jpeg_ctx *ctx = priv;
struct mtk_jpeg_dev *jpeg = ctx->jpeg; struct mtk_jpeg_dev *jpeg = ctx->jpeg;
struct vb2_buffer *src_buf, *dst_buf; struct vb2_v4l2_buffer *src_buf, *dst_buf;
enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
unsigned long flags; unsigned long flags;
struct mtk_jpeg_src_buf *jpeg_src_buf; struct mtk_jpeg_src_buf *jpeg_src_buf;
...@@ -817,11 +817,11 @@ static void mtk_jpeg_device_run(void *priv) ...@@ -817,11 +817,11 @@ static void mtk_jpeg_device_run(void *priv)
src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf); jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf);
if (jpeg_src_buf->flags & MTK_JPEG_BUF_FLAGS_LAST_FRAME) { if (jpeg_src_buf->flags & MTK_JPEG_BUF_FLAGS_LAST_FRAME) {
for (i = 0; i < dst_buf->num_planes; i++) for (i = 0; i < dst_buf->vb2_buf.num_planes; i++)
vb2_set_plane_payload(dst_buf, i, 0); vb2_set_plane_payload(&dst_buf->vb2_buf, i, 0);
buf_state = VB2_BUF_STATE_DONE; buf_state = VB2_BUF_STATE_DONE;
goto dec_end; goto dec_end;
} }
...@@ -833,8 +833,8 @@ static void mtk_jpeg_device_run(void *priv) ...@@ -833,8 +833,8 @@ static void mtk_jpeg_device_run(void *priv)
return; return;
} }
mtk_jpeg_set_dec_src(ctx, src_buf, &bs); mtk_jpeg_set_dec_src(ctx, &src_buf->vb2_buf, &bs);
if (mtk_jpeg_set_dec_dst(ctx, &jpeg_src_buf->dec_param, dst_buf, &fb)) if (mtk_jpeg_set_dec_dst(ctx, &jpeg_src_buf->dec_param, &dst_buf->vb2_buf, &fb))
goto dec_end; goto dec_end;
spin_lock_irqsave(&jpeg->hw_lock, flags); spin_lock_irqsave(&jpeg->hw_lock, flags);
...@@ -849,8 +849,8 @@ static void mtk_jpeg_device_run(void *priv) ...@@ -849,8 +849,8 @@ static void mtk_jpeg_device_run(void *priv)
dec_end: dec_end:
v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state); v4l2_m2m_buf_done(src_buf, buf_state);
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state); v4l2_m2m_buf_done(dst_buf, buf_state);
v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
} }
...@@ -921,7 +921,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) ...@@ -921,7 +921,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
{ {
struct mtk_jpeg_dev *jpeg = priv; struct mtk_jpeg_dev *jpeg = priv;
struct mtk_jpeg_ctx *ctx; struct mtk_jpeg_ctx *ctx;
struct vb2_buffer *src_buf, *dst_buf; struct vb2_v4l2_buffer *src_buf, *dst_buf;
struct mtk_jpeg_src_buf *jpeg_src_buf; struct mtk_jpeg_src_buf *jpeg_src_buf;
enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
u32 dec_irq_ret; u32 dec_irq_ret;
...@@ -938,7 +938,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) ...@@ -938,7 +938,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf); jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf);
if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW) if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW)
mtk_jpeg_dec_reset(jpeg->dec_reg_base); mtk_jpeg_dec_reset(jpeg->dec_reg_base);
...@@ -948,15 +948,15 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) ...@@ -948,15 +948,15 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
goto dec_end; goto dec_end;
} }
for (i = 0; i < dst_buf->num_planes; i++) for (i = 0; i < dst_buf->vb2_buf.num_planes; i++)
vb2_set_plane_payload(dst_buf, i, vb2_set_plane_payload(&dst_buf->vb2_buf, i,
jpeg_src_buf->dec_param.comp_size[i]); jpeg_src_buf->dec_param.comp_size[i]);
buf_state = VB2_BUF_STATE_DONE; buf_state = VB2_BUF_STATE_DONE;
dec_end: dec_end:
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state); v4l2_m2m_buf_done(src_buf, buf_state);
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state); v4l2_m2m_buf_done(dst_buf, buf_state);
v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
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