summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdrm/xf86drm.c17
-rw-r--r--libdrm/xf86drm.h3
-rw-r--r--linux-core/drmP.h4
-rw-r--r--linux-core/drm_drv.c3
-rw-r--r--linux-core/drm_stub.c23
-rw-r--r--shared-core/drm.h3
6 files changed, 53 insertions, 0 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index bcf562d5..53275f52 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2977,3 +2977,20 @@ void drmCloseOnce(int fd)
}
}
}
+
+int drmSetMaster(int fd)
+{
+ int ret;
+
+ fprintf(stderr,"Setting master \n");
+ ret = ioctl(fd, DRM_IOCTL_SET_MASTER, 0);
+ return ret;
+}
+
+int drmDropMaster(int fd)
+{
+ int ret;
+ fprintf(stderr,"Dropping master \n");
+ ret = ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
+ return ret;
+}
diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h
index 7b418604..35780aca 100644
--- a/libdrm/xf86drm.h
+++ b/libdrm/xf86drm.h
@@ -660,6 +660,9 @@ extern int drmSLLookupNeighbors(void *l, unsigned long key,
extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
extern void drmCloseOnce(int fd);
+extern int drmSetMaster(int fd);
+extern int drmDropMaster(int fd);
+
#include "xf86mm.h"
#endif
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 8273c879..c2c3cdde 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -1266,6 +1266,10 @@ extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
extern struct drm_ttm_backend *drm_agp_init_ttm(struct drm_device *dev);
extern void drm_agp_chipset_flush(struct drm_device *dev);
/* Stub support (drm_stub.h) */
+extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
extern struct drm_master *drm_get_master(struct drm_minor *minor);
extern void drm_put_master(struct drm_master *master);
extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 09372c71..649d4cae 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -76,6 +76,9 @@ static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, DRM_ROOT_ONLY),
+
DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c
index 6856075b..f66dec07 100644
--- a/linux-core/drm_stub.c
+++ b/linux-core/drm_stub.c
@@ -88,6 +88,29 @@ again:
return new_id;
}
+int drm_setmaster_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ if (file_priv->minor->master && file_priv->minor->master != file_priv->master)
+ return -EINVAL;
+
+ if (!file_priv->master)
+ return -EINVAL;
+
+ if (!file_priv->minor->master && file_priv->minor->master != file_priv->master)
+ file_priv->minor->master = file_priv->master;
+ return 0;
+}
+
+int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ if (!file_priv->master)
+ return -EINVAL;
+ file_priv->minor->master = NULL;
+ return 0;
+}
+
struct drm_master *drm_get_master(struct drm_minor *minor)
{
struct drm_master *master;
diff --git a/shared-core/drm.h b/shared-core/drm.h
index a1ebfb93..a72263ae 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -1200,6 +1200,9 @@ struct drm_mode_hotplug {
#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, struct drm_ctx_priv_map)
#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, struct drm_ctx_priv_map)
+#define DRM_IOCTL_SET_MASTER DRM_IO(0x1e)
+#define DRM_IOCTL_DROP_MASTER DRM_IO(0x1f)
+
#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, struct drm_ctx)
#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, struct drm_ctx)
#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, struct drm_ctx)