aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-11-03 16:44:42 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-12-14 13:21:09 +0000
commita15c327718dafb1b7b7f1213c8878187b6351dba (patch)
tree4ba0a28e635f1331690b0059b0b4ef68d4b07c5d /backend/drm
parent4377b5529279aa9dab64256d22ad0f2e9009843c (diff)
backend/drm: use drmModeFormatModifierBlobIterNext
This avoids open-coding our own logic. The resulting code is more readable. References: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/drm.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 1a46b495..43de54e5 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -142,17 +142,9 @@ static bool add_plane(struct wlr_drm_backend *drm,
goto error;
}
- struct drm_format_modifier_blob *data = blob->data;
- uint32_t *fmts = (uint32_t *)((char *)data + data->formats_offset);
- struct drm_format_modifier *mods = (struct drm_format_modifier *)
- ((char *)data + data->modifiers_offset);
- for (uint32_t i = 0; i < data->count_modifiers; ++i) {
- for (int j = 0; j < 64; ++j) {
- if (mods[i].formats & ((uint64_t)1 << j)) {
- wlr_drm_format_set_add(&p->formats,
- fmts[j + mods[i].offset], mods[i].modifier);
- }
- }
+ drmModeFormatModifierIterator iter = {0};
+ while (drmModeFormatModifierBlobIterNext(blob, &iter)) {
+ wlr_drm_format_set_add(&p->formats, iter.fmt, iter.mod);
}
drmModeFreePropertyBlob(blob);