Commit graph xserver/hw
Author SHA1 Message Date
b-aaz
ea4abb01ae xfree86: loader: Fix memory/array bugs in loadmod.
`sizeof` was incorrectly used to get the length of an string in an array
of char pointers (array of strings), which always returns the system's
pointer size (8 on 64bit) instead of the actual string length.
Was fixed by using `strlen` instead.

Additionally the final step that appended the returning array of strings
with another array of strings, also used an incorrect `memcpy` function
to copy the elements.
Was fixed by using an explicit for loop.

And I also replaced the 'length' variables' type's with the proper
`size_t` type instead of `int`, where possible.

Issue and patch from:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299077

Signed-off-by: b-aaz <b-aazbsd@proton.me>
2026-11-13 15:31:03 +01:00
Enrico Weigelt, metux IT consult
ee4bb3f96e xfree86: int10: remove unused/obsolete dprint()
Not used anymore, so no need to keep it around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-02 14:16:03 +01:00
Enrico Weigelt, metux IT consult
63379b4871 xfree86: int10: drop never used SHOW_ALL_DEVICES code pathes
These code pathes have never been actually used, thus no need to
carry them around for any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-02 14:14:20 +01:00
Enrico Weigelt, metux IT consult
483a1722f9 xfree86: int10: drop obsolete vm86 backend
* didn't compile since 2014 (commit 21b216ad6)
* based on vm86(), which is only availble on Linux i386/i686
* obsoleted by x86emu

Thus no need to carry around broken code pathes any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 18:11:33 +01:00
Enrico Weigelt, metux IT consult
2545199fd8 xfree86: int10: remove some unused defines
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 17:23:31 +01:00
Enrico Weigelt, metux IT consult
07fa547b67 xfree86: int10: drop ancient remains of some DX/UX workaround
It seems that ancient DG/UX systems needed some special workarounds,
which of we only have some remains left that are never compiled.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 17:19:21 +01:00
Enrico Weigelt, metux IT consult
146a76a6c1 xfree86: int10: add define X86_CARRY_MASK
add a define with proper name instead of using raw literal value.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 16:43:25 +01:00
Enrico Weigelt, metux IT consult
722929bf50 xfre86: int10: drop obsolete REG macro definition
Not used anywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 16:04:55 +01:00
Enrico Weigelt, metux IT consult
809696d4ee xfree86: int10: drop mode dead code
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 15:22:07 +01:00
Enrico Weigelt, metux IT consult
2ebd277a6d xfree86: drop some dead code
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 12:33:38 +01:00
Mario Kleiner
81e6f606a1 modesetting: Fix RandR output leasing while TearFree is enabled.
Since commit a94dd9536 ("modesetting: add support for TearFree page flips"),
whenever TearFree and PageFlip is simultaneously enabled (which is the
default now), the driver does enable DRM universal plane support, just
as when atomic modesetting is enabled.

Leasing RandR / DRM outputs with universal planes enabled requires
also adding the drm_plane object to the set of leased objects,
otherwise the drmModeCreateLease() ioctl will fail.

Adding a drm_plane object under this condition was omitted, so fix
this omission, and thereby fix RandR output leasing.

Fixes: a94dd9536 ("modesetting: add support for TearFree page flips")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2332>
(cherry picked from commit f37bd8de26)
2026-10-20 19:58:05 +02:00
Peter Hutterer
9e3b288abf Fix remaining ruff check issues
Two if conditions compressed into one.
Two open() marked as ignored by SIM115 (use context manager for opening files)
because it'd require too much restructuring.
And one open() ... close()  changed to a context manager, the diff
is the reindentation of everything between open and close.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit eb9292efdb)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:56:53 +02:00
Peter Hutterer
d6de666503 Ruff check --fix --unsafe-fixes across the tree
Only affecting two files and these are the straightforward changes.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit 2c53e65004)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:56:53 +02:00
Peter Hutterer
c3b028aee8 Run ruff format against the whole source tree
Only two files that needed changes anyway, might as well enforce this.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit 6aa23cf642)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:56:53 +02:00
stefan11111
29a6b17197 kdrive/modesetting: pass the gbm device to glamor
Don't have it open another one

