Commit Graph

40 Commits (66c3afb75fa993f2f8b00c2dd9c2ec37a3a9dfb6)

Author SHA1 Message Date
Jonathan Gray 66c3afb75f xf86drm: correct the OpenBSD DRM_MAJOR define
As far as I can tell no OpenBSD platform ever used 81
for a drm major.  While the value was added to libdrm in 2003
or earlier drm didn't appear in OpenBSD till 2007.

Of the OpenBSD platforms that support drm amd64/macppc/sparc64
use a major of 87, i386 uses 88.

v2: rearrange ifdefs as suggested by Emil.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-07-29 18:04:15 +01:00
Emil Velikov c1cd3d9388 xf86drm: fix incorrect fd comparison in drmOpenOnce{,WithType}
Spotted by looking for similar "let's assume fd == 0 is invalid" bugs.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
2015-07-16 16:41:49 +01:00
Emil Velikov 5b0e76f143 Revert "Add device enumeration interface (v4)"
This reverts commit fde4969176.

The commit adds an API that does not seem flexible enough to be used in
current open-source projects. Additionally it adds a hidden dependency
of libudev, which when used in mesa caused grief when combined with
Steam('s runtime).

Let's revert this for now and add a tweaked API later on that can be
used in mesa/xserver.

Cc: Frank Min <frank.min@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Jammy Zhou <Jammy.Zhou@amd.com>
2015-06-29 11:12:21 +01:00
Guillaume Desmottes 4bca42fc50 drmPrime*: initialize output args to 0
Fix Valgrind errors because those memory was uninitialized.

https://bugs.freedesktop.org/show_bug.cgi?id=90194
Signed-off-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>

v2: Explicitly zero the whole struct using memclear.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-05-28 15:58:34 +01:00
Jammy Zhou 454b149494 Fix one warning (v2)
xf86drm.c:356:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
  group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
  ^

v2: do 'int' cast to fix the warning

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-05-28 15:49:18 +01:00
Emil Velikov d0e592d4e9 xf86drm: simplify drmMalloc/drmFree
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-05-28 15:40:18 +01:00
frank fde4969176 Add device enumeration interface (v4)
Add an interface for enumerating PCI devices on
a system.

v3: switch to udev/sysfs for the enumeration
v4: fix warnings

Signed-off-by: Frank Min <frank.min@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
2015-05-26 12:34:38 -04:00
Emil Velikov 42465feb97 drm: rename libdrm{,_macros}.h
Provide a more meaningful name, considering what it does.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-04-28 11:19:15 +01:00
Connor Behan 1490055bc0 xf86drm: Fix ioctl struct clearing in drmAgpEnable
This one is a bit harder to notice.

Signed-off-by: Connor Behan <connor.behan@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-04-05 15:33:33 +01:00
Jan Vesely cfbe9c9807 Remove drmSetDebugMsgFunction and related infrastructure
Not used anywhere

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-03-20 17:36:04 -04:00
Jan Vesely 6fc0e4ba1e Fix unused function warnings
v2: Remove the handler function instead of commenting out
    split debugmsg function removal to a separate patch

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-03-20 13:36:53 -04:00
Jan Vesely 0706c14e7c Fix unused, and unused-but-set variables warnings
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Emil Velikov <eil.l.velikov@gmail.com>
2015-03-14 17:02:06 -04:00
Alan Coopersmith 0e1135de5c On Solaris, #include <sys/mkdev.h> in xf86drm.c
Needed on Solaris for the definitions of major() & minor() used in
drmGetNodeTypeFromFd() and makedev() used in drmOpenMinor()

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-03-14 08:37:36 -07:00
Emil Velikov 0ca03a4087 drm: add drmGet(Primary|Render)DeviceNameFromFd functions
Currently most places assume reliable primary(master) <> render node
mapping. Although this may work in some cases, it is not correct.

Add a couple of helpers that hide the details and provide the name of
the master or render device name, given an fd. The latter may belong to
either the master, control or render node device.

v2:
 - Rename Device and Primary to Master (aka the /dev/dri/cardX device).
 - Check for the file via readdir_r() rather than stat().
 - Wrap the check into a single function.
 - Return NULL for non-linux platforms.

v3:
 - Don't segfault if name is NULL.
 - Update function names, as suggested by Frank Binns.

v4:
 - Update commit message to reflect the function name changes.

Cc: Frank Binns <frank.binns@imgtec.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
2015-03-10 18:14:40 +00:00
Frank Binns 1f73578df3 Add new drmGetNodeTypeFromFd function
Add a helper function that returns the type of device node from an fd.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-02-23 09:29:19 +00:00
Jammy Zhou dbc8b11db6 Add new drmOpenOnceWithType function (v2)
v2: call drmOpenOnceWithType in drmOpenOnce, and drop unused param
for drmOpenOnceWithType

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
2015-02-12 18:36:52 -05:00
Jammy Zhou f1adc4b375 Add new drmOpenWithType function (v4)
v2: Add drmGetMinorBase, and call drmOpenWithType in drmOpen
v3: Pass 'type' to drmOpenByBusid and drmOpenDevice in drmOpenByName
v4: Renumber node type definitions, and return -1 for unsupported type

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v3)
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
2015-02-12 18:34:57 -05:00
Daniel Vetter 95f23cf894 xf86drm: Fix ioctl struct clearing in drmGetVersion
Oops, fumbled that one.

