diff options
Diffstat (limited to 'bsd')
-rw-r--r-- | bsd/drm.h | 8 | ||||
-rw-r--r-- | bsd/drmP.h | 5 | ||||
-rw-r--r-- | bsd/drm_drv.h | 1 | ||||
-rw-r--r-- | bsd/drm_ioctl.h | 70 |
4 files changed, 81 insertions, 3 deletions
@@ -405,6 +405,13 @@ typedef struct drm_scatter_gather { unsigned long handle; /* Used for mapping / unmapping */ } drm_scatter_gather_t; +typedef struct drm_set_version { + int drm_di_major; + int drm_di_minor; + int drm_dd_major; + int drm_dd_minor; +} drm_set_version_t; + #define DRM_IOCTL_BASE 'd' #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) #define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type) @@ -418,6 +425,7 @@ typedef struct drm_scatter_gather { #define DRM_IOCTL_GET_MAP DRM_IOWR(0x04, drm_map_t) #define DRM_IOCTL_GET_CLIENT DRM_IOWR(0x05, drm_client_t) #define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, drm_stats_t) +#define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, drm_set_version_t) #define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t) #define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t) @@ -390,9 +390,6 @@ struct drm_device { extern int DRM(flags); - /* Driver support (drm_drv.h) */ -extern int DRM(version)( DRM_IOCTL_ARGS ); - /* Memory management support (drm_memory.h) */ extern void DRM(mem_init)(void); extern void DRM(mem_uninit)(void); @@ -491,6 +488,8 @@ extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev, /* Locking IOCTL support (drm_drv.h) */ extern int DRM(lock)(DRM_IOCTL_ARGS); extern int DRM(unlock)(DRM_IOCTL_ARGS); +extern int DRM(version)( DRM_IOCTL_ARGS ); +extern int DRM(setversion)( DRM_IOCTL_ARGS ); /* Misc. IOCTL support (drm_ioctl.h) */ extern int DRM(irq_busid)(DRM_IOCTL_ARGS); diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h index 582a4112..3f494694 100644 --- a/bsd/drm_drv.h +++ b/bsd/drm_drv.h @@ -135,6 +135,7 @@ static drm_ioctl_desc_t DRM(ioctls)[] = { [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { DRM(setversion), 0, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 }, diff --git a/bsd/drm_ioctl.h b/bsd/drm_ioctl.h index a195d0c4..50cf937d 100644 --- a/bsd/drm_ioctl.h +++ b/bsd/drm_ioctl.h @@ -79,6 +79,12 @@ int DRM(irq_busid)( DRM_IOCTL_ARGS ) #endif } +/* + * Beginning in revision 1.1 of the DRM interface, getunique will return + * a unique in the form pci:oooo:bb:dd.f (o=domain, b=bus, d=device, f=function) + * before setunique has been called. The format for the bus-specific part of + * the unique is not defined for any other bus. + */ int DRM(getunique)( DRM_IOCTL_ARGS ) { DRM_DEVICE; @@ -97,6 +103,9 @@ int DRM(getunique)( DRM_IOCTL_ARGS ) return 0; } +/* Deprecated in DRM version 1.1, and will return EBUSY when setversion has + * requested version 1.1 or greater. + */ int DRM(setunique)( DRM_IOCTL_ARGS ) { DRM_DEVICE; @@ -125,6 +134,26 @@ int DRM(setunique)( DRM_IOCTL_ARGS ) } +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; + + /* XXX Fix domain number (alpha hoses) */ + snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%1x", + 0, pci_get_bus(dev->device), pci_get_slot(dev->device), + pci_get_function(dev->device)); + + return 0; +} + int DRM(getmap)( DRM_IOCTL_ARGS ) { DRM_DEVICE; @@ -231,6 +260,47 @@ int DRM(getstats)( DRM_IOCTL_ARGS ) 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; +} + + int DRM(noop)(DRM_IOCTL_ARGS) { DRM_DEBUG("\n"); |