mirror of
https://github.com/torvalds/linux.git
synced 2026-04-24 17:42:27 -04:00
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: Dave Stevenson <dave.stevenson@raspberrypi.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Tested-by: Sui Jingfeng <sui.jingfeng@linux.dev> Link: https://patchwork.freedesktop.org/patch/msgid/20240527-kms-hdmi-connector-state-v15-6-c5af16c3aae2@kernel.org Signed-off-by: Maxime Ripard <mripard@kernel.org>
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
|
||||
#include <kunit/test.h>
|
||||
|
||||
#include "../drm_crtc_internal.h"
|
||||
|
||||
struct drm_connector_init_priv {
|
||||
struct drm_device drm;
|
||||
struct drm_connector connector;
|
||||
@@ -206,6 +208,154 @@ static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test)
|
||||
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
|
||||
* connector type succeeds.
|
||||
@@ -284,6 +434,11 @@ KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_invalid,
|
||||
|
||||
static struct kunit_case drmm_connector_hdmi_init_tests[] = {
|
||||
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_PARAM(drm_test_connector_hdmi_init_type_valid,
|
||||
drm_connector_hdmi_init_type_valid_gen_params),
|
||||
|
||||
Reference in New Issue
Block a user