From 22237ef19ff4d3c3f5ec02220cfa4423954e9fef Mon Sep 17 00:00:00 2001 From: Mikko Gronoff Date: Thu, 20 Apr 2023 08:56:47 +0300 Subject: meta-tegra: update layer Update to latest revision in dunfell branch. There are two qtbase patches added in the updated OE4T/dunfell revision, of which patch#1 is present in qtbase and patch#2 needs a rebase to deal with patch fuzz. Both patches from meta-tegra bbmasked and a rebased patch#2 added to tegra dynamic layers section. Change-Id: I529e8ab9b53677e450ef2297f7b33c867ae19b71 Reviewed-by: Samuli Piippo --- meta-boot2qt-distro/conf/distro/include/jetson.inc | 5 + ...-default-framebuffer-to-NVIDIA-eglstreams.patch | 135 +++++++++++++++++++++ .../tegra/recipes-qt/qt5/qtbase_git.bbappend | 6 + scripts/manifest.xml | 2 +- 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase/0001-eglfs-add-a-default-framebuffer-to-NVIDIA-eglstreams.patch diff --git a/meta-boot2qt-distro/conf/distro/include/jetson.inc b/meta-boot2qt-distro/conf/distro/include/jetson.inc index e5066e0c..cd76d9f9 100644 --- a/meta-boot2qt-distro/conf/distro/include/jetson.inc +++ b/meta-boot2qt-distro/conf/distro/include/jetson.inc @@ -27,6 +27,11 @@ ## ############################################################################ +# Mask already applied & non-applying patches +BBMASK += "\ + meta-tegra/external/qt5-layer/recipes-qt/qt5/qtbase_%.bbappend \ + " + # without the distro_bootpart that's not supported by stock u-boot KERNEL_ROOTSPEC = "root=/dev/mmcblk${devnum}p1 rw rootwait" KERNEL_ROOTSPEC_jetson-nano-2gb-devkit = "root=/dev/mmcblk0p1 rw rootwait" diff --git a/meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase/0001-eglfs-add-a-default-framebuffer-to-NVIDIA-eglstreams.patch b/meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase/0001-eglfs-add-a-default-framebuffer-to-NVIDIA-eglstreams.patch new file mode 100644 index 00000000..6dbd7495 --- /dev/null +++ b/meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase/0001-eglfs-add-a-default-framebuffer-to-NVIDIA-eglstreams.patch @@ -0,0 +1,135 @@ +From 988b39d819d9b3041d409228dd70c6599bd1fc2a Mon Sep 17 00:00:00 2001 +From: Kurt Kiefer +Date: Thu, 14 Apr 2022 14:35:32 -0700 +Subject: [PATCH] eglfs: add a default framebuffer to NVIDIA eglstreams + +Newer versions of NVIDIA's DRM driver are rejecting the previously +accepted but non-standard use of framebuffer_id -1 in order to set +the output mode but not issue a page flip. + +This change adds a default framebuffer to the egldevice driver for +use with the initial calls to set the CRTC mode and plane. +--- + .../qeglfskmsegldevicescreen.cpp | 66 +++++++++++++++++-- + .../qeglfskmsegldevicescreen.h | 3 + + 2 files changed, 65 insertions(+), 4 deletions(-) + +diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +index d3d2ca1085..b3b24a2305 100644 +--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp ++++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +@@ -49,11 +49,68 @@ Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) + + QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, const QKmsOutput &output) + : QEglFSKmsScreen(device, output) ++ , m_default_fb_handle(uint32_t(-1)) ++ , m_default_fb_id(uint32_t(-1)) + { ++ const int fd = device->fd(); ++ ++ struct drm_mode_create_dumb createRequest; ++ createRequest.width = output.size.width(); ++ createRequest.height = output.size.height(); ++ createRequest.bpp = 32; ++ createRequest.flags = 0; ++ ++ qCDebug(qLcEglfsKmsDebug, "Creating dumb fb %dx%d", createRequest.width, createRequest.height); ++ ++ int ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &createRequest); ++ if (ret < 0) { ++ qFatal("Unable to create dumb buffer.\n"); ++ } ++ ++ m_default_fb_handle = createRequest.handle; ++ ++ uint32_t handles[4] = { 0, 0, 0, 0 }; ++ uint32_t pitches[4] = { 0, 0, 0, 0 }; ++ uint32_t offsets[4] = { 0, 0, 0, 0 }; ++ ++ handles[0] = createRequest.handle; ++ pitches[0] = createRequest.pitch; ++ offsets[0] = 0; ++ ++ ret = drmModeAddFB2(fd, createRequest.width, createRequest.height, DRM_FORMAT_ARGB8888, handles, ++ pitches, offsets, &m_default_fb_id, 0); ++ if (ret) { ++ qErrnoWarning("Unable to add fb\n"); ++ } ++ ++ qCDebug(qLcEglfsKmsDebug, "Added dumb fb %dx%d handle:%u pitch:%d id:%u", createRequest.width, createRequest.height, ++ createRequest.handle, createRequest.pitch, m_default_fb_id); + } + + QEglFSKmsEglDeviceScreen::~QEglFSKmsEglDeviceScreen() + { ++ int ret; ++ const int fd = device()->fd(); ++ ++ if (m_default_fb_id != uint32_t(-1)) { ++ ++ ret = drmModeRmFB(fd, m_default_fb_id); ++ if (ret) { ++ qErrnoWarning("drmModeRmFB failed"); ++ } ++ } ++ ++ if (m_default_fb_handle != uint32_t(-1)) { ++ ++ struct drm_mode_destroy_dumb destroyRequest; ++ destroyRequest.handle = m_default_fb_handle; ++ ++ ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroyRequest); ++ if (ret) { ++ qErrnoWarning("DRM_IOCTL_MODE_DESTROY_DUMB failed"); ++ } ++ } ++ + const int remainingScreenCount = qGuiApp->screens().count(); + qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount); + if (!remainingScreenCount && !device()->screenConfig()->separateScreens()) +@@ -87,10 +144,11 @@ void QEglFSKmsEglDeviceScreen::waitForFlip() + if (currentMode) + drmModeFreeCrtc(currentMode); + if (alreadySet) { ++ static bool ok = false; + // Maybe detecting the DPMS mode could help here, but there are no properties + // exposed on the connector apparently. So rely on an env var for now. +- static bool alwaysDoSet = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ALWAYS_SET_MODE"); +- if (!alwaysDoSet) { ++ static bool alwaysDoSet = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ALWAYS_SET_MODE", &ok); ++ if (ok ? !alwaysDoSet : false) { + qCDebug(qLcEglfsKmsDebug, "Mode already set"); + return; + } +@@ -98,7 +156,7 @@ void QEglFSKmsEglDeviceScreen::waitForFlip() + + qCDebug(qLcEglfsKmsDebug, "Setting mode"); + int ret = drmModeSetCrtc(fd, op.crtc_id, +- uint32_t(-1), 0, 0, ++ m_default_fb_id, 0, 0, + &op.connector_id, 1, + &op.modes[op.mode]); + if (ret) +@@ -110,7 +168,7 @@ void QEglFSKmsEglDeviceScreen::waitForFlip() + + if (op.wants_forced_plane) { + qCDebug(qLcEglfsKmsDebug, "Setting plane %u", op.forced_plane_id); +- int ret = drmModeSetPlane(fd, op.forced_plane_id, op.crtc_id, uint32_t(-1), 0, ++ int ret = drmModeSetPlane(fd, op.forced_plane_id, op.crtc_id, m_default_fb_id, 0, + 0, 0, w, h, + 0 << 16, 0 << 16, op.size.width() << 16, op.size.height() << 16); + if (ret == -1) +diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h +index a0e862ee4c..80b6b726b4 100644 +--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h ++++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h +@@ -53,6 +53,9 @@ public: + QPlatformCursor *cursor() const override; + + void waitForFlip() override; ++private: ++ uint32_t m_default_fb_handle; ++ uint32_t m_default_fb_id; + }; + + QT_END_NAMESPACE diff --git a/meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase_git.bbappend b/meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase_git.bbappend index 4de2e9ea..1953a580 100644 --- a/meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase_git.bbappend +++ b/meta-boot2qt-distro/dynamic-layers/tegra/recipes-qt/qt5/qtbase_git.bbappend @@ -27,6 +27,12 @@ ## ############################################################################ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI += " \ + file://0001-eglfs-add-a-default-framebuffer-to-NVIDIA-eglstreams.patch \ + " + PACKAGECONFIG += "kms" QT_QPA_EGLFS_INTEGRATION ?= "eglfs_kms_egldevice" diff --git a/scripts/manifest.xml b/scripts/manifest.xml index 78a37cc4..301b45aa 100644 --- a/scripts/manifest.xml +++ b/scripts/manifest.xml @@ -75,7 +75,7 @@ fetch="https://github.com/OE4T"/> -- cgit v1.2.3