From patchwork Thu Feb 22 18:14:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 204967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp128569dyb; Thu, 22 Feb 2024 10:27:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3S3M2BTHAAnYGoyegmnJayGFy0hz4XOeWuah3BT0aAh4JqmYGMRtXLNcfN0+5bnLhbTVmFf9HgB6ei8qqHjFALsxKgA== X-Google-Smtp-Source: AGHT+IGWDj4jozw5/pzt8HwFXpWGw7d0lI126fx+YUPDrr/YbBGuF2c/VDLNpEE51hnv1SfH3oeX X-Received: by 2002:a67:fc58:0:b0:470:4e67:3b38 with SMTP id p24-20020a67fc58000000b004704e673b38mr14727171vsq.14.1708626441927; Thu, 22 Feb 2024 10:27:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708626441; cv=pass; d=google.com; s=arc-20160816; b=TV4nEIfRVOMj/rB1KRGUa6rQiSamPrI+FYAchymziZWD+HCzet1DRt7bL11ZrEU5nL oHaltqtX7aSqia7zjRYpSFcq69hz7mbl2KKJuQ1HESk2FN++z2vC25V6C7opGCliBfnF nV2qwGmDvt1foyRbHSaziGpHQzZ1a6+ropOpytemAhNSewqh4oRxbANaX30UpLLt+jvD 3KsYaCgT2ea8TGwk6VZrUTicV0J/NtemdMP1EdEdcthcI1sSm4w8bfJv1n3hhuTMma13 kTDX6RkdNZv2BnewIAYSbHnd0hTPqiVv776JaD3j+UZAIiofZIxHYjYL2uPSEkw5UxY5 6wvQ== 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=OtP/yhynBf24PtYb1Fz/R2A7ZkG4Dlj3xglDToGp4vI=; fh=8wcoxKk21hICD+6obVirG13fsSSMhKa/pufykSf87d0=; b=mWlH0fTyS/hOxEXTFgcaIE6UMq42Vi0+GabSxYBT7ybg0IDl+8tVIZmOvRIwaUS2vV K9wRKmkwibEXa6QmYmLMbgC3D8hq8NTVE+kBtq7G7XbgGae2cYKD4WsSojpJmVUaai6e 0at1BqNyWhnaRrUDf/Jcm/dC4tu1oi7c+0q5hQW2yW2TKppM5zLks8Y3G4EMzNTp+pCa qjtA7pdY+k2xvOCvvhV0qI+bRYVexJHUpgzM8by0ic+ROp1i5VofvcKoD6C9v1xcxKoO 5d5hVxuSeiLD1oJGD07X1Z6GjUM5ib0uLtv+jIP8+9IrjxYs8/pZnFyj4Gpzifc9oAMP CMMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kQs8PYuK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77101-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a19-20020a05610222d300b004707a5017d5si868249vsh.661.2024.02.22.10.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:27:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77101-ouuuleilei=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=kQs8PYuK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77101-ouuuleilei=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 AC0861C20E62 for ; Thu, 22 Feb 2024 18:27:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A9871448D4; Thu, 22 Feb 2024 18:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kQs8PYuK" 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 5FAAE143C61; Thu, 22 Feb 2024 18:15:33 +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=1708625733; cv=none; b=bLkDclKO+92TFSxzvu+jaHLFOqwd1RsRW9uO2if2GIkaGVDga1S6R2tcEAWCe8Qr0ZX8/sa3jmXbXcPSnN3y/8JvNIDoAFFDQvoqGhhBdrY/9Ds4l402BuqIQrPof7coRNxy5yEim4S2kkdXJTlbrCuJ3UN2+Ce7kNmfa9gP8Dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708625733; c=relaxed/simple; bh=1I2pPlxI3vCCE9moTWhTTQHMRZBIhOmA5gBHqcZ2PGQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nE3WXd0ljd8H0uNqLO0h5zhCdKvIO/AEo3+78UcGYHzgoUnqMv2FF6WdUbHxkEHwKbiXHSDg8PxdypLuL/wc5onc6yYTqa1DS/2SEQg5MzutAq42J37ablxHWaNyhjjzeORT7tCd4xUFrN1mZFQVDMMHB08klpzYcXH1RmwjF6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kQs8PYuK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88EF0C433F1; Thu, 22 Feb 2024 18:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708625732; bh=1I2pPlxI3vCCE9moTWhTTQHMRZBIhOmA5gBHqcZ2PGQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kQs8PYuKf2BOoFOideBCM2lSWzNAzIt4JW4S48egW54sW8bSaH7i+HoZ3sw7JXLzR oVNrchSGET6wc+/X1s2PU0aHysK3vuvBBStPoOqx8VJjxkollvwLGOb2hgF3t0AQ2+ kgCzosB3yrbGBlz8RkNUx8sMgvxSOYrf0RCKdyrEtf49sSprjerDXV0HLExiz4rmzs PDNVf18oA/TVuGDwvwsgFyTOJyB64H6uc6UElcGk5h5LPPgJ1pM0iKS+aB77dn/f7V rPwDdrHo6VQMiIhiRfZfLbqbbcr+Kc9npYUhSdD+N8498pVYjRCfY1cLne3XG1mWga f4GkNkUyiz9YQ== From: Maxime Ripard Date: Thu, 22 Feb 2024 19:14:09 +0100 Subject: [PATCH v7 23/36] 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 Message-Id: <20240222-kms-hdmi-connector-state-v7-23-8f4af575fce2@kernel.org> References: <20240222-kms-hdmi-connector-state-v7-0-8f4af575fce2@kernel.org> In-Reply-To: <20240222-kms-hdmi-connector-state-v7-0-8f4af575fce2@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 Cc: Hans Verkuil , Sebastian Wick , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , 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.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3455; i=mripard@kernel.org; h=from:subject:message-id; bh=1I2pPlxI3vCCE9moTWhTTQHMRZBIhOmA5gBHqcZ2PGQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKnX+77fEvb6/ly444irUtcEwZxFuzWexthlX7f0yPpzV 6CgSLazo5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABNp+snIsD+C52nM8eWRz4Mf FJm8/6j1zu+NgVUns52pr5x2z+tX2xn+eyWXlh3g/9lpeayQicN859aZrHk5n+qDow5XK3t2zmB lBQA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791624679767465831 X-GMAIL-MSGID: 1791624679767465831 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/drm_atomic.c | 1 + drivers/gpu/drm/drm_atomic_state_helper.c | 29 +++++++++++++++++++++++++++++ include/drm/drm_connector.h | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3e57d98d8418..ec6c6beda5c9 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1147,6 +1147,7 @@ static void drm_atomic_connector_print_state(struct drm_printer *p, 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_full_range=%c\n", state->hdmi.is_full_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)); diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 0e8fb653965a..e66272c0d006 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -664,6 +664,33 @@ connector_state_get_mode(const struct drm_connector_state *conn_state) return &crtc_state->mode; } +static bool hdmi_is_full_range(const struct drm_connector *connector, + const struct drm_connector_state *state) +{ + const struct drm_display_info *display = &connector->display_info; + const struct drm_display_mode *mode = + connector_state_get_mode(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 (state->hdmi.output_format != HDMI_COLORSPACE_RGB) + return false; + + if (state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_FULL) + return true; + + if (state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) + return false; + + if (!display->is_hdmi) + return true; + + return drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_FULL ? true : false; +} + static bool sink_supports_format_bpc(const struct drm_connector *connector, const struct drm_display_info *info, @@ -910,6 +937,8 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, connector_state_get_mode(new_state); int ret; + new_state->hdmi.is_full_range = hdmi_is_full_range(connector, new_state); + ret = hdmi_compute_config(connector, new_state, mode); if (ret) return ret; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index bb6b6a36ade3..3eaf4d54364d 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1070,6 +1070,12 @@ struct drm_connector_state { */ 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_full_range; + /** * @output_bpc: Bits per color channel to output. */