[PATCH 1/3][V2] tools/amd_hdmi_compliance: Additional functionalities
Rodrigo Siqueira Jordao
Rodrigo.Siqueira at amd.com
Tue Oct 29 22:17:02 UTC 2024
On 10/29/24 11:03 AM, Alex Hung wrote:
> From: Wayne Lin <Wayne.Lin at amd.com>
>
> It needs different timings, pixel format and color depth combination
> to pass CTS under different HDMI versions. As the result, we extend
> this to:
>
> - Add additional timings and info. Especially aspect ratio which
> will impact the VIC code.
> - Can specify the connector to display the test pattern.
> - Set connector property "max bpc" to force bpc.
> - Set connector debugfs entry "force_yuv420_output" to enable
> using yuv420 pixel format.
>
> Signed-off-by: Wayne Lin <wayne.lin at amd.com>
> Signed-off-by: Alex Hung <alex.hung at amd.com>
> Signed-off-by: Stylon Wang <stylon.wang at amd.com>
> ---
> tools/amd_hdmi_compliance.c | 432 ++++++++++++++++++++++++++++++++----
> 1 file changed, 390 insertions(+), 42 deletions(-)
>
> diff --git a/tools/amd_hdmi_compliance.c b/tools/amd_hdmi_compliance.c
> index 1a7592995..d80ebeba7 100644
> --- a/tools/amd_hdmi_compliance.c
> +++ b/tools/amd_hdmi_compliance.c
> @@ -21,6 +21,8 @@
> */
>
> #include "igt.h"
> +#include "igt_sysfs.h"
> +#include <fcntl.h>
>
> /* Common test data */
> typedef struct data {
> @@ -36,52 +38,340 @@ typedef struct data {
>
> /* Video modes indexed by VIC */
> static drmModeModeInfo test_modes[] = {
> - [1] = { 25175,
> + [0] = { 25175,
> 640, 656, 752, 800, 0,
> 480, 489, 492, 525, 0,
> - 60, 0xa, 0x40,
> - "640x480", /* VIC 1 */
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_4_3,
> + 0x40, "640x480", /* VIC 0 */
> + },
> + [1] = { 25175,
> + 640, 656, 752, 800, 0,
> + 480, 490, 492, 525, 0,
> + 60, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_PIC_AR_4_3,
> + 0x40, "640x480", /* VIC 1 */
> + },
> + [2] = { 27000,
> + 720, 736, 798, 858, 0,
> + 480, 489, 495, 525, 0,
> + 60, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_PIC_AR_4_3,
> + 0x40, "720x480", /* VIC 2 */
> + },
> + [3] = { 27000,
> + 720, 736, 798, 858, 0,
> + 480, 489, 495, 525, 0,
> + 60, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "720x480", /* VIC 3 */
> + },
> + [4] = { 74250,
> + 1280, 1390, 1430, 1650, 0,
> + 720, 725, 730, 750, 0,
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "1280x720", /* VIC 4 */
> + },
> + [16] = { 148500,
> + 1920, 2008, 2052, 2200, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "1920x1080", /* VIC 16 */
> + },
> + [17] = { 27000,
> + 720, 732, 796, 864, 0,
> + 576, 581, 586, 625, 0,
> + 60, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_PIC_AR_4_3,
> + 0x40, "720x576", /* VIC 17 */
> + },
> + [18] = { 27000,
> + 720, 732, 796, 864, 0,
> + 576, 581, 586, 625, 0,
> + 60, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "720x576", /* VIC 18 */
> + },
> + [19] = { 74250,
> + 1280, 1720, 1760, 1980, 0,
> + 720, 725, 730, 750, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "1280x720", /* VIC 19 */
> + },
> + [31] = { 148500,
> + 1920, 2448, 2492, 2640, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "1920x1080", /* VIC 31 */
> + },
> + [63] = { 297000,
> + 1920, 2008, 2052, 2200, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 120, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "1920x1080", /* VIC 63 */
> + },
> + [64] = { 297000,
> + 1920, 2448, 2492, 2640, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 100, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "1920x1080", /* VIC 64 */
> + },
> + [65] = { 59400,
> + 1280, 3040, 3080, 3300, 0,
> + 720, 725, 730, 750, 0,
> + 24, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1280x720", /* VIC 65 */
> + },
> + [66] = { 74250,
> + 1280, 3700, 3740, 3960, 0,
> + 720, 725, 730, 750, 0,
> + 25, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1280x720", /* VIC 66 */
> + },
> + [67] = { 74250,
> + 1280, 3040, 3080, 3300, 0,
> + 720, 725, 730, 750, 0,
> + 30, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1280x720", /* VIC 67 */
> + },
> + [68] = { 74250,
> + 1280, 1720, 1760, 1980, 0,
> + 720, 725, 730, 750, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1280x720", /* VIC 68 */
> + },
> + [69] = { 74250,
> + 1280, 1390, 1430, 1650, 0,
> + 720, 725, 730, 750, 0,
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1280x720", /* VIC 69 */
> + },
> + [70] = { 148500,
> + 1280, 1720, 1760, 1980, 0,
> + 720, 725, 730, 750, 0,
> + 100, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1280x720", /* VIC 70 */
> + },
> + [71] = { 148500,
> + 1280, 1390, 1430, 1650, 0,
> + 720, 725, 730, 750, 0,
> + 120, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1280x720", /* VIC 71 */
> + },
> + [72] = { 74250,
> + 1920, 2558, 2602, 2750, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 24, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1920x1080", /* VIC 72 */
> + },
> + [73] = { 74250,
> + 1920, 2448, 2492, 2640, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 25, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1920x1080", /* VIC 74 */
> + },
> + [74] = { 74250,
> + 1920, 2008, 2052, 2200, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 30, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1920x1080", /* VIC 74 */
> + },
> + [75] = { 148500,
> + 1920, 2448, 2492, 2640, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1920x1080", /* VIC 75 */
> + },
> + [76] = { 148500,
> + 1920, 2008, 2052, 2200, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1920x1080", /* VIC 76 */
> + },
> + [77] = { 297000,
> + 1920, 2448, 2492, 2640, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1920x1080", /* VIC 77 */
> + },
> + [78] = { 297000,
> + 1920, 2008, 2052, 2200, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1920x1080", /* VIC 78 */
> + },
> + [79] = { 59400,
> + 1680, 3040, 3080, 3300, 0,
> + 720, 725, 730, 750, 0,
> + 24, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1680x720", /* VIC 79 */
> + },
> + [80] = { 59400,
> + 1680, 2908, 2948, 3168, 0,
> + 720, 725, 730, 750, 0,
> + 25, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1680x720", /* VIC 80 */
> + },
> + [81] = { 59400,
> + 1680, 2380, 2420, 2640, 0,
> + 720, 725, 730, 750, 0,
> + 30, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1680x720", /* VIC 81 */
> + },
> + [82] = { 82500,
> + 1680, 1940, 1980, 2200, 0,
> + 720, 725, 730, 750, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1680x720", /* VIC 82 */
> + },
> + [83] = { 99000,
> + 1680, 1940, 1980, 2200, 0,
> + 720, 725, 730, 750, 0,
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1680x720", /* VIC 83 */
> + },
> + [84] = { 165000,
> + 1680, 1740, 1780, 2000, 0,
> + 720, 725, 730, 825, 0,
> + 100, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1680x720", /* VIC 84 */
> + },
> + [85] = { 198000,
> + 1680, 1740, 1780, 2000, 0,
> + 720, 725, 730, 825, 0,
> + 120, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "1680x720", /* VIC 85 */
> + },
> + [86] = { 99000,
> + 2560, 3558, 3602, 3750, 0,
> + 1080, 1084, 1089, 1100, 0,
> + 24, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "2560x1080", /* VIC 86 */
> + },
> + [87] = { 90000,
> + 2560, 3008, 3052, 3200, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 25, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "2560x1080", /* VIC 87 */
> + },
> + [88] = { 118800,
> + 2560, 3328, 3372, 3520, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 30, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "2560x1080", /* VIC 88 */
> + },
> + [89] = { 185625,
> + 2560, 3108, 3152, 3300, 0,
> + 1080, 1084, 1089, 1125, 0,
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "2560x1080", /* VIC 89 */
> + },
> + [90] = { 198000,
> + 2560, 2808, 2852, 3000, 0,
> + 1080, 1084, 1089, 1100, 0,
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "2560x1080", /* VIC 90 */
> + },
> + [91] = { 371250,
> + 2560, 2778, 2822, 2970, 0,
> + 1080, 1084, 1089, 1250, 0,
> + 100, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "2560x1080", /* VIC 91 */
> + },
> + [92] = { 495000,
> + 2560, 3108, 3152, 3300, 0,
> + 1080, 1084, 1089, 1250, 0,
> + 120, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "2560x1080", /* VIC 92 */
> + },
> + [93] = { 297000,
> + 3840, 5116, 5204, 5500, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 24, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "4096x2160", /* VIC 93 */
> + },
> + [94] = { 297000,
> + 3840, 4896, 4984, 5280, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 25, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "3840x2160", /* VIC 94 */
> + },
> + [95] = { 297000,
> + 3840, 4016, 4104, 4400, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 30, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "3840x2160", /* VIC 95 */
> },
> [96] = { 594000,
> 3840, 4896, 4984, 5280, 0,
> 2160, 2168, 2178, 2250, 0,
> - 50, 0x5|DRM_MODE_FLAG_PIC_AR_16_9, 0x40,
> - "3840x2160", /* VIC 96 */
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "3840x2160", /* VIC 96 */
> },
> [97] = { 594000,
> 3840, 4016, 4104, 4400, 0,
> 2160, 2168, 2178, 2250, 0,
> - 60, 0x5|DRM_MODE_FLAG_PIC_AR_16_9, 0x40,
> - "3840x2160", /* VIC 97 */
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_16_9,
> + 0x40, "3840x2160", /* VIC 97 */
> + },
> + [98] = { 297000,
> + 4096, 5116, 5204, 5500, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 24, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_256_135,
> + 0x40, "4096x2160", /* VIC 98 */
> + },
> + [99] = { 297000,
> + 4096, 5064, 5152, 5280, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 25, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_256_135,
> + 0x40, "4096x2160", /* VIC 99 */
> + },
> + [100] = { 297000,
> + 4096, 4184, 4272, 4400, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 30, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_256_135,
> + 0x40, "4096x2160", /* VIC 100 */
> },
> [101] = { 594000,
> 4096, 5064, 5152, 5280, 0,
> 2160, 2168, 2178, 2250, 0,
> - 50, 0x5|DRM_MODE_FLAG_PIC_AR_256_135, 0x40,
> - "4096x2160", /* VIC 101 */
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_256_135,
> + 0x40, "4096x2160", /* VIC 101 */
> },
> [102] = { 594000,
> 4096, 4184, 4272, 4400, 0,
> 2160, 2168, 2178, 2250, 0,
> - 60, 0x5|DRM_MODE_FLAG_PIC_AR_256_135, 0x40,
> - "4096x2160", /* VIC 102 */
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_256_135,
> + 0x40, "4096x2160", /* VIC 102 */
> + },
> + [103] = { 297000,
> + 3840, 5116, 5204, 5500, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 24, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "4096x2160", /* VIC 103 */
> + },
> + [104] = { 297000,
> + 3840, 4896, 4984, 5280, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 25, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "3840x2160", /* VIC 104 */
> + },
> + [105] = { 297000,
> + 3840, 4016, 4104, 4400, 0,
> + 2160, 2168, 2178, 2250, 0,
> + 30, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "3840x2160", /* VIC 105 */
> },
> [106] = { 594000,
> 3840, 4896, 4984, 5280, 0,
> 2160, 2168, 2178, 2250, 0,
> - 50, 0x5|DRM_MODE_FLAG_PIC_AR_64_27, 0x40,
> - "3840x2160", /* VIC 106 */
> + 50, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "3840x2160", /* VIC 106 */
> },
> [107] = { 594000,
> 3840, 4016, 4104, 4400, 0,
> 2160, 2168, 2178, 2250, 0,
> - 60, 0x5|DRM_MODE_FLAG_PIC_AR_64_27, 0x40,
> - "3840x2160", /* VIC 107 */
> + 60, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_PIC_AR_64_27,
> + 0x40, "3840x2160", /* VIC 107 */
> },
> };
>
> /* Common test setup. */
> -static void test_init(data_t *data)
> +static void test_init(data_t *data, int conn_id)
> {
> igt_display_t *display = &data->display;
>
> @@ -90,19 +380,22 @@ static void test_init(data_t *data)
>
> igt_display_reset(display);
>
> - /* find a connected HDMI output */
> + /* find a connected output */
> data->output = NULL;
> for (int i=0; i < data->display.n_outputs; ++i) {
> - drmModeConnector *connector = data->display.outputs[i].config.connector;
> - if (connector->connection == DRM_MODE_CONNECTED &&
> - (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
> - (data->use_virtual_connector &&
> - connector->connector_type == DRM_MODE_CONNECTOR_VIRTUAL))) {
> + drmModeConnector *conn = data->display.outputs[i].config.connector;
> +
> + if ((data->use_virtual_connector &&
> + conn->connector_type == DRM_MODE_CONNECTOR_VIRTUAL) ||
> + (conn->connector_type == DRM_MODE_CONNECTOR_HDMIA &&
> + conn->connection == DRM_MODE_CONNECTED &&
> + (conn_id == 0 || conn->connector_id == conn_id))) {
> data->output = &data->display.outputs[i];
> + break;
> }
> }
>
> - igt_require(data->output);
> + igt_require_f(data->output, "No valid connectors found\n");
>
> data->primary =
> igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY);
> @@ -123,22 +416,57 @@ static void wait_for_keypress(void)
> ;
> }
>
> -static void test_vic_mode(data_t *data, int vic)
> +/* Write 0 or 1 to debugfs entry "force_yuv420_output" of connector */
> +static void set_force_yuv420(data_t *data, int force, int conn_id)
> +{
> + int fd, res;
> +
> + test_init(data, conn_id);
> +
> + igt_info("Setting force_yuv420_output to %d on connector id %d\n",
> + force ? 1 : 0, data->output->config.connector->connector_id);
> +
> + fd = igt_debugfs_connector_dir(data->fd, data->output->name, O_RDONLY);
> + igt_assert(fd >= 0);
> +
> + res = igt_sysfs_write(fd, "force_yuv420_output", force ? "1" : "0", 2);
> + igt_require(res > 0);
> +
> + close(fd);
> + test_fini(data);
> +}
> +
> +/* Set "max bpc" property of connector */
> +static void set_max_bpc(data_t *data, int max_bpc, int conn_id)
> +{
> + igt_display_t *display = &data->display;
> +
> + test_init(data, conn_id);
> +
> + igt_info("Setting max bpc to %d on connector id %d\n",
> + max_bpc, data->output->config.connector->connector_id);
> + igt_output_set_prop_value(data->output, IGT_CONNECTOR_MAX_BPC, max_bpc);
> + igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
> +
> + test_fini(data);
> +}
> +
> +/* Override video mode with specified VIC. */
> +static void test_vic_mode(data_t *data, int vic, int conn_id)
> {
> igt_display_t *display = &data->display;
> drmModeModeInfo *mode;
> igt_fb_t afb;
>
> - test_init(data);
> + test_init(data, conn_id);
>
> mode = &test_modes[vic];
>
> + igt_info("Setting mode %s on connector id %d\n",
> + mode->name, data->output->config.connector->connector_id);
> igt_output_override_mode(data->output, mode);
> -
> igt_create_pattern_fb(data->fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, 0, &afb);
> -
> igt_plane_set_fb(data->primary, &afb);
> -
> igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
>
> igt_info("Press [Enter] to finish\n");
> @@ -147,20 +475,27 @@ static void test_vic_mode(data_t *data, int vic)
> test_fini(data);
> }
>
> -const char *optstr = "hvt:";
> +const char *optstr = "hvt:i:b:y:";
> static void usage(const char *name)
> {
> - igt_info("Usage: %s [options]\n", name);
> - igt_info("-h Show help\n");
> - igt_info("-t vic Select video mode based on VIC\n");
> - igt_info("-v Test on 'Virtual' connector as well, for debugging.\n");
> + igt_info("Usage: %s options\n", name);
> + igt_info("-h Show help\n");
> + igt_info("-t vic Select video mode based on VIC\n");
> + igt_info("-v Test on 'Virtual' connector as well, for debugging.\n");
> + igt_info("-i conn_id Use connector by ID\n");
> + igt_info("-b max_bpc Set \"max bpc\" connector property\n");
> + igt_info("-y 0|1 Write 0 or 1 to connector's debugfs force_yuv420_output\n");
> + igt_info("NOTE: if -i is not specified, first connected HDMI connector will be used for -t, -b and -y\n");
> }
>
> int main(int argc, char **argv)
> {
> data_t data;
> int c;
> - int vic = 1; /* default to VIC 1 (640x480) */
> + int vic = 0;
> + int conn_id = 0;
> + int max_bpc = 0;
> + int force_yuv_420 = -1;
>
> memset(&data, 0, sizeof(data));
>
> @@ -169,9 +504,18 @@ int main(int argc, char **argv)
> case 't':
> vic = atoi(optarg);
> break;
> + case 'i':
> + conn_id = atoi(optarg);
> + break;
> case 'v':
> data.use_virtual_connector = true;
> break;
> + case 'b':
> + max_bpc = atoi(optarg);
> + break;
> + case 'y':
> + force_yuv_420 = atoi(optarg);
> + break;
> default:
> case 'h':
> usage(argv[0]);
> @@ -179,13 +523,6 @@ int main(int argc, char **argv)
> }
> }
>
> - if (vic < 1 ||
> - vic > ARRAY_SIZE(test_modes) ||
> - !test_modes[vic].name[0]) {
> - igt_warn("VIC %d is not supported\n", vic);
> - exit(EXIT_FAILURE);
> - }
> -
> data.fd = drm_open_driver_master(DRIVER_ANY);
> kmstest_set_vt_graphics_mode();
>
> @@ -193,7 +530,18 @@ int main(int argc, char **argv)
> igt_require(data.display.is_atomic);
> igt_display_require_output(&data.display);
>
> - test_vic_mode(&data, vic);
> + if (force_yuv_420 >= 0)
> + set_force_yuv420(&data, force_yuv_420, conn_id);
> +
> + if (max_bpc)
> + set_max_bpc(&data, max_bpc, conn_id);
> +
> + if (vic >= 0) {
> + if (vic > ARRAY_SIZE(test_modes) || !test_modes[vic].name[0])
> + igt_warn("VIC %d is not supported\n", vic);
> + else
> + test_vic_mode(&data, vic, conn_id);
> + }
>
> igt_display_fini(&data.display);
> }
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
More information about the igt-dev
mailing list