Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2856506lqt; Tue, 23 Apr 2024 03:58:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUoToZCfObmbmJ+NTr0ODK1ushCLZsWLlJ0tNJq9j5PjDd7+zUzKXRgsIuogEr6zYnRTaCYg+RSKyc+n9x/oT2Mdq082dyoz/46JibMEA== X-Google-Smtp-Source: AGHT+IGMCAoO0S0TmVbWG/nVCYEhuShIvoZc/x2tyRc3nzqg/gaVnTUIzsYSngXmIa+XEA6z6Ido X-Received: by 2002:a17:90b:3889:b0:2ae:7224:aaf8 with SMTP id mu9-20020a17090b388900b002ae7224aaf8mr2911082pjb.30.1713869910294; Tue, 23 Apr 2024 03:58:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713869910; cv=pass; d=google.com; s=arc-20160816; b=b9m27DNZmRvgJzY6hyfGHLfM9pfJzetj6k1reGg7bxv9mmdSXMlzEi2nOeOf4ZnREI RE9+thMiM3i0v2mcadHA4h2QQQHViW1wp6zSf/tV7O2BE9XrloPXYkQ/6X3L0sERVDIK KMrDgj/rxOtlAK1+4X7Mb7ERCII2/nxu+sYGmd7IsLotxIpLsLcqwFTK/jCDE11FGUqT jTtx76xUCV3ovAKw6pXSdlRPTHxUf69AlQmoBIzGsMimTF2AMwMuxyeIrjJsdLx8HQCf ZqIsGlnQZzngUwOxVP4j4C2FnHx5/EDLRJTiYcW/g8PSZFioIH7JjZ7pyQXaUHLJtFL1 TCoA== 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=BKdSCJA0dP4ZwwBo+YBHJQMuiBuQVTtGm04CGuwXErg=; fh=ufmwd8Wo0DI+kdMOJWC7ZXqsyLxoMBbO0En/E/GApYU=; b=JdjC62LAm9GzFJ12FxTTUGmOts5KQPrta2qYc6HkOFJMkWsSjMtIARWI8o8bVwXWFj 3dkgmwekLJFcJ0252nTBJzbN1EPDMznzLN7dtgAdR2l9ugOyuAVEAUiGjQ1ZLpMW72Ts 0y1E3Cvr2r6FcekOZaM6QWwJDlEty2RO3XAPcnhUePOmsJ4BDD/vdxIPYDsEL5cyZ/Lc 7bDZlv6XyTjUSkA6qFssOl5hFfaqoX7g/PchygleN+gFQqRloGMAp+y+KCrF9Fbxtk0q gN6+sf4KGNpAUVHneVmTOg5z5hkkpwbY6Mpd3epY+ROpVPdJhv449wjTTvxF74tvKRJX TRTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nc84L7Vl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x16-20020a17090aca1000b002a606004eb8si9557090pjt.114.2024.04.23.03.58.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 03:58:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nc84L7Vl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154911-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 88097284855 for ; Tue, 23 Apr 2024 10:51:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A680F137749; Tue, 23 Apr 2024 10:46:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nc84L7Vl" 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 9A3DF136E07; Tue, 23 Apr 2024 10:46:39 +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=1713869199; cv=none; b=btsU4k9D45qKu2vgcD5hBk5VjxH7KbygMqZ0WLUt3nqBH9TvaX5Bnr+4S9MSdmfnGCs9Q+W2LzgmsFuGn6AqD7iFVVYgUn97nKnR7Y2GIX9UpYkQWOOM2vjL77Onv9v0iIew9SZqhdPRH6Jl4K+qWsyk9vbdNnQPqFVN43GxFEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713869199; c=relaxed/simple; bh=qzfgVKbyx/ZW6EQh/njMwRTT7IngtuLEE0DO8Z6nLmY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NJJMmVsCHWKgdB+YYjgwPdN+niG/6uSh5cBjv8oZ5Ju+jGTdNcIrInMEsbuudkFq3YzP9Cw4fdeNObLiarv0TdSXjKjxu2vXOkLKq9YX4bU0hOEk0a3Eps0NKgySCrm2J9vXxak8BJxoWJP2UcEH9UuFNKchzUvpzwlqo3Q8sgg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nc84L7Vl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29DC4C3277B; Tue, 23 Apr 2024 10:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713869199; bh=qzfgVKbyx/ZW6EQh/njMwRTT7IngtuLEE0DO8Z6nLmY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Nc84L7Vlie4XE7EFg2aBGIbnv/s+ItZsOrlr0m+hqshd0pC8fDC+PVSJhW0dW6ZJT R6novmjtviPf+eOwmzY7xW/HYjad3/1e46JK3VpRF9hKFWGr1U9y/9kseLR128MQRc /eotbdZvivBTEZKfwkG1U/nj7e5m7clyUzDKCpuEvQMCiylqtjUo0tYww4K39B8yQR Nio5bsX0yR/MS/RDzcZwgT7O3r5rEmbHKJjrl7QMJy/T5qSZKkLfYKLpaofRkb9u9o niy4HrJAasTCPhVn+YFHkqAgxbbQLjqN9k9TFTIKGs0scVstZdYn+Jbbc+sAu/1MLf RNvcgydp65tUA== From: Maxime Ripard Date: Tue, 23 Apr 2024 12:45:48 +0200 Subject: [PATCH v12 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: <20240423-kms-hdmi-connector-state-v12-19-3338e4c0b189@kernel.org> References: <20240423-kms-hdmi-connector-state-v12-0-3338e4c0b189@kernel.org> In-Reply-To: <20240423-kms-hdmi-connector-state-v12-0-3338e4c0b189@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=qzfgVKbyx/ZW6EQh/njMwRTT7IngtuLEE0DO8Z6nLmY=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGnqE4MN5wsHvg2L5/h/2TRgpVf1QtNtXDZ/XRLsjb48d 2TdnHe2YyoLgzAng6yYIssTmbDTy9sXVznYr/wBM4eVCWQIAxenAEykVoWxYZo0h5Jo0oQG5t11 WzN1P9699DPyq/i2PdeVMp2eP1VzKJBqyo15d/vc429/XOTm3zgfzVgroRU8pcngTdOfFzwKOh+ 0d5d6xeer+Kp/yRdp6nzOJzwlVU7LZKnLldtz+5Kyqpq3qwMA 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 c844cbeb675b..6be3a7d9e0cc 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) @@ -307,10 +334,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.44.0