mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 10:29:49 +01:00
Merge pull request #1435 from emersion/duplicate-custom-modes
backend/drm: don't insert duplicate custom modes, fix refresh rate
This commit is contained in:
commit
c4c1d63a0c
3 changed files with 11 additions and 4 deletions
|
@ -550,11 +550,18 @@ bool wlr_drm_connector_add_mode(struct wlr_output *output,
|
||||||
const drmModeModeInfo *modeinfo) {
|
const drmModeModeInfo *modeinfo) {
|
||||||
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
||||||
|
|
||||||
assert(modeinfo);
|
|
||||||
if (modeinfo->type != DRM_MODE_TYPE_USERDEF) {
|
if (modeinfo->type != DRM_MODE_TYPE_USERDEF) {
|
||||||
return false;
|
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));
|
struct wlr_drm_mode *mode = calloc(1, sizeof(*mode));
|
||||||
if (!mode) {
|
if (!mode) {
|
||||||
return false;
|
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.width = mode->drm_mode.hdisplay;
|
||||||
mode->wlr_mode.height = mode->drm_mode.vdisplay;
|
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 "
|
wlr_log(WLR_INFO, "Registered custom mode "
|
||||||
"%"PRId32"x%"PRId32"@%"PRId32,
|
"%"PRId32"x%"PRId32"@%"PRId32,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "backend/drm/util.h"
|
#include "backend/drm/util.h"
|
||||||
|
|
||||||
int32_t calculate_refresh_rate(drmModeModeInfo *mode) {
|
int32_t calculate_refresh_rate(const drmModeModeInfo *mode) {
|
||||||
int32_t refresh = (mode->clock * 1000000LL / mode->htotal +
|
int32_t refresh = (mode->clock * 1000000LL / mode->htotal +
|
||||||
mode->vtotal / 2) / mode->vtotal;
|
mode->vtotal / 2) / mode->vtotal;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
|
||||||
// Calculates a more accurate refresh rate (mHz) than what mode itself provides
|
// Calculates a more accurate refresh rate (mHz) than what mode itself provides
|
||||||
int32_t calculate_refresh_rate(drmModeModeInfo *mode);
|
int32_t calculate_refresh_rate(const drmModeModeInfo *mode);
|
||||||
// Populates the make/model/phys_{width,height} of output from the edid data
|
// Populates the make/model/phys_{width,height} of output from the edid data
|
||||||
void parse_edid(struct wlr_output *restrict output, size_t len,
|
void parse_edid(struct wlr_output *restrict output, size_t len,
|
||||||
const uint8_t *data);
|
const uint8_t *data);
|
||||||
|
|
Loading…
Reference in a new issue