Commit 66167269 authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab

media: staging: rkisp1: allow quantization setting by userspace on the isp source pad

The isp entity has hardware support to force full range quantization
for YUV formats. Use the subdev CSC API to allow userspace to set the
quantization for YUV formats on the isp entity.

- The flag V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION is set for
YUV formats during enumeration of the isp formats on the source pad.
- The full quantization is set on YUV formats if userspace asks it
on the isp entity using the flag V4L2_MBUS_FRAMEFMT_SET_CSC.

On the capture and the resizer, the quantization is read-only
and always set to the default quantization.
Signed-off-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarHelen Koike <helen.koike@collabora.com>
Reviewed-by: default avatarTomasz Figa <tfiga@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 62aacfa9
* Fix pad format size for statistics and parameters entities. * Fix pad format size for statistics and parameters entities.
* Fix checkpatch errors. * Fix checkpatch errors.
* Review and comment every lock * Review and comment every lock
* Handle quantization * Add uapi docs. Remember to add documentation of how quantization is handled.
* streaming paths (mainpath and selfpath) check if the other path is streaming * streaming paths (mainpath and selfpath) check if the other path is streaming
in several places of the code, review this, specially that it doesn't seem it in several places of the code, review this, specially that it doesn't seem it
supports streaming from both paths at the same time. supports streaming from both paths at the same time.
......
...@@ -1069,8 +1069,6 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap, ...@@ -1069,8 +1069,6 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap,
const struct v4l2_format_info **fmt_info) const struct v4l2_format_info **fmt_info)
{ {
const struct rkisp1_capture_config *config = cap->config; 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 rkisp1_capture_fmt_cfg *fmt;
const struct v4l2_format_info *info; const struct v4l2_format_info *info;
const unsigned int max_widths[] = { RKISP1_RSZ_MP_SRC_MAX_WIDTH, const unsigned int max_widths[] = { RKISP1_RSZ_MP_SRC_MAX_WIDTH,
...@@ -1095,14 +1093,6 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap, ...@@ -1095,14 +1093,6 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap,
info = rkisp1_fill_pixfmt(pixm, cap->id); 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)
pixm->quantization = V4L2_QUANTIZATION_FULL_RANGE;
if (fmt_cfg) if (fmt_cfg)
*fmt_cfg = fmt; *fmt_cfg = fmt;
if (fmt_info) if (fmt_info)
......
...@@ -589,6 +589,10 @@ static int rkisp1_isp_enum_mbus_code(struct v4l2_subdev *sd, ...@@ -589,6 +589,10 @@ static int rkisp1_isp_enum_mbus_code(struct v4l2_subdev *sd,
if (code->index == pos - 1) { if (code->index == pos - 1) {
code->code = fmt->mbus_code; code->code = fmt->mbus_code;
if (fmt->pixel_enc == V4L2_PIXEL_ENC_YUV &&
dir == RKISP1_ISP_SD_SRC)
code->flags =
V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION;
return 0; return 0;
} }
} }
...@@ -620,7 +624,6 @@ static int rkisp1_isp_init_config(struct v4l2_subdev *sd, ...@@ -620,7 +624,6 @@ static int rkisp1_isp_init_config(struct v4l2_subdev *sd,
RKISP1_ISP_PAD_SOURCE_VIDEO); RKISP1_ISP_PAD_SOURCE_VIDEO);
*src_fmt = *sink_fmt; *src_fmt = *sink_fmt;
src_fmt->code = RKISP1_DEF_SRC_PAD_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, src_crop = v4l2_subdev_get_try_crop(sd, cfg,
RKISP1_ISP_PAD_SOURCE_VIDEO); RKISP1_ISP_PAD_SOURCE_VIDEO);
...@@ -663,9 +666,18 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp, ...@@ -663,9 +666,18 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp,
isp->src_fmt = mbus_info; isp->src_fmt = mbus_info;
src_fmt->width = src_crop->width; src_fmt->width = src_crop->width;
src_fmt->height = src_crop->height; src_fmt->height = src_crop->height;
src_fmt->quantization = format->quantization;
/* full range by default */ /*
if (!src_fmt->quantization) * 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 if (mbus_info->pixel_enc == V4L2_PIXEL_ENC_YUV)
src_fmt->quantization = V4L2_QUANTIZATION_LIM_RANGE;
else
src_fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE; src_fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
*format = *src_fmt; *format = *src_fmt;
......
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