Merge tag 'drm-misc-fixes-2018-02-21' of git://anongit.freedesktop.org/drm/drm-misc...
[sfrench/cifs-2.6.git] / include / drm / drmP.h
1 /*
2  * Internal Header for the Direct Rendering Manager
3  *
4  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6  * Copyright (c) 2009-2010, Code Aurora Forum.
7  * All rights reserved.
8  *
9  * Author: Rickard E. (Rik) Faith <faith@valinux.com>
10  * Author: Gareth Hughes <gareth@valinux.com>
11  *
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
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>
45 #include <linux/kernel.h>
46 #include <linux/kref.h>
47 #include <linux/miscdevice.h>
48 #include <linux/mm.h>
49 #include <linux/mutex.h>
50 #include <linux/platform_device.h>
51 #include <linux/poll.h>
52 #include <linux/ratelimit.h>
53 #include <linux/sched.h>
54 #include <linux/slab.h>
55 #include <linux/types.h>
56 #include <linux/vmalloc.h>
57 #include <linux/workqueue.h>
58 #include <linux/dma-fence.h>
59 #include <linux/module.h>
60
61 #include <asm/mman.h>
62 #include <asm/pgalloc.h>
63 #include <linux/uaccess.h>
64
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>
70 #include <drm/drm_fourcc.h>
71 #include <drm/drm_global.h>
72 #include <drm/drm_hashtab.h>
73 #include <drm/drm_mm.h>
74 #include <drm/drm_os_linux.h>
75 #include <drm/drm_sarea.h>
76 #include <drm/drm_drv.h>
77 #include <drm/drm_prime.h>
78 #include <drm/drm_print.h>
79 #include <drm/drm_pci.h>
80 #include <drm/drm_file.h>
81 #include <drm/drm_debugfs.h>
82 #include <drm/drm_ioctl.h>
83 #include <drm/drm_sysfs.h>
84 #include <drm/drm_vblank.h>
85 #include <drm/drm_irq.h>
86 #include <drm/drm_device.h>
87
88 struct module;
89
90 struct device_node;
91 struct videomode;
92 struct reservation_object;
93 struct dma_buf_attachment;
94
95 struct pci_dev;
96 struct pci_controller;
97
98 /***********************************************************************/
99 /** \name DRM template customization defaults */
100 /*@{*/
101
102 /***********************************************************************/
103 /** \name Internal types and structures */
104 /*@{*/
105
106 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
107
108 /**
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
121 #define DRM_SWITCH_POWER_ON 0
122 #define DRM_SWITCH_POWER_OFF 1
123 #define DRM_SWITCH_POWER_CHANGING 2
124 #define DRM_SWITCH_POWER_DYNAMIC_OFF 3
125
126 static __inline__ int drm_core_check_feature(struct drm_device *dev,
127                                              int feature)
128 {
129         return ((dev->driver->driver_features & feature) ? 1 : 0);
130 }
131
132 /******************************************************************/
133 /** \name Internal function definitions */
134 /*@{*/
135
136                                 /* Driver support (drm_drv.h) */
137
138 /*
139  * These are exported to drivers so that they can implement fencing using
140  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
141  */
142
143 /*@}*/
144
145 /* returns true if currently okay to sleep */
146 static __inline__ bool drm_can_sleep(void)
147 {
148         if (in_atomic() || in_dbg_master() || irqs_disabled())
149                 return false;
150         return true;
151 }
152
153 /* helper for handling conditionals in various for_each macros */
154 #define for_each_if(condition) if (!(condition)) {} else
155
156 #endif