aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/drm.c27
-rw-r--r--include/backend/drm/drm.h4
2 files changed, 31 insertions, 0 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index c5db480e..39906342 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -566,6 +566,33 @@ error_conn:
return false;
}
+bool wlr_drm_connector_add_mode(struct wlr_output *output,
+ const drmModeModeInfo *modeinfo) {
+ struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
+
+ assert(modeinfo);
+ if (modeinfo->type != DRM_MODE_TYPE_USERDEF) {
+ return false;
+ }
+
+ struct wlr_drm_mode *mode = calloc(1, sizeof(*mode));
+ if (!mode) {
+ return false;
+ }
+ memcpy(&mode->drm_mode, modeinfo, sizeof(*modeinfo));
+
+ mode->wlr_mode.width = mode->drm_mode.hdisplay;
+ mode->wlr_mode.height = mode->drm_mode.vdisplay;
+ mode->wlr_mode.refresh = mode->drm_mode.vrefresh;
+
+ wlr_log(L_INFO, "Registered custom mode "
+ "%"PRId32"x%"PRId32"@%"PRId32,
+ mode->wlr_mode.width, mode->wlr_mode.height,
+ mode->wlr_mode.refresh);
+ wl_list_insert(&conn->output.modes, &mode->wlr_mode.link);
+ return true;
+}
+
static void drm_connector_transform(struct wlr_output *output,
enum wl_output_transform transform) {
output->transform = transform;
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index 5d6ff231..416507ea 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -143,5 +143,9 @@ void restore_drm_outputs(struct wlr_drm_backend *drm);
void scan_drm_connectors(struct wlr_drm_backend *state);
int handle_drm_event(int fd, uint32_t mask, void *data);
void enable_drm_connector(struct wlr_output *output, bool enable);
+/**
+ * Add mode to the list of available modes
+ */
+bool wlr_drm_connector_add_mode(struct wlr_output *output, const drmModeModeInfo *mode);
#endif