summaryrefslogtreecommitdiff
path: root/xf86drm.c
AgeCommit message (Collapse)AuthorFilesLines
2015-09-21xf86drm: remove makedev() hack/workaroundEmil Velikov1-8/+0
Back when this was introduced commit 569da5a42eb(Merged glxmisc-3-0-0) sys/sysmacros.h was used instead of the respecive headers (as per the manual). We've been handling it correctly for a little while now - in Linux, BSD and Solaris. Thus we can drop this workaround. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-09-21xf86drm: add drm{Get,Free}DeviceEmil Velikov1-1/+114
Similar interface to the *Devices() ones but they obtain/free the information of the opened device (as given by its fd). Note there is a fair bit of duplication between the two Get functions, and anyone interested is more than welcome to consolidate it. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: split out drmProcessPciDevice and drmFoldDuplicatedDevicesEmil Velikov1-49/+74
Will be reused in the next commit. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: warn on missing drmGetMinorNameForFD implementationEmil Velikov1-0/+2
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: move ifdef __linux__ guards where neededEmil Velikov1-18/+15
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: rework drmGetDevices()Emil Velikov1-110/+94
Do a once off memory allocation for each drmDevice. This allows us to ease the error handling and simplify the de-duplication loop. As part of this we need to rework drmFreeDevice() such so that it frees the relevant hunks, rather than leaving that to the caller. Some memory stats from the drmdevice test before: 22 allocs, 22 frees, 66,922 bytes allocated after: 9 allocs, 9 frees, 66,436 bytes allocated Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: rename drmSameDevice to drmCompareBusInfoEmil Velikov1-6/+8
Move away form the boolean name, change the return value appropriately and check if either argument is NULL. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: move the final linux specific bits out of drmGetDevicesEmil Velikov1-10/+9
Third and final piece of making drmGetDevices less crazy/ugly. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: move platform details to drmParsePciDeviceInfo()Emil Velikov1-21/+15
As with previous commit let's try to keep drmGetDevices clean of linux specifics. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21xf86drm: flex platform specifics into drmParsePciBusInfoEmil Velikov1-26/+20
This will allow one to reuse the core drmGetDevices implementation on other platforms. Keeping all the platform specifics in ParseFoo. On the plus side this saves a bit of code :) Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-04drm: make individual drm_server_info fxns optionalRob Clark1-5/+7
For android / drm_gralloc, we want to hook up our own debug_print() without bothering with the reset of it. Signed-off-by: Rob Clark <robdclark@gmail.com>
2015-08-24drm: add interface to get drm devices on the system v3Emil Velikov1-0/+351
For mutiple GPU support, the devices on the system should be enumerated to get necessary information about each device, and the drmGetDevices interface is added for this. Currently only PCI devices are supported for the enumeration. Typical usage: int count; drmDevicePtr *foo; count = drmGetDevices(NULL, 0); foo = calloc(count, sizeof(drmDevicePtr)); count = drmGetDevices(foo, count); /* find proper device, open correct device node, etc */ drmFreeDevices(foo, count); free(foo); v2: [Jammy Zhou] - return a list of devices, rather than nodes v3: [Jammy Zhou] - fix the signed extension for PCI device info Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
2015-08-24drm: fix the usage after freeMathias Tillman1-2/+3
For readdir_r(), the next directory entry is returned in caller-allocted buffer (pointered by pent here). https://bugs.freedesktop.org/show_bug.cgi?id=91704 Signed-off-by: Mathias Tillman <master.homer@gmail.com> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
2015-07-29xf86drm: use the correct device minor names on OpenBSDJonathan Gray1-3/+13
Add defines for the device minor names and make use of them in drmGetMinorName() so the correct paths will be used on OpenBSD. v2: don't add new defines to xf86drm.h to keep them out of the API as requested by Emil. Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-07-29xf86drm: correct the OpenBSD DRM_MAJOR defineJonathan Gray1-3/+7
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-16xf86drm: fix incorrect fd comparison in drmOpenOnce{,WithType}Emil Velikov1-1/+1
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-06-29Revert "Add device enumeration interface (v4)"Emil Velikov1-100/+0
This reverts commit fde4969176822fe54197b6baa78f8b0ef900baba. 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-05-28drmPrime*: initialize output args to 0Guillaume Desmottes1-1/+3
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-28Fix one warning (v2)Jammy Zhou1-1/+1
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-28xf86drm: simplify drmMalloc/drmFreeEmil Velikov1-6/+2
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-05-26Add device enumeration interface (v4)frank1-0/+100
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-04-28drm: rename libdrm{,_macros}.hEmil Velikov1-1/+1
Provide a more meaningful name, considering what it does. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-04-05xf86drm: Fix ioctl struct clearing in drmAgpEnableConnor Behan1-1/+1
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-03-20Remove drmSetDebugMsgFunction and related infrastructureJan Vesely1-12/+1
Not used anywhere Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-03-20Fix unused function warningsJan Vesely1-0/+2
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-14Fix unused, and unused-but-set variables warningsJan Vesely1-3/+6
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> Reviewed-by: Emil Velikov <eil.l.velikov@gmail.com>
2015-03-14On Solaris, #include <sys/mkdev.h> in xf86drm.cAlan Coopersmith1-0/+3
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-10drm: add drmGet(Primary|Render)DeviceNameFromFd functionsEmil Velikov1-0/+84
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-02-23Add new drmGetNodeTypeFromFd functionFrank Binns1-0/+39
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-12Add new drmOpenOnceWithType function (v2)Jammy Zhou1-2/+10
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-12Add new drmOpenWithType function (v4)Jammy Zhou1-15/+55
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-11xf86drm: Fix ioctl struct clearing in drmGetVersionDaniel Vetter1-1/+1
Oops, fumbled that one. Reported-by: Jan Vesely <jan.vesely@rutgers.edu> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-11xf86drm: Unconditionally clear ioctl structsDaniel Vetter1-35/+77
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-11drm: use drmIoctl everywhereDaniel Vetter1-2/+2
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-10Fix gcc -Wextra warningsJan Vesely1-2/+2
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-01-23Add new drmOpenRender functionFrank Binns1-2/+38
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-23Rename DRM_NODE_RENDER to DRM_NODE_PRIMARYFrank Binns1-5/+5
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>
2014-09-28drm: use drm_mmap/drm_munmap wrappersEmil Velikov1-4/+4
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
2014-05-13drmOpenByName: remove redundant drmAvailable checkDaniel Kurtz1-13/+0
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-04-17libdrm: Remove extraneous parameterThierry Reding1-1/+1
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-17Mark functions printf-like where possibleThierry Reding1-3/+7
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>
2013-09-30drm: Introduce a drmSetClientCap() wrapperDamien Lespiau1-0/+7
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-03-28drm: Fix error message in drmWaitVBlankDaniel Kurtz1-1/+1
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>
2012-07-16libdrm: add prime fd->handle and handle->fd interfacesDave Airlie1-0/+31
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>
2011-11-01Fix compilation with -Werror=int-to-pointer-cast -Werror=pointer-to-int-castJeremy Huddleston1-4/+4
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-03-04libdrm: oops fix get cap return value.Dave Airlie1-1/+1
2011-03-04Implement drmGetCap() to query device/driver capabilitiesBen Skeggs1-0/+12
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2010-12-07drm: don't do the create the node ourselves if we have udev.Dave Airlie1-0/+2
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-10-27s/drmStrdup/strdup/Adam Jackson1-21/+4
_DRM_MALLOC hasn't been a relevant concern since we split libdrm out from xserver. Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-08-06libdrm: Fix PCI domain domain supportBenjamin Herrenschmidt1-5/+25
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>