ABI compatibility
Before we go too far into this project, it would be good to figure out how to design a stable ABI.
The problem we're trying to solve is make it so /usr/bin/my-compositor
compiled with an old libdisplay-info should still work with a newer /usr/lib/libdisplay-info.so
. IOW, we want to be able to upgrade libdisplay-info without breaking users. (We've also discussed about libdisplay-info downgrades but the benefits of caring about that case are unclear.)
EDIDs has a lot of fields organized into blocks and sections, and we'd like to expose these fields to our users. For instance, low-level basic digital display parameters include the bit depth (undefined/6/8/10/12/…) and video interface (undefined/HDMI-A/HDMI-B/MDDI/DisplayPort). (Note, other blocks/sections have a lot more fields.)
A related problem is that some EDID sections and fields can be omitted by manufacturers.
We discussed a few options yesterday on IRC. (cc @pq)
Provide getters for each individual field
This is the easiest way to guarantee a stable ABI: provide one getter function per field.
int di_edid_get_digital_bit_depth(const struct di_edid *edid);
enum di_edid_digital_video_interface di_edid_get_digital_video_interface(const struct di_edid *edid);
Provide getters for structs
This is a nicer API, but needs some effort to guarantee ABI compatibility.
struct di_edid_basic_digital {
int bit_depth;
enum di_edid_digital_video_interface video_interface;
};
void di_edid_get_basic_digital(const struct di_edid *edid, struct di_edid_basic_digital *digital);
ABI compatibility issues arise because libdisplay-info may try to fill up fields introduced in a newer version of the library.
@pq has suggested versioning each struct. I think letting users provide a version number when creating the struct di_edid
could work as well.
Alternatively, the library could allocate and return the struct:
struct di_edid_basic_digital *di_edid_get_basic_digital(const struct di_edid *edid);