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: Dave Stevenson <dave.stevenson@raspberrypi.com>, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Hans Verkuil <hverkuil@xs4all.nl>, Maxime Ripard <maxime@cerno.tech>, Thomas Zimmermann <tzimmermann@suse.de> Subject: [PATCH v3 9/9] drm/vc4: hdmi: Add BT.2020 Support Date: Mon, 06 Mar 2023 11:46:50 +0100 [thread overview] Message-ID: <20221207-rpi-hdmi-improvements-v3-9-bdd54f66884e@cerno.tech> (raw) In-Reply-To: <20221207-rpi-hdmi-improvements-v3-0-bdd54f66884e@cerno.tech> From: Dave Stevenson <dave.stevenson@raspberrypi.com> Even though we report that we support the BT.2020 Colorspace, we were always using the BT.709 conversion matrices. Let's add the BT.2020 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 ad38cac3d1b9..2787284e60ea 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1303,6 +1303,37 @@ static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt709[2][3][4] = { }, }; +/* + * Conversion between Full Range RGB and YUV using the BT.2020 Colorspace + * + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets + */ +static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt2020[2][3][4] = { + { + /* + * Full Range + * + * [ 0.262700 0.678000 0.059300 0 ] + * [ -0.139630 -0.360370 0.500000 128 ] + * [ 0.500000 -0.459786 -0.040214 128 ] + */ + { 0x0868, 0x15b2, 0x01e6, 0x0000 }, + { 0xfb89, 0xf479, 0x1000, 0x2000 }, + { 0x1000, 0xf14a, 0xfeb8, 0x2000 }, + }, + { + /* Limited Range + * + * [ 0.224732 0.580008 0.050729 16 ] + * [ -0.122176 -0.315324 0.437500 128 ] + * [ 0.437500 -0.402312 -0.035188 128 ] + */ + { 0x082f, 0x1012, 0x031f, 0x0400 }, + { 0xfb48, 0xf6ba, 0x0e00, 0x2000 }, + { 0x0e00, 0xf448, 0xfdba, 0x2000 }, + }, +}; + static void vc5_hdmi_set_csc_coeffs(struct vc4_hdmi *vc4_hdmi, const u16 coeffs[3][4]) { @@ -1348,6 +1379,13 @@ static const u16 case DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED: case DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT: return vc5_hdmi_csc_full_rgb_to_yuv_bt709[limited]; + + case DRM_MODE_COLORIMETRY_BT2020_CYCC: + case DRM_MODE_COLORIMETRY_BT2020_YCC: + case DRM_MODE_COLORIMETRY_BT2020_RGB: + case DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65: + case DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER: + return vc5_hdmi_csc_full_rgb_to_yuv_bt2020[limited]; } } -- 2.39.2
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: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dave Stevenson <dave.stevenson@raspberrypi.com>, Hans Verkuil <hverkuil@xs4all.nl>, Maxime Ripard <maxime@cerno.tech>, Thomas Zimmermann <tzimmermann@suse.de> Subject: [PATCH v3 9/9] drm/vc4: hdmi: Add BT.2020 Support Date: Mon, 06 Mar 2023 11:46:50 +0100 [thread overview] Message-ID: <20221207-rpi-hdmi-improvements-v3-9-bdd54f66884e@cerno.tech> (raw) In-Reply-To: <20221207-rpi-hdmi-improvements-v3-0-bdd54f66884e@cerno.tech> From: Dave Stevenson <dave.stevenson@raspberrypi.com> Even though we report that we support the BT.2020 Colorspace, we were always using the BT.709 conversion matrices. Let's add the BT.2020 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 ad38cac3d1b9..2787284e60ea 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1303,6 +1303,37 @@ static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt709[2][3][4] = { }, }; +/* + * Conversion between Full Range RGB and YUV using the BT.2020 Colorspace + * + * Matrices are signed 2p13 fixed point, with signed 9p6 offsets + */ +static const u16 vc5_hdmi_csc_full_rgb_to_yuv_bt2020[2][3][4] = { + { + /* + * Full Range + * + * [ 0.262700 0.678000 0.059300 0 ] + * [ -0.139630 -0.360370 0.500000 128 ] + * [ 0.500000 -0.459786 -0.040214 128 ] + */ + { 0x0868, 0x15b2, 0x01e6, 0x0000 }, + { 0xfb89, 0xf479, 0x1000, 0x2000 }, + { 0x1000, 0xf14a, 0xfeb8, 0x2000 }, + }, + { + /* Limited Range + * + * [ 0.224732 0.580008 0.050729 16 ] + * [ -0.122176 -0.315324 0.437500 128 ] + * [ 0.437500 -0.402312 -0.035188 128 ] + */ + { 0x082f, 0x1012, 0x031f, 0x0400 }, + { 0xfb48, 0xf6ba, 0x0e00, 0x2000 }, + { 0x0e00, 0xf448, 0xfdba, 0x2000 }, + }, +}; + static void vc5_hdmi_set_csc_coeffs(struct vc4_hdmi *vc4_hdmi, const u16 coeffs[3][4]) { @@ -1348,6 +1379,13 @@ static const u16 case DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED: case DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT: return vc5_hdmi_csc_full_rgb_to_yuv_bt709[limited]; + + case DRM_MODE_COLORIMETRY_BT2020_CYCC: + case DRM_MODE_COLORIMETRY_BT2020_YCC: + case DRM_MODE_COLORIMETRY_BT2020_RGB: + case DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65: + case DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER: + return vc5_hdmi_csc_full_rgb_to_yuv_bt2020[limited]; } } -- 2.39.2
next prev parent reply other threads:[~2023-03-06 10:50 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-06 10:46 [PATCH v3 0/9] drm/vc4: hdmi: Broadcast RGB, BT601, BT2020 Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-03-06 10:46 ` [PATCH v3 1/9] drm/vc4: Switch to container_of_const Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-04-22 5:26 ` Javier Martinez Canillas 2023-04-22 5:26 ` Javier Martinez Canillas 2023-04-25 7:38 ` Maxime Ripard 2023-04-25 7:38 ` Maxime Ripard 2023-04-25 8:21 ` Javier Martinez Canillas 2023-04-25 8:21 ` Javier Martinez Canillas 2023-03-06 10:46 ` [PATCH v3 2/9] drm/vc4: hdmi: Update all the planes if the TV margins are changed Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-03-06 10:46 ` [PATCH v3 3/9] drm/vc4: hdmi: Add Broadcast RGB property to allow override of RGB range Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-10-11 13:23 ` Daniel Vetter 2023-10-11 13:23 ` Daniel Vetter 2023-10-19 8:02 ` Maxime Ripard 2023-10-19 8:02 ` Maxime Ripard 2023-10-19 8:26 ` Hans Verkuil 2023-10-19 8:26 ` Hans Verkuil 2023-10-23 14:58 ` Maxime Ripard 2023-10-23 14:58 ` Maxime Ripard 2023-10-23 16:22 ` Sebastian Wick 2023-10-23 16:22 ` Sebastian Wick 2023-03-06 10:46 ` [PATCH v3 4/9] drm/vc4: hdmi: Rename full range helper Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-03-06 10:46 ` [PATCH v3 5/9] drm/vc4: hdmi: Swap CSC matrix channels for YUV444 Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-03-06 10:46 ` [PATCH v3 6/9] drm/vc4: hdmi: Rework the CSC matrices organization Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-03-06 10:46 ` [PATCH v3 7/9] drm/vc4: hdmi: Add a function to retrieve the CSC matrix Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-03-06 10:46 ` [PATCH v3 8/9] drm/vc4: hdmi: Add BT.601 Support Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard 2023-03-06 10:46 ` Maxime Ripard [this message] 2023-03-06 10:46 ` [PATCH v3 9/9] drm/vc4: hdmi: Add BT.2020 Support Maxime Ripard 2023-04-25 7:34 ` [PATCH v3 0/9] drm/vc4: hdmi: Broadcast RGB, BT601, BT2020 Maxime Ripard 2023-04-25 7:34 ` 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-v3-9-bdd54f66884e@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=hverkuil@xs4all.nl \ --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.