From 94ac2ab3fff96814d7460a27a0e9d004abbd4128 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 19 Jun 2024 23:00:37 +0200 Subject: Merging upstream version 6.9.2. Signed-off-by: Daniel Baumann --- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c') diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index 64112b6329..cc97790ed3 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -1373,6 +1373,8 @@ static bool mxc_jpeg_source_change(struct mxc_jpeg_ctx *ctx, q_data_cap->crop.top = 0; q_data_cap->crop.width = jpeg_src_buf->w; q_data_cap->crop.height = jpeg_src_buf->h; + q_data_cap->bytesperline[0] = 0; + q_data_cap->bytesperline[1] = 0; /* * align up the resolution for CAST IP, @@ -1752,6 +1754,14 @@ static u32 mxc_jpeg_get_image_format(struct device *dev, static void mxc_jpeg_bytesperline(struct mxc_jpeg_q_data *q, u32 precision) { + u32 bytesperline[2]; + + bytesperline[0] = q->bytesperline[0]; + bytesperline[1] = q->bytesperline[0]; /*imx-jpeg only support the same line pitch*/ + v4l_bound_align_image(&bytesperline[0], 0, MXC_JPEG_MAX_LINE, 2, + &bytesperline[1], 0, MXC_JPEG_MAX_LINE, 2, + 0); + /* Bytes distance between the leftmost pixels in two adjacent lines */ if (q->fmt->fourcc == V4L2_PIX_FMT_JPEG) { /* bytesperline unused for compressed formats */ @@ -1775,6 +1785,12 @@ static void mxc_jpeg_bytesperline(struct mxc_jpeg_q_data *q, u32 precision) q->bytesperline[0] = q->w_adjusted * DIV_ROUND_UP(precision, 8); q->bytesperline[1] = 0; } + + if (q->fmt->fourcc != V4L2_PIX_FMT_JPEG) { + q->bytesperline[0] = max(q->bytesperline[0], bytesperline[0]); + if (q->fmt->mem_planes > 1) + q->bytesperline[1] = max(q->bytesperline[1], bytesperline[1]); + } } static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q) -- cgit v1.2.3