mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Escande <thierry.escande@collabora.com>
To: Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/6] [media] s5p-jpeg: Call jpeg_bound_align_image after qbuf
Date: Mon, 12 Jun 2017 19:13:21 +0200	[thread overview]
Message-ID: <1497287605-20074-3-git-send-email-thierry.escande@collabora.com> (raw)
In-Reply-To: <1497287605-20074-1-git-send-email-thierry.escande@collabora.com>

From: Tony K Nadackal <tony.kn@samsung.com>

When queuing an OUTPUT buffer for decoder, s5p_jpeg_parse_hdr()
function parses the input jpeg file and takes the width and height
parameters from its header. These new width/height values will be used
for the calculation of stride. HX_JPEG Hardware needs the width and
height values aligned on a 16 bits boundary. This width/height alignment
is handled in the s5p_jpeg_s_fmt_vid_cap() function during the S_FMT
ioctl call.

But if user space calls the QBUF of OUTPUT buffer after the S_FMT of
CAPTURE buffer, these aligned values will be replaced by the values in
jpeg header. If the width/height values of jpeg are not aligned, the
decoder output will be corrupted. So in this patch we call
jpeg_bound_align_image() to align the width/height values of Capture
buffer in s5p_jpeg_buf_queue().

Signed-off-by: Tony K Nadackal <tony.kn@samsung.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
---
 drivers/media/platform/s5p-jpeg/jpeg-core.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 52dc794..623508d 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -2523,6 +2523,25 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
 		q_data = &ctx->cap_q;
 		q_data->w = tmp.w;
 		q_data->h = tmp.h;
+
+		/*
+		 * This call to jpeg_bound_align_image() takes care of width and
+		 * height values alignment when user space calls the QBUF of
+		 * OUTPUT buffer after the S_FMT of CAPTURE buffer.
+		 * Please note that on Exynos4x12 SoCs, resigning from executing
+		 * S_FMT on capture buffer for each JPEG image can result in a
+		 * hardware hangup if subsampling is lower than the one of input
+		 * JPEG.
+		 */
+		jpeg_bound_align_image(ctx,
+				       &q_data->w,
+				       S5P_JPEG_MIN_WIDTH, S5P_JPEG_MAX_WIDTH,
+				       q_data->fmt->h_align,
+				       &q_data->h,
+				       S5P_JPEG_MIN_HEIGHT, S5P_JPEG_MAX_HEIGHT,
+				       q_data->fmt->v_align);
+
+		q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3;
 	}
 
 	v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
-- 
2.7.4

  parent reply	other threads:[~2017-06-12 17:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12 17:13 [PATCH v2 0/6] [media] s5p-jpeg: Various fixes and improvements Thierry Escande
2017-06-12 17:13 ` [PATCH v2 1/6] [media] s5p-jpeg: Reset the Codec before doing a soft reset Thierry Escande
2017-06-21  8:00   ` Andrzej Pietrasiewicz
2017-06-12 17:13 ` Thierry Escande [this message]
2017-06-12 17:13 ` [PATCH v2 3/6] [media] s5p-jpeg: Correct WARN_ON statement for checking subsampling Thierry Escande
2017-06-12 17:13 ` [PATCH v2 4/6] [media] s5p-jpeg: Decode 4:1:1 chroma subsampling format Thierry Escande
2017-06-20 11:57   ` Andrzej Pietrasiewicz
2017-06-12 17:13 ` [PATCH v2 5/6] [media] s5p-jpeg: Add support for resolution change event Thierry Escande
2017-06-16 15:38   ` Andrzej Pietrasiewicz
2017-06-19 13:50     ` Thierry Escande
2017-06-20 10:51       ` Andrzej Pietrasiewicz
2017-06-20 14:08         ` Thierry Escande
2017-06-12 17:13 ` [PATCH v2 6/6] [media] s5p-jpeg: Add stream error handling for Exynos5420 Thierry Escande
2017-06-16 15:30   ` Andrzej Pietrasiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497287605-20074-3-git-send-email-thierry.escande@collabora.com \
    --to=thierry.escande@collabora.com \
    --cc=andrzej.p@samsung.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®