EDID(9)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’– edid β€” VESA Extended Display Identification Data πŸ’–

okay so this is from the EDID(9) page in the Kernel Developer's Manual β€” it's the little kernel API that reads what your monitor is, bestie. let's get into it ✨


🌸 NAME 🌸

edid β€” VESA Extended Display Identification Data

like, it's the vibe check your monitor does on itself so the kernel knows what it's working with πŸ’…


✨ SYNOPSIS ✨

grab these headers first, they're the whole entrance fee:

#include <dev/videomode/videomode.h>
#include <dev/videomode/edidvar.h>
#include <dev/videomode/edidreg.h>

and here's the three functions, exactly as they are, no cap:

int
edid_is_valid(uint8_t *data);

int
edid_parse(uint8_t *data, struct edid_info *info);

void
edid_print(struct edid_info *info);

πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions are literally the support squad for parsing Extended Display Identification Data β€” that's the data that describes a display device, like a monitor or a flat panel display πŸ–₯️✨

  • edid_is_valid() β€” this one just tests if the EDID block in data contains valid data. simple as that. and what's the test, you ask? it includes a verification of the checksum, and it also checks that valid vendor and product idenfication data is present. also lowkey important: the data block must contain at least 128 bytes. no 128 bytes, no deal 🫢
  • edid_parse() β€” this one parses the supplied data block (and again, it must be at least 128 bytes, same rule, fr fr) and writes the relevant data into the structure pointed to by info. it's giving "read the room and take notes" πŸ“
  • edid_print() β€” and this one prints the data in the given info structure to the console device. that's it, that's the whole job πŸ‘‘

πŸ’€ RETURN VALUES πŸ’€

  • edid_is_valid() returns 0 if the data block is valid, and EINVAL otherwise. so zero = slay, EINVAL = something's off πŸ™ˆ
  • edid_parse() returns zero if the data was successfully parsed, and non-zero otherwise. like, "0 = we ate" and "non-zero = we did not" πŸ’…

🌈 EXAMPLES 🌈

okay here's the moment you've been waiting for β€” actual code that uses these functions to retrieve and print information about a monitor πŸŽ€

struct edid_info info;
i2c_tag_t        tag;
char             buffer[128];

...
/* initialize i2c tag... */
...
if ((ddc_read_edid(tag, buffer, 128) == 0) &&
    (edid_parse(buffer, &info) == 0))
        edid_print(&info);
...

see how the 128 keeps showing up? that's not a coincidence bestie, that's the minimum πŸ’–


🧚 CODE REFERENCES 🧚

the EDID subsystem is implemented within the file sys/dev/videomode/edid.c ⭐

it also makes use of VESA Generalized Timing Formula, located located in sys/dev/videomode/vesagtf.c, and the generic videomode database, located in sys/dev/videomode/videomode.c πŸ¦‹

yeah, the original really does say "located located" twice. iconic of it, honestly. we're keeping it exactly as it is πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

go read those next, iykyk πŸ“š


🌸 HISTORY 🌸

these routines were added in NetBSD 4.0. vintage. retro. a little throwback moment πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

Garrett D'Amore <gdamore@NetBSD.org> β€” the main character who wrote this whole thing 🫢


and that's the page!! this gorgeous little document came to you from the Debian edition, dated July 24, 2013, and it lives at the bottom of the page as EDID(9) β€” so like, that's the whole sign-off. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from