18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Internal Header for the Direct Rendering Manager 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 58c2ecf20Sopenharmony_ci * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 68c2ecf20Sopenharmony_ci * Copyright (c) 2009-2010, Code Aurora Forum. 78c2ecf20Sopenharmony_ci * All rights reserved. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Author: Rickard E. (Rik) Faith <faith@valinux.com> 108c2ecf20Sopenharmony_ci * Author: Gareth Hughes <gareth@valinux.com> 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 138c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 148c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 158c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 168c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 178c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 208c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 218c2ecf20Sopenharmony_ci * Software. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 248c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 258c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 268c2ecf20Sopenharmony_ci * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 278c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 288c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 298c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#ifndef _DRM_IOCTL_H_ 338c2ecf20Sopenharmony_ci#define _DRM_IOCTL_H_ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#include <linux/types.h> 368c2ecf20Sopenharmony_ci#include <linux/bitops.h> 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#include <asm/ioctl.h> 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct drm_device; 418c2ecf20Sopenharmony_cistruct drm_file; 428c2ecf20Sopenharmony_cistruct file; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/** 458c2ecf20Sopenharmony_ci * drm_ioctl_t - DRM ioctl function type. 468c2ecf20Sopenharmony_ci * @dev: DRM device inode 478c2ecf20Sopenharmony_ci * @data: private pointer of the ioctl call 488c2ecf20Sopenharmony_ci * @file_priv: DRM file this ioctl was made on 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * This is the DRM ioctl typedef. Note that drm_ioctl() has alrady copied @data 518c2ecf20Sopenharmony_ci * into kernel-space, and will also copy it back, depending upon the read/write 528c2ecf20Sopenharmony_ci * settings in the ioctl command code. 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_citypedef int drm_ioctl_t(struct drm_device *dev, void *data, 558c2ecf20Sopenharmony_ci struct drm_file *file_priv); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/** 588c2ecf20Sopenharmony_ci * drm_ioctl_compat_t - compatibility DRM ioctl function type. 598c2ecf20Sopenharmony_ci * @filp: file pointer 608c2ecf20Sopenharmony_ci * @cmd: ioctl command code 618c2ecf20Sopenharmony_ci * @arg: DRM file this ioctl was made on 628c2ecf20Sopenharmony_ci * 638c2ecf20Sopenharmony_ci * Just a typedef to make declaring an array of compatibility handlers easier. 648c2ecf20Sopenharmony_ci * New drivers shouldn't screw up the structure layout for their ioctl 658c2ecf20Sopenharmony_ci * structures and hence never need this. 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_citypedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, 688c2ecf20Sopenharmony_ci unsigned long arg); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define DRM_IOCTL_NR(n) _IOC_NR(n) 718c2ecf20Sopenharmony_ci#define DRM_IOCTL_TYPE(n) _IOC_TYPE(n) 728c2ecf20Sopenharmony_ci#define DRM_MAJOR 226 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/** 758c2ecf20Sopenharmony_ci * enum drm_ioctl_flags - DRM ioctl flags 768c2ecf20Sopenharmony_ci * 778c2ecf20Sopenharmony_ci * Various flags that can be set in &drm_ioctl_desc.flags to control how 788c2ecf20Sopenharmony_ci * userspace can use a given ioctl. 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_cienum drm_ioctl_flags { 818c2ecf20Sopenharmony_ci /** 828c2ecf20Sopenharmony_ci * @DRM_AUTH: 838c2ecf20Sopenharmony_ci * 848c2ecf20Sopenharmony_ci * This is for ioctl which are used for rendering, and require that the 858c2ecf20Sopenharmony_ci * file descriptor is either for a render node, or if it's a 868c2ecf20Sopenharmony_ci * legacy/primary node, then it must be authenticated. 878c2ecf20Sopenharmony_ci */ 888c2ecf20Sopenharmony_ci DRM_AUTH = BIT(0), 898c2ecf20Sopenharmony_ci /** 908c2ecf20Sopenharmony_ci * @DRM_MASTER: 918c2ecf20Sopenharmony_ci * 928c2ecf20Sopenharmony_ci * This must be set for any ioctl which can change the modeset or 938c2ecf20Sopenharmony_ci * display state. Userspace must call the ioctl through a primary node, 948c2ecf20Sopenharmony_ci * while it is the active master. 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * Note that read-only modeset ioctl can also be called by 978c2ecf20Sopenharmony_ci * unauthenticated clients, or when a master is not the currently active 988c2ecf20Sopenharmony_ci * one. 998c2ecf20Sopenharmony_ci */ 1008c2ecf20Sopenharmony_ci DRM_MASTER = BIT(1), 1018c2ecf20Sopenharmony_ci /** 1028c2ecf20Sopenharmony_ci * @DRM_ROOT_ONLY: 1038c2ecf20Sopenharmony_ci * 1048c2ecf20Sopenharmony_ci * Anything that could potentially wreak a master file descriptor needs 1058c2ecf20Sopenharmony_ci * to have this flag set. Current that's only for the SETMASTER and 1068c2ecf20Sopenharmony_ci * DROPMASTER ioctl, which e.g. logind can call to force a non-behaving 1078c2ecf20Sopenharmony_ci * master (display compositor) into compliance. 1088c2ecf20Sopenharmony_ci * 1098c2ecf20Sopenharmony_ci * This is equivalent to callers with the SYSADMIN capability. 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_ci DRM_ROOT_ONLY = BIT(2), 1128c2ecf20Sopenharmony_ci /** 1138c2ecf20Sopenharmony_ci * @DRM_UNLOCKED: 1148c2ecf20Sopenharmony_ci * 1158c2ecf20Sopenharmony_ci * Whether &drm_ioctl_desc.func should be called with the DRM BKL held 1168c2ecf20Sopenharmony_ci * or not. Enforced as the default for all modern drivers, hence there 1178c2ecf20Sopenharmony_ci * should never be a need to set this flag. 1188c2ecf20Sopenharmony_ci * 1198c2ecf20Sopenharmony_ci * Do not use anywhere else than for the VBLANK_WAIT IOCTL, which is the 1208c2ecf20Sopenharmony_ci * only legacy IOCTL which needs this. 1218c2ecf20Sopenharmony_ci */ 1228c2ecf20Sopenharmony_ci DRM_UNLOCKED = BIT(4), 1238c2ecf20Sopenharmony_ci /** 1248c2ecf20Sopenharmony_ci * @DRM_RENDER_ALLOW: 1258c2ecf20Sopenharmony_ci * 1268c2ecf20Sopenharmony_ci * This is used for all ioctl needed for rendering only, for drivers 1278c2ecf20Sopenharmony_ci * which support render nodes. This should be all new render drivers, 1288c2ecf20Sopenharmony_ci * and hence it should be always set for any ioctl with DRM_AUTH set. 1298c2ecf20Sopenharmony_ci * Note though that read-only query ioctl might have this set, but have 1308c2ecf20Sopenharmony_ci * not set DRM_AUTH because they do not require authentication. 1318c2ecf20Sopenharmony_ci */ 1328c2ecf20Sopenharmony_ci DRM_RENDER_ALLOW = BIT(5), 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/** 1368c2ecf20Sopenharmony_ci * struct drm_ioctl_desc - DRM driver ioctl entry 1378c2ecf20Sopenharmony_ci * @cmd: ioctl command number, without flags 1388c2ecf20Sopenharmony_ci * @flags: a bitmask of &enum drm_ioctl_flags 1398c2ecf20Sopenharmony_ci * @func: handler for this ioctl 1408c2ecf20Sopenharmony_ci * @name: user-readable name for debug output 1418c2ecf20Sopenharmony_ci * 1428c2ecf20Sopenharmony_ci * For convenience it's easier to create these using the DRM_IOCTL_DEF_DRV() 1438c2ecf20Sopenharmony_ci * macro. 1448c2ecf20Sopenharmony_ci */ 1458c2ecf20Sopenharmony_cistruct drm_ioctl_desc { 1468c2ecf20Sopenharmony_ci unsigned int cmd; 1478c2ecf20Sopenharmony_ci enum drm_ioctl_flags flags; 1488c2ecf20Sopenharmony_ci drm_ioctl_t *func; 1498c2ecf20Sopenharmony_ci const char *name; 1508c2ecf20Sopenharmony_ci}; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/** 1538c2ecf20Sopenharmony_ci * DRM_IOCTL_DEF_DRV() - helper macro to fill out a &struct drm_ioctl_desc 1548c2ecf20Sopenharmony_ci * @ioctl: ioctl command suffix 1558c2ecf20Sopenharmony_ci * @_func: handler for the ioctl 1568c2ecf20Sopenharmony_ci * @_flags: a bitmask of &enum drm_ioctl_flags 1578c2ecf20Sopenharmony_ci * 1588c2ecf20Sopenharmony_ci * Small helper macro to create a &struct drm_ioctl_desc entry. The ioctl 1598c2ecf20Sopenharmony_ci * command number is constructed by prepending ``DRM_IOCTL\_`` and passing that 1608c2ecf20Sopenharmony_ci * to DRM_IOCTL_NR(). 1618c2ecf20Sopenharmony_ci */ 1628c2ecf20Sopenharmony_ci#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ 1638c2ecf20Sopenharmony_ci [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \ 1648c2ecf20Sopenharmony_ci .cmd = DRM_IOCTL_##ioctl, \ 1658c2ecf20Sopenharmony_ci .func = _func, \ 1668c2ecf20Sopenharmony_ci .flags = _flags, \ 1678c2ecf20Sopenharmony_ci .name = #ioctl \ 1688c2ecf20Sopenharmony_ci } 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ciint drm_ioctl_permit(u32 flags, struct drm_file *file_priv); 1718c2ecf20Sopenharmony_cilong drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); 1728c2ecf20Sopenharmony_cilong drm_ioctl_kernel(struct file *, drm_ioctl_t, void *, u32); 1738c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT 1748c2ecf20Sopenharmony_cilong drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); 1758c2ecf20Sopenharmony_ci#else 1768c2ecf20Sopenharmony_ci/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */ 1778c2ecf20Sopenharmony_ci#define drm_compat_ioctl NULL 1788c2ecf20Sopenharmony_ci#endif 1798c2ecf20Sopenharmony_cibool drm_ioctl_flags(unsigned int nr, unsigned int *flags); 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ciint drm_noop(struct drm_device *dev, void *data, 1828c2ecf20Sopenharmony_ci struct drm_file *file_priv); 1838c2ecf20Sopenharmony_ciint drm_invalid_op(struct drm_device *dev, void *data, 1848c2ecf20Sopenharmony_ci struct drm_file *file_priv); 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci#endif /* _DRM_IOCTL_H_ */ 187