From: Maxime Ripard <maxime@cerno.tech> To: Emma Anholt <emma@anholt.net>, Maxime Ripard <mripard@kernel.org>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dave Stevenson <dave.stevenson@raspberrypi.com>, Maxime Ripard <maxime@cerno.tech>, Thomas Zimmermann <tzimmermann@suse.de> Subject: [PATCH v2 8/9] drm/vc4: hdmi: Add BT.601 Support Date: Thu, 26 Jan 2023 14:46:42 +0100 [thread overview] Message-ID: <20221207-rpi-hdmi-improvements-v2-8-8ace2d8221ad@cerno.tech> (raw) In-Reply-To: <20221207-rpi-hdmi-improvements-v2-0-8ace2d8221ad@cerno.tech> From: Dave Stevenson <dave.stevenson@raspberrypi.com> Even though we report that we support the BT601 Colorspace, we were always using the BT.709 conversion matrices. Let's add the BT601 ones. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> --- drivers/gpu/drm/vc4/vc4_hdmi.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index c74a01f97de5..5d37952d620b 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1237,6 +1237,37 @@ static const u16 vc5_hdmi_csc_full_rgb_to_rgb[2][3][4] = { }, }; +/* + * Conversion between Full Range RGB and YUV using the BT.601 Colorspace + * + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets + */ +static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt601[2][3][4] = { + { + /* + * Full Range + * + * [ 0.299000 0.587000 0.114000 0 ] + * [ -0.168736 -0.331264 0.500000 128 ] + * [ 0.500000 -0.418688 -0.081312 128 ] + */ + { 0x0991, 0x12c9, 0x03a6, 0x0000 }, + { 0xfa9b, 0xf567, 0x1000, 0x2000 }, + { 0x1000, 0xf29b, 0xfd67, 0x2000 }, + }, + { + /* Limited Range + * + * [ 0.255785 0.502160 0.097523 16 ] + * [ -0.147644 -0.289856 0.437500 128 ] + * [ 0.437500 -0.366352 -0.071148 128 ] + */ + { 0x082f, 0x1012, 0x031f, 0x0400 }, + { 0xfb48, 0xf6ba, 0x0e00, 0x2000 }, + { 0x0e00, 0xf448, 0xfdba, 0x2000 }, + }, +}; + /* * Conversion between Full Range RGB and YUV using the BT.709 Colorspace * @@ -1300,6 +1331,13 @@ static const u16 (*vc5_hdmi_find_yuv_csc_coeffs(struct vc4_hdmi *vc4_hdmi, u32 colorspace, bool limited))[4] { switch (colorspace) { + case DRM_MODE_COLORIMETRY_SMPTE_170M_YCC: + case DRM_MODE_COLORIMETRY_XVYCC_601: + case DRM_MODE_COLORIMETRY_SYCC_601: + case DRM_MODE_COLORIMETRY_OPYCC_601: + case DRM_MODE_COLORIMETRY_BT601_YCC: + return vc5_hdmi_csc_full_rgb_to_yuv_bt601[limited]; + default: case DRM_MODE_COLORIMETRY_NO_DATA: case DRM_MODE_COLORIMETRY_BT709_YCC: -- 2.39.1
WARNING: multiple messages have this Message-ID (diff)
From: Maxime Ripard <maxime@cerno.tech> To: Emma Anholt <emma@anholt.net>, Maxime Ripard <mripard@kernel.org>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: Thomas Zimmermann <tzimmermann@suse.de>, Maxime Ripard <maxime@cerno.tech>, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson <dave.stevenson@raspberrypi.com> Subject: [PATCH v2 8/9] drm/vc4: hdmi: Add BT.601 Support Date: Thu, 26 Jan 2023 14:46:42 +0100 [thread overview] Message-ID: <20221207-rpi-hdmi-improvements-v2-8-8ace2d8221ad@cerno.tech> (raw) In-Reply-To: <20221207-rpi-hdmi-improvements-v2-0-8ace2d8221ad@cerno.tech> From: Dave Stevenson <dave.stevenson@raspberrypi.com> Even though we report that we support the BT601 Colorspace, we were always using the BT.709 conversion matrices. Let's add the BT601 ones. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> --- drivers/gpu/drm/vc4/vc4_hdmi.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index c74a01f97de5..5d37952d620b 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1237,6 +1237,37 @@ static const u16 vc5_hdmi_csc_full_rgb_to_rgb[2][3][4] = { }, }; +/* + * Conversion between Full Range RGB and YUV using the BT.601 Colorspace + * + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets + */ +static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt601[2][3][4] = { + { + /* + * Full Range + * + * [ 0.299000 0.587000 0.114000 0 ] + * [ -0.168736 -0.331264 0.500000 128 ] + * [ 0.500000 -0.418688 -0.081312 128 ] + */ + { 0x0991, 0x12c9, 0x03a6, 0x0000 }, + { 0xfa9b, 0xf567, 0x1000, 0x2000 }, + { 0x1000, 0xf29b, 0xfd67, 0x2000 }, + }, + { + /* Limited Range + * + * [ 0.255785 0.502160 0.097523 16 ] + * [ -0.147644 -0.289856 0.437500 128 ] + * [ 0.437500 -0.366352 -0.071148 128 ] + */ + { 0x082f, 0x1012, 0x031f, 0x0400 }, + { 0xfb48, 0xf6ba, 0x0e00, 0x2000 }, + { 0x0e00, 0xf448, 0xfdba, 0x2000 }, + }, +}; + /* * Conversion between Full Range RGB and YUV using the BT.709 Colorspace * @@ -1300,6 +1331,13 @@ static const u16 (*vc5_hdmi_find_yuv_csc_coeffs(struct vc4_hdmi *vc4_hdmi, u32 colorspace, bool limited))[4] { switch (colorspace) { + case DRM_MODE_COLORIMETRY_SMPTE_170M_YCC: + case DRM_MODE_COLORIMETRY_XVYCC_601: + case DRM_MODE_COLORIMETRY_SYCC_601: + case DRM_MODE_COLORIMETRY_OPYCC_601: + case DRM_MODE_COLORIMETRY_BT601_YCC: + return vc5_hdmi_csc_full_rgb_to_yuv_bt601[limited]; + default: case DRM_MODE_COLORIMETRY_NO_DATA: case DRM_MODE_COLORIMETRY_BT709_YCC: -- 2.39.1
next prev parent reply other threads:[~2023-01-26 13:49 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-26 13:46 [PATCH v2 0/9] drm/vc4: hdmi: Broadcast RGB, BT601, BT2020 Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-01-26 13:46 ` [PATCH v2 1/9] drm/vc4: Switch to container_of_const Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-02-18 10:45 ` Hans Verkuil 2023-02-18 10:45 ` Hans Verkuil 2023-02-21 11:38 ` Maxime Ripard 2023-02-21 11:38 ` Maxime Ripard 2023-02-21 14:18 ` Hans Verkuil 2023-02-21 14:18 ` Hans Verkuil 2023-01-26 13:46 ` [PATCH v2 2/9] drm/vc4: hdmi: Update all the planes if the TV margins are changed Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-01-26 13:46 ` [PATCH v2 3/9] drm/vc4: hdmi: Add Broadcast RGB property to allow override of RGB range Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-02-18 11:33 ` Hans Verkuil 2023-02-18 11:33 ` Hans Verkuil 2023-02-20 15:23 ` Dave Stevenson 2023-02-20 15:23 ` Dave Stevenson 2023-02-21 11:27 ` Hans Verkuil 2023-02-21 11:27 ` Hans Verkuil 2023-02-21 11:38 ` Sebastian Wick 2023-02-21 11:38 ` Sebastian Wick 2023-01-26 13:46 ` [PATCH v2 4/9] drm/vc4: hdmi: Rename full range helper Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-01-26 13:46 ` [PATCH v2 5/9] drm/vc4: hdmi: Swap CSC matrix channels for YUV444 Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-01-26 13:46 ` [PATCH v2 6/9] drm/vc4: hdmi: Rework the CSC matrices organization Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-01-26 13:46 ` [PATCH v2 7/9] drm/vc4: hdmi: Add a function to retrieve the CSC matrix Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard [this message] 2023-01-26 13:46 ` [PATCH v2 8/9] drm/vc4: hdmi: Add BT.601 Support Maxime Ripard 2023-01-26 13:46 ` [PATCH v2 9/9] drm/vc4: hdmi: Add BT.2020 Support Maxime Ripard 2023-01-26 13:46 ` Maxime Ripard
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=20221207-rpi-hdmi-improvements-v2-8-8ace2d8221ad@cerno.tech \ --to=maxime@cerno.tech \ --cc=airlied@gmail.com \ --cc=daniel@ffwll.ch \ --cc=dave.stevenson@raspberrypi.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=emma@anholt.net \ --cc=linux-kernel@vger.kernel.org \ --cc=mripard@kernel.org \ --cc=tzimmermann@suse.de \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.