Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2066977lqb; Mon, 27 May 2024 06:59:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5XNl50R8bRIcuqDBuj0LOcE58V7iZlvzSQaPx+YXqKcrcEKr1zZ0TkDCuhjaa5IgFzOvpabUp3xpM0w6c3WT8hD10lZRX/wkBcqsXbA== X-Google-Smtp-Source: AGHT+IHBS+BnNkaxrVNZ7Z4LJO8NarqnBmmqM+elRlHbodnOAN3gOq4mLlTsvwzs1rzhYydDVbiw X-Received: by 2002:a05:6808:2895:b0:3c7:a5f:8d2 with SMTP id 5614622812f47-3d1a745ce9bmr9622547b6e.45.1716818381296; Mon, 27 May 2024 06:59:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716818381; cv=pass; d=google.com; s=arc-20160816; b=a6lBFJzr9jsb8BRdw9ET1c5MuNVCMHonm3neoqumQFO2hCsHuHY0p3kus/+NG0zlxk dNAKFu4BdUCVihH25oEZUWOfrG3DFnCyqSQNB3wLQriGwpD7B4Es8m13+5zms6EQs/eq nwUmNTK5OUCmWnaMrPMKZUguB9oIVyJsK+l2nOBj/ecYFfmWTzlE4ZpiGMyOe6ZXlfb2 Sl71YCC8vJVRZ6bLjeNTOfFMSN90XLn0aCuZ0iMXmqhmkc3VO+Z+mf7PkTpyhH8Yii1x VMJqmi5Rll6Ur6AOVQ7045zXInfkAI9OXFss+JLUDHdWmCOLE/aeG+7cyLNbsUprxO2X dKxw== 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=jVPd5qqaTH4sKK2IUQ1bj0gSf172nXslEIdpPEzsMGs=; fh=Rmvm45DLBttDXPZ7ZQBINOOM6/ese2BHFaa7wD2L3jc=; b=zY6L23NBKn2bXtzCOx/4y6uUaIwlH9571ShNIlo2APcXJ5ovwoKo+dEeOFF36vvV47 jSMHOcQ7VL6MuqccNCsMCHBr/V0hopgNqvxJFZofoBzSLSq3SUMEeP2gDGbgDWZi8lhV w11spHU7gwYUSXr72MYRUyvSJor1u17jkgHxxsiqhg0PBTKVs10vQYc/sAnIvDinr1Cj sXMvMC5IjdD3RG7dMtGGQz0DsxiQ60q1+oMo7jejv4dJFwNHASUHMs3a5DmV6Kz1NN7M qRtcGNCaNRKRFZBsisTJPHfkYF7bJeX/Cj9pcg4/fgePMzQwHo4/M0Dlz6Wvj6fTMyvT 51+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KswPnBSh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190766-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190766-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-43fb18a8346si80541831cf.265.2024.05.27.06.59.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 06:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190766-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=KswPnBSh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190766-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190766-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 ED2411C20BAE for ; Mon, 27 May 2024 13:59:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD4C615FCE2; Mon, 27 May 2024 13:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KswPnBSh" 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 80FE815FA7F; Mon, 27 May 2024 13:58:20 +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=1716818300; cv=none; b=ZmNUvccPtrVIpy2iudGuPITY9syB1tO65BrVdXoWymTwPWECIzwZTtAQyeCiuRC/UfZke2dOaTETVH34lFU87Os2efJadOHncJ48ti54PCaQjDw7XY9u/29MZRLjI5ZzChingWWG3MZptbxwMLMc+kZG4NA7oCA9hnrWzCX0XVU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716818300; c=relaxed/simple; bh=+4AzKiyqAeO2P4pZZ0g8gEGGU0uN3S9W/yTh2M+2RBQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qXJHsH3EFhSGrC7xLKxDItJa0rV6PmU08ILy31l0Y9cnwD5MfoOOZpl9CLUzrhblMr/yJEK8bbP1SrYlUPTMPunq0bOgfHSSYM9YwNO22vBZNISpSJDX/DWorJggCJ9yDtVhxJw6QMTjXJJ54cSQ3jO0c8aypLVy9D4rqxDOU2s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KswPnBSh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 958B0C32781; Mon, 27 May 2024 13:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716818300; bh=+4AzKiyqAeO2P4pZZ0g8gEGGU0uN3S9W/yTh2M+2RBQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KswPnBShwfR4f80ulS2cCKEU6988qCfChlPRg6meSO0wToqfsZdzbiRE6DT1pBV+M DXBprmq53iL8FwcVBlSSJgRlSZoQJEowx0Rd7qmDu5cIoro9g6bAqnHxPW2fR5ntr4 5bUPXckH6j01RCxgAx79Jy8ZtrENyu2X/4+SW0Nmi2TPBKUK7q74iidXI4LZP4Vqez JhEfF2ra3cC7nFlGDs15GmdCGgcsFPvrk/0Wf8y+lvLJ6KhgfJ8Uwl+8r7mVrwjNoB NLCIOkOgW6IkDBrCjnb3ksCYFu4wcK0iFeR7V/ZKk5F2lVN26NtVzB9Ai2fLMLqg8a JV6wLWBtOkE0g== From: Maxime Ripard Date: Mon, 27 May 2024 15:57:53 +0200 Subject: [PATCH v15 04/29] drm/connector: hdmi: Add output BPC 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: <20240527-kms-hdmi-connector-state-v15-4-c5af16c3aae2@kernel.org> References: <20240527-kms-hdmi-connector-state-v15-0-c5af16c3aae2@kernel.org> In-Reply-To: <20240527-kms-hdmi-connector-state-v15-0-c5af16c3aae2@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 , Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9019; i=mripard@kernel.org; h=from:subject:message-id; bh=+4AzKiyqAeO2P4pZZ0g8gEGGU0uN3S9W/yTh2M+2RBQ=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGkhExMnz6hMKK2bqTSt1TNQkuewaK6/Q6nU1M+h1gql3 0I6k7Z3TGVhEOZkkBVTZHkiE3Z6efviKgf7lT9g5rAygQxh4OIUgIkIzmBsmBf/ZzHDtabfb025 P5kqa/x4EjDlxrLCud/OBPXdPj2rKzrdojTnve1VhsI9fZFSIhJbGBue1yWZn1EW9lXWkbrjpzx d/ss2gcMfJFf0TuU4VW5t9+3a+uxUqzPqq3mtgwPLbiX79QAA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D We'll add automatic selection of the output BPC in a following patch, but let's add it to the HDMI connector state already. Reviewed-by: Dave Stevenson Reviewed-by: Dmitry Baryshkov Signed-off-by: Maxime Ripard --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 20 ++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 5 +++++ drivers/gpu/drm/drm_connector.c | 20 +++++++++++++++++++- drivers/gpu/drm/tests/drm_connector_test.c | 12 ++++++++---- include/drm/drm_connector.h | 12 +++++++++++- 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index 1e92c1108d23..82293d93b5f8 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -16,10 +16,14 @@ * drm_atomic_helper_connector_reset(). */ void __drm_atomic_helper_connector_hdmi_reset(struct drm_connector *connector, struct drm_connector_state *new_conn_state) { + unsigned int max_bpc = connector->max_bpc; + + new_conn_state->max_bpc = max_bpc; + new_conn_state->max_requested_bpc = max_bpc; } EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset); /** * drm_atomic_helper_connector_hdmi_check() - Helper to check HDMI connector atomic state @@ -34,8 +38,24 @@ EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset); * Zero on success, or an errno code otherwise. */ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, struct drm_atomic_state *state) { + struct drm_connector_state *old_conn_state = + drm_atomic_get_old_connector_state(state, connector); + struct drm_connector_state *new_conn_state = + drm_atomic_get_new_connector_state(state, connector); + + if (old_conn_state->hdmi.output_bpc != new_conn_state->hdmi.output_bpc) { + struct drm_crtc *crtc = new_conn_state->crtc; + struct drm_crtc_state *crtc_state; + + crtc_state = drm_atomic_get_crtc_state(state, crtc); + if (IS_ERR(crtc_state)) + return PTR_ERR(crtc_state); + + crtc_state->mode_changed = true; + } + return 0; } EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check); diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index a91737adf8e7..4e11cfb4518b 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1141,10 +1141,15 @@ static void drm_atomic_connector_print_state(struct drm_printer *p, drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)"); drm_printf(p, "\tself_refresh_aware=%d\n", state->self_refresh_aware); drm_printf(p, "\tmax_requested_bpc=%d\n", state->max_requested_bpc); drm_printf(p, "\tcolorspace=%s\n", drm_get_colorspace_name(state->colorspace)); + if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || + connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { + drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc); + } + if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) if (state->writeback_job && state->writeback_job->fb) drm_printf(p, "\tfb=%d\n", state->writeback_job->fb->base.id); if (connector->funcs->atomic_print_state) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index d9961cce8245..da51a2bcb978 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -457,10 +457,11 @@ EXPORT_SYMBOL(drmm_connector_init); * @dev: DRM device * @connector: A pointer to the HDMI connector to init * @funcs: callbacks for this connector * @connector_type: user visible type of the connector * @ddc: optional pointer to the associated ddc adapter + * @max_bpc: Maximum bits per char the HDMI connector supports * * Initialises a preallocated HDMI connector. Connectors can be * subclassed as part of driver connector objects. * * Cleanup is automatically handled with a call to @@ -473,22 +474,39 @@ EXPORT_SYMBOL(drmm_connector_init); */ int drmm_connector_hdmi_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type, - struct i2c_adapter *ddc) + struct i2c_adapter *ddc, + unsigned int max_bpc) { int ret; if (!(connector_type == DRM_MODE_CONNECTOR_HDMIA || connector_type == DRM_MODE_CONNECTOR_HDMIB)) return -EINVAL; + if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12)) + return -EINVAL; + ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); if (ret) return ret; + /* + * drm_connector_attach_max_bpc_property() requires the + * connector to have a state. + */ + if (connector->funcs->reset) + connector->funcs->reset(connector); + + drm_connector_attach_max_bpc_property(connector, 8, max_bpc); + connector->max_bpc = max_bpc; + + if (max_bpc > 8) + drm_connector_attach_hdr_output_metadata_property(connector); + return 0; } EXPORT_SYMBOL(drmm_connector_hdmi_init); /** diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c index 261d4109946d..2661eb64a5cd 100644 --- a/drivers/gpu/drm/tests/drm_connector_test.c +++ b/drivers/gpu/drm/tests/drm_connector_test.c @@ -182,11 +182,12 @@ static void drm_test_connector_hdmi_init_valid(struct kunit *test) int ret; ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, &dummy_funcs, DRM_MODE_CONNECTOR_HDMIA, - &priv->ddc); + &priv->ddc, + 8); KUNIT_EXPECT_EQ(test, ret, 0); } /* * Test that the registration of a connector without a DDC adapter @@ -198,11 +199,12 @@ static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test) int ret; ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, &dummy_funcs, DRM_MODE_CONNECTOR_HDMIA, - NULL); + NULL, + 8); KUNIT_EXPECT_EQ(test, ret, 0); } /* * Test that the registration of an HDMI connector with an HDMI @@ -215,11 +217,12 @@ static void drm_test_connector_hdmi_init_type_valid(struct kunit *test) int ret; ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, &dummy_funcs, connector_type, - &priv->ddc); + &priv->ddc, + 8); KUNIT_EXPECT_EQ(test, ret, 0); } static const unsigned int drm_connector_hdmi_init_type_valid_tests[] = { DRM_MODE_CONNECTOR_HDMIA, @@ -246,11 +249,12 @@ static void drm_test_connector_hdmi_init_type_invalid(struct kunit *test) int ret; ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, &dummy_funcs, connector_type, - &priv->ddc); + &priv->ddc, + 8); KUNIT_EXPECT_LT(test, ret, 0); } static const unsigned int drm_connector_hdmi_init_type_invalid_tests[] = { DRM_MODE_CONNECTOR_Unknown, diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 000a2a156619..d4d2ae15bc1e 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1035,10 +1035,14 @@ struct drm_connector_state { /** * @hdmi: HDMI-related variable and properties. Filled by * @drm_atomic_helper_connector_hdmi_check(). */ struct { + /** + * @output_bpc: Bits per color channel to output. + */ + unsigned int output_bpc; } hdmi; }; /** * struct drm_connector_funcs - control connectors on a given device @@ -1680,10 +1684,15 @@ struct drm_connector { * DRM blob property data for the DP MST path property. This should only * be updated by calling drm_connector_set_path_property(). */ struct drm_property_blob *path_blob_ptr; + /** + * @max_bpc: Maximum bits per color channel the connector supports. + */ + unsigned int max_bpc; + /** * @max_bpc_property: Default connector property for the max bpc to be * driven out of the connector. */ struct drm_property *max_bpc_property; @@ -1913,11 +1922,12 @@ int drmm_connector_init(struct drm_device *dev, struct i2c_adapter *ddc); int drmm_connector_hdmi_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type, - struct i2c_adapter *ddc); + struct i2c_adapter *ddc, + unsigned int max_bpc); void drm_connector_attach_edid_property(struct drm_connector *connector); int drm_connector_register(struct drm_connector *connector); void drm_connector_unregister(struct drm_connector *connector); int drm_connector_attach_encoder(struct drm_connector *connector, struct drm_encoder *encoder); -- 2.45.0