Commit 8dd504a3 authored by Ming Qian's avatar Ming Qian Committed by Mauro Carvalho Chehab

media: imx-jpeg: Refactor function mxc_jpeg_parse

Refine code to support dynamic resolution change
Signed-off-by: default avatarMing Qian <ming.qian@nxp.com>
Reviewed-by: default avatarMirela Rabulea <mirela.rabulea@nxp.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 86851969
...@@ -1247,8 +1247,7 @@ static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q) ...@@ -1247,8 +1247,7 @@ static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q)
} }
} }
static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb)
u8 *src_addr, u32 size, bool *dht_needed)
{ {
struct device *dev = ctx->mxc_jpeg->dev; struct device *dev = ctx->mxc_jpeg->dev;
struct mxc_jpeg_q_data *q_data_out, *q_data_cap; struct mxc_jpeg_q_data *q_data_out, *q_data_cap;
...@@ -1258,6 +1257,9 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, ...@@ -1258,6 +1257,9 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx,
struct v4l2_jpeg_header header; struct v4l2_jpeg_header header;
struct mxc_jpeg_sof *psof = NULL; struct mxc_jpeg_sof *psof = NULL;
struct mxc_jpeg_sos *psos = NULL; struct mxc_jpeg_sos *psos = NULL;
struct mxc_jpeg_src_buf *jpeg_src_buf = vb2_to_mxc_buf(vb);
u8 *src_addr = (u8 *)vb2_plane_vaddr(vb, 0);
u32 size = vb2_get_plane_payload(vb, 0);
int ret; int ret;
memset(&header, 0, sizeof(header)); memset(&header, 0, sizeof(header));
...@@ -1268,7 +1270,7 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, ...@@ -1268,7 +1270,7 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx,
} }
/* if DHT marker present, no need to inject default one */ /* if DHT marker present, no need to inject default one */
*dht_needed = (header.num_dht == 0); jpeg_src_buf->dht_needed = (header.num_dht == 0);
q_data_out = mxc_jpeg_get_q_data(ctx, q_data_out = mxc_jpeg_get_q_data(ctx,
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
...@@ -1383,10 +1385,7 @@ static void mxc_jpeg_buf_queue(struct vb2_buffer *vb) ...@@ -1383,10 +1385,7 @@ static void mxc_jpeg_buf_queue(struct vb2_buffer *vb)
jpeg_src_buf = vb2_to_mxc_buf(vb); jpeg_src_buf = vb2_to_mxc_buf(vb);
jpeg_src_buf->jpeg_parse_error = false; jpeg_src_buf->jpeg_parse_error = false;
ret = mxc_jpeg_parse(ctx, ret = mxc_jpeg_parse(ctx, vb);
(u8 *)vb2_plane_vaddr(vb, 0),
vb2_get_plane_payload(vb, 0),
&jpeg_src_buf->dht_needed);
if (ret) if (ret)
jpeg_src_buf->jpeg_parse_error = true; jpeg_src_buf->jpeg_parse_error = true;
......
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