From: "Mario Limonciello (AMD)" <superm1@kernel.org>
To: Maxime Ripard <mripard@kernel.org>,
Alex Deucher <alexander.deucher@amd.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Javier Martinez Canillas <javierm@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Harry Wentland <harry.wentland@amd.com>,
Leo Li <sunpeng.li@amd.com>,
Rodrigo Siqueira <siqueira@igalia.com>
Cc: Mario Limonciello <superm1@kernel.org>,
Xaver Hugl <xaver.hugl@gmail.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org
Subject: [PATCH v10 05/15] drm/amd/display: update KUnit luminance fixtures
Date: Mon, 02 Nov 2026 10:49:21 -0600 [thread overview]
Message-ID: <20261102-superm1-backlight-property-v10-5-b2a6f24131f5@kernel.org> (raw)
In-Reply-To: <20261102-superm1-backlight-property-v10-0-b2a6f24131f5@kernel.org>
Initialize complete DRM connector state in backlight test fixtures so
the atomic LUMINANCE property can be attached. Check the optional
property and keep the ABM property expectations correct with either
interface selected.
Also initialize the display-manager lock and mode configuration needed
by the existing backlight registration test.
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
.../amdgpu_dm/tests/amdgpu_dm_backlight_test.c | 43 ++++++++++++++++++----
.../amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c | 7 +++-
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
index b21850788f36f..8883010e8af9c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
@@ -41,12 +41,21 @@ static void setup_test_connector(struct kunit *test,
struct dm_backlight_connector_fixture *fixture,
int bl_idx, enum signal_type signal)
{
- fixture->adev = kunit_kzalloc(test, sizeof(*fixture->adev), GFP_KERNEL);
- fixture->aconnector = kunit_kzalloc(test, sizeof(*fixture->aconnector), GFP_KERNEL);
+ int ret;
+
+ fixture->adev = dm_kunit_alloc_adev(test);
+ ret = drmm_mode_config_init(&fixture->adev->ddev);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ fixture->aconnector = dm_kunit_alloc_connector(test, fixture->adev, NULL);
fixture->link = kunit_kzalloc(test, sizeof(*fixture->link), GFP_KERNEL);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fixture->adev);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fixture->aconnector);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fixture->link);
+ ret = drmm_connector_init(&fixture->adev->ddev,
+ &fixture->aconnector->base,
+ &dm_backlight_test_connector_funcs,
+ DRM_MODE_CONNECTOR_eDP, NULL);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ drm_atomic_helper_connector_reset(&fixture->aconnector->base);
fixture->aconnector->bl_idx = bl_idx;
fixture->aconnector->dc_link = fixture->link;
@@ -483,12 +492,17 @@ static void dm_test_register_backlight_device_success(struct kunit *test)
struct dc_link *link = dm_kunit_alloc_link(test);
struct drm_minor *primary;
unsigned int max;
+ int ret;
+
+ ret = drmm_mode_config_init(&adev->ddev);
+ KUNIT_ASSERT_EQ(test, ret, 0);
setup_test_link_service(test, link);
link->dc->link_srv->edp_get_backlight_level = dm_test_get_backlight_level_error;
primary = kunit_kzalloc(test, sizeof(*primary), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, primary);
adev->ddev.primary = primary;
+ adev->dm.ddev = &adev->ddev;
adev->dm.backlight_link[0] = link;
aconnector = dm_kunit_alloc_connector(test, adev, link);
@@ -1872,6 +1886,7 @@ static void dm_test_setup_backlight_device_attaches_abm_property(struct kunit *t
struct dc_link *link;
int saved_abm_level = amdgpu_dm_get_abm_level_param();
int saved_backlight = amdgpu_dm_get_backlight_param();
+ int abm_index;
int old_count;
int ret;
@@ -1890,6 +1905,7 @@ static void dm_test_setup_backlight_device_attaches_abm_property(struct kunit *t
&dm_backlight_test_connector_funcs,
DRM_MODE_CONNECTOR_eDP, NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
+ drm_atomic_helper_connector_reset(&aconnector->base);
link = dm_kunit_alloc_link(test);
link->connector_signal = SIGNAL_TYPE_EDP;
@@ -1900,15 +1916,26 @@ static void dm_test_setup_backlight_device_attaches_abm_property(struct kunit *t
dm->adev = adev;
dm->ddev = &adev->ddev;
old_count = aconnector->base.base.properties->count;
+ abm_index = old_count + IS_ENABLED(CONFIG_DRM_LUMINANCE);
amdgpu_dm_setup_backlight_device(dm, aconnector);
KUNIT_EXPECT_EQ(test, dm->num_of_edps, 1);
KUNIT_EXPECT_EQ(test, aconnector->bl_idx, 0);
- KUNIT_EXPECT_EQ(test, aconnector->base.base.properties->count, old_count + 1);
- KUNIT_EXPECT_PTR_EQ(test, aconnector->base.base.properties->properties[old_count], prop);
- KUNIT_EXPECT_EQ(test, aconnector->base.base.properties->values[old_count],
- (uint64_t)ABM_SYSFS_CONTROL);
+ KUNIT_EXPECT_EQ(test, aconnector->base.base.properties->count,
+ old_count + 1 + IS_ENABLED(CONFIG_DRM_LUMINANCE));
+ if (IS_ENABLED(CONFIG_DRM_LUMINANCE)) {
+ KUNIT_EXPECT_NOT_NULL(test,
+ aconnector->base.luminance_property);
+ KUNIT_EXPECT_LE(test,
+ aconnector->base.state->luminance,
+ (uint64_t)MAX_BACKLIGHT_LEVEL);
+ }
+ KUNIT_EXPECT_PTR_EQ(test,
+ aconnector->base.base.properties->properties[abm_index],
+ prop);
+ KUNIT_EXPECT_EQ(test, aconnector->base.base.properties->values[abm_index],
+ (uint64_t)ABM_SYSFS_CONTROL);
amdgpu_dm_set_backlight_param(saved_backlight);
amdgpu_dm_set_abm_level_param(saved_abm_level);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
index aad122c7229f5..66c9b2cb70fcd 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
@@ -20,6 +20,7 @@
struct amdgpu_device *dm_kunit_alloc_adev(struct kunit *test)
{
+ struct amdgpu_device *adev;
struct drm_device *drm;
struct device *dev;
@@ -32,7 +33,11 @@ struct amdgpu_device *dm_kunit_alloc_adev(struct kunit *test)
DRIVER_MODESET | DRIVER_ATOMIC);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
- return drm_to_adev(drm);
+ adev = drm_to_adev(drm);
+
+ mutex_init(&adev->dm.dc_lock);
+
+ return adev;
}
EXPORT_SYMBOL(dm_kunit_alloc_adev);
--
2.53.0
next prev parent reply other threads:[~2026-11-02 16:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 16:49 [PATCH v10 00/15] Add support for a DRM backlight capability Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 01/15] drm: add connector LUMINANCE property Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 02/15] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 03/15] drm/amd: add luminance property support Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 04/15] drm/amdgpu: Check bios_scratch_reg_offset in backlight level helper Mario Limonciello (AMD)
2026-11-02 16:49 ` Mario Limonciello (AMD) [this message]
2026-11-02 16:49 ` [PATCH v10 06/15] drm/i915/display: add luminance property support Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 07/15] drm/bridge: add connector luminance operations Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 08/15] drm/panel: add connector luminance forwarding Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 09/15] drm/bridge_connector: add luminance support Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 10/15] drm/nouveau: add connector " Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 11/15] drm/gud: " Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 12/15] drm/radeon: " Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 13/15] drm/gma500: " Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 14/15] drm/bridge: add PS8622 " Mario Limonciello (AMD)
2026-11-02 16:49 ` [PATCH v10 15/15] drm/solomon: add SSD130x " Mario Limonciello (AMD)
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=20261102-superm1-backlight-property-v10-5-b2a6f24131f5@kernel.org \
--to=superm1@kernel.org \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=simona@ffwll.ch \
--cc=siqueira@igalia.com \
--cc=sunpeng.li@amd.com \
--cc=tzimmermann@suse.de \
--cc=xaver.hugl@gmail.com \
/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®