Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2981851lqo; Tue, 21 May 2024 03:20:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDfLjW09yYtrtwil75tNPJ5g+wIyf4Lyoc+lXK27j8rZkj/19fuJbdD09gkjtDyjrMH8Jd3Uv01/DuM4AhB6hJz2MSIomCbA1F+4bZQA== X-Google-Smtp-Source: AGHT+IG9DqQIszyn4XqGNodvBWPcSaXNIIZf10SNHe8jxutBpt/duL0DowWcUhmEuybUaz0mAC0E X-Received: by 2002:a05:622a:314:b0:43d:fd4e:b893 with SMTP id d75a77b69052e-43dfdb81c06mr341791721cf.45.1716286805431; Tue, 21 May 2024 03:20:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716286805; cv=pass; d=google.com; s=arc-20160816; b=R4lj04KJY558aOn8uujcQkO8LAdUNyp2ExQetMorLv2db7BgKkMFlGwHlYWkOMsfwV EVNJhIqPp8hk0dlpgjDmzVpfyZs9YUxLjpd6zS6nnj30spxH+JKRLGLTs2GKutuMipQp HBzGPaFiR99MceFJiglN6+D75z8bAwkZC3gW6FhhKgiWmcAsZdGC588YA7eSEUdbwL3D iG7fcYzidR1SX76sTe4oWjDIiMLtzqwPfnW20MfIm1bgt6q8XEJwmJLQYWcz2XzHxy/t +LOQfK7POi5XLrofzh4Qp2UAzxyegbl5IknMlQqODAhniPGwVHvjk9bghLsebqzvBgfN F7ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=XYW1tRVf4anhVO27J5VPhM//O7MCS8RqD5NE0mlheqw=; fh=ufmwd8Wo0DI+kdMOJWC7ZXqsyLxoMBbO0En/E/GApYU=; b=ulFRUFsOw+jX7zRYAGL3VMJGZjpYiKd7AtTcRCpp4fk+CEyuEcB9yD3PxEMRGruS2C M1Zn/R/zqybTDn3hHNRBniSfTfwTZ2CzZkfbSN/kFspdxQ1gIawe6Q4J8RCh81YgnZZY bzIlKDW8JSL8hJwT472VOPhgnphz6XVjxZIrJWnaFKTL3+prWSjEJBCarsudq0FJEWii Vs1JuvayyZX2HebOSxHqdFBDDSuM2ZbPGVp971c8dFPhFRug84Ltp+je5z3wpiXTDb7n gLXSb3chRb0c8QWmYf5ElaNdmhD0SFQFtienjAmQXL0hdvuBZOzyExO6fwjF3Mq7lMNb UR8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mB+28NTy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df56dcd13si17093831cf.733.2024.05.21.03.20.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 03:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mB+28NTy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1F41C1C20F7D for ; Tue, 21 May 2024 10:20:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF7C2811E2; Tue, 21 May 2024 10:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mB+28NTy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B63EA80BEE; Tue, 21 May 2024 10:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716286485; cv=none; b=K/Fh13IykfGzMvMte0EW2KbgsAzLiHo/3KwXdyq1DE8WlbkZzql9S67B0MgnGQtU9Hdi7bJGkgIag31Oj5CQPUBK1g9qj0SOouJpqQPQy/R7RxEdbsyVIfmYgOt7Eno2rWcfn3jkt3HJTHrflvyg3UTVcjXrPxaTxhVLiDsrU0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716286485; c=relaxed/simple; bh=bsZaRioTo9P24nTqtdpewb+sUdl+aKP/eKsU7k4I+FA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M3x7U65UIrr4mpns5TLz6vMuAB6dfa55tO/am1ltPTMIKyFO2yJpxYlf1N0MxcgqclB5XVokZGGK9hdfE3AqNCJKPtBBuZR1Xd46DBb7NmKjdcAs9rZ6v84sBHpOtVXGbmWa8y1bvddr/qOf2sAk8q91ccbXhAJQdpev1h9AwE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mB+28NTy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFD12C2BD11; Tue, 21 May 2024 10:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716286485; bh=bsZaRioTo9P24nTqtdpewb+sUdl+aKP/eKsU7k4I+FA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mB+28NTy4yAEFfKkHMoI78werRfG4TGAcXcKySiJXotaaj0WkG4rVy+Ck83mfZvHF tZE1+ui52ec0WDffDkmkLQg3dC9/EXO5moIdTwP+RWAHTAG/R+l9uQa3rFt+v+aHW1 ok9M9FHGSJwCZnxyYyugwcS3sx+fj/kjpdWnLlu1KzvNtQ4Lr/RS2J+t/plFV+bDKD YBPBXcDPbMQU1m7cLGrZVIaRVtzb+BCVuEkL4Y4s8MQVmONaVxuwVCmSYkG8NXeOaW 3eReQy6RnXAlf364UbWwC1gFqIYBgzW38RiEyWifT3MtbM3f7sF32BRy12jlbSxsVF DeUmKCpZ/GclQ== From: Maxime Ripard Date: Tue, 21 May 2024 12:13:52 +0200 Subject: [PATCH v14 19/28] drm/connector: hdmi: Add RGB Quantization Range to the connector state Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240521-kms-hdmi-connector-state-v14-19-51950db4fedb@kernel.org> References: <20240521-kms-hdmi-connector-state-v14-0-51950db4fedb@kernel.org> In-Reply-To: <20240521-kms-hdmi-connector-state-v14-0-51950db4fedb@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andy Yan Cc: Hans Verkuil , Sebastian Wick , =?utf-8?q?Ville_Syrj=C3=A4l=C3=A4?= , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard , Dave Stevenson X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4100; i=mripard@kernel.org; h=from:subject:message-id; bh=bsZaRioTo9P24nTqtdpewb+sUdl+aKP/eKsU7k4I+FA=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGk+xTdLvmxsLdnSe/WB8scV17guN53bOOGHTOau1NVti 04dPvHmScdUFgZhTgZZMUWWJzJhp5e3L65ysF/5A2YOKxPIEAYuTgGYSOsuxvoyY2VJl7aFK6fn TrqbVGJtv2pJyr7tr6q+pk21MlnONoO58f6v+jdz7nc/Zns1RaVJ6z5jw+VCk4XRvt7uBU/51p2 23BC3eJaR02PBXQkKPRL5PzTKLkTw1GUbxO26sfH2O98k/ivqAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D HDMI controller drivers will need to figure out the RGB range they need to configure based on a mode and property values. Let's expose that in the HDMI connector state so drivers can just use that value. Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 29 +++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 1 + include/drm/drm_connector.h | 6 +++++ 3 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index 888fe1fe9594..6d30c47fca65 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -49,10 +49,37 @@ connector_state_get_mode(const struct drm_connector_state *conn_state) return NULL; return &crtc_state->mode; } +static bool hdmi_is_limited_range(const struct drm_connector *connector, + const struct drm_connector_state *conn_state) +{ + const struct drm_display_info *info = &connector->display_info; + const struct drm_display_mode *mode = + connector_state_get_mode(conn_state); + + /* + * The Broadcast RGB property only applies to RGB format, and + * i915 just assumes limited range for YCbCr output, so let's + * just do the same. + */ + if (conn_state->hdmi.output_format != HDMI_COLORSPACE_RGB) + return true; + + if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_FULL) + return false; + + if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) + return true; + + if (!info->is_hdmi) + return false; + + return drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED; +} + static bool sink_supports_format_bpc(const struct drm_connector *connector, const struct drm_display_info *info, const struct drm_display_mode *mode, unsigned int format, unsigned int bpc) @@ -315,10 +342,12 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, drm_atomic_get_new_connector_state(state, connector); const struct drm_display_mode *mode = 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; if (old_conn_state->hdmi.broadcast_rgb != new_conn_state->hdmi.broadcast_rgb || diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3e57d98d8418..07b4b394e3bf 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1145,10 +1145,11 @@ static void drm_atomic_connector_print_state(struct drm_printer *p, if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { drm_printf(p, "\tbroadcast_rgb=%s\n", drm_hdmi_connector_get_broadcast_rgb_name(state->hdmi.broadcast_rgb)); + drm_printf(p, "\tis_limited_range=%c\n", state->hdmi.is_limited_range ? 'y' : 'n'); drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc); drm_printf(p, "\toutput_format=%s\n", drm_hdmi_connector_get_output_format_name(state->hdmi.output_format)); drm_printf(p, "\ttmds_char_rate=%llu\n", state->hdmi.tmds_char_rate); } diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index a40eaf3a8ce4..1fca26d51218 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1068,10 +1068,16 @@ struct drm_connector_state { * @broadcast_rgb: Connector property to pass the * Broadcast RGB selection value. */ enum drm_hdmi_broadcast_rgb broadcast_rgb; + /** + * @is_full_range: Is the output supposed to use a full + * RGB Quantization Range or not? + */ + bool is_limited_range; + /** * @output_bpc: Bits per color channel to output. */ unsigned int output_bpc; -- 2.45.0