From: Philipp Zabel <p.zabel@pengutronix.de>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, Mats Randgaard <matrandg@cisco.com>
Subject: Re: [PATCH v2 2/2] [media] tc358743: extend colorimetry support
Date: Mon, 13 Feb 2017 11:39:31 +0100 [thread overview]
Message-ID: <1486982371.2873.52.camel@pengutronix.de> (raw)
In-Reply-To: <aae5aa4d-f407-41eb-b244-41affbdafab5@xs4all.nl>
On Mon, 2017-02-13 at 11:05 +0100, Hans Verkuil wrote:
[...]
> > @@ -1469,38 +1477,88 @@ static int tc358743_s_stream(struct v4l2_subdev *sd, int enable)
> >
> > /* --------------- PAD OPS --------------- */
> >
> > -static int tc358743_get_fmt(struct v4l2_subdev *sd,
> > - struct v4l2_subdev_pad_config *cfg,
> > - struct v4l2_subdev_format *format)
> > +static void tc358743_get_csi_color_space(struct v4l2_subdev *sd,
> > + struct v4l2_mbus_framefmt *format)
> > {
> > - struct tc358743_state *state = to_state(sd);
> > + u8 vi_status3 = i2c_rd8(sd, VI_STATUS3);
> > u8 vi_rep = i2c_rd8(sd, VI_REP);
> >
> > - if (format->pad != 0)
> > - return -EINVAL;
> > + switch (vi_status3 & MASK_S_V_COLOR) {
> > + default:
> > + case MASK_S_V_COLOR_RGB:
> > + case MASK_S_V_COLOR_SYCC601:
> > + format->colorspace = V4L2_COLORSPACE_SRGB;
> > + format->xfer_func = V4L2_XFER_FUNC_SRGB;
> > + break;
> > + case MASK_S_V_COLOR_YCBCR601:
> > + case MASK_S_V_COLOR_XVYCC601:
> > + format->colorspace = V4L2_COLORSPACE_SMPTE170M;
>
> Not correct. XVYCC601 uses the REC709 colorspace. The XVYCC formats
> are only defined for the REC709 colorspace and only differ in the
> YCbCr encoding that they use.
I'll move the XVYCC601 case down to join YCBCR709 and XVYCC709.
> > + format->xfer_func = V4L2_XFER_FUNC_709;
> > + break;
> > + case MASK_S_V_COLOR_YCBCR709:
> > + case MASK_S_V_COLOR_XVYCC709:
> > + format->colorspace = V4L2_COLORSPACE_REC709;
> > + format->xfer_func = V4L2_XFER_FUNC_709;
> > + break;
> > + case MASK_S_V_COLOR_ADOBERGB:
> > + case MASK_S_V_COLOR_ADOBEYCC601:
> > + format->colorspace = V4L2_COLORSPACE_ADOBERGB;
> > + format->xfer_func = V4L2_XFER_FUNC_ADOBERGB;
> > + break;
> > + }
> >
> > - format->format.code = state->mbus_fmt_code;
> > - format->format.width = state->timings.bt.width;
> > - format->format.height = state->timings.bt.height;
> > - format->format.field = V4L2_FIELD_NONE;
> > + format->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(format->colorspace);
> >
> > switch (vi_rep & MASK_VOUT_COLOR_SEL) {
> > + default:
> > case MASK_VOUT_COLOR_RGB_FULL:
> > + format->ycbcr_enc = V4L2_YCBCR_ENC_601;
> > + format->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> > + break;
> > case MASK_VOUT_COLOR_RGB_LIMITED:
> > - format->format.colorspace = V4L2_COLORSPACE_SRGB;
> > + format->ycbcr_enc = V4L2_YCBCR_ENC_601;
> > + format->quantization = V4L2_QUANTIZATION_LIM_RANGE;
> > break;
> > case MASK_VOUT_COLOR_601_YCBCR_LIMITED:
> > + format->ycbcr_enc = V4L2_YCBCR_ENC_601;
> > + format->quantization = V4L2_QUANTIZATION_LIM_RANGE;
> > + break;
> > case MASK_VOUT_COLOR_601_YCBCR_FULL:
> > - format->format.colorspace = V4L2_COLORSPACE_SMPTE170M;
> > + format->ycbcr_enc = V4L2_YCBCR_ENC_XV601;
>
> This isn't right. Only use V4L2_YCBCR_ENC_XV601 (or XV709) if this is
> signaled in the InfoFrame.
>
> Full Range V4L2_YCBCR_ENC_601 != Full Range V4L2_YCBCR_ENC_XV601.
>
> XV601 is similar to Limited Range 601, except that it also utilizes
> values 0-15 and 241-255, thus allowing for a wider gamut of colors.
Thanks. With that explanation, I think I should just change this to
V4L2_YCBCR_ENC_601 and limit the VOUT_COLOR_RGB/601/709 selections to
RGB input.
> > + format->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> > break;
> > case MASK_VOUT_COLOR_709_YCBCR_FULL:
> > + format->ycbcr_enc = V4L2_YCBCR_ENC_XV709;
> > + format->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> > + break;
> > case MASK_VOUT_COLOR_709_YCBCR_LIMITED:
> > - format->format.colorspace = V4L2_COLORSPACE_REC709;
> > + format->ycbcr_enc = V4L2_YCBCR_ENC_709;
> > + format->quantization = V4L2_QUANTIZATION_LIM_RANGE;
> > break;
> > - default:
> > - format->format.colorspace = 0;
> > + case MASK_VOUT_COLOR_FULL_TO_LIMITED:
> > + format->quantization = V4L2_QUANTIZATION_LIM_RANGE;
> > + break;
> > + case MASK_VOUT_COLOR_LIMITED_TO_FULL:
> > + format->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> > break;
Then I'll use FULL_TO_LIMITED / LIMITED_TO_FULL to for YUV inputs and
correctly set ycbcr_enc and quantization depending on this and input
colorspace.
[...]
> Except for the noted issues this looks good to me.
Thank you for the review.
regards
Philipp
prev parent reply other threads:[~2017-02-13 10:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 9:24 [PATCH v2 1/2] [media] tc358743: put lanes in STOP state before starting streaming Philipp Zabel
2017-02-13 9:24 ` [PATCH v2 2/2] [media] tc358743: extend colorimetry support Philipp Zabel
2017-02-13 10:05 ` Hans Verkuil
2017-02-13 10:39 ` Philipp Zabel [this message]
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=1486982371.2873.52.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=matrandg@cisco.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