From: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
To: linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com, helen.koike@collabora.com,
ezequiel@collabora.com, hverkuil@xs4all.nl, kernel@collabora.com,
dafna3@gmail.com, sakari.ailus@linux.intel.com,
linux-rockchip@lists.infradead.org, mchehab@kernel.org,
tfiga@chromium.org, skhan@linuxfoundation.org,
p.zabel@pengutronix.de
Subject: Re: [RFC v4 5/8] media: staging: rkisp1: allow quantization conversion from userspace for isp source pad
Date: Sat, 6 Jun 2020 09:28:50 +0200 [thread overview]
Message-ID: <1254a90c-1851-c334-32e9-3c593fc38355@collabora.com> (raw)
In-Reply-To: <20200605172625.19777-6-dafna.hirschfeld@collabora.com>
On 05.06.20 19:26, Dafna Hirschfeld wrote:
> The isp entity has a hardware support to force full range quantization
> for YUV formats. Use the CSC API to allow userspace to set the
> quantization for YUV formats on the isp, resizer and capture entities.
>
> - The flag V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION is set on
> YUV formats during enumeration of the resizer and isp formats.
> - The flag V4L2_FMT_FLAG_CSC_QUANTIZATION is set on the YUV formats
> during enumeration of the capture formats.
> - The full quantization is set on YUV formats if userspace ask it
> on the entities using the flag V4L2_MBUS_FRAMEFMT_SET_CSC
> for subdevices and the flag V4L2_PIX_FMT_FLAG_SET_CSC on for
> the capture entity.
>
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> ---
> drivers/staging/media/rkisp1/rkisp1-capture.c | 23 ++++++++++++-------
> drivers/staging/media/rkisp1/rkisp1-isp.c | 22 ++++++++++++++----
> drivers/staging/media/rkisp1/rkisp1-resizer.c | 22 ++++++++++++++++++
> 3 files changed, 55 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
> index f69235f82c45..66856d5eb576 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-capture.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
> @@ -1085,8 +1085,6 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap,
> const struct v4l2_format_info **fmt_info)
> {
> const struct rkisp1_capture_config *config = cap->config;
> - struct rkisp1_capture *other_cap =
> - &cap->rkisp1->capture_devs[cap->id ^ 1];
> const struct rkisp1_capture_fmt_cfg *fmt;
> const struct v4l2_format_info *info;
> const unsigned int max_widths[] = { RKISP1_RSZ_MP_SRC_MAX_WIDTH,
> @@ -1108,16 +1106,21 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap,
> pixm->field = V4L2_FIELD_NONE;
> pixm->colorspace = V4L2_COLORSPACE_DEFAULT;
> pixm->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
> + pixm->xfer_func = V4L2_XFER_FUNC_DEFAULT;
>
> info = rkisp1_fill_pixfmt(pixm, cap->id);
>
> - /* can not change quantization when stream-on */
> - if (other_cap->is_streaming)
> - pixm->quantization = other_cap->pix.fmt.quantization;
> - /* output full range by default, take effect in params */
> - else if (!pixm->quantization ||
> - pixm->quantization > V4L2_QUANTIZATION_LIM_RANGE)
> + /*
> + * isp has a feature to select between limited and full range for YUV
> + * formats.
> + * So we should also support it in the capture using the CSC API
> + */
> + if (pixm->flags & V4L2_PIX_FMT_FLAG_SET_CSC &&
> + pixm->quantization == V4L2_QUANTIZATION_FULL_RANGE &&
> + v4l2_is_format_yuv(info))
> pixm->quantization = V4L2_QUANTIZATION_FULL_RANGE;
I notice now that this assignment makes no sense since we already check two lines
above that the pixm->quantization is full-range, I'll fix it in v5.
The logic is anyway correct.
Thanks,
Dafna
> + else
> + pixm->quantization = V4L2_QUANTIZATION_DEFAULT;
>
> if (fmt_cfg)
> *fmt_cfg = fmt;
> @@ -1152,12 +1155,16 @@ static int rkisp1_enum_fmt_vid_cap_mplane(struct file *file, void *priv,
> {
> struct rkisp1_capture *cap = video_drvdata(file);
> const struct rkisp1_capture_fmt_cfg *fmt = NULL;
> + const struct v4l2_format_info *info;
>
> if (f->index >= cap->config->fmt_size)
> return -EINVAL;
>
> fmt = &cap->config->fmts[f->index];
> f->pixelformat = fmt->fourcc;
> + info = v4l2_format_info(f->pixelformat);
> + if (v4l2_is_format_yuv(info))
> + f->flags = V4L2_FMT_FLAG_CSC_QUANTIZATION;
>
> return 0;
> }
> diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c
> index e66e87d6ea8b..28e0a3c594aa 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-isp.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c
> @@ -591,6 +591,10 @@ static int rkisp1_isp_enum_mbus_code(struct v4l2_subdev *sd,
>
> if (code->index == pos - 1) {
> code->code = fmt->mbus_code;
> + if (fmt->pixel_enc == V4L2_PIXEL_ENC_YUV &&
> + dir == RKISP1_DIR_SRC)
> + code->flags =
> + V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION;
> return 0;
> }
> }
> @@ -622,7 +626,6 @@ static int rkisp1_isp_init_config(struct v4l2_subdev *sd,
> RKISP1_ISP_PAD_SOURCE_VIDEO);
> *src_fmt = *sink_fmt;
> src_fmt->code = RKISP1_DEF_SRC_PAD_FMT;
> - src_fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
>
> src_crop = v4l2_subdev_get_try_crop(sd, cfg,
> RKISP1_ISP_PAD_SOURCE_VIDEO);
> @@ -665,10 +668,21 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp,
> isp->src_fmt = mbus_info;
> src_fmt->width = src_crop->width;
> src_fmt->height = src_crop->height;
> - src_fmt->quantization = format->quantization;
> - /* full range by default */
> - if (!src_fmt->quantization)
> +
> + src_fmt->colorspace = V4L2_COLORSPACE_DEFAULT;
> + src_fmt->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
> + src_fmt->xfer_func = V4L2_XFER_FUNC_DEFAULT;
> +
> + /*
> + * The CSC API is used to allow userspace to force full
> + * quantization on YUV formats.
> + */
> + if (format->flags & V4L2_MBUS_FRAMEFMT_SET_CSC &&
> + format->quantization == V4L2_QUANTIZATION_FULL_RANGE &&
> + mbus_info->pixel_enc == V4L2_PIXEL_ENC_YUV)
> src_fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE> + else
> + src_fmt->quantization = V4L2_QUANTIZATION_DEFAULT;
>
> *format = *src_fmt;
> }
> diff --git a/drivers/staging/media/rkisp1/rkisp1-resizer.c b/drivers/staging/media/rkisp1/rkisp1-resizer.c
> index fa28f4bd65c0..237cce9183f7 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-resizer.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-resizer.c
> @@ -549,8 +549,30 @@ static void rkisp1_rsz_set_sink_fmt(struct rkisp1_resizer *rsz,
> if (which == V4L2_SUBDEV_FORMAT_ACTIVE)
> rsz->pixel_enc = mbus_info->pixel_enc;
>
> + sink_fmt->colorspace = V4L2_COLORSPACE_DEFAULT;
> + sink_fmt->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
> + sink_fmt->xfer_func = V4L2_XFER_FUNC_DEFAULT;
> +
> + /*
> + * isp has a feature to select between limited and full range for
> + * YUV formats.
> + * so we should support it in the resizer using the CSC API
> + */
> +
> + if (format->flags & V4L2_MBUS_FRAMEFMT_SET_CSC &&
> + format->quantization == V4L2_QUANTIZATION_FULL_RANGE &&
> + mbus_info->pixel_enc == V4L2_PIXEL_ENC_YUV)
> + sink_fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> + else
> + sink_fmt->quantization = V4L2_QUANTIZATION_DEFAULT;
> +
> /* Propagete to source pad */
> src_fmt->code = sink_fmt->code;
> + src_fmt->field = sink_fmt->field;
> + src_fmt->colorspace = sink_fmt->colorspace;
> + src_fmt->ycbcr_enc = sink_fmt->ycbcr_enc;
> + src_fmt->xfer_func = sink_fmt->xfer_func;
> + src_fmt->quantization = sink_fmt->quantization;
>
> sink_fmt->width = clamp_t(u32, format->width,
> rsz->config->min_rsz_width,
>
next prev parent reply other threads:[~2020-06-06 7:28 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-05 17:26 [RFC v4 0/8] v4l2: add support for colorspace conversion API (CSC) for video capture and subdevices Dafna Hirschfeld
2020-06-05 17:26 ` [RFC v4 1/8] media: staging: rkisp1: rsz: supported formats are the isp's src formats, not sink formats Dafna Hirschfeld
2020-06-08 11:33 ` Hans Verkuil
2020-06-05 17:26 ` [RFC v4 2/8] media: staging: rkisp1: rsz: set default format if the given format is not RKISP1_DIR_SRC Dafna Hirschfeld
2020-06-08 11:31 ` Hans Verkuil
2020-06-05 17:26 ` [RFC v4 3/8] media: Documentation: v4l: move table of v4l2_pix_format(_mplane) flags to pixfmt-v4l2.rst Dafna Hirschfeld
2020-06-25 23:29 ` Helen Koike
2020-06-05 17:26 ` [RFC v4 4/8] v4l2: add support for colorspace conversion API (CSC) for video capture and subdevices Dafna Hirschfeld
2020-06-08 10:00 ` Hans Verkuil
2020-06-26 12:22 ` Philipp Zabel
2020-06-30 15:23 ` Dafna Hirschfeld
2020-07-01 13:21 ` Philipp Zabel
2020-06-25 23:29 ` Helen Koike
2020-06-26 7:13 ` Hans Verkuil
2020-06-30 16:36 ` Dafna Hirschfeld
2020-06-05 17:26 ` [RFC v4 5/8] media: staging: rkisp1: allow quantization conversion from userspace for isp source pad Dafna Hirschfeld
2020-06-06 7:28 ` Dafna Hirschfeld [this message]
2020-06-25 23:52 ` Helen Koike
2020-06-26 7:07 ` Dafna Hirschfeld
2020-06-05 17:26 ` [RFC v4 6/8] media: staging: rkisp1: validate quantization matching in link_validate callbacks Dafna Hirschfeld
2020-06-05 17:26 ` [RFC v4 7/8] media: vivid: Add support to the CSC API Dafna Hirschfeld
2020-06-08 10:10 ` Hans Verkuil
2020-06-08 16:34 ` Dafna Hirschfeld
2020-06-09 11:51 ` Hans Verkuil
2020-06-05 17:26 ` [RFC v4 8/8] media: v4l2: add support for the CSC API for hsv_enc on mediabus Dafna Hirschfeld
2020-06-26 12:24 ` Philipp Zabel
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=1254a90c-1851-c334-32e9-3c593fc38355@collabora.com \
--to=dafna.hirschfeld@collabora.com \
--cc=dafna3@gmail.com \
--cc=ezequiel@collabora.com \
--cc=helen.koike@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=sakari.ailus@linux.intel.com \
--cc=skhan@linuxfoundation.org \
--cc=tfiga@chromium.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;
as well as URLs for NNTP newsgroup(s).