Skip to content

Commit 93801b8

Browse files
cristicclumag
authored andcommitted
drm/tests: connector: Add ycbcr_420_allowed tests
Extend HDMI connector output format tests to verify its registration succeeds only when the presence of YUV420 in the supported formats matches the state of ycbcr_420_allowed flag. Signed-off-by: Cristian Ciocaltea <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent f2f9661 commit 93801b8

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

drivers/gpu/drm/tests/drm_connector_test.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,64 @@ static void drm_test_connector_hdmi_init_formats_no_rgb(struct kunit *test)
635635
KUNIT_EXPECT_LT(test, ret, 0);
636636
}
637637

638+
struct drm_connector_hdmi_init_formats_yuv420_allowed_test {
639+
unsigned long supported_formats;
640+
bool yuv420_allowed;
641+
int expected_result;
642+
};
643+
644+
#define YUV420_ALLOWED_TEST(_formats, _allowed, _result) \
645+
{ \
646+
.supported_formats = BIT(HDMI_COLORSPACE_RGB) | (_formats), \
647+
.yuv420_allowed = _allowed, \
648+
.expected_result = _result, \
649+
}
650+
651+
static const struct drm_connector_hdmi_init_formats_yuv420_allowed_test
652+
drm_connector_hdmi_init_formats_yuv420_allowed_tests[] = {
653+
YUV420_ALLOWED_TEST(BIT(HDMI_COLORSPACE_YUV420), true, 0),
654+
YUV420_ALLOWED_TEST(BIT(HDMI_COLORSPACE_YUV420), false, -EINVAL),
655+
YUV420_ALLOWED_TEST(BIT(HDMI_COLORSPACE_YUV422), true, -EINVAL),
656+
YUV420_ALLOWED_TEST(BIT(HDMI_COLORSPACE_YUV422), false, 0),
657+
};
658+
659+
static void
660+
drm_connector_hdmi_init_formats_yuv420_allowed_desc(const struct drm_connector_hdmi_init_formats_yuv420_allowed_test *t,
661+
char *desc)
662+
{
663+
sprintf(desc, "supported_formats=0x%lx yuv420_allowed=%d",
664+
t->supported_formats, t->yuv420_allowed);
665+
}
666+
667+
KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_formats_yuv420_allowed,
668+
drm_connector_hdmi_init_formats_yuv420_allowed_tests,
669+
drm_connector_hdmi_init_formats_yuv420_allowed_desc);
670+
671+
/*
672+
* Test that the registration of an HDMI connector succeeds only when
673+
* the presence of YUV420 in the supported formats matches the value
674+
* of the ycbcr_420_allowed flag.
675+
*/
676+
static void drm_test_connector_hdmi_init_formats_yuv420_allowed(struct kunit *test)
677+
{
678+
const struct drm_connector_hdmi_init_formats_yuv420_allowed_test *params;
679+
struct drm_connector_init_priv *priv = test->priv;
680+
int ret;
681+
682+
params = test->param_value;
683+
priv->connector.ycbcr_420_allowed = params->yuv420_allowed;
684+
685+
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
686+
"Vendor", "Product",
687+
&dummy_funcs,
688+
&dummy_hdmi_funcs,
689+
DRM_MODE_CONNECTOR_HDMIA,
690+
&priv->ddc,
691+
params->supported_formats,
692+
8);
693+
KUNIT_EXPECT_EQ(test, ret, params->expected_result);
694+
}
695+
638696
/*
639697
* Test that the registration of an HDMI connector with an HDMI
640698
* connector type succeeds.
@@ -726,6 +784,8 @@ static struct kunit_case drmm_connector_hdmi_init_tests[] = {
726784
KUNIT_CASE(drm_test_connector_hdmi_init_bpc_null),
727785
KUNIT_CASE(drm_test_connector_hdmi_init_formats_empty),
728786
KUNIT_CASE(drm_test_connector_hdmi_init_formats_no_rgb),
787+
KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_formats_yuv420_allowed,
788+
drm_connector_hdmi_init_formats_yuv420_allowed_gen_params),
729789
KUNIT_CASE(drm_test_connector_hdmi_init_null_ddc),
730790
KUNIT_CASE(drm_test_connector_hdmi_init_null_product),
731791
KUNIT_CASE(drm_test_connector_hdmi_init_null_vendor),

0 commit comments

Comments
 (0)