Commit Graph

139 Commits

Author SHA1 Message Date
Chris Wilson 88db217705 tools/dri3info: Match fd against render nodes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-02-10 12:20:47 +00:00
Chris Wilson 27ededdfc7 tools/dri3info: Query the kernel driver name
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-02-10 12:10:56 +00:00
Chris Wilson 928ff25430 tools: Add rudimentary dri3info
A simple tool just to check if the target Xserver offers dri3.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-02-09 17:09:55 +00:00
Chris Wilson 82e4802670 intel-virtual-output: Do not attempt to tidy up the local display if it fails
Just fix the segfault dereferencing the primary display if we bail
during its setup.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-12-17 08:01:30 +00:00
Chris Wilson c211b3bc61 intel-virtual-output: Add version number to verbose output
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-12-17 08:00:00 +00:00
Chris Wilson 7548f77fff intel-virtual-output: Initialise width/height for a disabled output
virtual.c:1081:6: warning: variable 'width' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (clone->dst.mode.id == 0) {
            ^~~~~~~~~~~~~~~~~~~~~~~
virtual.c:1092:6: note: uninitialized use occurs here
        if (width == clone->width && height == clone->height)
            ^~~~~
virtual.c:1081:2: note: remove the 'if' if its condition is always false
        if (clone->dst.mode.id == 0) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
virtual.c:1079:11: note: initialize the variable 'width' to silence this warning
        int width, height;

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-09-12 21:15:18 +01:00
Chris Wilson f95d04b75b intel-virtual-output: Use snprintf() for simplicity
Third one-line patch to fix copying from the tainted user argument into
the socket's path buffer. This time, give in and just use snprintf() as
it guarrantees that it will not write more than 'n' characters and that
the last is a NUL byte.

Suggested-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-08-27 10:24:35 +01:00
Chris Wilson 011f04ff8e intel-virtual-output: Fix invocation of strncpy()
Somebody (me) confused it with snprintf() and put the string length in
the wrong location. Also note that strncpy() does not NUL terminate long
strings.

Reported-by: Zdenek Kabelac <zdenek.kabelac@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-08-26 18:31:05 +01:00
Chris Wilson e827f80e5c intel-virtual-output: Sanity check length on user supplied socket path
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Suggested-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-08-26 12:46:41 +01:00
Chris Wilson 4ae346e764 configure: Double check xinerama's headers
Having the pkgconfig present doesn't always necessarily imply the
headers are installed correctly - just fail over gracefully for xinerama
and intel-virtual-output

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-18 07:38:59 +01:00
Chris Wilson 3140d72826 backlight: Prevent dereference of potential NULL argv
Adam Sampson spotted that

"It's possible (but not very sensible) to exec a program with an empty
argument list, so argv[0] is not necessarily a valid pointer. For
example:

$ cat exec0.c

int main(int argc, char *argv[]) {
    char *empty[1] = { NULL };
    execvp(argv[1], empty);
    perror("execvp");
    return 1;
}
$ ./exec0 /usr/libexec/xf86-video-intel-backlight-helper
Usage: (null) <iface>
"

He sensibly suggested that we hardcode the program name to avoid the
NULL dereference. Being the paranoid type, we should also be careful not
to write to any file descriptors outside of our control (i.e. stderr),
so disable the messages unless we are debugging.

Reported-by: Adam Sampson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-17 16:14:16 +01:00
Matthieu Herrb 8fa22964f6 backlight: Fix security issues in handling of the interface path name.
- don't allow '/' in the interface name to avoid escaping the /sys
  hierarchy
- check snprintf() return value for overflow.

Problems reported by  Adam Sampson. Thanks.

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-07-04 20:33:29 +01:00
Chris Wilson 901d889dd7 intel-virtual-output: Remove one redundant cleanup on error
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-30 07:44:25 +01:00
Chris Wilson a8b0ba0ed5 intel-virtual-output: Cleanup singleton on failure
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-29 15:30:03 +01:00
Chris Wilson 8188966485 intel-virtual-output: Convert debugging messages to verbosity
Original patch by main.haarp:
"A verbose switch is quite useful for debugging, it shouldn't require
editing and recompilation to gain more useful output. I added it."

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80664
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-29 15:29:46 +01:00
Chris Wilson 85bb55e4a6 intel: Fix weblinks (again)
Julien pointed out that I fail at checking links.

Reported-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-25 11:45:55 +01:00
Chris Wilson ff31d49bfa intel: Fix weblinks
Matti reported a few outdated links to intellinuxgraphics.org, now
superseded by 01.org.

Reported-by: Matti Hämäläinen <ccr@tnsp.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-25 11:34:48 +01:00
Chris Wilson 05fdfe3b28 intel-virtual-output: Compile fixes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-13 21:43:59 +01:00
Chris Wilson 8a92261b22 intel-virtual-output: Disable outputs on remote displays upon shutdown
References: https://bugs.freedesktop.org/show_bug.cgi?id=79994
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-13 20:00:05 +01:00
Chris Wilson 0c6fa0cdf0 intel-virtual-output: Initialise image after clone
As the image inherits its width/height from the clone, we need to set
those first on the clone.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79994
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-13 19:30:54 +01:00
Chris Wilson 79b4e45ebe intel-virtual-output: Only call XShmDetach on a valid SHM segment
Saves a couple of extraneous XErrors.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-13 19:30:54 +01:00
Chris Wilson c8074b6bcf intel-virtual-output: Check for an error creating the DRI3 fd
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79994
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-13 18:37:47 +01:00
Chris Wilson 67b37332bd intel-virtual-output: Add DRI3 xfer path
Just as proof-of-principle.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-02 08:32:11 +01:00
Chris Wilson 8d1e9afb60 intel-virtual-output: Probe after claiming virtual output
Rerun a detection cycle after claiming the virtual output so that it is
hidden again.

References: https://bugs.freedesktop.org/show_bug.cgi?id=78293
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-22 20:55:55 +01:00
Chris Wilson 10c18b1a46 intel-virtual-output: Mark the source SHMPixmap as writeable
This is fortunately a no-op, as it gets initialized to zero already
(that is the pixmap is writeable). However, we may as well do the right
thing...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-16 10:02:16 +01:00
Chris Wilson 0625185f47 intel-virtual-output: Make it possible to disable building via configure
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-14 17:29:21 +01:00
Chris Wilson c5bad6daaa intel-virtual-output: Disable remote CRTC using the remote Display!
Reported-by: Kirill Müller <mail@kirill-mueller.de>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78293
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-07 07:56:14 +01:00
Chris Wilson 77507909a1 intel-virtual-output: Grab the server whilst cleanging up the local output
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-06 06:59:20 +01:00
Chris Wilson 464ef44ab1 intel-virtual-output: Copy existing CRTC information
If we fail to disable the remote output during initialisation, copy the
current configuration in order to try and keep the bookkeeping in order.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-05 14:50:44 +01:00
Chris Wilson 194f9332d3 intel-virtual-output: Try disabling Panning after disabling CRTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-05 14:34:12 +01:00
Chris Wilson 5279ebf564 intel-virtual-output: Mark ShmPixmap destinations as writeable
In order to prevent a subsequent BadAccess when we try to use it as a
ShmPixmap, we need to mark the segment as writeable.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
References: https://bugs.freedesktop.org/show_bug.cgi?id=78293
2014-05-05 13:07:31 +01:00
Chris Wilson a93d2d4f91 intel-virtual-output: Check for errors whilst creating ShmPixmaps
Creating a ShmPixmap may cause an asynchronous BadAccess error, so wrap
the construction with XSync and check for an error before proceeding.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
References: https://bugs.freedesktop.org/show_bug.cgi?id=78293
2014-05-05 13:07:31 +01:00
Chris Wilson 45892b3a63 intel-virtual-output: Record shm/randr/xinerama queries in DBG log
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-05 12:42:56 +01:00
Chris Wilson 6c9f216d7c intel-virtual-output: Check error state when disabling CRTC
Only mark an output as disabled if we do successfully disable it. This
will require a little more work to make sure that such errors are
cleanly propagated back to the host...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-05 12:42:56 +01:00
Chris Wilson f9a279b2dc intel-virtual-output: Fix damage bounds
Sigh. A serious mixup of integer promotion rules and wraparound caused
the damage computation for small regions to be completely bogus.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-04-09 22:15:19 +01:00
Chris Wilson bf18751398 intel-virtual-output: Fixup DBG messages
Use the right variables and it may even compile.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-04-07 08:28:55 +01:00
Chris Wilson 771b86e2a8 intel-virtual-output: Add DBG option to force 16 bit transfers
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-27 14:26:54 +00:00
Chris Wilson a273b207b9 intel-virtual-output: Fix damage iteration over active list
When iterating over the active list to mark the current damage, we need
to chase the ->active pointer rather than ->next or else we walk the
wrong list from the wrong starting point.

Reported-by: Kirill Müller <mail@kirill-mueller.de>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76271
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-25 09:40:40 +00:00
Chris Wilson bfd51e2056 intel-virtual-output: Add a little more DBG around damaging clones
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-25 08:59:58 +00:00
Chris Wilson 278ef8f7bc intel-virtual-output: Do not detach with DBG enabled
Since DBG is sent to stdout, we only see it if we do not daemonize
(which closes stdout).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-25 08:33:46 +00:00
Chris Wilson 57e63221ec intel-virtual-output: Minor DBG fixes
Improve the summary after failing to detect MIT-SHM, and fix a DBG

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-14 19:49:59 +00:00
Chris Wilson 8cc1f005c6 intel-virtual-output: Iterate over remote outputs in the same order as listed
If we walk the output lists in the same order as they are listed by
RandR, we are more likely to hit favourable priority sorting. E.g. the
user is likely to setup the outputs in the same order as listed, meaning
fewer CRTC transitions etc.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-14 15:55:41 +00:00
Chris Wilson a55bbe3b59 intel-virtual-output: Disable panning before setting mode on CRTC
For whatever reason, presumably to do with the switch between CRTCs, we
need to disable the panning before setting the mode in order for our
desired CRTC position to take effect.

Reported-by: Jeff Katz <bugzilla@kraln.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76146
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-14 15:47:20 +00:00
Chris Wilson 5079830bd5 intel-virtual-output: Mode names are freed with ScreenResources
So we have to be careful not to continue to reference the strings after
they may be freed.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-14 14:35:29 +00:00
Chris Wilson f47f192f22 intel-virtual-output: Include extra debug information for modesets
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-14 11:38:19 +00:00
Chris Wilson 0ad54325e9 intel-virtual-output: Disable remote CRTCs at startup
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-03-14 08:15:24 +00:00
Chris Wilson ecc20fbcf8 intel-virtual-output: Discard unwanted events from the mouse recorder
X always sends MappingNotify events (there is no way for the client
to ignore them). In particular, MappingNotify would be sent after a VT
switch, and this would knock out our ability to track the cursor..

Reported-by: Raul Dias <raul@dias.com.br>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75115
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-02-18 07:56:07 +00:00
Hans de Goede e860b3eaed backlight-helper: Simplify reading the level from stdin
Since the helper is a standalone app, the usual xserver rules of not using
stdio because of signal handling don't apply.

And since the helper does run with elevated rights, it is important to keep
the code KISS so that it can be audited easily.

This commit replaces the hard to read "raw" read loop with a much simpler
loop using fgets, improving readability of the code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-02-17 18:38:54 +00:00
Jan Alexander Steffens (heftig) b71f3d8bd4 Backlight helper build fixes
Don't hardcode $(prefix)/libexec

Fix install hook when DESTDIR is set

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75028
2014-02-15 17:39:01 +00:00
Chris Wilson 3d629c91cf intel: Add a helper for setting backlight without root rights
Once the xserver stops running as root on kms capabable systems, we will need
some other way to access the backlight.

The approach taken in this patch moves most of the heavy lifting to a
helper that runs with root privileges and pipes our requested brightness
into the sysfs backlight interface. Where required, we use pkexec to
launch the helper with the elevated privilege.

v2: Amalgamate much more of the duplicate code.
    Keep the daemon and pipe alive for the lifetime of the backlight interface.
    Provide an alternative for systems without PolicyKit.

Signed-off-by: Hans de Goede <hdegoede@redhat.com> [v1]
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-02-15 15:33:47 +00:00