libdisplay-info/info.c
Simon Ser c383417629 edid: prefix private functions with "_di_"
The extra underscore indicates that it's not a function which is
part of our public API. This will allow the next commit to setup the
linker to export functions based on their name.

Signed-off-by: Simon Ser <contact@emersion.fr>
2022-06-14 11:40:07 +00:00

58 lines
1.1 KiB
C

#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
edid = _di_edid_parse(data, size);
if (!edid)
return NULL;
info = calloc(1, sizeof(*info));
if (!info) {
_di_edid_destroy(edid);
return NULL;
}
info->edid = edid;
return info;
}
void
di_info_destroy(struct di_info *info)
{
_di_edid_destroy(info->edid);
free(info);
}
const struct di_edid *
di_info_get_edid(const struct di_info *info)
{
return info->edid;
}
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);
}