aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/drm.c
diff options
context:
space:
mode:
authorScott Anderson <ascent12@hotmail.com>2017-05-14 01:24:09 +1200
committerScott Anderson <ascent12@hotmail.com>2017-05-14 01:24:09 +1200
commiteac603bfdf107daa1bb33568c8cc282713c31edd (patch)
treefe3752518a62f96f970ea98478150f96ca612b2e /backend/drm/drm.c
parent3000b8615fd4ba62b1a0f804caf0b150d5edf22c (diff)
parent599d1bcbdc8e0e9fb2d743d70dbf8b6fa9f3bea2 (diff)
Merge branch 'master' into refresh
Diffstat (limited to 'backend/drm/drm.c')
-rw-r--r--backend/drm/drm.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index fb49d46c..8a64dfa6 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -263,6 +263,30 @@ static uint32_t calculate_refresh_rate(drmModeModeInfo *mode) {
return refresh;
}
+static void scan_property_ids(int fd, drmModeConnector *conn,
+ struct wlr_output_state *output) {
+ for (int i = 0; i < conn->count_props; ++i) {
+ drmModePropertyRes *prop = drmModeGetProperty(fd, conn->props[i]);
+ if (!prop) {
+ continue;
+ }
+
+ // I think this is guranteed to exist
+ if (strcmp(prop->name, "DPMS") == 0) {
+ output->props.dpms = prop->prop_id;
+
+ /* There may be more properties we want to get,
+ * but since it's currently only this, we exit early
+ */
+
+ drmModeFreeProperty(prop);
+ break;
+ }
+
+ drmModeFreeProperty(prop);
+ }
+}
+
void wlr_drm_scan_connectors(struct wlr_backend_state *state) {
wlr_log(L_INFO, "Scanning DRM connectors");
@@ -314,6 +338,8 @@ void wlr_drm_scan_connectors(struct wlr_backend_state *state) {
free(curr_enc);
}
+ scan_property_ids(state->fd, conn, output);
+
list_add(state->outputs, output);
wlr_log(L_INFO, "Found display '%s'", output->name);
} else {
@@ -428,3 +454,23 @@ void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore) {
}
// TODO: free wlr_output
}
+
+void wlr_drm_output_dpms(int fd, struct wlr_output_state *output, bool screen_on) {
+ if (output->state != DRM_OUTPUT_CONNECTED) {
+ return;
+ }
+
+ if (screen_on) {
+ drmModeConnectorSetProperty(fd, output->connector, output->props.dpms,
+ DRM_MODE_DPMS_ON);
+
+ // Start rendering loop again by drawing a black frame
+ wlr_drm_output_begin(output->wlr_output);
+ glClearColor(0.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ wlr_drm_output_end(output->wlr_output);
+ } else {
+ drmModeConnectorSetProperty(fd, output->connector, output->props.dpms,
+ DRM_MODE_DPMS_STANDBY);
+ }
+}