summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2024-05-03 14:29:13 +0300
committerNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2024-12-29 17:21:00 +0900
commit2218de5d4581843f229f2327900d9e11ff65c738 (patch)
treef114f3b742a81b6993c63d4d23633c4ccba55d05
parent0824eb521f8e26e4c0f143ec7850d45c4b2f675b (diff)
Add drm-lease support
Add an option to use a DRM lease instead of a DRM device as the video output. This will allow agl-compositor to operate alongside other applications output via a DRM lease. The original patch developed by Damian Hobson-Garcia <dhobsong@igel.co.jp>. This patch based on his work. On the other hand, it cause some build error in case of disabling a drm lease build option. This patch improve to fix build error in case of disabling a drm lease build option. Bug-AGL: SPEC-4889 Change-Id: Idd76d574ee9cfd72f97657dddaa40d904fa2788b Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
-rw-r--r--meson.build6
-rw-r--r--meson_options.txt7
-rw-r--r--src/compositor.c12
-rw-r--r--src/drm-lease.c82
-rw-r--r--src/drm-lease.h15
-rw-r--r--src/ivi-compositor.h2
6 files changed, 123 insertions, 1 deletions
diff --git a/meson.build b/meson.build
index 215b5ac..8dd852a 100644
--- a/meson.build
+++ b/meson.build
@@ -138,6 +138,7 @@ srcs_agl_compositor = [
'src/policy.c',
'src/shell.c',
'src/input.c',
+ 'src/drm-lease.c',
'shared/option-parser.c',
'shared/os-compatibility.c',
'shared/process-util.c',
@@ -159,6 +160,11 @@ elif policy_to_install == 'rba'
message('Installing rba policy')
endif
+if get_option('drm-lease')
+ deps_libweston += dependency('libdlmclient')
+ config_h.set('HAVE_DRM_LEASE', '1')
+endif
+
# From meson documentation:
# In order to look for headers in a specific directory you can use args :
# '-I/extra/include/dir, but this should only be used in exceptional cases for
diff --git a/meson_options.txt b/meson_options.txt
index 7c0e103..eda8c3e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -17,10 +17,15 @@ option(
value: false,
description: 'Build compositor with XWayland support. Disabled by default'
)
-
option(
'xwayland-path',
type: 'string',
value: '/usr/bin/Xwayland',
description: 'Xwayland: path to installed Xwayland binary'
)
+option(
+ 'drm-lease',
+ type: 'boolean',
+ value: false,
+ description: 'Support for running weston with a leased DRM Master'
+)
diff --git a/src/compositor.c b/src/compositor.c
index 36a12d4..c7a12e4 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -57,6 +57,7 @@
#include "config.h"
#include "agl-shell-server-protocol.h"
+#include "drm-lease.h"
#define WINDOWED_DEFAULT_WIDTH 1024
#define WINDOWED_DEFAULT_HEIGHT 768
@@ -901,14 +902,17 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[],
};
struct weston_config_section *section;
int use_current_mode = 0;
+ int ret = -1;
bool force_pixman = false;
bool use_shadow;
bool without_input = false;
struct ivi_backend *ivi_backend = NULL;
+ char *drm_lease_name = NULL;
const struct weston_option options[] = {
{ WESTON_OPTION_STRING, "seat", 0, &config.seat_id },
{ WESTON_OPTION_STRING, "drm-device", 0, &config.specific_device },
+ { WESTON_OPTION_STRING, "drm-lease", 0, &drm_lease_name },
{ WESTON_OPTION_BOOLEAN, "current-mode", 0, &use_current_mode },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman },
{ WESTON_OPTION_BOOLEAN, "continue-without-input", false, &without_input }
@@ -931,6 +935,10 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[],
weston_config_section_get_bool(section, "pixman-shadow", &use_shadow, 1);
config.use_pixman_shadow = use_shadow;
+ ret = setup_drm_lease(&ivi->drm_lease, &config, drm_lease_name);
+ if (ret < 0)
+ goto error;
+
if (without_input)
ivi->compositor->require_input = !without_input;
@@ -955,10 +963,13 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[],
goto error;
}
+ free(drm_lease_name);
+
return 0;
error:
free(config.gbm_format);
+ free(drm_lease_name);
free(config.seat_id);
return -1;
}
@@ -2284,6 +2295,7 @@ error_compositor:
free(modules);
modules = NULL;
+ cleanup_drm_lease(ivi.drm_lease);
weston_compositor_destroy(ivi.compositor);
weston_log_scope_destroy(log_scope);
diff --git a/src/drm-lease.c b/src/drm-lease.c
new file mode 100644
index 0000000..0e796e1
--- /dev/null
+++ b/src/drm-lease.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2022 IGEL Co., Ltd.
+ * Copyright © 2024 AISIN CORPORATION
+ *
+ * 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>
+#include <libweston/backend-drm.h>
+
+#ifdef HAVE_DRM_LEASE
+int setup_drm_lease(struct dlm_lease **drm_lease, struct weston_drm_backend_config *config, const char *drm_lease_name)
+{
+ if (drm_lease_name == NULL) {
+ // drm lease option is not set. That is disabled.
+ config->device_fd = -1;
+ return 0;
+ }
+
+ int drm_fd = -1;
+ 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);
+ cleanup_drm_lease(lease);
+ config->device_fd = -1;
+ return -1;
+ }
+
+ *drm_lease = lease;
+ config->device_fd = drm_fd;
+
+ return 0;
+}
+
+void cleanup_drm_lease(struct dlm_lease *lease)
+{
+ if (lease)
+ dlm_release_lease(lease);
+}
+#else //#ifdef HAVE_DRM_LEASE
+int setup_drm_lease(struct dlm_lease **drm_lease, struct weston_drm_backend_config *config, const char *drm_lease_name)
+{
+ if (drm_lease_name != NULL) {
+ weston_log("Set drm lease option but drm lease feature is disabled.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+void cleanup_drm_lease(struct dlm_lease *lease)
+{
+ return;
+}
+#endif //#ifdef HAVE_DRM_LEASE
diff --git a/src/drm-lease.h b/src/drm-lease.h
new file mode 100644
index 0000000..3ef16a2
--- /dev/null
+++ b/src/drm-lease.h
@@ -0,0 +1,15 @@
+#ifndef DRM_LEASE_H
+#define DRM_LEASE_H
+
+#include "config.h"
+
+#ifdef HAVE_DRM_LEASE
+#include <dlmclient.h>
+#else
+struct dlm_lease;
+#endif //#ifdef HAVE_DRM_LEASE
+struct weston_drm_backend_config;
+
+int setup_drm_lease(struct dlm_lease **drm_lease, struct weston_drm_backend_config *config, const char *drm_lease_name);
+void cleanup_drm_lease(struct dlm_lease *drm_lease);
+#endif /* DRM_LEASE_H */
diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h
index 1e8c55a..ea8138a 100644
--- a/src/ivi-compositor.h
+++ b/src/ivi-compositor.h
@@ -36,6 +36,7 @@
#include <libweston/desktop.h>
#include "remote.h"
+#include "drm-lease.h"
#include "agl-shell-server-protocol.h"
@@ -148,6 +149,7 @@ struct ivi_compositor {
bool need_ivi_output_relayout;
struct wl_list child_process_list;
+ struct dlm_lease *drm_lease;
};
struct ivi_surface;