Control: tags 1124888 + patch
Control: tags 1124888 + pending

Dear maintainer,

I've prepared an NMU for psychtoolbox-3 (versioned as 3.0.19.14.dfsg1-1.1)
and uploaded it to DELAYED/1. Please feel free to tell me if I should 
cancel it.

The difference compared to the previous version is that the changelog 
now also closes #1124888.

cu
Adrian
diffstat for psychtoolbox-3-3.0.19.14.dfsg1 psychtoolbox-3-3.0.19.14.dfsg1

 changelog                                                               |    9 
 patches/0001-Remove-obsolete-redundant-PsychHardware-LinuxDrivers.patch |  787 ++++++++++
 patches/series                                                          |    1 
 rules                                                                   |    8 
 4 files changed, 797 insertions(+), 8 deletions(-)

diff -Nru psychtoolbox-3-3.0.19.14.dfsg1/debian/changelog psychtoolbox-3-3.0.19.14.dfsg1/debian/changelog
--- psychtoolbox-3-3.0.19.14.dfsg1/debian/changelog	2024-08-12 16:38:17.000000000 +0300
+++ psychtoolbox-3-3.0.19.14.dfsg1/debian/changelog	2026-03-30 14:08:25.000000000 +0300
@@ -1,3 +1,12 @@
+psychtoolbox-3 (3.0.19.14.dfsg1-1.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Backport upstream removal of obsolete NVidia Optimus handling.
+    (Closes: #1128000)
+  * Build with default optimization. (Closes: #1124888)
+
+ -- Adrian Bunk <[email protected]>  Mon, 30 Mar 2026 14:08:25 +0300
+
 psychtoolbox-3 (3.0.19.14.dfsg1-1) unstable; urgency=medium
 
   * debian/dfsg-upstream - improve listing of left non-source - list only
diff -Nru psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/0001-Remove-obsolete-redundant-PsychHardware-LinuxDrivers.patch psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/0001-Remove-obsolete-redundant-PsychHardware-LinuxDrivers.patch
--- psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/0001-Remove-obsolete-redundant-PsychHardware-LinuxDrivers.patch	1970-01-01 02:00:00.000000000 +0200
+++ psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/0001-Remove-obsolete-redundant-PsychHardware-LinuxDrivers.patch	2026-03-30 14:08:25.000000000 +0300
@@ -0,0 +1,787 @@
+From 6f3b4e8bb5003304814831ea513f76e89497ff8c Mon Sep 17 00:00:00 2001
+From: Mario Kleiner <[email protected]>
+Date: Sun, 15 Mar 2026 10:20:17 +0100
+Subject: Remove obsolete/redundant PsychHardware/LinuxDrivers/NVidiaOptimus/
+ folder.
+
+This old way of dealing with NVidia Optimus dual-gpu laptops has long been replaced
+by a much better method, so all this content is not needed anymore.
+
+It also causes Debian "autoremoval from testing" issues right now, so get rid of it.
+---
+ .../PsychHardware/LinuxDrivers/Contents.m     |  25 --
+ .../LinuxDrivers/NVidiaOptimus/.xinitrc       |   9 -
+ ...custom-UDP-Prime-Sync-protocol-for-P.patch | 260 ------------------
+ ...custom-low-lag-optimizations-for-Psy.patch | 151 ----------
+ .../LinuxDrivers/NVidiaOptimus/Readme.txt     | 147 ----------
+ .../LinuxDrivers/NVidiaOptimus/lightdm.conf   |   3 -
+ .../NVidiaOptimus/modesetting_drv.la          |  41 ---
+ .../NVidiaOptimus/optimusproprietary.conf     |   8 -
+ .../LinuxDrivers/NVidiaOptimus/xorg.conf      |  54 ----
+ 9 files changed, 698 deletions(-)
+ delete mode 100755 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/.xinitrc
+ delete mode 100644 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0001-modesetting-Add-custom-UDP-Prime-Sync-protocol-for-P.patch
+ delete mode 100644 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0002-modesetting-Add-custom-low-lag-optimizations-for-Psy.patch
+ delete mode 100644 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/Readme.txt
+ delete mode 100644 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/lightdm.conf
+ delete mode 100755 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/modesetting_drv.la
+ delete mode 100644 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/optimusproprietary.conf
+ delete mode 100644 Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/xorg.conf
+
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/Contents.m b/Psychtoolbox/PsychHardware/LinuxDrivers/Contents.m
+index 4fc489646..41eb4bec9 100644
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/Contents.m
++++ b/Psychtoolbox/PsychHardware/LinuxDrivers/Contents.m
+@@ -2,28 +2,3 @@
+ %
+ % Customized device drivers for Linux.
+ %
+-% The subfolder NVidiaOptimus/ contains a customized
+-% display modesetting driver and configuration files
+-% for 64-Bit X-Server 1.19, to use NVidia Optimus
+-% Laptops with the proprietary NVidia graphics driver
+-% instead of the open-source nouveau driver.
+-%
+-% CAUTION: These drivers are only for specific processor
+-% architectures and versions of the X-Server, and thereby
+-% only for specific versions of specific Linux distributions.
+-%
+-% Installation of these drivers on a mismatched/unsuitable
+-% distribution will likely make your machines GUI unuseable
+-% by preventing successfull startup of the X-Server!
+-%
+-% You can find out which version of X-Server is used on your
+-% system by typing...
+-%
+-% xdpyinfo | grep 'X.Org version'
+-%
+-% ... into a terminal window. It should report version 1.19 for a
+-% XOrg 1.19 server.
+-%
+-% Currently the following drivers are provided:
+-%
+-
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/.xinitrc b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/.xinitrc
+deleted file mode 100755
+index 76fae9469..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/.xinitrc
++++ /dev/null
+@@ -1,9 +0,0 @@
+-#!/bin/bash
+-#
+-# Copy this file into /root/ iff you use the bundled
+-# lightdm.conf file. Otherwise copy it to the location
+-# to which you pointed your login manager to find it.
+-#
+-xrandr --setprovideroutputsource modesetting NVIDIA-0
+-xrandr --auto
+-#xrandr --output eDP-1 --set "PRIME Synchronization" 1
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0001-modesetting-Add-custom-UDP-Prime-Sync-protocol-for-P.patch b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0001-modesetting-Add-custom-UDP-Prime-Sync-protocol-for-P.patch
+deleted file mode 100644
+index 5f496f2af..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0001-modesetting-Add-custom-UDP-Prime-Sync-protocol-for-P.patch
++++ /dev/null
+@@ -1,260 +0,0 @@
+-From 6d6e1526b949ab7ac40efceddbca54ef7cfc01a1 Mon Sep 17 00:00:00 2001
+-From: Mario Kleiner <[email protected]>
+-Date: Sat, 15 Oct 2016 10:22:12 +0200
+-Subject: [PATCH xserver 1/2] modesetting: Add custom UDP Prime-Sync protocol
+- for Psychtoolbox.
+-
+-The new Prime-Sync code contributed to XOrg 1.19 by NVidia's
+-Alex Goins for implementing properly synchronized and serialized
+-NVidia dGPU outputSource -> Intel iGPU outputSlave Prime support,
+-to support Optimus Laptops, works well for preventing tearing or
+-incomplete rendering.
+-
+-A current limitation is that it doesn't provide any way to
+-reliably signal completion of an OpenGL double-buffer swap to
+-a running fullscreen OpenGL client, e.g., Psychtoolbox.
+-
+-Therefore the current X-Server 1.19 implementation is not
+-useable for vision science applications which require precise
+-visual stimulus onset timing or any kind of reliable time-
+-stamping.
+-
+-As it is too late for some better solution for the 1.19 cycle,
+-and use of nouveau is not always possible for (lack of)performance
+-reasons, we use the following hack to make NVidia Optimus
+-useable for vision science applications on modern gpus:
+-
+-This patch implements a custom UDP protocol between the
+-modesetting-ddx which drives the slaveOutput iGPU, and
+-interested clients, ie. Psychtoolbox. The modesetting-ddx
+-creates one UDP socket for emission of UDP packets for each
+-X-Screen. A UDP packet is sent to localhost:10000+(x-screenId),
+-e.g., localhost:10000 for X-Screen 0, localhost:10001 for
+-X-Screen 1 etc., whenever a kms-pageflip has been scheduled
+-or completed on the iGPU. The send operation is non-blocking,
+-so the X-Server can't get stalled if there isn't any client
+-listening at the receiving port.
+-
+-1. "Flip scheduled" packets are sent out after a successfull
+-   call to drmModePageFlip, including the vblank count (msc)
+-   and timestamp (ust) of the vblank in which the flip was
+-   scheduled. The expectation is that usually such a flip
+-   will complete at msc + 1 and ust + 1 videorefresh duration.
+-   This allows Psychtoolbox to know that a Flip will likely
+-   complete one frame duration ahead of likely completion.
+-
+-2. "Flip completed" packets with msc and ust of completion
+-   are sent out when a kms pageflip completed, iow. visual
+-   stimulus onset after vblank msc at time ust is guaranteed.
+-
+-Ideally Psychtoolbox could just wait for "Flip completed" packets,
+-but the current implementation of slaveOutput update scheduling
+-in the modesetting ddx introduces 1 frame extra lag for each
+-client glXSwapBuffers call. Therefore PTB must not wait for flip
+-completion, but start rendering the next frame already when
+-a type 1 "Flip scheduled" packet arrives, so it can submit
+-glXSwapBuffers calls 1 frame early to compensate for the 1 frame
+-delay. This allows to achieve full framerate (fps == display Hz)
+-at the expense that timestamping could be wrong under very high
+-load scenarios, where the dGPU can't complete the DMA copy of the
+-new framebuffer from VRAM to the shared dmabuf in system RAM within
+-1 video refresh cycle, or where some massive kthread scheduling
+-delay would prevent hw pageflip programming within 1 refresh cycle.
+-In practice no such glitch was observed during testing.
+-
+-For highest reliability PTB can instead wait for type 2 packets,
+-trading loss of performance for highest reliability.
+-
+-The modesetting ddx creates a new XAtom to signal to PTB or
+-other clients that it supports this custom protocol, so PTB
+-et al. can enable their corresponding receiver and timestamping
+-code.
+-
+-An important limitation is that the outputSlave / modesetting
+-driver can not detect the reason for a requested output update.
+-It could be an OpenGL bufferswap of a unredirected fullscreen
+-window, or any kind of visual update on a regular desktop GUI,
+-or even the visual movement/appearance change of a software cursor.
+-As such this timestamping/swap completion protocol can only work
+-somewhat reliable if the client displays a unredirected fullscreen
+-window covering the whole X-Screen -- luckily the common scenario
+-for vision science stimulation. It also only works well if there
+-is one single active output attached to the X-Screen, as the Prime
+-implementation will update/pageflip each active output individually
+-and send out separate UDP packets for flip completion. The client
+-has no way to disambiguate which packet to use for its flip completion
+-handling. A third limitation seems to be that we can only drive one
+-X-Screen in a session with NVidia's Optimus + proprietary driver and
+-GLX module. At least i could not find a xorg.conf which would allow
+-to successfully setup a multi-x-screen ZaphodHeads setup or such, so
+-this is so far only successfully tested on a single display setup,
+-either Laptop panel only, or external video output only, but not both
+-at the same time.
+-
+-This patch tested against the NVidia 375.20 release driver with final
+-X-Server 1.19.0 on a Lenovo Z50 Optimus laptop with Intel HD 4400
+-+ GeForce 840M. Datapixx confirms correct timestamps.
+-
+-Signed-off-by: Mario Kleiner <[email protected]>
+----
+- hw/xfree86/drivers/modesetting/drmmode_display.c | 108 +++++++++++++++++++++++
+- 1 file changed, 108 insertions(+)
+-
+-diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
+-index 6e755e9..d0cf665 100644
+---- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+-+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
+-@@ -29,6 +29,11 @@
+- #include "dix-config.h"
+- #endif
+- 
+-+/* For Unix UDP socket (msc,ust) side channel: */
+-+#include <sys/socket.h>
+-+#include <sys/fcntl.h>
+-+#include <netinet/ip.h>
+-+
+- #include <errno.h>
+- #include <sys/ioctl.h>
+- #include <sys/mman.h>
+-@@ -199,6 +204,95 @@ drmmode_SetSlaveBO(PixmapPtr ppix,
+-     return TRUE;
+- }
+- 
+-+static int fd_primestatus[1024] = { 0 };
+-+static struct buf {
+-+    uint64_t frame;
+-+    uint64_t usec;
+-+    int scrnIndex;
+-+    unsigned char flags;
+-+} buf;
+-+
+-+static void
+-+drmmode_InitSharedPixmapFeedback(drmmode_ptr drmmode)
+-+{
+-+    static Atom PrimeTimingHack1 = None;
+-+    int scrnIndex = drmmode->scrn->scrnIndex % 256;
+-+    struct sockaddr_in addr = { 0 };
+-+
+-+    fd_primestatus[scrnIndex] = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+-+    if  (-1 == fd_primestatus[scrnIndex]) {
+-+        xf86DrvMsg(drmmode->scrn->scrnIndex, X_ERROR,
+-+                    "Failed to create Unix UDP socket for Prime feedback! %s\n",
+-+                   strerror(errno));
+-+    } else {
+-+        memset(&addr, 0, sizeof(addr));
+-+        addr.sin_family = AF_INET;
+-+        addr.sin_port = htons(10000 + scrnIndex);
+-+        addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+-+
+-+        if(connect(fd_primestatus[scrnIndex], (struct sockaddr *) &addr, sizeof(addr))) {
+-+            close(fd_primestatus[scrnIndex]);
+-+            fd_primestatus[scrnIndex] = 0;
+-+            xf86DrvMsg(drmmode->scrn->scrnIndex, X_ERROR,
+-+                        "Failed to connect() socket for Prime feedback on localhost:%i! %s\n",
+-+                       10000 + scrnIndex,strerror(errno));
+-+        }
+-+        else {
+-+            unsigned char sendpriority = IPTOS_LOWDELAY;
+-+            setsockopt(fd_primestatus[scrnIndex], SOL_IP, IP_TOS, &sendpriority, sizeof(sendpriority));
+-+
+-+            fcntl(fd_primestatus[scrnIndex], F_SETFL, O_NONBLOCK);
+-+
+-+            xf86DrvMsg(drmmode->scrn->scrnIndex, X_INFO,
+-+                        "Bound Unix UDP socket for Prime feedback on localhost:%i\n", 10000 + scrnIndex);
+-+        }
+-+    }
+-+
+-+    /* Create an Atom to signal that this is an enhanced modesetting-ddx with custom UDP
+-+     * Prime timestamping.
+-+     */
+-+    if (PrimeTimingHack1 == None)
+-+        PrimeTimingHack1 = MakeAtom("PrimeTimingHack1", strlen("PrimeTimingHack1"), TRUE);
+-+}
+-+
+-+static void
+-+drmmode_FiniSharedPixmapFeedback(drmmode_ptr drmmode)
+-+{
+-+    int scrnIndex = drmmode->scrn->scrnIndex % 256;
+-+    if (fd_primestatus[scrnIndex] > 0) {
+-+        close(fd_primestatus[scrnIndex]);
+-+        fd_primestatus[scrnIndex] = 0;
+-+        xf86DrvMsg(drmmode->scrn->scrnIndex, X_INFO,
+-+                   "Closed Unix UDP socket for Prime feedback.\n");
+-+    }
+-+}
+-+
+-+static void
+-+drmmode_SetSharedPixmapFeedback(int scrnIndex, uint64_t frame, uint64_t usec)
+-+{
+-+    scrnIndex = scrnIndex % 256;
+-+
+-+    if (fd_primestatus[scrnIndex] <= 0)
+-+        return;
+-+
+-+    buf.frame = frame;
+-+    buf.usec = usec;
+-+    buf.scrnIndex = scrnIndex;
+-+}
+-+
+-+static void
+-+drmmode_SendSharedPixmapFeedback(Bool flipcomplete)
+-+{
+-+    if (fd_primestatus[buf.scrnIndex] <= 0)
+-+        return;
+-+
+-+    buf.flags = flipcomplete ? 1 : 0;
+-+
+-+    if ((send(fd_primestatus[buf.scrnIndex], &buf, sizeof(buf), MSG_DONTWAIT) == sizeof(buf)) && FALSE)
+-+        xf86DrvMsg(buf.scrnIndex, X_DEBUG,
+-+                   "Send for Prime feedback: flipcompletion=%d : msc=%lu : ust=%lu\n", buf.flags, buf.frame, buf.usec);
+-+}
+-+
+- static Bool
+- drmmode_SharedPixmapPresent(PixmapPtr ppix, xf86CrtcPtr crtc,
+-                             drmmode_ptr drmmode)
+-@@ -248,7 +342,12 @@ drmmode_SharedPixmapVBlankEventHandler(uint64_t frame, uint64_t usec,
+- 
+-     drmmode_crtc_private_ptr drmmode_crtc = args->crtc->driver_private;
+- 
+-+    drmmode_SetSharedPixmapFeedback(args->drmmode->scrn->scrnIndex, frame, usec);
+-+
+-     if (args->flip) {
+-+        /* pageflip completed - Send completion packet */
+-+        drmmode_SendSharedPixmapFeedback(TRUE);
+-+
+-         /* frontTarget is being displayed, update crtc to reflect */
+-         drmmode_crtc->prime_pixmap = args->frontTarget;
+-         drmmode_crtc->prime_pixmap_back = args->backTarget;
+-@@ -342,6 +441,10 @@ drmmode_SharedPixmapFlip(PixmapPtr frontTarget, xf86CrtcPtr crtc,
+-         return FALSE;
+-     }
+- 
+-+    /* pageflip scheduled - Send scheduled packet */
+-+    if (drmmode_crtc->flipping_active)
+-+        drmmode_SendSharedPixmapFeedback(FALSE);
+-+
+-     return TRUE;
+- }
+- 
+-@@ -360,6 +463,9 @@ drmmode_InitSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode)
+-         drmmode_SharedPixmapPresent(drmmode_crtc->prime_pixmap_back,
+-                                     crtc, drmmode);
+- 
+-+    if (drmmode_crtc->flipping_active)
+-+        drmmode_InitSharedPixmapFeedback(drmmode);
+-+
+-     return drmmode_crtc->flipping_active;
+- }
+- 
+-@@ -384,6 +490,8 @@ drmmode_FiniSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode)
+-                           drmmode_crtc->prime_pixmap_back)->flip_seq;
+-     if (seq)
+-         ms_drm_abort_seq(crtc->scrn, seq);
+-+
+-+    drmmode_FiniSharedPixmapFeedback(drmmode);
+- }
+- 
+- static Bool drmmode_set_target_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix,
+--- 
+-2.7.4
+-
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0002-modesetting-Add-custom-low-lag-optimizations-for-Psy.patch b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0002-modesetting-Add-custom-low-lag-optimizations-for-Psy.patch
+deleted file mode 100644
+index e992ea418..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/0002-modesetting-Add-custom-low-lag-optimizations-for-Psy.patch
++++ /dev/null
+@@ -1,151 +0,0 @@
+-From 008d213cb4b4ee0d400fe776ba2764b2b8dd277e Mon Sep 17 00:00:00 2001
+-From: Mario Kleiner <[email protected]>
+-Date: Thu, 1 Dec 2016 07:42:03 +0100
+-Subject: [PATCH xserver 2/2] modesetting: Add custom low-lag optimizations for
+- Psychtoolbox.
+-
+-We want to get rid of the 1 frame extra-lag induced by NVidia's
+-design, so Psychtoolbox can wait for true flip completion UDP
+-packets, instead of the "flip scheduled" UDP packets, and thereby
+-provide more robust Flip completion timestamping, without the 1
+-frame penalty that would cut maximu achievable display update
+-rate (fps) down to half the video refresh rate.
+-
+-For this we use the following trick:
+-
+-We modify the msSharedPixmapNotifyDamage() callback, which is
+-called by the NVidia proprietary driver as soon as a OpenGL
+-bufferswap has been triggered and the new rendered frame copied
+-to the NVidia drivers GPU internal linear staging framebuffer.
+-The callback no longer calls drmmode_SharedPixmapPresentOnVBlank()
+-as in the original design to schedule a PresentSharedPixmap and
+-kms-pageflip at the next vblank, inducing the 1 frame delay, as
+-the pageflip can then only execute 1 vblank after that vblank.
+-Instead we call drmmode_SharedPixmapPresent() immediately without
+-waiting for next vblank.
+-
+-This removes the extra lag. However, the trick only works
+-on a single display setup, ie. with exactly 1 active crtc
+-on the X-Screen. On multi-display it causes stability issues,
+-freezes, hangs etc. Therefore we only enable this optimization
+-if the X-Screen has exactly one active crtc. Otherwise we fall
+-back to the old extra-lag code which is stable. This is not a
+-real loss to PTB, as the whole hack only works with reasonably
+-reliable timing on a single-display per X-Screen configuration.
+-We can't deal with the timestamping of multi-display kms-flip
+-completion in any sane way.
+-
+-Availability of this extra low-lag mode is signalled to PTB
+-by exposure of a new X-Atom "PrimeTimingHack2", so PTB can
+-adapt its swap scheduling and feedback to the user accordingly.
+-
+-This patch tested against the NVidia 375.20 release driver with
+-X-Server 1.19.0 final on a Lenovo Z50 Optimus laptop with
+-Intel HD 4400 + GeForce 840M. Datapixx confirms correct
+-timestamping.
+-
+-Signed-off-by: Mario Kleiner <[email protected]>
+----
+- hw/xfree86/drivers/modesetting/driver.c          | 17 +++++++++++++++--
+- hw/xfree86/drivers/modesetting/drmmode_display.c |  9 +++++++--
+- hw/xfree86/drivers/modesetting/drmmode_display.h |  1 +
+- 3 files changed, 23 insertions(+), 4 deletions(-)
+-
+-diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
+-index 3da69a3..542fa47 100644
+---- a/hw/xfree86/drivers/modesetting/driver.c
+-+++ b/hw/xfree86/drivers/modesetting/driver.c
+-@@ -1462,6 +1462,7 @@ msSharedPixmapNotifyDamage(PixmapPtr ppix)
+- {
+-     Bool ret = FALSE;
+-     int c;
+-+    int num_enabled = 0;
+- 
+-     ScreenPtr screen = ppix->drawable.pScreen;
+-     ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+-@@ -1476,6 +1477,11 @@ msSharedPixmapNotifyDamage(PixmapPtr ppix)
+- 
+-     for (c = 0; c < xf86_config->num_crtc; c++) {
+-         xf86CrtcPtr crtc = xf86_config->crtc[c];
+-+        num_enabled += crtc->enabled ? 1 : 0;
+-+    }
+-+
+-+    for (c = 0; c < xf86_config->num_crtc; c++) {
+-+        xf86CrtcPtr crtc = xf86_config->crtc[c];
+-         drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+- 
+-         if (!drmmode_crtc)
+-@@ -1483,8 +1489,15 @@ msSharedPixmapNotifyDamage(PixmapPtr ppix)
+-         if (!(drmmode_crtc->prime_pixmap && drmmode_crtc->prime_pixmap_back))
+-             continue;
+- 
+--        // Received damage on master screen pixmap, schedule present on vblank
+--        ret |= drmmode_SharedPixmapPresentOnVBlank(ppix, crtc, &ms->drmmode);
+-+        /* Immediate present only works reliably for single active crtc. */
+-+        if (num_enabled > 1) {
+-+            // Received damage on master screen pixmap, schedule present at next vblank:
+-+            ret |= drmmode_SharedPixmapPresentOnVBlank(ppix, crtc, &ms->drmmode);
+-+        }
+-+        else {
+-+            // Received damage on master screen pixmap, schedule present asap:
+-+            ret |= drmmode_SharedPixmapPresent(ppix, crtc, &ms->drmmode);
+-+        }
+-     }
+- 
+-     return ret;
+-diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
+-index d0cf665..f2c4f4f 100644
+---- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+-+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
+-@@ -216,6 +216,7 @@ static void
+- drmmode_InitSharedPixmapFeedback(drmmode_ptr drmmode)
+- {
+-     static Atom PrimeTimingHack1 = None;
+-+    static Atom PrimeTimingHack2 = None;
+-     int scrnIndex = drmmode->scrn->scrnIndex % 256;
+-     struct sockaddr_in addr = { 0 };
+- 
+-@@ -244,7 +245,7 @@ drmmode_InitSharedPixmapFeedback(drmmode_ptr drmmode)
+-             fcntl(fd_primestatus[scrnIndex], F_SETFL, O_NONBLOCK);
+- 
+-             xf86DrvMsg(drmmode->scrn->scrnIndex, X_INFO,
+--                        "Bound Unix UDP socket for Prime feedback on localhost:%i\n", 10000 + scrnIndex);
+-+                        "NoLag: Bound Unix UDP socket for Prime feedback on localhost:%i\n", 10000 + scrnIndex);
+-         }
+-     }
+- 
+-@@ -253,6 +254,10 @@ drmmode_InitSharedPixmapFeedback(drmmode_ptr drmmode)
+-      */
+-     if (PrimeTimingHack1 == None)
+-         PrimeTimingHack1 = MakeAtom("PrimeTimingHack1", strlen("PrimeTimingHack1"), TRUE);
+-+
+-+    /* Additionally signal via Atom that this is a driver with low/no lag modifications: */
+-+    if (PrimeTimingHack2 == None)
+-+        PrimeTimingHack2 = MakeAtom("PrimeTimingHack2", strlen("PrimeTimingHack2"), TRUE);
+- }
+- 
+- static void
+-@@ -293,7 +298,7 @@ drmmode_SendSharedPixmapFeedback(Bool flipcomplete)
+-                    "Send for Prime feedback: flipcompletion=%d : msc=%lu : ust=%lu\n", buf.flags, buf.frame, buf.usec);
+- }
+- 
+--static Bool
+-+Bool
+- drmmode_SharedPixmapPresent(PixmapPtr ppix, xf86CrtcPtr crtc,
+-                             drmmode_ptr drmmode)
+- {
+-diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
+-index 50976b8..26f1578 100644
+---- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+-+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
+-@@ -178,6 +178,7 @@ Bool drmmode_EnableSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode,
+-                                         PixmapPtr front, PixmapPtr back);
+- Bool drmmode_SharedPixmapPresentOnVBlank(PixmapPtr frontTarget, xf86CrtcPtr crtc,
+-                                          drmmode_ptr drmmode);
+-+Bool drmmode_SharedPixmapPresent(PixmapPtr ppix, xf86CrtcPtr crtc, drmmode_ptr drmmode);
+- Bool drmmode_SharedPixmapFlip(PixmapPtr frontTarget, xf86CrtcPtr crtc,
+-                               drmmode_ptr drmmode);
+- void drmmode_DisableSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode);
+--- 
+-2.7.4
+-
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/Readme.txt b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/Readme.txt
+deleted file mode 100644
+index 0d621652d..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/Readme.txt
++++ /dev/null
+@@ -1,147 +0,0 @@
+-CAUTION: THIS WILL ONLY WORK ON DISTRIBUTIONS WITH X-SERVER 1.19, NOT
+-WITH UBUNTU 20.04-LTS AND LATER AT THE MOMENT!
+-
+-How to setup research grade NVidia Optimus support with the proprietary
+-drivers:
+-
+-First you need a Linux distribution with XOrg X-Server 1.19.0 or later.
+-As of December 2016, that would be "Debian unstable" or "Fedora 25".
+-Both of these distros are completely untested with our driver and PTB.
+-
+-The only way to get this working on a Ubuntu Linux flavor older than 17.04
+-is currently to download, compile and install an X-Server 1.19 yourself.
+-This is how this driver was developed and tested. If you are clever and
+-adventurous enough to try this route, instead of waiting for the release of
+-Ubuntu 17.04 in April 2017, you will have enough Google and Computer skills
+-to find out how to get such an X-Server downloaded, compiled and installed.
+-
+-Once you have the X-Server 1.19 up and running, you need to install NVidia
+-proprietary display drivers of version 375.20 or preferrably any later and
+-more modern version. You can get those from www.nvidia.com, or via an
+-installation method specific to your Linux distribution.
+-
+-Next you need to setup various configuration files and scripts. Many of
+-these steps are also explained in the release notes of the NVidia proprietary
+-driver.
+-
+-This folder contains templates of these scripts, to be copied into the
+-proper folders on your machine. Ubuntu also provides a package "nvidia-prime"
+-which, once installed, will automate parts of this setup.
+-
+-The following config files exist in this folder:
+-
+-".xinitrc" --> To be copied into /root/.xinitrc
+-"lightdm.conf" --> To be copied into /etc/lightm/lightdm.conf on Ubuntu 16.04-LTS.
+-
+---> lightdm.conf tells the LightDM login manager ro execute the .xinitrc script
+-    found in /root.xinitrc. If you use a different login manager, find out what
+-    kind of config file is needed to execute the .xinitrc script at X-Server
+-    startup. You can copy the .xinitrc file under a different name into a different
+-    location if you like, you just need to adapt the path/name in lightdm.conf etc.
+-    accordingly.
+-
+---> The Ubuntu nvidia-prime package will perform these setup steps for you
+-    automatically if it works for you, but this has not been tested with PTB.
+-
+-"optimusproprietary.conf" --> To be copied into /etc/modprobe.d/optimusproprietary.conf
+-
+-"xorg.conf" needs to be copied into /etc/X11/xorg.conf
+-However, read the instructions at the top of xorg.conf on how you will have to
+-customize the file for your specific machine.
+-
+-If, after a logout/login or machine restart you still enjoy a working display,
+-congratulations! You did everything right.
+-
+-Finally copy the file modesetting_drv.so into the system folder
+-/usr/lib/x86_64-linux-gnu/xorg/extra-modules/
+-
+-Then logout and login again, or maybe restart the machine, so the X-Server can pick
+-up the new driver. If your display still works, then that's a good sign :)
+-
+-You will also need Linux kernel version 4.6 or later for timing to work
+-correctly. However, as of NVidia driver version 375.20, you are restricted
+-to Linux 4.6 and Linux 4.7, as the proprietary 375.20 driver does not work
+-Linux 4.8 or later!
+-
+-As you can see, the setup procedure is quite involved at the moment, and
+-even small mistakes can lead to a completely non-functional GUI, so tread
+-carefully and only execute these instructions if you have some experience
+-working on a Unix command line and finding your way around compilers and
+-Makefiles.
+-
+-Credits/Licenses:
+-
+-The modesetting_drv.so module and modesetting_drv.so_highlag module are
+-modified versions of the modesetting ddx driver which ships as part of
+-X-Server 1.19.0 by default. Iow. they are created by ...
+-
+-1. Installing the source code of X-Server 1.19.0 downloaded from
+-   https://cgit.freedesktop.org/xorg/xserver/ at the xorg-server-1.19.0 tag
+-
+-2. Applying the patches included in this folder to the source tree:
+-   0001-modesetting-Add-custom-UDP-Prime-Sync-protocol-for-P.patch
+-   0002-modesetting-Add-custom-low-lag-optimizations-for-Psy.patch
+-
+-3. Building the X-Server and thereby modesetting driver.
+-
+-4. This results in the modesetting_drv.so files included in this folder.
+-
+--> There are two variants: modesetting_drv.so is the result of applying
+-   both patches in step 2.
+-
+-   modesetting_drv.so_highlag is the result of only applying the patch
+-   0001-modesetting-Add-custom-UDP-Prime-Sync-protocol-for-P.patch
+-   which only provides the timestamping funcionality, but not the
+-   frame lag reduction of patch 0002.
+-
+-The source code of the modesetting driver, and thereby modesetting_drv.so itself,
+-is licensed under a license as posted below. For the individual copyrights of
+-each sourc file of the driver, look at the top of the files contained in the
+-following part of the X-Server git tree:
+-
+-https://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/drivers/modesetting
+-
+-The license always says this - with changing copyrights assigned to different
+-entities for the different files:
+-
+-e.g., for driver.c:
+-
+-/*
+-
+-Copyright assignment -- different for different files, here for driver.c:
+-
+- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+- * Copyright 2011 Dave Airlie
+- * All Rights Reserved.
+- *
+-
+-Actual license, identical for the whole driver:
+-
+- * 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, sub license, 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 NON-INFRINGEMENT.
+- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+- *
+-
+-Different authors for the different files, here for driver.c:
+-
+- *
+- * Original Author: Alan Hourihane <[email protected]>
+- * Rewrite: Dave Airlie <[email protected]>
+- *
+- */
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/lightdm.conf b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/lightdm.conf
+deleted file mode 100644
+index 91c30947f..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/lightdm.conf
++++ /dev/null
+@@ -1,3 +0,0 @@
+-[SeatDefaults]
+-display-setup-script=/root/.xinitrc
+-
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/modesetting_drv.la b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/modesetting_drv.la
+deleted file mode 100755
+index 1ac84eb81..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/modesetting_drv.la
++++ /dev/null
+@@ -1,41 +0,0 @@
+-# modesetting_drv.la - a libtool library file
+-# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-0.1
+-#
+-# Please DO NOT delete this file!
+-# It is necessary for linking the library.
+-
+-# The name that we can dlopen(3).
+-dlname='modesetting_drv.so'
+-
+-# Names of this library.
+-library_names='modesetting_drv.so modesetting_drv.so modesetting_drv.so'
+-
+-# The name of the static archive.
+-old_library=''
+-
+-# Linker flags that cannot go in dependency_libs.
+-inherited_linker_flags=' -pthread'
+-
+-# Libraries that this one depends upon.
+-dependency_libs=' -ludev -lm'
+-
+-# Names of additional weak libraries provided by this library
+-weak_library_names=''
+-
+-# Version information for modesetting_drv.
+-current=0
+-age=0
+-revision=0
+-
+-# Is this an already installed library?
+-installed=yes
+-
+-# Should we warn about portability when linking against -modules?
+-shouldnotlink=yes
+-
+-# Files to dlopen/dlpreopen
+-dlopen=''
+-dlpreopen=''
+-
+-# Directory that this library needs to be installed in:
+-libdir='/usr/local/lib/xorg/modules/drivers'
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/optimusproprietary.conf b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/optimusproprietary.conf
+deleted file mode 100644
+index 8faa6114f..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/optimusproprietary.conf
++++ /dev/null
+@@ -1,8 +0,0 @@
+-# Tell NVidia's proprietary kernel display driver to enable
+-# basic DRM kernel modesetting support, needed for PRIME Sync
+-# on Optimus Laptops for tear-free display.
+-#
+-# 1. Copy this to /etc/modprobe.d/
+-# 2. Reboot.
+-
+-options nvidia_drm modeset=1
+diff --git a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/xorg.conf b/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/xorg.conf
+deleted file mode 100644
+index 38be607d2..000000000
+--- a/Psychtoolbox/PsychHardware/LinuxDrivers/NVidiaOptimus/xorg.conf
++++ /dev/null
+@@ -1,54 +0,0 @@
+-# xorg.conf for use with NVidia binary driver and
+-# Optimus PRIME with proper synchronization.
+-# This config actually works, but needs a X-Server 1.19
+-# or later, compiled with --enable-glamor
+-#
+-# You must set the BusID to the PCI Id of your Intel
+-# graphics chip in the "Device" intel section, and to
+-# the PCI Id of your NVidia gpu in the "Device" nvidia
+-# section. A way to get these id's is to execute:
+-#
+-# grep PCI /usr/local/var/log/Xorg.0.log
+-#
+-# The output will look something like:
+-# [ 15545.440] (--) PCI:*(0:0:2:0) 8086:0a16:17aa:380d rev 11, Mem @ 0xc3000000/4194304, 0xd0000000/268435456, I/O @ 0x00006000/64, BIOS @ 0x????????/131072
+-# [ 15545.440] (--) PCI: (0:3:0:0) 10de:1341:17aa:380d rev 162, Mem @ 0xc2000000/16777216, 0xb0000000/268435456, 0xc0000000/33554432, I/O @ 0x00003000/128
+-#
+-# Note the PCI Id with the *, and the 8096 ie. PCI:*(0:0:2:0) 8086
+-# The last three numbers in (0:0:2:0) translate into PCI:0:2:0 below
+-# for the intel card.
+-#
+-# The other PCI Id without *, but with the 10de, ie. PCI: (0:3:0:0) 10de
+-# the last three numbers in (0:3:0:0) translate into PCI:3:0:0 for the
+-# nvidia card.
+-#
+-# 1. Edit this files BusID entries accordingly (see above).
+-# 2. Copy this to /etc/X11/xorg.conf
+-# 3. Logout/Login again, or reboot.
+-#
+-
+-Section "ServerLayout"
+-    Identifier     "Optimus"
+-    Screen      0  "nvidia" 0 0
+-    Inactive       "intel"
+-EndSection
+-
+-Section "Device"
+-    Identifier     "intel"
+-    Driver         "modesetting"
+-    Option         "AccelMethod" "none"
+-    BusID          "PCI:0:2:0"
+-EndSection
+-
+-Section "Device"
+-    Identifier     "nvidia"
+-    Driver         "nvidia"
+-    VendorName     "NVIDIA Corporation"
+-    BusID          "PCI:3:0:0"
+-    Option         "AllowEmptyInitialConfiguration"
+-EndSection
+-
+-Section "Screen"
+-    Identifier     "nvidia"
+-    Device         "nvidia"
+-EndSection
+-- 
+2.47.3
+
diff -Nru psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/series psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/series
--- psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/series	2024-08-12 16:38:17.000000000 +0300
+++ psychtoolbox-3-3.0.19.14.dfsg1/debian/patches/series	2026-03-30 14:08:25.000000000 +0300
@@ -4,3 +4,4 @@
 deb_no_special_arm
 deb_no_PTB_USE_NVSTUSB
 deb_no_so2_stripping
