diff options
author | Jonas Ã…dahl <jadahl@gmail.com> | 2020-07-02 15:47:32 +0200 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2021-01-22 16:47:08 +0000 |
commit | abac217617a10ed1d3da7b79a68a720d2d97c867 (patch) | |
tree | 95c49d34c741892b4879115135346362c2c71c44 /src/backends/native/meta-kms-mode.c | |
parent | e15bb68d8f17b4ac6b14fe412c2276d496c9533b (diff) | |
download | mutter-abac217617a10ed1d3da7b79a68a720d2d97c867.tar.gz |
crtc-mode-kms: Wrap MetaKmsMode instead of drmModeModeInfo
We'll need to use the MetaKmsMode later on for state keeping.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
Diffstat (limited to 'src/backends/native/meta-kms-mode.c')
-rw-r--r-- | src/backends/native/meta-kms-mode.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/backends/native/meta-kms-mode.c b/src/backends/native/meta-kms-mode.c index 8b61e1f60..cc726cff2 100644 --- a/src/backends/native/meta-kms-mode.c +++ b/src/backends/native/meta-kms-mode.c @@ -73,6 +73,54 @@ meta_kms_mode_get_drm_mode (MetaKmsMode *mode) return &mode->drm_mode; } +static gboolean +meta_drm_mode_equal (const drmModeModeInfo *one, + const drmModeModeInfo *two) +{ + return (one->clock == two->clock && + one->hdisplay == two->hdisplay && + one->hsync_start == two->hsync_start && + one->hsync_end == two->hsync_end && + one->htotal == two->htotal && + one->hskew == two->hskew && + one->vdisplay == two->vdisplay && + one->vsync_start == two->vsync_start && + one->vsync_end == two->vsync_end && + one->vtotal == two->vtotal && + one->vscan == two->vscan && + one->vrefresh == two->vrefresh && + one->flags == two->flags && + one->type == two->type && + strncmp (one->name, two->name, DRM_DISPLAY_MODE_LEN) == 0); +} + +gboolean +meta_kms_mode_equal (MetaKmsMode *mode, + MetaKmsMode *other_mode) +{ + return meta_drm_mode_equal (&mode->drm_mode, &other_mode->drm_mode); +} + +unsigned int +meta_kms_mode_hash (MetaKmsMode *mode) +{ + const drmModeModeInfo *drm_mode = &mode->drm_mode; + unsigned int hash = 0; + + /* + * We don't include the name in the hash because it's generally + * derived from the other fields (hdisplay, vdisplay and flags) + */ + + hash ^= drm_mode->clock; + hash ^= drm_mode->hdisplay ^ drm_mode->hsync_start ^ drm_mode->hsync_end; + hash ^= drm_mode->vdisplay ^ drm_mode->vsync_start ^ drm_mode->vsync_end; + hash ^= drm_mode->vrefresh; + hash ^= drm_mode->flags ^ drm_mode->type; + + return hash; +} + void meta_kms_mode_free (MetaKmsMode *mode) { |