aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 6224fc10..9fff79fd 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -8,6 +8,7 @@
8#include <wlr/types/wlr_cursor.h> 8#include <wlr/types/wlr_cursor.h>
9#include <wlr/types/wlr_output_layout.h> 9#include <wlr/types/wlr_output_layout.h>
10#include <wlr/types/wlr_output.h> 10#include <wlr/types/wlr_output.h>
11#include <wlr/backend/drm.h>
11#include "sway/config.h" 12#include "sway/config.h"
12#include "sway/input/cursor.h" 13#include "sway/input/cursor.h"
13#include "sway/output.h" 14#include "sway/output.h"
@@ -58,6 +59,7 @@ struct output_config *new_output_config(const char *name) {
58 oc->width = oc->height = -1; 59 oc->width = oc->height = -1;
59 oc->refresh_rate = -1; 60 oc->refresh_rate = -1;
60 oc->custom_mode = -1; 61 oc->custom_mode = -1;
62 oc->drm_mode.type = -1;
61 oc->x = oc->y = -1; 63 oc->x = oc->y = -1;
62 oc->scale = -1; 64 oc->scale = -1;
63 oc->scale_filter = SCALE_FILTER_DEFAULT; 65 oc->scale_filter = SCALE_FILTER_DEFAULT;
@@ -99,6 +101,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
99 if (src->custom_mode != -1) { 101 if (src->custom_mode != -1) {
100 dst->custom_mode = src->custom_mode; 102 dst->custom_mode = src->custom_mode;
101 } 103 }
104 if (src->drm_mode.type != (uint32_t) -1) {
105 memcpy(&dst->drm_mode, &src->drm_mode, sizeof(src->drm_mode));
106 }
102 if (src->transform != -1) { 107 if (src->transform != -1) {
103 dst->transform = src->transform; 108 dst->transform = src->transform;
104 } 109 }
@@ -271,6 +276,18 @@ static void set_mode(struct wlr_output *output, int width, int height,
271 wlr_output_set_mode(output, best); 276 wlr_output_set_mode(output, best);
272} 277}
273 278
279static void set_modeline(struct wlr_output *output, drmModeModeInfo *drm_mode) {
280 if (!wlr_output_is_drm(output)) {
281 sway_log(SWAY_ERROR, "Modeline can only be set to DRM output");
282 return;
283 }
284 sway_log(SWAY_DEBUG, "Assigning custom modeline to %s", output->name);
285 struct wlr_output_mode *mode = wlr_drm_connector_add_mode(output, drm_mode);
286 if (mode) {
287 wlr_output_set_mode(output, mode);
288 }
289}
290
274/* Some manufacturers hardcode the aspect-ratio of the output in the physical 291/* Some manufacturers hardcode the aspect-ratio of the output in the physical
275 * size field. */ 292 * size field. */
276static bool phys_size_is_aspect_ratio(struct wlr_output *output) { 293static bool phys_size_is_aspect_ratio(struct wlr_output *output) {
@@ -351,7 +368,11 @@ static void queue_output_config(struct output_config *oc,
351 sway_log(SWAY_DEBUG, "Turning on output %s", wlr_output->name); 368 sway_log(SWAY_DEBUG, "Turning on output %s", wlr_output->name);
352 wlr_output_enable(wlr_output, true); 369 wlr_output_enable(wlr_output, true);
353 370
354 if (oc && oc->width > 0 && oc->height > 0) { 371 if (oc && oc->drm_mode.type != 0 && oc->drm_mode.type != (uint32_t) -1) {
372 sway_log(SWAY_DEBUG, "Set %s modeline",
373 wlr_output->name);
374 set_modeline(wlr_output, &oc->drm_mode);
375 } else if (oc && oc->width > 0 && oc->height > 0) {
355 sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f Hz)", 376 sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f Hz)",
356 wlr_output->name, oc->width, oc->height, oc->refresh_rate); 377 wlr_output->name, oc->width, oc->height, oc->refresh_rate);
357 set_mode(wlr_output, oc->width, oc->height, 378 set_mode(wlr_output, oc->width, oc->height,