From: Hans Verkuil <hverkuil@xs4all.nl>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: linux-media@vger.kernel.org, kyungmin.park@samsung.com,
s.nawrocki@samsung.com, sw0312.kim@samsung.com
Subject: Re: [PATCH 15/16] s5p-jpeg: Ensure setting correct value of the chroma subsampling control
Date: Tue, 19 Nov 2013 15:52:38 +0100 [thread overview]
Message-ID: <528B7B36.4020009@xs4all.nl> (raw)
In-Reply-To: <1384871228-6648-16-git-send-email-j.anaszewski@samsung.com>
On 11/19/2013 03:27 PM, Jacek Anaszewski wrote:
> Exynos4x12 has limitations regarding setting chroma subsampling
> of an output JPEG image. It cannot be lower than the subsampling
> of the raw source image. Also in case of V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY
> option the source image fourcc has to be V4L2_PIX_FMT_GREY.
> This patch adds mechanism that prevents setting invalid value
> of the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control.
>
> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> drivers/media/platform/s5p-jpeg/jpeg-core.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index d4db612..3605470 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -1176,6 +1176,7 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
> {
> struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl);
> unsigned long flags;
> + int ret = 0;
>
> spin_lock_irqsave(&ctx->jpeg->slock, flags);
>
> @@ -1187,12 +1188,34 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
> ctx->restart_interval = ctrl->val;
> break;
> case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
> - ctx->subsampling = ctrl->val;
> + if (ctx->jpeg->variant->version == SJPEG_S5P) {
> + ctx->subsampling = ctrl->val;
> + break;
> + }
> + /*
> + * The exynos4x12 device requires input raw image fourcc
> + * to be V4L2_PIX_FMT_GREY if gray jpeg format
> + * is to be set.
> + */
> + if (ctx->out_q.fmt->fourcc != V4L2_PIX_FMT_GREY &&
> + ctrl->val == V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY) {
> + ret = -EINVAL;
> + goto error_free;
> + }
> + /*
> + * The exynos4x12 device requires resulting jpeg subsampling
> + * not to be lower than the input raw image subsampling.
> + */
> + if (ctx->out_q.fmt->subsampling > ctrl->val)
> + ctx->subsampling = ctx->out_q.fmt->subsampling;
> + else
> + ctx->subsampling = ctrl->val;
I would do this in a try_ctrl op instead: that way VIDIOC_TRY_EXT_CTRLS will
also be able to understand these restrictions.
Before the s_ctrl op is called the control framework will always call the
try_ctrl op as well if it is present.
Regards,
Hans
> break;
> }
>
> +error_free:
> spin_unlock_irqrestore(&ctx->jpeg->slock, flags);
> - return 0;
> + return ret;
> }
>
> static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops = {
>
next prev parent reply other threads:[~2013-11-19 14:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-19 14:26 [PATCH 00/16] Add support for Exynox4x12 to the s5p-jpeg driver Jacek Anaszewski
2013-11-19 14:26 ` [PATCH 01/16] s5p-jpeg: Reorder quantization tables Jacek Anaszewski
2013-11-19 14:26 ` [PATCH 02/16] s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder Jacek Anaszewski
2013-11-19 14:26 ` [PATCH 03/16] s5p-jpeg: Fix erroneous condition while validating bytesperline value Jacek Anaszewski
2013-11-19 14:26 ` [PATCH 04/16] s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function Jacek Anaszewski
2013-11-19 14:26 ` [PATCH 05/16] s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly Jacek Anaszewski
2013-11-19 14:26 ` [PATCH 06/16] s5p-jpeg: Fix clock resource management Jacek Anaszewski
2013-11-19 14:26 ` [PATCH 07/16] s5p-jpeg: Fix lack of spin_lock protection Jacek Anaszewski
2013-11-19 14:27 ` [PATCH 08/16] s5p-jpeg: Synchronize cached controls with V4L2 core Jacek Anaszewski
2013-11-19 14:27 ` [PATCH 09/16] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c Jacek Anaszewski
2013-11-19 14:27 ` [PATCH 10/16] s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec Jacek Anaszewski
2013-11-19 14:27 ` [PATCH 11/16] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header Jacek Anaszewski
2013-11-19 14:27 ` [PATCH 12/16] s5p-jpeg: Ensure correct capture format for Exynos4x12 Jacek Anaszewski
2013-11-19 14:27 ` [PATCH 13/16] s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder Jacek Anaszewski
2013-11-19 14:27 ` [PATCH 14/16] s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value Jacek Anaszewski
2013-11-19 14:46 ` Hans Verkuil
2013-11-20 13:47 ` Jacek Anaszewski
2013-11-20 14:13 ` Hans Verkuil
2013-11-19 14:27 ` [PATCH 15/16] s5p-jpeg: Ensure setting correct value of the chroma subsampling control Jacek Anaszewski
2013-11-19 14:52 ` Hans Verkuil [this message]
2013-11-19 14:27 ` [PATCH 16/16] s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs Jacek Anaszewski
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=528B7B36.4020009@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=j.anaszewski@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=sw0312.kim@samsung.com \
/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