mirror of
https://gitlab.freedesktop.org/emersion/libdisplay-info.git
synced 2024-12-25 21:59:08 +01:00
edid: add di_edid_format()
Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
6df26fb327
commit
bed829366e
2 changed files with 38 additions and 0 deletions
25
edid.c
25
edid.c
|
@ -1707,3 +1707,28 @@ error:
|
|||
di_edid_destroy(copy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
di_edid_format(const struct di_edid *edid, void *buf, size_t buf_size)
|
||||
{
|
||||
size_t size;
|
||||
uint8_t *data;
|
||||
|
||||
size = EDID_BLOCK_SIZE * (1 + edid->exts_len);
|
||||
if (buf == NULL) {
|
||||
return (ssize_t) size;
|
||||
} else if (buf_size < size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf, 0, size);
|
||||
|
||||
data = buf;
|
||||
memcpy(data, header, sizeof(header));
|
||||
data[0x12] = (uint8_t) edid->version;
|
||||
data[0x13] = (uint8_t) edid->revision;
|
||||
|
||||
/* TODO */
|
||||
|
||||
return (ssize_t) size;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* EDID data structure.
|
||||
|
@ -33,6 +34,18 @@ di_edid_destroy(struct di_edid *edid);
|
|||
struct di_edid *
|
||||
di_edid_dup(const struct di_edid *edid);
|
||||
|
||||
/**
|
||||
* Format an EDID.
|
||||
*
|
||||
* If buf is NULL, the size of the EDID is returned without writing the EDID.
|
||||
* If buf is not NULL, buf_size must be its capacity in bytes.
|
||||
*
|
||||
* On success, the size of the EDID in bytes is returned. On error, a negative
|
||||
* integer is returned.
|
||||
*/
|
||||
ssize_t
|
||||
di_edid_format(const struct di_edid *edid, void *buf, size_t buf_size);
|
||||
|
||||
/**
|
||||
* Get the EDID version.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue