From patchwork Fri Nov 29 23:56:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13889009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A9E4D735E4 for ; Sat, 30 Nov 2024 00:00:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B79F010E04D; Sat, 30 Nov 2024 00:00:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="GkX25JLP"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1FD8710E04D for ; Sat, 30 Nov 2024 00:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1732924830; bh=W1HibQ9xsma1KDzi+AGd4o9sDlBpPQXYOQNxed481Qo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GkX25JLPmMRvOOprAk5gVhykgnZzKZD3+xks198uHojL70Ut6HT0ykC8Fzm4kpZeF LwoflTJVZKgPJRlFtpO8ouQ0gtKBbP1JAkd/g9reidbcl9qJRHj3Plb+O2zalZYNGM XixodShsOK4IV6fOjpSDi/oQ5QscigeNthP2+XC+RjCKuE90lTPctVDSyP15ums0eU ThX0CwYjklQxEvrDTYEmKtf605A2kBZtRVO6v4N5kTNhNaDCrJSXcKs4Lwq+wOCVak xJSqoffdXYFii5o1s/YRAYqfkfgtUnD/emOJJNW/ri1dB9+yVrHsQdMb13/V1jSb+4 mP5FiS9Y97t8w== Received: from localhost (unknown [86.120.21.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 8436E17E0E6C; Sat, 30 Nov 2024 01:00:30 +0100 (CET) From: Cristian Ciocaltea Date: Sat, 30 Nov 2024 01:56:32 +0200 Subject: [PATCH 1/3] drm/connector: hdmi: Evaluate limited range after computing format MIME-Version: 1.0 Message-Id: <20241130-hdmi-conn-yuv-v1-1-254279a08671@collabora.com> References: <20241130-hdmi-conn-yuv-v1-0-254279a08671@collabora.com> In-Reply-To: <20241130-hdmi-conn-yuv-v1-0-254279a08671@collabora.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: kernel@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Evaluating the requirement to use a limited RGB quantization range involves a verification of the output format, among others, but this is currently performed before actually computing the format, hence relying on the old connector state. Move the call to hdmi_is_limited_range() after hdmi_compute_config() to ensure the verification is done on the updated output format. Signed-off-by: Cristian Ciocaltea --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index feb7a3a759811aed70c679be8704072093e2a79b..0cbcee7e77cd8dff387044487ce28ee5748f5587 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -494,12 +494,12 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, connector_state_get_mode(new_conn_state); int ret; - new_conn_state->hdmi.is_limited_range = hdmi_is_limited_range(connector, new_conn_state); - ret = hdmi_compute_config(connector, new_conn_state, mode); if (ret) return ret; + new_conn_state->hdmi.is_limited_range = hdmi_is_limited_range(connector, new_conn_state); + ret = hdmi_generate_infoframes(connector, new_conn_state); if (ret) return ret; From patchwork Fri Nov 29 23:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13889010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4722D735E6 for ; Sat, 30 Nov 2024 00:00:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B05D410E368; Sat, 30 Nov 2024 00:00:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="Qi95bxbh"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0340D10E368 for ; Sat, 30 Nov 2024 00:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1732924831; bh=Cza86IcsLPmgAtr3aY7j2z93JXxEWnTLFN4ccz2Y7tA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Qi95bxbhHt/xrTnYL0cSIahFCfQJ+geCLTtTT9ZKN0q/y+8JDtU9vLawsdyRU33jm ZQSvQ5i8ZF6kajwuv7rLkzrsS3X31bH5sly9fLdXDRib5AnBog1ivzlEI7dfSxuHOr le+fX1OobfmRz08cWD13rQxDs9U0RvHtbLyCx3541N+oa/YjwDubyw1T3EhgXyCY9x RD9TrRsd3ZDvBsYRWrYnHLd2xBW9WwWQbEJLPtCANMY6KAluBoXOWdXKr/SRGVZg49 dVgvZE43UCYzV+cVIChVvEvSzCt/9nnJebpi1IZIr6EKn3Y2s6tWvBC8/KdaslCeqm TGo0Re6ei+/gg== Received: from localhost (unknown [86.120.21.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 4EC0317E0E6E; Sat, 30 Nov 2024 01:00:31 +0100 (CET) From: Cristian Ciocaltea Date: Sat, 30 Nov 2024 01:56:33 +0200 Subject: [PATCH 2/3] drm/connector: hdmi: Add support for YUV420 format verification MIME-Version: 1.0 Message-Id: <20241130-hdmi-conn-yuv-v1-2-254279a08671@collabora.com> References: <20241130-hdmi-conn-yuv-v1-0-254279a08671@collabora.com> In-Reply-To: <20241130-hdmi-conn-yuv-v1-0-254279a08671@collabora.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: kernel@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Provide the necessary constraints verification in sink_supports_format_bpc() in order to support handling of YUV420 output format. Signed-off-by: Cristian Ciocaltea --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 40 +++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index 0cbcee7e77cd8dff387044487ce28ee5748f5587..3a55881a544a519bb1254968db891c814f831a0f 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -114,6 +115,12 @@ sink_supports_format_bpc(const struct drm_connector *connector, return false; } + if (drm_mode_is_420_only(info, mode) && format != HDMI_COLORSPACE_YUV420) { + drm_dbg_kms(dev, "%s format unsupported by the sink for VIC%u.\n", + drm_hdmi_connector_get_output_format_name(format), vic); + return false; + } + switch (format) { case HDMI_COLORSPACE_RGB: drm_dbg_kms(dev, "RGB Format, checking the constraints.\n"); @@ -144,9 +151,36 @@ sink_supports_format_bpc(const struct drm_connector *connector, return true; case HDMI_COLORSPACE_YUV420: - /* TODO: YUV420 is unsupported at the moment. */ - drm_dbg_kms(dev, "YUV420 format isn't supported yet.\n"); - return false; + drm_dbg_kms(dev, "YUV420 format, checking the constraints.\n"); + + if (!(info->color_formats & DRM_COLOR_FORMAT_YCBCR420)) { + drm_dbg_kms(dev, "Sink doesn't support YUV420.\n"); + return false; + } + + if (!drm_mode_is_420(info, mode)) { + drm_dbg_kms(dev, "Sink doesn't support YUV420 for VIC%u.\n", vic); + return false; + } + + if (bpc == 10 && !(info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_30)) { + drm_dbg_kms(dev, "10 BPC but sink doesn't support Deep Color 30.\n"); + return false; + } + + if (bpc == 12 && !(info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_36)) { + drm_dbg_kms(dev, "12 BPC but sink doesn't support Deep Color 36.\n"); + return false; + } + + if (bpc == 16 && !(info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_48)) { + drm_dbg_kms(dev, "16 BPC but sink doesn't support Deep Color 48.\n"); + return false; + } + + drm_dbg_kms(dev, "YUV420 format supported in that configuration.\n"); + + return true; case HDMI_COLORSPACE_YUV422: drm_dbg_kms(dev, "YUV422 format, checking the constraints.\n"); From patchwork Fri Nov 29 23:56:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13889012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BC94D735E6 for ; Sat, 30 Nov 2024 00:00:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C701810E377; Sat, 30 Nov 2024 00:00:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="ai6A+FCH"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id C41A910E36E for ; Sat, 30 Nov 2024 00:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1732924832; bh=puJiKU+qLxiAvpxZBNmrz9798z4jRJgq+rbdWEWlURU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ai6A+FCHL8CfariIHFrOaOu1ecbTsrjMIEhhYn/PlnUXJrGiJoGV3e/6KePfTRcPu /gkV31HceLDNURxqbaMnKXjkmn94UtaefP/IEsC+4pNwLz9R+ik3TL2dlQVUhfugVX 9CaDEUIg1bG7iuj8Ff/ieRQ+mT55QHfYvEgf6qs7TAJ5weOiaM7tpLa6DyTKpTGDDH fZUhiiRWOQtj+sK24tDxvgt5RZNRBQLlqZMD66msRo1cEvMfCCeD2WJVH6UkZ+5esg WSon9HOhYxok7Ej7KbUjIXOh3s7J/HFxs5agnEqT4+XQqiA/90j8w4gFgy8PkzxNgS fIVDXA4qEF+bw== Received: from localhost (unknown [86.120.21.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 1749A17E0E88; Sat, 30 Nov 2024 01:00:32 +0100 (CET) From: Cristian Ciocaltea Date: Sat, 30 Nov 2024 01:56:34 +0200 Subject: [PATCH 3/3] drm/connector: hdmi: Use YUV420 output format as an RGB fallback MIME-Version: 1.0 Message-Id: <20241130-hdmi-conn-yuv-v1-3-254279a08671@collabora.com> References: <20241130-hdmi-conn-yuv-v1-0-254279a08671@collabora.com> In-Reply-To: <20241130-hdmi-conn-yuv-v1-0-254279a08671@collabora.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: kernel@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce the switch to YUV420 when computing the best output format and RGB cannot be supported for a given color depth. While at it, add a minor improvement to the debug message indicating the supported format. Signed-off-by: Cristian Ciocaltea --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index 3a55881a544a519bb1254968db891c814f831a0f..b4e865e0680f35fd2d849536789f6c1f98a48258 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -304,7 +304,7 @@ hdmi_try_format_bpc(const struct drm_connector *connector, return false; } - drm_dbg_kms(dev, "%s output format supported with %u (TMDS char rate: %llu Hz)\n", + drm_dbg_kms(dev, "%s output format supported with %u bpc (TMDS char rate: %llu Hz)\n", drm_hdmi_connector_get_output_format_name(fmt), bpc, conn_state->hdmi.tmds_char_rate); @@ -319,15 +319,16 @@ hdmi_compute_format(const struct drm_connector *connector, { struct drm_device *dev = connector->dev; - /* - * TODO: Add support for YCbCr420 output for HDMI 2.0 capable - * devices, for modes that only support YCbCr420. - */ if (hdmi_try_format_bpc(connector, conn_state, mode, bpc, HDMI_COLORSPACE_RGB)) { conn_state->hdmi.output_format = HDMI_COLORSPACE_RGB; return 0; } + if (hdmi_try_format_bpc(connector, conn_state, mode, bpc, HDMI_COLORSPACE_YUV420)) { + conn_state->hdmi.output_format = HDMI_COLORSPACE_YUV420; + return 0; + } + drm_dbg_kms(dev, "Failed. No Format Supported for that bpc count.\n"); return -EINVAL;