Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <cristian.ciocaltea@collabora.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20241224-bridge-conn-fmt-prio-v4-4-a9ceb5671379@collabora.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

authored by

Cristian Ciocaltea and committed by
Dmitry Baryshkov
93801b8c f2f96619

+60
+60
drivers/gpu/drm/tests/drm_connector_test.c
··· 635 635 KUNIT_EXPECT_LT(test, ret, 0); 636 636 } 637 637 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 + 638 696 /* 639 697 * Test that the registration of an HDMI connector with an HDMI 640 698 * connector type succeeds. ··· 784 726 KUNIT_CASE(drm_test_connector_hdmi_init_bpc_null), 785 727 KUNIT_CASE(drm_test_connector_hdmi_init_formats_empty), 786 728 KUNIT_CASE(drm_test_connector_hdmi_init_formats_no_rgb), 729 + KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_formats_yuv420_allowed, 730 + drm_connector_hdmi_init_formats_yuv420_allowed_gen_params), 787 731 KUNIT_CASE(drm_test_connector_hdmi_init_null_ddc), 788 732 KUNIT_CASE(drm_test_connector_hdmi_init_null_product), 789 733 KUNIT_CASE(drm_test_connector_hdmi_init_null_vendor),