General API structure
From our previous discussions (ref !3 (merged)) it seems like the consensus is to have two API tiers:
- A low-level API mirroring the EDID and DisplayID specs
- A high-level API exposing simple and easy-to-use helpers for common metadata compositors are interested in
How does this translate to a C API?
There's a related discussion about this in !2 (comment 1311164). The general idea is:
/* Low-level EDID API */
struct di_edid;
struct di_edid *
di_edid_parse(const void *data, size_t size);
void
di_edid_destroy(struct di_edid *edid);
int
di_edid_get_version(const struct di_edid *edid);
int
di_edid_get_revision(const struct di_edid *edid);
void
di_edid_get_vendor_product(const struct di_edid *edid,
struct di_edid_vendor_product *vendor_product);
/* etc */
/* Low-level DisplayID API */
struct di_displayid;
struct di_displayid *
di_displayid_parse(const void *data, size_t size);
void
di_displayid_destroy(struct di_displayid *displayid);
/* etc */
/* High-level API (uses low-level APIs internally) */
struct di_info;
struct di_info *
di_info_parse_edid(const void *data, size_t size);
struct di_info *
di_info_parse_displayid(const void *data, size_t size);
void
di_info_destroy(struct di_info *info);
/* Returns the EDID if any */
const struct di_edid *
di_info_get_edid(const struct di_info *info);
/* Returns the DisplayID if any (standalone or embedded in an EDID block) */
const struct di_displayid *
di_info_get_displayid(const struct di_info *info);
/* Returns the serial number string, looking first at the DisplayID if any,
* falling back to the EDID otherwise. */
char *
di_info_get_serial(const struct di_info *info);
/* etc */
Edited by Simon Ser