Commit 68aaa74d authored by Maxime Ripard's avatar Maxime Ripard

drm/tests: connector: Add tests for drmm_connector_hdmi_init

We just introduced a new initialization function for our connectors, so
let's build a kunit test suite for it as well.
Reviewed-by: default avatarDave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240527-kms-hdmi-connector-state-v15-2-c5af16c3aae2@kernel.orgSigned-off-by: default avatarMaxime Ripard <mripard@kernel.org>
parent 582d79f3
......@@ -172,6 +172,128 @@ static struct kunit_suite drmm_connector_init_test_suite = {
.test_cases = drmm_connector_init_tests,
};
/*
* Test that the registration of a bog standard connector works as
* expected and doesn't report any error.
*/
static void drm_test_connector_hdmi_init_valid(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);
KUNIT_EXPECT_EQ(test, ret, 0);
}
/*
* Test that the registration of a connector without a DDC adapter
* doesn't report any error.
*/
static void drm_test_connector_hdmi_init_null_ddc(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,
NULL);
KUNIT_EXPECT_EQ(test, ret, 0);
}
/*
* Test that the registration of an HDMI connector with an HDMI
* connector type succeeds.
*/
static void drm_test_connector_hdmi_init_type_valid(struct kunit *test)
{
struct drm_connector_init_priv *priv = test->priv;
unsigned int connector_type = *(unsigned int *)test->param_value;
int ret;
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs,
connector_type,
&priv->ddc);
KUNIT_EXPECT_EQ(test, ret, 0);
}
static const unsigned int drm_connector_hdmi_init_type_valid_tests[] = {
DRM_MODE_CONNECTOR_HDMIA,
DRM_MODE_CONNECTOR_HDMIB,
};
static void drm_connector_hdmi_init_type_desc(const unsigned int *type, char *desc)
{
sprintf(desc, "%s", drm_get_connector_type_name(*type));
}
KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_valid,
drm_connector_hdmi_init_type_valid_tests,
drm_connector_hdmi_init_type_desc);
/*
* Test that the registration of an HDMI connector with an !HDMI
* connector type fails.
*/
static void drm_test_connector_hdmi_init_type_invalid(struct kunit *test)
{
struct drm_connector_init_priv *priv = test->priv;
unsigned int connector_type = *(unsigned int *)test->param_value;
int ret;
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs,
connector_type,
&priv->ddc);
KUNIT_EXPECT_LT(test, ret, 0);
}
static const unsigned int drm_connector_hdmi_init_type_invalid_tests[] = {
DRM_MODE_CONNECTOR_Unknown,
DRM_MODE_CONNECTOR_VGA,
DRM_MODE_CONNECTOR_DVII,
DRM_MODE_CONNECTOR_DVID,
DRM_MODE_CONNECTOR_DVIA,
DRM_MODE_CONNECTOR_Composite,
DRM_MODE_CONNECTOR_SVIDEO,
DRM_MODE_CONNECTOR_LVDS,
DRM_MODE_CONNECTOR_Component,
DRM_MODE_CONNECTOR_9PinDIN,
DRM_MODE_CONNECTOR_DisplayPort,
DRM_MODE_CONNECTOR_TV,
DRM_MODE_CONNECTOR_eDP,
DRM_MODE_CONNECTOR_VIRTUAL,
DRM_MODE_CONNECTOR_DSI,
DRM_MODE_CONNECTOR_DPI,
DRM_MODE_CONNECTOR_WRITEBACK,
DRM_MODE_CONNECTOR_SPI,
DRM_MODE_CONNECTOR_USB,
};
KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_invalid,
drm_connector_hdmi_init_type_invalid_tests,
drm_connector_hdmi_init_type_desc);
static struct kunit_case drmm_connector_hdmi_init_tests[] = {
KUNIT_CASE(drm_test_connector_hdmi_init_valid),
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),
KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_invalid,
drm_connector_hdmi_init_type_invalid_gen_params),
{ }
};
static struct kunit_suite drmm_connector_hdmi_init_test_suite = {
.name = "drmm_connector_hdmi_init",
.init = drm_test_connector_init,
.test_cases = drmm_connector_hdmi_init_tests,
};
struct drm_get_tv_mode_from_name_test {
const char *name;
enum drm_connector_tv_mode expected_mode;
......@@ -236,6 +358,7 @@ static struct kunit_suite drm_get_tv_mode_from_name_test_suite = {
};
kunit_test_suites(
&drmm_connector_hdmi_init_test_suite,
&drmm_connector_init_test_suite,
&drm_get_tv_mode_from_name_test_suite
);
......
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