^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Internal Header for the Direct Rendering Manager
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 2009-2010, Code Aurora Forum.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Author: Rickard E. (Rik) Faith <faith@valinux.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Author: Gareth Hughes <gareth@valinux.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * The above copyright notice and this permission notice (including the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * paragraph) shall be included in all copies or substantial portions of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #ifndef _DRM_IOCTL_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define _DRM_IOCTL_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <asm/ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct drm_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct drm_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * drm_ioctl_t - DRM ioctl function type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @dev: DRM device inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @data: private pointer of the ioctl call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @file_priv: DRM file this ioctl was made on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * This is the DRM ioctl typedef. Note that drm_ioctl() has alrady copied @data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * into kernel-space, and will also copy it back, depending upon the read/write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * settings in the ioctl command code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) typedef int drm_ioctl_t(struct drm_device *dev, void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct drm_file *file_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * drm_ioctl_compat_t - compatibility DRM ioctl function type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @filp: file pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @cmd: ioctl command code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * @arg: DRM file this ioctl was made on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * Just a typedef to make declaring an array of compatibility handlers easier.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * New drivers shouldn't screw up the structure layout for their ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * structures and hence never need this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define DRM_IOCTL_NR(n) _IOC_NR(n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define DRM_IOCTL_TYPE(n) _IOC_TYPE(n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define DRM_MAJOR 226
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * enum drm_ioctl_flags - DRM ioctl flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * Various flags that can be set in &drm_ioctl_desc.flags to control how
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * userspace can use a given ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) enum drm_ioctl_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * @DRM_AUTH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * This is for ioctl which are used for rendering, and require that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * file descriptor is either for a render node, or if it's a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * legacy/primary node, then it must be authenticated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) DRM_AUTH = BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @DRM_MASTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * This must be set for any ioctl which can change the modeset or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * display state. Userspace must call the ioctl through a primary node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * while it is the active master.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * Note that read-only modeset ioctl can also be called by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * unauthenticated clients, or when a master is not the currently active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) DRM_MASTER = BIT(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @DRM_ROOT_ONLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * Anything that could potentially wreak a master file descriptor needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * to have this flag set. Current that's only for the SETMASTER and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * DROPMASTER ioctl, which e.g. logind can call to force a non-behaving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * master (display compositor) into compliance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * This is equivalent to callers with the SYSADMIN capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) DRM_ROOT_ONLY = BIT(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * @DRM_UNLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * Whether &drm_ioctl_desc.func should be called with the DRM BKL held
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * or not. Enforced as the default for all modern drivers, hence there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * should never be a need to set this flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * Do not use anywhere else than for the VBLANK_WAIT IOCTL, which is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * only legacy IOCTL which needs this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) DRM_UNLOCKED = BIT(4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * @DRM_RENDER_ALLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * This is used for all ioctl needed for rendering only, for drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * which support render nodes. This should be all new render drivers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * and hence it should be always set for any ioctl with DRM_AUTH set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * Note though that read-only query ioctl might have this set, but have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * not set DRM_AUTH because they do not require authentication.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) DRM_RENDER_ALLOW = BIT(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * struct drm_ioctl_desc - DRM driver ioctl entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * @cmd: ioctl command number, without flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * @flags: a bitmask of &enum drm_ioctl_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * @func: handler for this ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * @name: user-readable name for debug output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * For convenience it's easier to create these using the DRM_IOCTL_DEF_DRV()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * macro.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct drm_ioctl_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) unsigned int cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) enum drm_ioctl_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) drm_ioctl_t *func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * DRM_IOCTL_DEF_DRV() - helper macro to fill out a &struct drm_ioctl_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * @ioctl: ioctl command suffix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * @_func: handler for the ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * @_flags: a bitmask of &enum drm_ioctl_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * Small helper macro to create a &struct drm_ioctl_desc entry. The ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * command number is constructed by prepending ``DRM_IOCTL\_`` and passing that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * to DRM_IOCTL_NR().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) .cmd = DRM_IOCTL_##ioctl, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) .func = _func, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) .flags = _flags, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) .name = #ioctl \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) long drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) long drm_ioctl_kernel(struct file *, drm_ioctl_t, void *, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define drm_compat_ioctl NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int drm_noop(struct drm_device *dev, void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct drm_file *file_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int drm_invalid_op(struct drm_device *dev, void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct drm_file *file_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #endif /* _DRM_IOCTL_H_ */