This fixes a segfault when the render card is different from
the scanout card, and glamor uses the fast gbm import path.

If https://github.com/X11Libre/xserver/issues/2645
applies to Xmodesetting, this probably fixes it.

This is also a resource usage optimization,
since glamor doesn't allocate another gbm device
when Xmodesetting already allocates a perfectly usable one.

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-19 13:09:25 +02:00
Enrico Weigelt, metux IT consult
a6710636a1 xfree86: remove $XORGCONFIG environment variable
It's just an ancient relic from previous century, that's ever been helpful
in a few corner cases - and can be easily replaced by -config / -configdir
cmdline options.

OTOH, it's a potential security risk for Xservers running with suid root
(eg. if it somehow fails to detect/switch to the restricted mode)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-14 18:01:00 +02:00
Sergey Fedorov
cb05d5067b xquartz: define HAS_LIBDISPATCH only in osxcompat.h
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
3d5224df92 xquartz: only build libdispatch callbacks when libdispatch is used
Without HAS_LIBDISPATCH (macOS < 10.6) these static callbacks are
never referenced, which triggers -Wunused-function and breaks the
build with -Dwerror=true:

  - sendX11NSEvent_fptr() in X11Application.m
  - socketHandoff_fptr() in bundle-main.c
  - windowHashInsert(), windowHashRemove(), windowLookup() and
    windowGet() in xprFrame.c

