From cf5ddd05cb5f5b75f5218de51ff830c1c2f7563d Mon Sep 17 00:00:00 2001 From: Hideyuki Nagase Date: Thu, 17 Mar 2022 12:08:42 -0500 Subject: [PATCH] rdp: Allow configuring the refresh rate We currently hardcode a 60Hz update rate for the rdp backend. In some cases it may be useful to override this to increase the rate for a faster monitor, or to decrease it to reduce network traffic. Co-authored-by: Steve Pronovost Co-authored-by: Brenton DeGeer Signed-off-by: Hideyuki Nagase Signed-off-by: Steve Pronovost Signed-off-by: Brenton DeGeer --- compositor/main.c | 6 ++++++ include/libweston/backend-rdp.h | 2 ++ libweston/backend-rdp/rdp.c | 11 ++++++++--- libweston/backend-rdp/rdp.h | 2 +- man/weston-rdp.man | 13 +++++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/compositor/main.c b/compositor/main.c index 7bfcbc2d..96a99097 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -2777,6 +2777,7 @@ weston_rdp_backend_config_init(struct weston_rdp_backend_config *config) config->no_clients_resize = 0; config->force_no_compression = 0; config->remotefx_codec = true; + config->refresh_rate = RDP_DEFAULT_FREQ; } static int @@ -2784,6 +2785,7 @@ load_rdp_backend(struct weston_compositor *c, int *argc, char *argv[], struct weston_config *wc) { struct weston_rdp_backend_config config = {{ 0, }}; + struct weston_config_section *section; int ret = 0; bool no_remotefx_codec = false; @@ -2812,6 +2814,10 @@ load_rdp_backend(struct weston_compositor *c, config.remotefx_codec = !no_remotefx_codec; wet_set_simple_head_configurator(c, rdp_backend_output_configure); + section = weston_config_get_section(wc, "rdp", NULL, NULL); + weston_config_section_get_int(section, "refresh-rate", + &config.refresh_rate, + RDP_DEFAULT_FREQ); ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP, &config.base); diff --git a/include/libweston/backend-rdp.h b/include/libweston/backend-rdp.h index d9f56b93..e88cd856 100644 --- a/include/libweston/backend-rdp.h +++ b/include/libweston/backend-rdp.h @@ -34,6 +34,7 @@ extern "C" { #include #define WESTON_RDP_OUTPUT_API_NAME "weston_rdp_output_api_v1" +#define RDP_DEFAULT_FREQ 60 struct weston_rdp_output_api { /** Initialize a RDP output with specified width and height. @@ -68,6 +69,7 @@ struct weston_rdp_backend_config { int force_no_compression; bool remotefx_codec; int external_listener_fd; + int refresh_rate; }; #ifdef __cplusplus diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index b3dacb58..e0990f18 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -311,6 +311,7 @@ rdp_insert_new_mode(struct weston_output *output, int width, int height, int rat static struct weston_mode * ensure_matching_mode(struct weston_output *output, struct weston_mode *target) { + struct rdp_backend *b = to_rdp_backend(output->compositor); struct weston_mode *local; wl_list_for_each(local, &output->mode_list, link) { @@ -318,7 +319,7 @@ ensure_matching_mode(struct weston_output *output, struct weston_mode *target) return local; } - return rdp_insert_new_mode(output, target->width, target->height, RDP_MODE_FREQ); + return rdp_insert_new_mode(output, target->width, target->height, b->rdp_monitor_refresh_rate); } static int @@ -379,6 +380,7 @@ rdp_output_set_size(struct weston_output *base, int width, int height) { struct rdp_output *output = to_rdp_output(base); + struct rdp_backend *rdpBackend = to_rdp_backend(base->compositor); struct weston_head *head; struct weston_mode *currentMode; struct weston_mode initMode; @@ -399,8 +401,7 @@ rdp_output_set_size(struct weston_output *base, initMode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; initMode.width = width; initMode.height = height; - initMode.refresh = RDP_MODE_FREQ; - + initMode.refresh = rdpBackend->rdp_monitor_refresh_rate; currentMode = ensure_matching_mode(&output->base, &initMode); if (!currentMode) return -1; @@ -1370,6 +1371,9 @@ rdp_backend_create(struct weston_compositor *compositor, /* After here, rdp_debug() is ready to be used */ + b->rdp_monitor_refresh_rate = config->refresh_rate * 1000; + rdp_debug(b, "RDP backend: WESTON_RDP_MONITOR_REFRESH_RATE: %d\n", b->rdp_monitor_refresh_rate); + compositor->backend = &b->base; if (config->server_cert && config->server_key) { @@ -1485,6 +1489,7 @@ config_init_to_defaults(struct weston_rdp_backend_config *config) config->force_no_compression = 0; config->remotefx_codec = true; config->external_listener_fd = -1; + config->refresh_rate = RDP_DEFAULT_FREQ; } WL_EXPORT int diff --git a/libweston/backend-rdp/rdp.h b/libweston/backend-rdp/rdp.h index e25082b6..9b32ab4c 100644 --- a/libweston/backend-rdp/rdp.h +++ b/libweston/backend-rdp/rdp.h @@ -49,7 +49,6 @@ #define MAX_FREERDP_FDS 32 #define DEFAULT_AXIS_STEP_DISTANCE 10 -#define RDP_MODE_FREQ 60 * 1000 #define DEFAULT_PIXEL_FORMAT PIXEL_FORMAT_BGRA32 struct rdp_output; @@ -72,6 +71,7 @@ struct rdp_backend { int force_no_compression; bool remotefx_codec; int external_listener_fd; + int rdp_monitor_refresh_rate; }; enum peer_item_flags { diff --git a/man/weston-rdp.man b/man/weston-rdp.man index 8900a6ca..a596826f 100644 --- a/man/weston-rdp.man +++ b/man/weston-rdp.man @@ -24,6 +24,19 @@ backend will announce security options based on which files have been given. The RDP backend is multi-seat aware, so if two clients connect on the backend, they will get their own seat. +.\" *************************************************************** +.SH CONFIGURATION +. +The RDP backend uses the following entries from +.BR weston.ini . +.SS Section rdp +.TP +\fBrefresh-rate\fR=\fIrate\fR +Specifies the desktop redraw rate in Hz. If unspecified, the default is 60Hz. Changing +this may be useful if you have a faster than 60Hz display, or if you want to reduce updates to +reduce network traffic. + + .\" *************************************************************** .SH OPTIONS .