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/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <linux/poll.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 52 | #include <linux/ratelimit.h> |
| 53 | #include <linux/sched.h> |
| 54 | #include <linux/slab.h> |
| 55 | #include <linux/types.h> |
David Herrmann | d6db656 | 2014-08-29 12:12:35 +0200 | [diff] [blame] | 56 | #include <linux/vmalloc.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 57 | #include <linux/workqueue.h> |
Chris Wilson | f54d186 | 2016-10-25 13:00:45 +0100 | [diff] [blame] | 58 | #include <linux/dma-fence.h> |
Daniel Vetter | c6bb9ba | 2017-03-08 15:12:35 +0100 | [diff] [blame] | 59 | #include <linux/module.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 60 | |
| 61 | #include <asm/mman.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #include <asm/pgalloc.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 63 | #include <linux/uaccess.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 64 | |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 65 | #include <uapi/drm/drm.h> |
| 66 | #include <uapi/drm/drm_mode.h> |
| 67 | |
| 68 | #include <drm/drm_agpsupport.h> |
| 69 | #include <drm/drm_crtc.h> |
Laurent Pinchart | ae4df11 | 2016-06-09 12:54:08 +0300 | [diff] [blame] | 70 | #include <drm/drm_fourcc.h> |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 71 | #include <drm/drm_global.h> |
David Herrmann | 9699390 | 2014-08-29 12:12:37 +0200 | [diff] [blame] | 72 | #include <drm/drm_hashtab.h> |
| 73 | #include <drm/drm_mm.h> |
| 74 | #include <drm/drm_os_linux.h> |
David Howells | 19218e4 | 2012-10-02 18:01:03 +0100 | [diff] [blame] | 75 | #include <drm/drm_sarea.h> |
Daniel Vetter | 85e634b | 2016-11-14 12:58:19 +0100 | [diff] [blame] | 76 | #include <drm/drm_drv.h> |
Daniel Vetter | c6bb9ba | 2017-03-08 15:12:35 +0100 | [diff] [blame] | 77 | #include <drm/drm_prime.h> |
Haneen Mohammed | 02c9656 | 2017-10-17 22:30:07 -0600 | [diff] [blame] | 78 | #include <drm/drm_print.h> |
Daniel Vetter | 23ef59e | 2017-03-08 15:12:37 +0100 | [diff] [blame] | 79 | #include <drm/drm_pci.h> |
Daniel Vetter | a8f8b1d | 2017-03-08 15:12:42 +0100 | [diff] [blame] | 80 | #include <drm/drm_file.h> |
Daniel Vetter | 4834442 | 2017-03-22 21:53:36 +0100 | [diff] [blame] | 81 | #include <drm/drm_debugfs.h> |
Daniel Vetter | 7cfdf71 | 2017-03-22 21:54:47 +0100 | [diff] [blame] | 82 | #include <drm/drm_ioctl.h> |
Daniel Vetter | e227170 | 2017-04-04 11:52:55 +0200 | [diff] [blame] | 83 | #include <drm/drm_sysfs.h> |
Daniel Vetter | 3ed4351 | 2017-05-31 11:21:46 +0200 | [diff] [blame] | 84 | #include <drm/drm_vblank.h> |
| 85 | #include <drm/drm_irq.h> |
Daniel Vetter | e4672e5 | 2017-08-02 13:56:01 +0200 | [diff] [blame] | 86 | #include <drm/drm_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Paul Gortmaker | de47725 | 2011-05-26 13:46:22 -0400 | [diff] [blame] | 88 | struct module; |
| 89 | |
Steffen Trumtrar | edb37a9 | 2012-10-28 18:28:06 +0100 | [diff] [blame] | 90 | struct device_node; |
Steffen Trumtrar | ebc64e4 | 2012-11-14 11:22:52 +0100 | [diff] [blame] | 91 | struct videomode; |
Maarten Lankhorst | 3aac450 | 2014-07-01 12:57:26 +0200 | [diff] [blame] | 92 | struct reservation_object; |
Maarten Lankhorst | b5e9c1a | 2014-01-09 11:03:14 +0100 | [diff] [blame] | 93 | struct dma_buf_attachment; |
Steffen Trumtrar | ebc64e4 | 2012-11-14 11:22:52 +0100 | [diff] [blame] | 94 | |
Daniel Vetter | 23ef59e | 2017-03-08 15:12:37 +0100 | [diff] [blame] | 95 | struct pci_dev; |
| 96 | struct pci_controller; |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | /***********************************************************************/ |
| 99 | /** \name DRM template customization defaults */ |
| 100 | /*@{*/ |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | /***********************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | /** \name Internal types and structures */ |
| 104 | /*@{*/ |
| 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
Ben Gamari | 955b12d | 2009-02-17 20:08:49 -0500 | [diff] [blame] | 108 | /** |
Dhinakaran Pandiyan | a743d75 | 2016-12-22 00:50:42 -0800 | [diff] [blame] | 109 | * drm_drv_uses_atomic_modeset - check if the driver implements |
| 110 | * atomic_commit() |
| 111 | * @dev: DRM device |
| 112 | * |
| 113 | * This check is useful if drivers do not have DRIVER_ATOMIC set but |
| 114 | * have atomic modesetting internally implemented. |
| 115 | */ |
| 116 | static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) |
| 117 | { |
| 118 | return dev->mode_config.funcs->atomic_commit != NULL; |
| 119 | } |
| 120 | |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 121 | #define DRM_SWITCH_POWER_ON 0 |
| 122 | #define DRM_SWITCH_POWER_OFF 1 |
| 123 | #define DRM_SWITCH_POWER_CHANGING 2 |
Dave Airlie | 13bb9cc | 2012-09-12 15:55:05 +1000 | [diff] [blame] | 124 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 125 | |
Jani Nikula | d1a9d71 | 2018-03-27 23:47:20 +0300 | [diff] [blame^] | 126 | static inline int drm_core_check_feature(struct drm_device *dev, int feature) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | { |
| 128 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
| 129 | } |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | /******************************************************************/ |
| 132 | /** \name Internal function definitions */ |
| 133 | /*@{*/ |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | /* Driver support (drm_drv.h) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Thomas Hellstrom | 040ac32 | 2007-03-23 13:28:33 +1100 | [diff] [blame] | 137 | /* |
| 138 | * These are exported to drivers so that they can implement fencing using |
| 139 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. |
| 140 | */ |
| 141 | |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 142 | /*@}*/ |
| 143 | |
Dave Airlie | cc1f719 | 2012-01-05 09:55:22 +0000 | [diff] [blame] | 144 | /* returns true if currently okay to sleep */ |
Jani Nikula | d1a9d71 | 2018-03-27 23:47:20 +0300 | [diff] [blame^] | 145 | static inline bool drm_can_sleep(void) |
Dave Airlie | cc1f719 | 2012-01-05 09:55:22 +0000 | [diff] [blame] | 146 | { |
| 147 | if (in_atomic() || in_dbg_master() || irqs_disabled()) |
| 148 | return false; |
| 149 | return true; |
| 150 | } |
| 151 | |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 152 | /* helper for handling conditionals in various for_each macros */ |
| 153 | #define for_each_if(condition) if (!(condition)) {} else |
| 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | #endif |