| 1 | |
| 2 | * Copyright © 2014 Intel Corporation
|
| 3 | * Daniel Vetter <[email protected]>
|
| 4 | *
|
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a
|
| 6 | * copy of this software and associated documentation files (the "Software"),
|
| 7 | * to deal in the Software without restriction, including without limitation
|
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
| 9 | * and/or sell copies of the Software, and to permit persons to whom the
|
| 10 | * Software is furnished to do so, subject to the following conditions:
|
| 11 | *
|
| 12 | * The above copyright notice and this permission notice shall be included in
|
| 13 | * all copies or substantial portions of the Software.
|
| 14 | *
|
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
| 18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
| 19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 21 | * OTHER DEALINGS IN THE SOFTWARE.
|
| 22 |
|
| 23 |
|
| 24 | #ifndef __DRM_INTERNAL_H__
|
| 25 | #define __DRM_INTERNAL_H__
|
| 26 |
|
| 27 | #include <linux/kthread.h>
|
| 28 | #include <linux/types.h>
|
| 29 |
|
| 30 | #include <drm/drm_ioctl.h>
|
| 31 | #include <drm/drm_vblank.h>
|
| 32 |
|
| 33 | #define DRM_IF_MAJOR 1
|
| 34 | #define DRM_IF_MINOR 4
|
| 35 |
|
| 36 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
|
| 37 |
|
| 38 | struct dentry;
|
| 39 | struct dma_buf;
|
| 40 | struct iosys_map;
|
| 41 | struct drm_connector;
|
| 42 | struct drm_crtc;
|
| 43 | struct drm_framebuffer;
|
| 44 | struct drm_gem_object;
|
| 45 | struct drm_master;
|
| 46 | struct drm_minor;
|
| 47 | struct drm_prime_file_private;
|
| 48 | struct drm_printer;
|
| 49 | struct drm_vblank_crtc;
|
| 50 |
|
| 51 |
|
| 52 | #if defined(CONFIG_DRM_CLIENT)
|
| 53 | void drm_client_debugfs_init(struct drm_device *dev);
|
| 54 | #else
|
| 55 | static inline void drm_client_debugfs_init(struct drm_device *dev)
|
| 56 | { }
|
| 57 | #endif
|
| 58 |
|
| 59 |
|
| 60 | #if defined(CONFIG_DRM_CLIENT) && defined(CONFIG_MAGIC_SYSRQ)
|
| 61 | void drm_client_sysrq_register(struct drm_device *dev);
|
| 62 | void drm_client_sysrq_unregister(struct drm_device *dev);
|
| 63 | #else
|
| 64 | static inline void drm_client_sysrq_register(struct drm_device *dev)
|
| 65 | { }
|
| 66 | static inline void drm_client_sysrq_unregister(struct drm_device *dev)
|
| 67 | { }
|
| 68 | #endif
|
| 69 |
|
| 70 |
|
| 71 | extern struct mutex drm_global_mutex;
|
| 72 | bool drm_dev_needs_global_mutex(struct drm_device *dev);
|
| 73 | struct drm_file *drm_file_alloc(struct drm_minor *minor);
|
| 74 | void drm_file_free(struct drm_file *file);
|
| 75 |
|
| 76 | #ifdef CONFIG_PCI
|
| 77 |
|
| 78 |
|
| 79 | int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
|
| 80 |
|
| 81 | #else
|
| 82 |
|
| 83 | static inline int drm_pci_set_busid(struct drm_device *dev,
|
| 84 | struct drm_master *master)
|
| 85 | {
|
| 86 | return -EINVAL;
|
| 87 | }
|
| 88 |
|
| 89 | #endif
|
| 90 |
|
| 91 |
|
| 92 | int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
|
| 93 | struct drm_file *file_priv);
|
| 94 | int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
|
| 95 | struct drm_file *file_priv);
|
| 96 |
|
| 97 | void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
|
| 98 | void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
|
| 99 | int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
|
| 100 | struct dma_buf *dma_buf, uint32_t handle);
|
| 101 | void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
|
| 102 | uint32_t handle);
|
| 103 |
|
| 104 |
|
| 105 | void drm_managed_release(struct drm_device *dev);
|
| 106 | void drmm_add_final_kfree(struct drm_device *dev, void *container);
|
| 107 |
|
| 108 |
|
| 109 | static inline bool drm_vblank_passed(u64 seq, u64 ref)
|
| 110 | {
|
| 111 | return (seq - ref) <= (1 << 23);
|
| 112 | }
|
| 113 |
|
| 114 | void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
|
| 115 | int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
|
| 116 | void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
|
| 117 | u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
|
| 118 |
|
| 119 |
|
| 120 | static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
|
| 121 | {
|
| 122 | kthread_flush_worker(vblank->worker);
|
| 123 | }
|
| 124 |
|
| 125 | static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
|
| 126 | {
|
| 127 | if (vblank->worker)
|
| 128 | kthread_destroy_worker(vblank->worker);
|
| 129 | }
|
| 130 |
|
| 131 | int drm_vblank_worker_init(struct drm_vblank_crtc *vblank);
|
| 132 | void drm_vblank_cancel_pending_works(struct drm_vblank_crtc *vblank);
|
| 133 | void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
|
| 134 |
|
| 135 |
|
| 136 | int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
|
| 137 | struct drm_file *filp);
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 | int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
|
| 143 | struct drm_file *filp);
|
| 144 |
|
| 145 | int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
|
| 146 | struct drm_file *filp);
|
| 147 |
|
| 148 |
|
| 149 | int drm_getmagic(struct drm_device *dev, void *data,
|
| 150 | struct drm_file *file_priv);
|
| 151 | int drm_authmagic(struct drm_device *dev, void *data,
|
| 152 | struct drm_file *file_priv);
|
| 153 | int drm_setmaster_ioctl(struct drm_device *dev, void *data,
|
| 154 | struct drm_file *file_priv);
|
| 155 | int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
|
| 156 | struct drm_file *file_priv);
|
| 157 | int drm_master_open(struct drm_file *file_priv);
|
| 158 | void drm_master_release(struct drm_file *file_priv);
|
| 159 | bool drm_master_internal_acquire(struct drm_device *dev);
|
| 160 | void drm_master_internal_release(struct drm_device *dev);
|
| 161 |
|
| 162 |
|
| 163 | extern struct class *drm_class;
|
| 164 |
|
| 165 | int drm_sysfs_init(void);
|
| 166 | void drm_sysfs_destroy(void);
|
| 167 | struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
|
| 168 | int drm_sysfs_connector_add(struct drm_connector *connector);
|
| 169 | int drm_sysfs_connector_add_late(struct drm_connector *connector);
|
| 170 | void drm_sysfs_connector_remove_early(struct drm_connector *connector);
|
| 171 | void drm_sysfs_connector_remove(struct drm_connector *connector);
|
| 172 |
|
| 173 | void drm_sysfs_lease_event(struct drm_device *dev);
|
| 174 |
|
| 175 |
|
| 176 | int drm_gem_init(struct drm_device *dev);
|
| 177 | bool drm_gem_object_handle_get_if_exists_unlocked(struct drm_gem_object *obj);
|
| 178 | void drm_gem_object_handle_put_unlocked(struct drm_gem_object *obj);
|
| 179 | int drm_gem_handle_create_tail(struct drm_file *file_priv,
|
| 180 | struct drm_gem_object *obj,
|
| 181 | u32 *handlep);
|
| 182 | int drm_gem_close_ioctl(struct drm_device *dev, void *data,
|
| 183 | struct drm_file *file_priv);
|
| 184 | int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
|
| 185 | struct drm_file *file_priv);
|
| 186 | int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
|
| 187 | struct drm_file *file_priv);
|
| 188 | int drm_gem_open_ioctl(struct drm_device *dev, void *data,
|
| 189 | struct drm_file *file_priv);
|
| 190 | void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
|
| 191 | void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
|
| 192 | void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
|
| 193 | const struct drm_gem_object *obj);
|
| 194 |
|
| 195 | int drm_gem_vmap_locked(struct drm_gem_object *obj, struct iosys_map *map);
|
| 196 | void drm_gem_vunmap_locked(struct drm_gem_object *obj, struct iosys_map *map);
|
| 197 |
|
| 198 |
|
| 199 | #if defined(CONFIG_DEBUG_FS)
|
| 200 | void drm_debugfs_dev_fini(struct drm_device *dev);
|
| 201 | void drm_debugfs_dev_register(struct drm_device *dev);
|
| 202 | int drm_debugfs_register(struct drm_minor *minor, int minor_id);
|
| 203 | void drm_debugfs_unregister(struct drm_minor *minor);
|
| 204 | void drm_debugfs_connector_add(struct drm_connector *connector);
|
| 205 | void drm_debugfs_connector_remove(struct drm_connector *connector);
|
| 206 | void drm_debugfs_crtc_add(struct drm_crtc *crtc);
|
| 207 | void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
|
| 208 | void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
|
| 209 | void drm_debugfs_encoder_add(struct drm_encoder *encoder);
|
| 210 | void drm_debugfs_encoder_remove(struct drm_encoder *encoder);
|
| 211 | #else
|
| 212 | static inline void drm_debugfs_dev_fini(struct drm_device *dev)
|
| 213 | {
|
| 214 | }
|
| 215 |
|
| 216 | static inline void drm_debugfs_dev_register(struct drm_device *dev)
|
| 217 | {
|
| 218 | }
|
| 219 |
|
| 220 | static inline int drm_debugfs_register(struct drm_minor *minor, int minor_id)
|
| 221 | {
|
| 222 | return 0;
|
| 223 | }
|
| 224 |
|
| 225 | static inline void drm_debugfs_unregister(struct drm_minor *minor)
|
| 226 | {
|
| 227 | }
|
| 228 |
|
| 229 | static inline void drm_debugfs_connector_add(struct drm_connector *connector)
|
| 230 | {
|
| 231 | }
|
| 232 | static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
|
| 233 | {
|
| 234 | }
|
| 235 |
|
| 236 | static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
|
| 237 | {
|
| 238 | }
|
| 239 | static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
|
| 240 | {
|
| 241 | }
|
| 242 |
|
| 243 | static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
|
| 244 | {
|
| 245 | }
|
| 246 |
|
| 247 | static inline void drm_debugfs_encoder_add(struct drm_encoder *encoder)
|
| 248 | {
|
| 249 | }
|
| 250 |
|
| 251 | static inline void drm_debugfs_encoder_remove(struct drm_encoder *encoder)
|
| 252 | {
|
| 253 | }
|
| 254 |
|
| 255 | #endif
|
| 256 |
|
| 257 | drm_ioctl_t drm_version;
|
| 258 | drm_ioctl_t drm_getunique;
|
| 259 | drm_ioctl_t drm_getclient;
|
| 260 |
|
| 261 |
|
| 262 | void drm_syncobj_open(struct drm_file *file_private);
|
| 263 | void drm_syncobj_release(struct drm_file *file_private);
|
| 264 | int drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
|
| 265 | struct drm_file *file_private);
|
| 266 | int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
|
| 267 | struct drm_file *file_private);
|
| 268 | int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
|
| 269 | struct drm_file *file_private);
|
| 270 | int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
|
| 271 | struct drm_file *file_private);
|
| 272 | int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
|
| 273 | struct drm_file *file_private);
|
| 274 | int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
|
| 275 | struct drm_file *file_private);
|
| 276 | int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
|
| 277 | struct drm_file *file_private);
|
| 278 | int drm_syncobj_eventfd_ioctl(struct drm_device *dev, void *data,
|
| 279 | struct drm_file *file_private);
|
| 280 | int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
|
| 281 | struct drm_file *file_private);
|
| 282 | int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
|
| 283 | struct drm_file *file_private);
|
| 284 | int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
|
| 285 | struct drm_file *file_private);
|
| 286 | int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
|
| 287 | struct drm_file *file_private);
|
| 288 |
|
| 289 |
|
| 290 | void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
|
| 291 | const struct drm_framebuffer *fb);
|
| 292 | void drm_framebuffer_debugfs_init(struct drm_device *dev);
|
| 293 |
|
| 294 | #endif
|