From: Xilin Wu <sophon@radxa.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Rob Clark <robin.clark@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Sean Paul <sean@poorly.run>,
Marijn Suijten <marijn.suijten@somainline.org>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
dragon@radxa.com, Xilin Wu <sophon@radxa.com>,
linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 01/20] drm/atomic: Handle max bpc properties before connector state allocation
Date: Fri, 09 Oct 2026 11:15:53 +0800 [thread overview]
Message-ID: <20261009-msm-dp-hdr10-v2-1-1835d4966da3@radxa.com> (raw)
In-Reply-To: <20261009-msm-dp-hdr10-v2-0-1835d4966da3@radxa.com>
Allow drivers to attach the max bpc property before allocating connector
state, as needed by the upcoming non-HDMI bridge connector support.
Only update the current state when one exists.
Initialize max_requested_bpc and max_bpc from the attached property default
when creating connector state. Use drm_object_property_get_default_value()
rather than the range maximum so that state creation and subsequent resets
restore the value chosen when attaching the property.
Cover deferred allocation, existing state and restoration of a default
that differs from the range maximum in the connector KUnit tests.
Assisted-by: LLM
Signed-off-by: Xilin Wu <sophon@radxa.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 8 +++++
drivers/gpu/drm/drm_connector.c | 6 ++--
drivers/gpu/drm/tests/drm_connector_test.c | 53 ++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index a2ef272e9f27..8352b5a9097a 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -494,7 +494,15 @@ void
__drm_atomic_helper_connector_state_init(struct drm_connector_state *conn_state,
struct drm_connector *connector)
{
+ u64 val;
+
conn_state->connector = connector;
+ if (connector->max_bpc_property &&
+ !drm_object_property_get_default_value(&connector->base,
+ connector->max_bpc_property, &val)) {
+ conn_state->max_requested_bpc = val;
+ conn_state->max_bpc = val;
+ }
}
EXPORT_SYMBOL(__drm_atomic_helper_connector_state_init);
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 8b4baed060f3..34c30469f405 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2886,8 +2886,10 @@ int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
}
drm_object_attach_property(&connector->base, prop, max);
- connector->state->max_requested_bpc = max;
- connector->state->max_bpc = max;
+ if (connector->state) {
+ connector->state->max_requested_bpc = max;
+ connector->state->max_bpc = max;
+ }
return 0;
}
diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
index beb1d50a6646..1174607441b9 100644
--- a/drivers/gpu/drm/tests/drm_connector_test.c
+++ b/drivers/gpu/drm/tests/drm_connector_test.c
@@ -12,6 +12,7 @@
#include <drm/drm_file.h>
#include <drm/drm_kunit_helpers.h>
#include <drm/drm_modes.h>
+#include <drm/drm_property.h>
#include <drm/display/drm_hdmi_helper.h>
@@ -187,7 +188,59 @@ KUNIT_ARRAY_PARAM(drm_connector_init_type_valid,
drm_connector_init_type_valid_tests,
drm_connector_init_type_desc);
+/* The attached default need not equal the upper end of the property range. */
+static void drm_test_connector_max_bpc_default(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ struct drm_connector *connector = &priv->connector;
+ struct drm_property *prop;
+ int ret;
+
+ ret = drmm_connector_init(&priv->drm, connector, &dummy_funcs,
+ DRM_MODE_CONNECTOR_DisplayPort, NULL);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ prop = drm_property_create_range(&priv->drm, 0, "max bpc", 6, 12);
+ KUNIT_ASSERT_NOT_NULL(test, prop);
+ connector->max_bpc_property = prop;
+ ret = drm_connector_attach_max_bpc_property(connector, 6, 10);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ KUNIT_EXPECT_NULL(test, connector->state);
+
+ drm_mode_config_reset(&priv->drm);
+ KUNIT_ASSERT_NOT_NULL(test, connector->state);
+ KUNIT_EXPECT_EQ(test, connector->state->max_requested_bpc, 10);
+ KUNIT_EXPECT_EQ(test, connector->state->max_bpc, 10);
+
+ connector->state->max_requested_bpc = 8;
+ connector->state->max_bpc = 8;
+ drm_mode_config_reset(&priv->drm);
+ KUNIT_ASSERT_NOT_NULL(test, connector->state);
+ KUNIT_EXPECT_EQ(test, connector->state->max_requested_bpc, 10);
+ KUNIT_EXPECT_EQ(test, connector->state->max_bpc, 10);
+}
+
+static void drm_test_connector_max_bpc_existing_state(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ struct drm_connector *connector = &priv->connector;
+ int ret;
+
+ ret = drmm_connector_init(&priv->drm, connector, &dummy_funcs,
+ DRM_MODE_CONNECTOR_DisplayPort, NULL);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ drm_mode_config_reset(&priv->drm);
+ KUNIT_ASSERT_NOT_NULL(test, connector->state);
+
+ ret = drm_connector_attach_max_bpc_property(connector, 6, 10);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, connector->state->max_requested_bpc, 10);
+ KUNIT_EXPECT_EQ(test, connector->state->max_bpc, 10);
+}
+
static struct kunit_case drmm_connector_init_tests[] = {
+ KUNIT_CASE(drm_test_connector_max_bpc_default),
+ KUNIT_CASE(drm_test_connector_max_bpc_existing_state),
KUNIT_CASE(drm_test_drmm_connector_init),
KUNIT_CASE(drm_test_drmm_connector_init_null_ddc),
KUNIT_CASE_PARAM(drm_test_drmm_connector_init_type_valid,
--
2.56.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-10-09 3:17 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 3:15 [PATCH v2 00/20] drm/msm/dp: Add static HDR support for DP and eDP Xilin Wu
2026-10-09 3:15 ` Xilin Wu [this message]
2026-10-10 2:48 ` [PATCH v2 01/20] drm/atomic: Handle max bpc properties before connector state allocation Chaoyi Chen
2026-10-12 12:33 ` Dmitry Baryshkov
2026-10-09 3:15 ` [PATCH v2 02/20] drm/connector: Drop early state allocation for max bpc registration Xilin Wu
2026-10-10 22:44 ` Martin Blumenstingl
2026-10-09 3:15 ` [PATCH v2 03/20] drm/bridge-connector: Attach max bpc for non-HDMI bridges Xilin Wu
2026-10-10 2:39 ` Chaoyi Chen
2026-10-12 12:40 ` Dmitry Baryshkov
2026-10-09 3:15 ` [PATCH v2 04/20] drm/msm/dp: Accept a const SDP header when packing Xilin Wu
2026-10-09 3:15 ` [PATCH v2 05/20] drm/msm/dp: Support multiple generic SDP slots Xilin Wu
2026-10-09 3:15 ` [PATCH v2 06/20] drm/msm/dp: Keep runtime PM calls outside the connection lock Xilin Wu
2026-10-09 3:37 ` sashiko-bot
2026-10-09 3:15 ` [PATCH v2 07/20] drm/msm/dp: Serialize stream operations with HPD processing Xilin Wu
2026-10-09 3:30 ` sashiko-bot
2026-10-12 12:48 ` Dmitry Baryshkov
2026-10-09 3:16 ` [PATCH v2 08/20] drm/msm/dp: Track PHY power ownership Xilin Wu
2026-10-09 3:16 ` [PATCH v2 09/20] drm/msm/dp: Unwind resources when enabling a stream fails Xilin Wu
2026-10-09 3:35 ` sashiko-bot
2026-10-09 3:16 ` [PATCH v2 10/20] drm/msm/dp: Report stream enable failures through link status Xilin Wu
2026-10-09 3:28 ` sashiko-bot
2026-10-09 3:16 ` [PATCH v2 11/20] drm/msm/dp: Cache eDP link capabilities after successful discovery Xilin Wu
2026-10-09 3:34 ` sashiko-bot
2026-10-30 4:29 ` Burke Cates
2026-10-09 3:16 ` [PATCH v2 12/20] drm/msm/dp: Rebuild the eDP stream on modesets leaving self refresh Xilin Wu
2026-10-09 3:16 ` [PATCH v2 13/20] drm/msm/dp: Track output bit depth in bridge atomic state Xilin Wu
2026-10-09 3:16 ` [PATCH v2 14/20] drm/msm/dp: Clear stale MSA colorimetry bits Xilin Wu
2026-10-12 8:00 ` Konrad Dybcio
2026-10-09 3:16 ` [PATCH v2 15/20] drm/msm/dp: Flush VSC updates when leaving YUV420 Xilin Wu
2026-10-12 14:09 ` Dmitry Baryshkov
2026-10-09 3:16 ` [PATCH v2 16/20] drm/msm/dp: Disable PSR for YUV420 streams Xilin Wu
2026-10-09 3:34 ` sashiko-bot
2026-10-12 14:36 ` Dmitry Baryshkov
2026-10-09 3:16 ` [PATCH v2 17/20] drm/msm/dp: Track VSC packets in bridge atomic state Xilin Wu
2026-10-09 3:34 ` sashiko-bot
2026-10-09 3:16 ` [PATCH v2 18/20] drm/msm/dp: Signal BT.2020 RGB on DP and eDP Xilin Wu
2026-10-12 14:48 ` Dmitry Baryshkov
2026-10-09 3:16 ` [PATCH v2 19/20] drm/msm/dp: Serialize video test state changes Xilin Wu
2026-10-09 3:44 ` sashiko-bot
2026-10-12 21:52 ` Dmitry Baryshkov
2026-10-09 3:16 ` [PATCH v2 20/20] drm/msm/dp: Add static HDR metadata support for DP and eDP Xilin Wu
2026-10-09 3:40 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261009-msm-dp-hdr10-v2-1-1835d4966da3@radxa.com \
--to=sophon@radxa.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dragon@radxa.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jbrunet@baylibre.com \
--cc=jernej.skrabec@gmail.com \
--cc=jesszhan0024@gmail.com \
--cc=jonas@kwiboo.se \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=lumag@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=marijn.suijten@somainline.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®