diff options
Diffstat (limited to 'meta-agl-drm-lease/recipes-graphics/weston/weston/0002-Add-DRM-lease-support.patch')
-rw-r--r-- | meta-agl-drm-lease/recipes-graphics/weston/weston/0002-Add-DRM-lease-support.patch | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/meta-agl-drm-lease/recipes-graphics/weston/weston/0002-Add-DRM-lease-support.patch b/meta-agl-drm-lease/recipes-graphics/weston/weston/0002-Add-DRM-lease-support.patch new file mode 100644 index 00000000..5b2d69ae --- /dev/null +++ b/meta-agl-drm-lease/recipes-graphics/weston/weston/0002-Add-DRM-lease-support.patch @@ -0,0 +1,230 @@ +From 24ece5f73b7c9377e14d74c2b14c9ae3504edcc3 Mon Sep 17 00:00:00 2001 +From: Damian Hobson-Garcia <dhobsong@igel.co.jp> +Date: Fri, 5 Mar 2021 19:24:35 +0900 +Subject: [PATCH 2/2] Add DRM lease support + +Add a command line option to use a DRM lease instead of a primary node for +output when using the DRM backend. +--- + compositor/drm-lease.c | 53 ++++++++++++++++++++++++++++++++++++++++++ + compositor/drm-lease.h | 40 +++++++++++++++++++++++++++++++ + compositor/main.c | 11 ++++++++- + compositor/meson.build | 5 ++++ + meson_options.txt | 7 ++++++ + 5 files changed, 115 insertions(+), 1 deletion(-) + create mode 100644 compositor/drm-lease.c + create mode 100644 compositor/drm-lease.h + +diff --git a/compositor/drm-lease.c b/compositor/drm-lease.c +new file mode 100644 +index 00000000..fdb1f5e2 +--- /dev/null ++++ b/compositor/drm-lease.c +@@ -0,0 +1,53 @@ ++/* ++ * Copyright © 2021 IGEL Co., Ltd. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial ++ * portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ++ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ */ ++ ++#include "drm-lease.h" ++ ++#include <libweston/libweston.h> ++ ++int get_drm_lease(struct dlm_lease **drm_lease, const char *drm_lease_name) { ++ if (!drm_lease_name) ++ return -1; ++ ++ int drm_fd; ++ struct dlm_lease *lease = dlm_get_lease(drm_lease_name); ++ if (lease) { ++ drm_fd = dlm_lease_fd(lease); ++ if (drm_fd < 0) ++ dlm_release_lease(lease); ++ } ++ if (drm_fd < 0) ++ weston_log("Could not get DRM lease %s\n", drm_lease_name); ++ ++ *drm_lease = lease; ++ return drm_fd; ++} ++ ++void release_drm_lease(struct dlm_lease *lease) { ++ if (lease) ++ dlm_release_lease(lease); ++} ++ ++ +diff --git a/compositor/drm-lease.h b/compositor/drm-lease.h +new file mode 100644 +index 00000000..a102e4cb +--- /dev/null ++++ b/compositor/drm-lease.h +@@ -0,0 +1,40 @@ ++/* ++ * Copyright © 2021 IGEL Co., Ltd. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial ++ * portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ++ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ */ ++ ++#include "config.h" ++ ++#ifdef BUILD_DRM_LEASE_CLIENT ++#include <dlmclient.h> ++int get_drm_lease(struct dlm_lease **drm_lease, const char *drm_lease_name); ++void release_drm_lease(struct dlm_lease *drm_lease); ++#else ++struct dlm_lease; ++int get_drm_lease(struct dlm_lease **drm_lease, const char *drm_lease_name) { ++ return -1; ++} ++void release_drm_lease(struct dlm_lease *drm_lease) { ++} ++ ++#endif +diff --git a/compositor/main.c b/compositor/main.c +index 7d5373f7..dae754aa 100644 +--- a/compositor/main.c ++++ b/compositor/main.c +@@ -65,6 +65,7 @@ + #include <libweston/weston-log.h> + #include "../remoting/remoting-plugin.h" + #include "../pipewire/pipewire-plugin.h" ++#include "drm-lease.h" + + #define WINDOW_TITLE "Weston Compositor" + /* flight recorder size (in bytes) */ +@@ -122,6 +123,7 @@ struct wet_compositor { + int (*simple_output_configure)(struct weston_output *output); + bool init_failed; + struct wl_list layoutput_list; /**< wet_layoutput::compositor_link */ ++ struct dlm_lease *drm_lease; + }; + + static FILE *weston_logfile = NULL; +@@ -669,6 +671,9 @@ usage(int error_code) + " --seat=SEAT\t\tThe seat that weston should run on, instead of the seat defined in XDG_SEAT\n" + " --tty=TTY\t\tThe tty to use\n" + " --drm-device=CARD\tThe DRM device to use, e.g. \"card0\".\n" ++#ifdef BUILD_DRM_LEASE_CLIENT ++ " --drm-lease=lease\tUse the specified DRM lease. e.g \"card0-HDMI-A-1\"\n" ++#endif + " --use-pixman\t\tUse the pixman (CPU) renderer\n" + " --current-mode\tPrefer current KMS mode over EDID preferred mode\n\n"); + #endif +@@ -2481,6 +2486,7 @@ load_drm_backend(struct weston_compositor *c, + struct weston_config_section *section; + struct wet_compositor *wet = to_wet_compositor(c); + int ret = 0; ++ char *drm_lease_name = NULL; + + wet->drm_use_current_mode = false; + +@@ -2492,6 +2498,7 @@ load_drm_backend(struct weston_compositor *c, + { WESTON_OPTION_STRING, "seat", 0, &config.seat_id }, + { WESTON_OPTION_INTEGER, "tty", 0, &config.tty }, + { WESTON_OPTION_STRING, "drm-device", 0, &config.specific_device }, ++ { WESTON_OPTION_STRING, "drm-lease", 0, &drm_lease_name }, + { WESTON_OPTION_BOOLEAN, "current-mode", 0, &wet->drm_use_current_mode }, + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman }, + }; +@@ -2510,7 +2517,7 @@ load_drm_backend(struct weston_compositor *c, + config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION; + config.base.struct_size = sizeof(struct weston_drm_backend_config); + config.configure_device = configure_input_device; +- config.device_fd = -1; ++ config.device_fd = get_drm_lease(&wet->drm_lease, drm_lease_name); + + wet->heads_changed_listener.notify = drm_heads_changed; + weston_compositor_add_heads_changed_listener(c, +@@ -2527,6 +2534,7 @@ load_drm_backend(struct weston_compositor *c, + + free(config.gbm_format); + free(config.seat_id); ++ free(drm_lease_name); + + return ret; + } +@@ -3373,6 +3381,7 @@ out: + + /* free(NULL) is valid, and it won't be NULL if it's used */ + free(wet.parsed_options); ++ release_drm_lease(wet.drm_lease); + + if (protologger) + wl_protocol_logger_destroy(protologger); +diff --git a/compositor/meson.build b/compositor/meson.build +index e1334d6a..e5b82a88 100644 +--- a/compositor/meson.build ++++ b/compositor/meson.build +@@ -25,6 +25,11 @@ if get_option('xwayland') + srcs_weston += 'xwayland.c' + config_h.set_quoted('XSERVER_PATH', get_option('xwayland-path')) + endif ++if get_option('drm-lease') ++ deps_weston += dependency('libdlmclient') ++ srcs_weston += 'drm-lease.c' ++ config_h.set('BUILD_DRM_LEASE_CLIENT', '1') ++endif + + libexec_weston = shared_library( + 'exec_weston', +diff --git a/meson_options.txt b/meson_options.txt +index 73ef2c34..9cb27536 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -113,6 +113,13 @@ option( + description: 'Virtual remote output with Pipewire on DRM backend' + ) + ++option( ++ 'drm-lease', ++ type: 'boolean', ++ value: false, ++ description: 'Support for running weston with a leased DRM Master' ++) ++ + option( + 'shell-desktop', + type: 'boolean', +-- +2.25.1 + |