Commit eb66d34d authored by Maxime Ripard's avatar Maxime Ripard

drm/tests: Add output bpc tests

Now that we're tracking the output bpc count in the connector state,
let's add a few tests to make sure it works as expected.
Reviewed-by: default avatarDave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tested-by: default avatarSui Jingfeng <sui.jingfeng@linux.dev>
Link: https://patchwork.freedesktop.org/patch/msgid/20240527-kms-hdmi-connector-state-v15-6-c5af16c3aae2@kernel.orgSigned-off-by: default avatarMaxime Ripard <mripard@kernel.org>
parent c6d219fb
...@@ -79,6 +79,7 @@ config DRM_KUNIT_TEST ...@@ -79,6 +79,7 @@ config DRM_KUNIT_TEST
depends on DRM && KUNIT && MMU depends on DRM && KUNIT && MMU
select DRM_BUDDY select DRM_BUDDY
select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_DP_HELPER
select DRM_DISPLAY_HDMI_STATE_HELPER
select DRM_DISPLAY_HELPER select DRM_DISPLAY_HELPER
select DRM_EXEC select DRM_EXEC
select DRM_EXPORT_FOR_TESTS if m select DRM_EXPORT_FOR_TESTS if m
......
...@@ -14,6 +14,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ ...@@ -14,6 +14,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
drm_format_test.o \ drm_format_test.o \
drm_framebuffer_test.o \ drm_framebuffer_test.o \
drm_gem_shmem_test.o \ drm_gem_shmem_test.o \
drm_hdmi_state_helper_test.o \
drm_managed_test.o \ drm_managed_test.o \
drm_mm_test.o \ drm_mm_test.o \
drm_modes_test.o \ drm_modes_test.o \
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include <kunit/test.h> #include <kunit/test.h>
#include "../drm_crtc_internal.h"
struct drm_connector_init_priv { struct drm_connector_init_priv {
struct drm_device drm; struct drm_device drm;
struct drm_connector connector; struct drm_connector connector;
...@@ -206,6 +208,154 @@ static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test) ...@@ -206,6 +208,154 @@ static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test)
KUNIT_EXPECT_EQ(test, ret, 0); KUNIT_EXPECT_EQ(test, ret, 0);
} }
/*
* Test that the registration of a connector with an invalid maximum bpc
* count fails.
*/
static void drm_test_connector_hdmi_init_bpc_invalid(struct kunit *test)
{
struct drm_connector_init_priv *priv = test->priv;
int ret;
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs,
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
9);
KUNIT_EXPECT_LT(test, ret, 0);
}
/*
* Test that the registration of a connector with a null maximum bpc
* count fails.
*/
static void drm_test_connector_hdmi_init_bpc_null(struct kunit *test)
{
struct drm_connector_init_priv *priv = test->priv;
int ret;
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs,
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
0);
KUNIT_EXPECT_LT(test, ret, 0);
}
/*
* Test that the registration of a connector with a maximum bpc count of
* 8 succeeds, registers the max bpc property, but doesn't register the
* HDR output metadata one.
*/
static void drm_test_connector_hdmi_init_bpc_8(struct kunit *test)
{
struct drm_connector_init_priv *priv = test->priv;
struct drm_connector_state *state;
struct drm_connector *connector = &priv->connector;
struct drm_property *prop;
uint64_t val;
int ret;
ret = drmm_connector_hdmi_init(&priv->drm, connector,
&dummy_funcs,
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
prop = connector->max_bpc_property;
KUNIT_ASSERT_NOT_NULL(test, prop);
KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id));
ret = drm_object_property_get_default_value(&connector->base, prop, &val);
KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_EQ(test, val, 8);
state = connector->state;
KUNIT_EXPECT_EQ(test, state->max_bpc, 8);
KUNIT_EXPECT_EQ(test, state->max_requested_bpc, 8);
prop = priv->drm.mode_config.hdr_output_metadata_property;
KUNIT_ASSERT_NOT_NULL(test, prop);
KUNIT_EXPECT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id));
}
/*
* Test that the registration of a connector with a maximum bpc count of
* 10 succeeds and registers the max bpc and HDR output metadata
* properties.
*/
static void drm_test_connector_hdmi_init_bpc_10(struct kunit *test)
{
struct drm_connector_init_priv *priv = test->priv;
struct drm_connector_state *state;
struct drm_connector *connector = &priv->connector;
struct drm_property *prop;
uint64_t val;
int ret;
ret = drmm_connector_hdmi_init(&priv->drm, connector,
&dummy_funcs,
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
10);
KUNIT_EXPECT_EQ(test, ret, 0);
prop = connector->max_bpc_property;
KUNIT_ASSERT_NOT_NULL(test, prop);
KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id));
ret = drm_object_property_get_default_value(&connector->base, prop, &val);
KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_EQ(test, val, 10);
state = connector->state;
KUNIT_EXPECT_EQ(test, state->max_bpc, 10);
KUNIT_EXPECT_EQ(test, state->max_requested_bpc, 10);
prop = priv->drm.mode_config.hdr_output_metadata_property;
KUNIT_ASSERT_NOT_NULL(test, prop);
KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id));
}
/*
* Test that the registration of a connector with a maximum bpc count of
* 12 succeeds and registers the max bpc and HDR output metadata
* properties.
*/
static void drm_test_connector_hdmi_init_bpc_12(struct kunit *test)
{
struct drm_connector_init_priv *priv = test->priv;
struct drm_connector_state *state;
struct drm_connector *connector = &priv->connector;
struct drm_property *prop;
uint64_t val;
int ret;
ret = drmm_connector_hdmi_init(&priv->drm, connector,
&dummy_funcs,
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
12);
KUNIT_EXPECT_EQ(test, ret, 0);
prop = connector->max_bpc_property;
KUNIT_ASSERT_NOT_NULL(test, prop);
KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id));
ret = drm_object_property_get_default_value(&connector->base, prop, &val);
KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_EQ(test, val, 12);
state = connector->state;
KUNIT_EXPECT_EQ(test, state->max_bpc, 12);
KUNIT_EXPECT_EQ(test, state->max_requested_bpc, 12);
prop = priv->drm.mode_config.hdr_output_metadata_property;
KUNIT_ASSERT_NOT_NULL(test, prop);
KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id));
}
/* /*
* Test that the registration of an HDMI connector with an HDMI * Test that the registration of an HDMI connector with an HDMI
* connector type succeeds. * connector type succeeds.
...@@ -284,6 +434,11 @@ KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_invalid, ...@@ -284,6 +434,11 @@ KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_invalid,
static struct kunit_case drmm_connector_hdmi_init_tests[] = { static struct kunit_case drmm_connector_hdmi_init_tests[] = {
KUNIT_CASE(drm_test_connector_hdmi_init_valid), KUNIT_CASE(drm_test_connector_hdmi_init_valid),
KUNIT_CASE(drm_test_connector_hdmi_init_bpc_8),
KUNIT_CASE(drm_test_connector_hdmi_init_bpc_10),
KUNIT_CASE(drm_test_connector_hdmi_init_bpc_12),
KUNIT_CASE(drm_test_connector_hdmi_init_bpc_invalid),
KUNIT_CASE(drm_test_connector_hdmi_init_bpc_null),
KUNIT_CASE(drm_test_connector_hdmi_init_null_ddc), KUNIT_CASE(drm_test_connector_hdmi_init_null_ddc),
KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_valid, KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_valid,
drm_connector_hdmi_init_type_valid_gen_params), drm_connector_hdmi_init_type_valid_gen_params),
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef DRM_KUNIT_EDID_H_
#define DRM_KUNIT_EDID_H_
/*
* edid-decode (hex):
*
* 00 ff ff ff ff ff ff 00 31 d8 2a 00 00 00 00 00
* 00 21 01 03 81 a0 5a 78 02 00 00 00 00 00 00 00
* 00 00 00 20 00 00 01 01 01 01 01 01 01 01 01 01
* 01 01 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c
* 45 00 40 84 63 00 00 1e 00 00 00 fc 00 54 65 73
* 74 20 45 44 49 44 0a 20 20 20 00 00 00 fd 00 32
* 46 1e 46 0f 00 0a 20 20 20 20 20 20 00 00 00 10
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 92
*
* 02 03 1b 81 e3 05 00 20 41 10 e2 00 4a 6d 03 0c
* 00 12 34 00 28 20 00 00 00 00 00 00 00 00 00 00
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d0
*
* ----------------
*
* Block 0, Base EDID:
* EDID Structure Version & Revision: 1.3
* Vendor & Product Identification:
* Manufacturer: LNX
* Model: 42
* Made in: 2023
* Basic Display Parameters & Features:
* Digital display
* DFP 1.x compatible TMDS
* Maximum image size: 160 cm x 90 cm
* Gamma: 2.20
* Monochrome or grayscale display
* First detailed timing is the preferred timing
* Color Characteristics:
* Red : 0.0000, 0.0000
* Green: 0.0000, 0.0000
* Blue : 0.0000, 0.0000
* White: 0.0000, 0.0000
* Established Timings I & II:
* DMT 0x04: 640x480 59.940476 Hz 4:3 31.469 kHz 25.175000 MHz
* Standard Timings: none
* Detailed Timing Descriptors:
* DTD 1: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz (1600 mm x 900 mm)
* Hfront 88 Hsync 44 Hback 148 Hpol P
* Vfront 4 Vsync 5 Vback 36 Vpol P
* Display Product Name: 'Test EDID'
* Display Range Limits:
* Monitor ranges (GTF): 50-70 Hz V, 30-70 kHz H, max dotclock 150 MHz
* Dummy Descriptor:
* Extension blocks: 1
* Checksum: 0x92
*
* ----------------
*
* Block 1, CTA-861 Extension Block:
* Revision: 3
* Underscans IT Video Formats by default
* Native detailed modes: 1
* Colorimetry Data Block:
* sRGB
* Video Data Block:
* VIC 16: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz
* Video Capability Data Block:
* YCbCr quantization: No Data
* RGB quantization: Selectable (via AVI Q)
* PT scan behavior: No Data
* IT scan behavior: Always Underscanned
* CE scan behavior: Always Underscanned
* Vendor-Specific Data Block (HDMI), OUI 00-0C-03:
* Source physical address: 1.2.3.4
* Maximum TMDS clock: 200 MHz
* Extended HDMI video details:
* Checksum: 0xd0 Unused space in Extension Block: 100 bytes
*/
static const unsigned char test_edid_hdmi_1080p_rgb_max_200mhz[] = {
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x31, 0xd8, 0x2a, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x01, 0x03, 0x81, 0xa0, 0x5a, 0x78,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38,
0x2d, 0x40, 0x58, 0x2c, 0x45, 0x00, 0x40, 0x84, 0x63, 0x00, 0x00, 0x1e,
0x00, 0x00, 0x00, 0xfc, 0x00, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x44,
0x49, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x32,
0x46, 0x00, 0x00, 0xc4, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x41, 0x02, 0x03, 0x1b, 0x81,
0xe3, 0x05, 0x00, 0x20, 0x41, 0x10, 0xe2, 0x00, 0x4a, 0x6d, 0x03, 0x0c,
0x00, 0x12, 0x34, 0x00, 0x28, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xd0
};
#endif // DRM_KUNIT_EDID_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment