Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 2 | * Internal Header for the Direct Rendering Manager |
| 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
| 5 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
Jordan Crouse | dcdb167 | 2010-05-27 13:40:25 -0600 | [diff] [blame] | 6 | * Copyright (c) 2009-2010, Code Aurora Forum. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * All rights reserved. |
| 8 | * |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 9 | * Author: Rickard E. (Rik) Faith <faith@valinux.com> |
| 10 | * Author: Gareth Hughes <gareth@valinux.com> |
| 11 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 13 | * copy of this software and associated documentation files (the "Software"), |
| 14 | * to deal in the Software without restriction, including without limitation |
| 15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 16 | * and/or sell copies of the Software, and to permit persons to whom the |
| 17 | * Software is furnished to do so, subject to the following conditions: |
| 18 | * |
| 19 | * The above copyright notice and this permission notice (including the next |
| 20 | * paragraph) shall be included in all copies or substantial portions of the |
| 21 | * Software. |
| 22 | * |
| 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 26 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 27 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 28 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 29 | * OTHER DEALINGS IN THE SOFTWARE. |
| 30 | */ |
| 31 | |
| 32 | #ifndef _DRM_P_H_ |
| 33 | #define _DRM_P_H_ |
| 34 | |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 35 | #include <linux/agp_backend.h> |
| 36 | #include <linux/cdev.h> |
| 37 | #include <linux/dma-mapping.h> |
| 38 | #include <linux/file.h> |
| 39 | #include <linux/fs.h> |
| 40 | #include <linux/highmem.h> |
| 41 | #include <linux/idr.h> |
| 42 | #include <linux/init.h> |
| 43 | #include <linux/io.h> |
| 44 | #include <linux/jiffies.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <linux/kernel.h> |
David Herrmann | 099d1c2 | 2014-01-29 10:21:36 +0100 | [diff] [blame] | 46 | #include <linux/kref.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <linux/miscdevice.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include <linux/mm.h> |
Dave Airlie | 30e2fb1 | 2006-02-02 19:37:46 +1100 | [diff] [blame] | 49 | #include <linux/mutex.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 50 | #include <linux/pci.h> |
| 51 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include <linux/poll.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 53 | #include <linux/ratelimit.h> |
Chris Wilson | 077675c | 2016-09-26 21:44:14 +0100 | [diff] [blame] | 54 | #include <linux/rbtree.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 55 | #include <linux/sched.h> |
| 56 | #include <linux/slab.h> |
| 57 | #include <linux/types.h> |
David Herrmann | d6db656 | 2014-08-29 12:12:35 +0200 | [diff] [blame] | 58 | #include <linux/vmalloc.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 59 | #include <linux/workqueue.h> |
Chris Wilson | f54d186 | 2016-10-25 13:00:45 +0100 | [diff] [blame] | 60 | #include <linux/dma-fence.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 61 | |
| 62 | #include <asm/mman.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #include <asm/pgalloc.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 64 | #include <linux/uaccess.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 65 | |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 66 | #include <uapi/drm/drm.h> |
| 67 | #include <uapi/drm/drm_mode.h> |
| 68 | |
| 69 | #include <drm/drm_agpsupport.h> |
| 70 | #include <drm/drm_crtc.h> |
Laurent Pinchart | ae4df11 | 2016-06-09 12:54:08 +0300 | [diff] [blame] | 71 | #include <drm/drm_fourcc.h> |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 72 | #include <drm/drm_global.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 73 | #include <drm/drm_hashtab.h> |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 74 | #include <drm/drm_mem_util.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 75 | #include <drm/drm_mm.h> |
| 76 | #include <drm/drm_os_linux.h> |
David Howells | 19218e4 | 2012-10-02 18:01:03 +0100 | [diff] [blame] | 77 | #include <drm/drm_sarea.h> |
David Herrmann | 0de2397 | 2013-07-24 21:07:52 +0200 | [diff] [blame] | 78 | #include <drm/drm_vma_manager.h> |
Daniel Vetter | 85e634b | 2016-11-14 12:58:19 +0100 | [diff] [blame] | 79 | #include <drm/drm_drv.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Paul Gortmaker | de47725 | 2011-05-26 13:46:22 -0400 | [diff] [blame] | 81 | struct module; |
| 82 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 83 | struct drm_file; |
| 84 | struct drm_device; |
David Herrmann | cc5ea59 | 2014-08-29 12:12:32 +0200 | [diff] [blame] | 85 | struct drm_agp_head; |
Daniel Vetter | ba8286f | 2014-09-11 07:43:25 +0200 | [diff] [blame] | 86 | struct drm_local_map; |
| 87 | struct drm_device_dma; |
| 88 | struct drm_dma_handle; |
Daniel Vetter | d9fc941 | 2014-09-23 15:46:53 +0200 | [diff] [blame] | 89 | struct drm_gem_object; |
Daniel Vetter | 3b96a0b | 2016-06-21 10:54:22 +0200 | [diff] [blame] | 90 | struct drm_master; |
Daniel Vetter | 34a67dd | 2016-07-15 21:48:01 +0200 | [diff] [blame] | 91 | struct drm_vblank_crtc; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 92 | |
Steffen Trumtrar | edb37a9 | 2012-10-28 18:28:06 +0100 | [diff] [blame] | 93 | struct device_node; |
Steffen Trumtrar | ebc64e4 | 2012-11-14 11:22:52 +0100 | [diff] [blame] | 94 | struct videomode; |
Maarten Lankhorst | 3aac450 | 2014-07-01 12:57:26 +0200 | [diff] [blame] | 95 | struct reservation_object; |
Maarten Lankhorst | b5e9c1a | 2014-01-09 11:03:14 +0100 | [diff] [blame] | 96 | struct dma_buf_attachment; |
Steffen Trumtrar | ebc64e4 | 2012-11-14 11:22:52 +0100 | [diff] [blame] | 97 | |
Lespiau, Damien | 1414b76 | 2014-03-24 15:53:08 +0000 | [diff] [blame] | 98 | /* |
Robert Foss | 346fea6 | 2016-04-14 10:34:16 -0400 | [diff] [blame] | 99 | * The following categories are defined: |
Lespiau, Damien | 1414b76 | 2014-03-24 15:53:08 +0000 | [diff] [blame] | 100 | * |
| 101 | * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... |
| 102 | * This is the category used by the DRM_DEBUG() macro. |
| 103 | * |
| 104 | * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... |
| 105 | * This is the category used by the DRM_DEBUG_DRIVER() macro. |
| 106 | * |
| 107 | * KMS: used in the modesetting code. |
| 108 | * This is the category used by the DRM_DEBUG_KMS() macro. |
| 109 | * |
| 110 | * PRIME: used in the prime code. |
| 111 | * This is the category used by the DRM_DEBUG_PRIME() macro. |
| 112 | * |
Daniel Vetter | 17a38d9 | 2015-02-22 12:24:16 +0100 | [diff] [blame] | 113 | * ATOMIC: used in the atomic code. |
| 114 | * This is the category used by the DRM_DEBUG_ATOMIC() macro. |
| 115 | * |
Ville Syrjälä | 235fabe | 2015-10-09 22:57:37 +0300 | [diff] [blame] | 116 | * VBL: used for verbose debug message in the vblank code |
| 117 | * This is the category used by the DRM_DEBUG_VBL() macro. |
| 118 | * |
Lespiau, Damien | 1414b76 | 2014-03-24 15:53:08 +0000 | [diff] [blame] | 119 | * Enabling verbose debug messages is done through the drm.debug parameter, |
| 120 | * each category being enabled by a bit. |
| 121 | * |
| 122 | * drm.debug=0x1 will enable CORE messages |
| 123 | * drm.debug=0x2 will enable DRIVER messages |
| 124 | * drm.debug=0x3 will enable CORE and DRIVER messages |
| 125 | * ... |
Ville Syrjälä | 235fabe | 2015-10-09 22:57:37 +0300 | [diff] [blame] | 126 | * drm.debug=0x3f will enable all messages |
Lespiau, Damien | 1414b76 | 2014-03-24 15:53:08 +0000 | [diff] [blame] | 127 | * |
| 128 | * An interesting feature is that it's possible to enable verbose logging at |
| 129 | * run-time by echoing the debug value in its sysfs node: |
| 130 | * # echo 0xf > /sys/module/drm/parameters/debug |
| 131 | */ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 132 | #define DRM_UT_NONE 0x00 |
yakui_zhao | 4fefcb2 | 2009-06-02 14:09:47 +0800 | [diff] [blame] | 133 | #define DRM_UT_CORE 0x01 |
| 134 | #define DRM_UT_DRIVER 0x02 |
| 135 | #define DRM_UT_KMS 0x04 |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 136 | #define DRM_UT_PRIME 0x08 |
Daniel Vetter | 17a38d9 | 2015-02-22 12:24:16 +0100 | [diff] [blame] | 137 | #define DRM_UT_ATOMIC 0x10 |
Ville Syrjälä | 235fabe | 2015-10-09 22:57:37 +0300 | [diff] [blame] | 138 | #define DRM_UT_VBL 0x20 |
Rob Clark | fceffb32 | 2016-11-05 11:08:09 -0400 | [diff] [blame] | 139 | #define DRM_UT_STATE 0x40 |
yakui_zhao | 4fefcb2 | 2009-06-02 14:09:47 +0800 | [diff] [blame] | 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | /***********************************************************************/ |
| 142 | /** \name DRM template customization defaults */ |
| 143 | /*@{*/ |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | /***********************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | /** \name Macros to make printk easier */ |
| 147 | /*@{*/ |
| 148 | |
Dave Gordon | 30b0da8 | 2016-08-18 18:17:22 +0100 | [diff] [blame] | 149 | #define _DRM_PRINTK(once, level, fmt, ...) \ |
| 150 | do { \ |
| 151 | printk##once(KERN_##level "[" DRM_NAME "] " fmt, \ |
| 152 | ##__VA_ARGS__); \ |
| 153 | } while (0) |
| 154 | |
| 155 | #define DRM_INFO(fmt, ...) \ |
| 156 | _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__) |
| 157 | #define DRM_NOTE(fmt, ...) \ |
| 158 | _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__) |
| 159 | #define DRM_WARN(fmt, ...) \ |
| 160 | _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__) |
| 161 | |
| 162 | #define DRM_INFO_ONCE(fmt, ...) \ |
| 163 | _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__) |
| 164 | #define DRM_NOTE_ONCE(fmt, ...) \ |
| 165 | _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__) |
| 166 | #define DRM_WARN_ONCE(fmt, ...) \ |
| 167 | _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__) |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | /** |
| 170 | * Error output. |
| 171 | * |
| 172 | * \param fmt printf() like format string. |
| 173 | * \param arg arguments |
| 174 | */ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 175 | #define DRM_DEV_ERROR(dev, fmt, ...) \ |
| 176 | drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\ |
| 177 | fmt, ##__VA_ARGS__) |
| 178 | #define DRM_ERROR(fmt, ...) \ |
Joe Perches | 6bd488d | 2016-09-25 19:18:34 -0700 | [diff] [blame] | 179 | drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Rob Clark | 5d13d42 | 2013-11-21 14:29:51 -0500 | [diff] [blame] | 181 | /** |
| 182 | * Rate limited error output. Like DRM_ERROR() but won't flood the log. |
| 183 | * |
| 184 | * \param fmt printf() like format string. |
| 185 | * \param arg arguments |
| 186 | */ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 187 | #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \ |
Rob Clark | 5d13d42 | 2013-11-21 14:29:51 -0500 | [diff] [blame] | 188 | ({ \ |
| 189 | static DEFINE_RATELIMIT_STATE(_rs, \ |
| 190 | DEFAULT_RATELIMIT_INTERVAL, \ |
| 191 | DEFAULT_RATELIMIT_BURST); \ |
| 192 | \ |
| 193 | if (__ratelimit(&_rs)) \ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 194 | DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \ |
Rob Clark | 5d13d42 | 2013-11-21 14:29:51 -0500 | [diff] [blame] | 195 | }) |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 196 | #define DRM_ERROR_RATELIMITED(fmt, ...) \ |
| 197 | DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) |
Rob Clark | 5d13d42 | 2013-11-21 14:29:51 -0500 | [diff] [blame] | 198 | |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 199 | #define DRM_DEV_INFO(dev, fmt, ...) \ |
| 200 | drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \ |
| 201 | ##__VA_ARGS__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 203 | #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ |
| 204 | ({ \ |
| 205 | static bool __print_once __read_mostly; \ |
| 206 | if (!__print_once) { \ |
| 207 | __print_once = true; \ |
| 208 | DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ |
| 209 | } \ |
| 210 | }) |
Jani Nikula | 48b8f63 | 2014-01-31 15:49:07 +0200 | [diff] [blame] | 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | /** |
| 213 | * Debug output. |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 214 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | * \param fmt printf() like format string. |
| 216 | * \param arg arguments |
| 217 | */ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 218 | #define DRM_DEV_DEBUG(dev, fmt, args...) \ |
| 219 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \ |
| 220 | ##args) |
Joe Perches | 6bd488d | 2016-09-25 19:18:34 -0700 | [diff] [blame] | 221 | #define DRM_DEBUG(fmt, ...) \ |
| 222 | drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__) |
yakui_zhao | 4fefcb2 | 2009-06-02 14:09:47 +0800 | [diff] [blame] | 223 | |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 224 | #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \ |
| 225 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \ |
| 226 | fmt, ##args) |
Joe Perches | 6bd488d | 2016-09-25 19:18:34 -0700 | [diff] [blame] | 227 | #define DRM_DEBUG_DRIVER(fmt, ...) \ |
| 228 | drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 230 | #define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \ |
| 231 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \ |
| 232 | ##args) |
Joe Perches | 6bd488d | 2016-09-25 19:18:34 -0700 | [diff] [blame] | 233 | #define DRM_DEBUG_KMS(fmt, ...) \ |
| 234 | drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__) |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 235 | |
| 236 | #define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \ |
| 237 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \ |
| 238 | fmt, ##args) |
Joe Perches | 6bd488d | 2016-09-25 19:18:34 -0700 | [diff] [blame] | 239 | #define DRM_DEBUG_PRIME(fmt, ...) \ |
| 240 | drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__) |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 241 | |
| 242 | #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \ |
| 243 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \ |
| 244 | fmt, ##args) |
Joe Perches | 6bd488d | 2016-09-25 19:18:34 -0700 | [diff] [blame] | 245 | #define DRM_DEBUG_ATOMIC(fmt, ...) \ |
| 246 | drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 247 | |
| 248 | #define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \ |
| 249 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \ |
| 250 | ##args) |
Joe Perches | 6bd488d | 2016-09-25 19:18:34 -0700 | [diff] [blame] | 251 | #define DRM_DEBUG_VBL(fmt, ...) \ |
| 252 | drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__) |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 253 | |
| 254 | #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ |
| 255 | ({ \ |
| 256 | static DEFINE_RATELIMIT_STATE(_rs, \ |
| 257 | DEFAULT_RATELIMIT_INTERVAL, \ |
| 258 | DEFAULT_RATELIMIT_BURST); \ |
| 259 | if (__ratelimit(&_rs)) \ |
| 260 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \ |
| 261 | __func__, "", fmt, ##args); \ |
| 262 | }) |
Lyude | 27528c6 | 2016-08-05 20:30:38 -0400 | [diff] [blame] | 263 | |
| 264 | /** |
| 265 | * Rate limited debug output. Like DRM_DEBUG() but won't flood the log. |
| 266 | * |
| 267 | * \param fmt printf() like format string. |
| 268 | * \param arg arguments |
| 269 | */ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 270 | #define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \ |
| 271 | DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args) |
Lyude | 27528c6 | 2016-08-05 20:30:38 -0400 | [diff] [blame] | 272 | #define DRM_DEBUG_RATELIMITED(fmt, args...) \ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 273 | DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args) |
| 274 | #define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \ |
| 275 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args) |
Lyude | 27528c6 | 2016-08-05 20:30:38 -0400 | [diff] [blame] | 276 | #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 277 | DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args) |
| 278 | #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \ |
| 279 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args) |
Lyude | 27528c6 | 2016-08-05 20:30:38 -0400 | [diff] [blame] | 280 | #define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 281 | DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args) |
| 282 | #define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \ |
| 283 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args) |
Lyude | 27528c6 | 2016-08-05 20:30:38 -0400 | [diff] [blame] | 284 | #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \ |
Sean Paul | c4e68a5 | 2016-08-15 16:18:04 -0700 | [diff] [blame] | 285 | DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args) |
Lyude | 27528c6 | 2016-08-05 20:30:38 -0400 | [diff] [blame] | 286 | |
Rob Clark | 65c7dc1 | 2016-11-05 11:08:06 -0400 | [diff] [blame] | 287 | /* Format strings and argument splitters to simplify printing |
| 288 | * various "complex" objects |
| 289 | */ |
| 290 | #define DRM_MODE_FMT "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x" |
| 291 | #define DRM_MODE_ARG(m) \ |
| 292 | (m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \ |
| 293 | (m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \ |
| 294 | (m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \ |
| 295 | (m)->type, (m)->flags |
| 296 | |
| 297 | #define DRM_RECT_FMT "%dx%d%+d%+d" |
| 298 | #define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1 |
| 299 | |
| 300 | /* for rect's in fixed-point format: */ |
| 301 | #define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u" |
| 302 | #define DRM_RECT_FP_ARG(r) \ |
| 303 | drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \ |
| 304 | drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \ |
| 305 | (r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \ |
| 306 | (r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10 |
| 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | /*@}*/ |
| 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | /***********************************************************************/ |
| 311 | /** \name Internal types and structures */ |
| 312 | /*@{*/ |
| 313 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
| 316 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | * Ioctl function type. |
| 318 | * |
| 319 | * \param inode device inode. |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 320 | * \param file_priv DRM file private pointer. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | * \param cmd command. |
| 322 | * \param arg argument. |
| 323 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 324 | typedef int drm_ioctl_t(struct drm_device *dev, void *data, |
| 325 | struct drm_file *file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Dave Airlie | 9a18664 | 2005-06-23 21:29:18 +1000 | [diff] [blame] | 327 | typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, |
| 328 | unsigned long arg); |
| 329 | |
Kristian Høgsberg | 1a95916 | 2009-12-02 12:13:48 -0500 | [diff] [blame] | 330 | #define DRM_IOCTL_NR(n) _IOC_NR(n) |
| 331 | #define DRM_MAJOR 226 |
| 332 | |
Dave Airlie | a7a2cc3 | 2006-01-02 13:54:04 +1100 | [diff] [blame] | 333 | #define DRM_AUTH 0x1 |
| 334 | #define DRM_MASTER 0x2 |
| 335 | #define DRM_ROOT_ONLY 0x4 |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 336 | #define DRM_CONTROL_ALLOW 0x8 |
Arnd Bergmann | ed8b670 | 2009-12-16 22:17:09 +0000 | [diff] [blame] | 337 | #define DRM_UNLOCKED 0x10 |
David Herrmann | 1793126 | 2013-08-25 18:29:00 +0200 | [diff] [blame] | 338 | #define DRM_RENDER_ALLOW 0x20 |
Dave Airlie | a7a2cc3 | 2006-01-02 13:54:04 +1100 | [diff] [blame] | 339 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 340 | struct drm_ioctl_desc { |
| 341 | unsigned int cmd; |
Dave Airlie | a7a2cc3 | 2006-01-02 13:54:04 +1100 | [diff] [blame] | 342 | int flags; |
Richard Kennedy | c972d75 | 2009-03-18 17:26:44 +0000 | [diff] [blame] | 343 | drm_ioctl_t *func; |
Chris Cummins | b9434d0 | 2013-05-09 14:20:40 +0100 | [diff] [blame] | 344 | const char *name; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 345 | }; |
| 346 | |
| 347 | /** |
| 348 | * Creates a driver or general drm_ioctl_desc array entry for the given |
| 349 | * ioctl, for use by drm_ioctl(). |
| 350 | */ |
Dave Airlie | 1b2f148 | 2010-08-14 20:20:34 +1000 | [diff] [blame] | 351 | |
Emil Velikov | 066626d | 2015-03-30 17:10:36 +0000 | [diff] [blame] | 352 | #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ |
| 353 | [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \ |
| 354 | .cmd = DRM_IOCTL_##ioctl, \ |
| 355 | .func = _func, \ |
| 356 | .flags = _flags, \ |
| 357 | .name = #ioctl \ |
| 358 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 360 | /* Event queued up for userspace to read */ |
| 361 | struct drm_pending_event { |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 362 | struct completion *completion; |
Daniel Vetter | 24835e4 | 2016-12-21 11:23:30 +0100 | [diff] [blame] | 363 | void (*completion_release)(struct completion *completion); |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 364 | struct drm_event *event; |
Chris Wilson | f54d186 | 2016-10-25 13:00:45 +0100 | [diff] [blame] | 365 | struct dma_fence *fence; |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 366 | struct list_head link; |
Daniel Vetter | 681047b | 2016-01-25 22:16:43 +0100 | [diff] [blame] | 367 | struct list_head pending_link; |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 368 | struct drm_file *file_priv; |
Jesse Barnes | b9c2c9a | 2010-07-01 16:48:09 -0700 | [diff] [blame] | 369 | pid_t pid; /* pid of requester, no guarantee it's valid by the time |
| 370 | we deliver the event, for tracing only */ |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 371 | }; |
| 372 | |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 373 | struct drm_prime_file_private { |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 374 | struct mutex lock; |
Chris Wilson | 077675c | 2016-09-26 21:44:14 +0100 | [diff] [blame] | 375 | struct rb_root dmabufs; |
| 376 | struct rb_root handles; |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 377 | }; |
| 378 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | /** File private data */ |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 380 | struct drm_file { |
Chris Wilson | 39868bd | 2013-10-29 08:55:58 +0000 | [diff] [blame] | 381 | unsigned authenticated :1; |
Chris Wilson | 39868bd | 2013-10-29 08:55:58 +0000 | [diff] [blame] | 382 | /* true when the client has asked us to expose stereo 3D mode flags */ |
| 383 | unsigned stereo_allowed :1; |
Matt Roper | 681e7ec | 2014-04-01 15:22:42 -0700 | [diff] [blame] | 384 | /* |
| 385 | * true if client understands CRTC primary planes and cursor planes |
| 386 | * in the plane list |
| 387 | */ |
| 388 | unsigned universal_planes:1; |
Rob Clark | 88a48e2 | 2014-12-18 16:01:50 -0500 | [diff] [blame] | 389 | /* true if client understands atomic properties */ |
| 390 | unsigned atomic:1; |
Thomas Hellstrom | a0af2e5 | 2015-12-02 09:24:46 -0800 | [diff] [blame] | 391 | /* |
Daniel Vetter | 0aae592 | 2016-06-21 10:54:21 +0200 | [diff] [blame] | 392 | * This client is the creator of @master. |
Thomas Hellstrom | a0af2e5 | 2015-12-02 09:24:46 -0800 | [diff] [blame] | 393 | * Protected by struct drm_device::master_mutex. |
| 394 | */ |
Daniel Vetter | 0aae592 | 2016-06-21 10:54:21 +0200 | [diff] [blame] | 395 | unsigned is_master:1; |
Chris Wilson | 39868bd | 2013-10-29 08:55:58 +0000 | [diff] [blame] | 396 | |
Eric W. Biederman | 5fce5e0 | 2012-02-07 16:47:26 -0800 | [diff] [blame] | 397 | struct pid *pid; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 398 | drm_magic_t magic; |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 399 | struct list_head lhead; |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 400 | struct drm_minor *minor; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 401 | unsigned long lock_count; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 402 | |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 403 | /** Mapping of mm object handles to object pointers. */ |
| 404 | struct idr object_idr; |
| 405 | /** Lock for synchronization of access to object_idr. */ |
| 406 | spinlock_t table_lock; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 407 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 408 | struct file *filp; |
Dave Airlie | 8562b3f | 2007-11-05 12:37:41 +1000 | [diff] [blame] | 409 | void *driver_priv; |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 410 | |
Dave Airlie | 7c1c287 | 2008-11-28 14:22:24 +1000 | [diff] [blame] | 411 | struct drm_master *master; /* master this node is currently associated with |
Daniel Vetter | 95c081c | 2016-06-21 10:54:12 +0200 | [diff] [blame] | 412 | N.B. not always dev->master */ |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 413 | /** |
| 414 | * fbs - List of framebuffers associated with this file. |
| 415 | * |
| 416 | * Protected by fbs_lock. Note that the fbs list holds a reference on |
| 417 | * the fb object to prevent it from untimely disappearing. |
| 418 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 419 | struct list_head fbs; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 420 | struct mutex fbs_lock; |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 421 | |
Daniel Stone | e2f5d2e | 2015-05-22 13:34:51 +0100 | [diff] [blame] | 422 | /** User-created blob properties; this retains a reference on the |
| 423 | * property. */ |
| 424 | struct list_head blobs; |
| 425 | |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 426 | wait_queue_head_t event_wait; |
Daniel Vetter | 681047b | 2016-01-25 22:16:43 +0100 | [diff] [blame] | 427 | struct list_head pending_event_list; |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 428 | struct list_head event_list; |
| 429 | int event_space; |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 430 | |
Chris Wilson | 9b2c0b7 | 2015-11-25 14:39:03 +0000 | [diff] [blame] | 431 | struct mutex event_read_lock; |
| 432 | |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 433 | struct drm_prime_file_private prime; |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 434 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | /** |
| 437 | * Lock data. |
| 438 | */ |
Dave Airlie | 5591051 | 2007-07-11 16:53:40 +1000 | [diff] [blame] | 439 | struct drm_lock_data { |
Dave Airlie | c60ce62 | 2007-07-11 15:27:12 +1000 | [diff] [blame] | 440 | struct drm_hw_lock *hw_lock; /**< Hardware lock */ |
Dave Airlie | 8562b3f | 2007-11-05 12:37:41 +1000 | [diff] [blame] | 441 | /** Private of lock holder's file (NULL=kernel) */ |
| 442 | struct drm_file *file_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 444 | unsigned long lock_time; /**< Time of last lock in jiffies */ |
Thomas Hellstrom | 040ac32 | 2007-03-23 13:28:33 +1100 | [diff] [blame] | 445 | spinlock_t spinlock; |
| 446 | uint32_t kernel_waiters; |
| 447 | uint32_t user_waiters; |
| 448 | int idle_has_lock; |
Dave Airlie | 5591051 | 2007-07-11 16:53:40 +1000 | [diff] [blame] | 449 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 451 | /* Flags and return codes for get_vblank_timestamp() driver function. */ |
| 452 | #define DRM_CALLED_FROM_VBLIRQ 1 |
| 453 | #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
Daniel Vetter | 3d3cbd8 | 2014-09-10 17:36:11 +0200 | [diff] [blame] | 454 | #define DRM_VBLANKTIME_IN_VBLANK (1 << 1) |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 455 | |
| 456 | /* get_scanout_position() return flags */ |
| 457 | #define DRM_SCANOUTPOS_VALID (1 << 0) |
Daniel Vetter | 3d3cbd8 | 2014-09-10 17:36:11 +0200 | [diff] [blame] | 458 | #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1) |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 459 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
| 460 | |
David Herrmann | cb8a239 | 2014-01-29 12:31:40 +0100 | [diff] [blame] | 461 | enum drm_minor_type { |
David Herrmann | a3ccc46 | 2016-08-03 20:04:25 +0200 | [diff] [blame] | 462 | DRM_MINOR_PRIMARY, |
David Herrmann | cb8a239 | 2014-01-29 12:31:40 +0100 | [diff] [blame] | 463 | DRM_MINOR_CONTROL, |
| 464 | DRM_MINOR_RENDER, |
| 465 | DRM_MINOR_CNT, |
| 466 | }; |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 467 | |
Ben Gamari | 955b12d | 2009-02-17 20:08:49 -0500 | [diff] [blame] | 468 | /** |
| 469 | * Info file list entry. This structure represents a debugfs or proc file to |
| 470 | * be created by the drm core |
| 471 | */ |
| 472 | struct drm_info_list { |
| 473 | const char *name; /** file name */ |
| 474 | int (*show)(struct seq_file*, void*); /** show callback */ |
| 475 | u32 driver_features; /**< Required driver features for this entry */ |
| 476 | void *data; |
| 477 | }; |
| 478 | |
| 479 | /** |
| 480 | * debugfs node structure. This structure represents a debugfs file. |
| 481 | */ |
| 482 | struct drm_info_node { |
| 483 | struct list_head list; |
| 484 | struct drm_minor *minor; |
David Howells | ce089b5 | 2013-04-12 15:23:25 +0100 | [diff] [blame] | 485 | const struct drm_info_list *info_ent; |
Ben Gamari | 955b12d | 2009-02-17 20:08:49 -0500 | [diff] [blame] | 486 | struct dentry *dent; |
| 487 | }; |
| 488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | /** |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 490 | * DRM minor structure. This structure represents a drm minor number. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | */ |
Dave Airlie | 2c14f28 | 2008-04-21 16:47:32 +1000 | [diff] [blame] | 492 | struct drm_minor { |
| 493 | int index; /**< Minor device number */ |
| 494 | int type; /**< Control or render */ |
Dave Airlie | 5bdebb1 | 2013-10-11 14:07:25 +1000 | [diff] [blame] | 495 | struct device *kdev; /**< Linux device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | struct drm_device *dev; |
Ben Gamari | 955b12d | 2009-02-17 20:08:49 -0500 | [diff] [blame] | 497 | |
Ben Gamari | 955b12d | 2009-02-17 20:08:49 -0500 | [diff] [blame] | 498 | struct dentry *debugfs_root; |
Marcin Slusarz | b3e067c | 2011-11-09 22:20:35 +0100 | [diff] [blame] | 499 | |
| 500 | struct list_head debugfs_list; |
| 501 | struct mutex debugfs_lock; /* Protects debugfs_list. */ |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 502 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | |
| 504 | /** |
| 505 | * DRM device structure. This structure represent a complete card that |
| 506 | * may contain multiple heads. |
| 507 | */ |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 508 | struct drm_device { |
Daniel Vetter | b3f2333 | 2013-12-11 11:34:31 +0100 | [diff] [blame] | 509 | struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 510 | int if_version; /**< Highest interface version set */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | |
David Herrmann | 45e212d | 2014-01-28 16:00:35 +0100 | [diff] [blame] | 512 | /** \name Lifetime Management */ |
| 513 | /*@{ */ |
David Herrmann | 099d1c2 | 2014-01-29 10:21:36 +0100 | [diff] [blame] | 514 | struct kref ref; /**< Object ref-count */ |
David Herrmann | 45e212d | 2014-01-28 16:00:35 +0100 | [diff] [blame] | 515 | struct device *dev; /**< Device structure of bus-device */ |
| 516 | struct drm_driver *driver; /**< DRM driver managing the device */ |
| 517 | void *dev_private; /**< DRM driver private data */ |
David Herrmann | 45e212d | 2014-01-28 16:00:35 +0100 | [diff] [blame] | 518 | struct drm_minor *control; /**< Control node */ |
| 519 | struct drm_minor *primary; /**< Primary node */ |
| 520 | struct drm_minor *render; /**< Render node */ |
Daniel Vetter | e6e7b48 | 2017-01-12 17:15:56 +0100 | [diff] [blame] | 521 | bool registered; |
Daniel Vetter | 95c081c | 2016-06-21 10:54:12 +0200 | [diff] [blame] | 522 | |
| 523 | /* currently active master for this device. Protected by master_mutex */ |
| 524 | struct drm_master *master; |
| 525 | |
David Herrmann | 45e212d | 2014-01-28 16:00:35 +0100 | [diff] [blame] | 526 | atomic_t unplugged; /**< Flag whether dev is dead */ |
David Herrmann | 07b48c3 | 2014-03-16 13:13:51 +0100 | [diff] [blame] | 527 | struct inode *anon_inode; /**< inode for private address-space */ |
Thierry Reding | ca8e2ad | 2014-04-11 15:23:00 +0200 | [diff] [blame] | 528 | char *unique; /**< unique name of the device */ |
David Herrmann | 45e212d | 2014-01-28 16:00:35 +0100 | [diff] [blame] | 529 | /*@} */ |
| 530 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | /** \name Locks */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 532 | /*@{ */ |
Dave Airlie | 30e2fb1 | 2006-02-02 19:37:46 +1100 | [diff] [blame] | 533 | struct mutex struct_mutex; /**< For others */ |
Thomas Hellstrom | c996fd0 | 2014-02-25 19:57:44 +0100 | [diff] [blame] | 534 | struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 535 | /*@} */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | |
| 537 | /** \name Usage Counters */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 538 | /*@{ */ |
Daniel Vetter | fc8fd40 | 2013-11-03 20:46:34 +0100 | [diff] [blame] | 539 | int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ |
Daniel Vetter | 2177a21 | 2013-12-16 11:21:06 +0100 | [diff] [blame] | 540 | spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 541 | int buf_use; /**< Buffers in use -- cannot alloc */ |
| 542 | atomic_t buf_alloc; /**< Buffer allocation in progress */ |
| 543 | /*@} */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | |
Daniel Vetter | 1d2ac40 | 2016-04-26 19:29:41 +0200 | [diff] [blame] | 545 | struct mutex filelist_mutex; |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 546 | struct list_head filelist; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | |
| 548 | /** \name Memory management */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 549 | /*@{ */ |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 550 | struct list_head maplist; /**< Linked list of regions */ |
Dave Airlie | e0be428 | 2007-07-12 10:26:44 +1000 | [diff] [blame] | 551 | struct drm_open_hash map_hash; /**< User token hash table for maps */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
| 553 | /** \name Context handle management */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 554 | /*@{ */ |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 555 | struct list_head ctxlist; /**< Linked list of context handles */ |
Dave Airlie | 30e2fb1 | 2006-02-02 19:37:46 +1100 | [diff] [blame] | 556 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
Dave Airlie | 6296814 | 2007-07-17 10:46:52 +1000 | [diff] [blame] | 558 | struct idr ctx_idr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
Dave Airlie | bd1b331 | 2007-05-26 05:01:51 +1000 | [diff] [blame] | 560 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 561 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 562 | /*@} */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
Daniel Vetter | a344a7e | 2011-10-26 00:54:41 +0200 | [diff] [blame] | 564 | /** \name DMA support */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 565 | /*@{ */ |
Dave Airlie | cdd55a2 | 2007-07-11 16:32:08 +1000 | [diff] [blame] | 566 | struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 567 | /*@} */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | |
| 569 | /** \name Context support */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 570 | /*@{ */ |
Daniel Vetter | 7c1a38e | 2013-12-16 11:21:15 +0100 | [diff] [blame] | 571 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | __volatile__ long context_flag; /**< Context swapping flag */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 573 | int last_context; /**< Last current context */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 574 | /*@} */ |
| 575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | /** \name VBLANK IRQ support */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 577 | /*@{ */ |
Thierry Reding | b46004b | 2014-12-17 16:41:41 +0100 | [diff] [blame] | 578 | bool irq_enabled; |
| 579 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 581 | /* |
Ville Syrjälä | 00185e6 | 2014-08-06 14:49:54 +0300 | [diff] [blame] | 582 | * If true, vblank interrupt will be disabled immediately when the |
| 583 | * refcount drops to zero, as opposed to via the vblank disable |
| 584 | * timer. |
| 585 | * This can be set to true it the hardware has a working vblank |
| 586 | * counter and the driver uses drm_vblank_on() and drm_vblank_off() |
| 587 | * appropriately. |
| 588 | */ |
| 589 | bool vblank_disable_immediate; |
| 590 | |
Ville Syrjälä | 5380e92 | 2013-10-04 14:53:36 +0300 | [diff] [blame] | 591 | /* array of size num_crtcs */ |
| 592 | struct drm_vblank_crtc *vblank; |
| 593 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 594 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 595 | spinlock_t vbl_lock; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 596 | |
| 597 | u32 max_vblank_count; /**< size of vblank counter register */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
Kristian Høgsberg | c9a9c5e | 2009-09-12 04:33:34 +1000 | [diff] [blame] | 599 | /** |
| 600 | * List of events |
| 601 | */ |
| 602 | struct list_head vblank_event_list; |
| 603 | spinlock_t event_lock; |
| 604 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 605 | /*@} */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
Dave Airlie | 5591051 | 2007-07-11 16:53:40 +1000 | [diff] [blame] | 607 | struct drm_agp_head *agp; /**< AGP data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 609 | struct pci_dev *pdev; /**< PCI device structure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | #ifdef __alpha__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | struct pci_controller *hose; |
| 612 | #endif |
Jordan Crouse | dcdb167 | 2010-05-27 13:40:25 -0600 | [diff] [blame] | 613 | |
| 614 | struct platform_device *platformdev; /**< Platform device struture */ |
Dave Airlie | dc5698e | 2013-09-09 10:02:56 +1000 | [diff] [blame] | 615 | struct virtio_device *virtdev; |
Jordan Crouse | dcdb167 | 2010-05-27 13:40:25 -0600 | [diff] [blame] | 616 | |
Dave Airlie | 5591051 | 2007-07-11 16:53:40 +1000 | [diff] [blame] | 617 | struct drm_sg_mem *sg; /**< Scatter gather memory */ |
Dave Airlie | 1922756 | 2011-02-24 08:35:06 +1000 | [diff] [blame] | 618 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
David Herrmann | 69d516c | 2014-08-29 12:12:39 +0200 | [diff] [blame] | 620 | struct { |
| 621 | int context; |
| 622 | struct drm_hw_lock *lock; |
| 623 | } sigdata; |
| 624 | |
Benjamin Herrenschmidt | f77d390 | 2009-02-02 16:55:46 +1100 | [diff] [blame] | 625 | struct drm_local_map *agp_buffer_map; |
Dave Airlie | d1f2b55 | 2005-08-05 22:11:22 +1000 | [diff] [blame] | 626 | unsigned int agp_buffer_token; |
=?utf-8?q?Michel_D=C3=A4nzer?= | bea5679 | 2006-10-24 23:04:19 +1000 | [diff] [blame] | 627 | |
Rob Clark | 417009fb | 2014-11-25 20:33:10 -0500 | [diff] [blame] | 628 | struct drm_mode_config mode_config; /**< Current mode config */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 629 | |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 630 | /** \name GEM information */ |
| 631 | /*@{ */ |
Daniel Vetter | cd4f013 | 2013-08-15 00:02:44 +0200 | [diff] [blame] | 632 | struct mutex object_name_lock; |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 633 | struct idr object_name_idr; |
Daniel Vetter | b04a590 | 2013-12-11 14:24:46 +0100 | [diff] [blame] | 634 | struct drm_vma_offset_manager *vma_offset_manager; |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 635 | /*@} */ |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 636 | int switch_power_state; |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 637 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
Dhinakaran Pandiyan | a743d75 | 2016-12-22 00:50:42 -0800 | [diff] [blame] | 639 | /** |
| 640 | * drm_drv_uses_atomic_modeset - check if the driver implements |
| 641 | * atomic_commit() |
| 642 | * @dev: DRM device |
| 643 | * |
| 644 | * This check is useful if drivers do not have DRIVER_ATOMIC set but |
| 645 | * have atomic modesetting internally implemented. |
| 646 | */ |
| 647 | static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) |
| 648 | { |
| 649 | return dev->mode_config.funcs->atomic_commit != NULL; |
| 650 | } |
| 651 | |
Daniel Vetter | 34a67dd | 2016-07-15 21:48:01 +0200 | [diff] [blame] | 652 | #include <drm/drm_irq.h> |
| 653 | |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 654 | #define DRM_SWITCH_POWER_ON 0 |
| 655 | #define DRM_SWITCH_POWER_OFF 1 |
| 656 | #define DRM_SWITCH_POWER_CHANGING 2 |
Dave Airlie | 13bb9cc | 2012-09-12 15:55:05 +1000 | [diff] [blame] | 657 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 658 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 659 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
| 660 | int feature) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | { |
| 662 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
| 663 | } |
| 664 | |
Dave Airlie | 2c07a21 | 2012-02-20 14:18:07 +0000 | [diff] [blame] | 665 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
| 666 | { |
| 667 | smp_wmb(); |
| 668 | atomic_set(&dev->unplugged, 1); |
| 669 | } |
| 670 | |
| 671 | static inline int drm_device_is_unplugged(struct drm_device *dev) |
| 672 | { |
| 673 | int ret = atomic_read(&dev->unplugged); |
| 674 | smp_rmb(); |
| 675 | return ret; |
| 676 | } |
| 677 | |
Thomas Hellstrom | 4368305 | 2014-03-13 11:07:44 +0100 | [diff] [blame] | 678 | static inline bool drm_is_render_client(const struct drm_file *file_priv) |
David Herrmann | 1793126 | 2013-08-25 18:29:00 +0200 | [diff] [blame] | 679 | { |
| 680 | return file_priv->minor->type == DRM_MINOR_RENDER; |
| 681 | } |
| 682 | |
Thomas Hellstrom | ac05dbc | 2014-02-19 14:21:48 +0100 | [diff] [blame] | 683 | static inline bool drm_is_control_client(const struct drm_file *file_priv) |
| 684 | { |
| 685 | return file_priv->minor->type == DRM_MINOR_CONTROL; |
| 686 | } |
| 687 | |
Thomas Hellstrom | 4368305 | 2014-03-13 11:07:44 +0100 | [diff] [blame] | 688 | static inline bool drm_is_primary_client(const struct drm_file *file_priv) |
| 689 | { |
David Herrmann | a3ccc46 | 2016-08-03 20:04:25 +0200 | [diff] [blame] | 690 | return file_priv->minor->type == DRM_MINOR_PRIMARY; |
Thomas Hellstrom | 4368305 | 2014-03-13 11:07:44 +0100 | [diff] [blame] | 691 | } |
| 692 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | /******************************************************************/ |
| 694 | /** \name Internal function definitions */ |
| 695 | /*@{*/ |
| 696 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | /* Driver support (drm_drv.h) */ |
Thomas Hellstrom | 5101020 | 2015-07-10 22:31:08 -0700 | [diff] [blame] | 698 | extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv); |
Arnd Bergmann | ed8b670 | 2009-12-16 22:17:09 +0000 | [diff] [blame] | 699 | extern long drm_ioctl(struct file *filp, |
| 700 | unsigned int cmd, unsigned long arg); |
Jani Nikula | 55edf41 | 2016-11-01 17:40:44 +0200 | [diff] [blame] | 701 | #ifdef CONFIG_COMPAT |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 702 | extern long drm_compat_ioctl(struct file *filp, |
| 703 | unsigned int cmd, unsigned long arg); |
Jani Nikula | 55edf41 | 2016-11-01 17:40:44 +0200 | [diff] [blame] | 704 | #else |
| 705 | /* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */ |
| 706 | #define drm_compat_ioctl NULL |
| 707 | #endif |
Thomas Hellstrom | 4beb6d9 | 2014-02-26 15:51:57 +0100 | [diff] [blame] | 708 | extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Daniel Vetter | bcb877e | 2016-01-11 22:40:55 +0100 | [diff] [blame] | 710 | /* File Operations (drm_fops.c) */ |
| 711 | int drm_open(struct inode *inode, struct file *filp); |
| 712 | ssize_t drm_read(struct file *filp, char __user *buffer, |
| 713 | size_t count, loff_t *offset); |
| 714 | int drm_release(struct inode *inode, struct file *filp); |
Daniel Vetter | bcb877e | 2016-01-11 22:40:55 +0100 | [diff] [blame] | 715 | unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
Daniel Vetter | 4020b22 | 2016-01-28 12:01:04 +0100 | [diff] [blame] | 716 | int drm_event_reserve_init_locked(struct drm_device *dev, |
| 717 | struct drm_file *file_priv, |
| 718 | struct drm_pending_event *p, |
| 719 | struct drm_event *e); |
Daniel Vetter | 2dd500f | 2016-01-11 22:40:56 +0100 | [diff] [blame] | 720 | int drm_event_reserve_init(struct drm_device *dev, |
| 721 | struct drm_file *file_priv, |
| 722 | struct drm_pending_event *p, |
| 723 | struct drm_event *e); |
| 724 | void drm_event_cancel_free(struct drm_device *dev, |
| 725 | struct drm_pending_event *p); |
Daniel Vetter | fb740cf | 2016-01-11 22:40:59 +0100 | [diff] [blame] | 726 | void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e); |
| 727 | void drm_send_event(struct drm_device *dev, struct drm_pending_event *e); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | |
Daniel Vetter | 7823875 | 2014-09-10 12:43:55 +0200 | [diff] [blame] | 729 | /* Misc. IOCTL support (drm_ioctl.c) */ |
| 730 | int drm_noop(struct drm_device *dev, void *data, |
| 731 | struct drm_file *file_priv); |
Daniel Vetter | 4b63539 | 2015-09-08 13:56:26 +0200 | [diff] [blame] | 732 | int drm_invalid_op(struct drm_device *dev, void *data, |
| 733 | struct drm_file *file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | |
Thomas Hellstrom | 040ac32 | 2007-03-23 13:28:33 +1100 | [diff] [blame] | 735 | /* |
| 736 | * These are exported to drivers so that they can implement fencing using |
| 737 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
| 738 | */ |
| 739 | |
Ben Gamari | 955b12d | 2009-02-17 20:08:49 -0500 | [diff] [blame] | 740 | /* Debugfs support */ |
| 741 | #if defined(CONFIG_DEBUG_FS) |
Lespiau, Damien | 7d74795 | 2013-10-17 19:09:53 +0100 | [diff] [blame] | 742 | extern int drm_debugfs_create_files(const struct drm_info_list *files, |
| 743 | int count, struct dentry *root, |
| 744 | struct drm_minor *minor); |
| 745 | extern int drm_debugfs_remove_files(const struct drm_info_list *files, |
| 746 | int count, struct drm_minor *minor); |
Thierry Reding | 66ee52e | 2013-12-12 15:44:04 +0100 | [diff] [blame] | 747 | #else |
Thierry Reding | 66ee52e | 2013-12-12 15:44:04 +0100 | [diff] [blame] | 748 | static inline int drm_debugfs_create_files(const struct drm_info_list *files, |
| 749 | int count, struct dentry *root, |
| 750 | struct drm_minor *minor) |
| 751 | { |
| 752 | return 0; |
| 753 | } |
| 754 | |
| 755 | static inline int drm_debugfs_remove_files(const struct drm_info_list *files, |
| 756 | int count, struct drm_minor *minor) |
| 757 | { |
| 758 | return 0; |
| 759 | } |
Ben Gamari | 955b12d | 2009-02-17 20:08:49 -0500 | [diff] [blame] | 760 | #endif |
| 761 | |
Chris Wilson | a4fce9c | 2016-10-05 13:21:44 +0100 | [diff] [blame] | 762 | struct dma_buf_export_info; |
| 763 | |
Aaron Plattner | 8917764 | 2013-01-15 20:47:42 +0000 | [diff] [blame] | 764 | extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, |
Chris Wilson | 56a76c0 | 2016-10-05 13:21:43 +0100 | [diff] [blame] | 765 | struct drm_gem_object *obj, |
| 766 | int flags); |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 767 | extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, |
| 768 | struct drm_file *file_priv, uint32_t handle, uint32_t flags, |
| 769 | int *prime_fd); |
Aaron Plattner | 8917764 | 2013-01-15 20:47:42 +0000 | [diff] [blame] | 770 | extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, |
| 771 | struct dma_buf *dma_buf); |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 772 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, |
| 773 | struct drm_file *file_priv, int prime_fd, uint32_t *handle); |
Chris Wilson | a4fce9c | 2016-10-05 13:21:44 +0100 | [diff] [blame] | 774 | struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, |
| 775 | struct dma_buf_export_info *exp_info); |
Daniel Vetter | c1d6798 | 2013-08-15 00:02:30 +0200 | [diff] [blame] | 776 | extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 777 | |
Dave Airlie | 51ab7ba | 2012-05-18 15:40:33 +0100 | [diff] [blame] | 778 | extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, |
| 779 | dma_addr_t *addrs, int max_pages); |
Thierry Reding | 34eab43 | 2014-06-04 09:18:29 +0200 | [diff] [blame] | 780 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages); |
Dave Airlie | 3248877 | 2011-11-25 15:21:02 +0000 | [diff] [blame] | 781 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); |
| 782 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | |
Daniel Vetter | ba8286f | 2014-09-11 07:43:25 +0200 | [diff] [blame] | 784 | extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, |
| 785 | size_t align); |
| 786 | extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | |
| 788 | /* sysfs support (drm_sysfs.c) */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 789 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 791 | |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 792 | /*@}*/ |
| 793 | |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 794 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); |
| 795 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); |
Thierry Reding | a9e3c90 | 2014-08-05 13:37:47 +0200 | [diff] [blame] | 796 | #ifdef CONFIG_PCI |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 797 | extern int drm_get_pci_dev(struct pci_dev *pdev, |
Jordan Crouse | dcdb167 | 2010-05-27 13:40:25 -0600 | [diff] [blame] | 798 | const struct pci_device_id *ent, |
| 799 | struct drm_driver *driver); |
David Herrmann | 915b4d1 | 2014-08-29 12:12:43 +0200 | [diff] [blame] | 800 | extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master); |
Thierry Reding | a9e3c90 | 2014-08-05 13:37:47 +0200 | [diff] [blame] | 801 | #else |
| 802 | static inline int drm_get_pci_dev(struct pci_dev *pdev, |
| 803 | const struct pci_device_id *ent, |
| 804 | struct drm_driver *driver) |
| 805 | { |
| 806 | return -ENOSYS; |
| 807 | } |
| 808 | |
| 809 | static inline int drm_pci_set_busid(struct drm_device *dev, |
| 810 | struct drm_master *master) |
| 811 | { |
| 812 | return -ENOSYS; |
| 813 | } |
| 814 | #endif |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 815 | |
Dave Airlie | f429778 | 2012-06-27 08:35:53 +0100 | [diff] [blame] | 816 | #define DRM_PCIE_SPEED_25 1 |
| 817 | #define DRM_PCIE_SPEED_50 2 |
| 818 | #define DRM_PCIE_SPEED_80 4 |
| 819 | |
| 820 | extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); |
Alex Deucher | 60d8edd | 2015-11-11 23:14:39 -0500 | [diff] [blame] | 821 | extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw); |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 822 | |
| 823 | /* platform section */ |
| 824 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 825 | |
Dave Airlie | cc1f719 | 2012-01-05 09:55:22 +0000 | [diff] [blame] | 826 | /* returns true if currently okay to sleep */ |
| 827 | static __inline__ bool drm_can_sleep(void) |
| 828 | { |
| 829 | if (in_atomic() || in_dbg_master() || irqs_disabled()) |
| 830 | return false; |
| 831 | return true; |
| 832 | } |
| 833 | |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 834 | /* helper for handling conditionals in various for_each macros */ |
| 835 | #define for_each_if(condition) if (!(condition)) {} else |
| 836 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | #endif |