mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
backend/drm: add support for adaptive_sync_enabled
The vrr_capable and VRR_ENABLED properties are used.
This commit is contained in:
parent
9be1af3afb
commit
52c67284e2
3 changed files with 46 additions and 0 deletions
|
@ -412,6 +412,43 @@ static bool drm_connector_commit_buffer(struct wlr_output *output) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drm_connector_enable_adaptive_sync(struct wlr_output *output,
|
||||||
|
bool enabled) {
|
||||||
|
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
|
||||||
|
struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
|
||||||
|
|
||||||
|
struct wlr_drm_crtc *crtc = conn->crtc;
|
||||||
|
if (!crtc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t vrr_capable;
|
||||||
|
if (conn->props.vrr_capable == 0 ||
|
||||||
|
!get_drm_prop(drm->fd, conn->id, conn->props.vrr_capable,
|
||||||
|
&vrr_capable) || !vrr_capable) {
|
||||||
|
wlr_log(WLR_DEBUG, "Failed to enable adaptive sync: "
|
||||||
|
"connector '%s' doesn't support VRR", output->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crtc->props.vrr_enabled == 0) {
|
||||||
|
wlr_log(WLR_DEBUG, "Failed to enable adaptive sync: "
|
||||||
|
"CRTC %"PRIu32" doesn't support VRR", crtc->id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drmModeObjectSetProperty(drm->fd, crtc->id, DRM_MODE_OBJECT_CRTC,
|
||||||
|
crtc->props.vrr_enabled, enabled) != 0) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "drmModeObjectSetProperty(VRR_ENABLED) failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
output->adaptive_sync_status = enabled ? WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED :
|
||||||
|
WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED;
|
||||||
|
wlr_log(WLR_DEBUG, "VRR %s on connector '%s'",
|
||||||
|
enabled ? "enabled" : "disabled", output->name);
|
||||||
|
}
|
||||||
|
|
||||||
static bool drm_connector_set_custom_mode(struct wlr_output *output,
|
static bool drm_connector_set_custom_mode(struct wlr_output *output,
|
||||||
int32_t width, int32_t height, int32_t refresh);
|
int32_t width, int32_t height, int32_t refresh);
|
||||||
|
|
||||||
|
@ -446,6 +483,11 @@ static bool drm_connector_commit(struct wlr_output *output) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (output->pending.committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) {
|
||||||
|
drm_connector_enable_adaptive_sync(output,
|
||||||
|
output->pending.adaptive_sync_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: support modesetting with a buffer
|
// TODO: support modesetting with a buffer
|
||||||
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER &&
|
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER &&
|
||||||
!(output->pending.committed & WLR_OUTPUT_STATE_MODE)) {
|
!(output->pending.committed & WLR_OUTPUT_STATE_MODE)) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ static const struct prop_info connector_info[] = {
|
||||||
{ "EDID", INDEX(edid) },
|
{ "EDID", INDEX(edid) },
|
||||||
{ "PATH", INDEX(path) },
|
{ "PATH", INDEX(path) },
|
||||||
{ "link-status", INDEX(link_status) },
|
{ "link-status", INDEX(link_status) },
|
||||||
|
{ "vrr_capable", INDEX(vrr_capable) },
|
||||||
#undef INDEX
|
#undef INDEX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ static const struct prop_info crtc_info[] = {
|
||||||
{ "GAMMA_LUT", INDEX(gamma_lut) },
|
{ "GAMMA_LUT", INDEX(gamma_lut) },
|
||||||
{ "GAMMA_LUT_SIZE", INDEX(gamma_lut_size) },
|
{ "GAMMA_LUT_SIZE", INDEX(gamma_lut_size) },
|
||||||
{ "MODE_ID", INDEX(mode_id) },
|
{ "MODE_ID", INDEX(mode_id) },
|
||||||
|
{ "VRR_ENABLED", INDEX(vrr_enabled) },
|
||||||
{ "rotation", INDEX(rotation) },
|
{ "rotation", INDEX(rotation) },
|
||||||
{ "scaling mode", INDEX(scaling_mode) },
|
{ "scaling mode", INDEX(scaling_mode) },
|
||||||
#undef INDEX
|
#undef INDEX
|
||||||
|
|
|
@ -16,6 +16,7 @@ union wlr_drm_connector_props {
|
||||||
uint32_t dpms;
|
uint32_t dpms;
|
||||||
uint32_t link_status; // not guaranteed to exist
|
uint32_t link_status; // not guaranteed to exist
|
||||||
uint32_t path;
|
uint32_t path;
|
||||||
|
uint32_t vrr_capable; // not guaranteed to exist
|
||||||
|
|
||||||
// atomic-modesetting only
|
// atomic-modesetting only
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ union wlr_drm_crtc_props {
|
||||||
// Neither of these are guaranteed to exist
|
// Neither of these are guaranteed to exist
|
||||||
uint32_t rotation;
|
uint32_t rotation;
|
||||||
uint32_t scaling_mode;
|
uint32_t scaling_mode;
|
||||||
|
uint32_t vrr_enabled;
|
||||||
|
|
||||||
// atomic-modesetting only
|
// atomic-modesetting only
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue