diff options
Diffstat (limited to 'meta-agl-drm-lease/recipes-graphics')
3 files changed, 120 insertions, 126 deletions
diff --git a/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-backend-drm-Add-method-to-import-DRM-fd.patch b/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-backend-drm-Add-method-to-import-DRM-fd.patch index 7387be9c..a87e8bac 100644 --- a/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-backend-drm-Add-method-to-import-DRM-fd.patch +++ b/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-backend-drm-Add-method-to-import-DRM-fd.patch @@ -1,7 +1,7 @@ -From 9ce172053169bbfd27ef8c18eb50ebac348f5bc2 Mon Sep 17 00:00:00 2001 -From: Damian Hobson-Garcia <dhobsong@igel.co.jp> -Date: Mon, 11 Apr 2022 18:50:45 +0900 -Subject: [PATCH 1/3] backend-drm: Add method to import DRM fd +From 46e5ec89cad434b1a1dd9ca49a35e1c6992c54c1 Mon Sep 17 00:00:00 2001 +From: Marius Vlad <marius.vlad@collabora.com> +Date: Thu, 2 May 2024 19:11:06 +0300 +Subject: [PATCH 1/2] backend-drm: Add method to import DRM fd Allow the compositor to provide a file descriptor for a DRM device. @@ -15,20 +15,21 @@ Having the DRM device management in the compositor allows for integrating a platform specific resource manager without having to add extra dependencies to the generic libweston code. -%% original patch: 0001-backend-drm-Add-method-to-import-DRM-fd.patch +Signed-off-by: Marius Vlad <marius.vlad@collabora.com> +Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp> --- include/libweston/backend-drm.h | 7 +++ - libweston/backend-drm/drm.c | 75 ++++++++++++++++++++++++--------- - 2 files changed, 63 insertions(+), 19 deletions(-) + libweston/backend-drm/drm.c | 78 ++++++++++++++++++++++++--------- + 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/include/libweston/backend-drm.h b/include/libweston/backend-drm.h -index af2da4a..2c12b17 100644 +index d47955c..889848a 100644 --- a/include/libweston/backend-drm.h +++ b/include/libweston/backend-drm.h -@@ -223,6 +223,13 @@ struct weston_drm_backend_config { - - /** Use shadow buffer if using Pixman-renderer. */ - bool use_pixman_shadow; +@@ -258,6 +258,13 @@ struct weston_drm_backend_config { + * rendering device. + */ + char *additional_devices; + + /** DRM device file descriptor to use + * @@ -40,7 +41,7 @@ index af2da4a..2c12b17 100644 #ifdef __cplusplus diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c -index 4278770..0707db7 100644 +index 8092789..4e78ad0 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -40,6 +40,7 @@ @@ -49,9 +50,9 @@ index 4278770..0707db7 100644 #include <sys/mman.h> +#include <sys/stat.h> #include <time.h> + #include <poll.h> - #include <xf86drm.h> -@@ -2670,29 +2671,22 @@ drm_device_changed(struct weston_compositor *compositor, +@@ -3431,31 +3432,22 @@ drm_device_changed(struct weston_backend *backend, wl_signal_emit(&compositor->session_signal, compositor); } @@ -60,25 +61,27 @@ index 4278770..0707db7 100644 - * sets b->drm.fd and b->drm.filename to the opened device. - */ static bool --drm_device_is_kms(struct drm_backend *b, struct udev_device *device) -+drm_backend_update_kms_device(struct drm_backend *b, struct udev_device *device, -+ const char *name, int drm_fd) +-drm_device_is_kms(struct drm_backend *b, struct drm_device *device, +- struct udev_device *udev_device) ++drm_backend_update_kms_device(struct drm_backend *b, struct drm_device *device, ++ struct udev_device *udev_device, const char *name, int drm_fd) { -- const char *filename = udev_device_get_devnode(device); - const char *sysnum = udev_device_get_sysnum(device); - dev_t devnum = udev_device_get_devnum(device); + struct weston_compositor *compositor = b->compositor; +- const char *filename = udev_device_get_devnode(udev_device); + const char *sysnum = udev_device_get_sysnum(udev_device); + dev_t devnum = udev_device_get_devnum(udev_device); drmModeRes *res; - int id = -1, fd; + int id = -1; - if (!filename) +- return false; +- +- fd = weston_launcher_open(compositor->launcher, filename, O_RDWR); +- if (fd < 0) + if (!name) return false; -- fd = weston_launcher_open(b->compositor->launcher, filename, O_RDWR); -- if (fd < 0) -- return false; - - res = drmModeGetResources(fd); + res = drmModeGetResources(drm_fd); if (!res) @@ -87,7 +90,7 @@ index 4278770..0707db7 100644 if (res->count_crtcs <= 0 || res->count_connectors <= 0 || res->count_encoders <= 0) -@@ -2701,7 +2695,7 @@ drm_device_is_kms(struct drm_backend *b, struct udev_device *device) +@@ -3464,7 +3456,7 @@ drm_device_is_kms(struct drm_backend *b, struct drm_device *device, if (sysnum) id = atoi(sysnum); if (!sysnum || id < 0) { @@ -96,19 +99,19 @@ index 4278770..0707db7 100644 goto out_res; } -@@ -2711,9 +2705,9 @@ drm_device_is_kms(struct drm_backend *b, struct udev_device *device) - weston_launcher_close(b->compositor->launcher, b->drm.fd); - free(b->drm.filename); +@@ -3474,9 +3466,9 @@ drm_device_is_kms(struct drm_backend *b, struct drm_device *device, + weston_launcher_close(compositor->launcher, device->drm.fd); + free(device->drm.filename); -- b->drm.fd = fd; -+ b->drm.fd = drm_fd; - b->drm.id = id; -- b->drm.filename = strdup(filename); -+ b->drm.filename = strdup(name); - b->drm.devnum = devnum; +- device->drm.fd = fd; ++ device->drm.fd = drm_fd; + device->drm.id = id; +- device->drm.filename = strdup(filename); ++ device->drm.filename = strdup(name); + device->drm.devnum = devnum; drmModeFreeResources(res); -@@ -2722,11 +2716,33 @@ drm_device_is_kms(struct drm_backend *b, struct udev_device *device) +@@ -3485,11 +3477,34 @@ drm_device_is_kms(struct drm_backend *b, struct drm_device *device, out_res: drmModeFreeResources(res); @@ -122,10 +125,11 @@ index 4278770..0707db7 100644 + * sets b->drm.fd and b->drm.filename to the opened device. + */ +static bool -+drm_device_is_kms(struct drm_backend *b, struct udev_device *device) ++drm_device_is_kms(struct drm_backend *b, struct drm_device *device, ++ struct udev_device *udev_device) +{ + int fd; -+ const char *filename = udev_device_get_devnode(device); ++ const char *filename = udev_device_get_devnode(udev_device); + if (!filename) + return false; + @@ -133,7 +137,7 @@ index 4278770..0707db7 100644 + if (fd < 0) + return false; + -+ if (!drm_backend_update_kms_device(b, device, filename, fd)) { ++ if (!drm_backend_update_kms_device(b, b->drm, udev_device, filename, fd)) { + weston_launcher_close(b->compositor->launcher, fd); + return false; + } @@ -144,33 +148,33 @@ index 4278770..0707db7 100644 /* * Find primary GPU * Some systems may have multiple DRM devices attached to a single seat. This -@@ -2814,6 +2830,25 @@ find_primary_gpu(struct drm_backend *b, const char *seat) +@@ -3578,6 +3593,25 @@ find_primary_gpu(struct drm_backend *b, const char *seat) return drm_device; } +static struct udev_device * +import_drm_device_fd(struct drm_backend *b, int fd) +{ -+ struct udev_device *device; ++ struct udev_device *udev_device; + struct stat s; + + if (fstat(fd, &s) < 0 || !S_ISCHR(s.st_mode)) + return NULL; + -+ device = udev_device_new_from_devnum(b->udev, 'c', s.st_rdev); -+ if (!device) ++ udev_device = udev_device_new_from_devnum(b->udev, 'c', s.st_rdev); ++ if (!udev_device) + return NULL; + -+ if (!drm_backend_update_kms_device(b, device, "imported DRM device fd", fd)) ++ if (!drm_backend_update_kms_device(b, b->drm, udev_device, "imported DRM device fd", fd)) + return NULL; + -+ return device; ++ return udev_device; +} + static struct udev_device * - open_specific_drm_device(struct drm_backend *b, const char *name) - { -@@ -3038,7 +3073,9 @@ drm_backend_create(struct weston_compositor *compositor, + open_specific_drm_device(struct drm_backend *b, struct drm_device *device, + const char *name) +@@ -3904,7 +3938,9 @@ drm_backend_create(struct weston_compositor *compositor, b->session_listener.notify = session_notify; wl_signal_add(&compositor->session_signal, &b->session_listener); @@ -178,9 +182,9 @@ index 4278770..0707db7 100644 + if (config->device_fd > 0) + drm_device = import_drm_device_fd(b, config->device_fd); + else if (config->specific_device) - drm_device = open_specific_drm_device(b, config->specific_device); + drm_device = open_specific_drm_device(b, device, + config->specific_device); else - drm_device = find_primary_gpu(b, seat_id); -- -2.17.1 +2.43.0 diff --git a/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-compositor-do-not-request-repaint-in-output_enable.patch b/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-compositor-do-not-request-repaint-in-output_enable.patch index 8301b051..f982f0b6 100644 --- a/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-compositor-do-not-request-repaint-in-output_enable.patch +++ b/meta-agl-drm-lease/recipes-graphics/weston/weston/0001-compositor-do-not-request-repaint-in-output_enable.patch @@ -1,7 +1,7 @@ -From 434e7f0e87c7728ad2c9056ee4cf42686db2d5f2 Mon Sep 17 00:00:00 2001 -From: Michael Tretter <m.tretter@pengutronix.de> -Date: Thu, 23 Aug 2018 16:58:47 +0200 -Subject: [PATCH 3/3] compositor: do not request repaint in output_enable +From c030a31ee81e5d17002b4b6ee672ae3d532e4e28 Mon Sep 17 00:00:00 2001 +From: Marius Vlad <marius.vlad@collabora.com> +Date: Sat, 4 May 2024 23:27:57 +0300 +Subject: [PATCH] compositor: do not request repaint in output_enable When enabling a weston_output, the compositor damages the entire output, to ensure that the entire output is redrawn. However, this triggers a @@ -12,27 +12,25 @@ Damage the entire output region, but do not trigger the repaint when enabling a weston_output. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> - -%% original patch: 0001-compositor-do-not-request-repaint-in-output_enable.patch +Signed-off-by: Marius Vlad <marius.vlad@collabora.com> --- - libweston/compositor.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) + libweston/compositor.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libweston/compositor.c b/libweston/compositor.c -index 1670c50..a983e60 100644 +index 34cde8c..3eba50d 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c -@@ -6762,7 +6762,9 @@ weston_output_enable(struct weston_output *output) - weston_output_init_zoom(output); +@@ -7823,7 +7823,8 @@ weston_output_enable(struct weston_output *output) + } - weston_output_init_geometry(output, x, y); + weston_compositor_add_output(output->compositor, output); - weston_output_damage(output); -+ pixman_region32_union(&c->primary_plane.damage, -+ &c->primary_plane.damage, -+ &output->region); ++ weston_output_flush_damage_for_plane(output, &output->primary_plane, ++ &output->region); - wl_list_init(&output->animation_list); - wl_list_init(&output->feedback_list); + head_names = weston_output_create_heads_string(output); + weston_log("Output '%s' enabled with head(s) %s\n", -- -2.17.1 +2.43.0 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 index a2249460..48314680 100644 --- 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 @@ -1,29 +1,30 @@ -From 5c315a4e4ab5e0d0376508f72c6f8a8070251c3f Mon Sep 17 00:00:00 2001 -From: Damian Hobson-Garcia <dhobsong@igel.co.jp> -Date: Mon, 11 Apr 2022 18:43:06 +0900 -Subject: [PATCH 2/3] Add DRM lease support +From 180b3f71ef411c88d4fd40a90ef75ef1a694805e Mon Sep 17 00:00:00 2001 +From: Marius Vlad <marius.vlad@collabora.com> +Date: Thu, 2 May 2024 19:45:41 +0300 +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. -%% original patch: 0002-Add-DRM-lease-support.patch +Signed-off-by: Marius Vlad <marius.vlad@collabora.com> +Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp> --- - compositor/drm-lease.c | 53 +++++++++++++++++++++++++++++++++++++ - compositor/drm-lease.h | 40 ++++++++++++++++++++++++++++ - compositor/main.c | 10 +++++++ - compositor/meson.build | 5 ++++ + compositor/drm-lease.c | 51 +++++++++++++++++++++++++++++++++++++ + compositor/drm-lease.h | 40 +++++++++++++++++++++++++++++ + compositor/main.c | 9 +++++++ + compositor/meson.build | 6 +++++ libweston/backend-drm/drm.c | 1 + meson_options.txt | 7 +++++ - 6 files changed, 116 insertions(+) + 6 files changed, 114 insertions(+) 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 0000000..fdb1f5e +index 0000000..11ee2e4 --- /dev/null +++ b/compositor/drm-lease.c -@@ -0,0 +1,53 @@ +@@ -0,0 +1,51 @@ +/* + * Copyright © 2021 IGEL Co., Ltd. + * @@ -65,9 +66,9 @@ index 0000000..fdb1f5e + dlm_release_lease(lease); + } + if (drm_fd < 0) -+ weston_log("Could not get DRM lease %s\n", drm_lease_name); ++ weston_log("Could not get DRM lease %s\n", drm_lease_name); + -+ *drm_lease = lease; ++ *drm_lease = lease; + return drm_fd; +} + @@ -75,8 +76,6 @@ index 0000000..fdb1f5e + if (lease) + dlm_release_lease(lease); +} -+ -+ diff --git a/compositor/drm-lease.h b/compositor/drm-lease.h new file mode 100644 index 0000000..a102e4c @@ -124,10 +123,10 @@ index 0000000..a102e4c + +#endif diff --git a/compositor/main.c b/compositor/main.c -index 322f2ff..419ad06 100644 +index 0e3d375..bb8e27e 100644 --- a/compositor/main.c +++ b/compositor/main.c -@@ -65,6 +65,7 @@ +@@ -70,6 +70,7 @@ #include <libweston/weston-log.h> #include <libweston/remoting-plugin.h> #include <libweston/pipewire-plugin.h> @@ -135,97 +134,90 @@ index 322f2ff..419ad06 100644 #define WINDOW_TITLE "Weston Compositor" /* flight recorder size (in bytes) */ -@@ -127,6 +128,7 @@ struct wet_compositor { - pid_t autolaunch_pid; - bool autolaunch_watch; - bool use_color_manager; +@@ -152,6 +153,7 @@ struct wet_compositor { + bool drm_backend_loaded; + struct wl_listener screenshot_auth; + enum require_outputs require_outputs; + struct dlm_lease *drm_lease; }; static FILE *weston_logfile = NULL; -@@ -687,6 +689,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" +@@ -718,6 +720,9 @@ usage(int error_code) + " --drm-device=CARD\tThe DRM device to use for rendering and output, e.g. \"card0\".\n" + " --additional-devices=CARD\tSecondary DRM devices to use for output only, e.g. \"card1,card2\".\n" + " --use-pixman\t\tUse the pixman (CPU) renderer (deprecated alias for --renderer=pixman)\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" " --continue-without-input\tAllow the compositor to start without input devices\n\n"); -@@ -2626,6 +2631,7 @@ load_drm_backend(struct weston_compositor *c, - struct wet_compositor *wet = to_wet_compositor(c); + #endif +@@ -3025,6 +3030,7 @@ load_drm_backend(struct weston_compositor *c, int *argc, char **argv, + struct wet_backend *wb; bool without_input = false; - int ret = 0; + bool force_pixman = false; + char *drm_lease_name = NULL; wet->drm_use_current_mode = false; -@@ -2637,6 +2643,7 @@ load_drm_backend(struct weston_compositor *c, +@@ -3036,6 +3042,7 @@ load_drm_backend(struct weston_compositor *c, int *argc, char **argv, + const struct weston_option options[] = { { 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_STRING, "additional-devices", 0, &config.additional_devices}, { WESTON_OPTION_BOOLEAN, "current-mode", 0, &wet->drm_use_current_mode }, - { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman }, - { WESTON_OPTION_BOOLEAN, "continue-without-input", false, &without_input } -@@ -2658,6 +2665,7 @@ load_drm_backend(struct weston_compositor *c, + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman }, +@@ -3067,6 +3074,7 @@ load_drm_backend(struct weston_compositor *c, int *argc, char **argv, 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 = get_drm_lease(&wet->drm_lease, drm_lease_name); - wet->heads_changed_listener.notify = drm_heads_changed; - weston_compositor_add_heads_changed_listener(c, -@@ -2675,6 +2683,7 @@ load_drm_backend(struct weston_compositor *c, + wb = wet_compositor_load_backend(c, WESTON_BACKEND_DRM, &config.base, + drm_heads_changed, NULL); +@@ -3080,6 +3088,7 @@ load_drm_backend(struct weston_compositor *c, int *argc, char **argv, free(config.gbm_format); free(config.seat_id); free(config.specific_device); + free(drm_lease_name); - return ret; + return 0; } -@@ -3577,6 +3586,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 8a54ea9..5700d25 100644 +index 7b49c48..d0f7c6a 100644 --- a/compositor/meson.build +++ b/compositor/meson.build -@@ -25,6 +25,11 @@ if get_option('xwayland') - srcs_weston += 'xwayland.c' +@@ -25,6 +25,12 @@ if get_option('xwayland') 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', + sources: srcs_weston, diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c -index 0707db7..03e80ce 100644 +index 4e78ad0..3b747ed 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c -@@ -3267,6 +3267,7 @@ static void - config_init_to_defaults(struct weston_drm_backend_config *config) +@@ -4150,6 +4150,7 @@ config_init_to_defaults(struct weston_drm_backend_config *config) { + config->renderer = WESTON_RENDERER_AUTO; config->use_pixman_shadow = true; + config->device_fd = -1; } WL_EXPORT int diff --git a/meson_options.txt b/meson_options.txt -index 8a527d7..db9f19b 100644 +index ac355f1..b0d32a0 100644 --- a/meson_options.txt +++ b/meson_options.txt -@@ -106,6 +106,13 @@ option( +@@ -105,6 +105,13 @@ option( description: 'Virtual remote output with Pipewire on DRM backend' ) @@ -240,5 +232,5 @@ index 8a527d7..db9f19b 100644 'shell-desktop', type: 'boolean', -- -2.17.1 +2.43.0 |