diff options
Diffstat (limited to 'sway/config')
-rw-r--r-- | sway/config/output.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index 6d39c2f5..63c81382 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <assert.h> | 2 | #include <assert.h> |
3 | #include <drm_fourcc.h> | ||
3 | #include <stdbool.h> | 4 | #include <stdbool.h> |
4 | #include <string.h> | 5 | #include <string.h> |
5 | #include <sys/socket.h> | 6 | #include <sys/socket.h> |
@@ -67,6 +68,7 @@ struct output_config *new_output_config(const char *name) { | |||
67 | oc->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN; | 68 | oc->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN; |
68 | oc->max_render_time = -1; | 69 | oc->max_render_time = -1; |
69 | oc->adaptive_sync = -1; | 70 | oc->adaptive_sync = -1; |
71 | oc->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT; | ||
70 | return oc; | 72 | return oc; |
71 | } | 73 | } |
72 | 74 | ||
@@ -113,6 +115,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) { | |||
113 | if (src->adaptive_sync != -1) { | 115 | if (src->adaptive_sync != -1) { |
114 | dst->adaptive_sync = src->adaptive_sync; | 116 | dst->adaptive_sync = src->adaptive_sync; |
115 | } | 117 | } |
118 | if (src->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { | ||
119 | dst->render_bit_depth = src->render_bit_depth; | ||
120 | } | ||
116 | if (src->background) { | 121 | if (src->background) { |
117 | free(dst->background); | 122 | free(dst->background); |
118 | dst->background = strdup(src->background); | 123 | dst->background = strdup(src->background); |
@@ -351,6 +356,23 @@ static int compute_default_scale(struct wlr_output *output) { | |||
351 | return 2; | 356 | return 2; |
352 | } | 357 | } |
353 | 358 | ||
359 | /* Lists of formats to try, in order, when a specific render bit depth has | ||
360 | * been asked for. The second to last format in each list should always | ||
361 | * be XRGB8888, as a reliable backup in case the others are not available; | ||
362 | * the last should be DRM_FORMAT_INVALID, to indicate the end of the list. */ | ||
363 | static const uint32_t *bit_depth_preferences[] = { | ||
364 | [RENDER_BIT_DEPTH_8] = (const uint32_t []){ | ||
365 | DRM_FORMAT_XRGB8888, | ||
366 | DRM_FORMAT_INVALID, | ||
367 | }, | ||
368 | [RENDER_BIT_DEPTH_10] = (const uint32_t []){ | ||
369 | DRM_FORMAT_XRGB2101010, | ||
370 | DRM_FORMAT_XBGR2101010, | ||
371 | DRM_FORMAT_XRGB8888, | ||
372 | DRM_FORMAT_INVALID, | ||
373 | }, | ||
374 | }; | ||
375 | |||
354 | static void queue_output_config(struct output_config *oc, | 376 | static void queue_output_config(struct output_config *oc, |
355 | struct sway_output *output) { | 377 | struct sway_output *output) { |
356 | if (output == root->noop_output) { | 378 | if (output == root->noop_output) { |
@@ -437,6 +459,22 @@ static void queue_output_config(struct output_config *oc, | |||
437 | oc->adaptive_sync); | 459 | oc->adaptive_sync); |
438 | wlr_output_enable_adaptive_sync(wlr_output, oc->adaptive_sync == 1); | 460 | wlr_output_enable_adaptive_sync(wlr_output, oc->adaptive_sync == 1); |
439 | } | 461 | } |
462 | |||
463 | if (oc && oc->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { | ||
464 | const uint32_t *fmts = bit_depth_preferences[oc->render_bit_depth]; | ||
465 | assert(fmts); | ||
466 | |||
467 | for (size_t i = 0; fmts[i] != DRM_FORMAT_INVALID; i++) { | ||
468 | wlr_output_set_render_format(wlr_output, fmts[i]); | ||
469 | if (wlr_output_test(wlr_output)) { | ||
470 | break; | ||
471 | } | ||
472 | |||
473 | sway_log(SWAY_DEBUG, "Preferred output format 0x%08x " | ||
474 | "failed to work, falling back to next in " | ||
475 | "list, 0x%08x", fmts[i], fmts[i + 1]); | ||
476 | } | ||
477 | } | ||
440 | } | 478 | } |
441 | 479 | ||
442 | bool apply_output_config(struct output_config *oc, struct sway_output *output) { | 480 | bool apply_output_config(struct output_config *oc, struct sway_output *output) { |