diff options
author | emersion <contact@emersion.fr> | 2018-12-16 18:23:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-16 18:23:36 +0100 |
commit | c4c1d63a0c0d7315a1a4468d62d883371ba3ec4e (patch) | |
tree | e9dca74205246bf27e88f4f8774d94188a0e3916 /backend/drm/drm.c | |
parent | 6d4bfa3226123e958ff2bdc4f226489cba49f84d (diff) | |
parent | ff6c4f80b25d1c3960fbe050858ca44331ee1111 (diff) |
Merge pull request #1435 from emersion/duplicate-custom-modes
backend/drm: don't insert duplicate custom modes, fix refresh rate
Diffstat (limited to 'backend/drm/drm.c')
-rw-r--r-- | backend/drm/drm.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 0acb0324..332abfe5 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -550,11 +550,18 @@ bool wlr_drm_connector_add_mode(struct wlr_output *output, const drmModeModeInfo *modeinfo) { struct wlr_drm_connector *conn = get_drm_connector_from_output(output); - assert(modeinfo); if (modeinfo->type != DRM_MODE_TYPE_USERDEF) { return false; } + struct wlr_output_mode *wlr_mode; + wl_list_for_each(wlr_mode, &conn->output.modes, link) { + struct wlr_drm_mode *mode = (struct wlr_drm_mode *)wlr_mode; + if (memcmp(&mode->drm_mode, modeinfo, sizeof(*modeinfo)) == 0) { + return true; + } + } + struct wlr_drm_mode *mode = calloc(1, sizeof(*mode)); if (!mode) { return false; @@ -563,7 +570,7 @@ bool wlr_drm_connector_add_mode(struct wlr_output *output, mode->wlr_mode.width = mode->drm_mode.hdisplay; mode->wlr_mode.height = mode->drm_mode.vdisplay; - mode->wlr_mode.refresh = mode->drm_mode.vrefresh; + mode->wlr_mode.refresh = calculate_refresh_rate(modeinfo); wlr_log(WLR_INFO, "Registered custom mode " "%"PRId32"x%"PRId32"@%"PRId32, |