Commit 84e490b3 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Stefan Bader

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

BugLink: https://bugs.launchpad.net/bugs/1828420

[ Upstream commit 4a88f898 ]

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>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent b50d27c7
...@@ -788,14 +788,14 @@ static void skip(struct s5p_jpeg_buffer *buf, long len); ...@@ -788,14 +788,14 @@ static void skip(struct s5p_jpeg_buffer *buf, long len);
static void exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx) static void exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
struct s5p_jpeg_buffer jpeg_buffer; struct s5p_jpeg_buffer jpeg_buffer;
unsigned int word; unsigned int word;
int c, x, components; int c, x, components;
jpeg_buffer.size = 2; /* Ls */ jpeg_buffer.size = 2; /* Ls */
jpeg_buffer.data = jpeg_buffer.data =
(unsigned long)vb2_plane_vaddr(vb, 0) + ctx->out_q.sos + 2; (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) + ctx->out_q.sos + 2;
jpeg_buffer.curr = 0; jpeg_buffer.curr = 0;
word = 0; word = 0;
...@@ -825,14 +825,14 @@ static void exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx) ...@@ -825,14 +825,14 @@ static void exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx)
static void exynos4_jpeg_parse_huff_tbl(struct s5p_jpeg_ctx *ctx) static void exynos4_jpeg_parse_huff_tbl(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
struct s5p_jpeg_buffer jpeg_buffer; struct s5p_jpeg_buffer jpeg_buffer;
unsigned int word; unsigned int word;
int c, i, n, j; int c, i, n, j;
for (j = 0; j < ctx->out_q.dht.n; ++j) { for (j = 0; j < ctx->out_q.dht.n; ++j) {
jpeg_buffer.size = ctx->out_q.dht.len[j]; jpeg_buffer.size = ctx->out_q.dht.len[j];
jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(vb, 0) + jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) +
ctx->out_q.dht.marker[j]; ctx->out_q.dht.marker[j];
jpeg_buffer.curr = 0; jpeg_buffer.curr = 0;
...@@ -884,13 +884,13 @@ static void exynos4_jpeg_parse_huff_tbl(struct s5p_jpeg_ctx *ctx) ...@@ -884,13 +884,13 @@ static void exynos4_jpeg_parse_huff_tbl(struct s5p_jpeg_ctx *ctx)
static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx) static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
struct s5p_jpeg_buffer jpeg_buffer; struct s5p_jpeg_buffer jpeg_buffer;
int c, x, components; int c, x, components;
jpeg_buffer.size = ctx->out_q.sof_len; jpeg_buffer.size = ctx->out_q.sof_len;
jpeg_buffer.data = jpeg_buffer.data =
(unsigned long)vb2_plane_vaddr(vb, 0) + ctx->out_q.sof; (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) + ctx->out_q.sof;
jpeg_buffer.curr = 0; jpeg_buffer.curr = 0;
skip(&jpeg_buffer, 5); /* P, Y, X */ skip(&jpeg_buffer, 5); /* P, Y, X */
...@@ -915,14 +915,14 @@ static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx) ...@@ -915,14 +915,14 @@ static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx)
static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx *ctx) static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); struct vb2_v4l2_buffer *vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
struct s5p_jpeg_buffer jpeg_buffer; struct s5p_jpeg_buffer jpeg_buffer;
unsigned int word; unsigned int word;
int c, i, j; int c, i, j;
for (j = 0; j < ctx->out_q.dqt.n; ++j) { for (j = 0; j < ctx->out_q.dqt.n; ++j) {
jpeg_buffer.size = ctx->out_q.dqt.len[j]; jpeg_buffer.size = ctx->out_q.dqt.len[j];
jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(vb, 0) + jpeg_buffer.data = (unsigned long)vb2_plane_vaddr(&vb->vb2_buf, 0) +
ctx->out_q.dqt.marker[j]; ctx->out_q.dqt.marker[j];
jpeg_buffer.curr = 0; jpeg_buffer.curr = 0;
...@@ -2016,15 +2016,15 @@ static void s5p_jpeg_device_run(void *priv) ...@@ -2016,15 +2016,15 @@ static void s5p_jpeg_device_run(void *priv)
{ {
struct s5p_jpeg_ctx *ctx = priv; struct s5p_jpeg_ctx *ctx = priv;
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *src_buf, *dst_buf; struct vb2_v4l2_buffer *src_buf, *dst_buf;
unsigned long src_addr, dst_addr, flags; unsigned long src_addr, dst_addr, flags;
spin_lock_irqsave(&ctx->jpeg->slock, flags); spin_lock_irqsave(&ctx->jpeg->slock, flags);
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);
src_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0); src_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);
dst_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0); dst_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
s5p_jpeg_reset(jpeg->regs); s5p_jpeg_reset(jpeg->regs);
s5p_jpeg_poweron(jpeg->regs); s5p_jpeg_poweron(jpeg->regs);
...@@ -2097,7 +2097,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2097,7 +2097,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct s5p_jpeg_fmt *fmt; struct s5p_jpeg_fmt *fmt;
struct vb2_buffer *vb; struct vb2_v4l2_buffer *vb;
struct s5p_jpeg_addr jpeg_addr = {}; struct s5p_jpeg_addr jpeg_addr = {};
u32 pix_size, padding_bytes = 0; u32 pix_size, padding_bytes = 0;
...@@ -2116,7 +2116,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2116,7 +2116,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
vb = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); vb = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
} }
jpeg_addr.y = vb2_dma_contig_plane_dma_addr(vb, 0); jpeg_addr.y = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
if (fmt->colplanes == 2) { if (fmt->colplanes == 2) {
jpeg_addr.cb = jpeg_addr.y + pix_size - padding_bytes; jpeg_addr.cb = jpeg_addr.y + pix_size - padding_bytes;
...@@ -2134,7 +2134,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2134,7 +2134,7 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
static void exynos4_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx) static void exynos4_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *vb; struct vb2_v4l2_buffer *vb;
unsigned int jpeg_addr = 0; unsigned int jpeg_addr = 0;
if (ctx->mode == S5P_JPEG_ENCODE) if (ctx->mode == S5P_JPEG_ENCODE)
...@@ -2142,7 +2142,7 @@ static void exynos4_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2142,7 +2142,7 @@ static void exynos4_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
else else
vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
jpeg_addr = vb2_dma_contig_plane_dma_addr(vb, 0); jpeg_addr = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
if (jpeg->variant->version == SJPEG_EXYNOS5433 && if (jpeg->variant->version == SJPEG_EXYNOS5433 &&
ctx->mode == S5P_JPEG_DECODE) ctx->mode == S5P_JPEG_DECODE)
jpeg_addr += ctx->out_q.sos; jpeg_addr += ctx->out_q.sos;
...@@ -2257,7 +2257,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2257,7 +2257,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct s5p_jpeg_fmt *fmt; struct s5p_jpeg_fmt *fmt;
struct vb2_buffer *vb; struct vb2_v4l2_buffer *vb;
struct s5p_jpeg_addr jpeg_addr = {}; struct s5p_jpeg_addr jpeg_addr = {};
u32 pix_size; u32 pix_size;
...@@ -2271,7 +2271,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2271,7 +2271,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
fmt = ctx->cap_q.fmt; fmt = ctx->cap_q.fmt;
} }
jpeg_addr.y = vb2_dma_contig_plane_dma_addr(vb, 0); jpeg_addr.y = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
if (fmt->colplanes == 2) { if (fmt->colplanes == 2) {
jpeg_addr.cb = jpeg_addr.y + pix_size; jpeg_addr.cb = jpeg_addr.y + pix_size;
...@@ -2289,7 +2289,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2289,7 +2289,7 @@ static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
static void exynos3250_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx) static void exynos3250_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
{ {
struct s5p_jpeg *jpeg = ctx->jpeg; struct s5p_jpeg *jpeg = ctx->jpeg;
struct vb2_buffer *vb; struct vb2_v4l2_buffer *vb;
unsigned int jpeg_addr = 0; unsigned int jpeg_addr = 0;
if (ctx->mode == S5P_JPEG_ENCODE) if (ctx->mode == S5P_JPEG_ENCODE)
...@@ -2297,7 +2297,7 @@ static void exynos3250_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx) ...@@ -2297,7 +2297,7 @@ static void exynos3250_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
else else
vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
jpeg_addr = vb2_dma_contig_plane_dma_addr(vb, 0); jpeg_addr = vb2_dma_contig_plane_dma_addr(&vb->vb2_buf, 0);
exynos3250_jpeg_jpgadr(jpeg->regs, jpeg_addr); exynos3250_jpeg_jpgadr(jpeg->regs, jpeg_addr);
} }
......
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