@@ -635,6 +635,64 @@ static void drm_test_connector_hdmi_init_formats_no_rgb(struct kunit *test)
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.
@@ -726,6 +784,8 @@ static struct kunit_case drmm_connector_hdmi_init_tests[] = {
726
784
KUNIT_CASE (drm_test_connector_hdmi_init_bpc_null ),
727
785
KUNIT_CASE (drm_test_connector_hdmi_init_formats_empty ),
728
786
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 ),
729
789
KUNIT_CASE (drm_test_connector_hdmi_init_null_ddc ),
730
790
KUNIT_CASE (drm_test_connector_hdmi_init_null_product ),
731
791
KUNIT_CASE (drm_test_connector_hdmi_init_null_vendor ),
0 commit comments