+0001-Remove-obsolete-redundant-PsychHardware-LinuxDrivers.patch
diff -Nru psychtoolbox-3-3.0.19.14.dfsg1/debian/rules psychtoolbox-3-3.0.19.14.dfsg1/debian/rules
--- psychtoolbox-3-3.0.19.14.dfsg1/debian/rules	2024-08-12 16:38:17.000000000 +0300
+++ psychtoolbox-3-3.0.19.14.dfsg1/debian/rules	2026-03-30 14:08:25.000000000 +0300
@@ -19,16 +19,8 @@
 
 export LDFLAGS=-Wl,--as-needed
 
-# Critical for building on machines with multiarch support
-# (e.g. ubuntu 11.04)
-GLIB_INCLUDES=$(shell pkg-config --cflags glib-2.0)
-GST_INCLUDES=$(shell pkg-config --cflags gstreamer-1.0)
 GLEW_VERSION=$(shell pkg-config --modversion glew)
 
-# Upstream advises to build without optimization at the moment
-export CXXFLAGS=-Wall -g -O0
-export CFLAGS=-Wall -g -O0 -std=gnu99 $(GLIB_INCLUDES) $(GST_INCLUDES)
-
 # Let's use "advanced" bash patterns
 export SHELL=/bin/bash
 

Reply via email to