diff options
author | Pekka Paalanen <pekka.paalanen@collabora.com> | 2023-04-28 12:48:16 +0300 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.com> | 2023-04-28 13:58:53 +0300 |
commit | 902697d08e57a1ad5858c7327085aaff37a1cefc (patch) | |
tree | 84317e3641c31cc5e47b88514da7449d6091693c | |
parent | d48d571f0ab77cc44eb53379247d601dc7847ad8 (diff) | |
download | weston-902697d08e57a1ad5858c7327085aaff37a1cefc.tar.gz |
backend-drm: add drm_head_info_from_edid()
Move the ad hoc filling code into a separate function. Then we can
easily add an alternative implementation of the new function using
libdisplay-info without messing up the code any more than necessary.
Pure refactoring.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
-rw-r--r-- | libweston/backend-drm/modes.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c index cc253e4b..e8c9474b 100644 --- a/libweston/backend-drm/modes.c +++ b/libweston/backend-drm/modes.c @@ -326,6 +326,28 @@ edid_parse(struct drm_edid *edid, const uint8_t *data, size_t length) return 0; } +static void +drm_head_info_from_edid(struct drm_head_info *dhi, + const uint8_t *data, + size_t length) +{ + struct drm_edid edid = {}; + int rc; + + rc = edid_parse(&edid, data, length); + if (rc == 0) { + if (edid.pnp_id[0] != '\0') + dhi->make = xstrdup(edid.pnp_id); + if (edid.monitor_name[0] != '\0') + dhi->model = xstrdup(edid.monitor_name); + if (edid.serial_number[0] != '\0') + dhi->serial_number = xstrdup(edid.serial_number); + } + + /* TODO: parse this from EDID */ + dhi->eotf_mask = WESTON_EOTF_MODE_ALL_MASK; +} + /** Parse monitor make, model and serial from EDID * * \param head The head whose \c drm_edid to fill in. @@ -341,9 +363,7 @@ find_and_parse_output_edid(struct drm_head *head, { struct drm_device *device = head->connector.device; drmModePropertyBlobPtr edid_blob = NULL; - struct drm_edid edid = {}; uint32_t blob_id; - int rc; blob_id = drm_property_get_value( @@ -356,19 +376,9 @@ find_and_parse_output_edid(struct drm_head *head, if (!edid_blob) return; - rc = edid_parse(&edid, edid_blob->data, edid_blob->length); - if (rc == 0) { - if (edid.pnp_id[0] != '\0') - dhi->make = xstrdup(edid.pnp_id); - if (edid.monitor_name[0] != '\0') - dhi->model = xstrdup(edid.monitor_name); - if (edid.serial_number[0] != '\0') - dhi->serial_number = xstrdup(edid.serial_number); - } - drmModeFreePropertyBlob(edid_blob); + drm_head_info_from_edid(dhi, edid_blob->data, edid_blob->length); - /* TODO: parse this from EDID */ - dhi->eotf_mask = WESTON_EOTF_MODE_ALL_MASK; + drmModeFreePropertyBlob(edid_blob); } static void |