From: Saalim Quadri Date: Thu, 20 Mar 2025 05:32:46 +0000 (+0530) Subject: meta-agl-drm-lease: kmscube: Fix patchsets X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=98de20772b5d52c326017e292b8dbfc91024efa0;p=AGL%2Fmeta-agl-devel.git meta-agl-drm-lease: kmscube: Fix patchsets * After [1], we do not require updating the inclusion header * Rebase drm lease support on current source revision of kmscube [1]: https://gitlab.freedesktop.org/mesa/kmscube/-/commit/94bee60c016bfc55164715249d2bb724de095ea9 Change-Id: Id763ac54efa74d3699e44c99f83f5e6bb150482d Signed-off-by: Saalim Quadri --- diff --git a/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0001-Add-DRM-lease-support.patch b/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0001-Add-DRM-lease-support.patch new file mode 100644 index 00000000..d40bd0c6 --- /dev/null +++ b/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0001-Add-DRM-lease-support.patch @@ -0,0 +1,246 @@ +From 35d9eab43bd7bee493c42abee99d351d93d27d4a Mon Sep 17 00:00:00 2001 +From: Damian Hobson-Garcia +Date: Thu, 20 Mar 2025 10:51:58 +0530 +Subject: [PATCH] Add DRM lease support + +Signed-off-by: Saalim Quadri +--- + drm-atomic.c | 4 ++-- + drm-common.c | 21 +++++++++++++++++++-- + drm-common.h | 9 ++++++--- + drm-legacy.c | 4 ++-- + kmscube.c | 19 ++++++++++++++----- + meson.build | 5 +++++ + meson_options.txt | 5 +++++ + texturator.c | 2 +- + 8 files changed, 54 insertions(+), 15 deletions(-) + +diff --git a/drm-atomic.c b/drm-atomic.c +index 02771db..8d5e44d 100644 +--- a/drm-atomic.c ++++ b/drm-atomic.c +@@ -392,12 +392,12 @@ static int get_plane_id(void) + } + + const struct drm * init_drm_atomic(const char *device, const char *mode_str, +- int connector_id, unsigned int vrefresh, unsigned int count) ++ int connector_id, unsigned int vrefresh, unsigned int count, int lease) + { + uint32_t plane_id; + int ret; + +- ret = init_drm(&drm, device, mode_str, connector_id, vrefresh, count); ++ ret = init_drm(&drm, device, mode_str, connector_id, vrefresh, count, lease); + if (ret) + return NULL; + +diff --git a/drm-common.c b/drm-common.c +index 40f7112..d7c7bd5 100644 +--- a/drm-common.c ++++ b/drm-common.c +@@ -32,6 +32,10 @@ + #include "common.h" + #include "drm-common.h" + ++#ifdef HAVE_DRM_LEASE ++#include "dlmclient.h" ++#endif ++ + WEAK union gbm_bo_handle + gbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane); + +@@ -173,6 +177,19 @@ static int get_resources(int fd, drmModeRes **resources) + return 0; + } + ++static int open_device(struct drm *drm, const char *device, int lease) ++{ ++ if (!lease) ++ return open(device, O_RDWR); ++ ++#ifdef HAVE_DRM_LEASE ++ drm->lease = dlm_get_lease(device); ++ if (drm->lease) ++ return dlm_lease_fd(drm->lease); ++#endif ++ return -1; ++} ++ + #define MAX_DRM_DEVICES 64 + + static int find_drm_render_device(void) +@@ -270,7 +287,7 @@ static drmModeConnector * find_drm_connector(int fd, drmModeRes *resources, + } + + int init_drm(struct drm *drm, const char *device, const char *mode_str, +- int connector_id, unsigned int vrefresh, unsigned int count) ++ int connector_id, unsigned int vrefresh, unsigned int count, int lease) + { + drmModeRes *resources; + drmModeConnector *connector = NULL; +@@ -278,7 +295,7 @@ int init_drm(struct drm *drm, const char *device, const char *mode_str, + int i, ret, area; + + if (device) { +- drm->fd = open(device, O_RDWR); ++ drm->fd = open(device, O_RDWR, lease); + ret = get_resources(drm->fd, &resources); + if (ret < 0 && errno == EOPNOTSUPP) + printf("%s does not look like a modeset device\n", device); +diff --git a/drm-common.h b/drm-common.h +index 4a4f9be..3ef77e2 100644 +--- a/drm-common.h ++++ b/drm-common.h +@@ -51,6 +51,9 @@ struct connector { + struct drm { + int fd; + ++ /* only used for DRM lease */ ++ struct dlm_lease *lease; ++ + /* only used for atomic: */ + struct plane *plane; + struct crtc *crtc; +@@ -76,10 +79,10 @@ struct drm_fb { + + struct drm_fb * drm_fb_get_from_bo(struct gbm_bo *bo); + +-int init_drm(struct drm *drm, const char *device, const char *mode_str, int connector_id, unsigned int vrefresh, unsigned int count); ++int init_drm(struct drm *drm, const char *device, const char *mode_str, int connector_id, unsigned int vrefresh, unsigned int count, int lease); + int init_drm_render(struct drm *drm, const char *device, const char *mode_str, unsigned int count); +-const struct drm * init_drm_legacy(const char *device, const char *mode_str, int connector_id, unsigned int vrefresh, unsigned int count); +-const struct drm * init_drm_atomic(const char *device, const char *mode_str, int connector_id, unsigned int vrefresh, unsigned int count); ++const struct drm * init_drm_legacy(const char *device, const char *mode_str, int connector_id, unsigned int vrefresh, unsigned int count, int lease); ++const struct drm * init_drm_atomic(const char *device, const char *mode_str, int connector_id, unsigned int vrefresh, unsigned int count, int lease); + const struct drm * init_drm_offscreen(const char *device, const char *mode_str, unsigned int count); + + #endif /* _DRM_COMMON_H */ +diff --git a/drm-legacy.c b/drm-legacy.c +index e60ea7d..4e6dd47 100644 +--- a/drm-legacy.c ++++ b/drm-legacy.c +@@ -170,11 +170,11 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) + } + + const struct drm * init_drm_legacy(const char *device, const char *mode_str, +- int connector_id, unsigned int vrefresh, unsigned int count) ++ int connector_id, unsigned int vrefresh, unsigned int count, int lease) + { + int ret; + +- ret = init_drm(&drm, device, mode_str, connector_id, vrefresh, count); ++ ret = init_drm(&drm, device, mode_str, connector_id, vrefresh, count, lease); + if (ret) + return NULL; + +diff --git a/kmscube.c b/kmscube.c +index e8a47a9..12b69f9 100644 +--- a/kmscube.c ++++ b/kmscube.c +@@ -41,7 +41,7 @@ static const struct egl *egl; + static const struct gbm *gbm; + static const struct drm *drm; + +-static const char *shortopts = "Ac:D:f:gM:m:n:Op:S:s:V:v:x"; ++static const char *shortopts = "Ac:D:f:gL:M:m:n:Op:S:s:V:v:x"; + + static const struct option longopts[] = { + {"atomic", no_argument, 0, 'A'}, +@@ -49,6 +49,7 @@ static const struct option longopts[] = { + {"device", required_argument, 0, 'D'}, + {"format", required_argument, 0, 'f'}, + {"gears", no_argument, 0, 'g'}, ++ {"drm-lease", no_argument, 0, 'L'}, + {"mode", required_argument, 0, 'M'}, + {"modifier", required_argument, 0, 'm'}, + {"connector_id", required_argument, 0, 'n'}, +@@ -69,6 +70,9 @@ static void usage(const char *name) + " -A, --atomic use atomic modesetting and fencing\n" + " -c, --count=N run for the specified number of frames\n" + " -D, --device=DEVICE use the given device\n" ++#ifdef HAVE_DRM_LEASE ++ " -L, --drm-lease the given device is the name of a DRM lease:\n" ++#endif + " -f, --format=FOURCC framebuffer format\n" + " -g, --gears render gears on each cube face\n" + " -M, --mode=MODE specify mode, one of:\n" +@@ -104,8 +108,8 @@ int main(int argc, char *argv[]) + uint32_t format = DRM_FORMAT_XRGB8888; + uint64_t modifier = DRM_FORMAT_MOD_LINEAR; + int samples = 0; +- int atomic = 0; +- int gears = 0; ++ int atomic = 0; int gears = 0; ++ int lease = 0; + int offscreen = 0; + int connector_id = -1; + int opt; +@@ -148,6 +152,11 @@ int main(int argc, char *argv[]) + case 'g': + gears = 1; + break; ++#ifdef HAVE_DRM_LEASE ++ case 'L': ++ lease = 1; ++ break; ++#endif + case 'M': + if (strcmp(optarg, "smooth") == 0) { + mode = SMOOTH; +@@ -216,9 +225,9 @@ int main(int argc, char *argv[]) + if (offscreen) + drm = init_drm_offscreen(device, mode_str, count); + else if (atomic) +- drm = init_drm_atomic(device, mode_str, connector_id, vrefresh, count); ++ drm = init_drm_atomic(device, mode_str, connector_id, vrefresh, count, lease); + else +- drm = init_drm_legacy(device, mode_str, connector_id, vrefresh, count); ++ drm = init_drm_legacy(device, mode_str, connector_id, vrefresh, count, lease); + if (!drm) { + printf("failed to initialize %s DRM\n", + offscreen ? "offscreen" : +diff --git a/meson.build b/meson.build +index 2b962a9..6ba9a2c 100644 +--- a/meson.build ++++ b/meson.build +@@ -104,6 +104,11 @@ else + message('Building without gstreamer support') + endif + ++if get_option('drm_lease').enabled() ++ dep_common += dependency('libdlmclient') ++ add_project_arguments('-DHAVE_DRM_LEASE', language : 'c') ++endif ++ + executable('kmscube', sources, dependencies : dep_common, install : true) + + if with_gles3 +diff --git a/meson_options.txt b/meson_options.txt +index 1ed8abc..d932a1c 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -3,3 +3,8 @@ option( + type : 'feature', + description : 'Enable support for gstreamer and cube-video' + ) ++option( ++ 'drm_lease', ++ type : 'feature', ++ description : 'Enable support for running as a DRM lease client' ++) +diff --git a/texturator.c b/texturator.c +index 7aa34ee..4d5c887 100644 +--- a/texturator.c ++++ b/texturator.c +@@ -950,7 +950,7 @@ int main(int argc, char *argv[]) + print_summary(); + + /* no real need for atomic here: */ +- drm = init_drm_legacy(device, mode_str, -1, vrefresh, ~0); ++ drm = init_drm_legacy(device, mode_str, -1, vrefresh, ~0, 0); + if (!drm) { + printf("failed to initialize DRM\n"); + return -1; +-- +2.34.1 + diff --git a/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0001-texturator-Use-correct-GL-extension-header.patch b/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0001-texturator-Use-correct-GL-extension-header.patch deleted file mode 100644 index d6050778..00000000 --- a/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0001-texturator-Use-correct-GL-extension-header.patch +++ /dev/null @@ -1,30 +0,0 @@ -From afe70b04556be4840e7fe74d7601946ade8fdbfa Mon Sep 17 00:00:00 2001 -From: Damian Hobson-Garcia -Date: Wed, 16 Dec 2020 11:08:25 +0900 -Subject: [PATCH] texturator: Use correct GL extension header - -gl2ext.h is the extenstion header for OpenGL ES 2.0 and all later -versions according to the Khronos documentation [1]. gl3ext.h is either -an empty stub, or may not even exist on some platforms. - -[1]: https://www.khronos.org/registry/OpenGL/index_es.php#headers ---- - texturator.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/texturator.c b/texturator.c -index d9335d7..6d97856 100644 ---- a/texturator.c -+++ b/texturator.c -@@ -30,7 +30,7 @@ - #include - - #include --#include -+#include - - #ifdef HAVE_LIBPNG - #include --- -2.17.1 - diff --git a/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0002-Add-DRM-lease-support.patch b/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0002-Add-DRM-lease-support.patch deleted file mode 100644 index 0366bef0..00000000 --- a/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube/0002-Add-DRM-lease-support.patch +++ /dev/null @@ -1,235 +0,0 @@ -From 3a766fb852b53316f4b4c0b37ec801a5b188093b Mon Sep 17 00:00:00 2001 -From: Damian Hobson-Garcia -Date: Wed, 16 Dec 2020 16:21:57 +0900 -Subject: [PATCH] Add DRM lease support - ---- - drm-atomic.c | 4 ++-- - drm-common.c | 21 +++++++++++++++++++-- - drm-common.h | 9 ++++++--- - drm-legacy.c | 4 ++-- - kmscube.c | 12 +++++++++--- - meson.build | 5 +++++ - meson_options.txt | 5 +++++ - texturator.c | 2 +- - 8 files changed, 49 insertions(+), 13 deletions(-) - -diff --git a/drm-atomic.c b/drm-atomic.c -index d748772..8cb3ca5 100644 ---- a/drm-atomic.c -+++ b/drm-atomic.c -@@ -337,12 +337,12 @@ static int get_plane_id(void) - return ret; - } - --const struct drm * init_drm_atomic(const char *device, const char *mode_str, unsigned int vrefresh) -+const struct drm * init_drm_atomic(const char *device, const char *mode_str, unsigned int vrefresh, int lease) - { - uint32_t plane_id; - int ret; - -- ret = init_drm(&drm, device, mode_str, vrefresh); -+ ret = init_drm(&drm, device, mode_str, vrefresh, lease); - if (ret) - return NULL; - -diff --git a/drm-common.c b/drm-common.c -index b9d61c1..6e7d1ce 100644 ---- a/drm-common.c -+++ b/drm-common.c -@@ -32,6 +32,10 @@ - #include "common.h" - #include "drm-common.h" - -+#ifdef HAVE_DRM_LEASE -+#include "dlmclient.h" -+#endif -+ - WEAK uint64_t - gbm_bo_get_modifier(struct gbm_bo *bo); - -@@ -169,6 +173,19 @@ static int get_resources(int fd, drmModeRes **resources) - return 0; - } - -+static int open_device(struct drm *drm, const char *device, int lease) -+{ -+ if (!lease) -+ return open(device, O_RDWR); -+ -+#ifdef HAVE_DRM_LEASE -+ drm->lease = dlm_get_lease(device); -+ if (drm->lease) -+ return dlm_lease_fd(drm->lease); -+#endif -+ return -1; -+} -+ - #define MAX_DRM_DEVICES 64 - - static int find_drm_device(drmModeRes **resources) -@@ -208,7 +225,7 @@ static int find_drm_device(drmModeRes **resources) - return fd; - } - --int init_drm(struct drm *drm, const char *device, const char *mode_str, unsigned int vrefresh) -+int init_drm(struct drm *drm, const char *device, const char *mode_str, unsigned int vrefresh, int lease) - { - drmModeRes *resources; - drmModeConnector *connector = NULL; -@@ -216,7 +233,7 @@ int init_drm(struct drm *drm, const char *device, const char *mode_str, unsigned - int i, ret, area; - - if (device) { -- drm->fd = open(device, O_RDWR); -+ drm->fd = open_device(drm, device, lease); - ret = get_resources(drm->fd, &resources); - if (ret < 0 && errno == EOPNOTSUPP) - printf("%s does not look like a modeset device\n", device); -diff --git a/drm-common.h b/drm-common.h -index c4eb886..5119e79 100644 ---- a/drm-common.h -+++ b/drm-common.h -@@ -51,6 +51,9 @@ struct connector { - struct drm { - int fd; - -+ /* only used for DRM lease */ -+ struct dlm_lease *lease; -+ - /* only used for atomic: */ - struct plane *plane; - struct crtc *crtc; -@@ -73,8 +76,8 @@ struct drm_fb { - - struct drm_fb * drm_fb_get_from_bo(struct gbm_bo *bo); - --int init_drm(struct drm *drm, const char *device, const char *mode_str, unsigned int vrefresh); --const struct drm * init_drm_legacy(const char *device, const char *mode_str, unsigned int vrefresh); --const struct drm * init_drm_atomic(const char *device, const char *mode_str, unsigned int vrefresh); -+int init_drm(struct drm *drm, const char *device, const char *mode_str, unsigned int vrefresh, int lease); -+const struct drm * init_drm_legacy(const char *device, const char *mode_str, unsigned int vrefresh, int lease); -+const struct drm * init_drm_atomic(const char *device, const char *mode_str, unsigned int vrefresh, int lease); - - #endif /* _DRM_COMMON_H */ -diff --git a/drm-legacy.c b/drm-legacy.c -index 56a0fed..03db13d 100644 ---- a/drm-legacy.c -+++ b/drm-legacy.c -@@ -122,11 +122,11 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) - return 0; - } - --const struct drm * init_drm_legacy(const char *device, const char *mode_str, unsigned int vrefresh) -+const struct drm * init_drm_legacy(const char *device, const char *mode_str, unsigned int vrefresh, int lease) - { - int ret; - -- ret = init_drm(&drm, device, mode_str, vrefresh); -+ ret = init_drm(&drm, device, mode_str, vrefresh, lease); - if (ret) - return NULL; - -diff --git a/kmscube.c b/kmscube.c -index f14c1d9..abb5bdd 100644 ---- a/kmscube.c -+++ b/kmscube.c -@@ -41,12 +41,13 @@ static const struct egl *egl; - static const struct gbm *gbm; - static const struct drm *drm; - --static const char *shortopts = "AD:M:m:V:v:"; -+static const char *shortopts = "AD:LM:m:V:v:"; - - static const struct option longopts[] = { - {"atomic", no_argument, 0, 'A'}, - {"device", required_argument, 0, 'D'}, - {"format", required_argument, 0, 'f'}, -+ {"drm-lease", no_argument, 0, 'L'}, - {"mode", required_argument, 0, 'M'}, - {"modifier", required_argument, 0, 'm'}, - {"samples", required_argument, 0, 's'}, -@@ -62,6 +63,9 @@ static void usage(const char *name) - "options:\n" - " -A, --atomic use atomic modesetting and fencing\n" - " -D, --device=DEVICE use the given device\n" -+#ifdef HAVE_DRM_LEASE -+ " -L, --drm-lease the given device is the name of a DRM lease:\n" -+#endif - " -M, --mode=MODE specify mode, one of:\n" - " smooth - smooth shaded cube (default)\n" - " rgba - rgba textured cube\n" -@@ -87,6 +89,7 @@ int main(int argc, char *argv[]) - uint64_t modifier = DRM_FORMAT_MOD_LINEAR; - int samples = 0; - int atomic = 0; -+ int lease = 0; - int opt; - unsigned int len; - unsigned int vrefresh = 0; -@@ -119,6 +122,11 @@ int main(int argc, char *argv[]) - fourcc[2], fourcc[3]); - break; - } -+#ifdef HAVE_DRM_LEASE -+ case 'L': -+ lease = 1; -+ break; -+#endif - case 'M': - if (strcmp(optarg, "smooth") == 0) { - mode = SMOOTH; -@@ -164,9 +170,9 @@ int main(int argc, char *argv[]) - } - - if (atomic) -- drm = init_drm_atomic(device, mode_str, vrefresh); -+ drm = init_drm_atomic(device, mode_str, vrefresh, lease); - else -- drm = init_drm_legacy(device, mode_str, vrefresh); -+ drm = init_drm_legacy(device, mode_str, vrefresh, lease); - if (!drm) { - printf("failed to initialize %s DRM\n", atomic ? "atomic" : "legacy"); - return -1; -diff --git a/meson.build b/meson.build -index df9c315..1b47a52 100644 ---- a/meson.build -+++ b/meson.build -@@ -91,6 +91,11 @@ else - message('Building without gstreamer support') - endif - -+if get_option('drm_lease').enabled() -+ dep_common += dependency('libdlmclient') -+ add_project_arguments('-DHAVE_DRM_LEASE', language : 'c') -+endif -+ - executable('kmscube', sources, dependencies : dep_common, install : true) - - -diff --git a/meson_options.txt b/meson_options.txt -index 1ed8abc..d932a1c 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -3,3 +3,8 @@ option( - type : 'feature', - description : 'Enable support for gstreamer and cube-video' - ) -+option( -+ 'drm_lease', -+ type : 'feature', -+ description : 'Enable support for running as a DRM lease client' -+) -diff --git a/texturator.c b/texturator.c -index 3d09e9e..9b87f0d 100644 ---- a/texturator.c -+++ b/texturator.c -@@ -948,7 +948,7 @@ int main(int argc, char *argv[]) - print_summary(); - - /* no real need for atomic here: */ -- drm = init_drm_legacy(device, mode_str, vrefresh); -+ drm = init_drm_legacy(device, mode_str, vrefresh, 0); - if (!drm) { - printf("failed to initialize DRM\n"); - return -1; diff --git a/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube_agl-drm-lease.inc b/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube_agl-drm-lease.inc index fded6ce4..3ced13e6 100644 --- a/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube_agl-drm-lease.inc +++ b/meta-agl-drm-lease/recipes-graphics/kmscube/kmscube_agl-drm-lease.inc @@ -1,8 +1,6 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/kmscube:" - -SRC_URI += "file://0001-texturator-Use-correct-GL-extension-header.patch \ - file://0002-Add-DRM-lease-support.patch" +SRC_URI += "file://0001-Add-DRM-lease-support.patch" PACKAGECONFIG += "drm-lease" PACKAGECONFIG[drm-lease] = "-Ddrm_lease=enabled,-Ddrm_lease=disabled,drm-lease-manager"