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

Configure Feed

Select the types of activity you want to include in your feed.

drm/tests: Add HDMI connector bpc and format tests

The previous patch added the bpc and format an HDMI connector needs to
be set up with for a given connector state.

Let's add a few tests to make sure it works as expected.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240527-kms-hdmi-connector-state-v15-16-c5af16c3aae2@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+669
+509
drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
··· 17 17 #include <drm/drm_print.h> 18 18 #include <drm/drm_probe_helper.h> 19 19 20 + #include <drm/display/drm_hdmi_helper.h> 20 21 #include <drm/display/drm_hdmi_state_helper.h> 21 22 22 23 #include "../drm_crtc_internal.h" ··· 374 373 } 375 374 376 375 /* 376 + * Test that if we have an HDMI connector but a !HDMI display, we always 377 + * output RGB with 8 bpc. 378 + */ 379 + static void drm_test_check_output_bpc_dvi(struct kunit *test) 380 + { 381 + struct drm_atomic_helper_connector_hdmi_priv *priv; 382 + struct drm_modeset_acquire_ctx *ctx; 383 + struct drm_connector_state *conn_state; 384 + struct drm_display_info *info; 385 + struct drm_display_mode *preferred; 386 + struct drm_connector *conn; 387 + struct drm_device *drm; 388 + struct drm_crtc *crtc; 389 + int ret; 390 + 391 + priv = drm_atomic_helper_connector_hdmi_init(test, 392 + BIT(HDMI_COLORSPACE_RGB) | 393 + BIT(HDMI_COLORSPACE_YUV422) | 394 + BIT(HDMI_COLORSPACE_YUV444), 395 + 12); 396 + KUNIT_ASSERT_NOT_NULL(test, priv); 397 + 398 + conn = &priv->connector; 399 + ret = set_connector_edid(test, conn, 400 + test_edid_dvi_1080p, 401 + ARRAY_SIZE(test_edid_dvi_1080p)); 402 + KUNIT_ASSERT_EQ(test, ret, 0); 403 + 404 + info = &conn->display_info; 405 + KUNIT_ASSERT_FALSE(test, info->is_hdmi); 406 + 407 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 408 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 409 + 410 + preferred = find_preferred_mode(conn); 411 + KUNIT_ASSERT_NOT_NULL(test, preferred); 412 + 413 + drm = &priv->drm; 414 + crtc = priv->crtc; 415 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 416 + KUNIT_ASSERT_EQ(test, ret, 0); 417 + 418 + conn_state = conn->state; 419 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 420 + 421 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 8); 422 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 423 + } 424 + 425 + /* 377 426 * Test that when doing a commit which would use RGB 8bpc, the TMDS 378 427 * clock rate stored in the connector state is equal to the mode clock 379 428 */ ··· 615 564 KUNIT_EXPECT_LT(test, ret, 0); 616 565 } 617 566 567 + /* 568 + * Test that if: 569 + * - We have an HDMI connector supporting RGB only 570 + * - The chosen mode has a TMDS character rate higher than the display 571 + * supports in RGB/12bpc 572 + * - The chosen mode has a TMDS character rate lower than the display 573 + * supports in RGB/10bpc. 574 + * 575 + * Then we will pick the latter, and the computed TMDS character rate 576 + * will be equal to 1.25 times the mode pixel clock. 577 + */ 578 + static void drm_test_check_max_tmds_rate_bpc_fallback(struct kunit *test) 579 + { 580 + struct drm_atomic_helper_connector_hdmi_priv *priv; 581 + struct drm_modeset_acquire_ctx *ctx; 582 + struct drm_connector_state *conn_state; 583 + struct drm_display_info *info; 584 + struct drm_display_mode *preferred; 585 + unsigned long long rate; 586 + struct drm_connector *conn; 587 + struct drm_device *drm; 588 + struct drm_crtc *crtc; 589 + int ret; 590 + 591 + priv = drm_atomic_helper_connector_hdmi_init(test, 592 + BIT(HDMI_COLORSPACE_RGB), 593 + 12); 594 + KUNIT_ASSERT_NOT_NULL(test, priv); 595 + 596 + conn = &priv->connector; 597 + ret = set_connector_edid(test, conn, 598 + test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, 599 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz)); 600 + KUNIT_ASSERT_EQ(test, ret, 0); 601 + 602 + info = &conn->display_info; 603 + KUNIT_ASSERT_TRUE(test, info->is_hdmi); 604 + KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 605 + 606 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 607 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 608 + 609 + preferred = find_preferred_mode(conn); 610 + KUNIT_ASSERT_NOT_NULL(test, preferred); 611 + KUNIT_ASSERT_FALSE(test, preferred->flags & DRM_MODE_FLAG_DBLCLK); 612 + 613 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 614 + KUNIT_ASSERT_GT(test, rate, info->max_tmds_clock * 1000); 615 + 616 + rate = drm_hdmi_compute_mode_clock(preferred, 10, HDMI_COLORSPACE_RGB); 617 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 618 + 619 + drm = &priv->drm; 620 + crtc = priv->crtc; 621 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 622 + KUNIT_EXPECT_EQ(test, ret, 0); 623 + 624 + conn_state = conn->state; 625 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 626 + 627 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 10); 628 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 629 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.tmds_char_rate, preferred->clock * 1250); 630 + } 631 + 632 + /* 633 + * Test that if: 634 + * - We have an HDMI connector supporting both RGB and YUV422 and up to 635 + * 12 bpc 636 + * - The chosen mode has a TMDS character rate higher than the display 637 + * supports in RGB/12bpc but lower than the display supports in 638 + * RGB/10bpc 639 + * - The chosen mode has a TMDS character rate lower than the display 640 + * supports in YUV422/12bpc. 641 + * 642 + * Then we will prefer to keep the RGB format with a lower bpc over 643 + * picking YUV422. 644 + */ 645 + static void drm_test_check_max_tmds_rate_format_fallback(struct kunit *test) 646 + { 647 + struct drm_atomic_helper_connector_hdmi_priv *priv; 648 + struct drm_modeset_acquire_ctx *ctx; 649 + struct drm_connector_state *conn_state; 650 + struct drm_display_info *info; 651 + struct drm_display_mode *preferred; 652 + unsigned long long rate; 653 + struct drm_connector *conn; 654 + struct drm_device *drm; 655 + struct drm_crtc *crtc; 656 + int ret; 657 + 658 + priv = drm_atomic_helper_connector_hdmi_init(test, 659 + BIT(HDMI_COLORSPACE_RGB) | 660 + BIT(HDMI_COLORSPACE_YUV422) | 661 + BIT(HDMI_COLORSPACE_YUV444), 662 + 12); 663 + KUNIT_ASSERT_NOT_NULL(test, priv); 664 + 665 + conn = &priv->connector; 666 + ret = set_connector_edid(test, conn, 667 + test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, 668 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz)); 669 + KUNIT_ASSERT_EQ(test, ret, 0); 670 + 671 + info = &conn->display_info; 672 + KUNIT_ASSERT_TRUE(test, info->is_hdmi); 673 + KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 674 + 675 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 676 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 677 + 678 + preferred = find_preferred_mode(conn); 679 + KUNIT_ASSERT_NOT_NULL(test, preferred); 680 + KUNIT_ASSERT_FALSE(test, preferred->flags & DRM_MODE_FLAG_DBLCLK); 681 + 682 + rate = drm_hdmi_compute_mode_clock(preferred, 10, HDMI_COLORSPACE_RGB); 683 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 684 + 685 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 686 + KUNIT_ASSERT_GT(test, rate, info->max_tmds_clock * 1000); 687 + 688 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_YUV422); 689 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 690 + 691 + drm = &priv->drm; 692 + crtc = priv->crtc; 693 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 694 + KUNIT_EXPECT_EQ(test, ret, 0); 695 + 696 + conn_state = conn->state; 697 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 698 + 699 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 10); 700 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 701 + } 702 + 703 + /* 704 + * Test that if a driver and screen supports RGB and YUV formats, and we 705 + * try to set the VIC 1 mode, we end up with 8bpc RGB even if we could 706 + * have had a higher bpc. 707 + */ 708 + static void drm_test_check_output_bpc_format_vic_1(struct kunit *test) 709 + { 710 + struct drm_atomic_helper_connector_hdmi_priv *priv; 711 + struct drm_modeset_acquire_ctx *ctx; 712 + struct drm_connector_state *conn_state; 713 + struct drm_display_info *info; 714 + struct drm_display_mode *mode; 715 + unsigned long long rate; 716 + struct drm_connector *conn; 717 + struct drm_device *drm; 718 + struct drm_crtc *crtc; 719 + int ret; 720 + 721 + priv = drm_atomic_helper_connector_hdmi_init(test, 722 + BIT(HDMI_COLORSPACE_RGB) | 723 + BIT(HDMI_COLORSPACE_YUV422) | 724 + BIT(HDMI_COLORSPACE_YUV444), 725 + 12); 726 + KUNIT_ASSERT_NOT_NULL(test, priv); 727 + 728 + drm = &priv->drm; 729 + conn = &priv->connector; 730 + ret = set_connector_edid(test, conn, 731 + test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, 732 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz)); 733 + KUNIT_ASSERT_EQ(test, ret, 0); 734 + 735 + info = &conn->display_info; 736 + KUNIT_ASSERT_TRUE(test, info->is_hdmi); 737 + KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 738 + 739 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 740 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 741 + 742 + mode = drm_display_mode_from_cea_vic(drm, 1); 743 + KUNIT_ASSERT_NOT_NULL(test, mode); 744 + 745 + /* 746 + * NOTE: We can't use drm_hdmi_compute_mode_clock() 747 + * here because we're trying to get the rate of an invalid 748 + * configuration. 749 + * 750 + * Thus, we have to calculate the rate by hand. 751 + */ 752 + rate = mode->clock * 1500; 753 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 754 + 755 + drm = &priv->drm; 756 + crtc = priv->crtc; 757 + ret = light_up_connector(test, drm, crtc, conn, mode, ctx); 758 + KUNIT_EXPECT_EQ(test, ret, 0); 759 + 760 + conn_state = conn->state; 761 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 762 + 763 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 8); 764 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 765 + } 766 + 767 + /* 768 + * Test that if a driver supports only RGB but the screen also supports 769 + * YUV formats, we only end up with an RGB format. 770 + */ 771 + static void drm_test_check_output_bpc_format_driver_rgb_only(struct kunit *test) 772 + { 773 + struct drm_atomic_helper_connector_hdmi_priv *priv; 774 + struct drm_modeset_acquire_ctx *ctx; 775 + struct drm_connector_state *conn_state; 776 + struct drm_display_info *info; 777 + struct drm_display_mode *preferred; 778 + unsigned long long rate; 779 + struct drm_connector *conn; 780 + struct drm_device *drm; 781 + struct drm_crtc *crtc; 782 + int ret; 783 + 784 + priv = drm_atomic_helper_connector_hdmi_init(test, 785 + BIT(HDMI_COLORSPACE_RGB), 786 + 12); 787 + KUNIT_ASSERT_NOT_NULL(test, priv); 788 + 789 + conn = &priv->connector; 790 + ret = set_connector_edid(test, conn, 791 + test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, 792 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz)); 793 + KUNIT_ASSERT_EQ(test, ret, 0); 794 + 795 + info = &conn->display_info; 796 + KUNIT_ASSERT_TRUE(test, info->is_hdmi); 797 + KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 798 + 799 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 800 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 801 + 802 + preferred = find_preferred_mode(conn); 803 + KUNIT_ASSERT_NOT_NULL(test, preferred); 804 + 805 + /* 806 + * We're making sure that YUV422 would be the preferred option 807 + * here: we're always favouring higher bpc, we can't have RGB 808 + * because the TMDS character rate exceeds the maximum supported 809 + * by the display, and YUV422 works for that display. 810 + * 811 + * But since the driver only supports RGB, we should fallback to 812 + * a lower bpc with RGB. 813 + */ 814 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 815 + KUNIT_ASSERT_GT(test, rate, info->max_tmds_clock * 1000); 816 + 817 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_YUV422); 818 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 819 + 820 + drm = &priv->drm; 821 + crtc = priv->crtc; 822 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 823 + KUNIT_EXPECT_EQ(test, ret, 0); 824 + 825 + conn_state = conn->state; 826 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 827 + 828 + KUNIT_EXPECT_LT(test, conn_state->hdmi.output_bpc, 12); 829 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 830 + } 831 + 832 + /* 833 + * Test that if a screen supports only RGB but the driver also supports 834 + * YUV formats, we only end up with an RGB format. 835 + */ 836 + static void drm_test_check_output_bpc_format_display_rgb_only(struct kunit *test) 837 + { 838 + struct drm_atomic_helper_connector_hdmi_priv *priv; 839 + struct drm_modeset_acquire_ctx *ctx; 840 + struct drm_connector_state *conn_state; 841 + struct drm_display_info *info; 842 + struct drm_display_mode *preferred; 843 + unsigned long long rate; 844 + struct drm_connector *conn; 845 + struct drm_device *drm; 846 + struct drm_crtc *crtc; 847 + int ret; 848 + 849 + priv = drm_atomic_helper_connector_hdmi_init(test, 850 + BIT(HDMI_COLORSPACE_RGB) | 851 + BIT(HDMI_COLORSPACE_YUV422) | 852 + BIT(HDMI_COLORSPACE_YUV444), 853 + 12); 854 + KUNIT_ASSERT_NOT_NULL(test, priv); 855 + 856 + conn = &priv->connector; 857 + ret = set_connector_edid(test, conn, 858 + test_edid_hdmi_1080p_rgb_max_200mhz, 859 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_max_200mhz)); 860 + KUNIT_ASSERT_EQ(test, ret, 0); 861 + 862 + info = &conn->display_info; 863 + KUNIT_ASSERT_TRUE(test, info->is_hdmi); 864 + KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 865 + 866 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 867 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 868 + 869 + preferred = find_preferred_mode(conn); 870 + KUNIT_ASSERT_NOT_NULL(test, preferred); 871 + 872 + /* 873 + * We're making sure that YUV422 would be the preferred option 874 + * here: we're always favouring higher bpc, we can't have RGB 875 + * because the TMDS character rate exceeds the maximum supported 876 + * by the display, and YUV422 works for that display. 877 + * 878 + * But since the display only supports RGB, we should fallback to 879 + * a lower bpc with RGB. 880 + */ 881 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 882 + KUNIT_ASSERT_GT(test, rate, info->max_tmds_clock * 1000); 883 + 884 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_YUV422); 885 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 886 + 887 + drm = &priv->drm; 888 + crtc = priv->crtc; 889 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 890 + KUNIT_EXPECT_EQ(test, ret, 0); 891 + 892 + conn_state = conn->state; 893 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 894 + 895 + KUNIT_EXPECT_LT(test, conn_state->hdmi.output_bpc, 12); 896 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 897 + } 898 + 899 + /* 900 + * Test that if a display supports higher bpc but the driver only 901 + * supports 8 bpc, we only end up with 8 bpc even if we could have had a 902 + * higher bpc. 903 + */ 904 + static void drm_test_check_output_bpc_format_driver_8bpc_only(struct kunit *test) 905 + { 906 + struct drm_atomic_helper_connector_hdmi_priv *priv; 907 + struct drm_modeset_acquire_ctx *ctx; 908 + struct drm_connector_state *conn_state; 909 + struct drm_display_info *info; 910 + struct drm_display_mode *preferred; 911 + unsigned long long rate; 912 + struct drm_connector *conn; 913 + struct drm_device *drm; 914 + struct drm_crtc *crtc; 915 + int ret; 916 + 917 + priv = drm_atomic_helper_connector_hdmi_init(test, 918 + BIT(HDMI_COLORSPACE_RGB), 919 + 8); 920 + KUNIT_ASSERT_NOT_NULL(test, priv); 921 + 922 + conn = &priv->connector; 923 + ret = set_connector_edid(test, conn, 924 + test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz, 925 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz)); 926 + KUNIT_ASSERT_EQ(test, ret, 0); 927 + 928 + info = &conn->display_info; 929 + KUNIT_ASSERT_TRUE(test, info->is_hdmi); 930 + KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 931 + 932 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 933 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 934 + 935 + preferred = find_preferred_mode(conn); 936 + KUNIT_ASSERT_NOT_NULL(test, preferred); 937 + 938 + /* 939 + * We're making sure that we have headroom on the TMDS character 940 + * clock to actually use 12bpc. 941 + */ 942 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 943 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 944 + 945 + drm = &priv->drm; 946 + crtc = priv->crtc; 947 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 948 + KUNIT_EXPECT_EQ(test, ret, 0); 949 + 950 + conn_state = conn->state; 951 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 952 + 953 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 8); 954 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 955 + } 956 + 957 + /* 958 + * Test that if a driver supports higher bpc but the display only 959 + * supports 8 bpc, we only end up with 8 bpc even if we could have had a 960 + * higher bpc. 961 + */ 962 + static void drm_test_check_output_bpc_format_display_8bpc_only(struct kunit *test) 963 + { 964 + struct drm_atomic_helper_connector_hdmi_priv *priv; 965 + struct drm_modeset_acquire_ctx *ctx; 966 + struct drm_connector_state *conn_state; 967 + struct drm_display_info *info; 968 + struct drm_display_mode *preferred; 969 + unsigned long long rate; 970 + struct drm_connector *conn; 971 + struct drm_device *drm; 972 + struct drm_crtc *crtc; 973 + int ret; 974 + 975 + priv = drm_atomic_helper_connector_hdmi_init(test, 976 + BIT(HDMI_COLORSPACE_RGB) | 977 + BIT(HDMI_COLORSPACE_YUV422) | 978 + BIT(HDMI_COLORSPACE_YUV444), 979 + 12); 980 + KUNIT_ASSERT_NOT_NULL(test, priv); 981 + 982 + conn = &priv->connector; 983 + ret = set_connector_edid(test, conn, 984 + test_edid_hdmi_1080p_rgb_max_340mhz, 985 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_max_340mhz)); 986 + KUNIT_ASSERT_EQ(test, ret, 0); 987 + 988 + info = &conn->display_info; 989 + KUNIT_ASSERT_TRUE(test, info->is_hdmi); 990 + KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 991 + 992 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 993 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 994 + 995 + preferred = find_preferred_mode(conn); 996 + KUNIT_ASSERT_NOT_NULL(test, preferred); 997 + 998 + /* 999 + * We're making sure that we have headroom on the TMDS character 1000 + * clock to actually use 12bpc. 1001 + */ 1002 + rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 1003 + KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1004 + 1005 + drm = &priv->drm; 1006 + crtc = priv->crtc; 1007 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1008 + KUNIT_EXPECT_EQ(test, ret, 0); 1009 + 1010 + conn_state = conn->state; 1011 + KUNIT_ASSERT_NOT_NULL(test, conn_state); 1012 + 1013 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 8); 1014 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); 1015 + } 1016 + 618 1017 static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { 619 1018 KUNIT_CASE(drm_test_check_hdmi_funcs_reject_rate), 1019 + KUNIT_CASE(drm_test_check_max_tmds_rate_bpc_fallback), 1020 + KUNIT_CASE(drm_test_check_max_tmds_rate_format_fallback), 620 1021 KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_changed), 621 1022 KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_not_changed), 1023 + KUNIT_CASE(drm_test_check_output_bpc_dvi), 1024 + KUNIT_CASE(drm_test_check_output_bpc_format_vic_1), 1025 + KUNIT_CASE(drm_test_check_output_bpc_format_display_8bpc_only), 1026 + KUNIT_CASE(drm_test_check_output_bpc_format_display_rgb_only), 1027 + KUNIT_CASE(drm_test_check_output_bpc_format_driver_8bpc_only), 1028 + KUNIT_CASE(drm_test_check_output_bpc_format_driver_rgb_only), 622 1029 KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_8bpc), 623 1030 KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_10bpc), 624 1031 KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_12bpc),
+160
drivers/gpu/drm/tests/drm_kunit_edid.h
··· 7 7 * edid-decode (hex): 8 8 * 9 9 * 00 ff ff ff ff ff ff 00 31 d8 2a 00 00 00 00 00 10 + * 00 21 01 03 81 a0 5a 78 0a 00 00 00 00 00 00 00 11 + * 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 12 + * 01 01 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c 13 + * 45 00 40 84 63 00 00 1e 00 00 00 fc 00 54 65 73 14 + * 74 20 45 44 49 44 0a 20 20 20 00 00 00 fd 00 32 15 + * 46 1e 46 0f 00 0a 20 20 20 20 20 20 00 00 00 10 16 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ab 17 + * 18 + * ---------------- 19 + * 20 + * Block 0, Base EDID: 21 + * EDID Structure Version & Revision: 1.3 22 + * Vendor & Product Identification: 23 + * Manufacturer: LNX 24 + * Model: 42 25 + * Made in: 2023 26 + * Basic Display Parameters & Features: 27 + * Digital display 28 + * DFP 1.x compatible TMDS 29 + * Maximum image size: 160 cm x 90 cm 30 + * Gamma: 2.20 31 + * RGB color display 32 + * First detailed timing is the preferred timing 33 + * Color Characteristics: 34 + * Red : 0.0000, 0.0000 35 + * Green: 0.0000, 0.0000 36 + * Blue : 0.0000, 0.0000 37 + * White: 0.0000, 0.0000 38 + * Established Timings I & II: none 39 + * Standard Timings: none 40 + * Detailed Timing Descriptors: 41 + * DTD 1: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz (1600 mm x 900 mm) 42 + * Hfront 88 Hsync 44 Hback 148 Hpol P 43 + * Vfront 4 Vsync 5 Vback 36 Vpol P 44 + * Display Product Name: 'Test EDID' 45 + * Display Range Limits: 46 + * Monitor ranges (GTF): 50-70 Hz V, 30-70 kHz H, max dotclock 150 MHz 47 + * Dummy Descriptor: 48 + * Checksum: 0xab 49 + */ 50 + static const unsigned char test_edid_dvi_1080p[] = { 51 + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x31, 0xd8, 0x2a, 0x00, 52 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x01, 0x03, 0x81, 0xa0, 0x5a, 0x78, 53 + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 55 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 56 + 0x2d, 0x40, 0x58, 0x2c, 0x45, 0x00, 0x40, 0x84, 0x63, 0x00, 0x00, 0x1e, 57 + 0x00, 0x00, 0x00, 0xfc, 0x00, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x44, 58 + 0x49, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x32, 59 + 0x46, 0x1e, 0x46, 0x0f, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 60 + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab 62 + }; 63 + 64 + /* 65 + * edid-decode (hex): 66 + * 67 + * 00 ff ff ff ff ff ff 00 31 d8 2a 00 00 00 00 00 10 68 * 00 21 01 03 81 a0 5a 78 02 00 00 00 00 00 00 00 11 69 * 00 00 00 20 00 00 01 01 01 01 01 01 01 01 01 01 12 70 * 01 01 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c ··· 152 94 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x41, 0x02, 0x03, 0x1b, 0x81, 153 95 0xe3, 0x05, 0x00, 0x20, 0x41, 0x10, 0xe2, 0x00, 0x4a, 0x6d, 0x03, 0x0c, 154 96 0x00, 0x12, 0x34, 0x00, 0x28, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 97 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 98 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 99 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 100 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 101 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 102 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 103 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 104 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 105 + 0x00, 0x00, 0x00, 0xd0 106 + }; 107 + 108 + /* 109 + * edid-decode (hex): 110 + * 111 + * 00 ff ff ff ff ff ff 00 31 d8 2a 00 00 00 00 00 112 + * 00 21 01 03 81 a0 5a 78 02 00 00 00 00 00 00 00 113 + * 00 00 00 20 00 00 01 01 01 01 01 01 01 01 01 01 114 + * 01 01 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c 115 + * 45 00 40 84 63 00 00 1e 00 00 00 fc 00 54 65 73 116 + * 74 20 45 44 49 44 0a 20 20 20 00 00 00 fd 00 32 117 + * 46 1e 46 0f 00 0a 20 20 20 20 20 20 00 00 00 10 118 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 92 119 + * 120 + * 02 03 1b 81 e3 05 00 20 41 10 e2 00 4a 6d 03 0c 121 + * 00 12 34 00 28 20 00 00 00 00 00 00 00 00 00 00 122 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 123 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 124 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 125 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 126 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 127 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d0 128 + * 129 + * ---------------- 130 + * 131 + * Block 0, Base EDID: 132 + * EDID Structure Version & Revision: 1.3 133 + * Vendor & Product Identification: 134 + * Manufacturer: LNX 135 + * Model: 42 136 + * Made in: 2023 137 + * Basic Display Parameters & Features: 138 + * Digital display 139 + * DFP 1.x compatible TMDS 140 + * Maximum image size: 160 cm x 90 cm 141 + * Gamma: 2.20 142 + * Monochrome or grayscale display 143 + * First detailed timing is the preferred timing 144 + * Color Characteristics: 145 + * Red : 0.0000, 0.0000 146 + * Green: 0.0000, 0.0000 147 + * Blue : 0.0000, 0.0000 148 + * White: 0.0000, 0.0000 149 + * Established Timings I & II: 150 + * DMT 0x04: 640x480 59.940476 Hz 4:3 31.469 kHz 25.175000 MHz 151 + * Standard Timings: none 152 + * Detailed Timing Descriptors: 153 + * DTD 1: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz (1600 mm x 900 mm) 154 + * Hfront 88 Hsync 44 Hback 148 Hpol P 155 + * Vfront 4 Vsync 5 Vback 36 Vpol P 156 + * Display Product Name: 'Test EDID' 157 + * Display Range Limits: 158 + * Monitor ranges (GTF): 50-70 Hz V, 30-70 kHz H, max dotclock 150 MHz 159 + * Dummy Descriptor: 160 + * Extension blocks: 1 161 + * Checksum: 0x92 162 + * 163 + * ---------------- 164 + * 165 + * Block 1, CTA-861 Extension Block: 166 + * Revision: 3 167 + * Underscans IT Video Formats by default 168 + * Native detailed modes: 1 169 + * Colorimetry Data Block: 170 + * sRGB 171 + * Video Data Block: 172 + * VIC 16: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz 173 + * Video Capability Data Block: 174 + * YCbCr quantization: No Data 175 + * RGB quantization: Selectable (via AVI Q) 176 + * PT scan behavior: No Data 177 + * IT scan behavior: Always Underscanned 178 + * CE scan behavior: Always Underscanned 179 + * Vendor-Specific Data Block (HDMI), OUI 00-0C-03: 180 + * Source physical address: 1.2.3.4 181 + * Maximum TMDS clock: 340 MHz 182 + * Extended HDMI video details: 183 + * Checksum: 0xd0 Unused space in Extension Block: 100 bytes 184 + */ 185 + static const unsigned char test_edid_hdmi_1080p_rgb_max_340mhz[] = { 186 + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x31, 0xd8, 0x2a, 0x00, 187 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x01, 0x03, 0x81, 0xa0, 0x5a, 0x78, 188 + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 189 + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 190 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 191 + 0x2d, 0x40, 0x58, 0x2c, 0x45, 0x00, 0x40, 0x84, 0x63, 0x00, 0x00, 0x1e, 192 + 0x00, 0x00, 0x00, 0xfc, 0x00, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x44, 193 + 0x49, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x32, 194 + 0x46, 0x00, 0x00, 0xc4, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 195 + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 196 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x41, 0x02, 0x03, 0x1b, 0x81, 197 + 0xe3, 0x05, 0x00, 0x20, 0x41, 0x10, 0xe2, 0x00, 0x4a, 0x6d, 0x03, 0x0c, 198 + 0x00, 0x12, 0x34, 0x00, 0x44, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 155 199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 156 200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 157 201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,