From 74a74be23feb5d44121f059e1ab96787be4b7532 Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Thu, 15 Dec 2016 14:22:05 +0100 Subject: apalis-tk1: Mainline kernel machine This patch adds mainline linux based Apalis TK1 machine. It includes compatible recipes for libdrm, mesa, Xorg, and weston. Signed-off-by: Dominik Sliwa Acked-by: Max Krummenacher --- ...drm-Add-new-gbm-struct-to-allow-for-a-sep.patch | 181 +++++++++++++++++++ ...itor-drm-Add-support-for-Tegra-Jetson-TK1.patch | 195 +++++++++++++++++++++ ...-glFinish-to-DRM-backend-to-avoid-tearing.patch | 48 +++++ ...sed-detection-of-display-and-render-nodes.patch | 73 ++++++++ recipes-graphics/wayland/weston_%.bbappend | 12 ++ 5 files changed, 509 insertions(+) create mode 100644 recipes-graphics/wayland/files/0001-compositor-drm-Add-new-gbm-struct-to-allow-for-a-sep.patch create mode 100644 recipes-graphics/wayland/files/0002-compositor-drm-Add-support-for-Tegra-Jetson-TK1.patch create mode 100644 recipes-graphics/wayland/files/0003-Add-glFinish-to-DRM-backend-to-avoid-tearing.patch create mode 100644 recipes-graphics/wayland/files/0004-use-name-based-detection-of-display-and-render-nodes.patch create mode 100644 recipes-graphics/wayland/weston_%.bbappend (limited to 'recipes-graphics/wayland') diff --git a/recipes-graphics/wayland/files/0001-compositor-drm-Add-new-gbm-struct-to-allow-for-a-sep.patch b/recipes-graphics/wayland/files/0001-compositor-drm-Add-new-gbm-struct-to-allow-for-a-sep.patch new file mode 100644 index 0000000..cbd2cd5 --- /dev/null +++ b/recipes-graphics/wayland/files/0001-compositor-drm-Add-new-gbm-struct-to-allow-for-a-sep.patch @@ -0,0 +1,181 @@ +From 0719ed96aa2c41afe342f4c3c19e4ca91f270be2 Mon Sep 17 00:00:00 2001 +From: James Thomas +Date: Fri, 20 Jun 2014 12:12:26 +0100 +Subject: [PATCH 1/6] compositor-drm: Add new gbm struct to allow for a + separate gbm device + +This is needed for devices like tegra jetson where the gbm device is not +the same as the drm device +--- + src/compositor-drm.c | 48 +++++++++++++++++++++++++++--------------------- + 1 file changed, 27 insertions(+), 21 deletions(-) + +diff --git a/src/compositor-drm.c b/src/compositor-drm.c +index 893877d..5db86dc 100644 +--- a/src/compositor-drm.c ++++ b/src/compositor-drm.c +@@ -90,8 +90,11 @@ struct drm_backend { + int fd; + char *filename; + } drm; +- struct gbm_device *gbm; +- uint32_t *crtcs; ++ struct { ++ int fd; ++ char *filename; ++ } gbm; ++ struct gbm_device *gbm_device; uint32_t *crtcs; + int num_crtcs; + uint32_t crtc_allocator; + uint32_t connector_allocator; +@@ -478,7 +481,7 @@ drm_output_prepare_scanout_view(struct drm_output *output, + + if (ev->geometry.x != output->base.x || + ev->geometry.y != output->base.y || +- buffer == NULL || b->gbm == NULL || ++ buffer == NULL || b->gbm_device == NULL || + buffer->width != output->base.current_mode->width || + buffer->height != output->base.current_mode->height || + output->base.transform != viewport->buffer.transform || +@@ -488,7 +491,7 @@ drm_output_prepare_scanout_view(struct drm_output *output, + if (ev->geometry.scissor_enabled) + return NULL; + +- bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_WL_BUFFER, ++ bo = gbm_bo_import(b->gbm_device, GBM_BO_IMPORT_WL_BUFFER, + buffer->resource, GBM_BO_USE_SCANOUT); + + /* Unable to use the buffer for scanout */ +@@ -923,7 +926,7 @@ drm_output_prepare_overlay_view(struct drm_output *output, + uint32_t format; + wl_fixed_t sx1, sy1, sx2, sy2; + +- if (b->gbm == NULL) ++ if (b->gbm_device == NULL) + return NULL; + + if (viewport->buffer.transform != output->base.transform) +@@ -985,13 +988,13 @@ drm_output_prepare_overlay_view(struct drm_output *output, + if (dmabuf->attributes.n_planes != 1 || dmabuf->attributes.offset[0] != 0) + return NULL; + +- bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_FD, &gbm_dmabuf, ++ bo = gbm_bo_import(b->gbm_device, GBM_BO_IMPORT_FD, &gbm_dmabuf, + GBM_BO_USE_SCANOUT); + #else + return NULL; + #endif + } else { +- bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_WL_BUFFER, ++ bo = gbm_bo_import(b->gbm_device, GBM_BO_IMPORT_WL_BUFFER, + buffer_resource, GBM_BO_USE_SCANOUT); + } + if (!bo) +@@ -1091,7 +1094,7 @@ drm_output_prepare_cursor_view(struct drm_output *output, + if (ev->transform.enabled && + (ev->transform.matrix.type > WESTON_MATRIX_TRANSFORM_TRANSLATE)) + return NULL; +- if (b->gbm == NULL) ++ if (b->gbm_device == NULL) + return NULL; + if (output->base.transform != WL_OUTPUT_TRANSFORM_NORMAL) + return NULL; +@@ -1493,6 +1496,9 @@ init_drm(struct drm_backend *b, struct udev_device *device) + b->drm.fd = fd; + b->drm.filename = strdup(filename); + ++ b->gbm.fd = fd; ++ b->gbm.filename = b->drm.filename; ++ + ret = drmGetCap(fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap); + if (ret == 0 && cap == 1) + clk_id = CLOCK_MONOTONIC; +@@ -1579,7 +1585,7 @@ drm_backend_create_gl_renderer(struct drm_backend *b) + n_formats = 3; + if (gl_renderer->create(b->compositor, + EGL_PLATFORM_GBM_KHR, +- (void *)b->gbm, ++ (void *)b->gbm_device, + gl_renderer->opaque_attribs, + format, + n_formats) < 0) { +@@ -1592,13 +1598,13 @@ drm_backend_create_gl_renderer(struct drm_backend *b) + static int + init_egl(struct drm_backend *b) + { +- b->gbm = create_gbm_device(b->drm.fd); ++ b->gbm_device = create_gbm_device(b->gbm.fd); + +- if (!b->gbm) ++ if (!b->gbm_device) + return -1; + + if (drm_backend_create_gl_renderer(b) < 0) { +- gbm_device_destroy(b->gbm); ++ gbm_device_destroy(b->gbm_device); + return -1; + } + +@@ -1831,7 +1837,7 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b) + }; + int i, flags, n_formats = 1; + +- output->gbm_surface = gbm_surface_create(b->gbm, ++ output->gbm_surface = gbm_surface_create(b->gbm_device, + output->base.current_mode->width, + output->base.current_mode->height, + format[0], +@@ -1862,7 +1868,7 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b) + continue; + + output->gbm_cursor_bo[i] = +- gbm_bo_create(b->gbm, b->cursor_width, b->cursor_height, ++ gbm_bo_create(b->gbm_device, b->cursor_width, b->cursor_height, + GBM_FORMAT_ARGB8888, flags); + } + +@@ -2703,8 +2709,8 @@ drm_destroy(struct weston_compositor *ec) + + weston_compositor_shutdown(ec); + +- if (b->gbm) +- gbm_device_destroy(b->gbm); ++ if (b->gbm_device) ++ gbm_device_destroy(b->gbm_device); + + weston_launcher_destroy(ec->launcher); + +@@ -2989,8 +2995,8 @@ switch_to_gl_renderer(struct drm_backend *b) + + weston_log("Switching to GL renderer\n"); + +- b->gbm = create_gbm_device(b->drm.fd); +- if (!b->gbm) { ++ b->gbm_device = create_gbm_device(b->drm.fd); ++ if (!b->gbm_device) { + weston_log("Failed to create gbm device. " + "Aborting renderer switch\n"); + return; +@@ -3002,7 +3008,7 @@ switch_to_gl_renderer(struct drm_backend *b) + b->compositor->renderer->destroy(b->compositor); + + if (drm_backend_create_gl_renderer(b) < 0) { +- gbm_device_destroy(b->gbm); ++ gbm_device_destroy(b->gbm_device); + weston_log("Failed to create GL renderer. Quitting.\n"); + /* FIXME: we need a function to shutdown cleanly */ + assert(0); +@@ -3191,8 +3197,8 @@ err_drm_source: + err_udev_input: + udev_input_destroy(&b->input); + err_sprite: +- if (b->gbm) +- gbm_device_destroy(b->gbm); ++ if (b->gbm_device) ++ gbm_device_destroy(b->gbm_device); + destroy_sprites(b); + err_udev_dev: + udev_device_unref(drm_device); +-- +2.9.3 + diff --git a/recipes-graphics/wayland/files/0002-compositor-drm-Add-support-for-Tegra-Jetson-TK1.patch b/recipes-graphics/wayland/files/0002-compositor-drm-Add-support-for-Tegra-Jetson-TK1.patch new file mode 100644 index 0000000..83aafe7 --- /dev/null +++ b/recipes-graphics/wayland/files/0002-compositor-drm-Add-support-for-Tegra-Jetson-TK1.patch @@ -0,0 +1,195 @@ +From 22cbce65feeb49f547f412ab77a9430773b692b8 Mon Sep 17 00:00:00 2001 +From: James Thomas +Date: Fri, 20 Jun 2014 12:42:32 +0000 +Subject: [PATCH 2/6] compositor-drm: Add support for Tegra Jetson TK1 + +Update configure.ac to add check for libdrm_tegra +--- + configure.ac | 18 ++++++++++ + src/compositor-drm.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 109 insertions(+), 3 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 97a7769..fbb2c8c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -133,6 +133,23 @@ fi + PKG_CHECK_MODULES(LIBDRM, [libdrm], + [AC_DEFINE(HAVE_LIBDRM, 1, [Define if libdrm is available]) have_libdrm=yes], have_libdrm=no) + ++AC_ARG_ENABLE(libdrm-tegra, ++ AS_HELP_STRING([--disable-libdrm-tegra], ++ [do not build support for nvidia Jetson TK1]),, ++ enable_libdrm_tegra=auto) ++ ++if test "x$enable_libdrm_tegra" != "xno"; then ++ PKG_CHECK_MODULES(LIBDRM_TEGRA, ++ libdrm_tegra, ++ have_libdrm_tegra=yes, ++ have_libdrm_tegra=no) ++ if test "x$have_libdrm_tegra" = "xno" -a "x$enable_libdrm_tegra" = "xyes"; then ++ AC_MSG_ERROR([Tegra support explicitly requested, but libdrm_tegra not found]) ++ fi ++ AS_IF([test "x$have_libdrm_tegra" = "xyes"], ++ AC_DEFINE([HAVE_DRM_TEGRA], [1], [Enable tegra support in drm backend])) ++fi ++ + AC_ARG_ENABLE(x11-compositor, [ --enable-x11-compositor],, + enable_x11_compositor=yes) + AM_CONDITIONAL(ENABLE_X11_COMPOSITOR, test x$enable_x11_compositor = xyes) +@@ -699,4 +716,5 @@ AC_MSG_RESULT([ + libwebp Support ${have_webp} + libunwind Support ${have_libunwind} + VA H.264 encoding Support ${have_libva} ++ Tegra DRM Support ${have_libdrm_tegra} + ]) +diff --git a/src/compositor-drm.c b/src/compositor-drm.c +index 5db86dc..90cae10 100644 +--- a/src/compositor-drm.c ++++ b/src/compositor-drm.c +@@ -45,6 +45,9 @@ + + #include + #include ++#ifdef HAVE_DRM_TEGRA ++#include ++#endif + + #include "compositor.h" + #include "compositor-drm.h" +@@ -226,6 +229,32 @@ static struct gl_renderer_interface *gl_renderer; + + static const char default_seat[] = "seat0"; + ++static int ++drm_tegra_import(int fd, uint32_t handle) ++{ ++ #ifdef HAVE_DRM_TEGRA ++ struct drm_tegra_gem_set_tiling args; ++ int err; ++ ++ memset(&args, 0, sizeof(args)); ++ args.handle = handle; ++ args.mode = DRM_TEGRA_GEM_TILING_MODE_BLOCK; ++ args.value = 4; ++ ++ err = ioctl(fd, DRM_IOCTL_TEGRA_GEM_SET_TILING, &args); ++ if (err < 0) { ++ weston_log("failed to set tiling parameters: %m\n"); ++ return -errno; ++ } ++ return 0; ++ #else ++ weston_log("DRM device is a tegra but weston compiled without " ++ "libdrm tegra"); ++ ++ return -1; ++ #endif ++} ++ + static void + drm_output_set_cursor(struct drm_output *output); + +@@ -368,6 +397,32 @@ drm_fb_get_from_bo(struct gbm_bo *bo, + fb->size = fb->stride * height; + fb->fd = backend->drm.fd; + ++ if (backend->drm.fd != backend->gbm.fd) { ++ int fd; ++ ++ ret = drmPrimeHandleToFD(backend->gbm.fd, fb->handle, 0, ++ &fd); ++ if (ret) { ++ weston_log("failed to export bo: %m\n"); ++ goto err_free; ++ } ++ ++ ret = drmPrimeFDToHandle(backend->drm.fd, fd, &fb->handle); ++ if (ret) { ++ weston_log("failed to import bo: %m\n"); ++ goto err_free; ++ } ++ ++ close(fd); ++ ++ ret = drm_tegra_import(backend->drm.fd, fb->handle); ++ if (ret < 0) { ++ weston_log("failed to import handle: %s\n", ++ strerror(-ret)); ++ goto err_free; ++ } ++ } ++ + if (backend->min_width > width || width > backend->max_width || + backend->min_height > height || + height > backend->max_height) { +@@ -1496,8 +1551,14 @@ init_drm(struct drm_backend *b, struct udev_device *device) + b->drm.fd = fd; + b->drm.filename = strdup(filename); + +- b->gbm.fd = fd; +- b->gbm.filename = b->drm.filename; ++ if (b->gbm.filename) { ++ fd = weston_launcher_open(b->compositor->launcher, b->gbm.filename, ++ O_RDWR); ++ b->gbm.fd = fd; ++ } else { ++ b->gbm.fd = fd; ++ b->gbm.filename = b->drm.filename; ++ } + + ret = drmGetCap(fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap); + if (ret == 0 && cap == 1) +@@ -2808,7 +2869,7 @@ find_primary_gpu(struct drm_backend *b, const char *seat) + struct udev_enumerate *e; + struct udev_list_entry *entry; + const char *path, *device_seat, *id; +- struct udev_device *device, *drm_device, *pci; ++ struct udev_device *device, *drm_device, *pci, *soc = NULL; + + e = udev_enumerate_new(b->udev); + udev_enumerate_add_match_subsystem(e, "drm"); +@@ -2818,6 +2879,7 @@ find_primary_gpu(struct drm_backend *b, const char *seat) + drm_device = NULL; + udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { + path = udev_list_entry_get_name(entry); ++ weston_log("udev path = %s\n", path); + device = udev_device_new_from_syspath(b->udev, path); + if (!device) + continue; +@@ -2839,6 +2901,32 @@ find_primary_gpu(struct drm_backend *b, const char *seat) + drm_device = device; + break; + } ++ } else { ++ soc = udev_device_get_parent_with_subsystem_devtype( ++ device, ++ "soc", ++ NULL); ++ if (soc) { ++ id = udev_device_get_sysattr_value(soc, ++ "family"); ++ if (id && !strcmp(id, "Tegra")) { ++ if (drm_device) { ++ /* Previously have found the ++ * drm device, use this device ++ * as the GBM device ++ */ ++ if (udev_device_get_devnode( ++ device)) { ++ b->gbm.filename = strdup( ++ udev_device_get_devnode(device)); ++ break; ++ } ++ continue; ++ } ++ drm_device = device; ++ continue; ++ } ++ } + } + + if (!drm_device) +-- +2.9.3 + diff --git a/recipes-graphics/wayland/files/0003-Add-glFinish-to-DRM-backend-to-avoid-tearing.patch b/recipes-graphics/wayland/files/0003-Add-glFinish-to-DRM-backend-to-avoid-tearing.patch new file mode 100644 index 0000000..c7426a4 --- /dev/null +++ b/recipes-graphics/wayland/files/0003-Add-glFinish-to-DRM-backend-to-avoid-tearing.patch @@ -0,0 +1,48 @@ +From 412880dfeb9951f9e807ed36e293805bc97beb32 Mon Sep 17 00:00:00 2001 +From: Alexandre Courbot +Date: Thu, 24 Sep 2015 13:19:02 +0900 +Subject: [PATCH 3/6] Add glFinish to DRM backend to avoid tearing + +--- + Makefile.am | 3 ++- + src/compositor-drm.c | 2 ++ + 2 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index 00b74e5..071d540 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -281,8 +281,9 @@ drm_backend_la_LIBADD = \ + $(COMPOSITOR_LIBS) \ + $(DRM_COMPOSITOR_LIBS) \ + $(INPUT_BACKEND_LIBS) \ +- libshared.la \ + $(CLOCK_GETTIME_LIBS) \ ++ $(SIMPLE_EGL_CLIENT_LIBS) \ ++ libshared.la -lrt \ + libsession-helper.la + drm_backend_la_CFLAGS = \ + $(COMPOSITOR_CFLAGS) \ +diff --git a/src/compositor-drm.c b/src/compositor-drm.c +index 90cae10..17ba640 100644 +--- a/src/compositor-drm.c ++++ b/src/compositor-drm.c +@@ -715,6 +715,7 @@ drm_output_repaint(struct weston_output *output_base, + output_base->set_dpms(output_base, WESTON_DPMS_ON); + } + ++ glFinish(); + if (drmModePageFlip(backend->drm.fd, output->crtc_id, + output->next->fb_id, + DRM_MODE_PAGE_FLIP_EVENT, output) < 0) { +@@ -838,6 +839,7 @@ drm_output_start_repaint_loop(struct weston_output *output_base) + */ + fb_id = output->current->fb_id; + ++ glFinish(); + if (drmModePageFlip(backend->drm.fd, output->crtc_id, fb_id, + DRM_MODE_PAGE_FLIP_EVENT, output) < 0) { + weston_log("queueing pageflip failed: %m\n"); +-- +2.9.3 + diff --git a/recipes-graphics/wayland/files/0004-use-name-based-detection-of-display-and-render-nodes.patch b/recipes-graphics/wayland/files/0004-use-name-based-detection-of-display-and-render-nodes.patch new file mode 100644 index 0000000..a5969ab --- /dev/null +++ b/recipes-graphics/wayland/files/0004-use-name-based-detection-of-display-and-render-nodes.patch @@ -0,0 +1,73 @@ +From 6c8d3da72fabd2a915e18dbf9fb65b7c1134d65d Mon Sep 17 00:00:00 2001 +From: Alexandre Courbot +Date: Fri, 9 Sep 2016 15:06:27 +0900 +Subject: [PATCH 4/6] use name-based detection of display and render nodes + +The previous detection scheme assumed that the graphics nodes were under +"soc0". This is no longer true for Jetson TX1. Instead, assume that +card0 is the display node, and card1 the render one. +--- + src/compositor-drm.c | 39 ++++++++------------------------------- + 1 file changed, 8 insertions(+), 31 deletions(-) + +diff --git a/src/compositor-drm.c b/src/compositor-drm.c +index 17ba640..214fc41 100644 +--- a/src/compositor-drm.c ++++ b/src/compositor-drm.c +@@ -2871,7 +2871,7 @@ find_primary_gpu(struct drm_backend *b, const char *seat) + struct udev_enumerate *e; + struct udev_list_entry *entry; + const char *path, *device_seat, *id; +- struct udev_device *device, *drm_device, *pci, *soc = NULL; ++ struct udev_device *device, *drm_device, *pci; + + e = udev_enumerate_new(b->udev); + udev_enumerate_add_match_subsystem(e, "drm"); +@@ -2904,37 +2904,14 @@ find_primary_gpu(struct drm_backend *b, const char *seat) + break; + } + } else { +- soc = udev_device_get_parent_with_subsystem_devtype( +- device, +- "soc", +- NULL); +- if (soc) { +- id = udev_device_get_sysattr_value(soc, +- "family"); +- if (id && !strcmp(id, "Tegra")) { +- if (drm_device) { +- /* Previously have found the +- * drm device, use this device +- * as the GBM device +- */ +- if (udev_device_get_devnode( +- device)) { +- b->gbm.filename = strdup( +- udev_device_get_devnode(device)); +- break; +- } +- continue; +- } +- drm_device = device; +- continue; +- } +- } ++ id = udev_device_get_sysname(device); ++ if (!strcmp(id, "card0")) ++ drm_device = device; ++ else if (!strcmp(id, "card1")) ++ b->gbm.filename = strdup(udev_device_get_devnode(device)); ++ else ++ udev_device_unref(device); + } +- +- if (!drm_device) +- drm_device = device; +- else +- udev_device_unref(device); + } + + udev_enumerate_unref(e); +-- +2.9.3 + diff --git a/recipes-graphics/wayland/weston_%.bbappend b/recipes-graphics/wayland/weston_%.bbappend new file mode 100644 index 0000000..cb57c9b --- /dev/null +++ b/recipes-graphics/wayland/weston_%.bbappend @@ -0,0 +1,12 @@ +FILESEXTRAPATHS_prepend_tegra124m := "${THISDIR}/files:" + +PACKAGE_ARCH_tegra124m = "${MACHINE_ARCH}" + +COMPATIBLE_MACHINE_tegra124m = "(apalis-tk1-mainline)" + +SRC_URI_append_tegra124m = "\ + file://0001-compositor-drm-Add-new-gbm-struct-to-allow-for-a-sep.patch \ + file://0002-compositor-drm-Add-support-for-Tegra-Jetson-TK1.patch \ + file://0003-Add-glFinish-to-DRM-backend-to-avoid-tearing.patch \ + file://0004-use-name-based-detection-of-display-and-render-nodes.patch \ + " -- cgit v1.2.3