Reported-by: Jan Vesely <jan.vesely@rutgers.edu>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-11 17:25:30 +01:00
Daniel Vetter fd38794344 xf86drm: Unconditionally clear ioctl structs
We really have to do this to avoid surprises when extending the ABI
later on. Especially when growing the structures.

A bit overkill to update all the old legacy ioctl wrappers, but can't
hurt really either.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-11 15:37:17 +01:00
Daniel Vetter 80834b377e drm: use drmIoctl everywhere
Well just core drm. All the other callers in there that still use
direct calls to ioctl have some custom retry logic already, so should
be good already.

All the other offenders (tests, freedreno/kgsl, ...) don't really
matter (e.g. kgsl is the blob library and so not a drm thing) or are
again special exceptions with their own retry loops.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-11 15:36:43 +01:00
Jan Vesely de8532dd83 Fix gcc -Wextra warnings
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Ian Romanick <idr@freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-02-10 15:25:28 -05:00
Frank Binns 0c5aaeef51 Add new drmOpenRender function
Add a new function, drmOpenRender, that can be used to open render nodes. This
can be used in the same way that drmOpenControl is used to open control nodes.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
2015-01-23 23:02:27 +00:00
Frank Binns ad8bbfd3c7 Rename DRM_NODE_RENDER to DRM_NODE_PRIMARY
Now that there are render nodes it doesn't seem appropriate for the type of
the card nodes to be DRM_NODE_RENDER. For this reason, rename this type to
DRM_NODE_PRIMARY as this name better represents the purpose of these nodes.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
2015-01-23 23:02:06 +00:00
Emil Velikov faf51d5694 drm: use drm_mmap/drm_munmap wrappers
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
2014-09-28 17:09:34 +01:00
Daniel Kurtz 305478ce02 drmOpenByName: remove redundant drmAvailable check
drmOpenByName() is a static function that is only called by drmOpen().
drmOpen() already checks drmAvailable(), so the check in
drmOpenByName() is redundant.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2014-05-13 12:14:19 +02:00
Thierry Reding 303ff26311 libdrm: Remove extraneous parameter
The debug message's format string doesn't contain any conversion
specifiers, therefore making the fd argument unused.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2014-04-17 16:21:46 +02:00
Thierry Reding 44b08c0ddf Mark functions printf-like where possible
These functions all take a format string and either a list of variable
arguments or a va_list. Use the new DRM_PRINTFLIKE macro to tell the
compiler about it so that the arguments can be checked against the
format string.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2014-04-17 16:21:40 +02:00
Damien Lespiau ddbbdb13d8 drm: Introduce a drmSetClientCap() wrapper
That wraps around the new DRM_SET_CLIENT_CAP ioctl.

v2: SET_CAP -> SET_CLIENT_CAP renaming

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-09-30 13:35:49 +01:00
Daniel Kurtz 1eb2860b4b drm: Fix error message in drmWaitVBlank
If clock_gettime did fail, it would return -1 and set errno.
What we really want to strerror() is the errno.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
2013-03-28 08:34:30 -07:00
Dave Airlie cc0a14575d libdrm: add prime fd->handle and handle->fd interfaces
These are just basic ioctl wrappers around the prime ioctls,
along with the capability reporting.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-16 02:39:56 +01:00
Jeremy Huddleston 961bf9b5c2 Fix compilation with -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-01 14:42:13 -07:00
Dave Airlie 3b04c73650 libdrm: oops fix get cap return value. 2011-03-04 15:48:31 +10:00
Ben Skeggs 5c6c6913d1 Implement drmGetCap() to query device/driver capabilities
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2011-03-04 15:25:51 +10:00
Dave Airlie 39e5e98224 drm: don't do the create the node ourselves if we have udev.
this can remove nodes it shouldn't, let udev run the show.

this is needed for reliably GPU switch.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2010-12-07 14:26:09 +10:00
Adam Jackson 0a1ff35c70 s/drmStrdup/strdup/
_DRM_MALLOC hasn't been a relevant concern since we split libdrm out
from xserver.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-10-27 18:46:57 -04:00
Benjamin Herrenschmidt b04515c5d6 libdrm: Fix PCI domain domain support
This works in conjunction with newer kernels. If we succeed in requesting
interface 1.4, the we know the kernel provides proper domain numbers. If
not, ignore the domain number as it's bogus (except on Alpha).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-08-06 09:38:43 -04:00
Kristian Høgsberg fbc8b2d95f Be less chatty in drmSetMaster/drmDropMaster 2009-12-15 08:44:40 -05:00
Robert Noland 6f66de982a Correctly set DRM_MAX_MINOR for all platforms.
DRM_MAJOR is platform specific, but not used outside of xf86drm.c
that I can find.
2009-11-25 15:09:24 -06:00
Kristian Høgsberg 22d4666904 Add drmGetDeviceNameFromFd function
Determines the /dev filename of the drm fd argument.
2009-11-23 20:51:34 -05:00
Kristian Høgsberg 4f57abfe66 Move libdrm/ up one level 2009-11-17 11:15:06 -05:00