summaryrefslogtreecommitdiff
path: root/linux-core/drm_ioctl.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2003-10-23 02:23:31 +0000
committerEric Anholt <anholt@freebsd.org>2003-10-23 02:23:31 +0000
commit06cb132e86dc4a04044c3c76725ba3037008ab34 (patch)
tree24525db4be133c43d9de9ac602d3ee44aaaa36cd /linux-core/drm_ioctl.c
parent86e6325e5ab848c15c422f20133445fe6c1caa09 (diff)
- Introduce a new ioctl, DRM_IOCTL_SET_VERSION. This ioctl allows the
server or client to notify the DRM that it expects a certain version of the device dependent or device independent interface. If the major doesn't match or minor is too large, EINVAL is returned. A major of -1 means that the requestor doesn't care about that portion of the interface. The ioctl returns the actual versions in the same struct. - Introduce DRM DI interface version 1.1. If the server requests version 1.1, then the DRM sets the unique itself according to the busid of the device it probed, which may then be accessed as normal using getunique. - Request version 1.1 in libdrm's drmOpenByBusID, allowing the X Server to request based on a BusID. Introduce a wrapper for DRM_IOCTL_SET_VERSION and bump libdrm minor version. - Pass the busid in DRIScreenInit if libdrm can handle both a busid and name. This allows drmOpenByBusID to be used to find the DRM instead of just the driver name, which allows us in the future to tie a DRM more strongly to the device it probed to. Introduce a function DRICreatePCIBusID which creates a busid in the form pci:oooo:bb:dd.f similar to linux's pci_name() function. This matches the format used by the DRM in version 1.1. libdrm knows how to match both this format and the old PCI:b:d:f format. - Use the new DRICreatePCIBusID function in the *_dri.c to request the new, more exact busid format.
Diffstat (limited to 'linux-core/drm_ioctl.c')
-rw-r--r--linux-core/drm_ioctl.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c
index 8d98000f..ac54cae9 100644
--- a/linux-core/drm_ioctl.c
+++ b/linux-core/drm_ioctl.c
@@ -36,6 +36,7 @@
#define __NO_VERSION__
#include "drmP.h"
+#include "linux/pci.h"
/**
* Get interrupt from bus id.
@@ -140,7 +141,9 @@ int DRM(getunique)(struct inode *inode, struct file *filp,
* \return zero on success or a negative number on failure.
*
* Copies the bus id from userspace into drm_device::unique, and searches for
- * the respective PCI device, updating drm_device::pdev.
+ * the respective PCI device, updating drm_device::pdev. Deprecated in
+ * interface version 1.1 and will return EBUSY when setversion has requested
+ * version 1.1 or greater.
*/
int DRM(setunique)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
@@ -218,6 +221,36 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
return 0;
}
+static int
+DRM(set_busid)(drm_device_t *dev)
+{
+ if (dev->unique != NULL)
+ return EBUSY;
+
+ dev->unique_len = 20;
+ dev->unique = DRM(alloc)(dev->unique_len + 1, DRM_MEM_DRIVER);
+ if (dev->unique == NULL)
+ return ENOMEM;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74)
+ snprintf(dev->unique, dev->unique_len, "pci:%s", pci_name(dev->pdev));
+#else
+ {
+ int domain = 0;
+#ifdef __alpha__
+ struct pci_controller *hose = pci_dev->sysdata;
+
+ domain = hose->bus->number;
+#endif
+ snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
+ domain, dev->pdev->bus->number,
+ PCI_SLOT(dev->pdev->devfn), PCI_FUNC(dev->pdev->devfn));
+ }
+#endif
+
+ return 0;
+}
+
/**
* Get a mapping information.
@@ -364,3 +397,43 @@ int DRM(getstats)( struct inode *inode, struct file *filp,
return -EFAULT;
return 0;
}
+
+int DRM(setversion)(DRM_IOCTL_ARGS)
+{
+ DRM_DEVICE;
+ drm_set_version_t sv;
+ drm_set_version_t retv;
+
+ DRM_COPY_FROM_USER_IOCTL(sv, (drm_set_version_t *)data, sizeof(sv));
+
+ retv.drm_di_major = 1;
+ retv.drm_di_minor = 1;
+ retv.drm_dd_major = DRIVER_MAJOR;
+ retv.drm_dd_minor = DRIVER_MINOR;
+
+ DRM_COPY_TO_USER_IOCTL((drm_set_version_t *)data, retv, sizeof(sv));
+
+ if (sv.drm_di_major != -1) {
+ if (sv.drm_di_major != 1 || sv.drm_di_minor < 0)
+ return EINVAL;
+ if (sv.drm_di_minor > 1)
+ return EINVAL;
+ if (sv.drm_di_minor >= 1) {
+ /*
+ * Version 1.1 includes tying of DRM to specific device
+ */
+ DRM(set_busid)(dev);
+ }
+ }
+
+ if (sv.drm_dd_major != -1) {
+ if (sv.drm_dd_major != DRIVER_MAJOR || sv.drm_dd_minor < 0)
+ return EINVAL;
+ if (sv.drm_dd_minor > DRIVER_MINOR)
+ return EINVAL;
+#ifdef DRIVER_SETVERSION
+ DRIVER_SETVERSION(dev, sv);
+#endif
+ }
+ return 0;
+}