tests/edid: Test EDID CTA-861 parsing code

Parses a real-world EDID blob with CTA-861 EDID extension and compares
it to edid-decode output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2351>
This commit is contained in:
Sebastian Wick 2022-03-25 20:15:31 +01:00 committed by Jonas Ådahl
parent 64362fcd76
commit 14b7da4292
3 changed files with 87 additions and 0 deletions

View File

@ -27,6 +27,8 @@
#include <stdint.h>
#include "core/util-private.h"
typedef struct _MetaEdidInfo MetaEdidInfo;
typedef struct _MetaEdidTiming MetaEdidTiming;
typedef struct _MetaEdidDetailedTiming MetaEdidDetailedTiming;
@ -230,6 +232,7 @@ struct _MetaEdidInfo
MetaEdidHdrStaticMetadata hdr_static_metadata;
};
META_EXPORT_TEST
MetaEdidInfo *meta_edid_info_new_parse (const uint8_t *data);
#endif

79
src/tests/edid-tests.c Normal file
View File

@ -0,0 +1,79 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2022 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib.h>
#include "backends/edid.h"
/* GSM 23507, DisplayHDR certified */
unsigned char edid_blob[] = {
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x1e, 0x6d, 0xd3, 0x5b,
0xf4, 0xe7, 0x1d, 0x00, 0x02, 0x20, 0x01, 0x04, 0xb5, 0x46, 0x27, 0x78,
0x9d, 0x8c, 0xb5, 0xaf, 0x4f, 0x43, 0xab, 0x26, 0x0e, 0x50, 0x54, 0x21,
0x08, 0x00, 0xd1, 0xc0, 0x61, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0xec, 0x00, 0xa0, 0xa0, 0xa0,
0x67, 0x50, 0x30, 0x20, 0x3a, 0x00, 0xb9, 0x88, 0x21, 0x00, 0x00, 0x1a,
0x00, 0x00, 0x00, 0xfd, 0x0c, 0x30, 0xa5, 0x03, 0x03, 0x46, 0x01, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x4c,
0x47, 0x20, 0x55, 0x4c, 0x54, 0x52, 0x41, 0x47, 0x45, 0x41, 0x52, 0x0a,
0x00, 0x00, 0x00, 0xff, 0x00, 0x32, 0x30, 0x32, 0x4d, 0x41, 0x50, 0x4e,
0x47, 0x59, 0x46, 0x32, 0x34, 0x0a, 0x02, 0x8d, 0x02, 0x03, 0x2d, 0x71,
0x23, 0x09, 0x06, 0x07, 0xe2, 0x00, 0x6a, 0xe3, 0x05, 0xc0, 0x00, 0xe6,
0x06, 0x05, 0x01, 0x61, 0x61, 0x4f, 0x48, 0x10, 0x04, 0x03, 0x01, 0x1f,
0x13, 0x3f, 0x40, 0x6d, 0x1a, 0x00, 0x00, 0x02, 0x05, 0x30, 0xa5, 0x00,
0x04, 0x61, 0x4f, 0x61, 0x4f, 0x56, 0x5e, 0x00, 0xa0, 0xa0, 0xa0, 0x29,
0x50, 0x30, 0x20, 0x35, 0x00, 0xb9, 0x88, 0x21, 0x00, 0x00, 0x1a, 0x5a,
0xa0, 0x00, 0xa0, 0xa0, 0xa0, 0x46, 0x50, 0x30, 0x20, 0x3a, 0x00, 0xb9,
0x88, 0x21, 0x00, 0x00, 0x00, 0x6f, 0xc2, 0x00, 0xa0, 0xa0, 0xa0, 0x55,
0x50, 0x30, 0x20, 0x3a, 0x00, 0xb9, 0x88, 0x21, 0x00, 0x00, 0x1a, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2f, 0x70, 0x12, 0x79, 0x03, 0x00, 0x03, 0x00, 0x14,
0x3d, 0x11, 0x01, 0x84, 0xff, 0x09, 0x9f, 0x00, 0x2f, 0x80, 0x1f, 0x00,
0x9f, 0x05, 0x76, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x90
};
unsigned int edid_blob_len = 384;
int
main (int argc,
char **argv)
{
MetaEdidInfo *edid;
edid = meta_edid_info_new_parse (edid_blob);
g_assert (edid != NULL);
g_assert (strcmp (edid->manufacturer_code, "GSM") == 0);
g_assert (edid->product_code == 23507);
g_assert (edid->hdr_static_metadata.max_luminance == 97);
g_assert (edid->hdr_static_metadata.tf ==
(META_EDID_TF_TRADITIONAL_GAMMA_SDR | META_EDID_TF_PQ));
g_assert (edid->colorimetry ==
(META_EDID_COLORIMETRY_BT2020YCC | META_EDID_COLORIMETRY_BT2020RGB));
}

View File

@ -201,6 +201,11 @@ test_cases += [
'suite': 'unit',
'sources': [ 'anonymous-file.c', ],
},
{
'name': 'edid',
'suite': 'unit',
'sources': [ 'edid-tests.c', ],
},
]
if have_native_tests