socketHandoff_fptr() calls socket_handoff(), which only exists with libdispatch
(otherwise it's socket_handoff_thread()).

Also move the WindowLookupCtx in xprRestackFrame() into the
libdispatch branch, since it's unused otherwise, like it's already
done in xprGetXWindow().

Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
483edb396b xquartz: X11Application.m: drop _fptr suffix from helpers
The _fptr suffix marked helpers that were only called as function
pointers through libdispatch. With the pre-10.6 fallbacks they're
now also called directly, so the suffix is misleading.

sendX11NSEvent_fptr() keeps its name: it's still only used through
dispatch_async_f().

Suggested-by: Aggelos Tselios <aggelostselios777@gmail.com>
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
00ae45d4ac xquartz: xpr: fix window id truncation on LP64 (ppc64)
xprCreateFrame() passed &pFrame->wid, a (void *), straight to
xp_create_window() through a (xp_window_id *) cast.  xp_window_id is
32 bits, so only half of the 64-bit RootlessFrameID word was written;
the other half was left uninitialized.  window_hash is created with
x_hash_table_new(NULL, NULL, NULL, NULL), so keys are compared by exact
pointer identity -- a dirty high word therefore makes subsequent
lookups miss, and also trips the

    assert(sv == uv);

in x_cvt_vptr_to_uint().  On a big-endian LP64 target (ppc64) it is
worse still: the 32-bit id is written into the high half of the word,
so the truncating conversions used everywhere else (MAKE_WINDOW_ID(),
x_cvt_vptr_to_uint()) read the wrong half entirely.

This is invisible on ILP32 (32-bit ppc/i386), where void * and
unsigned int are the same width and the raw store and the converted
value have identical bit patterns -- which is why 10.6/ppc worked while
10.5/ppc64 crashed launching a client.

Write the id through a real xp_window_id and zero-extend it into
pFrame->wid, so the word is fully defined regardless of ABI or byte
order, and key window_hash consistently in both the libdispatch and
non-libdispatch paths.  With pFrame->wid clean at its single point of
origin, the downstream MAKE_WINDOW_ID()/x_cvt_vptr_to_uint()
truncations are correct and the assert no longer needs to be disabled
on ppc64.

Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
9a646b07f0 xquartz: X11Controller.m: add one missing synthesize call
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
27d596b139 xquartz: xpr: support pre-10.6 versions of Xplugin
See: 16f52e51a2/hw/xquartz/xpr/xprAppleWM.c (L149-L158)
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
9a6c9f5bba xquartz: X11Application.m: fallbacks to support < 10.6
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
4e8d840f68 xquartz: xprFrame.c: drop duplicate variable in fallback code
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
bf4e970208 xquartz: bundle-main.c: add missing header for pre-10.6 fallback
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Sergey Fedorov
e9fda9bdb1 xquartz: work around a bug in 10.5 system headers
Picked from 16f52e51a2/hw/xquartz/quartz.c (L75-L79)

Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 15:32:39 +02:00
Enrico Weigelt, metux IT consult
9f913a3156 meson_options: disable XvMC build by default
XvMC is only helpful for old MPEG2 decoding (and here only some specific
part, the motion compensation). It's only supported by few cards, and needs
special client-side drivers, which need to have direct and pretty low-level
(non-DRI) GPU access (usually involving root access).

Since it's local-only anyways, modern clients can use generic GPU shaders
for various video formats (via standard DRI/mesa) and send whole frames.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-13 14:16:38 +02:00
galternat
3efbc12731 modesetting: fix whitespace and brace style in driver.c
Tab indentation, missing spaces before braces and after commas, a
function brace on the declaration line, stray blank lines and a
misaligned comment end.

Also end the "failed to open" error with a newline, so the next log
message doesn't start on the same line.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
2026-10-13 13:50:16 +02:00
galternat
a10ffde406 modesetting: release seatd GPU FDs through libseat
ms_try_open() falls back to seatd_libseat_open_graphics() when the
driver can't open the node itself, but every FD from open_hw() is
closed with a plain close(). seatd keeps its own reference to the
device, and the FD stays in seatd-libseat.c's list, where a later open
that reuses the FD number can be mistaken for it.

Export seatd_libseat_close_graphics() and call it before closing an FD
that may have come from open_hw(). It does nothing for an FD that
wasn't opened through seatd, so the driver doesn't have to remember
where each FD came from. drmOpen() FDs of PCI entities and server FDs
aren't closed on these paths.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
2026-10-13 13:50:16 +02:00
galternat
8dc955bf44 xfree86: seatd-libseat: release the GPU on platform device removal
xf86_remove_platform_device() frees the attributes with
config_odev_free_attributes(), which gives a server FD back through
systemd_logind_release_fd(): a plain close() without a logind session.
seatd keeps the device open, and the tracked entry is left pointing at
an FD number that can be reused.

Close the device through libseat there, next to the logind release.
config.c is also linked into the kdrive servers, which never open a
device through seatd, so they get an empty stub like the logind ones.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
2026-10-13 13:50:16 +02:00
galternat
1dc709ab7f xfree86: seatd-libseat: release the GPU when the driver won't take the FD
seatd_libseat_open_graphics() hands the probed GPU's FD to the platform
bus as a server FD. For a driver without SUPPORTS_SERVER_FDS,
doPlatformProbe() gives it back with systemd_logind_release_fd(), which
without a logind session is a plain close(). seatd keeps its own
reference to the same open file and with it DRM master, so the driver's
own open of the node is not master which will cause it to fail.

The libseat device ID was also kept in a single slot that every
seatd_libseat_open_graphics() call overwrote, so with more than one GPU
there was no way to close the right device.

Track the libseat ID per FD and close the device through libseat before
the server FD is dropped.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
2026-10-13 13:50:16 +02:00
Sergey Fedorov
99f26056ed xquartz: fix regression due to unconditional usage of qos APIs
Fixes breakage introduced by b4b8617fe6

Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
2026-10-13 13:04:25 +02:00
galternat
15bc9fbfc6 kdrive/modesetting: use the drm_defines.h GBM fallbacks
ms_gbm.c uses GBM_BO_USE_FRONT_RENDERING, which older libgbm versions
accepted by meson don't provide, so Xmodesetting fails to build against
them. Include drm_defines.h, which defines it to 0 in that case, as the
Xorg modesetting driver does.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
2026-10-13 09:38:28 +02:00
galternat
27d07c40ce modesetting: drop the stale GBM_BO_USE_FRONT_RENDERING fallback
GBM_BO_USE_FRONT_RENDERING is a gbm_bo_flags enum value, so this
#ifndef always redefines it to 0. Nothing in drmmode_display.c has used
it since the front buffer allocation moved to drmmode_bo.c, which gets
the correct fallback from drm_defines.h, as does this file.

Remove it, so a later use here doesn't silently get 0.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
2026-10-13 09:38:28 +02:00
Sergey Fedorov
027067d485 xquartz: bundle_trampoline.c: fall back to ASL when os_log is unavailable
Commit ee9cb28c3 switched the trampoline's error reporting to
os_log_error(), which only exists on macOS 10.12 and later, breaking the
build for older deployment targets.

Add HAS_OS_LOG to osxcompat.h, keyed on MAC_OS_X_VERSION_MIN_REQUIRED
like the other compat checks, and route logging through
a trampoline_log_error() macro that uses asl_log() when os_log is not
available. The os_log-only %{public}s specifier is wrapped in a PUBLIC_S
macro that expands to plain %s for ASL.

Signed-off-by: Sergey Fedorov <barracuda@macos-powerpc.org>
2026-10-12 15:23:30 +02:00
galternat
942379ce91 xfree86: platform bus: don't crash on an OutputClass without ModulePath
An OutputClass with neither Driver nor Module ends up in the branch that
extends the default module search path, which dereferences
cl->modulepath without checking it. A class that only sets options, such
as PrimaryGPU, crashes the server during the bus probe.

Leave the search path alone when the class has no ModulePath, as before
per-driver search paths were introduced.

Fixes: 9f25f5d3f1 ("xfree86: make search paths configurable for certain modules")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
2026-10-12 15:17:50 +02:00
Enrico Weigelt, metux IT consult
3c36e9029d xfree86: loader: treat empty module path as not present
Callers of LoaderSetPath(), eg. xf86PlatformProbe, might pass empty strings
instead of NULL, but those also meaning "not present" (IOW: use default path).
That's leading to spurious "Failed to store module search path" error log
messages for modules that don't have a search path yet.

Instead of adding extra complexity there for transforming empty strings
to NULL pointers, just deal with those here and so make the interface
a bit more robust.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-12 14:41:53 +02:00
stefan11111
e90608e5d9 kdrive/modesetting: Work around mesa format restrictions for dumb gbm buffers
If a dumb gbm buffer cannot be created for a given depth,
but a tiled buffer works, use the tiled buffer and hope it works

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
21583e6f96 kdrive/modesetting: Fix modifier filter bounds
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
62ef6314e7 kdrive/modesetting: Query glamor if the context is gles instead of guessing
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
db99ba82b7 kdrive/modesetting: Fix screen rotations when the buffer is tiled
When the front buffer is tiled, this untextures the root pixmap,
and replaces the tiled bo with a cpu-mapped bo (+ ShadowFB if needed)

In the future, we should probably create a tiled shadow buffer,
and use gl for rotations

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
197b230e18 kdrive/modesetting: Re-enable ShadowFb on the msSetScreenBo bail path
We change the shadow update on the happy path.
If we later need to bail, we need to restore the old shadow update proc.

This can happen for example when we can't texture the front bo,
and we need to bail back to the cpu-mapped front bo,
and the cpu-mapped front bo was using ShadowFB

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
85c205fb2a kdrive/modesetting: Add option -modifier
Mostly intended for testing

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
4cc2a5693c kdrive/modesetting: Always use a shadow framebuffer for rotated screens
Improve the logged info message

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
f1d3f93201 kdrive/modesetting: Log some info about options -notile and -planar
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
ee24c6c4e4 kdrive/modesetting: Fix option -planar
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
9ebafed369 kdrive/modesetting: Try to use a 64x64 cursor if possible
For most uses, a 64x64 cursor is large enough.

If we are asked for a larger cursor, we allocate and use it then.

A 64x64 should be a good compromise between power usage and complexity.

See: 1f41320e1c
See: https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1922

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
d81e3fa51c kdrive/modesetting: Damage-track the cursor buffer
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
0c67f47d52 kdrive/modesetting: Repaint the cursor when rotating the screen
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00
stefan11111
42204fff0c kdrive/{fbdev,modesetting}: Don't constrain the cursor position unnecessarily
We don't tell RandR about the initial rotation, so it thinks that it needs to
constrains the cursor position to the intersection of the rotated screen and unrotated screen

Wrap `pScreen->ConstrainCursorHarder` and return early when we are initially rotated.

We could instead just tell RandR about out initial rotation and assign new rotations directly
in RRSetConfig.

For now do it like this, revisit later if needed/desired.

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-12 13:22:59 +02:00