2022-04-10 11:29:06 +02:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdio.h>
|
2022-04-10 11:07:42 +02:00
|
|
|
#include <stdlib.h>
|
2022-04-10 11:29:06 +02:00
|
|
|
#include <string.h>
|
2022-04-10 11:07:42 +02:00
|
|
|
|
|
|
|
#include "edid.h"
|
|
|
|
#include "info.h"
|
|
|
|
|
|
|
|
struct di_info *
|
|
|
|
di_info_parse_edid(const void *data, size_t size)
|
|
|
|
{
|
|
|
|
struct di_edid *edid;
|
|
|
|
struct di_info *info;
|
|
|
|
|
2022-06-09 14:45:47 +02:00
|
|
|
edid = _di_edid_parse(data, size);
|
2022-04-10 11:07:42 +02:00
|
|
|
if (!edid)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
info = calloc(1, sizeof(*info));
|
|
|
|
if (!info) {
|
2022-06-09 14:45:47 +02:00
|
|
|
_di_edid_destroy(edid);
|
2022-04-10 11:07:42 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->edid = edid;
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
di_info_destroy(struct di_info *info)
|
|
|
|
{
|
2022-06-09 14:45:47 +02:00
|
|
|
_di_edid_destroy(info->edid);
|
2022-04-10 11:07:42 +02:00
|
|
|
free(info);
|
|
|
|
}
|
2022-05-03 12:04:11 +02:00
|
|
|
|
|
|
|
const struct di_edid *
|
|
|
|
di_info_get_edid(const struct di_info *info)
|
|
|
|
{
|
|
|
|
return info->edid;
|
|
|
|
}
|
2022-04-10 11:29:06 +02:00
|
|
|
|
|
|
|
char *
|
|
|
|
di_info_get_product_name(const struct di_info *info)
|
|
|
|
{
|
|
|
|
char name[64];
|
|
|
|
const struct di_edid_vendor_product *edid_vendor_product;
|
|
|
|
|
|
|
|
edid_vendor_product = di_edid_get_vendor_product(info->edid);
|
|
|
|
|
|
|
|
/* TODO: use strings from Detailed Timing Descriptors, if any */
|
|
|
|
snprintf(name, sizeof(name), "%.3s 0x%X" PRIu16 " 0x%X" PRIu32,
|
|
|
|
edid_vendor_product->manufacturer,
|
|
|
|
edid_vendor_product->product,
|
|
|
|
edid_vendor_product->serial);
|
|
|
|
|
|
|
|
return strdup(name);
|
|
|
|
}
|