2022-10-14 10:03:35 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
2023-07-05 13:49:51 +02:00
|
|
|
#include <stdbool.h>
|
2023-07-06 12:06:36 +02:00
|
|
|
#include <assert.h>
|
2022-10-14 10:03:35 +02:00
|
|
|
|
|
|
|
#include <libdisplay-info/info.h>
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
str_or_null(const char *str)
|
|
|
|
{
|
|
|
|
return str ? str : "{null}";
|
|
|
|
}
|
|
|
|
|
2023-07-05 13:49:51 +02:00
|
|
|
static const char *
|
|
|
|
yes_no(bool cond)
|
|
|
|
{
|
|
|
|
return cond ? "yes" : "no";
|
|
|
|
}
|
|
|
|
|
2023-07-06 12:06:36 +02:00
|
|
|
static void
|
|
|
|
print_chromaticity(const char *prefix, const struct di_chromaticity_cie1931 *c)
|
|
|
|
{
|
|
|
|
printf("%s: %.3f, %.3f\n", prefix, c->x, c->y);
|
|
|
|
}
|
|
|
|
|
2022-10-14 10:03:35 +02:00
|
|
|
static void
|
|
|
|
print_info(const struct di_info *info)
|
|
|
|
{
|
2023-07-05 13:49:51 +02:00
|
|
|
const struct di_hdr_static_metadata *hdr_static;
|
2023-07-06 12:06:36 +02:00
|
|
|
const struct di_color_primaries *primaries;
|
2023-07-06 15:23:15 +02:00
|
|
|
const struct di_supported_signal_colorimetry *ssc;
|
2022-10-14 10:03:35 +02:00
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = di_info_get_make(info);
|
|
|
|
printf("make: %s\n", str_or_null(str));
|
|
|
|
free(str);
|
|
|
|
|
|
|
|
str = di_info_get_model(info);
|
|
|
|
printf("model: %s\n", str_or_null(str));
|
|
|
|
free(str);
|
|
|
|
|
|
|
|
str = di_info_get_serial(info);
|
|
|
|
printf("serial: %s\n", str_or_null(str));
|
|
|
|
free(str);
|
2023-07-06 12:06:36 +02:00
|
|
|
|
2023-07-05 13:49:51 +02:00
|
|
|
hdr_static = di_info_get_hdr_static_metadata(info);
|
|
|
|
assert(hdr_static);
|
|
|
|
printf("HDR static metadata:\n"
|
|
|
|
"luminance %f-%f, maxFALL %f\n"
|
|
|
|
"metadata type1=%s\n"
|
|
|
|
"EOTF tSDR=%s, tHDR=%s, PQ=%s, HLG=%s\n",
|
|
|
|
hdr_static->desired_content_min_luminance,
|
|
|
|
hdr_static->desired_content_max_luminance,
|
|
|
|
hdr_static->desired_content_max_frame_avg_luminance,
|
|
|
|
yes_no(hdr_static->type1),
|
|
|
|
yes_no(hdr_static->traditional_sdr),
|
|
|
|
yes_no(hdr_static->traditional_hdr),
|
|
|
|
yes_no(hdr_static->pq),
|
|
|
|
yes_no(hdr_static->hlg));
|
|
|
|
|
2023-07-06 12:06:36 +02:00
|
|
|
primaries = di_info_get_default_color_primaries(info);
|
|
|
|
assert(primaries);
|
|
|
|
printf("default color primaries:\n");
|
|
|
|
print_chromaticity(" red", &primaries->primary[0]);
|
|
|
|
print_chromaticity(" green", &primaries->primary[1]);
|
|
|
|
print_chromaticity(" blue", &primaries->primary[2]);
|
|
|
|
print_chromaticity("default white", &primaries->default_white);
|
2023-07-06 15:23:15 +02:00
|
|
|
|
2023-07-11 12:50:38 +02:00
|
|
|
printf("default gamma: %.2f\n", di_info_get_default_gamma(info));
|
|
|
|
|
2023-07-06 15:23:15 +02:00
|
|
|
ssc = di_info_get_supported_signal_colorimetry(info);
|
|
|
|
assert(ssc);
|
|
|
|
printf("signal colorimetry:");
|
|
|
|
if (ssc->bt2020_cycc)
|
|
|
|
printf(" BT2020_cYCC");
|
|
|
|
if (ssc->bt2020_ycc)
|
|
|
|
printf(" BT2020_YCC");
|
|
|
|
if (ssc->bt2020_rgb)
|
|
|
|
printf(" BT2020_RGB");
|
|
|
|
if (ssc->st2113_rgb)
|
|
|
|
printf(" P3D65+P3DCI");
|
|
|
|
if (ssc->ictcp)
|
|
|
|
printf(" ICtCp");
|
|
|
|
printf("\n");
|
2022-10-14 10:03:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
FILE *in;
|
|
|
|
static uint8_t raw[32 * 1024];
|
|
|
|
size_t size = 0;
|
|
|
|
struct di_info *info;
|
|
|
|
|
|
|
|
in = stdin;
|
|
|
|
if (argc > 1) {
|
|
|
|
in = fopen(argv[1], "r");
|
|
|
|
if (!in) {
|
|
|
|
perror("failed to open input file");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!feof(in)) {
|
|
|
|
size += fread(&raw[size], 1, sizeof(raw) - size, in);
|
|
|
|
if (ferror(in)) {
|
|
|
|
perror("fread failed");
|
|
|
|
return 1;
|
|
|
|
} else if (size >= sizeof(raw)) {
|
|
|
|
fprintf(stderr, "input too large\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(in);
|
|
|
|
|
|
|
|
info = di_info_parse_edid(raw, size);
|
|
|
|
if (!info) {
|
|
|
|
perror("di_edid_parse failed");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_info(info);
|
|
|
|
di_info_destroy(info);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|